-FROM centos:5
+# We use Debian 6 (glibc 2.11, kernel 2.6.32) as a common base for other
+# distros that still need Rust support: RHEL 6 (glibc 2.12, kernel 2.6.32) and
+# SLES 11 SP4 (glibc 2.11, kernel 3.0).
+FROM debian:6
WORKDIR /build
-# Centos 5 is EOL and is no longer available from the usual mirrors, so switch
-# to http://vault.centos.org/
-RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
-RUN sed -i 's/mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo
-RUN sed -i 's|#\(baseurl.*\)mirror.centos.org/centos/$releasever|\1vault.centos.org/5.11|' /etc/yum.repos.d/*.repo
+# Debian 6 is EOL and no longer available from the usual mirrors,
+# so we'll need to switch to http://archive.debian.org/
+RUN sed -i '/updates/d' /etc/apt/sources.list && \
+ sed -i 's/httpredir/archive/' /etc/apt/sources.list
-RUN yum upgrade -y && yum install -y \
- curl \
+RUN apt-get update && \
+ apt-get install --allow-unauthenticated -y --no-install-recommends \
+ automake \
bzip2 \
+ ca-certificates \
+ curl \
+ file \
+ g++ \
+ g++-multilib \
gcc \
- gcc-c++ \
+ gcc-multilib \
+ git \
+ lib32z1-dev \
+ libedit-dev \
+ libncurses-dev \
make \
- glibc-devel \
+ patch \
perl \
- zlib-devel \
- file \
- xz \
- which \
- pkgconfig \
+ pkg-config \
+ unzip \
wget \
- autoconf \
- gettext
+ xz-utils \
+ zlib1g-dev
ENV PATH=/rustroot/bin:$PATH
-ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
+ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib
ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
WORKDIR /tmp
+RUN mkdir /home/user
COPY host-x86_64/dist-x86_64-linux/shared.sh /tmp/
# We need a build of openssl which supports SNI to download artifacts from
COPY host-x86_64/dist-x86_64-linux/build-openssl.sh /tmp/
RUN ./build-openssl.sh
-# The `curl` binary on CentOS doesn't support SNI which is needed for fetching
+# The `curl` binary on Debian 6 doesn't support SNI which is needed for fetching
# some https urls we have, so install a new version of libcurl + curl which is
# using the openssl we just built previously.
#
# Note that we also disable a bunch of optional features of curl that we don't
# really need.
COPY host-x86_64/dist-x86_64-linux/build-curl.sh /tmp/
-RUN ./build-curl.sh
+RUN ./build-curl.sh && apt-get remove -y curl
# binutils < 2.22 has a bug where the 32-bit executables it generates
# immediately segfault in Rust, so we need to install our own binutils.
COPY host-x86_64/dist-x86_64-linux/build-binutils.sh /tmp/
RUN ./build-binutils.sh
-# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
-# only has 2.6.4, so build our own
-COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
-RUN ./build-cmake.sh
-
-# Need a newer version of gcc than centos has to compile LLVM nowadays
+# Need at least GCC 5.1 to compile LLVM nowadays
COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
-RUN ./build-gcc.sh
+RUN ./build-gcc.sh && apt-get remove -y gcc g++
-# CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+
+# Debian 6 has Python 2.6 by default, but LLVM needs 2.7+
COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh
-# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
+# LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4.
+COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
+RUN ./build-cmake.sh
+
+# Now build LLVM+Clang, afterwards configuring further compilations to use the
# clang/clang++ compilers.
-COPY host-x86_64/dist-x86_64-linux/build-clang.sh host-x86_64/dist-x86_64-linux/llvm-project-centos.patch /tmp/
+COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
ENV CC=clang CXX=clang++
-# Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for
-# cloning, so download and build it here.
-COPY host-x86_64/dist-x86_64-linux/build-git.sh /tmp/
-RUN ./build-git.sh
-
-# for sanitizers, we need kernel headers files newer than the ones CentOS ships
-# with so we install newer ones here
-COPY host-x86_64/dist-x86_64-linux/build-headers.sh /tmp/
-RUN ./build-headers.sh
-
-# OpenSSL requires a more recent version of perl
-# with so we install newer ones here
-COPY host-x86_64/dist-x86_64-linux/build-perl.sh /tmp/
-RUN ./build-perl.sh
-
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
# libcurl, instead it should compile its own.
ENV LIBCURL_NO_PKG_CONFIG 1
+# There was a bad interaction between "old" 32-bit binaries on current 64-bit
+# kernels with selinux enabled, where ASLR mmap would sometimes choose a low
+# address and then block it for being below `vm.mmap_min_addr` -> `EACCES`.
+# This is probably a kernel bug, but setting `ulimit -Hs` works around it.
+# See also `src/ci/run.sh` where this takes effect.
+ENV SET_HARD_RLIMIT_STACK 1
+
ENV DIST_REQUIRE_ALL_TOOLS 1
-FROM centos:5
+# We use Debian 6 (glibc 2.11, kernel 2.6.32) as a common base for other
+# distros that still need Rust support: RHEL 6 (glibc 2.12, kernel 2.6.32) and
+# SLES 11 SP4 (glibc 2.11, kernel 3.0).
+FROM debian:6
WORKDIR /build
-# Centos 5 is EOL and is no longer available from the usual mirrors, so switch
-# to http://vault.centos.org/
-RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
-RUN sed -i 's/mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo
-RUN sed -i 's|#\(baseurl.*\)mirror.centos.org/centos/$releasever|\1vault.centos.org/5.11|' /etc/yum.repos.d/*.repo
+# Debian 6 is EOL and no longer available from the usual mirrors,
+# so we'll need to switch to http://archive.debian.org/
+RUN sed -i '/updates/d' /etc/apt/sources.list && \
+ sed -i 's/httpredir/archive/' /etc/apt/sources.list
-RUN yum upgrade -y && yum install -y \
- curl \
+RUN apt-get update && \
+ apt-get install --allow-unauthenticated -y --no-install-recommends \
+ automake \
bzip2 \
+ ca-certificates \
+ curl \
+ file \
+ g++ \
+ g++-multilib \
gcc \
- gcc-c++ \
+ gcc-multilib \
+ git \
+ lib32z1-dev \
+ libedit-dev \
+ libncurses-dev \
make \
- glibc-devel \
+ patch \
perl \
- zlib-devel \
- file \
- xz \
- which \
- pkgconfig \
+ pkg-config \
+ unzip \
wget \
- autoconf \
- gettext
+ xz-utils \
+ zlib1g-dev
ENV PATH=/rustroot/bin:$PATH
-ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
+ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib
ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
WORKDIR /tmp
+RUN mkdir /home/user
COPY host-x86_64/dist-x86_64-linux/shared.sh /tmp/
# We need a build of openssl which supports SNI to download artifacts from
COPY host-x86_64/dist-x86_64-linux/build-openssl.sh /tmp/
RUN ./build-openssl.sh
-# The `curl` binary on CentOS doesn't support SNI which is needed for fetching
+# The `curl` binary on Debian 6 doesn't support SNI which is needed for fetching
# some https urls we have, so install a new version of libcurl + curl which is
# using the openssl we just built previously.
#
# Note that we also disable a bunch of optional features of curl that we don't
# really need.
COPY host-x86_64/dist-x86_64-linux/build-curl.sh /tmp/
-RUN ./build-curl.sh
+RUN ./build-curl.sh && apt-get remove -y curl
# binutils < 2.22 has a bug where the 32-bit executables it generates
# immediately segfault in Rust, so we need to install our own binutils.
COPY host-x86_64/dist-x86_64-linux/build-binutils.sh /tmp/
RUN ./build-binutils.sh
-# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
-# only has 2.6.4, so build our own
-COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
-RUN ./build-cmake.sh
-
-# Build a version of gcc capable of building LLVM 6
+# Need at least GCC 5.1 to compile LLVM nowadays
COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
-RUN ./build-gcc.sh
+RUN ./build-gcc.sh && apt-get remove -y gcc g++
-# CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+
+# Debian 6 has Python 2.6 by default, but LLVM needs 2.7+
COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh
-# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
+# LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4.
+COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
+RUN ./build-cmake.sh
+
+# Now build LLVM+Clang, afterwards configuring further compilations to use the
# clang/clang++ compilers.
-COPY host-x86_64/dist-x86_64-linux/build-clang.sh host-x86_64/dist-x86_64-linux/llvm-project-centos.patch /tmp/
+COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
ENV CC=clang CXX=clang++
-# Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for
-# cloning, so download and build it here.
-COPY host-x86_64/dist-x86_64-linux/build-git.sh /tmp/
-RUN ./build-git.sh
-
-# for sanitizers, we need kernel headers files newer than the ones CentOS ships
-# with so we install newer ones here
-COPY host-x86_64/dist-x86_64-linux/build-headers.sh /tmp/
-RUN ./build-headers.sh
-
-# OpenSSL requires a more recent version of perl
-# with so we install newer ones here
-COPY host-x86_64/dist-x86_64-linux/build-perl.sh /tmp/
-RUN ./build-perl.sh
-
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
curl -L https://github.com/llvm/llvm-project/archive/$LLVM.tar.gz | \
tar xzf - --strip-components=1
-yum install -y patch
-patch -Np1 < ../llvm-project-centos.patch
-
mkdir clang-build
cd clang-build
set -ex
source shared.sh
-curl https://cmake.org/files/v3.6/cmake-3.6.3.tar.gz | tar xzf -
+CMAKE=3.13.4
+curl -L https://github.com/Kitware/CMake/releases/download/v$CMAKE/cmake-$CMAKE.tar.gz | tar xzf -
mkdir cmake-build
cd cmake-build
-hide_output ../cmake-3.6.3/configure --prefix=/rustroot
+hide_output ../cmake-$CMAKE/configure --prefix=/rustroot
hide_output make -j10
hide_output make install
cd ..
rm -rf cmake-build
-rm -rf cmake-3.6.3
+rm -rf cmake-$CMAKE
cd ..
rm -rf curl-build
rm -rf curl-$VERSION
-yum erase -y curl
cd ..
rm -rf gcc-build
rm -rf gcc-$GCC
-yum erase -y gcc gcc-c++ binutils
ulimit -c unlimited
fi
+# There was a bad interaction between "old" 32-bit binaries on current 64-bit
+# kernels with selinux enabled, where ASLR mmap would sometimes choose a low
+# address and then block it for being below `vm.mmap_min_addr` -> `EACCES`.
+# This is probably a kernel bug, but setting `ulimit -Hs` works around it.
+# See also `dist-i686-linux` where this setting is enabled.
+if [ "$SET_HARD_RLIMIT_STACK" = "1" ]; then
+ rlimit_stack=$(ulimit -Ss)
+ if [ "$rlimit_stack" != "" ]; then
+ ulimit -Hs "$rlimit_stack"
+ fi
+fi
+
ci_dir=`cd $(dirname $0) && pwd`
source "$ci_dir/shared.sh"
/// any other key, as determined by the [`Ord`] trait, changes while it is in the map. This is
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
///
-/// [`Ord`]: ../../std/cmp/trait.Ord.html
-/// [`Cell`]: ../../std/cell/struct.Cell.html
-/// [`RefCell`]: ../../std/cell/struct.RefCell.html
+/// [`Ord`]: core::cmp::Ord
+/// [`Cell`]: core::cell::Cell
+/// [`RefCell`]: core::cell::RefCell
///
/// # Examples
///
/// This `struct` is created by the [`iter`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`iter`]: struct.BTreeMap.html#method.iter
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`iter`]: BTreeMap::iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, K: 'a, V: 'a> {
range: Range<'a, K, V>,
/// This `struct` is created by the [`iter_mut`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`iter_mut`]: struct.BTreeMap.html#method.iter_mut
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`iter_mut`]: BTreeMap::iter_mut
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct IterMut<'a, K: 'a, V: 'a> {
/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`]
/// (provided by the `IntoIterator` trait). See its documentation for more.
///
-/// [`into_iter`]: struct.BTreeMap.html#method.into_iter
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`into_iter`]: IntoIterator::into_iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<K, V> {
front: Option<Handle<NodeRef<marker::Owned, K, V, marker::Leaf>, marker::Edge>>,
/// This `struct` is created by the [`keys`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`keys`]: struct.BTreeMap.html#method.keys
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`keys`]: BTreeMap::keys
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Keys<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
/// This `struct` is created by the [`values`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`values`]: struct.BTreeMap.html#method.values
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`values`]: BTreeMap::values
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Values<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
/// This `struct` is created by the [`values_mut`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`values_mut`]: struct.BTreeMap.html#method.values_mut
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`values_mut`]: BTreeMap::values_mut
#[stable(feature = "map_values_mut", since = "1.10.0")]
#[derive(Debug)]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
/// This `struct` is created by the [`range`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`range`]: struct.BTreeMap.html#method.range
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`range`]: BTreeMap::range
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct Range<'a, K: 'a, V: 'a> {
front: Option<Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>>,
/// This `struct` is created by the [`range_mut`] method on [`BTreeMap`]. See its
/// documentation for more.
///
-/// [`range_mut`]: struct.BTreeMap.html#method.range_mut
-/// [`BTreeMap`]: struct.BTreeMap.html
+/// [`range_mut`]: BTreeMap::range_mut
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct RangeMut<'a, K: 'a, V: 'a> {
front: Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>>,
///
/// This `enum` is constructed from the [`entry`] method on [`BTreeMap`].
///
-/// [`BTreeMap`]: struct.BTreeMap.html
-/// [`entry`]: struct.BTreeMap.html#method.entry
+/// [`entry`]: BTreeMap::entry
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Entry<'a, K: 'a, V: 'a> {
/// A vacant entry.
/// to any other item, as determined by the [`Ord`] trait, changes while it is in the set. This is
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
///
-/// [`Ord`]: ../../std/cmp/trait.Ord.html
-/// [`Cell`]: ../../std/cell/struct.Cell.html
-/// [`RefCell`]: ../../std/cell/struct.RefCell.html
+/// [`Ord`]: core::cmp::Ord
+/// [`Cell`]: core::cell::Cell
+/// [`RefCell`]: core::cell::RefCell
///
/// # Examples
///
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
/// replaces them with the replacement string slice.
///
- /// [`String`]: string/struct.String.html
- ///
/// # Examples
///
/// Basic usage:
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
/// replaces them with the replacement string slice at most `count` times.
///
- /// [`String`]: string/struct.String.html
- ///
/// # Examples
///
/// Basic usage:
/// the case, this function returns a [`String`] instead of modifying the
/// parameter in-place.
///
- /// [`String`]: string/struct.String.html
- ///
/// # Examples
///
/// Basic usage:
/// the case, this function returns a [`String`] instead of modifying the
/// parameter in-place.
///
- /// [`String`]: string/struct.String.html
- ///
/// # Examples
///
/// Basic usage:
/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
///
- /// [`String`]: string/struct.String.html
- /// [`Box<str>`]: boxed/struct.Box.html
+ /// [`Box<str>`]: Box
///
/// # Examples
///
///
/// This function will panic if the capacity would overflow.
///
- /// [`String`]: string/struct.String.html
- ///
/// # Examples
///
/// Basic usage:
/// assert_eq!("GRüßE, JüRGEN ❤", s.to_ascii_uppercase());
/// ```
///
- /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
+ /// [`make_ascii_uppercase`]: str::make_ascii_uppercase
/// [`to_uppercase`]: #method.to_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline]
/// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase());
/// ```
///
- /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
+ /// [`make_ascii_lowercase`]: str::make_ascii_lowercase
/// [`to_lowercase`]: #method.to_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline]
//! [`ToString`]s, and several error types that may result from working with
//! [`String`]s.
//!
-//! [`ToString`]: trait.ToString.html
-//!
//! # Examples
//!
//! There are multiple ways to create a new [`String`] from a string literal:
//! You can create a new [`String`] from an existing one by concatenating with
//! `+`:
//!
-//! [`String`]: struct.String.html
-//!
//! ```
//! let s = "Hello".to_string();
//!
/// contents of the string. It has a close relationship with its borrowed
/// counterpart, the primitive [`str`].
///
-/// [`str`]: ../../std/primitive.str.html
-///
/// # Examples
///
-/// You can create a `String` from a literal string with [`String::from`]:
+/// You can create a `String` from [a literal string][str] with [`String::from`]:
+///
+/// [`String::from`]: From::from
///
/// ```
/// let hello = String::from("Hello, world!");
/// hello.push_str("orld!");
/// ```
///
-/// [`String::from`]: #method.from
-/// [`char`]: ../../std/primitive.char.html
-/// [`push`]: #method.push
-/// [`push_str`]: #method.push_str
+/// [`push`]: String::push
+/// [`push_str`]: String::push_str
///
/// If you have a vector of UTF-8 bytes, you can create a `String` from it with
/// the [`from_utf8`] method:
/// assert_eq!("💖", sparkle_heart);
/// ```
///
-/// [`from_utf8`]: #method.from_utf8
+/// [`from_utf8`]: String::from_utf8
///
/// # UTF-8
///
/// The [`bytes`] and [`chars`] methods return iterators over the first
/// two, respectively.
///
-/// [`bytes`]: #method.bytes
-/// [`chars`]: #method.chars
+/// [`bytes`]: str::bytes
+/// [`chars`]: str::chars
///
/// # Deref
///
/// assert_eq!(String::from("Once upon a time..."), s);
/// ```
///
-/// [`as_ptr`]: #method.as_ptr
-/// [`len`]: #method.len
-/// [`capacity`]: #method.capacity
+/// [`as_ptr`]: str::as_ptr
+/// [`len`]: String::len
+/// [`capacity`]: String::capacity
///
/// If a `String` has enough capacity, adding elements to it will not
/// re-allocate. For example, consider this program:
/// }
/// ```
///
-/// [`with_capacity`]: #method.with_capacity
+/// [`with_capacity`]: String::with_capacity
///
/// We end up with a different output:
///
///
/// Here, there's no need to allocate more memory inside the loop.
///
-/// [`&str`]: ../../std/primitive.str.html
-/// [`Deref`]: ../../std/ops/trait.Deref.html
-/// [`as_str()`]: struct.String.html#method.as_str
+/// [`&str`]: str
+/// [`Deref`]: core::ops::Deref
+/// [`as_str()`]: String::as_str
#[derive(PartialOrd, Eq, Ord)]
#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")]
#[stable(feature = "rust1", since = "1.0.0")]
/// [`into_bytes`] method will give back the byte vector that was used in the
/// conversion attempt.
///
-/// [`from_utf8`]: struct.String.html#method.from_utf8
-/// [`String`]: struct.String.html
-/// [`into_bytes`]: struct.FromUtf8Error.html#method.into_bytes
+/// [`from_utf8`]: String::from_utf8
+/// [`into_bytes`]: FromUtf8Error::into_bytes
///
/// The [`Utf8Error`] type provided by [`std::str`] represents an error that may
/// occur when converting a slice of [`u8`]s to a [`&str`]. In this sense, it's
/// an analogue to `FromUtf8Error`, and you can get one from a `FromUtf8Error`
/// through the [`utf8_error`] method.
///
-/// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
-/// [`std::str`]: ../../std/str/index.html
-/// [`u8`]: ../../std/primitive.u8.html
-/// [`&str`]: ../../std/primitive.str.html
-/// [`utf8_error`]: #method.utf8_error
+/// [`Utf8Error`]: core::str::Utf8Error
+/// [`std::str`]: core::str
+/// [`&str`]: str
+/// [`utf8_error`]: Self::utf8_error
///
/// # Examples
///
///
/// This type is the error type for the [`from_utf16`] method on [`String`].
///
-/// [`from_utf16`]: struct.String.html#method.from_utf16
-/// [`String`]: struct.String.html
-///
+/// [`from_utf16`]: String::from_utf16
/// # Examples
///
/// Basic usage:
/// consider the [`with_capacity`] method to prevent excessive
/// re-allocation.
///
- /// [`with_capacity`]: #method.with_capacity
+ /// [`with_capacity`]: String::with_capacity
///
/// # Examples
///
/// appending a bunch of data to the `String`, reducing the number of
/// reallocations it needs to do.
///
- /// [`capacity`]: #method.capacity
+ /// [`capacity`]: String::capacity
///
/// If the given capacity is `0`, no allocation will occur, and this method
/// is identical to the [`new`] method.
///
- /// [`new`]: #method.new
+ /// [`new`]: String::new
///
/// # Examples
///
/// See the docs for [`FromUtf8Error`] for more details on what you can do
/// with this error.
///
- /// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked
- /// [`String`]: struct.String.html
- /// [`u8`]: ../../std/primitive.u8.html
- /// [`Vec<u8>`]: ../../std/vec/struct.Vec.html
- /// [`&str`]: ../../std/primitive.str.html
- /// [`str::from_utf8`]: ../../std/str/fn.from_utf8.html
- /// [`into_bytes`]: struct.String.html#method.into_bytes
- /// [`FromUtf8Error`]: struct.FromUtf8Error.html
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
+ /// [`from_utf8_unchecked`]: String::from_utf8_unchecked
+ /// [`Vec<u8>`]: crate::vec::Vec
+ /// [`&str`]: str
+ /// [`into_bytes`]: String::into_bytes
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
///
- /// [`u8`]: ../../std/primitive.u8.html
/// [byteslice]: ../../std/primitive.slice.html
- /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
+ /// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
///
/// If you are sure that the byte slice is valid UTF-8, and you don't want
/// to incur the overhead of the conversion, there is an unsafe version
/// of this function, [`from_utf8_unchecked`], which has the same behavior
/// but skips the checks.
///
- /// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked
+ /// [`from_utf8_unchecked`]: String::from_utf8_unchecked
///
/// This function returns a [`Cow<'a, str>`]. If our byte slice is invalid
/// UTF-8, then we need to insert the replacement characters, which will
/// it's already valid UTF-8, we don't need a new allocation. This return
/// type allows us to handle both cases.
///
- /// [`Cow<'a, str>`]: ../../std/borrow/enum.Cow.html
+ /// [`Cow<'a, str>`]: crate::borrow::Cow
///
/// # Examples
///
/// Decode a UTF-16 encoded vector `v` into a `String`, returning [`Err`]
/// if `v` contains any invalid data.
///
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- ///
/// # Examples
///
/// Basic usage:
/// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
/// conversion requires a memory allocation.
///
- /// [`from_utf8_lossy`]: #method.from_utf8_lossy
- /// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
- /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
+ /// [`from_utf8_lossy`]: String::from_utf8_lossy
+ /// [`Cow<'a, str>`]: crate::borrow::Cow
+ /// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
///
/// # Examples
///
/// into a `String` with the [`from_raw_parts`] function, allowing
/// the destructor to perform the cleanup.
///
- /// [`from_raw_parts`]: #method.from_raw_parts
+ /// [`from_raw_parts`]: String::from_raw_parts
///
/// # Examples
///
///
/// See the safe version, [`from_utf8`], for more details.
///
- /// [`from_utf8`]: struct.String.html#method.from_utf8
+ /// [`from_utf8`]: String::from_utf8
///
/// # Safety
///
///
/// Panics if the new capacity overflows [`usize`].
///
- /// [`reserve_exact`]: struct.String.html#method.reserve_exact
- /// [`usize`]: ../../std/primitive.usize.html
+ /// [`reserve_exact`]: String::reserve_exact
///
/// # Examples
///
/// Consider using the [`reserve`] method unless you absolutely know
/// better than the allocator.
///
- /// [`reserve`]: #method.reserve
+ /// [`reserve`]: String::reserve
///
/// # Panics
///
/// Appends the given [`char`] to the end of this `String`.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
///
/// The inverse of this method is [`from_utf8`].
///
- /// [`from_utf8`]: #method.from_utf8
+ /// [`from_utf8`]: String::from_utf8
///
/// # Examples
///
///
/// Panics if `new_len` does not lie on a [`char`] boundary.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
///
/// Returns [`None`] if this `String` is empty.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- ///
/// # Examples
///
/// Basic usage:
/// Panics if `idx` is larger than or equal to the `String`'s length,
/// or if it does not lie on a [`char`] boundary.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
/// Panics if `idx` is larger than the `String`'s length, or if it does not
/// lie on a [`char`] boundary.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
/// Panics if `idx` is larger than the `String`'s length, or if it does not
/// lie on a [`char`] boundary.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
/// Panics if the starting point or end point do not lie on a [`char`]
/// boundary, or if they're out of bounds.
///
- /// [`char`]: ../../std/primitive.char.html
- ///
/// # Examples
///
/// Basic usage:
/// Panics if the starting point or end point do not lie on a [`char`]
/// boundary, or if they're out of bounds.
///
- /// [`char`]: ../../std/primitive.char.html
- /// [`Vec::splice`]: ../../std/vec/struct.Vec.html#method.splice
- ///
/// # Examples
///
/// Basic usage:
///
/// This will drop any excess capacity.
///
- /// [`Box`]: ../../std/boxed/struct.Box.html
- /// [`str`]: ../../std/primitive.str.html
- ///
/// # Examples
///
/// Basic usage:
/// an analogue to `FromUtf8Error`. See its documentation for more details
/// on using it.
///
- /// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
- /// [`std::str`]: ../../std/str/index.html
- /// [`u8`]: ../../std/primitive.u8.html
- /// [`&str`]: ../../std/primitive.str.html
+ /// [`std::str`]: core::str
+ /// [`&str`]: str
///
/// # Examples
///
///
/// This alias exists for backwards compatibility, and may be eventually deprecated.
///
-/// [`Infallible`]: ../../core/convert/enum.Infallible.html
+/// [`Infallible`]: core::convert::Infallible
#[stable(feature = "str_parse_error", since = "1.5.0")]
pub type ParseError = core::convert::Infallible;
/// [`Display`] should be implemented instead, and you get the `ToString`
/// implementation for free.
///
-/// [`Display`]: ../../std/fmt/trait.Display.html
+/// [`Display`]: fmt::Display
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ToString {
/// Converts the given value to a `String`.
/// This struct is created by the [`drain`] method on [`String`]. See its
/// documentation for more.
///
-/// [`drain`]: struct.String.html#method.drain
-/// [`String`]: struct.String.html
+/// [`drain`]: String::drain
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a> {
/// Will be used as &'a mut String in the destructor
//!
//! For more details, see the [`std::str`] module.
//!
-//! [`std::str`]: ../../std/str/index.html
+//! [`std::str`]: self
#![stable(feature = "rust1", since = "1.0.0")]
/// Errors which can occur when attempting to interpret a sequence of [`u8`]
/// as a string.
///
-/// [`u8`]: ../../std/primitive.u8.html
-///
/// As such, the `from_utf8` family of functions and methods for both [`String`]s
/// and [`&str`]s make use of this error, for example.
///
/// [`String`]: ../../std/string/struct.String.html#method.from_utf8
-/// [`&str`]: ../../std/str/fn.from_utf8.html
+/// [`&str`]: from_utf8
///
/// # Examples
///
("powerpc64-wrs-vxworks", powerpc64_wrs_vxworks),
("mipsel-sony-psp", mipsel_sony_psp),
+ ("thumbv4t-none-eabi", thumbv4t_none_eabi),
}
/// Everything `rustc` knows about how to compile for a specific target.
--- /dev/null
+//! Targets the ARMv4T, with code as `t32` code by default.
+//!
+//! Primarily of use for the GBA, but usable with other devices too.
+//!
+//! Please ping @Lokathor if changes are needed.
+//!
+//! This target profile assumes that you have the ARM binutils in your path (specifically the linker, `arm-none-eabi-ld`). They can be obtained for free for all major OSes from the ARM developer's website, and they may also be available in your system's package manager. Unfortunately, the standard linker that Rust uses (`lld`) only supports as far back as `ARMv5TE`, so we must use the GNU `ld` linker.
+//!
+//! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.
+
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+
+pub fn target() -> TargetResult {
+ Ok(Target {
+ llvm_target: "thumbv4t-none-eabi".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "32".to_string(),
+ target_c_int_width: "32".to_string(),
+ target_os: "none".to_string(),
+ target_env: "".to_string(),
+ target_vendor: "".to_string(),
+ arch: "arm".to_string(),
+ /* Data layout args are '-' separated:
+ * little endian
+ * stack is 64-bit aligned (EABI)
+ * pointers are 32-bit
+ * i64 must be 64-bit aligned (EABI)
+ * mangle names with ELF style
+ * native integers are 32-bit
+ * All other elements are default
+ */
+ data_layout: "e-S64-p:32:32-i64:64-m:e-n32".to_string(),
+ linker_flavor: LinkerFlavor::Ld,
+ options: TargetOptions {
+ linker: Some("arm-none-eabi-ld".to_string()),
+ linker_is_gnu: true,
+
+ // extra args passed to the external assembler (assuming `arm-none-eabi-as`):
+ // * activate t32/a32 interworking
+ // * use arch ARMv4T
+ // * use little-endian
+ asm_args: vec![
+ "-mthumb-interwork".to_string(),
+ "-march=armv4t".to_string(),
+ "-mlittle-endian".to_string(),
+ ],
+
+ // minimum extra features, these cannot be disabled via -C
+ features: "+soft-float,+strict-align".to_string(),
+
+ main_needs_argc_argv: false,
+
+ // No thread-local storage (just use a static Cell)
+ has_elf_tls: false,
+
+ // don't have atomic compare-and-swap
+ atomic_cas: false,
+
+ ..super::thumb_base::opts()
+ },
+ })
+}
//! The `#[global_allocator]` can only be used once in a crate
//! or its recursive dependencies.
+#![deny(unsafe_op_in_unsafe_fn)]
#![stable(feature = "alloc_module", since = "1.28.0")]
use core::intrinsics;
#[inline]
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
if layout.size() != 0 {
- GlobalAlloc::dealloc(self, ptr.as_ptr(), layout)
+ // SAFETY: The safety guarantees are explained in the documentation
+ // for the `GlobalAlloc` trait and its `dealloc` method.
+ unsafe { GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) }
}
}
match placement {
ReallocPlacement::InPlace => Err(AllocErr),
ReallocPlacement::MayMove if layout.size() == 0 => {
- let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
+ let new_layout =
+ // SAFETY: The new size and layout alignement guarantees
+ // are transfered to the caller (they come from parameters).
+ //
+ // See the preconditions for `Layout::from_size_align` to
+ // see what must be checked.
+ unsafe { Layout::from_size_align_unchecked(new_size, layout.align()) };
self.alloc(new_layout, init)
}
ReallocPlacement::MayMove => {
- // `realloc` probably checks for `new_size > size` or something similar.
- intrinsics::assume(new_size > size);
- let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size);
- let memory =
- MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size };
- init.init_offset(memory, size);
+ // SAFETY:
+ //
+ // The safety guarantees are explained in the documentation
+ // for the `GlobalAlloc` trait and its `dealloc` method.
+ //
+ // `realloc` probably checks for `new_size > size` or something
+ // similar.
+ //
+ // For the guarantees about `init_offset`, see its documentation:
+ // `ptr` is assumed valid (and checked for non-NUL) and
+ // `memory.size` is set to `new_size` so the offset being `size`
+ // is valid.
+ let memory = unsafe {
+ intrinsics::assume(new_size > size);
+ let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size);
+ let memory =
+ MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size };
+ init.init_offset(memory, size);
+ memory
+ };
Ok(memory)
}
}
match placement {
ReallocPlacement::InPlace => Err(AllocErr),
ReallocPlacement::MayMove if new_size == 0 => {
- self.dealloc(ptr, layout);
+ // SAFETY: see `GlobalAlloc::dealloc` for the guarantees that
+ // must be respected. `ptr` and `layout` are parameters and so
+ // those guarantees must be checked by the caller.
+ unsafe { self.dealloc(ptr, layout) };
Ok(MemoryBlock { ptr: layout.dangling(), size: 0 })
}
ReallocPlacement::MayMove => {
- // `realloc` probably checks for `new_size < size` or something similar.
- intrinsics::assume(new_size < size);
- let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size);
- Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size })
+ // SAFETY:
+ //
+ // See `GlobalAlloc::realloc` for more informations about the
+ // guarantees expected by this method. `ptr`, `layout` and
+ // `new_size` are parameters and the responsability for their
+ // correctness is left to the caller.
+ //
+ // `realloc` probably checks for `new_size < size` or something
+ // similar.
+ let memory = unsafe {
+ intrinsics::assume(new_size < size);
+ let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size);
+ MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }
+ };
+ Ok(memory)
}
}
}
#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rdl_alloc(size: usize, align: usize) -> *mut u8 {
- let layout = Layout::from_size_align_unchecked(size, align);
- System.alloc(layout)
+ // SAFETY: see the guarantees expected by `Layout::from_size_align` and
+ // `GlobalAlloc::alloc`.
+ unsafe {
+ let layout = Layout::from_size_align_unchecked(size, align);
+ System.alloc(layout)
+ }
}
#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rdl_dealloc(ptr: *mut u8, size: usize, align: usize) {
- System.dealloc(ptr, Layout::from_size_align_unchecked(size, align))
+ // SAFETY: see the guarantees expected by `Layout::from_size_align` and
+ // `GlobalAlloc::dealloc`.
+ unsafe { System.dealloc(ptr, Layout::from_size_align_unchecked(size, align)) }
}
#[rustc_std_internal_symbol]
align: usize,
new_size: usize,
) -> *mut u8 {
- let old_layout = Layout::from_size_align_unchecked(old_size, align);
- System.realloc(ptr, old_layout, new_size)
+ // SAFETY: see the guarantees expected by `Layout::from_size_align` and
+ // `GlobalAlloc::realloc`.
+ unsafe {
+ let old_layout = Layout::from_size_align_unchecked(old_size, align);
+ System.realloc(ptr, old_layout, new_size)
+ }
}
#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rdl_alloc_zeroed(size: usize, align: usize) -> *mut u8 {
- let layout = Layout::from_size_align_unchecked(size, align);
- System.alloc_zeroed(layout)
+ // SAFETY: see the guarantees expected by `Layout::from_size_align` and
+ // `GlobalAlloc::alloc_zeroed`.
+ unsafe {
+ let layout = Layout::from_size_align_unchecked(size, align);
+ System.alloc_zeroed(layout)
+ }
}
}
/// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`].
/// We must also derive [`PartialEq`].
///
-/// [`Eq`]: ../../std/cmp/trait.Eq.html
-/// [`Hash`]: ../../std/hash/trait.Hash.html
-/// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html
-/// [`RefCell`]: ../../std/cell/struct.RefCell.html
-/// [`Cell`]: ../../std/cell/struct.Cell.html
-/// [`default`]: #method.default
-/// [`with_hasher`]: #method.with_hasher
-/// [`with_capacity_and_hasher`]: #method.with_capacity_and_hasher
+/// [`RefCell`]: crate::cell::RefCell
+/// [`Cell`]: crate::cell::Cell
+/// [`default`]: Default::default
+/// [`with_hasher`]: Self::with_hasher
+/// [`with_capacity_and_hasher`]: Self::with_capacity_and_hasher
/// [`fnv`]: https://crates.io/crates/fnv
///
/// ```
/// let mut map = HashMap::with_hasher(s);
/// map.insert(1, 2);
/// ```
- ///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
/// let mut map = HashMap::with_capacity_and_hasher(10, s);
/// map.insert(1, 2);
/// ```
- ///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {
/// Returns a reference to the map's [`BuildHasher`].
///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
- ///
/// # Examples
///
/// ```
///
/// Panics if the new allocation size overflows [`usize`].
///
- /// [`usize`]: ../../std/primitive.usize.html
- ///
/// # Examples
///
/// ```
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// types that can be `==` without being identical. See the [module-level
/// documentation] for more.
///
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
- /// [module-level documentation]: index.html#insert-and-complex-keys
+ /// [module-level documentation]: crate::collections#insert-and-complex-keys
///
/// # Examples
///
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
/// the key type.
///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
- ///
/// # Examples
///
/// ```
/// This `struct` is created by the [`iter`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`iter`]: struct.HashMap.html#method.iter
-/// [`HashMap`]: struct.HashMap.html
+/// [`iter`]: HashMap::iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, K: 'a, V: 'a> {
base: base::Iter<'a, K, V>,
/// This `struct` is created by the [`iter_mut`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`iter_mut`]: struct.HashMap.html#method.iter_mut
-/// [`HashMap`]: struct.HashMap.html
+/// [`iter_mut`]: HashMap::iter_mut
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IterMut<'a, K: 'a, V: 'a> {
base: base::IterMut<'a, K, V>,
/// This `struct` is created by the [`into_iter`] method on [`HashMap`]
/// (provided by the `IntoIterator` trait). See its documentation for more.
///
-/// [`into_iter`]: struct.HashMap.html#method.into_iter
-/// [`HashMap`]: struct.HashMap.html
+/// [`into_iter`]: IntoIterator::into_iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<K, V> {
base: base::IntoIter<K, V>,
/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`keys`]: struct.HashMap.html#method.keys
-/// [`HashMap`]: struct.HashMap.html
+/// [`keys`]: HashMap::keys
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Keys<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
/// This `struct` is created by the [`values`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`values`]: struct.HashMap.html#method.values
-/// [`HashMap`]: struct.HashMap.html
+/// [`values`]: HashMap::values
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Values<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
/// This `struct` is created by the [`drain`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`drain`]: struct.HashMap.html#method.drain
-/// [`HashMap`]: struct.HashMap.html
+/// [`drain`]: HashMap::drain
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a, K: 'a, V: 'a> {
base: base::Drain<'a, K, V>,
/// This `struct` is created by the [`values_mut`] method on [`HashMap`]. See its
/// documentation for more.
///
-/// [`values_mut`]: struct.HashMap.html#method.values_mut
-/// [`HashMap`]: struct.HashMap.html
+/// [`values_mut`]: HashMap::values_mut
#[stable(feature = "map_values_mut", since = "1.10.0")]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
///
/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
///
-/// [`HashMap::raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
+/// [`HashMap::raw_entry_mut`]: HashMap::raw_entry_mut
#[unstable(feature = "hash_raw_entry", issue = "56167")]
pub struct RawEntryBuilderMut<'a, K: 'a, V: 'a, S: 'a> {
/// This `enum` is constructed through the [`raw_entry_mut`] method on [`HashMap`],
/// then calling one of the methods of that [`RawEntryBuilderMut`].
///
-/// [`HashMap`]: struct.HashMap.html
/// [`Entry`]: enum.Entry.html
-/// [`raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
+/// [`raw_entry_mut`]: HashMap::raw_entry_mut
/// [`RawEntryBuilderMut`]: struct.RawEntryBuilderMut.html
#[unstable(feature = "hash_raw_entry", issue = "56167")]
pub enum RawEntryMut<'a, K: 'a, V: 'a, S: 'a> {
/// A view into an occupied entry in a `HashMap`.
/// It is part of the [`RawEntryMut`] enum.
-///
-/// [`RawEntryMut`]: enum.RawEntryMut.html
#[unstable(feature = "hash_raw_entry", issue = "56167")]
pub struct RawOccupiedEntryMut<'a, K: 'a, V: 'a> {
base: base::RawOccupiedEntryMut<'a, K, V>,
/// A view into a vacant entry in a `HashMap`.
/// It is part of the [`RawEntryMut`] enum.
-///
-/// [`RawEntryMut`]: enum.RawEntryMut.html
#[unstable(feature = "hash_raw_entry", issue = "56167")]
pub struct RawVacantEntryMut<'a, K: 'a, V: 'a, S: 'a> {
base: base::RawVacantEntryMut<'a, K, V, S>,
///
/// See the [`HashMap::raw_entry`] docs for usage examples.
///
-/// [`HashMap::raw_entry`]: struct.HashMap.html#method.raw_entry
+/// [`HashMap::raw_entry`]: HashMap::raw_entry
#[unstable(feature = "hash_raw_entry", issue = "56167")]
pub struct RawEntryBuilder<'a, K: 'a, V: 'a, S: 'a> {
map: &'a HashMap<K, V, S>,
///
/// This `enum` is constructed from the [`entry`] method on [`HashMap`].
///
-/// [`HashMap`]: struct.HashMap.html
-/// [`entry`]: struct.HashMap.html#method.entry
+/// [`entry`]: HashMap::entry
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Entry<'a, K: 'a, V: 'a> {
/// An occupied entry.
/// If you need a reference to the `OccupiedEntry` which may outlive the
/// destruction of the `Entry` value, see [`into_mut`].
///
- /// [`into_mut`]: #method.into_mut
+ /// [`into_mut`]: Self::into_mut
///
/// # Examples
///
///
/// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
///
- /// [`get_mut`]: #method.get_mut
+ /// [`get_mut`]: Self::get_mut
///
/// # Examples
///
/// [`Hasher`], but the hashers created by two different `RandomState`
/// instances are unlikely to produce the same result for the same values.
///
-/// [`HashMap`]: struct.HashMap.html
-/// [`Hasher`]: ../../hash/trait.Hasher.html
-///
/// # Examples
///
/// ```
///
/// The internal algorithm is not specified, and so it and its hashes should
/// not be relied upon over releases.
-///
-/// [`RandomState`]: struct.RandomState.html
-/// [`Hasher`]: ../../hash/trait.Hasher.html
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
#[allow(deprecated)]
#[derive(Clone, Debug)]
/// // use the values stored in the set
/// ```
///
-/// [`Cell`]: ../../std/cell/struct.Cell.html
-/// [`Eq`]: ../../std/cmp/trait.Eq.html
-/// [`Hash`]: ../../std/hash/trait.Hash.html
-/// [`HashMap`]: struct.HashMap.html
-/// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html
-/// [`RefCell`]: ../../std/cell/struct.RefCell.html
+/// [`RefCell`]: crate::cell::RefCell
+/// [`Cell`]: crate::cell::Cell
#[derive(Clone)]
#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_type")]
#[stable(feature = "rust1", since = "1.0.0")]
/// let mut set = HashSet::with_hasher(s);
/// set.insert(2);
/// ```
- ///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
/// let mut set = HashSet::with_capacity_and_hasher(10, s);
/// set.insert(1);
/// ```
- ///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
/// Returns a reference to the set's [`BuildHasher`].
///
- /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
- ///
/// # Examples
///
/// ```
/// assert_eq!(set.contains(&1), true);
/// assert_eq!(set.contains(&4), false);
/// ```
- ///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
/// assert_eq!(set.get(&2), Some(&2));
/// assert_eq!(set.get(&4), None);
/// ```
- ///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
#[inline]
#[stable(feature = "set_recovery", since = "1.9.0")]
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
/// assert_eq!(set.remove(&2), true);
/// assert_eq!(set.remove(&2), false);
/// ```
- ///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
/// assert_eq!(set.take(&2), Some(2));
/// assert_eq!(set.take(&2), None);
/// ```
- ///
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
- /// [`Hash`]: ../../std/hash/trait.Hash.html
#[inline]
#[stable(feature = "set_recovery", since = "1.9.0")]
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
/// This `struct` is created by the [`iter`] method on [`HashSet`].
/// See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`iter`]: struct.HashSet.html#method.iter
+/// [`iter`]: HashSet::iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, K: 'a> {
iter: Keys<'a, K, ()>,
/// This `struct` is created by the [`into_iter`] method on [`HashSet`]
/// (provided by the `IntoIterator` trait). See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`into_iter`]: struct.HashSet.html#method.into_iter
+/// [`into_iter`]: IntoIterator::into_iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<K> {
iter: map::IntoIter<K, ()>,
/// This `struct` is created by the [`drain`] method on [`HashSet`].
/// See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`drain`]: struct.HashSet.html#method.drain
+/// [`drain`]: HashSet::drain
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Drain<'a, K: 'a> {
iter: map::Drain<'a, K, ()>,
/// This `struct` is created by the [`intersection`] method on [`HashSet`].
/// See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`intersection`]: struct.HashSet.html#method.intersection
+/// [`intersection`]: HashSet::intersection
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Intersection<'a, T: 'a, S: 'a> {
// iterator of the first set
/// This `struct` is created by the [`difference`] method on [`HashSet`].
/// See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`difference`]: struct.HashSet.html#method.difference
+/// [`difference`]: HashSet::difference
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Difference<'a, T: 'a, S: 'a> {
// iterator of the first set
/// This `struct` is created by the [`symmetric_difference`] method on
/// [`HashSet`]. See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`symmetric_difference`]: struct.HashSet.html#method.symmetric_difference
+/// [`symmetric_difference`]: HashSet::symmetric_difference
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
iter: Chain<Difference<'a, T, S>, Difference<'a, T, S>>,
/// This `struct` is created by the [`union`] method on [`HashSet`].
/// See its documentation for more.
///
-/// [`HashSet`]: struct.HashSet.html
-/// [`union`]: struct.HashSet.html#method.union
+/// [`union`]: HashSet::union
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Union<'a, T: 'a, S: 'a> {
iter: Chain<Iter<'a, T>, Difference<'a, T, S>>,
//! contract. The implementation of many of these functions are subject to change over
//! time and may call fewer or more syscalls/library functions.
//!
-//! [`Read`]: trait.Read.html
-//! [`Write`]: trait.Write.html
-//! [`Seek`]: trait.Seek.html
-//! [`BufRead`]: trait.BufRead.html
-//! [`File`]: ../fs/struct.File.html
-//! [`TcpStream`]: ../net/struct.TcpStream.html
-//! [`Vec<T>`]: ../vec/struct.Vec.html
-//! [`BufReader`]: struct.BufReader.html
-//! [`BufWriter`]: struct.BufWriter.html
-//! [`Write::write`]: trait.Write.html#tymethod.write
-//! [`io::stdout`]: fn.stdout.html
-//! [`println!`]: ../macro.println.html
-//! [`Lines`]: struct.Lines.html
-//! [`io::Result`]: type.Result.html
+//! [`File`]: crate::fs::File
+//! [`TcpStream`]: crate::net::TcpStream
+//! [`Vec<T>`]: crate::vec::Vec
+//! [`io::stdout`]: stdout
+//! [`io::Result`]: crate::io::Result
//! [`?` operator]: ../../book/appendix-02-operators.html
-//! [`Read::read`]: trait.Read.html#tymethod.read
-//! [`Result`]: ../result/enum.Result.html
-//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
-// ignore-tidy-filelength
+//! [`Result`]: crate::result::Result
+//! [`.unwrap()`]: crate::result::Result::unwrap
#![stable(feature = "rust1", since = "1.0.0")]
/// }
/// ```
///
-/// [`read()`]: trait.Read.html#tymethod.read
-/// [`std::io`]: ../../std/io/index.html
-/// [`File`]: ../fs/struct.File.html
-/// [`BufRead`]: trait.BufRead.html
-/// [`BufReader`]: struct.BufReader.html
-/// [`&str`]: ../../std/primitive.str.html
+/// [`read()`]: Read::read
+/// [`&str`]: str
+/// [`std::io`]: self
+/// [`File`]: crate::fs::File
/// [slice]: ../../std/primitive.slice.html
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(spotlight)]
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
///
- /// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
+ /// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
///
/// # Errors
///
///
/// [`File`]s implement `Read`:
///
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`File`]: ../fs/struct.File.html
+ /// [`Ok(n)`]: Ok
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// This method is unsafe because a `Read`er could otherwise return a
/// non-zeroing `Initializer` from another `Read` type without an `unsafe`
/// block.
- ///
- /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop
- /// [`Initializer`]: ../../std/io/struct.Initializer.html
#[unstable(feature = "read_initializer", issue = "42788")]
#[inline]
unsafe fn initializer(&self) -> Initializer {
///
/// [`File`]s implement `Read`:
///
- /// [`read()`]: trait.Read.html#tymethod.read
- /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`File`]: ../fs/struct.File.html
+ /// [`read()`]: Read::read
+ /// [`Ok(0)`]: Ok
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// (See also the [`std::fs::read`] convenience function for reading from a
/// file.)
///
- /// [`std::fs::read`]: ../fs/fn.read.html
+ /// [`std::fs::read`]: crate::fs::read
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
read_to_end(self, buf)
///
/// See [`read_to_end`][readtoend] for other error semantics.
///
- /// [readtoend]: #method.read_to_end
+ /// [readtoend]: Self::read_to_end
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// (See also the [`std::fs::read_to_string`] convenience function for
/// reading from a file.)
///
- /// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
+ /// [`std::fs::read_to_string`]: crate::fs::read_to_string
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
// Note that we do *not* call `.read_to_end()` here. We are passing
/// No guarantees are provided about the contents of `buf` when this
/// function is called, implementations cannot rely on any property of the
/// contents of `buf` being true. It is recommended that implementations
- /// only write data to `buf` instead of reading its contents.
+ /// only write data to `buf` instead of reading its contents. The
+ /// documentation on [`read`] has a more detailed explanation on this
+ /// subject.
///
/// # Errors
///
///
/// [`File`]s implement `Read`:
///
- /// [`File`]: ../fs/struct.File.html
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
+ /// [`read`]: Read::read
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
- /// [`Iterator`]: ../../std/iter/trait.Iterator.html
- /// [`Result`]: ../../std/result/enum.Result.html
- /// [`io::Error`]: ../../std/io/struct.Error.html
- /// [`u8`]: ../../std/primitive.u8.html
- /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [file]: crate::fs::File
+ /// [`Iterator`]: crate::iter::Iterator
+ /// [`Result`]: crate::result::Result
+ /// [`io::Error`]: self::Error
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`]s implement `Read`:
///
- /// [`File`]: ../fs/struct.File.html
- /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`read()`]: trait.Read.html#tymethod.read
+ /// [`File`]: crate::fs::File
+ /// [`Ok(0)`]: Ok
+ /// [`read()`]: Read::read
///
/// ```no_run
/// use std::io;
/// throughout [`std::io`] take and provide types which implement the `Write`
/// trait.
///
-/// [`write`]: #tymethod.write
-/// [`flush`]: #tymethod.flush
+/// [`write`]: Self::write
+/// [`flush`]: Self::flush
/// [`std::io`]: index.html
///
/// # Examples
/// The trait also provides convenience methods like [`write_all`], which calls
/// `write` in a loop until its entire input has been written.
///
-/// [`write_all`]: #method.write_all
+/// [`write_all`]: Self::write_all
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(spotlight)]
pub trait Write {
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
/// write operation should be retried if there is nothing else to do.
///
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- ///
/// # Examples
///
/// ```no_run
/// This function will return the first error of
/// non-[`ErrorKind::Interrupted`] kind that [`write`] returns.
///
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`write`]: #tymethod.write
+ /// [`write`]: Self::write
///
/// # Examples
///
///
/// If the buffer contains no data, this will never call [`write_vectored`].
///
- /// [`write_vectored`]: #method.write_vectored
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
+ /// [`write_vectored`]: Self::write_vectored
///
/// # Notes
///
/// encountered.
///
/// This method is primarily used to interface with the
- /// [`format_args!`][formatargs] macro, but it is rare that this should
- /// explicitly be called. The [`write!`][write] macro should be favored to
+ /// [`format_args!()`] macro, but it is rare that this should
+ /// explicitly be called. The [`write!()`] macro should be favored to
/// invoke this method instead.
///
- /// [formatargs]: ../macro.format_args.html
- /// [write]: ../macro.write.html
- ///
/// This function internally uses the [`write_all`][writeall] method on
/// this trait and hence will continuously write data so long as no errors
/// are received. This also means that partial writes are not indicated in
/// this signature.
///
- /// [writeall]: #method.write_all
+ /// [writeall]: Self::write_all
///
/// # Errors
///
///
/// [`File`][file]s implement `Seek`:
///
-/// [file]: ../fs/struct.File.html
+/// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// [`BufReader`] to the rescue!
///
/// [`BufReader`]: struct.BufReader.html
-/// [`File`]: ../fs/struct.File.html
-/// [`read_line`]: #method.read_line
-/// [`lines`]: #method.lines
+/// [`File`]: crate::fs::File
+/// [`read_line`]: Self::read_line
+/// [`lines`]: Self::lines
/// [`Read`]: trait.Read.html
///
/// ```no_run
/// be called with the number of bytes that are consumed from this buffer to
/// ensure that the bytes are never returned twice.
///
- /// [`consume`]: #tymethod.consume
+ /// [`consume`]: Self::consume
///
/// An empty buffer returned indicates that the stream has reached EOF.
///
/// Since `consume()` is meant to be used with [`fill_buf`],
/// that method's example includes an example of `consume()`.
///
- /// [`fill_buf`]: #tymethod.fill_buf
+ /// [`fill_buf`]: Self::fill_buf
#[stable(feature = "rust1", since = "1.0.0")]
fn consume(&mut self, amt: usize);
/// If an I/O error is encountered then all bytes read so far will be
/// present in `buf` and its length will have been adjusted appropriately.
///
- /// [`fill_buf`]: #tymethod.fill_buf
+ /// [`fill_buf`]: Self::fill_buf
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
///
/// # Examples
/// error is encountered then `buf` may contain some bytes already read in
/// the event that all data read so far was valid UTF-8.
///
- /// [`read_until`]: #method.read_until
+ /// [`read_until`]: Self::read_until
///
/// # Examples
///
/// This function will yield errors whenever [`read_until`] would have
/// also yielded an error.
///
- /// [`io::Result`]: type.Result.html
- /// [`Vec<u8>`]: ../vec/struct.Vec.html
- /// [`read_until`]: #method.read_until
+ /// [`io::Result`]: self::Result
+ /// [`Vec<u8>`]: crate::vec::Vec
+ /// [`read_until`]: Self::read_until
///
/// # Examples
///
/// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline
/// byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.
///
- /// [`io::Result`]: type.Result.html
- /// [`String`]: ../string/struct.String.html
+ /// [`io::Result`]: self::Result
///
/// # Examples
///
/// this example, we use [`Cursor`] to iterate over all the lines in a byte
/// slice.
///
- /// [`Cursor`]: struct.Cursor.html
- ///
/// ```
/// use std::io::{self, BufRead};
///
/// This instance may reach `EOF` after reading fewer bytes than indicated by
/// this method if the underlying [`Read`] instance reaches EOF.
///
- /// [`Read`]: ../../std/io/trait.Read.html
- ///
/// # Examples
///
/// ```no_run
//
/// A value of type [`bool`] representing logical **false**.
///
-/// The documentation for this keyword is [not yet complete]. Pull requests welcome!
+/// `false` is the logical opposite of [`true`].
///
-/// [`bool`]: primitive.bool.html
-/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
+/// See the documentation for [`true`] for more information.
+///
+/// [`true`]: keyword.true.html
mod false_keyword {}
#[doc(keyword = "fn")]
Ok(0) => return Ok((p, ours)),
Ok(8) => {
let (errno, footer) = bytes.split_at(4);
- assert!(
- combine(CLOEXEC_MSG_FOOTER) == combine(footer.try_into().unwrap()),
+ assert_eq!(
+ CLOEXEC_MSG_FOOTER, footer,
"Validation on the CLOEXEC pipe failed: {:?}",
bytes
);
- let errno = combine(errno.try_into().unwrap());
+ let errno = i32::from_be_bytes(errno.try_into().unwrap());
assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
return Err(Error::from_raw_os_error(errno));
}
}
}
}
-
- fn combine(arr: [u8; 4]) -> i32 {
- i32::from_be_bytes(arr)
- }
}
pub fn exec(&mut self, default: Stdio) -> io::Error {
use crate::Redirect::*;
+// Add linkcheck exceptions here
+// If at all possible you should use intra-doc links to avoid linkcheck issues. These
+// are cases where that does not work
+// [(generated_documentation_page, &[broken_links])]
+const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[
+ // These are methods on slice, and `Self` does not work on primitive impls
+ // in intra-doc links (primitive impls are weird)
+ // https://github.com/rust-lang/rust/issues/62834 is necessary to be
+ // able to link to slices
+ (
+ "std/io/struct.IoSlice.html",
+ &[
+ "#method.as_mut_ptr",
+ "#method.sort_by_key",
+ "#method.make_ascii_uppercase",
+ "#method.make_ascii_lowercase",
+ ],
+ ),
+ // These try to link to std::collections, but are defined in alloc
+ // https://github.com/rust-lang/rust/issues/74481
+ ("std/collections/btree_map/struct.BTreeMap.html", &["#insert-and-complex-keys"]),
+ ("std/collections/btree_set/struct.BTreeSet.html", &["#insert-and-complex-keys"]),
+ ("alloc/collections/btree_map/struct.BTreeMap.html", &["#insert-and-complex-keys"]),
+ ("alloc/collections/btree_set/struct.BTreeSet.html", &["#insert-and-complex-keys"]),
+];
+
macro_rules! t {
($e:expr) => {
match $e {
}
}
+fn is_exception(file: &Path, link: &str) -> bool {
+ if let Some(entry) = LINKCHECK_EXCEPTIONS.iter().find(|&(f, _)| file.ends_with(f)) {
+ entry.1.contains(&link)
+ } else {
+ false
+ }
+}
+
fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Option<PathBuf> {
// Ignore non-HTML files.
if file.extension().and_then(|s| s.to_str()) != Some("html") {
return None;
}
- // Unfortunately we're not 100% full of valid links today to we need a few
- // exceptions to get this past `make check` today.
- // FIXME(#32129)
- if file.ends_with("std/io/struct.IoSlice.html")
- || file.ends_with("std/string/struct.String.html")
- {
- return None;
- }
- // FIXME(#32553)
- if file.ends_with("alloc/string/struct.String.html") {
- return None;
- }
- // FIXME(#32130)
- if file.ends_with("alloc/collections/btree_map/struct.BTreeMap.html")
- || file.ends_with("alloc/collections/btree_set/struct.BTreeSet.html")
- || file.ends_with("std/collections/btree_map/struct.BTreeMap.html")
- || file.ends_with("std/collections/btree_set/struct.BTreeSet.html")
- || file.ends_with("std/collections/hash_map/struct.HashMap.html")
- || file.ends_with("std/collections/hash_set/struct.HashSet.html")
- {
- return None;
- }
-
let res = load_file(cache, root, file, SkipRedirect);
let (pretty_file, contents) = match res {
Ok(res) => res,
let entry = &mut cache.get_mut(&pretty_path).unwrap();
entry.parse_ids(&pretty_path, &contents, errors);
- if !entry.ids.contains(*fragment) {
+ if !entry.ids.contains(*fragment) && !is_exception(file, &format!("#{}", fragment))
+ {
*errors = true;
print!("{}:{}: broken link fragment ", pretty_file.display(), i + 1);
println!("`#{}` pointing to `{}`", fragment, pretty_path.display());
};
}
} else {
- *errors = true;
- print!("{}:{}: broken link - ", pretty_file.display(), i + 1);
let pretty_path = path.strip_prefix(root).unwrap_or(&path);
- println!("{}", pretty_path.display());
+ if !is_exception(file, pretty_path.to_str().unwrap()) {
+ *errors = true;
+ print!("{}:{}: broken link - ", pretty_file.display(), i + 1);
+ println!("{}", pretty_path.display());
+ }
}
});
Some(pretty_file)