diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aad495fa3fae6..2a4c42ea0a456 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,5 +4,12 @@ Thank you for your interest in contributing to Rust! To get started, read the [Getting Started] guide in the [rustc-dev-guide]. +## Bug reports + +Did a compiler error message tell you to come here? If you want to create an ICE report, +refer to [this section][contributing-bug-reports] and [open an issue][issue template]. + [Getting Started]: https://rustc-dev-guide.rust-lang.org/getting-started.html [rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/ +[contributing-bug-reports]: https://rustc-dev-guide.rust-lang.org/contributing.html#bug-reports +[issue template]: https://github.com/rust-lang/rust/issues/new/choose diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 557fb1aa550a5..f6060ac14e75e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -773,7 +773,8 @@ impl<'a> Builder<'a> { let my_out = match mode { // This is the intended out directory for compiler documentation. Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target), - _ => self.crate_doc_out(target), + Mode::Std => out_dir.join(target).join("doc"), + _ => panic!("doc mode {:?} not expected", mode), }; let rustdoc = self.rustdoc(compiler); self.clear_if_dirty(&my_out, &rustdoc); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 582bc9da0e804..3121690285868 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -417,21 +417,6 @@ impl Step for Std { builder.ensure(compile::Std { compiler, target }); let out_dir = builder.stage_out(compiler, Mode::Std).join(target).join("doc"); - // Here what we're doing is creating a *symlink* (directory junction on - // Windows) to the final output location. This is not done as an - // optimization but rather for correctness. We've got three trees of - // documentation, one for std, one for test, and one for rustc. It's then - // our job to merge them all together. - // - // Unfortunately rustbuild doesn't know nearly as well how to merge doc - // trees as rustdoc does itself, so instead of actually having three - // separate trees we just have rustdoc output to the same location across - // all of them. - // - // This way rustdoc generates output directly into the output, and rustdoc - // will also directly handle merging. - let my_out = builder.crate_doc_out(target); - t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css"))); let run_cargo_rustdoc_for = |package: &str| { @@ -439,12 +424,9 @@ impl Step for Std { builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc"); compile::std_cargo(builder, target, compiler.stage, &mut cargo); - cargo.arg("-p").arg(package); - // Create all crate output directories first to make sure rustdoc uses - // relative links. - // FIXME: Cargo should probably do this itself. - t!(fs::create_dir_all(out_dir.join(package))); cargo + .arg("-p") + .arg(package) .arg("--") .arg("--markdown-css") .arg("rust.css") @@ -462,11 +444,17 @@ impl Step for Std { // folder structure, that would also build internal crates that we do // not want to show in documentation. These crates will later be visited // by the rustc step, so internal documentation will show them. - let krates = ["alloc", "core", "std", "proc_macro", "test"]; + // + // Note that the order here is important! The crates need to be + // processed starting from the leaves, otherwise rustdoc will not + // create correct links between crates because rustdoc depends on the + // existence of the output directories to know if it should be a local + // or remote link. + let krates = ["core", "alloc", "std", "proc_macro", "test"]; for krate in &krates { run_cargo_rustdoc_for(krate); } - builder.cp_r(&my_out, &out); + builder.cp_r(&out_dir, &out); // Look for src/libstd, src/libcore etc in the `x.py doc` arguments and // open the corresponding rendered docs. @@ -529,8 +517,11 @@ impl Step for Rustc { // Build rustc. builder.ensure(compile::Rustc { compiler, target }); - // We do not symlink to the same shared folder that already contains std library - // documentation from previous steps as we do not want to include that. + // This uses a shared directory so that librustdoc documentation gets + // correctly built and merged with the rustc documentation. This is + // needed because rustdoc is built in a different directory from + // rustc. rustdoc needs to be able to see everything, for example when + // merging the search index, or generating local (relative) links. let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc"); t!(symlink_dir_force(&builder.config, &out, &out_dir)); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 783a64c3581f9..9ca9e338d55c5 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -612,13 +612,6 @@ impl Build { INTERNER.intern_path(self.out.join(&*target).join("md-doc")) } - /// Output directory for all crate documentation for a target (temporary) - /// - /// The artifacts here are then copied into `doc_out` above. - fn crate_doc_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("crate-docs") - } - /// Returns `true` if no custom `llvm-config` is set for the specified target. /// /// If no custom `llvm-config` was specified then Rust's llvm will be used. diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index bb9091a66594b..f3781db1cf784 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1697,6 +1697,8 @@ where pred: F, inner: DrainFilterInner<'a, K, V>, } +/// Most of the implementation of DrainFilter, independent of the type +/// of the predicate, thus also serving for BTreeSet::DrainFilter. pub(super) struct DrainFilterInner<'a, K: 'a, V: 'a> { length: &'a mut usize, cur_leaf_edge: Option, K, V, marker::Leaf>, marker::Edge>>, diff --git a/src/liballoc/collections/btree/navigate.rs b/src/liballoc/collections/btree/navigate.rs index 5478d822438b1..44f0e25bbd798 100644 --- a/src/liballoc/collections/btree/navigate.rs +++ b/src/liballoc/collections/btree/navigate.rs @@ -161,15 +161,16 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::Edge impl Handle, marker::Edge> { /// Moves the leaf edge handle to the next leaf edge and returns the key and value /// in between, while deallocating any node left behind. - /// Unsafe for three reasons: + /// Unsafe for two reasons: /// - The caller must ensure that the leaf edge is not the last one in the tree /// and is not a handle previously resulting from counterpart `next_back_unchecked`. - /// - If the leaf edge is the last edge of a node, that node and possibly ancestors + /// - Further use of the updated leaf edge handle is very dangerous. In particular, + /// if the leaf edge is the last edge of a node, that node and possibly ancestors /// will be deallocated, while the reference to those nodes in the surviving ancestor - /// is left dangling; thus further use of the leaf edge handle is dangerous. - /// It is, however, safe to call this method again on the updated handle. - /// if the two preconditions above hold. - /// - Using the updated handle may well invalidate the returned references. + /// is left dangling. + /// The only safe way to proceed with the updated handle is to compare it, drop it, + /// call this method again subject to both preconditions listed in the first point, + /// or call counterpart `next_back_unchecked` subject to its preconditions. pub unsafe fn next_unchecked(&mut self) -> (K, V) { unsafe { replace(self, |leaf_edge| { @@ -183,15 +184,16 @@ impl Handle, marker::Edge> { /// Moves the leaf edge handle to the previous leaf edge and returns the key /// and value in between, while deallocating any node left behind. - /// Unsafe for three reasons: + /// Unsafe for two reasons: /// - The caller must ensure that the leaf edge is not the first one in the tree /// and is not a handle previously resulting from counterpart `next_unchecked`. - /// - If the lead edge is the first edge of a node, that node and possibly ancestors + /// - Further use of the updated leaf edge handle is very dangerous. In particular, + /// if the leaf edge is the first edge of a node, that node and possibly ancestors /// will be deallocated, while the reference to those nodes in the surviving ancestor - /// is left dangling; thus further use of the leaf edge handle is dangerous. - /// It is, however, safe to call this method again on the updated handle. - /// if the two preconditions above hold. - /// - Using the updated handle may well invalidate the returned references. + /// is left dangling. + /// The only safe way to proceed with the updated handle is to compare it, drop it, + /// call this method again subject to both preconditions listed in the first point, + /// or call counterpart `next_unchecked` subject to its preconditions. pub unsafe fn next_back_unchecked(&mut self) -> (K, V) { unsafe { replace(self, |leaf_edge| { diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index a4b6cf12a23bd..ce74d4f8ee688 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -94,7 +94,8 @@ struct InternalNode { data: LeafNode, /// The pointers to the children of this node. `len + 1` of these are considered - /// initialized and valid. + /// initialized and valid. Although during the process of `into_iter` or `drop`, + /// some pointers are dangling while others still need to be traversed. edges: [MaybeUninit>; 2 * B], } @@ -408,7 +409,7 @@ impl NodeRef { impl<'a, K, V, Type> NodeRef, K, V, Type> { /// Unsafely asserts to the compiler some static information about whether this - /// node is a `Leaf`. + /// node is a `Leaf` or an `Internal`. unsafe fn cast_unchecked(&mut self) -> NodeRef, K, V, NewType> { NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData } } @@ -515,7 +516,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { } impl<'a, K, V> NodeRef, K, V, marker::Leaf> { - /// Adds a key/value pair the end of the node. + /// Adds a key/value pair to the end of the node. pub fn push(&mut self, key: K, val: V) { assert!(self.len() < CAPACITY); @@ -602,8 +603,10 @@ impl<'a, K, V> NodeRef, K, V, marker::Internal> { } impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { - /// Removes a key/value pair from the end of this node. If this is an internal node, - /// also removes the edge that was to the right of that pair. + /// Removes a key/value pair from the end of this node and returns the pair. + /// If this is an internal node, also removes the edge that was to the right + /// of that pair and returns the orphaned node that this edge owned with its + /// parent erased. pub fn pop(&mut self) -> (K, V, Option>) { assert!(self.len() > 0); @@ -883,7 +886,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: } /// Unsafely asserts to the compiler some static information about whether the underlying - /// node of this handle is a `Leaf`. + /// node of this handle is a `Leaf` or an `Internal`. unsafe fn cast_unchecked( &mut self, ) -> Handle, K, V, NewType>, marker::Edge> { diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index 8ff1ced53b071..94f7ff5c1f7fe 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -18,8 +18,9 @@ //! [`TryFrom`][`TryFrom`] rather than [`Into`][`Into`] or [`TryInto`][`TryInto`], //! as [`From`] and [`TryFrom`] provide greater flexibility and offer //! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a -//! blanket implementation in the standard library. Only implement [`Into`] or [`TryInto`] -//! when a conversion to a type outside the current crate is required. +//! blanket implementation in the standard library. When targeting a version prior to Rust 1.41, it +//! may be necessary to implement [`Into`] or [`TryInto`] directly when converting to a type +//! outside the current crate. //! //! # Generic Implementations //! @@ -298,8 +299,10 @@ pub trait Into: Sized { /// because implementing `From` automatically provides one with an implementation of [`Into`] /// thanks to the blanket implementation in the standard library. /// -/// Only implement [`Into`] if a conversion to a type outside the current crate is required. -/// `From` cannot do these type of conversions because of Rust's orphaning rules. +/// Only implement [`Into`] when targeting a version prior to Rust 1.41 and converting to a type +/// outside the current crate. +/// `From` was not able to do these types of conversions in earlier versions because of Rust's +/// orphaning rules. /// See [`Into`] for more details. /// /// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function. diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 393911675c73e..86e8d5c42b7ad 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2374,11 +2374,14 @@ impl str { unsafe { Slices { str: self }.slice } } - /// Converts a mutable string slice to a mutable byte slice. To convert the - /// mutable byte slice back into a mutable string slice, use the - /// [`str::from_utf8_mut`] function. + /// Converts a mutable string slice to a mutable byte slice. /// - /// [`str::from_utf8_mut`]: ./str/fn.from_utf8_mut.html + /// # Safety + /// + /// The caller must ensure that the content of the slice is valid UTF-8 + /// before the borrow ends and the underlying `str` is used. + /// + /// Use of a `str` whose contents are not valid UTF-8 is undefined behavior. /// /// # Examples /// diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index be11e29cb2575..982a615dd9195 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -65,8 +65,8 @@ pub const EXIT_SUCCESS: i32 = 0; /// Exit status code used for compilation failures and invalid flags. pub const EXIT_FAILURE: i32 = 1; -const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\ - md#bug-reports"; +const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/issues/new\ + ?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md"; const ICE_REPORT_COMPILER_FLAGS: &[&str] = &["Z", "C", "crate-type"]; diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 490afb5a0438f..29893bd12f1f7 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -47,8 +47,6 @@ hermit-abi = { version = "0.1.14", features = ['rustc-dep-of-std'] } wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false } [features] -default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"] - backtrace = [ "backtrace_rs/dbghelp", # backtrace/symbolize on MSVC "backtrace_rs/libbacktrace", # symbolize on most platforms diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 5215db7cdb3ce..4fd5e238eea11 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -85,8 +85,9 @@ //! # Contributing changes to the documentation //! //! Check out the rust contribution guidelines [here]( -//! https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md). -//! The source for this documentation can be found on [Github](https://github.com/rust-lang). +//! https://rustc-dev-guide.rust-lang.org/getting-started.html). +//! The source for this documentation can be found on +//! [GitHub](https://github.com/rust-lang/rust). //! To contribute changes, make sure you read the guidelines first, then submit //! pull-requests for your suggested changes. //! diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml index 170fbb984cf9b..1667334871d5e 100644 --- a/src/libtest/Cargo.toml +++ b/src/libtest/Cargo.toml @@ -23,9 +23,12 @@ proc_macro = { path = "../libproc_macro" } # Forward features to the `std` crate as necessary [features] +default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"] backtrace = ["std/backtrace"] compiler-builtins-c = ["std/compiler-builtins-c"] llvm-libunwind = ["std/llvm-libunwind"] panic-unwind = ["std/panic_unwind"] panic_immediate_abort = ["std/panic_immediate_abort"] profiler = ["std/profiler"] +std_detect_file_io = ["std/std_detect_file_io"] +std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"] diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index d0018cef5f033..6e87e5c6912c3 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -5,7 +5,7 @@ error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports +note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc VERSION running on TARGET