diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 7a765973e20f8..34edca4cdeda1 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -149,7 +149,7 @@ fn main() { // // `compiler_builtins` are unconditionally compiled with panic=abort to // workaround undefined references to `rust_eh_unwind_resume` generated - // otherwise, see issue https://github.com/rust-lang/rust/issues/43095. + // otherwise, see issue #43095. if crate_name == "panic_abort" || crate_name == "compiler_builtins" && stage != "0" { cmd.arg("-C").arg("panic=abort"); diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 9d037dad9ccbd..371aeca4ac5c3 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -80,7 +80,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { // It is reasonable to not have an implementation of make_run for rules // who do not want to get called from the root context. This means that // they are likely dependencies (e.g., sysroot creation) or similar, and - // as such calling them from ./x.py isn't logical. + // as such calling them from `./x.py` isn't logical. unimplemented!() } } @@ -236,11 +236,11 @@ impl StepDescription { #[derive(Clone)] pub struct ShouldRun<'a> { pub builder: &'a Builder<'a>, - // use a BTreeSet to maintain sort order + // Use a `BTreeSet` to maintain sort order. paths: BTreeSet, // If this is a default rule, this is an additional constraint placed on - // its run. Generally something like compiler docs being enabled. + // its run (generally something like compiler docs being enabled). is_really_default: bool, } @@ -249,7 +249,8 @@ impl<'a> ShouldRun<'a> { ShouldRun { builder, paths: BTreeSet::new(), - is_really_default: true, // by default no additional conditions + // By default no additional conditions. + is_really_default: true, } } @@ -277,12 +278,12 @@ impl<'a> ShouldRun<'a> { self } - // single, non-aliased path + // Single, non-aliased path. pub fn path(self, path: &str) -> Self { self.paths(&[path]) } - // multiple aliases for the same job + // Multiple aliases for the same job. pub fn paths(mut self, paths: &[&str]) -> Self { self.paths .insert(PathSet::Set(paths.iter().map(PathBuf::from).collect())); @@ -301,7 +302,7 @@ impl<'a> ShouldRun<'a> { self } - // allows being more explicit about why should_run in Step returns the value passed to it + // Allows being more explicit about why `Step::should_run` returns the value passed to it. pub fn never(mut self) -> ShouldRun<'a> { self.paths.insert(PathSet::empty()); self @@ -677,7 +678,7 @@ impl<'a> Builder<'a> { let compiler = self.compiler(self.top_stage, host); cmd.env("RUSTC_STAGE", compiler.stage.to_string()) .env("RUSTC_SYSROOT", self.sysroot(compiler)) - // Note that this is *not* the sysroot_libdir because rustdoc must be linked + // Note that this is **not** the `sysroot_libdir` because rustdoc must be linked // equivalently to rustc. .env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler)) .env("CFG_RELEASE_CHANNEL", &self.config.channel) @@ -813,12 +814,12 @@ impl<'a> Builder<'a> { } cargo.arg("-j").arg(self.jobs().to_string()); - // Remove make-related flags to ensure Cargo can correctly set things up + // Remove make-related flags to ensure Cargo can correctly set things up. cargo.env_remove("MAKEFLAGS"); cargo.env_remove("MFLAGS"); - // FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005 - // Force cargo to output binaries with disambiguating hashes in the name + // FIXME: temporary fix for rust-lang/cargo#3005. + // Force cargo to output binaries with disambiguating hashes in the name. let metadata = if compiler.stage == 0 { // Treat stage0 like special channel, whether it's a normal prior- // release rustc or a local rebuild with the same version, so we @@ -863,7 +864,7 @@ impl<'a> Builder<'a> { // "raw" compiler in that it's the exact snapshot we download. Normally // the stage0 build means it uses libraries build by the stage0 // compiler, but for tools we just use the precompiled libraries that - // we've downloaded + // we've downloaded. let use_snapshot = mode == Mode::ToolBootstrap; assert!(!use_snapshot || stage == 0 || self.local_rebuild); @@ -920,7 +921,7 @@ impl<'a> Builder<'a> { if mode.is_tool() { // Tools like cargo and rls don't get debuginfo by default right now, but this can be - // enabled in the config. Adding debuginfo makes them several times larger. + // enabled in the config. Adding debuginfo makes them several times larger. if self.config.rust_debuginfo_tools { cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); cargo.env( @@ -1028,7 +1029,7 @@ impl<'a> Builder<'a> { // Build scripts use either the `cc` crate or `configure/make` so we pass // the options through environment variables that are fetched and understood by both. // - // FIXME: the guard against msvc shouldn't need to be here + // FIXME: the guard against MSVC shouldn't need to be here. if target.contains("msvc") { if let Some(ref cl) = self.config.llvm_clang_cl { cargo.env("CC", cl).env("CXX", cl); @@ -1040,7 +1041,7 @@ impl<'a> Builder<'a> { Some(ref s) => s, None => return s.display().to_string(), }; - // FIXME: the cc-rs crate only recognizes the literal strings + // FIXME: the cc-rs crate only recognizes the literal strings. // `ccache` and `sccache` when doing caching compilations, so we // mirror that here. It should probably be fixed upstream to // accept a new env var or otherwise work with custom ccache @@ -1080,12 +1081,12 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string()); } - // For `cargo doc` invocations, make rustdoc print the Rust version into the docs + // For `cargo doc` invocations, make rustdoc print the Rust version into the docs. cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version()); - // Environment variables *required* throughout the build + // Environment variables *required* throughout the build. // - // FIXME: should update code to not require this env var + // FIXME: should update code to not require this env var. cargo.env("CFG_COMPILER_HOST_TRIPLE", target); // Set this for all builds to make sure doc builds also get it. @@ -1476,7 +1477,7 @@ mod __test { #[test] fn dist_with_target_flag() { let mut config = configure(&["B"], &["C"]); - config.run_host_only = false; // as-if --target=C was passed + config.run_host_only = false; // as if `--target=C` were passed let build = Build::new(config); let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index 5f84816789a68..46d99ba93fe03 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -176,7 +176,7 @@ impl Default for TyIntern { impl TyIntern { fn intern_borrow(&mut self, item: &B) -> Interned where - B: Eq + Hash + ToOwned + ?Sized, + B: Eq + Hash + ToOwned + ?Sized, T: Borrow, { if let Some(i) = self.set.get(&item) { @@ -235,7 +235,8 @@ lazy_static! { pub struct Cache( RefCell, // actually a HashMap> + // Actually a `HashMap>`. + Box, >> ); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 8fabb8c3fd08f..901018e01d311 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -165,12 +165,12 @@ pub fn std_cargo(builder: &Builder, let features = builder.std_features(); if compiler.stage != 0 && builder.config.sanitizers { - // This variable is used by the sanitizer runtime crates, e.g. - // rustc_lsan, to build the sanitizer runtime from C code + // This variable is used by the sanitizer runtime crates, e.g., + // `rustc_lsan`, to build the sanitizer runtime from C code // When this variable is missing, those crates won't compile the C code, // so we don't set this variable during stage0 where llvm-config is // missing - // We also only build the runtimes when --enable-sanitizers (or its + // We also only build the runtimes when `--enable-sanitizers` (or its // config.toml equivalent) is used let llvm_config = builder.ensure(native::Llvm { target: builder.config.build, @@ -921,17 +921,17 @@ impl Step for Assemble { // produce some other architecture compiler we need to start from // `build` to get there. // - // FIXME: Perhaps we should download those libraries? + // FIXME: perhaps we should download those libraries? // It would make builds faster... // - // FIXME: It may be faster if we build just a stage 1 compiler and then + // FIXME: it may be faster if we build just a stage 1 compiler and then // use that to bootstrap this compiler forward. let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build); // Build the libraries for this compiler to link to (i.e., the libraries // it uses at runtime). NOTE: Crates the target compiler compiles don't - // link to these. (FIXME: Is that correct? It seems to be correct most + // link to these. (FIXME: is that correct? It seems to be correct most // of the time but I think we do link to these for stage2/bin compilers // when not performing a full bootstrap). builder.ensure(Rustc { diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index bc1fdad356be3..30cfbd61773c0 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2222,8 +2222,8 @@ impl Step for Lldb { } } - // The lldb scripts might be installed in lib/python$version - // or in lib64/python$version. If lib64 exists, use it; + // The lldb scripts might be installed in `lib/python$version` + // or in `lib64/python$version`. If lib64 exists, use it; // otherwise lib. let libdir = builder.llvm_out(target).join("lib64"); let (libdir, libdir_name) = if libdir.exists() { diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index d14b23e5988cb..dbfefe9c3e5f0 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -567,14 +567,14 @@ impl Step for Test { compiler }; - // Build libstd docs so that we generate relative links + // Build libstd docs so that we generate relative links. builder.ensure(Std { stage, target }); builder.ensure(compile::Test { compiler, target }); let out_dir = builder.stage_out(compiler, Mode::Test) .join(target).join("doc"); - // See docs in std above for why we symlink + // See docs in std above for why we symlink. let my_out = builder.crate_doc_out(target); t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); @@ -633,14 +633,14 @@ impl Step for WhitelistedRustc { compiler }; - // Build libstd docs so that we generate relative links + // Build libstd docs so that we generate relative links. builder.ensure(Std { stage, target }); builder.ensure(compile::Rustc { compiler, target }); let out_dir = builder.stage_out(compiler, Mode::Rustc) .join(target).join("doc"); - // See docs in std above for why we symlink + // See docs in std above for why we symlink. let my_out = builder.crate_doc_out(target); t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); @@ -737,7 +737,7 @@ impl Step for Rustc { for krate in &compiler_crates { // Create all crate output directories first to make sure rustdoc uses // relative links. - // FIXME: Cargo should probably do this itself. + // FIXME: cargo should probably do this itself. t!(fs::create_dir_all(out_dir.join(krate))); cargo.arg("-p").arg(krate); } @@ -879,7 +879,7 @@ impl Step for ErrorIndex { index.arg("html"); index.arg(out.join("error-index.html")); - // FIXME: shouldn't have to pass this env var + // FIXME: shouldn't have to pass this env var. index.env("CFG_BUILD", &builder.config.build) .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); @@ -936,7 +936,7 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> if m.file_type().is_dir() { fs::remove_dir_all(dst)?; } else { - // handle directory junctions on windows by falling back to + // Handle directory junctions on Windows by falling back to // `remove_dir`. fs::remove_file(dst).or_else(|_| { fs::remove_dir(dst) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 0f9a4271ac062..1cb2f44b4978d 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -33,7 +33,7 @@ pub struct Flags { pub rustc_error_format: Option, pub dry_run: bool, - // true => deny + // `true` => deny pub warnings: Option, } @@ -139,8 +139,8 @@ To learn more about a subcommand, run `./x.py -h`" // We can't use getopt to parse the options until we have completed specifying which // options are valid, but under the current implementation, some options are conditional on - // the subcommand. Therefore we must manually identify the subcommand first, so that we can - // complete the definition of the options. Then we can use the getopt::Matches object from + // the subcommand. Therefore, we must manually identify the subcommand first, so that we can + // complete the definition of the options. Then we can use the `getopt::Matches` object from // there on out. let subcommand = args.iter().find(|&s| { (s == "build") diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f48f9ee752e93..53fccc066d48a 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -197,8 +197,8 @@ impl Step for Llvm { cfg.define("LLDB_CODESIGN_IDENTITY", ""); cfg.define("LLDB_NO_DEBUGSERVER", "ON"); } else { - // LLDB requires libxml2; but otherwise we want it to be disabled. - // See https://github.com/rust-lang/rust/pull/50104 + // LLDB requires libxml2, but otherwise we want it to be disabled. + // See PR #50104. cfg.define("LLVM_ENABLE_LIBXML2", "OFF"); } diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index ff4fb85bbfad3..eae408888625b 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -62,13 +62,13 @@ pub fn check(build: &mut Build) { // On Windows, quotes are invalid characters for filename paths, and if // one is present as part of the PATH then that can lead to the system // being unable to identify the files properly. See - // https://github.com/rust-lang/rust/issues/34959 for more details. + // issue #34959 for more details. if cfg!(windows) && path.to_string_lossy().contains('\"') { panic!("PATH contains invalid character '\"'"); } let mut cmd_finder = Finder::new(); - // If we've got a git directory we're gonna need git to update + // If we've got a Git directory we're gonna need git to update // submodules and learn about various other aspects. if build.rust_info.is_git() { cmd_finder.must_have("git"); @@ -122,7 +122,7 @@ pub fn check(build: &mut Build) { // We're gonna build some custom C code here and there, host triples // also build some C++ shims for LLVM so we need a C++ compiler. for target in &build.targets { - // On emscripten we don't actually need the C compiler to just + // On Emscripten we don't actually need the C compiler to just // build the target artifacts, only for testing. For the sake // of easier bot configuration, just skip detection. if target.contains("emscripten") { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a882550f734f4..f2e312ae828d2 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -47,7 +47,7 @@ impl From for TestKind { } impl TestKind { - // Return the cargo subcommand for this test kind + // Returns the cargo subcommand for this test kind. fn subcommand(self) -> &'static str { match self { TestKind::Test => "test", @@ -517,8 +517,8 @@ impl Step for Clippy { } fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { - // Configure PATH to find the right rustc. NB. we have to use PATH - // and not RUSTC because the Cargo test suite has tests that will + // Configure `PATH` to find the right rustc. N.B., we have to use PATH + // and not `RUSTC` because the Cargo test suite has tests that will // fail if rustc is not spelled `rustc`. let path = builder.sysroot(compiler).join("bin"); let old_path = env::var_os("PATH").unwrap_or_default(); @@ -951,7 +951,7 @@ impl Step for Compiletest { } if suite.ends_with("fulldeps") || - // FIXME: Does pretty need librustc compiled? Note that there are + // FIXME: does pretty need librustc compiled? Note that there are // fulldeps test suites with mode = pretty as well. mode == "pretty" { @@ -971,7 +971,7 @@ impl Step for Compiletest { builder.ensure(compile::Std { compiler, target: compiler.host }); } - // HACK(eddyb) ensure that `libproc_macro` is available on the host. + // HACK(eddyb): ensure that `libproc_macro` is available on the host. builder.ensure(compile::Test { compiler, target: compiler.host }); // Also provide `rust_test_helpers` for the host. builder.ensure(native::TestHelpers { target: compiler.host }); @@ -1976,8 +1976,8 @@ impl Step for Bootstrap { .env("RUSTC", &builder.initial_rustc); if let Some(flags) = option_env!("RUSTFLAGS") { // Use the same rustc flags for testing as for "normal" compilation, - // so that Cargo doesn’t recompile the entire dependency graph every time: - // https://github.com/rust-lang/rust/issues/49215 + // so that Cargo doesn’t recompile the entire dependency graph every time + // (issue #49215). cmd.env("RUSTFLAGS", flags); } if !builder.fail_fast { diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index ec652df3b37a4..e3c783f23b8c6 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -1,4 +1,4 @@ -//! Memory allocation APIs +//! Memory allocation APIs. #![stable(feature = "alloc_module", since = "1.28.0")] @@ -11,7 +11,7 @@ use core::usize; pub use core::alloc::*; extern "Rust" { - // These are the magic symbols to call the global allocator. rustc generates + // These are the magic symbols to call the global allocator. rustc generates // them from the `#[global_allocator]` attribute if there is one, or uses the // default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`) // otherwise. @@ -38,7 +38,7 @@ extern "Rust" { #[derive(Copy, Clone, Default, Debug)] pub struct Global; -/// Allocate memory with the global allocator. +/// Allocates memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::alloc`] method /// of the allocator registered with the `#[global_allocator]` attribute @@ -72,7 +72,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 { __rust_alloc(layout.size(), layout.align()) } -/// Deallocate memory with the global allocator. +/// Deallocates memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::dealloc`] method /// of the allocator registered with the `#[global_allocator]` attribute @@ -90,7 +90,7 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { __rust_dealloc(ptr, layout.size(), layout.align()) } -/// Reallocate memory with the global allocator. +/// Reallocates memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::realloc`] method /// of the allocator registered with the `#[global_allocator]` attribute @@ -108,7 +108,7 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 __rust_realloc(ptr, layout.size(), layout.align(), new_size) } -/// Allocate zero-initialized memory with the global allocator. +/// Allocates zero-initialized memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::alloc_zeroed`] method /// of the allocator registered with the `#[global_allocator]` attribute @@ -170,6 +170,7 @@ unsafe impl Alloc for Global { } /// The allocator for unique pointers. +// // This function must not unwind. If it does, MIR codegen will fail. #[cfg(not(test))] #[lang = "exchange_malloc"] @@ -194,14 +195,15 @@ pub(crate) unsafe fn box_free(ptr: Unique) { let ptr = ptr.as_ptr(); let size = size_of_val(&*ptr); let align = min_align_of_val(&*ptr); - // We do not allocate for Box when T is ZST, so deallocation is also not necessary. + // We do not allocate for `Box` when `T` is zero-sized, so deallocation is also not + // necessary. if size != 0 { let layout = Layout::from_size_align_unchecked(size, align); dealloc(ptr as *mut u8, layout); } } -/// Abort on memory allocation error or failure. +/// Aborts on memory allocation error or failure. /// /// Callers of memory allocation APIs wishing to abort computation /// in response to an allocation error are encouraged to call this function, diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 51549f92d4dbf..58ea870fa4626 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -275,7 +275,7 @@ impl Box { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<#[may_dangle] T: ?Sized> Drop for Box { fn drop(&mut self) { - // FIXME: Do nothing, drop is currently performed by compiler. + // FIXME: do nothing; drop is currently performed by compiler. } } diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 3b94379b58f8f..1ec9229548e3d 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -945,7 +945,7 @@ impl fmt::Debug for Iter<'_, T> { } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 5ec5064b73515..e9e643ebd2574 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -887,7 +887,7 @@ impl BTreeMap { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { - // FIXME(@porglezomp) Avoid allocating if we don't insert + // FIXME(porglezomp): avoid allocating if we don't insert. self.ensure_root_is_owned(); match search::search_tree(self.root.as_mut(), &key) { Found(handle) => { @@ -1835,12 +1835,12 @@ fn range_search>( where Q: Ord, K: Borrow { match (range.start_bound(), range.end_bound()) { - (Excluded(s), Excluded(e)) if s==e => + (Excluded(s), Excluded(e)) if s == e => panic!("range start and end are equal and excluded in BTreeMap"), (Included(s), Included(e)) | (Included(s), Excluded(e)) | (Excluded(s), Included(e)) | - (Excluded(s), Excluded(e)) if s>e => + (Excluded(s), Excluded(e)) if s > e => panic!("range start is greater than range end in BTreeMap"), _ => {}, }; diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index eb0667228d1ff..4fd564b582652 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -1,4 +1,4 @@ -// This is an attempt at an implementation following the ideal +// This is an attempt at an implementation of the following ideal: // // ``` // struct BTreeMap { @@ -250,7 +250,7 @@ impl Root { NodeRef { height: self.height, node: self.node.as_ptr(), - root: ptr::null_mut(), // FIXME: Is there anything better to do here? + root: ptr::null_mut(), // FIXME: is there anything better to do here? _marker: PhantomData, } } @@ -305,7 +305,7 @@ impl Root { } } -// N.B. `NodeRef` is always covariant in `K` and `V`, even when the `BorrowType` +// N.B., `NodeRef` is always covariant in `K` and `V`, even when the `BorrowType` // is `Mut`. This is technically wrong, but cannot result in any unsafety due to // internal use of `NodeRef` because we stay completely generic over `K` and `V`. // However, whenever a public type wraps `NodeRef`, make sure that it has the @@ -322,8 +322,8 @@ impl Root { /// `Leaf`, the `NodeRef` points to a leaf node, when this is `Internal` the /// `NodeRef` points to an internal node, and when this is `LeafOrInternal` the /// `NodeRef` could be pointing to either type of node. -/// Note that in case of a leaf node, this might still be the shared root! Only turn -/// this into a `LeafNode` reference if you know it is not a root! Shared references +/// Note that in case of a leaf node, this might still be the shared root! Only turn +/// this into a `LeafNode` reference if you know it is not a root! Shared references /// must be dereferencable *for the entire size of their pointee*, so `&InternalNode` /// pointing to the shared root is UB. /// Turning this into a `NodeHeader` is always safe. @@ -549,7 +549,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { /// `into_root_mut`) mess with the root of the tree, the result of `reborrow_mut` /// can easily be used to make the original mutable pointer dangling, or, in the case /// of a reborrowed handle, out of bounds. - // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts + // FIXME(gereeter): consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. unsafe fn reborrow_mut(&mut self) -> NodeRef, K, V, Type> { NodeRef { @@ -562,7 +562,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { /// Returns a raw ptr to avoid asserting exclusive access to the entire node. fn as_leaf_mut(&mut self) -> *mut LeafNode { - // We are mutable, so we cannot be the root, so accessing this as a leaf is okay. + // We are mutable, so we cannot be the root, so accessing this as a leaf is ok. self.node.as_ptr() } @@ -578,14 +578,14 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { fn into_key_slice(self) -> &'a [K] { // We have to be careful here because we might be pointing to the shared root. - // In that case, we must not create an `&LeafNode`. We could just return + // In that case, we must not create an `&LeafNode`. We could just return // an empty slice whenever the length is 0 (this includes the shared root), // but we want to avoid that run-time check. // Instead, we create a slice pointing into the node whenever possible. // We can sometimes do this even for the shared root, as the slice will be - // empty. We cannot *always* do this because if the type is too highly + // empty. We cannot *always* do this because if the type is too highly // aligned, the offset of `keys` in a "full node" might be outside the bounds - // of the header! So we do an alignment check first, that will be + // of the header! So we do an alignment check first, that will be // evaluated at compile-time, and only do any run-time check in the rare case // that the alignment is very big. if mem::align_of::() > mem::align_of::>() && self.is_shared_root() { @@ -594,18 +594,18 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { // Thanks to the alignment check above, we know that `keys` will be // in-bounds of some allocation even if this is the shared root! // (We might be one-past-the-end, but that is allowed by LLVM.) - // Getting the pointer is tricky though. `NodeHeader` does not have a `keys` + // Getting the pointer is tricky though. `NodeHeader` does not have a `keys` // field because we want its size to not depend on the alignment of `K` - // (needed becuase `as_header` should be safe). We cannot call `as_leaf` + // (needed becuase `as_header` should be safe). We cannot call `as_leaf` // because we might be the shared root. // For this reason, `NodeHeader` has this `K2` parameter (that's usually `()` // and hence just adds a size-0-align-1 field, not affecting layout). // We know that we can transmute `NodeHeader` to `NodeHeader` // because we did the alignment check above, and hence `NodeHeader` - // is not bigger than `NodeHeader`! Then we can use `NodeHeader` + // is not bigger than `NodeHeader`! Then we can use `NodeHeader` // to compute the pointer where the keys start. // This entire hack will become unnecessary once - // lands, then we can just take a raw + // RFC #2582 lands, then we can just take a raw // pointer to the `keys` field of `*const InternalNode`. // This is a non-debug-assert because it can be completely compile-time evaluated. @@ -620,7 +620,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef, K, V, Type> { fn into_val_slice(self) -> &'a [V] { debug_assert!(!self.is_shared_root()); - // We cannot be the root, so `as_leaf` is okay + // We cannot be the root, so `as_leaf` is ok unsafe { slice::from_raw_parts( MaybeUninit::first_ptr(&self.as_leaf().vals), @@ -950,7 +950,7 @@ impl<'a, K, V, NodeType, HandleType> /// `into_root_mut`) mess with the root of the tree, the result of `reborrow_mut` /// can easily be used to make the original mutable pointer dangling, or, in the case /// of a reborrowed handle, out of bounds. - // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts + // FIXME(gereeter): consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. pub unsafe fn reborrow_mut(&mut self) -> Handle, K, V, NodeType>, HandleType> { diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index afd8078cdd753..54c5cbe58ca50 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -69,7 +69,7 @@ impl fmt::Debug for Iter<'_, T> { } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Iter<'_, T> { fn clone(&self) -> Self { @@ -1383,7 +1383,7 @@ mod tests { // This caused the RHS's dtor to walk up into the LHS at drop and delete all of // its nodes. // - // https://github.com/rust-lang/rust/issues/26021 + // Issue #26021. let mut v1 = LinkedList::new(); v1.push_front(1); v1.push_front(1); diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index b6fdaa8999212..0122511c08593 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -151,7 +151,7 @@ impl VecDeque { wrap_index(idx.wrapping_sub(subtrahend), self.cap()) } - /// Copies a contiguous block of memory len long from src to dst + /// Copies a contiguous block of memory len long from `src` to `dst`. #[inline] unsafe fn copy(&self, dst: usize, src: usize, len: usize) { debug_assert!(dst + len <= self.cap(), @@ -171,7 +171,7 @@ impl VecDeque { len); } - /// Copies a contiguous block of memory len long from src to dst + /// Copies a contiguous block of memory len long from `src` to `dst`. #[inline] unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) { debug_assert!(dst + len <= self.cap(), @@ -191,9 +191,9 @@ impl VecDeque { len); } - /// Copies a potentially wrapping block of memory len long from src to dest. - /// (abs(dst - src) + len) must be no larger than cap() (There must be at - /// most one continuous overlapping region between src and dest). + /// Copies a potentially wrapping block of memory len long from `src` to `dest`. + /// `abs(dst - src) + len` must be no larger than `cap()`. (There must be at + /// most one continuous overlapping region between `src` and `dest`). unsafe fn wrap_copy(&self, dst: usize, src: usize, len: usize) { #[allow(dead_code)] fn diff(a: usize, b: usize) -> usize { @@ -219,7 +219,7 @@ impl VecDeque { match (dst_after_src, src_wraps, dst_wraps) { (_, false, false) => { - // src doesn't wrap, dst doesn't wrap + // `src` doesn't wrap, `dst` doesn't wrap. // // S . . . // 1 [_ _ A A B B C C _] @@ -229,7 +229,7 @@ impl VecDeque { self.copy(dst, src, len); } (false, false, true) => { - // dst before src, src doesn't wrap, dst wraps + // `dst` before `src`, `src` doesn't wrap, `dst` wraps. // // S . . . // 1 [A A B B _ _ _ C C] @@ -241,7 +241,7 @@ impl VecDeque { self.copy(0, src + dst_pre_wrap_len, len - dst_pre_wrap_len); } (true, false, true) => { - // src before dst, src doesn't wrap, dst wraps + // `src` before `dst`, `src` doesn't wrap, `dst` wraps. // // S . . . // 1 [C C _ _ _ A A B B] @@ -253,7 +253,7 @@ impl VecDeque { self.copy(dst, src, dst_pre_wrap_len); } (false, true, false) => { - // dst before src, src wraps, dst doesn't wrap + // `dst` before `src`, `src` wraps, `dst` doesn't wrap. // // . . S . // 1 [C C _ _ _ A A B B] @@ -265,7 +265,7 @@ impl VecDeque { self.copy(dst + src_pre_wrap_len, 0, len - src_pre_wrap_len); } (true, true, false) => { - // src before dst, src wraps, dst doesn't wrap + // `src` before `dst`, `src` wraps, `dst` doesn't wrap. // // . . S . // 1 [A A B B _ _ _ C C] @@ -277,7 +277,7 @@ impl VecDeque { self.copy(dst, src, src_pre_wrap_len); } (false, true, true) => { - // dst before src, src wraps, dst wraps + // `dst` before `src`, `src` wraps, `dst` wraps. // // . . . S . // 1 [A B C D _ E F G H] @@ -293,7 +293,7 @@ impl VecDeque { self.copy(0, delta, len - dst_pre_wrap_len); } (true, true, true) => { - // src before dst, src wraps, dst wraps + // `src` before `dst`, `src` wraps, `dst` wraps. // // . . S . . // 1 [A B C D _ E F G H] @@ -312,7 +312,7 @@ impl VecDeque { } /// Frobs the head and tail sections around to handle the fact that we - /// just reallocated. Unsafe because it trusts old_cap. + /// just reallocated. Unsafe because it trusts `old_cap`. #[inline] unsafe fn handle_cap_increase(&mut self, old_cap: usize) { let new_cap = self.cap(); @@ -333,7 +333,7 @@ impl VecDeque { if self.tail <= self.head { // A - // Nop + // No-op. } else if self.head < old_cap - self.tail { // B self.copy_nonoverlapping(old_cap, 0, self.head); @@ -1014,7 +1014,7 @@ impl VecDeque { tail: drain_tail, head: drain_head, // Crucially, we only create shared references from `self` here and read from - // it. We do not write to `self` nor reborrow to a mutable reference. + // it. We do not write to `self` nor reborrow to a mutable reference. // Hence the raw pointer we created above, for `deque`, remains valid. ring: unsafe { self.buffer_as_slice() }, }, @@ -2130,7 +2130,7 @@ impl fmt::Debug for Iter<'_, T> { } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { @@ -3125,5 +3125,4 @@ mod tests { assert_eq!(*a, 2); } } - } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 95b9dacf8565a..8bb73b12c345b 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -135,7 +135,7 @@ pub mod alloc; // Primitive types using the heaps above // Need to conditionally define the mod from `boxed.rs` to avoid -// duplicating the lang-items when building in test cfg; but also need +// duplicating the lang-items when building in test cfg, but also need // to allow code to have `use boxed::Box;` declarations. #[cfg(not(test))] pub mod boxed; diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index eb3410078513d..e32f7e717e324 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -46,7 +46,7 @@ macro_rules! vec { ($($x:expr,)*) => (vec![$($x),*]) } -// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is +// HACK(japaric): with `cfg(test)`, the inherent `[T]::into_vec` method, which is // required for this macro definition, is not available. Instead use the // `slice::into_vec` function which is only available with cfg(test) // NB see the slice::hack module in slice.rs for more information diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index fe28fe5095cce..06e871b437042 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -123,7 +123,7 @@ impl RawVec { /// capacity and alignment requirements for a `[T; cap]`. This is /// equivalent to calling RawVec::new when `cap` is 0 or T is /// zero-sized. Note that if `T` is zero-sized this means you will - /// *not* get a RawVec with the requested capacity! + /// **not** get a RawVec with the requested capacity! /// /// # Panics /// @@ -317,7 +317,7 @@ impl RawVec { } } None => { - // skip to 4 because tiny Vec's are dumb; but not if that + // skip to 4 because tiny Vec's are dumb, but not if that // would cause overflow let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 }; match self.a.alloc_array::(new_cap) { @@ -350,14 +350,15 @@ impl RawVec { let elem_size = mem::size_of::(); let old_layout = match self.current_layout() { Some(layout) => layout, - None => return false, // nothing to double + // Nothing to double. + None => return false, }; - // since we set the capacity to usize::MAX when elem_size is - // 0, getting to here necessarily means the RawVec is overfull. + // Since we set the capacity to `usize::MAX` when `elem_size` is + // 0, getting to here necessarily means the `RawVec` is overfull. assert!(elem_size != 0, "capacity overflow"); - // Since we guarantee that we never allocate more than isize::MAX + // Since we guarantee that we never allocate more than `isize::MAX` // bytes, `elem_size * self.cap <= isize::MAX` as a precondition, so // this can't overflow. // @@ -533,11 +534,11 @@ impl RawVec { .unwrap_or_else(|_| capacity_overflow()); // Here, `cap < used_cap + needed_extra_cap <= new_cap` - // (regardless of whether `self.cap - used_cap` wrapped). - // Therefore we can safely call grow_in_place. + // (regardless of whether `self.cap - used_cap` wrapped), therefore we can safely + // call `grow_in_place`. let new_layout = Layout::new::().repeat(new_cap).unwrap().0; - // FIXME: may crash and burn on over-reserve + // FIXME: may crash and burn on over-reserving. alloc_guard(new_layout.size()).unwrap_or_else(|_| capacity_overflow()); match self.a.grow_in_place( NonNull::from(self.ptr).cast(), old_layout, new_layout.size(), @@ -566,21 +567,21 @@ impl RawVec { pub fn shrink_to_fit(&mut self, amount: usize) { let elem_size = mem::size_of::(); - // Set the `cap` because they might be about to promote to a `Box<[T]>` + // Set the `cap` because they might be about to promote to a `Box<[T]>`. if elem_size == 0 { self.cap = amount; return; } - // This check is my waterloo; it's the only thing Vec wouldn't have to do. - assert!(self.cap >= amount, "Tried to shrink to a larger capacity"); + // This check is my waterloo; it's the only thing `Vec` wouldn't have to do. + assert!(self.cap >= amount, "tried to shrink to a larger capacity"); if amount == 0 { // We want to create a new zero-length vector within the - // same allocator. We use ptr::write to avoid an + // same allocator. We use `ptr::write` to avoid an // erroneous attempt to drop the contents, and we use - // ptr::read to sidestep condition against destructuring - // types that implement Drop. + // `ptr::read` to sidestep condition against destructuring + // types that implement `Drop`. unsafe { let a = ptr::read(&self.a as *const A); @@ -651,7 +652,7 @@ impl RawVec { return Ok(()); } - // Nothing we can really do about these checks :( + // Nothing we can really do about these checks. let new_cap = match strategy { Exact => used_cap.checked_add(needed_extra_cap).ok_or(CapacityOverflow)?, Amortized => self.amortized_new_size(used_cap, needed_extra_cap)?, @@ -786,7 +787,8 @@ mod tests { let a = BoundedAlloc { fuel: 500 }; let mut v: RawVec = RawVec::with_capacity_in(50, a); assert_eq!(v.a.fuel, 450); - v.reserve(50, 150); // (causes a realloc, thus using 50 + 150 = 200 units of fuel) + // Causes a realloc, thus using 50 + 150 = 200 units of fuel. + v.reserve(50, 150); assert_eq!(v.a.fuel, 250); } @@ -794,7 +796,7 @@ mod tests { fn reserve_does_not_overallocate() { { let mut v: RawVec = RawVec::new(); - // First `reserve` allocates like `reserve_exact` + // First `reserve` allocates like `reserve_exact`. v.reserve(0, 9); assert_eq!(9, v.cap()); } @@ -817,10 +819,8 @@ mod tests { // 3 is less than half of 12, so `reserve` must grow // exponentially. At the time of writing this test grow // factor is 2, so new capacity is 24, however, grow factor - // of 1.5 is OK too. Hence `>= 18` in assert. + // of 1.5 is ok too. Hence `>= 18` in assert. assert!(v.cap() >= 12 + 12 / 2); } } - - } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 12f75d84211e6..a53a7d49c5816 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1220,7 +1220,7 @@ pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. // `Weak::new` sets this to `usize::MAX` so that it doesn’t need - // to allocate space on the heap. That's not a value a real pointer + // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. ptr: NonNull>, } @@ -1482,9 +1482,9 @@ impl Default for Weak { } } -// NOTE: We checked_add here to deal with mem::forget safely. In particular -// if you mem::forget Rcs (or Weaks), the ref-count can overflow, and then -// you can free the allocation while outstanding Rcs (or Weaks) exist. +// NOTE: we checked_add here to deal with `mem::forget` safely. In particular +// if you `mem::forget` `Rc`s (or `Weak`s), the ref-count can overflow, and then +// you can free the allocation while outstanding `Rc`s (or `Weak`s) exist. // We abort because this is such a degenerate scenario that we don't care about // what happens -- no real program should ever experience this. // diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index c4f4a80a017df..1c32a155667f1 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -122,12 +122,12 @@ pub use core::slice::{RChunks, RChunksMut, RChunksExact, RChunksExactMut}; // Basic slice extension methods //////////////////////////////////////////////////////////////////////////////// -// HACK(japaric) needed for the implementation of `vec!` macro during testing +// HACK(japaric): needed for the implementation of `vec!` macro during testing // NB see the hack module in this file for more details #[cfg(test)] pub use hack::into_vec; -// HACK(japaric) needed for the implementation of `Vec::clone` during testing +// HACK(japaric): needed for the implementation of `Vec::clone` during testing // NB see the hack module in this file for more details #[cfg(test)] pub use hack::to_vec; @@ -831,7 +831,7 @@ unsafe fn merge(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F) impl Drop for MergeHole { fn drop(&mut self) { - // `T` is not a zero-sized type, so it's okay to divide by its size. + // `T` is not a zero-sized type, so it's ok to divide by its size. let len = (self.end as usize - self.start as usize) / mem::size_of::(); unsafe { ptr::copy_nonoverlapping(self.start, self.dest, len); } } diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index a36804bddff32..011de06560677 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -356,7 +356,7 @@ impl str { // This is the only conditional (contextual) but language-independent mapping // in `SpecialCasing.txt`, // so hard-code it rather than have a generic "condition" mechanism. - // See https://github.com/rust-lang/rust/issues/26035 + // See issue #26035. map_uppercase_sigma(self, i, &mut s) } else { match conversions::to_lower(c) { @@ -376,7 +376,7 @@ impl str { return s; fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) { - // See http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992 + // See . // for the definition of `Final_Sigma`. debug_assert!('Σ'.len_utf8() == 2); let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev()) && diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index b7d7995b540ba..fc18642d73248 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -234,7 +234,7 @@ pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. // `Weak::new` sets this to `usize::MAX` so that it doesn’t need - // to allocate space on the heap. That's not a value a real pointer + // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. ptr: NonNull>, } @@ -283,8 +283,8 @@ impl Arc { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn new(data: T) -> Arc { - // Start the weak pointer count as 1 which is the weak pointer that's - // held by all the strong pointers (kinda), see std/rc.rs for more info + // Start the weak pointer count at `1`, which is the weak pointer that's + // held by all the strong pointers (kinda), see `std/rc.rs` for more info. let x: Box<_> = box ArcInner { strong: atomic::AtomicUsize::new(1), weak: atomic::AtomicUsize::new(1), @@ -449,27 +449,26 @@ impl Arc { /// ``` #[stable(feature = "arc_weak", since = "1.4.0")] pub fn downgrade(this: &Self) -> Weak { - // This Relaxed is OK because we're checking the value in the CAS - // below. + // This `Relaxed` is ok because we're checking the value in the CAS below. let mut cur = this.inner().weak.load(Relaxed); loop { - // check if the weak counter is currently "locked"; if so, spin. + // Check if the weak counter is currently "locked"; if so, spin. if cur == usize::MAX { cur = this.inner().weak.load(Relaxed); continue; } // NOTE: this code currently ignores the possibility of overflow - // into usize::MAX; in general both Rc and Arc need to be adjusted + // into `usize::MAX`; in general both `Rc` and `Arc` need to be adjusted // to deal with overflow. - // Unlike with Clone(), we need this to be an Acquire read to + // Unlike with `Clone()`, we need this to be an `Acquire` read to // synchronize with the write coming from `is_unique`, so that the // events prior to that write happen before this read. match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) { Ok(_) => { - // Make sure we do not create a dangling Weak + // Make sure we do not create a dangling `Weak`. debug_assert!(!is_dangling(this.ptr)); return Weak { ptr: this.ptr }; } @@ -749,7 +748,7 @@ impl Clone for Arc { // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html) let old_size = self.inner().strong.fetch_add(1, Relaxed); - // However we need to guard against massive refcounts in case someone + // However we need to guard against massive ref counts in case someone // is `mem::forget`ing Arcs. If we don't do this the count can overflow // and users will use-after free. We racily saturate to `isize::MAX` on // the assumption that there aren't ~2 billion threads incrementing @@ -920,7 +919,7 @@ impl Arc { // // The acquire label here ensures a happens-before relationship with any // writes to `strong` (in particular in `Weak::upgrade`) prior to decrements - // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded + // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded // weak ref was never dropped, the CAS here will fail so we do not care to synchronize. if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() { // This needs to be an `Acquire` to synchronize with the decrement of the `strong` @@ -978,7 +977,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc { } // This fence is needed to prevent reordering of use of the data and - // deletion of the data. Because it is marked `Release`, the decreasing + // deletion of the data. Because it is marked `Release`, the decreasing // of the reference count synchronizes with this `Acquire` fence. This // means that use of the data happens before decreasing the reference // count, which happens before this fence, which happens before the @@ -1270,13 +1269,13 @@ impl Clone for Weak { } else { return Weak { ptr: self.ptr }; }; - // See comments in Arc::clone() for why this is relaxed. This can use a - // fetch_add (ignoring the lock) because the weak count is only locked + // See comments in `Arc::clone()` for why this is relaxed. This can use a + // `fetch_add` (ignoring the lock) because the weak count is only locked // where are *no other* weak pointers in existence. (So we can't be // running this code in that case). let old_size = inner.weak.fetch_add(1, Relaxed); - // See comments in Arc::clone() for why we do this (for mem::forget). + // See comments in `Arc::clone()` for why we do this (for `mem::forget`). if old_size > MAX_REFCOUNT { unsafe { abort(); diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index 2b63ac5c7d2f9..358ea2182a52d 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -35,8 +35,8 @@ fn hash(t: &T) -> u64 { s.finish() } -// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. -// See https://github.com/kripken/emscripten-fastcomp/issues/169 +// FIXME: instantiated functions with `i128` in the signature is not supported in Emscripten. +// See . #[cfg(not(target_os = "emscripten"))] #[test] fn test_boxed_hasher() { diff --git a/src/liballoc/tests/linked_list.rs b/src/liballoc/tests/linked_list.rs index 0fbfbdccd4537..ca05b1b236c8f 100644 --- a/src/liballoc/tests/linked_list.rs +++ b/src/liballoc/tests/linked_list.rs @@ -93,7 +93,7 @@ fn test_split_off() { } } - // no-op on the last index + // No-op on the last index. { let mut m = LinkedList::new(); m.push_back(1); diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 2a9fdfa9324d5..62e1b15908fff 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -509,7 +509,7 @@ fn test_rotate_left() { let expected: Vec<_> = (0..13).collect(); let mut v = Vec::new(); - // no-ops + // No-ops. v.clone_from(&expected); v.rotate_left(0); assert_eq!(v, expected); @@ -518,14 +518,14 @@ fn test_rotate_left() { let mut zst_array = [(), (), ()]; zst_array.rotate_left(2); - // happy path + // Happy path. v = (5..13).chain(0..5).collect(); v.rotate_left(8); assert_eq!(v, expected); let expected: Vec<_> = (0..1000).collect(); - // small rotations in large slice, uses ptr::copy + // Small rotations in large slice; uses `ptr::copy`. v = (2..1000).chain(0..2).collect(); v.rotate_left(998); assert_eq!(v, expected); @@ -533,7 +533,7 @@ fn test_rotate_left() { v.rotate_left(2); assert_eq!(v, expected); - // non-small prime rotation, has a few rounds of swapping + // Non-small prime rotation; has a few rounds of swapping. v = (389..1000).chain(0..389).collect(); v.rotate_left(1000-389); assert_eq!(v, expected); @@ -544,7 +544,7 @@ fn test_rotate_right() { let expected: Vec<_> = (0..13).collect(); let mut v = Vec::new(); - // no-ops + // No-ops. v.clone_from(&expected); v.rotate_right(0); assert_eq!(v, expected); @@ -553,14 +553,14 @@ fn test_rotate_right() { let mut zst_array = [(), (), ()]; zst_array.rotate_right(2); - // happy path + // Happy path. v = (5..13).chain(0..5).collect(); v.rotate_right(5); assert_eq!(v, expected); let expected: Vec<_> = (0..1000).collect(); - // small rotations in large slice, uses ptr::copy + // Small rotations in large slice; uses `ptr::copy`. v = (2..1000).chain(0..2).collect(); v.rotate_right(2); assert_eq!(v, expected); @@ -568,7 +568,7 @@ fn test_rotate_right() { v.rotate_right(998); assert_eq!(v, expected); - // non-small prime rotation, has a few rounds of swapping + // Non-small prime rotation; has a few rounds of swapping. v = (389..1000).chain(0..389).collect(); v.rotate_right(389); assert_eq!(v, expected); diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index a1dc763f6d8ff..f021c7a96513f 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -577,7 +577,7 @@ mod slice_index { in mod rangeinclusive { data: "hello"; // note: using 0 specifically ensures that the result of overflowing is 0..0, - // so that `get` doesn't simply return None for the wrong reason. + // so that `get` doesn't simply return `None` for the wrong reason. bad: data[0..=usize::max_value()]; message: "maximum usize"; } @@ -1551,7 +1551,7 @@ fn to_lowercase() { assert_eq!("".to_lowercase(), ""); assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé "); - // https://github.com/rust-lang/rust/issues/26035 + // See issue #26035. assert_eq!("ΑΣ".to_lowercase(), "ας"); assert_eq!("Α'Σ".to_lowercase(), "α'ς"); assert_eq!("Α''Σ".to_lowercase(), "α''ς"); diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 57723e4d21281..0dc1a7776e7aa 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -688,11 +688,10 @@ impl Vec { let mut ptr = self.as_mut_ptr().add(self.len); // Set the final length at the end, keeping in mind that // dropping an element might panic. Works around a missed - // optimization, as seen in the following issue: - // https://github.com/rust-lang/rust/issues/51802 + // optimization, as seen in issue #51802. let mut local_len = SetLenOnDrop::new(&mut self.len); - // drop any extra elements + // Drop any extra elements. for _ in len..current_len { local_len.decrement_len(1); ptr = ptr.offset(-1); @@ -1793,7 +1792,7 @@ trait SpecExtend { } impl SpecExtend for Vec - where I: Iterator, + where I: Iterator, { default fn from_iter(mut iterator: I) -> Self { // Unroll the first iteration, as the vector is going to be @@ -1823,7 +1822,7 @@ impl SpecExtend for Vec } impl SpecExtend for Vec - where I: TrustedLen, + where I: TrustedLen, { default fn from_iter(iterator: I) -> Self { let mut vector = Vec::new(); @@ -1886,7 +1885,7 @@ impl SpecExtend> for Vec { } impl<'a, T: 'a, I> SpecExtend<&'a T, I> for Vec - where I: Iterator, + where I: Iterator, T: Clone, { default fn from_iter(iterator: I) -> Self { @@ -1973,7 +1972,7 @@ impl Vec { #[inline] #[stable(feature = "vec_splice", since = "1.21.0")] pub fn splice(&mut self, range: R, replace_with: I) -> Splice<'_, I::IntoIter> - where R: RangeBounds, I: IntoIterator + where R: RangeBounds, I: IntoIterator { Splice { drain: self.drain(range), @@ -2201,7 +2200,7 @@ impl<'a, T: Clone> From<&'a mut [T]> for Vec { } #[stable(feature = "vec_from_cow_slice", since = "1.14.0")] -impl<'a, T> From> for Vec where [T]: ToOwned> { +impl<'a, T> From> for Vec where [T]: ToOwned> { fn from(s: Cow<'a, [T]>) -> Vec { s.into_owned() } @@ -2579,7 +2578,7 @@ impl Drop for Splice<'_, I> { } // There may be more elements. Use the lower bound as an estimate. - // FIXME: Is the upper bound a better guess? Or something else? + // FIXME: is the upper bound a better guess? Or something else? let (lower_bound, _upper_bound) = self.replace_with.size_hint(); if lower_bound > 0 { self.drain.move_tail(lower_bound); @@ -2609,7 +2608,7 @@ impl Drain<'_, T> { /// that have been moved out. /// Fill that range as much as possible with new elements from the `replace_with` iterator. /// Returns `true` if we filled the entire range. (`replace_with.next()` didn’t return `None`.) - unsafe fn fill>(&mut self, replace_with: &mut I) -> bool { + unsafe fn fill>(&mut self, replace_with: &mut I) -> bool { let vec = self.vec.as_mut(); let range_start = vec.len; let range_end = self.tail_start; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 8ae046c0796bc..aecfd387b3f19 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -413,7 +413,7 @@ impl DroplessArena { } #[derive(Default)] -// FIXME(@Zoxc): this type is entirely unused in rustc +// FIXME(Zoxc): this type is entirely unused in rustc. pub struct SyncTypedArena { lock: MTLock>, } @@ -421,7 +421,7 @@ pub struct SyncTypedArena { impl SyncTypedArena { #[inline(always)] pub fn alloc(&self, object: T) -> &mut T { - // Extend the lifetime of the result since it's limited to the lock guard + // Extend the lifetime of the result since it's limited to the lock guard. unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) } } @@ -430,7 +430,7 @@ impl SyncTypedArena { where T: Copy, { - // Extend the lifetime of the result since it's limited to the lock guard + // Extend the lifetime of the result since it's limited to the lock guard. unsafe { &mut *(self.lock.lock().alloc_slice(slice) as *mut [T]) } } @@ -453,13 +453,13 @@ impl SyncDroplessArena { #[inline(always)] pub fn alloc_raw(&self, bytes: usize, align: usize) -> &mut [u8] { - // Extend the lifetime of the result since it's limited to the lock guard + // Extend the lifetime of the result since it's limited to the lock guard. unsafe { &mut *(self.lock.lock().alloc_raw(bytes, align) as *mut [u8]) } } #[inline(always)] pub fn alloc(&self, object: T) -> &mut T { - // Extend the lifetime of the result since it's limited to the lock guard + // Extend the lifetime of the result since it's limited to the lock guard. unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) } } @@ -468,7 +468,7 @@ impl SyncDroplessArena { where T: Copy, { - // Extend the lifetime of the result since it's limited to the lock guard + // Extend the lifetime of the result since it's limited to the lock guard. unsafe { &mut *(self.lock.lock().alloc_slice(slice) as *mut [T]) } } } diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index f49e226a5cb68..5e335b713d897 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -27,7 +27,7 @@ fn size_align() -> (usize, usize) { /// All layouts have an associated non-negative size and a /// power-of-two alignment. /// -/// (Note however that layouts are *not* required to have positive +/// (Note however that layouts are **not** required to have positive /// size, even though many allocators require that all memory /// requests have positive size. A caller to the `Alloc::alloc` /// method must either ensure that conditions like this are met, or @@ -1057,7 +1057,7 @@ pub unsafe trait Alloc { /// `T` does not meet allocator's size or alignment constraints. /// /// For zero-sized `T`, may return either of `Ok` or `Err`, but - /// will *not* yield undefined behavior. + /// will **not** yield undefined behavior. /// /// Clients wishing to abort computation in response to an /// allocation error are encouraged to call the [`handle_alloc_error`] function, @@ -1124,7 +1124,7 @@ pub unsafe trait Alloc { /// constraints. /// /// For zero-sized `T` or `n == 0`, may return either of `Ok` or - /// `Err`, but will *not* yield undefined behavior. + /// `Err`, but will **not** yield undefined behavior. /// /// Always returns `Err` on arithmetic overflow. /// @@ -1171,7 +1171,7 @@ pub unsafe trait Alloc { /// constraints. /// /// For zero-sized `T` or `n_new == 0`, may return either of `Ok` or - /// `Err`, but will *not* yield undefined behavior. + /// `Err`, but will **not** yield undefined behavior. /// /// Always returns `Err` on arithmetic overflow. /// diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 8383d305518ab..c2c02de76389c 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -670,7 +670,7 @@ impl RefCell { pub fn into_inner(self) -> T { // Since this function takes `self` (the `RefCell`) by value, the // compiler statically verifies that it is not currently borrowed. - // Therefore the following assertion is just a `debug_assert!`. + // Therefore, the following assertion is just a `debug_assert!`. debug_assert!(self.borrow.get() == UNUSED); self.value.into_inner() } @@ -1308,10 +1308,10 @@ impl Drop for BorrowRefMut<'_> { impl<'b> BorrowRefMut<'b> { #[inline] fn new(borrow: &'b Cell) -> Option> { - // NOTE: Unlike BorrowRefMut::clone, new is called to create the initial + // NOTE: unlike `BorrowRefMut::clone`, new is called to create the initial // mutable reference, and so there must currently be no existing - // references. Thus, while clone increments the mutable refcount, here - // we explicitly only allow going from UNUSED to UNUSED - 1. + // references. Thus, while clone increments the mutable ref count, here + // we explicitly only allow going from `UNUSED` to `UNUSED - 1`. match borrow.get() { UNUSED => { borrow.set(UNUSED - 1); @@ -1321,7 +1321,7 @@ impl<'b> BorrowRefMut<'b> { } } - // Clone a `BorrowRefMut`. + // Clones a `BorrowRefMut`. // // This is only valid if each `BorrowRefMut` is used to track a mutable // reference to a distinct, nonoverlapping range of the original object. diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index 122e5f3affdc2..d5ff2260a619a 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -172,12 +172,12 @@ impl char { pub fn escape_unicode(self) -> EscapeUnicode { let c = self as u32; - // or-ing 1 ensures that for c==0 the code computes that one + // Or-ing 1 ensures that for `c == 0` the code computes that one // digit should be printed and (which is the same) avoids the - // (31 - 32) underflow + // `31 - 32` underflow. let msb = 31 - (c | 1).leading_zeros(); - // the index of the most significant hex digit + // The index of the most significant hex digit. let ms_hex_digit = msb / 4; EscapeUnicode { c: self, diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index b8d751cfbb6df..25a2d546d0e26 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -17,7 +17,7 @@ //! [`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. However, there are some cases +//! blanket implementation in the standard library. However, there are some cases //! where this is not possible, such as creating conversions into a type defined //! outside your library, so implementing [`Into`] instead of [`From`] is //! sometimes necessary. @@ -408,7 +408,7 @@ impl AsRef for &mut T where T: AsRef } } -// FIXME (#45742): replace the above impls for &/&mut with the following more general one: +// FIXME(#45742): replace the above impls for `&`/`&mut` with the following more general one: // // As lifts over Deref // impl AsRef for D where D::Target: AsRef { // fn as_ref(&self) -> &U { @@ -416,7 +416,7 @@ impl AsRef for &mut T where T: AsRef // } // } -// AsMut lifts over &mut +// `AsMut` lifts over `&mut`. #[stable(feature = "rust1", since = "1.0.0")] impl AsMut for &mut T where T: AsMut { @@ -425,7 +425,7 @@ impl AsMut for &mut T where T: AsMut } } -// FIXME (#45742): replace the above impl for &mut with the following more general one: +// FIXME(#45742): replace the above impl for &mut with the following more general one: // // AsMut lifts over DerefMut // impl AsMut for D where D::Target: AsMut { // fn as_mut(&mut self) -> &mut U { @@ -433,7 +433,7 @@ impl AsMut for &mut T where T: AsMut // } // } -// From implies Into +// `From` implies `Into`. #[stable(feature = "rust1", since = "1.0.0")] impl Into for T where U: From { @@ -442,14 +442,14 @@ impl Into for T where U: From } } -// From (and thus Into) is reflexive +// `From` (and thus `Into`) is reflexive. #[stable(feature = "rust1", since = "1.0.0")] impl From for T { fn from(t: T) -> T { t } } -// TryFrom implies TryInto +// `TryFrom` implies `TryInto`. #[unstable(feature = "try_from", issue = "33417")] impl TryInto for T where U: TryFrom { diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index d88793f2801e7..c4d877462e71c 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -10,7 +10,7 @@ use ::fmt; /// /// In essence, `*const c_void` is equivalent to C's `const void*` /// and `*mut c_void` is equivalent to C's `void*`. That said, this is -/// *not* the same as C's `void` return type, which is Rust's `()` type. +/// **not** the same as C's `void` return type, which is Rust's `()` type. /// /// To model pointers to opaque types in FFI, until `extern type` is /// stabilized, it is recommended to use a newtype wrapper around an empty diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 20c626cef1b16..78541b3378846 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -13,7 +13,7 @@ fn float_to_decimal_common_exact(fmt: &mut Formatter, num: &T, let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64 let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized(); // FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized - // `MaybeUninit` (here and elsewhere in this file). Revisit this once + // `MaybeUninit` (here and elsewhere in this file). Revisit this once // we decided whether that is valid or not. let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact, *num, sign, precision, diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 7efb7f31298bf..b68e7dbe67a3f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -237,7 +237,7 @@ pub struct Formatter<'a> { args: &'a [ArgumentV1<'a>], } -// NB. Argument is essentially an optimized partially applied formatting function, +// N.B., argument is essentially an optimized partially applied formatting function, // equivalent to `exists T.(&T, fn(&T, &mut Formatter) -> Result`. struct Void { @@ -1117,7 +1117,7 @@ impl<'a> Formatter<'a> { // all formatting traits can use. /// Performs the correct padding for an integer which has already been - /// emitted into a str. The str should *not* contain the sign for the + /// emitted into a str. The str should **not** contain the sign for the /// integer, that will be added by this method. /// /// # Arguments @@ -1695,8 +1695,7 @@ impl<'a> Formatter<'a> { self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0 } - // FIXME: Decide what public API we want for these two flags. - // https://github.com/rust-lang/rust/issues/48584 + // FIXME: decide what public API we want for these two flags. See issue #48584. fn debug_lower_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugLowerHex as u32) != 0 } fn debug_upper_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugUpperHex as u32) != 0 } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index b9fa364037108..be1b371701e26 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -9,8 +9,8 @@ use ptr; use mem::MaybeUninit; #[doc(hidden)] -trait Int: PartialEq + PartialOrd + Div + Rem + - Sub + Copy { +trait Int: PartialEq + PartialOrd + Div + Rem + + Sub + Copy { fn zero() -> Self; fn from_u8(u: u8) -> Self; fn to_u8(&self) -> u8; diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index 02457e00054c8..ea33b004c2fb3 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -65,7 +65,7 @@ pub trait Future { /// it should only be called when the future indicates that it is ready to /// make progress (by calling `wake()`). If you're familiar with the /// `poll(2)` or `select(2)` syscalls on Unix it's worth noting that futures - /// typically do *not* suffer the same problems of "all wakeups must poll + /// typically do **not** suffer the same problems of "all wakeups must poll /// all events"; they are more like `epoll(4)`. /// /// An implementation of `poll` should strive to return quickly, and should diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index f6de7566be914..56700d8de4cbd 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -747,7 +747,7 @@ extern "rust-intrinsic" { /// assert_eq!(bitpattern, 0x3F800000); /// ``` /// - /// Turning a pointer into a function pointer. This is *not* portable to + /// Turning a pointer into a function pointer. This is **not** portable to /// machines where function pointers and data pointers have different sizes. /// /// ``` @@ -963,7 +963,7 @@ extern "rust-intrinsic" { pub fn arith_offset(dst: *const T, offset: isize) -> *const T; /// Copies `count * size_of::()` bytes from `src` to `dst`. The source - /// and destination must *not* overlap. + /// and destination must **not** overlap. /// /// For regions of memory which might overlap, use [`copy`] instead. /// @@ -984,7 +984,7 @@ extern "rust-intrinsic" { /// * Both `src` and `dst` must be properly aligned. /// /// * The region of memory beginning at `src` with a size of `count * - /// size_of::()` bytes must *not* overlap with the region of memory + /// size_of::()` bytes must **not** overlap with the region of memory /// beginning at `dst` with the same size. /// /// Like [`read`], `copy_nonoverlapping` creates a bitwise copy of `T`, regardless of diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index 6f45f082d6a37..65a6e610efbc5 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -582,7 +582,7 @@ impl fmt::Debug for FromFn { pub fn successors(first: Option, succ: F) -> Successors where F: FnMut(&T) -> Option { - // If this function returned `impl Iterator` + // If this function returned `impl Iterator` // it could be based on `unfold` and not need a dedicated type. // However having a named `Successors` type allows it to be `Clone` when `T` and `F` are. Successors { diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 861e9c3157a79..b5274586eca6f 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -421,7 +421,7 @@ pub trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn chain(self, other: U) -> Chain where - Self: Sized, U: IntoIterator, + Self: Sized, U: IntoIterator, { Chain::new(self, other.into_iter()) } @@ -1565,7 +1565,7 @@ pub trait Iterator { #[inline] #[stable(feature = "iterator_try_fold", since = "1.27.0")] fn try_fold(&mut self, init: B, mut f: F) -> R where - Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try + Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try { let mut accum = init; while let Some(x) = self.next() { @@ -2275,7 +2275,7 @@ pub trait Iterator { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn cloned<'a, T: 'a>(self) -> Cloned - where Self: Sized + Iterator, T: Clone + where Self: Sized + Iterator, T: Clone { Cloned::new(self) } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 227fb22bc7d93..f2ebe1d3213f6 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -17,7 +17,7 @@ //! //! Please note that all of these details are currently not considered stable. //! -// FIXME: Fill me in with more detail when the interface settles +// FIXME: fill me in with more detail when the interface settles. //! This library is built on the assumption of a few existing symbols: //! //! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 3f7455aeb59b9..06f94f1b00373 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -831,7 +831,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { #[stable(feature = "discriminant_value", since = "1.21.0")] pub struct Discriminant(u64, PhantomData T>); -// N.B. These trait implementations cannot be derived because we don't want any bounds on T. +// N.B., these trait implementations cannot be derived because we don't want any bounds on `T`. #[stable(feature = "discriminant_value", since = "1.21.0")] impl Copy for Discriminant {} @@ -1053,7 +1053,7 @@ impl DerefMut for ManuallyDrop { /// This is exploited by the compiler for various optimizations, such as eliding /// run-time checks and optimizing `enum` layout. /// -/// Not initializing memory at all (instead of zero--initializing it) causes the same +/// Not initializing memory at all (instead of zero-initializing it) causes the same /// issue: after all, the initial value of the variable might just happen to be /// one that violates the invariant. /// @@ -1077,14 +1077,14 @@ impl DerefMut for ManuallyDrop { /// The compiler then knows to not optimize this code. #[allow(missing_debug_implementations)] #[unstable(feature = "maybe_uninit", issue = "53491")] -// NOTE after stabilizing `MaybeUninit` proceed to deprecate `mem::{uninitialized,zeroed}` +// NOTE: after stabilizing `MaybeUninit`, proceed to deprecate `mem::{uninitialized,zeroed}`. pub union MaybeUninit { uninit: (), value: ManuallyDrop, } impl MaybeUninit { - /// Create a new `MaybeUninit` initialized with the given value. + /// Creates a new `MaybeUninit` initialized with the given value. /// /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. /// It is your responsibility to make sure `T` gets dropped if it got initialized. @@ -1176,7 +1176,7 @@ impl MaybeUninit { /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state, otherwise this will immediately cause undefined behavior. // FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references - // to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make + // to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make // a final decision about the rules before stabilization. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] @@ -1192,7 +1192,7 @@ impl MaybeUninit { unsafe { &*self.value as *const T } } - /// Get sa mutable pointer to the contained value. Reading from this pointer or turning it + /// Gets a mutable pointer to the contained value. Reading from this pointer or turning it /// into a reference will be undefined behavior unless the `MaybeUninit` is initialized. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] diff --git a/src/libcore/num/bignum.rs b/src/libcore/num/bignum.rs index c3a42a0fc0494..6dc04d5f8feed 100644 --- a/src/libcore/num/bignum.rs +++ b/src/libcore/num/bignum.rs @@ -47,7 +47,8 @@ macro_rules! impl_full_ops { $( impl FullOps for $ty { fn full_add(self, other: $ty, carry: bool) -> (bool, $ty) { - // This cannot overflow; the output is between `0` and `2 * 2^nbits - 1`. + // This cannot overflow; + // the output is between `0` and `2 * 2^nbits - 1`. // FIXME: will LLVM optimize this into ADC or similar? let (v, carry1) = intrinsics::add_with_overflow(self, other); let (v, carry2) = intrinsics::add_with_overflow(v, if carry {1} else {0}); @@ -74,7 +75,8 @@ macro_rules! impl_full_ops { fn full_div_rem(self, other: $ty, borrow: $ty) -> ($ty, $ty) { debug_assert!(borrow < other); - // This cannot overflow; the output is between `0` and `other * (2^nbits - 1)`. + // This cannot overflow; + // the output is between `0` and `other * (2^nbits - 1)`. let nbits = mem::size_of::<$ty>() * 8; let lhs = ((borrow as $bigty) << nbits) | (self as $bigty); let rhs = other as $bigty; @@ -396,7 +398,7 @@ macro_rules! define_bignum { // Stupid slow base-2 long division taken from // https://en.wikipedia.org/wiki/Division_algorithm - // FIXME use a greater base ($ty) for the long division. + // FIXME: use a greater base ($ty) for the long division. assert!(!d.is_zero()); let digitbits = mem::size_of::<$ty>() * 8; for digit in &mut q.base[..] { @@ -478,7 +480,7 @@ macro_rules! define_bignum { /// The digit type for `Big32x40`. pub type Digit32 = u32; -define_bignum!(Big32x40: type=Digit32, n=40); +define_bignum!(Big32x40: type = Digit32, n=40); // this one is used for testing only. #[doc(hidden)] diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs index 3b57bb7544b35..da7491e027542 100644 --- a/src/libcore/num/dec2flt/algorithm.rs +++ b/src/libcore/num/dec2flt/algorithm.rs @@ -284,7 +284,7 @@ pub fn algorithm_m(f: &Big, e: i16) -> T { v = Big::from_small(1); v.mul_pow5(e_abs).mul_pow2(e_abs); } else { - // FIXME possible optimization: generalize big_to_fp so that we can do the equivalent of + // FIXME: possible optimization: generalize big_to_fp so that we can do the equivalent of // fp_to_float(big_to_fp(u)) here, only without the double rounding. u = f.clone(); u.mul_pow5(e_abs).mul_pow2(e_abs); @@ -301,7 +301,7 @@ pub fn algorithm_m(f: &Big, e: i16) -> T { // We have to stop at the minimum exponent, if we wait until `k < T::MIN_EXP_INT`, // then we'd be off by a factor of two. Unfortunately this means we have to special- // case normal numbers with the minimum exponent. - // FIXME find a more elegant formulation, but run the `tiny-pow10` test to make sure + // FIXME: find a more elegant formulation, but run the `tiny-pow10` test to make sure // that it's actually correct! if x >= min_sig && x <= max_sig { break; @@ -330,11 +330,11 @@ pub fn algorithm_m(f: &Big, e: i16) -> T { fn quick_start(u: &mut Big, v: &mut Big, k: &mut i16) { // The bit length is an estimate of the base two logarithm, and log(u / v) = log(u) - log(v). // The estimate is off by at most 1, but always an under-estimate, so the error on log(u) - // and log(v) are of the same sign and cancel out (if both are large). Therefore the error + // and log(v) are of the same sign and cancel out (if both are large). Therefore, the error // for log(u / v) is at most one as well. // The target ratio is one where u/v is in an in-range significand. Thus our termination // condition is log2(u / v) being the significand bits, plus/minus one. - // FIXME Looking at the second bit could improve the estimate and avoid some more divisions. + // FIXME: Looking at the second bit could improve the estimate and avoid some more divisions. let target_ratio = T::SIG_BITS as i16; let log2_u = u.bit_length() as i16; let log2_v = v.bit_length() as i16; @@ -380,7 +380,7 @@ fn underflow(x: Big, v: Big, rem: Big) -> T { // \-----/\-------/ \------------/ // q trunc. (represented by rem) // - // Therefore, when the rounded-off bits are != 0.5 ULP, they decide the rounding + // Therefore, when the rounded-off bits are not equal to half ULP, they decide the rounding // on their own. When they are equal and the remainder is non-zero, the value still // needs to be rounded up. Only when the rounded off bits are 1/2 and the remainder // is zero, we have a half-to-even situation. diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 47ea5aa5ff000..f6e60ed2fd863 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -264,7 +264,7 @@ fn convert(mut decimal: Decimal) -> Result { // Now the exponent certainly fits in 16 bit, which is used throughout the main algorithms. let e = e as i16; - // FIXME These bounds are rather conservative. A more careful analysis of the failure modes + // FIXME: These bounds are rather conservative. A more careful analysis of the failure modes // of Bellerophon could allow using it in more cases for a massive speed up. let exponent_in_range = table::MIN_E <= e && e <= table::MAX_E; let value_in_range = upper_bound <= T::MAX_NORMAL_DIGITS as u64; diff --git a/src/libcore/num/dec2flt/num.rs b/src/libcore/num/dec2flt/num.rs index 126713185711b..d02b69a4e83d8 100644 --- a/src/libcore/num/dec2flt/num.rs +++ b/src/libcore/num/dec2flt/num.rs @@ -1,12 +1,12 @@ //! Utility functions for bignums that don't make too much sense to turn into methods. -// FIXME This module's name is a bit unfortunate, since other modules also import `core::num`. +// FIXME: This module's name is a bit unfortunate, since other modules also import `core::num`. use cmp::Ordering::{self, Less, Equal, Greater}; pub use num::bignum::Big32x40 as Big; -/// Test whether truncating all bits less significant than `ones_place` introduces +/// Tests whether truncating all bits less significant than `ones_place` introduces /// a relative error less, equal, or greater than 0.5 ULP. pub fn compare_with_half_ulp(f: &Big, ones_place: usize) -> Ordering { if ones_place == 0 { @@ -36,7 +36,7 @@ pub fn compare_with_half_ulp(f: &Big, ones_place: usize) -> Ordering { /// 1. using `FromStr` on `&[u8]` requires `from_utf8_unchecked`, which is bad, and /// 2. piecing together the results of `integral.parse()` and `fractional.parse()` is /// more complicated than this entire function. -pub fn from_str_unchecked<'a, T>(bytes: T) -> u64 where T : IntoIterator { +pub fn from_str_unchecked<'a, T>(bytes: T) -> u64 where T : IntoIterator { let mut result = 0; for &c in bytes { result = result * 10 + (c - b'0') as u64; diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index b65f539b29c97..6fa0ad6aa6344 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -48,9 +48,9 @@ pub trait RawFloat : Copy + Debug + LowerExp - + Mul - + Div - + Neg + + Mul + + Div + + Neg { const INFINITY: Self; const NAN: Self; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index dc0580764acb7..b93c5c7f7fb8f 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -378,7 +378,7 @@ impl f32 { // When either x or y is a signalingNaN, then the result is according to 6.2. // // Since we do not support sNaN in Rust yet, we do not need to handle them. - // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by + // FIXME(nagisa): due to , we canonicalize by // multiplying by 1.0. Should switch to the `canonicalize` when it works. (if self.is_nan() || self < other { other } else { self }) * 1.0 } @@ -402,7 +402,7 @@ impl f32 { // When either x or y is a signalingNaN, then the result is according to 6.2. // // Since we do not support sNaN in Rust yet, we do not need to handle them. - // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by + // FIXME(nagisa): due to , we canonicalize by // multiplying by 1.0. Should switch to the `canonicalize` when it works. (if other.is_nan() || self < other { self } else { other }) * 1.0 } diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index 582fe22f85406..414d7fffeeb23 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -275,7 +275,7 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi for i in 0..len { if mant.is_zero() { // following digits are all zeroes, we stop here - // do *not* try to perform rounding! rather, fill remaining digits. + // do **not** try to perform rounding! rather, fill remaining digits. for c in &mut buf[i..len] { *c = b'0'; } return (len, k); } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 6fb67ea9c9acb..0a712a8053eb9 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1224,9 +1224,9 @@ $EndFeature, " concat!("Panic-free bitwise shift-left; yields `self << mask(rhs)`, where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. -Note that this is *not* the same as a rotate-left; the RHS of a wrapping shift-left is restricted to -the range of the type, rather than the bits shifted out of the LHS being returned to the other end. -The primitive integer types all implement a `rotate_left` function, which may be what you want +Note that this is **not** the same as a rotate-left; the RHS of a wrapping shift-left is restricted +to the range of the type, rather than the bits shifted out of the LHS being returned to the other +end. The primitive integer types all implement a `rotate_left` function, which may be what you want instead. # Examples @@ -1251,10 +1251,10 @@ $EndFeature, " concat!("Panic-free bitwise shift-right; yields `self >> mask(rhs)`, where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. -Note that this is *not* the same as a rotate-right; the RHS of a wrapping shift-right is restricted -to the range of the type, rather than the bits shifted out of the LHS being returned to the other -end. The primitive integer types all implement a `rotate_right` function, which may be what you want -instead. +Note that this is **not** the same as a rotate-right; the RHS of a wrapping shift-right is +restricted to the range of the type, rather than the bits shifted out of the LHS being returned to +the other end. The primitive integer types all implement a `rotate_right` function, which may be +what you want instead. # Examples @@ -3101,7 +3101,7 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0); where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. -Note that this is *not* the same as a rotate-left; the +Note that this is **not** the same as a rotate-left; the RHS of a wrapping shift-left is restricted to the range of the type, rather than the bits shifted out of the LHS being returned to the other end. The primitive integer @@ -3130,7 +3130,7 @@ assert_eq!(1", stringify!($SelfT), ".wrapping_shl(128), 1);", $EndFeature, " where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. -Note that this is *not* the same as a rotate-right; the +Note that this is **not** the same as a rotate-right; the RHS of a wrapping shift-right is restricted to the range of the type, rather than the bits shifted out of the LHS being returned to the other end. The primitive integer @@ -3582,7 +3582,7 @@ assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer } doc_comment! { - concat!("Returns `true` if and only if `self == 2^k` for some `k`. + concat!("Returns `true` if `self == 2^k` for some `k`. # Examples @@ -4774,7 +4774,7 @@ fn from_str_radix(src: &str, radix: u32) -> Result T::min_value(); // all valid digits are ascii, so we will just iterate over the utf8 bytes - // and cast them to chars. .to_digit() will safely return None for anything + // and cast them to chars. .to_digit() will safely return `None` for anything // other than a valid ascii digit for the given radix, including the first-byte // of multi-byte sequences let src = src.as_bytes(); diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 50e189c9e3640..4174ba308364c 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -95,7 +95,7 @@ macro_rules! sh_impl_unsigned { ) } -// FIXME (#23545): uncomment the remaining impls +// FIXME(#23545): uncomment the remaining impls macro_rules! sh_impl_all { ($($t:ident)*) => ($( //sh_impl_unsigned! { $t, u8 } @@ -832,7 +832,7 @@ assert_eq!(n.leading_zeros(), 2); } doc_comment! { - concat!("Returns `true` if and only if `self == 2^k` for some `k`. + concat!("Returns `true` if `self == 2^k` for some `k`. # Examples diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 0252edee23125..a7fdd9fc1d719 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -78,7 +78,7 @@ label="no implementation for `{Self} + {RHS}`", )] #[doc(alias = "+")] -pub trait Add { +pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -176,7 +176,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } #[rustc_on_unimplemented(message="cannot subtract `{RHS}` from `{Self}`", label="no implementation for `{Self} - {RHS}`")] #[doc(alias = "-")] -pub trait Sub { +pub trait Sub { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -296,7 +296,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } #[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`", label="no implementation for `{Self} * {RHS}`")] #[doc(alias = "*")] -pub trait Mul { +pub trait Mul { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -420,7 +420,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } #[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`", label="no implementation for `{Self} / {RHS}`")] #[doc(alias = "/")] -pub trait Div { +pub trait Div { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -505,7 +505,7 @@ div_impl_float! { f32 f64 } #[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`", label="no implementation for `{Self} % {RHS}`")] #[doc(alias = "%")] -pub trait Rem { +pub trait Rem { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output = Self; @@ -668,7 +668,7 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } label="no implementation for `{Self} += {Rhs}`")] #[doc(alias = "+")] #[doc(alias = "+=")] -pub trait AddAssign { +pub trait AddAssign { /// Performs the `+=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn add_assign(&mut self, rhs: Rhs); @@ -724,7 +724,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } label="no implementation for `{Self} -= {Rhs}`")] #[doc(alias = "-")] #[doc(alias = "-=")] -pub trait SubAssign { +pub trait SubAssign { /// Performs the `-=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn sub_assign(&mut self, rhs: Rhs); @@ -771,7 +771,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } label="no implementation for `{Self} *= {Rhs}`")] #[doc(alias = "*")] #[doc(alias = "*=")] -pub trait MulAssign { +pub trait MulAssign { /// Performs the `*=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn mul_assign(&mut self, rhs: Rhs); @@ -818,7 +818,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } label="no implementation for `{Self} /= {Rhs}`")] #[doc(alias = "/")] #[doc(alias = "/=")] -pub trait DivAssign { +pub trait DivAssign { /// Performs the `/=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn div_assign(&mut self, rhs: Rhs); @@ -868,7 +868,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } label="no implementation for `{Self} %= {Rhs}`")] #[doc(alias = "%")] #[doc(alias = "%=")] -pub trait RemAssign { +pub trait RemAssign { /// Performs the `%=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn rem_assign(&mut self, rhs: Rhs); diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 2c9bf248633c4..8274b4fcd2b1f 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -114,7 +114,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`", label="no implementation for `{Self} & {RHS}`")] -pub trait BitAnd { +pub trait BitAnd { /// The resulting type after applying the `&` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -198,7 +198,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`", label="no implementation for `{Self} | {RHS}`")] -pub trait BitOr { +pub trait BitOr { /// The resulting type after applying the `|` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -285,7 +285,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`", label="no implementation for `{Self} ^ {RHS}`")] -pub trait BitXor { +pub trait BitXor { /// The resulting type after applying the `^` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -373,7 +373,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`", label="no implementation for `{Self} << {RHS}`")] -pub trait Shl { +pub trait Shl { /// The resulting type after applying the `<<` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -482,7 +482,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`", label="no implementation for `{Self} >> {RHS}`")] -pub trait Shr { +pub trait Shr { /// The resulting type after applying the `>>` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -598,7 +598,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} &= {Rhs}`", label="no implementation for `{Self} &= {Rhs}`")] -pub trait BitAndAssign { +pub trait BitAndAssign { /// Performs the `&=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn bitand_assign(&mut self, rhs: Rhs); @@ -647,7 +647,7 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} |= {Rhs}`", label="no implementation for `{Self} |= {Rhs}`")] -pub trait BitOrAssign { +pub trait BitOrAssign { /// Performs the `|=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn bitor_assign(&mut self, rhs: Rhs); @@ -696,7 +696,7 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} ^= {Rhs}`", label="no implementation for `{Self} ^= {Rhs}`")] -pub trait BitXorAssign { +pub trait BitXorAssign { /// Performs the `^=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn bitxor_assign(&mut self, rhs: Rhs); @@ -743,7 +743,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} <<= {Rhs}`", label="no implementation for `{Self} <<= {Rhs}`")] -pub trait ShlAssign { +pub trait ShlAssign { /// Performs the `<<=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn shl_assign(&mut self, rhs: Rhs); @@ -811,7 +811,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_on_unimplemented(message="no implementation for `{Self} >>= {Rhs}`", label="no implementation for `{Self} >>= {Rhs}`")] -pub trait ShrAssign { +pub trait ShrAssign { /// Performs the `>>=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn shr_assign(&mut self, rhs: Rhs); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 76ef36ac30962..3796e17b3f91b 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -41,7 +41,7 @@ //! ``` //! // -// FIXME: Show how `Option` is used in practice, with lots of methods +// FIXME: show how `Option` is used in practice, with lots of methods // //! # Options and pointers ("nullable" pointers) //! @@ -1321,7 +1321,7 @@ impl> FromIterator> for Option { /// /// [`Iterator`]: ../iter/trait.Iterator.html #[inline] - fn from_iter>>(iter: I) -> Option { + fn from_iter>>(iter: I) -> Option { // FIXME(#11084): This could be replaced with Iterator::scan when this // performance bug is closed. @@ -1330,7 +1330,7 @@ impl> FromIterator> for Option { found_none: bool, } - impl>> Iterator for Adapter { + impl>> Iterator for Adapter { type Item = T; #[inline] diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index 1abc0a18a9cc9..99186ef397dd3 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -116,8 +116,8 @@ impl<'a> PanicInfo<'a> { /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] pub fn location(&self) -> Option<&Location> { - // NOTE: If this is changed to sometimes return None, - // deal with that case in std::panicking::default_hook and std::panicking::begin_panic_fmt. + // N.B., if this is changed to sometimes return `None`, deal with that case in + // `std::panicking::default_hook` and `std::panicking::begin_panic_fmt`. Some(&self.location) } } @@ -131,9 +131,9 @@ impl fmt::Display for PanicInfo<'_> { } else if let Some(payload) = self.payload.downcast_ref::<&'static str>() { write!(formatter, "'{}', ", payload)? } - // NOTE: we cannot use downcast_ref::() here - // since String is not available in libcore! - // The payload is a String when `std::panic!` is called with multiple arguments, + // NOTE: we cannot use `downcast_ref::()` here + // since `String` is not available in libcore! + // The payload is a `String` when `std::panic!` is called with multiple arguments, // but in that case the message is also available. self.location.fmt(formatter) diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index d9cdb2a2b8a9f..eefe145a2fc13 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -70,8 +70,9 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) unsafe { super::intrinsics::abort() } } - // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call - #[allow(improper_ctypes)] // PanicInfo contains a trait object which is not FFI safe + // NOTE: this function never crosses the FFI boundary; it's a Rust-to-Rust call. + // `PanicInfo` contains a trait object which is not FFI safe. + #[allow(improper_ctypes)] extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo) -> !; diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index ee9098d73ee92..c2d10b3f13f38 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -366,8 +366,8 @@ impl fmt::Pointer for Pin

{ } // Note: this means that any impl of `CoerceUnsized` that allows coercing from -// a type that impls `Deref` to a type that impls -// `Deref` is unsound. Any such impl would probably be unsound +// a type that impls `Deref` to a type that impls +// `Deref` is unsound. Any such impl would probably be unsound // for other reasons, though, so we just need to take care not to allow such // impls to land in std. #[stable(feature = "pin", since = "1.33.0")] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 866c8d0896b3c..f7918023eb6a5 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -185,7 +185,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { // The real `drop_in_place` -- the one that gets called implicitly when variables go // out of scope -- should have a safe reference and not a raw pointer as argument -// type. When we drop a local variable, we access it with a pointer that behaves +// type. When we drop a local variable, we access it with a pointer that behaves // like a safe reference; transmuting that to a raw pointer does not mean we can // actually access it with raw pointers. #[lang = "drop_in_place"] @@ -305,7 +305,7 @@ pub unsafe fn swap(x: *mut T, y: *mut T) { } /// Swaps `count * size_of::()` bytes between the two regions of memory -/// beginning at `x` and `y`. The two regions must *not* overlap. +/// beginning at `x` and `y`. The two regions must **not** overlap. /// /// # Safety /// @@ -317,7 +317,7 @@ pub unsafe fn swap(x: *mut T, y: *mut T) { /// * Both `x` and `y` must be properly aligned. /// /// * The region of memory beginning at `x` with a size of `count * -/// size_of::()` bytes must *not* overlap with the region of memory +/// size_of::()` bytes must **not** overlap with the region of memory /// beginning at `y` with the same size. /// /// Note that even if the effectively copied size (`count * size_of::()`) is `0`, @@ -366,13 +366,13 @@ pub(crate) unsafe fn swap_nonoverlapping_one(x: *mut T, y: *mut T) { #[inline] unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { - // The approach here is to utilize simd to swap x & y efficiently. Testing reveals + // The approach here is to utilize simd to swap `x` and `y` efficiently. Testing reveals // that swapping either 32 bytes or 64 bytes at a time is most efficient for Intel // Haswell E processors. LLVM is more able to optimize if we give a struct a - // #[repr(simd)], even if we don't actually use this struct directly. + // `#[repr(simd)]`, even if we don't actually use this struct directly. // - // FIXME repr(simd) broken on emscripten and redox - // It's also broken on big-endian powerpc64 and s390x. #42778 + // FIXME: `repr(simd)` broken on emscripten and redox + // It's also broken on big-endian powerpc64 and s390x (see issue #42778). #[cfg_attr(not(any(target_os = "emscripten", target_os = "redox", target_endian = "big")), repr(simd))] @@ -381,20 +381,20 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { let block_size = mem::size_of::(); - // Loop through x & y, copying them `Block` at a time + // Loop through `x` and `y`, copying them `Block` at a time // The optimizer should unroll the loop fully for most types - // N.B. We can't use a for loop as the `range` impl calls `mem::swap` recursively + // N.B., we can't use a for loop as the `range` impl calls `mem::swap` recursively. let mut i = 0; while i + block_size <= len { // Create some uninitialized memory as scratch space - // Declaring `t` here avoids aligning the stack when this loop is unused + // Declaring `t` here avoids aligning the stack when this loop is unused. let mut t = mem::MaybeUninit::::uninitialized(); let t = t.as_mut_ptr() as *mut u8; let x = x.add(i); let y = y.add(i); - // Swap a block of bytes of x & y, using t as a temporary buffer - // This should be optimized into efficient SIMD operations where available + // Swap a block of bytes of x & y, using t as a temporary buffer. + // This should be optimized into efficient SIMD operations where available. copy_nonoverlapping(x, t, block_size); copy_nonoverlapping(y, x, block_size); copy_nonoverlapping(t, y, block_size); @@ -402,7 +402,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { } if i < len { - // Swap any remaining bytes + // Swap any remaining bytes. let mut t = mem::MaybeUninit::::uninitialized(); let rem = len - i; @@ -1086,10 +1086,10 @@ impl *const T { /// /// The resulting pointer does not need to be in bounds, but it is /// potentially hazardous to dereference (which requires `unsafe`). - /// In particular, the resulting pointer may *not* be used to access a + /// In particular, the resulting pointer may **not** be used to access a /// different allocated object than the one `self` points to. In other /// words, `x.wrapping_offset(y.wrapping_offset_from(x))` is - /// *not* the same as `y`, and dereferencing it is undefined behavior + /// **not** the same as `y`, and dereferencing it is undefined behavior /// unless `x` and `y` point into the same allocated object. /// /// Always use `.offset(count)` instead when possible, because `offset` @@ -1501,7 +1501,7 @@ impl *const T { } /// Copies `count * size_of` bytes from `self` to `dest`. The source - /// and destination may *not* overlap. + /// and destination may **not** overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. /// @@ -1705,10 +1705,10 @@ impl *mut T { /// /// The resulting pointer does not need to be in bounds, but it is /// potentially hazardous to dereference (which requires `unsafe`). - /// In particular, the resulting pointer may *not* be used to access a + /// In particular, the resulting pointer may **not** be used to access a /// different allocated object than the one `self` points to. In other /// words, `x.wrapping_offset(y.wrapping_offset_from(x))` is - /// *not* the same as `y`, and dereferencing it is undefined behavior + /// **not** the same as `y`, and dereferencing it is undefined behavior /// unless `x` and `y` point into the same allocated object. /// /// Always use `.offset(count)` instead when possible, because `offset` @@ -2139,7 +2139,7 @@ impl *mut T { } /// Copies `count * size_of` bytes from `self` to `dest`. The source - /// and destination may *not* overlap. + /// and destination may **not** overlap. /// /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. /// @@ -2171,7 +2171,7 @@ impl *mut T { } /// Copies `count * size_of` bytes from `src` to `self`. The source - /// and destination may *not* overlap. + /// and destination may **not** overlap. /// /// NOTE: this has the *opposite* argument order of [`ptr::copy_nonoverlapping`]. /// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 92d29f6ee8a30..467792882ba82 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -91,7 +91,7 @@ //! is just a synonym for [`Result`]``.* //! //! This method doesn't produce a value, but the write may -//! fail. It's crucial to handle the error case, and *not* write +//! fail. It's crucial to handle the error case, and **not** write //! something like this: //! //! ```no_run @@ -1203,7 +1203,7 @@ impl> FromIterator> for Result { /// assert!(res == Ok(vec![2, 3])); /// ``` #[inline] - fn from_iter>>(iter: I) -> Result { + fn from_iter>>(iter: I) -> Result { // FIXME(#11084): This could be replaced with Iterator::scan when this // performance bug is closed. @@ -1212,7 +1212,7 @@ impl> FromIterator> for Result { err: Option, } - impl>> Iterator for Adapter { + impl>> Iterator for Adapter { type Item = T; #[inline] diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index acca9748372ca..ad6feb5043ae2 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -451,14 +451,14 @@ impl [T] { let ln = self.len(); // For very small types, all the individual reads in the normal - // path perform poorly. We can do better, given efficient unaligned + // path perform poorly. We can do better, given efficient unaligned // load/store, by loading a larger chunk and reversing a register. // Ideally LLVM would do this for us, as it knows better than we do // whether unaligned reads are efficient (since that changes between // different ARM versions, for example) and what the best chunk size - // would be. Unfortunately, as of LLVM 4.0 (2017-05) it only unrolls - // the loop, so we need to do this ourselves. (Hypothesis: reverse + // would be. Unfortunately, as of LLVM 4.0 (2017-05) it only unrolls + // the loop, so we need to do this ourselves. (Hypothesis: reverse // is troublesome because the sides can be aligned differently -- // will be, when the length is odd -- so there's no way of emitting // pre- and postludes to use fully-aligned SIMD in the middle.) @@ -1647,7 +1647,7 @@ impl [T] { // over all the elements, swapping as we go so that at the end // the elements we wish to keep are in the front, and those we // wish to reject are at the back. We can then split the slice. - // This operation is still O(n). + // This operation is still `O(n)`. // // Example: We start in this state, where `r` represents "next // read" and `w` represents "next_write`. @@ -1658,9 +1658,9 @@ impl [T] { // +---+---+---+---+---+---+ // w // - // Comparing self[r] against self[w-1], this is not a duplicate, so - // we swap self[r] and self[w] (no effect as r==w) and then increment both - // r and w, leaving us with: + // Comparing `self[r]` against `self[w - 1]`, this is not a duplicate, so + // we swap `self[r]` and `self[w]` (no effect as `r == w`) and then increment both + // `r` and `w`, leaving us with: // // r // +---+---+---+---+---+---+ @@ -1668,7 +1668,7 @@ impl [T] { // +---+---+---+---+---+---+ // w // - // Comparing self[r] against self[w-1], this value is a duplicate, + // Comparing `self[r]` against `self[w - 1]`, this value is a duplicate, // so we increment `r` but leave everything else unchanged: // // r @@ -1677,8 +1677,8 @@ impl [T] { // +---+---+---+---+---+---+ // w // - // Comparing self[r] against self[w-1], this is not a duplicate, - // so swap self[r] and self[w] and advance r and w: + // Comparing `self[r]` against `self[w - 1]`, this is not a duplicate, + // so swap `self[r]` and `self[w]` and advance `r` and `w`: // // r // +---+---+---+---+---+---+ @@ -1694,7 +1694,7 @@ impl [T] { // +---+---+---+---+---+---+ // w // - // Duplicate, advance r. End of slice. Split at w. + // Duplicate, advance `r`. End of slice. Split at `w`. let len = self.len(); if len <= 1 { @@ -1894,7 +1894,7 @@ impl [T] { pub fn clone_from_slice(&mut self, src: &[T]) where T: Clone { assert!(self.len() == src.len(), "destination and source slices have different lengths"); - // NOTE: We need to explicitly slice them to the same length + // NOTE: we need to explicitly slice them to the same length // for bounds checking to be elided, and the optimizer will // generate memcpy for simple cases (for example T = u8). let len = self.len(); @@ -2106,8 +2106,8 @@ impl [T] { #[inline] fn gcd(a: usize, b: usize) -> usize { // iterative stein’s algorithm - // We should still make this `const fn` (and revert to recursive algorithm if we do) - // because relying on llvm to consteval all this is… well, it makes me uncomfortable. + // We should still make this `const fn` (and revert to recursive algorithm if we do), + // because relying on LLVM to const-eval all this does not make me comfortable. let (ctz_a, mut ctz_b) = unsafe { if a == 0 { return b; } if b == 0 { return a; } @@ -2176,19 +2176,19 @@ impl [T] { pub unsafe fn align_to(&self) -> (&[T], &[U], &[T]) { // Note that most of this function will be constant-evaluated, if ::mem::size_of::() == 0 || ::mem::size_of::() == 0 { - // handle ZSTs specially, which is – don't handle them at all. + // Handle ZSTs specially, which is -- don't handle them at all. return (self, &[], &[]); } - // First, find at what point do we split between the first and 2nd slice. Easy with - // ptr.align_offset. + // First, find at what point do we split between the first and 2nd slice -- easy with + // `ptr.align_offset`. let ptr = self.as_ptr(); let offset = ::ptr::align_offset(ptr, ::mem::align_of::()); if offset > self.len() { (self, &[], &[]) } else { let (left, rest) = self.split_at(offset); - // now `rest` is definitely aligned, so `from_raw_parts_mut` below is okay + // Now `rest` is definitely aligned, so `from_raw_parts_mut` below is ok. let (us_len, ts_len) = rest.align_to_offsets::(); (left, from_raw_parts(rest.as_ptr() as *const U, us_len), @@ -2241,7 +2241,7 @@ impl [T] { (self, &mut [], &mut []) } else { let (left, rest) = self.split_at_mut(offset); - // now `rest` is definitely aligned, so `from_raw_parts_mut` below is okay + // now `rest` is definitely aligned, so `from_raw_parts_mut` below is ok let (us_len, ts_len) = rest.align_to_offsets::(); let mut_ptr = rest.as_mut_ptr(); (left, @@ -2873,7 +2873,7 @@ macro_rules! iterator { #[inline(always)] unsafe fn post_inc_start(&mut self, offset: isize) -> * $raw_mut T { if mem::size_of::() == 0 { - // This is *reducing* the length. `ptr` never changes with ZST. + // This is *reducing* the length. `ptr` never changes with ZST. self.end = (self.end as * $raw_mut u8).wrapping_offset(-offset) as * $raw_mut T; self.ptr } else { @@ -2970,7 +2970,7 @@ macro_rules! iterator { #[inline] fn try_fold(&mut self, init: B, mut f: F) -> R where - Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try + Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try { // manual unrolling is needed when there are conditional exits from the loop let mut accum = init; @@ -3060,7 +3060,7 @@ macro_rules! iterator { #[inline] fn try_rfold(&mut self, init: B, mut f: F) -> R where - Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try + Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try { // manual unrolling is needed when there are conditional exits from the loop let mut accum = init; @@ -3124,9 +3124,10 @@ macro_rules! iterator { #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { ptr: *const T, - end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that - // ptr == end is a quick test for the Iterator being empty, that works - // for both ZST and non-ZST. + // If `T` is a ZST, this is actually `ptr + len`. This encoding is picked so that + // `ptr == end` is a quick test for the `Iterator` being empty, which works + // for both ZST and non-ZST. + end: *const T, _marker: marker::PhantomData<&'a T>, } @@ -3226,9 +3227,10 @@ impl AsRef<[T]> for Iter<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { ptr: *mut T, - end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that - // ptr == end is a quick test for the Iterator being empty, that works - // for both ZST and non-ZST. + // If `T` is a ZST, this is actually `ptr + len`. This encoding is picked so that + // `ptr == end` is a quick test for the `Iterator` being empty, that works + // for both ZST and non-ZST. + end: *mut T, _marker: marker::PhantomData<&'a mut T>, } @@ -3321,7 +3323,7 @@ impl fmt::Debug for Split<'_, T, P> where P: FnMut(&T) -> bool } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Split<'_, T, P> where P: Clone + FnMut(&T) -> bool { fn clone(&self) -> Self { @@ -3432,7 +3434,8 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool { fn next(&mut self) -> Option<&'a mut [T]> { if self.finished { return None; } - let idx_opt = { // work around borrowck limitations + // Work around borrowck limitations. + let idx_opt = { let pred = &mut self.pred; self.v.iter().position(|x| (*pred)(x)) }; @@ -3452,8 +3455,8 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool { if self.finished { (0, Some(0)) } else { - // if the predicate doesn't match anything, we yield one slice - // if it matches every element, we yield len+1 empty slices. + // If the predicate doesn't match anything, we yield one slice + // if it matches every element, we yield `len + 1` empty slices. (1, Some(self.v.len() + 1)) } } @@ -3610,7 +3613,7 @@ struct GenericSplitN { count: usize, } -impl> Iterator for GenericSplitN { +impl> Iterator for GenericSplitN { type Item = T; #[inline] @@ -3758,7 +3761,7 @@ pub struct Windows<'a, T:'a> { size: usize } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Windows<'_, T> { fn clone(&self) -> Self { @@ -3871,7 +3874,7 @@ pub struct Chunks<'a, T:'a> { chunk_size: usize } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Chunks<'_, T> { fn clone(&self) -> Self { @@ -4132,7 +4135,7 @@ impl<'a, T> ChunksExact<'a, T> { } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "chunks_exact", since = "1.31.0")] impl Clone for ChunksExact<'_, T> { fn clone(&self) -> Self { @@ -4359,7 +4362,7 @@ pub struct RChunks<'a, T:'a> { chunk_size: usize } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rchunks", since = "1.31.0")] impl<'a, T> Clone for RChunks<'a, T> { fn clone(&self) -> RChunks<'a, T> { @@ -4628,7 +4631,7 @@ impl<'a, T> RChunksExact<'a, T> { } } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): Remove in favor of `#[derive(Clone)]`. #[stable(feature = "rchunks", since = "1.31.0")] impl<'a, T> Clone for RChunksExact<'a, T> { fn clone(&self) -> RChunksExact<'a, T> { diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index 3f84faa049939..543365bde6639 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -225,7 +225,7 @@ fn partition_in_blocks(v: &mut [T], pivot: &T, is_less: &mut F) -> usize let mut end_r = ptr::null_mut(); let mut offsets_r: [MaybeUninit; BLOCK] = uninitialized_array![u8; BLOCK]; - // FIXME: When we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather + // FIXME: when we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather // than two fixed-size arrays of length `BLOCK`. VLAs might be more cache-efficient. // Returns the number of elements between pointers `l` (inclusive) and `r` (exclusive). diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 76a45e53684bd..812e28077eb9e 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -502,21 +502,21 @@ pub fn next_code_point<'a, I: Iterator>(bytes: &mut I) -> Option< return Some(x as u32) } - // Multibyte case follows - // Decode from a byte combination out of: [[[x y] z] w] - // NOTE: Performance is sensitive to the exact formulation here + // Multibyte case follows. + // Decode from a byte combination out of: `[[[x y] z] w]`. + // NOTE: performance is sensitive to the exact formulation here let init = utf8_first_byte(x, 2); let y = unwrap_or_0(bytes.next()); let mut ch = utf8_acc_cont_byte(init, y); if x >= 0xE0 { - // [[x y z] w] case - // 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid + // `[[x y z] w]` case. + // 5th bit in `0xE0 .. 0xEF` is always clear, so `init` is still valid. let z = unwrap_or_0(bytes.next()); let y_z = utf8_acc_cont_byte((y & CONT_MASK) as u32, z); ch = init << 12 | y_z; if x >= 0xF0 { - // [x y z w] case - // use only the lower 3 bits of `init` + // `[x y z w]` case. + // Use only the lower 3 bits of `init`. let w = unwrap_or_0(bytes.next()); ch = (init & 7) << 18 | utf8_acc_cont_byte(y_z, w); } @@ -531,14 +531,14 @@ pub fn next_code_point<'a, I: Iterator>(bytes: &mut I) -> Option< fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option where I: DoubleEndedIterator, { - // Decode UTF-8 + // Decode UTF-8. let w = match *bytes.next_back()? { next_byte if next_byte < 128 => return Some(next_byte as u32), back_byte => back_byte, }; - // Multibyte case follows - // Decode from a byte combination out of: [x [y [z w]]] + // Multibyte case follows. + // Decode from a byte combination out of: `[x [y [z w]]]`. let mut ch; let z = unwrap_or_0(bytes.next_back()); ch = utf8_first_byte(z, 2); @@ -564,7 +564,7 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn next(&mut self) -> Option { next_code_point(&mut self.iter).map(|ch| { - // str invariant says `ch` is a valid Unicode Scalar Value + // `str` invariant says `ch` is a valid Unicode Scalar Value. unsafe { char::from_u32_unchecked(ch) } @@ -573,7 +573,7 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn count(self) -> usize { - // length in `char` is equal to the number of non-continuation bytes + // Length in `char`s is equal to the number of non-continuation bytes. let bytes_len = self.iter.len(); let mut cont_bytes = 0; for &byte in self.iter { @@ -603,7 +603,7 @@ impl<'a> DoubleEndedIterator for Chars<'a> { #[inline] fn next_back(&mut self) -> Option { next_code_point_reverse(&mut self.iter).map(|ch| { - // str invariant says `ch` is a valid Unicode Scalar Value + // `str` invariant says `ch` is a valid Unicode Scalar Value. unsafe { char::from_u32_unchecked(ch) } diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 2571780ad0bab..fc1399549a5c4 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -313,7 +313,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> { // ꁁ (U+A041 YI SYLLABLE PA), utf-8 `EA 81 81` will have us always find // the second byte when searching for the third. // - // However, this is totally okay. While we have the invariant that + // However, this is totally ok. While we have the invariant that // self.finger is on a UTF8 boundary, this invariant is not relied upon // within this method (it is relied upon in CharSearcher::next()). // diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 8c5dde7dc271b..11db492174e46 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -2432,7 +2432,7 @@ pub fn fence(order: Ordering) { /// # Examples /// /// Without `compiler_fence`, the `assert_eq!` in following code -/// is *not* guaranteed to succeed, despite everything happening in a single thread. +/// is **not** guaranteed to succeed, despite everything happening in a single thread. /// To see why, remember that the compiler is free to swap the stores to /// `IMPORTANT_VARIABLE` and `IS_READ` since they are both /// `Ordering::Relaxed`. If it does, and the signal handler is invoked right diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index bf3039a7e51e8..45c9ad08b4c87 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -113,8 +113,8 @@ fn test_custom_state() { assert_eq!(hash(&Custom { hash: 5 }), 5); } -// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. -// See https://github.com/kripken/emscripten-fastcomp/issues/169 +// FIXME: instantiated functions with i128 in the signature is not supported in Emscripten. +// See . #[cfg(not(target_os = "emscripten"))] #[test] fn test_indirect_hasher() { diff --git a/src/libcore/tests/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index 8f1cd32c3563c..2b582cf8a7fea 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -23,7 +23,7 @@ macro_rules! test_literal { }) } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn ordinary() { test_literal!(1.0); @@ -34,7 +34,7 @@ fn ordinary() { test_literal!(2.2250738585072014e-308); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn special_code_paths() { test_literal!(36893488147419103229.0); // 2^65 - 3, triggers half-to-even with even significand diff --git a/src/libcore/tests/num/dec2flt/rawfp.rs b/src/libcore/tests/num/dec2flt/rawfp.rs index 747c1bfa3f9c2..002f8a22a41b4 100644 --- a/src/libcore/tests/num/dec2flt/rawfp.rs +++ b/src/libcore/tests/num/dec2flt/rawfp.rs @@ -76,7 +76,7 @@ fn rounding_overflow() { assert_eq!(rounded.k, adjusted_k + 1); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn prev_float_monotonic() { let mut x = 1.0; @@ -112,7 +112,7 @@ fn next_float_inf() { assert_eq!(next_float(f64::INFINITY), f64::INFINITY); } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn next_prev_identity() { for &x in &SOME_FLOATS { @@ -123,7 +123,7 @@ fn next_prev_identity() { } } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn next_float_monotonic() { let mut x = 0.49999999999999; diff --git a/src/libcore/tests/num/flt2dec/mod.rs b/src/libcore/tests/num/flt2dec/mod.rs index fed9ce73b2a8e..00f2f45b70d0b 100644 --- a/src/libcore/tests/num/flt2dec/mod.rs +++ b/src/libcore/tests/num/flt2dec/mod.rs @@ -831,7 +831,7 @@ pub fn to_exact_exp_str_test(mut f_: F) 0000000000000000000000000000000000000000000000000000000000000000\ 0000000000000000000000000000000000000000000000000000000000000000e308"); - // okay, this is becoming tough. fortunately for us, this is almost the worst case. + // ok, this is becoming tough. fortunately for us, this is almost the worst case. let minf64 = ldexp_f64(1.0, -1074); assert_eq!(to_string(f, minf64, Minus, 1, false), "5e-324"); assert_eq!(to_string(f, minf64, Minus, 2, false), "4.9e-324"); diff --git a/src/libcore/tests/num/flt2dec/strategy/dragon.rs b/src/libcore/tests/num/flt2dec/strategy/dragon.rs index 1803e39b46df3..0cec78d3f9274 100644 --- a/src/libcore/tests/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/tests/num/flt2dec/strategy/dragon.rs @@ -14,7 +14,7 @@ fn test_mul_pow10() { } } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn shortest_sanity_test() { f64_shortest_sanity_test(format_shortest); diff --git a/src/libcore/tests/num/flt2dec/strategy/grisu.rs b/src/libcore/tests/num/flt2dec/strategy/grisu.rs index 53e9f12ae0f14..41815be28b716 100644 --- a/src/libcore/tests/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/tests/num/flt2dec/strategy/grisu.rs @@ -27,7 +27,7 @@ fn test_max_pow10_no_more_than() { } -#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 +#[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn shortest_sanity_test() { f64_shortest_sanity_test(format_shortest); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index ab638e06cc10d..d2fab86d573ef 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -52,9 +52,9 @@ macro_rules! assume_usize_width { /// Helper function for testing numeric operations pub fn test_num(ten: T, two: T) where T: PartialEq - + Add + Sub - + Mul + Div - + Rem + Debug + + Add + Sub + + Mul + Div + + Rem + Debug + Copy { assert_eq!(ten.add(two), ten + two); diff --git a/src/libcore/tests/pattern.rs b/src/libcore/tests/pattern.rs index b78ed0210770f..c4ec2b0e5e8a2 100644 --- a/src/libcore/tests/pattern.rs +++ b/src/libcore/tests/pattern.rs @@ -1,7 +1,6 @@ use std::str::pattern::*; -// This macro makes it easier to write -// tests that do a series of iterations +// This macro makes it easier to write tests that do a series of iterations. macro_rules! search_asserts { ($haystack:expr, $needle:expr, $testname:expr, [$($func:ident),*], $result:expr) => { let mut searcher = $needle.into_searcher($haystack); @@ -10,11 +9,10 @@ macro_rules! search_asserts { } } -/// Combined enum for the results of next() and next_match()/next_reject() +/// Combined enum for the results of `next()` and `next_match()`/`next_reject()`. #[derive(Debug, PartialEq, Eq)] enum Step { - // variant names purposely chosen to - // be the same length for easy alignment + // Variant names purposely chosen to be the same length for easy alignment. Matches(usize, usize), Rejects(usize, usize), InRange(usize, usize), @@ -44,11 +42,11 @@ impl From> for Step { // ignore-tidy-linelength -// FIXME(Manishearth) these tests focus on single-character searching (CharSearcher) -// and on next()/next_match(), not next_reject(). This is because -// the memchr changes make next_match() for single chars complex, but next_reject() -// continues to use next() under the hood. We should add more test cases for all -// of these, as well as tests for StrSearcher and higher level tests for str::find() (etc) +// FIXME(Manishearth): these tests focus on single-character searching (`CharSearcher`), +// and on `next()`/`next_match()`, not `next_reject()`. This is because +// the `memchr` changes make `next_match()` for single chars complex, but `next_reject()` +// continues to `use next()` under the hood. We should add more test cases for all +// of these, as well as tests for `StrSearcher` and higher level tests for `str::find()`, etc. #[test] fn test_simple_iteration() { @@ -106,21 +104,21 @@ fn test_simple_search() { ); } -// Á, 각, ก, 😀 all end in 0x81 -// 🁀, ᘀ do not end in 0x81 but contain the byte -// ꁁ has 0x81 as its second and third bytes. +// `Á`, `각`, `ก`, `😀` all end in `0x81`. +// `🁀`, `ᘀ` do not end in `0x81`, but contain the byte. +// `ꁁ` has `0x81` as its second and third bytes. // -// The memchr-using implementation of next_match -// and next_match_back temporarily violate +// The `memchr`-using implementation of `next_match` +// and `next_match_back` temporarily violate // the property that the search is always on a unicode boundary, -// which is fine as long as this never reaches next() or next_back(). -// So we test if next() is correct after each next_match() as well. +// which is fine as long as this never reaches `next()` or `next_back()`. +// So we test if `next()` is correct after each `next_match()` as well. const STRESS: &str = "Áa🁀bÁꁁfg😁각กᘀ각aÁ각ꁁก😁a"; #[test] fn test_stress_indices() { - // this isn't really a test, more of documentation on the indices of each character in the stresstest string - + // This isn't really a test -- more of documentation on the indices of each character in the + // stress-test string. search_asserts!(STRESS, 'x', "Indices of characters in stress test", [next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next, next], [Rejects(0, 2), // Á @@ -255,8 +253,7 @@ fn test_reverse_search_shared_bytes() { #[test] fn double_ended_regression_test() { - // https://github.com/rust-lang/rust/issues/47175 - // Ensures that double ended searching comes to a convergence + // Issue #47175: ensure that double-ended searching comes to a convergence. search_asserts!("abcdeabcdeabcde", 'a', "alternating double ended search", [next_match, next_match_back, next_match, next_match_back], [InRange(0, 1), InRange(10, 11), InRange(5, 6), Done] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 04d646ea01d03..110a914ac20b6 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -810,7 +810,7 @@ mod slice_index { // optional: // // one or more similar inputs for which data[input] succeeds, - // and the corresponding output as an array. This helps validate + // and the corresponding output as an array. This helps validate // "critical points" where an input range straddles the boundary // between valid and invalid. // (such as the input `len..len`, which is just barely valid) @@ -938,7 +938,7 @@ mod slice_index { data: [0, 1]; // note: using 0 specifically ensures that the result of overflowing is 0..0, - // so that `get` doesn't simply return None for the wrong reason. + // so that `get` doesn't simply return `None` for the wrong reason. bad: data[0 ..= ::std::usize::MAX]; message: "maximum usize"; } diff --git a/src/libcore/time.rs b/src/libcore/time.rs index ac7e11754aa3a..0797bf4b8bb4b 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -679,14 +679,14 @@ macro_rules! sum_durations { #[stable(feature = "duration_sum", since = "1.16.0")] impl Sum for Duration { - fn sum>(iter: I) -> Duration { + fn sum>(iter: I) -> Duration { sum_durations!(iter) } } #[stable(feature = "duration_sum", since = "1.16.0")] impl<'a> Sum<&'a Duration> for Duration { - fn sum>(iter: I) -> Duration { + fn sum>(iter: I) -> Duration { sum_durations!(iter) } } diff --git a/src/libcore/unicode/printable.rs b/src/libcore/unicode/printable.rs index a950e82cba241..a5a655eb662f1 100644 --- a/src/libcore/unicode/printable.rs +++ b/src/libcore/unicode/printable.rs @@ -1,5 +1,5 @@ -// NOTE: The following code was generated by "src/libcore/unicode/printable.py", -// do not edit directly! +// NOTE: the following code was generated by `src/libcore/unicode/printable.py`; +// do not edit directly! fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8], normal: &[u8]) -> bool { diff --git a/src/libcore/unicode/tables.rs b/src/libcore/unicode/tables.rs index edef4ca361e4f..0e1805dc18657 100644 --- a/src/libcore/unicode/tables.rs +++ b/src/libcore/unicode/tables.rs @@ -1,4 +1,4 @@ -// NOTE: The following code was generated by "./unicode.py", do not edit directly +// NOTE: the following code was generated by `./unicode.py`; do not edit directly! #![allow(missing_docs, non_upper_case_globals, non_snake_case)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index aacd6cec565a5..86ed4ad15fbc9 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -413,7 +413,7 @@ impl<'a> Parser<'a> { let pos = self.position(); let format = self.format(); - // Resolve position after parsing format spec. + // Resolves position after parsing format spec. let pos = match pos { Some(position) => position, None => { diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 489020d4ee778..675b18842abcd 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -612,7 +612,7 @@ pub fn default_options() -> Vec { pub fn render<'a,N,E,G,W>(g: &'a G, w: &mut W) -> io::Result<()> where N: Clone + 'a, E: Clone + 'a, - G: Labeller<'a, Node=N, Edge=E> + GraphWalk<'a, Node=N, Edge=E>, + G: Labeller<'a, Node = N, Edge = E> + GraphWalk<'a, Node = N, Edge = E>, W: Write { render_opts(g, w, &[]) @@ -626,7 +626,7 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G, -> io::Result<()> where N: Clone + 'a, E: Clone + 'a, - G: Labeller<'a, Node=N, Edge=E> + GraphWalk<'a, Node=N, Edge=E>, + G: Labeller<'a, Node = N, Edge = E> + GraphWalk<'a, Node = N, Edge = E>, W: Write { writeln!(w, "digraph {} {{", g.graph_id().as_slice())?; @@ -1053,7 +1053,7 @@ r#"digraph syntax_tree { let id1 = Id::new("hello"); match id1 { Ok(_) => {} - Err(..) => panic!("'hello' is not a valid value for id anymore"), + Err(..) => panic!("'hello' is not a valid value for ID anymore"), } } @@ -1061,7 +1061,7 @@ r#"digraph syntax_tree { fn badly_formatted_id() { let id2 = Id::new("Weird { struct : ure } !!!"); match id2 { - Ok(_) => panic!("graphviz id suddenly allows spaces, brackets and stuff"), + Ok(_) => panic!("graphviz ID suddenly allows spaces, brackets and stuff"), Err(..) => {} } } diff --git a/src/libpanic_unwind/dwarf/eh.rs b/src/libpanic_unwind/dwarf/eh.rs index 07fa2971847f6..4cee394a7a55e 100644 --- a/src/libpanic_unwind/dwarf/eh.rs +++ b/src/libpanic_unwind/dwarf/eh.rs @@ -100,7 +100,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) } } } - // Ip is not present in the table. This should not happen... but it does: issue #35011. + // Ip is not present in the table. This should not happen... but it does: issue #35011. // So rather than returning EHAction::Terminate, we do this. Ok(EHAction::None) } else { diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index e2b743b379704..faf7f8ebf3b47 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -91,7 +91,7 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box { cause.unwrap() } -// Rust's exception class identifier. This is used by personality routines to +// Rust's exception class identifier. This is used by personality routines to // determine whether the exception was thrown by their own runtime. fn rust_exception_class() -> uw::_Unwind_Exception_Class { // M O Z \0 R U S T -- vendor, language @@ -99,11 +99,11 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class { } -// Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister() -// and TargetLowering::getExceptionSelectorRegister() for each architecture, +// Register IDs were lifted from LLVM's `TargetLowering::getExceptionPointerRegister()` +// and `TargetLowering::getExceptionSelectorRegister()` for each architecture, // then mapped to DWARF register numbers via register definition tables -// (typically RegisterInfo.td, search for "DwarfRegNum"). -// See also http://llvm.org/docs/WritingAnLLVMBackend.html#defining-a-register. +// (typically `RegisterInfo.td`; search for "DwarfRegNum"). +// See also . #[cfg(target_arch = "x86")] const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX @@ -126,12 +126,12 @@ const UNWIND_DATA_REG: (i32, i32) = (6, 7); // R6, R7 #[cfg(target_arch = "sparc64")] const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1 -// The following code is based on GCC's C and C++ personality routines. For reference, see: +// The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c // The personality routine for most of our targets, except ARM, which has a slightly different ABI -// (however, iOS goes here as it uses SjLj unwinding). Also, the 64-bit Windows implementation +// (however, iOS goes here as it uses SjLj unwinding). Also, the 64-bit Windows implementation // lives in seh64_gnu.rs #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm"))))] #[lang = "eh_personality"] @@ -281,12 +281,12 @@ unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! { uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception); } -// Frame unwind info registration +// Frame unwind info registration. // // Each module's image contains a frame unwind info section (usually -// ".eh_frame"). When a module is loaded/unloaded into the process, the +// ".eh_frame"). When a module is loaded/unloaded into the process, the // unwinder must be informed about the location of this section in memory. The -// methods of achieving that vary by the platform. On some (e.g., Linux), the +// methods of achieving that vary by the platform. On some (e.g., Linux), the // unwinder can discover unwind info sections on its own (by dynamically // enumerating currently loaded modules via the dl_iterate_phdr() API and // finding their ".eh_frame" sections); Others, like Windows, require modules diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index 996fdb931eff2..d5919c0775b4c 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -205,7 +205,7 @@ static mut CATCHABLE_TYPE2: _CatchableType = _CatchableType { extern "C" { // The leading `\x01` byte here is actually a magical signal to LLVM to - // *not* apply any other mangling like prefixing with a `_` character. + // **not** apply any other mangling like prefixing with a `_` character. // // This symbol is the vtable used by C++'s `std::type_info`. Objects of type // `std::type_info`, type descriptors, have a pointer to this table. Type diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index b198bdb144699..45d282f31dfab 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -15,7 +15,7 @@ macro_rules! define_handles { } impl HandleCounters { - // FIXME(#53451) public to work around `Cannot create local mono-item` ICE. + // FIXME(#53451): public to work around `cannot create local mono-item` ICE. pub extern "C" fn get() -> &'static Self { static COUNTERS: HandleCounters = HandleCounters { $($oty: AtomicUsize::new(1),)* @@ -25,7 +25,7 @@ macro_rules! define_handles { } } - // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`. + // FIXME(eddyb): generate the definition of `HandleStore` in `server.rs`. #[repr(C)] #[allow(non_snake_case)] pub(super) struct HandleStore { @@ -171,7 +171,7 @@ define_handles! { Span, } -// FIXME(eddyb) generate these impls by pattern-matching on the +// FIXME(eddyb): generate these impls by pattern-matching on the // names of methods - also could use the presence of `fn drop` // to distinguish between 'owned and 'interned, above. // Alternatively, special 'modes" could be listed of types in with_api @@ -201,7 +201,7 @@ impl Clone for Literal { } } -// FIXME(eddyb) `Literal` should not expose internal `Debug` impls. +// FIXME(eddyb): `Literal` should not expose internal `Debug` impls. impl fmt::Debug for Literal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.debug()) @@ -281,7 +281,7 @@ impl BridgeState<'_> { fn with(f: impl FnOnce(&mut BridgeState<'_>) -> R) -> R { BRIDGE_STATE.with(|state| { state.replace(BridgeState::InUse, |mut state| { - // FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone + // FIXME(#52812): pass `f` directly to `replace` when `RefMutL` is gone f(&mut *state) }) }) @@ -291,7 +291,7 @@ impl BridgeState<'_> { impl Bridge<'_> { fn enter(self, f: impl FnOnce() -> R) -> R { // Hide the default panic output within `proc_macro` expansions. - // NB. the server can't do this because it may use a different libstd. + // N.B., the server can't do this because it may use a different libstd. static HIDE_PANICS_DURING_EXPANSION: Once = Once::new(); HIDE_PANICS_DURING_EXPANSION.call_once(|| { let prev = panic::take_hook(); @@ -338,7 +338,7 @@ pub struct Client { pub(super) f: F, } -// FIXME(#53451) public to work around `Cannot create local mono-item` ICE, +// FIXME(#53451): public to work around `Cannot create local mono-item` ICE, // affecting not only the function itself, but also the `BridgeState` `thread_local!`. pub extern "C" fn __run_expand1( mut bridge: Bridge<'_>, @@ -360,7 +360,7 @@ pub extern "C" fn __run_expand1( // Take the `cached_buffer` back out, for the output value. b = Bridge::with(|bridge| bridge.cached_buffer.take()); - // HACK(eddyb) Separate encoding a success value (`Ok(output)`) + // HACK(eddyb): separate encoding a success value (`Ok(output)`) // from encoding a panic (`Err(e: PanicMessage)`) to avoid // having handles outside the `bridge.enter(|| ...)` scope, and // to catch panics that could happen while encoding the success. @@ -391,7 +391,7 @@ impl Client crate::TokenStream> { } } -// FIXME(#53451) public to work around `Cannot create local mono-item` ICE, +// FIXME(#53451): public to work around `Cannot create local mono-item` ICE, // affecting not only the function itself, but also the `BridgeState` `thread_local!`. pub extern "C" fn __run_expand2( mut bridge: Bridge<'_>, @@ -414,7 +414,7 @@ pub extern "C" fn __run_expand2( // Take the `cached_buffer` back out, for the output value. b = Bridge::with(|bridge| bridge.cached_buffer.take()); - // HACK(eddyb) Separate encoding a success value (`Ok(output)`) + // HACK(eddyb): separate encoding a success value (`Ok(output)`) // from encoding a panic (`Err(e: PanicMessage)`) to avoid // having handles outside the `bridge.enter(|| ...)` scope, and // to catch panics that could happen while encoding the success. diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs index 3173651b03951..68a2511a6cf10 100644 --- a/src/libproc_macro/bridge/mod.rs +++ b/src/libproc_macro/bridge/mod.rs @@ -103,7 +103,7 @@ macro_rules! with_api { Literal { fn drop($self: $S::Literal); fn clone($self: &$S::Literal) -> $S::Literal; - // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + // FIXME(eddyb): `Literal` should not expose internal `Debug` impls. fn debug($self: &$S::Literal) -> String; fn integer(n: &str) -> $S::Literal; fn typed_integer(n: &str, kind: &str) -> $S::Literal; @@ -160,7 +160,7 @@ macro_rules! with_api { }; } -// FIXME(eddyb) this calls `encode` for each argument, but in reverse, +// FIXME(eddyb): this calls `encode` for each argument, but in reverse, // to avoid borrow conflicts from borrows started by `&mut` arguments. macro_rules! reverse_encode { ($writer:ident;) => {}; @@ -170,7 +170,7 @@ macro_rules! reverse_encode { } } -// FIXME(eddyb) this calls `decode` for each argument, but in reverse, +// FIXME(eddyb): this calls `decode` for each argument, but in reverse, // to avoid borrow conflicts from borrows started by `&mut` arguments. macro_rules! reverse_decode { ($reader:ident, $s:ident;) => {}; diff --git a/src/libproc_macro/bridge/scoped_cell.rs b/src/libproc_macro/bridge/scoped_cell.rs index 6f7965095b638..f6a010f87658f 100644 --- a/src/libproc_macro/bridge/scoped_cell.rs +++ b/src/libproc_macro/bridge/scoped_cell.rs @@ -14,8 +14,8 @@ pub trait LambdaL: for<'a> ApplyL<'a> {} impl ApplyL<'a>> LambdaL for T {} -// HACK(eddyb) work around projection limitations with a newtype -// FIXME(#52812) replace with `&'a mut >::Out` +// HACK(eddyb): work around projection limitations with a newtype. +// FIXME(#52812): replace with `&'a mut >::Out`. pub struct RefMutL<'a, 'b, T: LambdaL>(&'a mut >::Out); impl<'a, 'b, T: LambdaL> Deref for RefMutL<'a, 'b, T> { diff --git a/src/libproc_macro/bridge/server.rs b/src/libproc_macro/bridge/server.rs index 75806eb9d1760..bd62da169f403 100644 --- a/src/libproc_macro/bridge/server.rs +++ b/src/libproc_macro/bridge/server.rs @@ -2,7 +2,7 @@ use super::*; -// FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`. +// FIXME(eddyb): generate the definition of `HandleStore` in `server.rs`. use super::client::HandleStore; /// Declare an associated item of one of the traits below, optionally @@ -83,9 +83,9 @@ macro_rules! define_dispatcher_impl { ($($name:ident { $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* }),* $(,)*) => { - // FIXME(eddyb) `pub` only for `ExecutionStrategy` below. + // FIXME(eddyb): `pub` only for `ExecutionStrategy` below. pub trait DispatcherTrait { - // HACK(eddyb) these are here to allow `Self::$name` to work below. + // HACK(eddyb): these are here to allow `Self::$name` to work below. $(type $name;)* fn dispatch(&mut self, b: Buffer) -> Buffer; } @@ -103,7 +103,7 @@ macro_rules! define_dispatcher_impl { reverse_decode!(reader, handle_store; $($arg: $arg_ty),*); $name::$method(server, $($arg),*) }; - // HACK(eddyb) don't use `panic::catch_unwind` in a panic. + // HACK(eddyb): don't use `panic::catch_unwind` in a panic. // If client and server happen to use the same `libstd`, // `catch_unwind` asserts that the panic counter was 0, // even when the closure passed to it didn't panic. diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 6c061189d00d7..e49907fc08dfa 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -177,7 +177,7 @@ impl Extend for TokenStream { #[stable(feature = "token_stream_extend", since = "1.30.0")] impl Extend for TokenStream { fn extend>(&mut self, streams: I) { - // FIXME(eddyb) Use an optimized implementation if/when possible. + // FIXME(eddyb): use an optimized implementation if/when possible. *self = iter::once(mem::replace(self, Self::new())).chain(streams).collect(); } } @@ -1065,7 +1065,7 @@ impl Literal { // was 'c' or whether it was '\u{63}'. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn subspan>(&self, range: R) -> Option { - // HACK(eddyb) something akin to `Option::cloned`, but for `Bound<&T>`. + // HACK(eddyb): something akin to `Option::cloned`, but for `Bound<&T>`. fn cloned_bound(bound: Bound<&T>) -> Bound { match bound { Bound::Included(x) => Bound::Included(x.clone()), @@ -1102,7 +1102,7 @@ impl fmt::Display for Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Literal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + // FIXME(eddyb): `Literal` should not expose internal `Debug` impls. self.0.fmt(f) } } diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index f7ffbe8c65833..c1785241e9b57 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -19,15 +19,20 @@ struct CFGBuilder<'a, 'tcx: 'a> { #[derive(Copy, Clone)] struct BlockScope { - block_expr_id: hir::ItemLocalId, // id of breakable block expr node - break_index: CFGIndex, // where to go on `break` + // ID of breakable block expr node. + block_expr_id: hir::ItemLocalId, + // Where to go on `break`. + break_index: CFGIndex, } #[derive(Copy, Clone)] struct LoopScope { - loop_id: hir::ItemLocalId, // id of loop/while node - continue_index: CFGIndex, // where to go on a `loop` - break_index: CFGIndex, // where to go on a `break` + // ID of `loop`/`while` node. + loop_id: hir::ItemLocalId, + // Where to go on a `loop`. + continue_index: CFGIndex, + // Where to go on `break`. + break_index: CFGIndex, } pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -150,7 +155,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn pats_all<'b, I: Iterator>>(&mut self, + fn pats_all<'b, I: Iterator>>(&mut self, pats: I, pred: CFGIndex) -> CFGIndex { //! Handles case where all of the patterns must match. @@ -389,7 +394,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn call<'b, I: Iterator>(&mut self, + fn call<'b, I: Iterator>(&mut self, call_expr: &hir::Expr, pred: CFGIndex, func_or_rcvr: &hir::Expr, @@ -404,7 +409,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn exprs<'b, I: Iterator>(&mut self, + fn exprs<'b, I: Iterator>(&mut self, exprs: I, pred: CFGIndex) -> CFGIndex { //! Constructs graph for `exprs` evaluated in order @@ -418,7 +423,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { opt_expr.iter().fold(pred, |p, e| self.expr(&e, p)) } - fn straightline<'b, I: Iterator>(&mut self, + fn straightline<'b, I: Iterator>(&mut self, expr: &hir::Expr, pred: CFGIndex, subexprs: I) -> CFGIndex { @@ -475,7 +480,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // #47295: We used to have very special case code // here for when a pair of arms are both formed // solely from constants, and if so, not add these - // edges. But this was not actually sound without + // edges. But this was not actually sound without // other constraints that we stopped enforcing at // some point. while let Some(prev) = prev_guards.pop() { diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 796739c872174..c926c42100b83 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -151,7 +151,7 @@ macro_rules! define_dep_nodes { } } - // FIXME: Make `is_anon`, `is_input`, `is_eval_always` and `has_params` properties + // FIXME: make `is_anon`, `is_input`, `is_eval_always` and `has_params` properties // of queries #[inline(always)] pub fn is_anon(&self) -> bool { @@ -428,23 +428,23 @@ define_dep_nodes!( <'tcx> [] Null, // Represents the `Krate` as a whole (the `hir::Krate` value) (as - // distinct from the krate module). This is basically a hash of + // distinct from the `krate` module). This is basically a hash of // the entire krate, so if you read from `Krate` (e.g., by calling // `tcx.hir().krate()`), we will have to assume that any change // means that you need to be recompiled. This is because the // `Krate` value gives you access to all other items. To avoid // this fate, do not call `tcx.hir().krate()`; instead, prefer - // wrappers like `tcx.visit_all_items_in_krate()`. If there is no + // wrappers like `tcx.visit_all_items_in_krate()`. If there is no // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain - // access to the krate, but you must remember to add suitable + // access to the crate, but you must remember to add suitable // edges yourself for the individual items that you read. [input] Krate, - // Represents the body of a function or method. The def-id is that of the + // Represents the body of a function or method. The `DefId` is that of the // function/method. [input] HirBody(DefId), - // Represents the HIR node with the given node-id + // Represents the HIR node with the given `NodeId`. [input] Hir(DefId), // Represents metadata from an extern crate. @@ -548,7 +548,7 @@ define_dep_nodes!( <'tcx> [] Environment(DefId), [] DescribeDef(DefId), - // FIXME(mw): DefSpans are not really inputs since they are derived from + // FIXME(mw): `DefSpan`s are not really inputs since they are derived from // HIR. But at the moment HIR hashing still contains some hacks that allow // to make type debuginfo to be source location independent. Declaring // DefSpan an input makes sure that changes to these are always detected diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 8a2f79e6793c0..eab951545af98 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -1,24 +1,24 @@ +use std::env; +use std::collections::hash_map::Entry; +use std::hash::Hash; + use errors::{Diagnostic, DiagnosticBuilder}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use parking_lot::{Mutex, Condvar}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use smallvec::SmallVec; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, Ordering}; -use std::env; -use std::hash::Hash; -use std::collections::hash_map::Entry; -use crate::ty::{self, TyCtxt}; -use crate::util::common::{ProfileQueriesMsg, profq_msg}; -use parking_lot::{Mutex, Condvar}; +use smallvec::SmallVec; use crate::ich::{StableHashingContext, StableHashingContextProvider, Fingerprint}; - +use crate::ty::{self, TyCtxt}; +use crate::util::common::{ProfileQueriesMsg, profq_msg}; use super::debug::EdgeFilter; use super::dep_node::{DepNode, DepKind, WorkProductId}; +use super::prev::PreviousDepGraph; use super::query::DepGraphQuery; use super::safe::DepGraphSafe; use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex}; -use super::prev::PreviousDepGraph; #[derive(Clone)] pub struct DepGraph { @@ -75,7 +75,7 @@ struct DepGraphData { dep_node_debug: Lock>, - // Used for testing, only populated when -Zquery-dep-graph is specified. + // Used for testing, only populated when the `-Zquery-dep-graph` compiler flag is specified. loaded_from_cache: Lock>, } @@ -256,8 +256,8 @@ impl DepGraph { // In incremental mode, hash the result of the task. We don't // do anything with the hash yet, but we are computing it // anyway so that - // - we make sure that the infrastructure works and - // - we can get an idea of the runtime cost. + // - we make sure that the infrastructure works and + // - we can get an idea of the runtime cost. let mut hcx = cx.get_stable_hashing_context(); if cfg!(debug_assertions) { @@ -294,7 +294,7 @@ impl DepGraph { let print_status = cfg!(debug_assertions) && hcx.sess().opts.debugging_opts.dep_tasks; - // Determine the color of the new DepNode. + // Determine the color of the new `DepNode`. if let Some(prev_index) = data.previous.node_to_index_opt(&key) { let prev_fingerprint = data.previous.fingerprint_by_index(prev_index); @@ -522,7 +522,7 @@ impl DepGraph { for (current_dep_node_index, edges) in current_dep_graph.data.iter_enumerated() .map(|(i, d)| (i, &d.edges)) { let start = edge_list_data.len() as u32; - // This should really just be a memcpy :/ + // FIXME: this should really just be a `memcpy`. edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex::new(i.index()))); let end = edge_list_data.len() as u32; @@ -578,17 +578,17 @@ impl DepGraph { ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> { debug_assert!(!dep_node.kind.is_input()); - // Return None if the dep graph is disabled + // Return `None` if the dep graph is disabled. let data = self.data.as_ref()?; - // Return None if the dep node didn't exist in the previous session + // Return `None` if the dep node didn't exist in the previous session. let prev_index = data.previous.node_to_index_opt(dep_node)?; match data.colors.get(prev_index) { Some(DepNodeColor::Green(dep_node_index)) => Some((prev_index, dep_node_index)), Some(DepNodeColor::Red) => None, None => { - // This DepNode and the corresponding query invocation existed + // This `DepNode` and the corresponding query invocation existed. // in the previous compilation session too, so we can try to // mark it as green by recursively marking all of its // dependencies green. @@ -620,7 +620,7 @@ impl DepGraph { debug_assert!(data.colors.get(prev_dep_node_index).is_none()); } - // We never try to mark inputs as green + // We never try to mark inputs as green. debug_assert!(!dep_node.kind.is_input()); debug_assert_eq!(data.previous.index_to_node(prev_dep_node_index), *dep_node); @@ -637,7 +637,7 @@ impl DepGraph { // This dependency has been marked as green before, we are // still fine and can continue with checking the other // dependencies. - debug!("try_mark_previous_green({:?}) --- found dependency {:?} to \ + debug!("try_mark_previous_green({:?}) - found dependency {:?} to \ be immediately green", dep_node, data.previous.index_to_node(dep_dep_node_index)); @@ -660,7 +660,7 @@ impl DepGraph { // We don't know the state of this dependency. If it isn't // an input node, let's try to mark it green recursively. if !dep_dep_node.kind.is_input() { - debug!("try_mark_previous_green({:?}) --- state of dependency {:?} \ + debug!("try_mark_previous_green({:?}) - state of dependency {:?} \ is unknown, trying to mark it green", dep_node, dep_dep_node); @@ -671,7 +671,7 @@ impl DepGraph { dep_dep_node ); if let Some(node_index) = node_index { - debug!("try_mark_previous_green({:?}) --- managed to MARK \ + debug!("try_mark_previous_green({:?}) - managed to mark \ dependency {:?} as green", dep_node, dep_dep_node); current_deps.push(node_index); continue; @@ -701,15 +701,15 @@ impl DepGraph { } // We failed to mark it green, so we try to force the query. - debug!("try_mark_previous_green({:?}) --- trying to force \ + debug!("try_mark_previous_green({:?}) - trying to force \ dependency {:?}", dep_node, dep_dep_node); if crate::ty::query::force_from_dep_node(tcx, dep_dep_node) { let dep_dep_node_color = data.colors.get(dep_dep_node_index); match dep_dep_node_color { Some(DepNodeColor::Green(node_index)) => { - debug!("try_mark_previous_green({:?}) --- managed to \ - FORCE dependency {:?} to green", + debug!("try_mark_previous_green({:?}) - managed to \ + force dependency {:?} to green", dep_node, dep_dep_node); current_deps.push(node_index); } @@ -722,8 +722,9 @@ impl DepGraph { } None => { if !tcx.sess.has_errors() { - bug!("try_mark_previous_green() - Forcing the DepNode \ - should have set its color") + bug!("try_mark_previous_green({:?}) - forcing `DepNode` \ + should have set its color", + dep_node); } else { // If the query we just forced has resulted // in some kind of compilation error, we @@ -733,7 +734,7 @@ impl DepGraph { } } } else { - // The DepNode could not be forced. + // The `DepNode` could not be forced. debug!("try_mark_previous_green({:?}) - END - dependency {:?} \ could not be forced", dep_node, dep_dep_node); return None @@ -743,24 +744,24 @@ impl DepGraph { } // If we got here without hitting a `return` that means that all - // dependencies of this DepNode could be marked as green. Therefore we - // can also mark this DepNode as green. + // dependencies of this `DepNode` could be marked as green. Therefore, we + // can also mark this `DepNode` as green. - // There may be multiple threads trying to mark the same dep node green concurrently + // There may be multiple threads trying to mark the same dep node green concurrently. let (dep_node_index, did_allocation) = { let mut current = data.current.borrow_mut(); // Copy the fingerprint from the previous graph, - // so we don't have to recompute it + // so we don't have to recompute it. let fingerprint = data.previous.fingerprint_by_index(prev_dep_node_index); // We allocating an entry for the node in the current dependency graph and - // adding all the appropriate edges imported from the previous graph + // adding all the appropriate edges imported from the previous graph. current.intern_node(*dep_node, current_deps, fingerprint) }; - // ... emitting any stored diagnostic ... + // ... emitting any stored diagnostic, ... let diagnostics = tcx.queries.on_disk_cache .load_diagnostics(tcx, prev_dep_node_index); @@ -775,16 +776,17 @@ impl DepGraph { ); } - // ... and finally storing a "Green" entry in the color map. - // Multiple threads can all write the same color here + // ... and finally storing a "green" entry in the color map. + // Multiple threads can all write the same color here. #[cfg(not(parallel_compiler))] debug_assert!(data.colors.get(prev_dep_node_index).is_none(), - "DepGraph::try_mark_previous_green() - Duplicate DepNodeColor \ - insertion for {:?}", dep_node); + "try_mark_previous_green({:?}) - duplicate `DepNodeColor` insertion", + dep_node); data.colors.insert(prev_dep_node_index, DepNodeColor::Green(dep_node_index)); - debug!("try_mark_previous_green({:?}) - END - successfully marked as green", dep_node); + debug!("try_mark_previous_green({:?}) - END - successfully marked as green", + dep_node); Some(dep_node_index) } @@ -801,7 +803,7 @@ impl DepGraph { diagnostics: Vec, ) { if did_allocation || !cfg!(parallel_compiler) { - // Only the thread which did the allocation emits the error messages + // Only the thread which did the allocation emits the error messages. let handle = tcx.sess.diagnostic(); // Promote the previous diagnostics to the current session. @@ -814,12 +816,12 @@ impl DepGraph { #[cfg(parallel_compiler)] { - // Mark the diagnostics and emitted and wake up waiters + // Mark the diagnostics and emitted and wake up waiters. data.emitted_diagnostics.lock().insert(dep_node_index); data.emitted_diagnostics_cond_var.notify_all(); } } else { - // The other threads will wait for the diagnostics to be emitted + // The other threads will wait for the diagnostics to be emitted. let mut emitted_diagnostics = data.emitted_diagnostics.lock(); loop { @@ -831,20 +833,20 @@ impl DepGraph { } } - // Returns true if the given node has been marked as green during the - // current compilation session. Used in various assertions + // Returns `true` if the given node has been marked as green during the + // current compilation session. Used in various assertions. pub fn is_green(&self, dep_node: &DepNode) -> bool { self.node_color(dep_node).map(|c| c.is_green()).unwrap_or(false) } - // This method loads all on-disk cacheable query results into memory, so - // they can be written out to the new cache file again. Most query results - // will already be in memory but in the case where we marked something as - // green but then did not need the value, that value will never have been - // loaded from disk. - // - // This method will only load queries that will end up in the disk cache. - // Other queries will not be executed. + /// Loads all on-disk cacheable query results into memory, so + /// they can be written out to the new cache file again. Most query results + /// will already be in memory but in the case where we marked something as + /// green but then did not need the value, that value will never have been + /// loaded from disk. + /// + /// This method will only load queries that will end up in the disk cache. + /// Other queries will not be executed. pub fn exec_cache_promotions<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) { let green_nodes: Vec = { let data = self.data.as_ref().unwrap(); @@ -1018,22 +1020,22 @@ impl CurrentDepGraph { fingerprint: Fingerprint ) -> DepNodeIndex { // If this is an input node, we expect that it either has no - // dependencies, or that it just depends on DepKind::CrateMetadata - // or DepKind::Krate. This happens for some "thin wrapper queries" + // dependencies, or that it just depends on `DepKind::CrateMetadata` + // or `DepKind::Krate`. This happens for some "thin wrapper queries" // like `crate_disambiguator` which sometimes have zero deps (for - // when called for LOCAL_CRATE) or they depend on a CrateMetadata + // when called for `LOCAL_CRATE`) or they depend on a `CrateMetadata` // node. if cfg!(debug_assertions) { if node.kind.is_input() && task_deps.reads.len() > 0 && - // FIXME(mw): Special case for DefSpan until Spans are handled - // better in general. + // FIXME(mw): special case for `DefSpan` until `Span`s are handled + // better in general. node.kind != DepKind::DefSpan && task_deps.reads.iter().any(|&i| { !(self.data[i].node.kind == DepKind::CrateMetadata || self.data[i].node.kind == DepKind::Krate) }) { - bug!("Input node {:?} with unexpected reads: {:?}", + bug!("input node {:?} with unexpected reads: {:?}", node, task_deps.reads.iter().map(|&i| self.data[i].node).collect::>()) } @@ -1053,8 +1055,8 @@ impl CurrentDepGraph { ::std::mem::discriminant(&read_dep_node.kind).hash(&mut hasher); - // Fingerprint::combine() is faster than sending Fingerprint - // through the StableHasher (at least as long as StableHasher + // `Fingerprint::combine()` is faster than sending `Fingerprint` + // through the `StableHasher` (at least as long as `StableHasher` // is so slow). fingerprint = fingerprint.combine(read_dep_node.hash); } @@ -1144,8 +1146,8 @@ pub struct TaskDeps { read_set: FxHashSet, } -// A data structure that stores Option values as a contiguous -// array, using one u32 per entry. +// A data structure that stores `Option` values as a contiguous +// array, using one `u32` per entry. struct DepNodeColorMap { values: IndexVec, } diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index f46ff6f6062c2..f91579dfc7c94 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -64,7 +64,7 @@ impl Trait for u8 { } ``` -(Note that `&self` and `&mut self` are okay, it's additional `Self` types which +(Note that `&self` and `&mut self` are ok, it's additional `Self` types which cause this problem.) In such a case, the compiler cannot predict the return type of `foo()` in a @@ -283,7 +283,7 @@ trait Super { ``` If the trait `Foo` was deriving from something like `Super` or -`Super` (where `Foo` itself is `Foo`), this is okay, because given a type +`Super` (where `Foo` itself is `Foo`), this is ok, because given a type `get_a()` will definitely return an object of that type. However, if it derives from `Super`, even though `Super` is object safe, @@ -1264,7 +1264,7 @@ where } ``` -Here, the where clause `T: 'a` that appears on the impl is not known to be +Here, the where-clause `T: 'a` that appears on the impl is not known to be satisfied on the struct. To make this example compile, you have to add a where-clause like `T: 'a` to the struct definition: @@ -1495,7 +1495,7 @@ impl<'a, T> SomeTrait<'a> for T { Here, the problem is that a reference type like `&'a T` is only valid if all the data in T outlives the lifetime `'a`. But this impl as written is applicable to any lifetime `'a` and any type `T` -- we have no guarantee -that `T` outlives `'a`. To fix this, you can add a where clause like +that `T` outlives `'a`. To fix this, you can add a where-clause like `where T: 'a`. ``` diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index b15bea017762e..c9242ae23f34a 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -188,7 +188,7 @@ impl PerNS> { } /// Returns an iterator over the items which are `Some`. - pub fn present_items(self) -> impl Iterator { + pub fn present_items(self) -> impl Iterator { use std::iter::once; once(self.type_ns) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 9436c600c9fd3..75ca186988613 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -31,8 +31,9 @@ //! This order consistency is required in a few places in rustc, for //! example generator inference, and possibly also HIR borrowck. -use syntax::ast::{NodeId, CRATE_NODE_ID, Ident, Name, Attribute}; use syntax_pos::Span; +use syntax::ast::{NodeId, CRATE_NODE_ID, Ident, Name, Attribute}; + use crate::hir::*; use crate::hir::def::Def; use crate::hir::map::Map; diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 84487c40f8745..5e87a37e51142 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -30,30 +30,17 @@ //! get confused if the spans from leaf AST nodes occur in multiple places //! in the HIR, especially for multiple identifiers. -use crate::dep_graph::DepGraph; -use crate::hir::{self, ParamName}; -use crate::hir::HirVec; -use crate::hir::map::{DefKey, DefPathData, Definitions}; -use crate::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace, CRATE_DEF_INDEX}; -use crate::hir::def::{Def, PathResolution, PerNS}; -use crate::hir::GenericArg; -use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - ELIDED_LIFETIMES_IN_PATHS}; -use crate::middle::cstore::CrateStore; -use crate::session::Session; -use crate::session::config::nightly_options; -use crate::util::common::FN_OUTPUT_NAME; -use crate::util::nodemap::{DefIdMap, NodeMap}; +use std::collections::{BTreeSet, BTreeMap}; +use std::fmt::Debug; +use std::mem; + use errors::Applicability; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::thin_vec::ThinVec; use rustc_data_structures::sync::Lrc; - -use std::collections::{BTreeSet, BTreeMap}; -use std::fmt::Debug; -use std::mem; use smallvec::SmallVec; +use syntax_pos::{Span, MultiSpan}; use syntax::attr; use syntax::ast; use syntax::ast::*; @@ -67,14 +54,28 @@ use syntax::symbol::{keywords, Symbol}; use syntax::tokenstream::{TokenStream, TokenTree}; use syntax::parse::token::Token; use syntax::visit::{self, Visitor}; -use syntax_pos::{Span, MultiSpan}; + +use crate::dep_graph::DepGraph; +use crate::hir::{self, ParamName}; +use crate::hir::HirVec; +use crate::hir::map::{DefKey, DefPathData, Definitions}; +use crate::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace, CRATE_DEF_INDEX}; +use crate::hir::def::{Def, PathResolution, PerNS}; +use crate::hir::GenericArg; +use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, + ELIDED_LIFETIMES_IN_PATHS}; +use crate::middle::cstore::CrateStore; +use crate::session::Session; +use crate::session::config::nightly_options; +use crate::util::common::FN_OUTPUT_NAME; +use crate::util::nodemap::{DefIdMap, NodeMap}; const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF; pub struct LoweringContext<'a> { crate_root: Option<&'static str>, - // Used to assign ids to HIR nodes that do not directly correspond to an AST node. + // Used to assign IDs to HIR nodes that do not directly correspond to an AST node. sess: &'a Session, cstore: &'a dyn CrateStore, @@ -527,7 +528,7 @@ impl<'a> LoweringContext<'a> { fn allocate_hir_id_counter(&mut self, owner: NodeId, debug: &T) -> LoweredNodeId { if self.item_local_id_counters.insert(owner, 0).is_some() { bug!( - "Tried to allocate item_local_id_counter for {:?} twice", + "tried to allocate `item_local_id_counter` for {:?} twice", debug ); } @@ -616,7 +617,7 @@ impl<'a> LoweringContext<'a> { let local_id_counter = this .item_local_id_counters .get_mut(&owner) - .expect("called lower_node_id_with_owner before allocate_hir_id_counter"); + .expect("called `lower_node_id_with_owner` before `allocate_hir_id_counter`"); let local_id = *local_id_counter; // We want to be sure not to modify the counter in the map while it @@ -629,7 +630,7 @@ impl<'a> LoweringContext<'a> { .resolver .definitions() .opt_def_index(owner) - .expect("You forgot to call `create_def_with_parent` or are lowering node ids \ + .expect("you forgot to call `create_def_with_parent` or are lowering `NodeId`s \ that do not belong to the current owner"); hir::HirId { @@ -1957,19 +1958,23 @@ impl<'a> LoweringContext<'a> { ast::GenericArg::Type(_) => true, _ => false, }); - (hir::GenericArgs { - args: args.iter().map(|a| self.lower_generic_arg(a, itctx.reborrow())).collect(), - bindings: bindings.iter().map(|b| self.lower_ty_binding(b, itctx.reborrow())).collect(), - parenthesized: false, - }, - !has_types && param_mode == ParamMode::Optional) + ( + hir::GenericArgs { + args: args.iter().map(|a| self.lower_generic_arg(a, itctx.reborrow())) + .collect(), + bindings: bindings.iter().map(|b| self.lower_ty_binding(b, itctx.reborrow())) + .collect(), + parenthesized: false, + }, + !has_types && param_mode == ParamMode::Optional + ) } fn lower_parenthesized_parameter_data( &mut self, data: &ParenthesizedArgs, ) -> (hir::GenericArgs, bool) { - // Switch to `PassThrough` mode for anonymous lifetimes: this + // Switch to `PassThrough` mode for anonymous lifetimes; this // means that we permit things like `&Ref`, where `Ref` has // a hidden lifetime parameter. This is needed for backwards // compatibility, even in contexts like an impl header where @@ -2101,7 +2106,7 @@ impl<'a> LoweringContext<'a> { self.lower_async_fn_ret_ty( &inputs, &decl.output, - in_band_ty_params.expect("make_ret_async but no fn_def_id").0, + in_band_ty_params.expect("`make_ret_async` but no `fn_def_id`").0, ret_id, ) } else { @@ -2331,14 +2336,14 @@ impl<'a> LoweringContext<'a> { } }; - // "" + // `` let LoweredNodeId { node_id, hir_id } = this.next_id(); let future_params = P(hir::GenericArgs { args: hir_vec![], bindings: hir_vec![hir::TypeBinding { + id: node_id, ident: Ident::from_str(FN_OUTPUT_NAME), ty: output_ty, - id: node_id, hir_id, span, }], @@ -3198,7 +3203,7 @@ impl<'a> LoweringContext<'a> { // // The first two are produced by recursively invoking // `lower_use_tree` (and indeed there may be things - // like `use foo::{a::{b, c}}` and so forth). They + // like `use foo::{a::{b, c}}` and so forth). They // wind up being directly added to // `self.items`. However, the structure of this // function also requires us to return one item, and @@ -3223,7 +3228,7 @@ impl<'a> LoweringContext<'a> { let mut ident = ident.clone(); let mut prefix = prefix.clone(); - // Give the segments new node-ids since they are being cloned. + // Give the segments new `NodeId`s since they are being cloned. for seg in &mut prefix.segments { seg.id = self.sess.next_node_id(); } @@ -3279,7 +3284,7 @@ impl<'a> LoweringContext<'a> { // because that affects rustdoc and also the lints // about `pub` items. But we can't *always* make it // private -- particularly not for restricted paths -- - // because it contains node-ids that would then be + // because it contains `NodeId`s that would then be // unused, failing the check that HirIds are "densely // assigned". match vis.node { @@ -5076,7 +5081,6 @@ impl<'a> LoweringContext<'a> { .resolve_str_path(span, self.crate_root, components, is_value); path.segments.last_mut().unwrap().args = params; - for seg in path.segments.iter_mut() { if let Some(id) = seg.id { seg.id = Some(self.lower_node_id(id).node_id); diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 37552f18f4a08..4f396eee8c1e0 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -1,20 +1,21 @@ -use super::*; +use std::iter::repeat; + +use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; +use syntax::ast::{NodeId, CRATE_NODE_ID}; +use syntax::source_map::SourceMap; +use syntax_pos::Span; + +use rustc_data_structures::svh::Svh; + use crate::dep_graph::{DepGraph, DepKind, DepNodeIndex}; use crate::hir; use crate::hir::def_id::{LOCAL_CRATE, CrateNum}; use crate::hir::intravisit::{Visitor, NestedVisitorMap}; -use rustc_data_structures::svh::Svh; -use crate::ich::Fingerprint; +use crate::ich::{Fingerprint, StableHashingContext}; use crate::middle::cstore::CrateStore; use crate::session::CrateDisambiguator; use crate::session::Session; -use std::iter::repeat; -use syntax::ast::{NodeId, CRATE_NODE_ID}; -use syntax::source_map::SourceMap; -use syntax_pos::Span; - -use crate::ich::StableHashingContext; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; +use super::*; /// A Visitor that walks over the HIR and collects Nodes into a HIR map pub(super) struct NodeCollector<'a, 'hir> { @@ -254,7 +255,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { }; let forgot_str = if hir_id == crate::hir::DUMMY_HIR_ID { - format!("\nMaybe you forgot to lower the node id {:?}?", id) + format!("\nmaybe you forgot to lower the `NodeId` {:?}?", id) } else { String::new() }; diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index f454d691d4188..ac04af04dd1ac 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -22,17 +22,17 @@ use syntax::symbol::{Symbol, InternedString}; use syntax_pos::{Span, DUMMY_SP}; use crate::util::nodemap::NodeMap; -/// The DefPathTable maps DefIndexes to DefKeys and vice versa. -/// Internally the DefPathTable holds a tree of DefKeys, where each DefKey -/// stores the DefIndex of its parent. -/// There is one DefPathTable for each crate. +/// Maps `DefIndex`es to `DefKey`s and vice versa. +/// Internally, holds a tree of `DefKey`s, where each `DefKey` +/// stores the `DefIndex` of its parent. +/// There is one `DefPathTable` for each crate. #[derive(Default)] pub struct DefPathTable { index_to_key: [Vec; 2], def_path_hashes: [Vec; 2], } -// Unfortunately we have to provide a manual impl of Clone because of the +// Unfortunately we have to provide a manual impl of `Clone` because of the // fixed-sized array field. impl Clone for DefPathTable { fn clone(&self) -> Self { @@ -46,7 +46,6 @@ impl Clone for DefPathTable { } impl DefPathTable { - fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash, @@ -107,14 +106,13 @@ impl DefPathTable { } } - impl Encodable for DefPathTable { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - // Index to key + // Index to key. self.index_to_key[DefIndexAddressSpace::Low.index()].encode(s)?; self.index_to_key[DefIndexAddressSpace::High.index()].encode(s)?; - // DefPath hashes + // `DefPath` hashes. self.def_path_hashes[DefIndexAddressSpace::Low.index()].encode(s)?; self.def_path_hashes[DefIndexAddressSpace::High.index()].encode(s)?; @@ -174,7 +172,7 @@ impl DefKey { fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash { let mut hasher = StableHasher::new(); - // We hash a 0u8 here to disambiguate between regular DefPath hashes, + // We hash a `0u8` here to disambiguate between regular `DefPath` hashes // and the special "root_parent" below. 0u8.hash(&mut hasher); parent_hash.hash(&mut hasher); @@ -198,8 +196,8 @@ impl DefKey { crate_disambiguator: CrateDisambiguator) -> DefPathHash { let mut hasher = StableHasher::new(); - // Disambiguate this from a regular DefPath hash, - // see compute_stable_hash() above. + // Disambiguate this from a regular `DefPath` hash; + // see `compute_stable_hash()` above. 1u8.hash(&mut hasher); crate_name.hash(&mut hasher); crate_disambiguator.hash(&mut hasher); @@ -295,7 +293,7 @@ impl DefPath { "{}[{}]", component.data.as_interned_str(), component.disambiguator) - .unwrap(); + .unwrap(); } } @@ -319,7 +317,7 @@ impl DefPath { "{}[{}]", component.data.as_interned_str(), component.disambiguator) - .unwrap(); + .unwrap(); } } s @@ -330,52 +328,59 @@ impl DefPath { pub enum DefPathData { // Root: these should only be used for the root nodes, because // they are treated specially by the `def_path` function. - /// The crate root (marker) + + /// The crate root (marker). CrateRoot, - // Catch-all for random DefId things like DUMMY_NODE_ID + // Catch-all for random `DefId` things like `DUMMY_NODE_ID`. Misc, - // Different kinds of items and item-like things: - /// An impl + + // Different kinds of items and item-like things. + + /// An impl. Impl, - /// A trait + /// A trait. Trait(InternedString), - /// An associated type **declaration** (i.e., in a trait) + /// An associated type **declaration** (i.e., in a trait). AssocTypeInTrait(InternedString), - /// An associated type **value** (i.e., in an impl) + /// An associated type **value** (i.e., in an impl). AssocTypeInImpl(InternedString), - /// An existential associated type **value** (i.e., in an impl) + /// An existential associated type **value** (i.e., in an impl). AssocExistentialInImpl(InternedString), - /// Something in the type NS + /// Something in the type namespace. TypeNs(InternedString), - /// Something in the value NS + /// Something in the value namespace. ValueNs(InternedString), - /// A module declaration + /// A module declaration. Module(InternedString), - /// A macro rule + /// A macro rule. MacroDef(InternedString), - /// A closure expression + /// A closure expression. ClosureExpr, - // Subportions of items - /// A type (generic) parameter + + // Subportions of items. + + /// A type (generic) parameter. TypeParam(InternedString), - /// A lifetime (generic) parameter + /// A lifetime (generic) parameter. LifetimeParam(InternedString), - /// A const (generic) parameter + /// A const (generic) parameter. ConstParam(InternedString), /// A variant of a enum EnumVariant(InternedString), - /// A struct field + /// A struct field. Field(InternedString), - /// Implicit ctor for a tuple-like struct + /// Implicit ctor for a tuple-like struct. StructCtor, - /// A constant expression (see {ast,hir}::AnonConst). + /// A constant expression (see `{ast,hir}::AnonConst`). AnonConst, - /// An `impl Trait` type node + /// An `impl Trait` type node. ImplTrait, - /// GlobalMetaData identifies a piece of crate metadata that is global to - /// a whole crate (as opposed to just one item). GlobalMetaData components + + /// Identifies a piece of crate metadata that is global to + /// a whole crate (as opposed to just one item). These components /// are only supposed to show up right below the crate root. GlobalMetaData(InternedString), + /// A trait alias. TraitAlias(InternedString), } @@ -469,7 +474,7 @@ impl Definitions { } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. #[inline] pub fn as_local_hir_id(&self, def_id: DefId) -> Option { if def_id.krate == LOCAL_CRATE { @@ -533,13 +538,13 @@ impl Definitions { self.def_index_to_node[address_space.index()].push(ast::CRATE_NODE_ID); self.node_to_def_index.insert(ast::CRATE_NODE_ID, root_index); - // Allocate some other DefIndices that always must exist. + // Allocate some other `DefIndex`es that always must exist. GlobalMetaDataKind::allocate_def_indices(self); root_index } - /// Add a definition with a parent definition. + /// Adds a definition with a parent definition. pub fn create_def_with_parent(&mut self, parent: DefIndex, node_id: ast::NodeId, @@ -552,12 +557,12 @@ impl Definitions { parent, node_id, data); assert!(!self.node_to_def_index.contains_key(&node_id), - "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}", + "adding def'n for `NodeId` {:?} and data {:?} but previous def'n exists: {:?}", node_id, data, self.table.def_key(self.node_to_def_index[&node_id])); - // The root node must be created with create_root_def() + // The root node must be created with `create_root_def()`. assert!(data != DefPathData::CrateRoot); // Find the next free disambiguator for this key. @@ -586,9 +591,9 @@ impl Definitions { self.def_index_to_node[address_space.index()].len()); self.def_index_to_node[address_space.index()].push(node_id); - // Some things for which we allocate DefIndices don't correspond to - // anything in the AST, so they don't have a NodeId. For these cases - // we don't need a mapping from NodeId to DefIndex. + // Some things for which we allocate `DefIndex`es don't correspond to + // anything in the AST, so they don't have a `NodeId`. For these cases + // we don't need a mapping from NodeId to `DefIndex`. if node_id != ast::DUMMY_NODE_ID { debug!("create_def_with_parent: def_index_to_node[{:?} <-> {:?}", index, node_id); self.node_to_def_index.insert(node_id, index); @@ -598,7 +603,7 @@ impl Definitions { self.expansions_that_defined.insert(index, expansion); } - // The span is added if it isn't dummy + // The span is added if it isn't dummy. if !span.is_dummy() { self.def_index_to_span.insert(index, span); } @@ -678,7 +683,7 @@ impl DefPathData { GlobalMetaData(name) => { return name } - // note that this does not show up in user printouts + // Note that this does not show up in user print-outs. CrateRoot => "{{root}}", Impl => "{{impl}}", Misc => "{{?}}", @@ -701,9 +706,9 @@ macro_rules! count { ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*)); } -// We define the GlobalMetaDataKind enum with this macro because we want to +// We define the `GlobalMetaDataKind` enum with this macro because we want to // make sure that we exhaustively iterate over all variants when registering -// the corresponding DefIndices in the DefTable. +// the corresponding `DefIndex`es in the `DefTable`. macro_rules! define_global_metadata_kind { (pub enum GlobalMetaDataKind { $($variant:ident),* @@ -729,7 +734,7 @@ macro_rules! define_global_metadata_kind { DUMMY_SP ); - // Make sure calling def_index does not crash. + // Make sure that calling `def_index` does not crash. instance.def_index(&definitions.table); })* } @@ -743,7 +748,7 @@ macro_rules! define_global_metadata_kind { } }; - // These DefKeys are all right after the root, + // These `DefKey`s are all right after the root, // so a linear search is fine. let index = def_path_table.index_to_key[GLOBAL_MD_ADDRESS_SPACE.index()] .iter() diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 2c3ff4c9b5c05..3a39b0797e10f 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -96,12 +96,12 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { .expect("owning item has no entry"); if max != self.hir_ids_seen.len() - 1 { - // Collect the missing ItemLocalIds + // Collect the missing `ItemLocalId`s. let missing: Vec<_> = (0 ..= max as u32) .filter(|&i| !self.hir_ids_seen.contains_key(&ItemLocalId::from_u32(i))) .collect(); - // Try to map those to something more useful + // Try to map those to something more useful. let mut missing_items = Vec::with_capacity(missing.len()); for local_id in missing { @@ -110,10 +110,9 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { local_id: ItemLocalId::from_u32(local_id), }; - trace!("missing hir id {:#?}", hir_id); + trace!("missing `HirID` {:#?}", hir_id); - // We are already in ICE mode here, so doing a linear search - // should be fine. + // We are already in ICE mode here, so doing a linear search should be fine. let (node_id, _) = self.hir_map .definitions() .node_to_hir_id @@ -127,8 +126,8 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { self.hir_map.node_to_string(node_id))); } self.error(|| format!( - "ItemLocalIds not assigned densely in {}. \ - Max ItemLocalId = {}, missing IDs = {:?}; seens IDs = {:?}", + "`ItemLocalId`s not assigned densely in {}; \ + max `ItemLocalId` = {}, missing IDs = {:?}; seens IDs = {:?}", self.hir_map.def_path(DefId::local(owner_def_index)).to_string_no_crate(), max, missing_items, @@ -141,7 +140,6 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { } impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'hir> { intravisit::NestedVisitorMap::OnlyBodies(self.hir_map) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index b6cf4c1b84d0c..a082ce035a493 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -208,7 +208,7 @@ impl<'hir> Map<'hir> { } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn read_by_hir_id(&self, hir_id: HirId) { let node_id = self.hir_to_node_id(hir_id); self.read(node_id); @@ -230,7 +230,7 @@ impl<'hir> Map<'hir> { }) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn def_path_from_hir_id(&self, id: HirId) -> DefPath { self.def_path(self.local_def_id_from_hir_id(id)) } @@ -248,7 +248,7 @@ impl<'hir> Map<'hir> { }) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. #[inline] pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId { let node_id = self.hir_to_node_id(hir_id); @@ -258,7 +258,7 @@ impl<'hir> Map<'hir> { }) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. #[inline] pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option { let node_id = self.hir_to_node_id(hir_id); @@ -275,7 +275,7 @@ impl<'hir> Map<'hir> { self.definitions.as_local_node_id(def_id) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. #[inline] pub fn as_local_hir_id(&self, def_id: DefId) -> Option { self.definitions.as_local_hir_id(def_id) @@ -485,7 +485,7 @@ impl<'hir> Map<'hir> { entry.associated_body() } else { - bug!("no entry for id `{}`", id) + bug!("no entry for ID `{}`", id) } } @@ -603,7 +603,7 @@ impl<'hir> Map<'hir> { // Read the module so we'll be re-executed if new items // appear immediately under in the module. If some new item appears // in some nested item in the module, we'll be re-executed due to reads - // in the expect_* calls the loops below + // in the `expect_*` calls the loops below. self.read(node_id); let module = &self.forest.krate.modules[&node_id]; @@ -621,21 +621,22 @@ impl<'hir> Map<'hir> { } } - /// Retrieve the Node corresponding to `id`, panicking if it cannot + /// Retrieves the `Node` corresponding to `id`, panicking if it cannot /// be found. pub fn get(&self, id: NodeId) -> Node<'hir> { - // read recorded by `find` - self.find(id).unwrap_or_else(|| bug!("couldn't find node id {} in the AST map", id)) + // Read is recorded by `find`. + self.find(id).unwrap_or_else(|| bug!("couldn't find `NodeId` {} in the AST map", id)) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn get_by_hir_id(&self, id: HirId) -> Node<'hir> { let node_id = self.hir_to_node_id(id); self.get(node_id) } pub fn get_if_local(&self, id: DefId) -> Option> { - self.as_local_node_id(id).map(|id| self.get(id)) // read recorded by `get` + // Read is recorded by `get`. + self.as_local_node_id(id).map(|id| self.get(id)) } pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> { @@ -680,13 +681,13 @@ impl<'hir> Map<'hir> { result } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn find_by_hir_id(&self, hir_id: HirId) -> Option> { let node_id = self.hir_to_node_id(hir_id); self.find(node_id) } - /// Similar to `get_parent`; returns the parent node-id, or own `id` if there is + /// Similar to `get_parent`; returns the parent `NodeId`, or own `id` if there is /// no parent. Note that the parent may be `CRATE_NODE_ID`, which is not itself /// present in the map -- so passing the return value of get_parent_node to /// get may actually panic. @@ -706,14 +707,14 @@ impl<'hir> Map<'hir> { self.find_entry(id).and_then(|x| x.parent_node()).unwrap_or(id) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn get_parent_node_by_hir_id(&self, id: HirId) -> HirId { let node_id = self.hir_to_node_id(id); let parent_node_id = self.get_parent_node(node_id); self.node_to_hir_id(parent_node_id) } - /// Check if the node is an argument. An argument is a local variable whose + /// Checks if the node is an argument. An argument is a local variable whose /// immediate parent is an item or a closure. pub fn is_argument(&self, id: NodeId) -> bool { match self.find(id) { @@ -748,24 +749,24 @@ impl<'hir> Map<'hir> { { let mut id = start_id; loop { - let parent_node = self.get_parent_node(id); - if parent_node == CRATE_NODE_ID { + let parent_id = self.get_parent_node(id); + if parent_id == CRATE_NODE_ID { return Ok(CRATE_NODE_ID); } - if parent_node == id { + if parent_id == id { return Err(id); } - if let Some(entry) = self.find_entry(parent_node) { + if let Some(entry) = self.find_entry(parent_id) { if let Node::Crate = entry.node { return Err(id); } if found(&entry.node) { - return Ok(parent_node); + return Ok(parent_id); } else if bail_early(&entry.node) { - return Err(parent_node); + return Err(parent_id); } - id = parent_node; + id = parent_id; } else { return Err(id); } @@ -837,7 +838,7 @@ impl<'hir> Map<'hir> { } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn get_parent_item(&self, id: HirId) -> HirId { let node_id = self.hir_to_node_id(id); let parent_node_id = self.get_parent(node_id); @@ -869,9 +870,10 @@ impl<'hir> Map<'hir> { } /// Returns the nearest enclosing scope. A scope is an item or block. - /// FIXME: it is not clear to me that all items qualify as scopes -- statics - /// and associated types probably shouldn't, for example. Behavior in this - /// regard should be expected to be highly unstable. + // + // FIXME: it is not clear to me that all items qualify as scopes -- statics + // and associated types probably shouldn't, for example. Behavior in this + // regard should be expected to be highly unstable. pub fn get_enclosing_scope(&self, id: NodeId) -> Option { self.walk_parent_nodes(id, |node| match *node { Node::Item(_) | @@ -899,7 +901,8 @@ impl<'hir> Map<'hir> { if let Entry { node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry { - self.read(id); // reveals some of the content of a node + // Reveals some of the content of a node. + self.read(id); return nm.abi; } } @@ -913,13 +916,14 @@ impl<'hir> Map<'hir> { } pub fn expect_item(&self, id: NodeId) -> &'hir Item { - match self.find(id) { // read recorded by `find` + // Read recorded by `find` method. + match self.find(id) { Some(Node::Item(item)) => item, _ => bug!("expected item, found {}", self.node_to_string(id)) } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn expect_item_by_hir_id(&self, id: HirId) -> &'hir Item { let node_id = self.hir_to_node_id(id); self.expect_item(node_id) @@ -985,19 +989,20 @@ impl<'hir> Map<'hir> { } pub fn expect_expr(&self, id: NodeId) -> &'hir Expr { - match self.find(id) { // read recorded by find + // Read recorded by `find` method. + match self.find(id) { Some(Node::Expr(expr)) => expr, _ => bug!("expected expr, found {}", self.node_to_string(id)) } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr { let node_id = self.hir_to_node_id(id); self.expect_expr(node_id) } - /// Returns the name associated with the given NodeId's AST. + /// Returns the name associated with the given `NodeId`'s AST. pub fn name(&self, id: NodeId) -> Name { match self.get(id) { Node::Item(i) => i.ident.name, @@ -1014,14 +1019,14 @@ impl<'hir> Map<'hir> { } } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn name_by_hir_id(&self, id: HirId) -> Name { let node_id = self.hir_to_node_id(id); self.name(node_id) } - /// Given a node ID, get a list of attributes associated with the AST - /// corresponding to the Node ID + /// Given a `NodeId`, get a list of attributes associated with the AST + /// corresponding to the `NodeId`. pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] { self.read(id); // reveals attributes on the node let attrs = match self.find(id) { @@ -1034,25 +1039,24 @@ impl<'hir> Map<'hir> { Some(Node::Expr(ref e)) => Some(&*e.attrs), Some(Node::Stmt(ref s)) => Some(s.node.attrs()), Some(Node::GenericParam(param)) => Some(¶m.attrs[..]), - // unit/tuple structs take the attributes straight from - // the struct definition. + // Unit/tuple structs take the attributes straight from the struct definition. Some(Node::StructCtor(_)) => return self.attrs(self.get_parent(id)), _ => None }; attrs.unwrap_or(&[]) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn attrs_by_hir_id(&self, id: HirId) -> &'hir [ast::Attribute] { let node_id = self.hir_to_node_id(id); self.attrs(node_id) } - /// Returns an iterator that yields the node id's with paths that - /// match `parts`. (Requires `parts` is non-empty.) + /// Returns an iterator that yields the `NodeId`'s with paths that + /// match `parts`. (Requires that `parts` is non-empty.) /// /// For example, if given `parts` equal to `["bar", "quux"]`, then - /// the iterator will produce node id's for items with paths + /// the iterator will produce `NodeId`'s for items with paths /// such as `foo::bar::quux`, `bar::quux`, `other::bar::quux`, and /// any other such items it can find in the map. pub fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String]) @@ -1066,7 +1070,8 @@ impl<'hir> Map<'hir> { } pub fn span(&self, id: NodeId) -> Span { - self.read(id); // reveals span from node + // Reveals span from node. + self.read(id); match self.find_entry(id).map(|entry| entry.node) { Some(Node::Item(item)) => item.span, Some(Node::ForeignItem(foreign_item)) => foreign_item.span, @@ -1093,7 +1098,7 @@ impl<'hir> Map<'hir> { Some(Node::Local(local)) => local.span, Some(Node::MacroDef(macro_def)) => macro_def.span, Some(Node::Crate) => self.forest.krate.span, - None => bug!("hir::map::Map::span: id not in map: {:?}", id), + None => bug!("hir::map::Map::span: ID not in map: {:?}", id), } } @@ -1111,7 +1116,7 @@ impl<'hir> Map<'hir> { node_id_to_string(self, id, true) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn hir_to_string(&self, id: HirId) -> String { hir_id_to_string(self, id, true) } @@ -1120,7 +1125,7 @@ impl<'hir> Map<'hir> { node_id_to_string(self, id, false) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn hir_to_user_string(&self, id: HirId) -> String { hir_id_to_string(self, id, false) } @@ -1129,7 +1134,7 @@ impl<'hir> Map<'hir> { print::to_string(self, |s| s.print_node(self.get(id))) } - // FIXME(@ljedrz): replace the NodeId variant + // FIXME(ljedrz): replace the `NodeId` variant. pub fn hir_to_pretty_string(&self, id: HirId) -> String { print::to_string(self, |s| s.print_node(self.get_by_hir_id(id))) } @@ -1167,7 +1172,7 @@ impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> { // that mod's name. // // If `id` itself is a mod named `m` with parent `p`, then - // returns `Some(id, m, p)`. If `id` has no mod in its parent + // returns `Some(id, m, p)`. If `id` has no mod in its parent // chain, then returns `None`. fn find_first_mod_parent<'a>(map: &'a Map<'_>, mut id: NodeId) -> Option<(NodeId, Name)> { loop { @@ -1325,9 +1330,9 @@ impl<'a> print::State<'a> { Node::Block(a) => { use syntax::print::pprust::PrintState; - // containing cbox, will be closed by print-block at } + // Containing cbox -- will be closed by print-block at `}`. self.cbox(print::indent_unit)?; - // head-ibox, will be closed by print-block after { + // Head-ibox -- will be closed by print-block after `{`. self.ibox(0)?; self.print_block(&a) } @@ -1335,8 +1340,8 @@ impl<'a> print::State<'a> { Node::Visibility(a) => self.print_visibility(&a), Node::GenericParam(_) => bug!("cannot print Node::GenericParam"), Node::Field(_) => bug!("cannot print StructField"), - // these cases do not carry enough information in the - // hir_map to reconstruct their full structure for pretty + // These cases do not carry enough information in the + // `hir_map` to reconstruct their full structure for pretty // printing. Node::StructCtor(_) => bug!("cannot print isolated StructCtor"), Node::Local(a) => self.print_local_decl(&a), @@ -1476,7 +1481,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { } } -// FIXME(@ljedrz): replace the NodeId variant +// FIXME(ljedrz): replace the `NodeId` variant. fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String { let node_id = map.hir_to_node_id(id); node_id_to_string(map, node_id, include_id) @@ -1486,7 +1491,7 @@ pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { tcx.hir().describe_def(node_id) } else { - bug!("Calling local describe_def query provider for upstream DefId: {:?}", + bug!("calling local `describe_def` query provider for upstream `DefId`: {:?}", def_id) } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d774359fa79ec..0711f2933e775 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1,24 +1,17 @@ -// HIR datatypes. See the [rustc guide] for more info. +// HIR data-types. See the [rustc guide] for more info. //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html -pub use self::BlockCheckMode::*; -pub use self::CaptureClause::*; -pub use self::FunctionRetTy::*; -pub use self::Mutability::*; -pub use self::PrimTy::*; -pub use self::UnOp::*; -pub use self::UnsafeSource::*; - -use crate::hir::def::Def; -use crate::hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; -use crate::util::nodemap::{NodeMap, FxHashSet}; -use crate::mir::mono::Linkage; +use std::collections::{BTreeSet, BTreeMap}; +use std::fmt; use errors::FatalError; +use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync}; +use rustc_data_structures::thin_vec::ThinVec; +use rustc_target::spec::abi::Abi; +use serialize::{self, Encoder, Encodable, Decoder, Decodable}; use syntax_pos::{Span, DUMMY_SP, symbol::InternedString}; use syntax::source_map::Spanned; -use rustc_target::spec::abi::Abi; use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect}; use syntax::ast::{Attribute, Label, Lit, StrStyle, FloatTy, IntTy, UintTy}; use syntax::attr::{InlineAttr, OptimizeAttr}; @@ -27,15 +20,20 @@ use syntax::ptr::P; use syntax::symbol::{Symbol, keywords}; use syntax::tokenstream::TokenStream; use syntax::util::parser::ExprPrecedence; + +use crate::hir::def::Def; +use crate::hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; +use crate::mir::mono::Linkage; use crate::ty::AdtKind; use crate::ty::query::Providers; - -use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync}; -use rustc_data_structures::thin_vec::ThinVec; - -use serialize::{self, Encoder, Encodable, Decoder, Decodable}; -use std::collections::{BTreeSet, BTreeMap}; -use std::fmt; +use crate::util::nodemap::{NodeMap, FxHashSet}; +pub use self::BlockCheckMode::*; +pub use self::CaptureClause::*; +pub use self::FunctionRetTy::*; +pub use self::Mutability::*; +pub use self::PrimTy::*; +pub use self::UnOp::*; +pub use self::UnsafeSource::*; /// HIR doesn't commit to a concrete storage type and has its own alias for a vector. /// It can be `Vec`, `P<[T]>` or potentially `Box<[T]>`, or some other container with similar @@ -112,12 +110,12 @@ impl serialize::UseSpecializedDecodable for HirId { } } -// hack to ensure that we don't try to access the private parts of `ItemLocalId` in this module +// HACK: ensure that we don't try to access the private parts of `ItemLocalId` in this module. mod item_local_id_inner { use rustc_data_structures::indexed_vec::Idx; /// An `ItemLocalId` uniquely identifies something within a given "item-like", - /// that is within a hir::Item, hir::TraitItem, or hir::ImplItem. There is no - /// guarantee that the numerical value of a given `ItemLocalId` corresponds to + /// that is within a `hir::Item`, `hir::TraitItem`, or `hir::ImplItem`. There is + /// no guarantee that the numerical value of a given `ItemLocalId` corresponds to /// the node's position within the owning item in any way, but there is a /// guarantee that the `LocalItemId`s within an owner occupy a dense range of /// integers starting at zero, so a mapping that maps all or most nodes within @@ -236,8 +234,8 @@ impl LifetimeName { LifetimeName::Implicit | LifetimeName::Underscore => true, // It might seem surprising that `Fresh(_)` counts as - // *not* elided -- but this is because, as far as the code - // in the compiler is concerned -- `Fresh(_)` variants act + // **not** elided, but this is because, as far as the code + // in the compiler is concerned, `Fresh(_)` variants act // equivalently to "some fresh name". They correspond to // early-bound regions on an impl, in other words. LifetimeName::Error | LifetimeName::Param(_) | LifetimeName::Static => false, @@ -375,8 +373,8 @@ impl PathSegment { } } - // FIXME: hack required because you can't create a static - // `GenericArgs`, so you can't just return a `&GenericArgs`. + // HACK: required because you can't create a static `GenericArgs`, + // so you can't just return a `&GenericArgs`. pub fn with_generic_args(&self, f: F) -> R where F: FnOnce(&GenericArgs) -> R { @@ -528,7 +526,7 @@ pub enum GenericParamKind { Type { default: Option>, synthetic: Option, - } + }, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -540,7 +538,6 @@ pub struct GenericParam { pub bounds: GenericBounds, pub span: Span, pub pure_wrt_drop: bool, - pub kind: GenericParamKind, } @@ -698,8 +695,8 @@ pub struct Crate { pub span: Span, pub exported_macros: HirVec, - // N.B., we use a BTreeMap here so that `visit_all_items` iterates - // over the ids in increasing order. In principle it should not + // N.B., we use a `BTreeMap` here so that `visit_all_items` iterates + // over the IDs in increasing order. In principle it should not // matter what order we visit things in, but in *practice* it // does, because it can affect the order in which errors are // detected, which in turn can make compile-fail tests yield @@ -833,7 +830,7 @@ impl fmt::Debug for Pat { } impl Pat { - // FIXME(#19596) this is a workaround, but there should be a better way + // FIXME(#19596): this is a workaround, but there should be a better way. fn walk_(&self, it: &mut G) -> bool where G: FnMut(&Pat) -> bool { @@ -1603,11 +1600,11 @@ impl fmt::Display for LoopIdError { #[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] pub struct Destination { - // This is `Some(_)` iff there is an explicit user-specified `label + // This is `Some(_)` iff there is an explicit user-specified label. pub label: Option, D}` + /// An enum definition (e.g., `enum Foo {C, D}`). Enum(EnumDef, Generics), - /// A struct definition, e.g., `struct Foo {x: A}` + /// A struct definition (e.g., `struct Foo {x: A}`). Struct(VariantData, Generics), - /// A union definition, e.g., `union Foo {x: A, y: B}` + /// A union definition (e.g., `union Foo {x: A, y: B}`). Union(VariantData, Generics), - /// Represents a Trait Declaration + /// Represents a trait declaration (e.g., `trait Foo { ... }`). Trait(IsAuto, Unsafety, Generics, GenericBounds, HirVec), - /// Represents a Trait Alias Declaration + /// Represents a trait alias declaration (e.g., `trait Foo = Bar;`). TraitAlias(Generics, GenericBounds), - /// An implementation, eg `impl Trait for Foo { .. }` + /// An implementation (e.g., `impl Trait for Foo { .. }`). Impl(Unsafety, ImplPolarity, Defaultness, Generics, Option, // (optional) trait this impl implements - P, // self + // Self type. + P, HirVec), } @@ -2426,7 +2424,7 @@ pub struct TraitCandidate { // Trait method resolution pub type TraitMap = NodeMap>; -// Map from the NodeId of a glob import to a list of items which are actually +// Map from the `NodeId` of a glob import to a list of items which are actually // imported. pub type GlobMap = NodeMap>; @@ -2521,17 +2519,16 @@ impl CodegenFnAttrs { } } - /// True if it looks like this symbol needs to be exported, for example: + /// Returns `true` if it looks like this symbol needs to be exported, for example, if: /// - /// * `#[no_mangle]` is present - /// * `#[export_name(...)]` is present - /// * `#[linkage]` is present + /// * `#[no_mangle]` is present, + /// * `#[export_name(...)]` is present, + /// * `#[linkage]` is present. pub fn contains_extern_indicator(&self) -> bool { self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || self.export_name.is_some() || match self.linkage { - // these are private, make sure we don't try to consider - // them external + // These are private, so make sure we don't try to consider them external. None | Some(Linkage::Internal) | Some(Linkage::Private) => false, @@ -2559,10 +2556,8 @@ pub enum Node<'hir> { Block(&'hir Block), Local(&'hir Local), MacroDef(&'hir MacroDef), - - /// StructCtor represents a tuple struct. + /// Represents a tuple struct. StructCtor(&'hir VariantData), - Lifetime(&'hir Lifetime), GenericParam(&'hir GenericParam), Visibility(&'hir Visibility), diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 9b6fcf259be14..280ca2e3fa5bb 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -743,7 +743,7 @@ impl<'a> State<'a> { self.print_ident(item.ident)?; self.print_generic_params(&generics.params)?; let mut real_bounds = Vec::with_capacity(bounds.len()); - // FIXME(durka) this seems to be some quite outdated syntax + // FIXME(durka): this seems to be some quite outdated syntax for b in bounds.iter() { if let GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b { self.s.space()?; @@ -1082,7 +1082,7 @@ impl<'a> State<'a> { match els { Some(_else) => { match _else.node { - // "another else-if" + // Another `else if` block. hir::ExprKind::If(ref i, ref then, ref e) => { self.cbox(indent_unit - 1)?; self.ibox(0)?; @@ -1092,16 +1092,16 @@ impl<'a> State<'a> { self.print_expr(&then)?; self.print_else(e.as_ref().map(|e| &**e)) } - // "final else" + // Final `else` block. hir::ExprKind::Block(ref b, _) => { self.cbox(indent_unit - 1)?; self.ibox(0)?; self.s.word(" else ")?; self.print_block(&b) } - // BLEAH, constraints would be great here + // Constraints would be great here! _ => { - panic!("print_if saw if with weird alternative"); + panic!("`print_if` saw `if` with weird alternative"); } } } @@ -1738,8 +1738,8 @@ impl<'a> State<'a> { self.commasep(Inconsistent, &types, |s, ty| s.print_type(&ty))?; } - // FIXME(eddyb) This would leak into error messages, e.g.: - // "non-exhaustive patterns: `Some::<..>(_)` not covered". + // FIXME(eddyb): this would leak into error messages (e.g., + // "non-exhaustive patterns: `Some::<..>(_)` not covered"). if infer_types && false { start_or_comma(self)?; self.s.word("..")?; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index b10e893732597..8a97a6c00e3ac 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -90,12 +90,12 @@ for hir::ItemLocalId { } } -// The following implementations of HashStable for ItemId, TraitItemId, and -// ImplItemId deserve special attention. Normally we do not hash NodeIds within -// the HIR, since they just signify a HIR nodes own path. But ItemId et al +// The following implementations of `HashStable` for `ItemId`, `TraitItemId`, and +// `ImplItemId` deserve special attention. Normally we do not hash `NodeId`s within +// the HIR, since they just signify a HIR nodes own path. But `ItemId` et al // are used when another item in the HIR is *referenced* and we certainly -// want to pick up on a reference changing its target, so we hash the NodeIds -// in "DefPath Mode". +// want to pick up on a reference changing its target, so we hash the `NodeId`s +// in DefPath mode. impl<'a> HashStable> for hir::ItemId { fn hash_stable(&self, @@ -1003,7 +1003,7 @@ impl_stable_hash_for!(struct hir::InlineAsmOutput { impl_stable_hash_for!(struct hir::GlobalAsm { asm, - ctxt -> _, // This is used for error reporting + ctxt -> _, // used for error reporting }); impl_stable_hash_for!(struct hir::InlineAsm { @@ -1015,7 +1015,7 @@ impl_stable_hash_for!(struct hir::InlineAsm { volatile, alignstack, dialect, - ctxt -> _, // This is used for error reporting + ctxt -> _, // used for error reporting }); impl_stable_hash_for!(enum hir::def::CtorKind { diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index d06334c3ba643..b2d010799ff0b 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -292,7 +292,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> match *r { ty::ReLateBound(index, ..) => { if index >= self.binder_index { - bug!("escaping late bound region during canonicalization") + bug!("escaping late-bound region during canonicalization") } else { r } diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 613e153ae33d4..4ec13d8951216 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -247,7 +247,7 @@ impl<'gcx, V> Canonical<'gcx, V> { /// same set of bound variables. /// /// **WARNING:** This function is very easy to mis-use, hence the - /// name! In particular, the new value `W` must use all **the + /// name! In particular, the new value `W` must use all **the /// same type/region variables** in **precisely the same order** /// as the original! (The ordering is defined by the /// `TypeFoldable` implementation of the type in question.) diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index aef0152b6ed73..dcd58133358e1 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -161,7 +161,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { debug!("true_errors = {:#?}", true_errors); if !true_errors.is_empty() { - // FIXME -- we don't indicate *why* we failed to solve + // FIXME: we don't indicate *why* we failed to solve debug!("make_query_response: true_errors={:#?}", true_errors); return Err(NoSolution); } diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 361fbfea09798..1b110256e7ba0 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -1,33 +1,28 @@ -/////////////////////////////////////////////////////////////////////////// -// # Type combining -// -// There are four type combiners: equate, sub, lub, and glb. Each -// implements the trait `Combine` and contains methods for combining -// two instances of various things and yielding a new instance. These -// combiner methods always yield a `Result`. There is a lot of -// common code for these operations, implemented as default methods on -// the `Combine` trait. -// -// Each operation may have side-effects on the inference context, -// though these can be unrolled using snapshots. On success, the -// LUB/GLB operations return the appropriate bound. The Eq and Sub -// operations generally return the first operand. -// -// ## Contravariance -// -// When you are relating two things which have a contravariant -// relationship, you should use `contratys()` or `contraregions()`, -// rather than inversing the order of arguments! This is necessary -// because the order of arguments is not relevant for LUB and GLB. It -// is also useful to track which value is the "expected" value in -// terms of error reporting. +//! # Type combining +//! +//! There are four type combiners: equate, sub, lub, and glb. Each +//! implements the trait `Combine` and contains methods for combining +//! two instances of various things and yielding a new instance. These +//! combiner methods always yield a `Result`. There is a lot of +//! common code for these operations, implemented as default methods on +//! the `Combine` trait. +//! +//! Each operation may have side-effects on the inference context, +//! though these can be unrolled using snapshots. On success, the +//! LUB/GLB operations return the appropriate bound. The Eq and Sub +//! operations generally return the first operand. +//! +//! ## Contravariance +//! +//! When you are relating two things that have a contravariant +//! relationship, you should use `contratys()` or `contraregions()`, +//! rather than inversing the order of arguments! This is necessary +//! because the order of arguments is not relevant for LUB and GLB. It +//! is also useful to track which value is the "expected" value in +//! terms of error reporting. -use super::equate::Equate; -use super::glb::Glb; -use super::{InferCtxt, MiscVariable, TypeTrace}; -use super::lub::Lub; -use super::sub::Sub; -use super::type_variable::TypeVariableValue; +use syntax_pos::Span; +use syntax::ast; use crate::hir::def_id::DefId; use crate::ty::{IntType, UintType}; @@ -36,9 +31,12 @@ use crate::ty::error::TypeError; use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; use crate::ty::subst::Substs; use crate::traits::{Obligation, PredicateObligations}; - -use syntax::ast; -use syntax_pos::Span; +use super::{InferCtxt, MiscVariable, TypeTrace}; +use super::equate::Equate; +use super::glb::Glb; +use super::lub::Lub; +use super::sub::Sub; +use super::type_variable::TypeVariableValue; #[derive(Clone)] pub struct CombineFields<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { @@ -65,7 +63,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { let a_is_expected = relation.a_is_expected(); match (&a.sty, &b.sty) { - // Relate integral variables to other types + // Relate integral variables to other types. (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => { self.int_unification_table .borrow_mut() @@ -86,7 +84,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { self.unify_integral_variable(!a_is_expected, v_id, UintType(v)) } - // Relate floating-point variables to other types + // Relate floating-point variables to other types. (&ty::Infer(ty::FloatVar(a_id)), &ty::Infer(ty::FloatVar(b_id))) => { self.float_unification_table .borrow_mut() @@ -101,7 +99,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { self.unify_float_variable(!a_is_expected, v_id, v) } - // All other cases of inference are errors + // All other cases of inference are errors. (&ty::Infer(_), _) | (_, &ty::Infer(_)) => { Err(TypeError::Sorts(ty::relate::expected_found(relation, &a, &b))) @@ -189,7 +187,7 @@ impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { debug!("instantiate(a_ty={:?} dir={:?} b_vid={:?})", a_ty, dir, b_vid); // Generalize type of `a_ty` appropriately depending on the - // direction. As an example, assume: + // direction. As an example, assume: // // - `a_ty == &'x ?1`, where `'x` is some free region and `?1` is an // inference variable, @@ -212,7 +210,7 @@ impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { // Finally, relate `b_ty` to `a_ty`, as described in previous comment. // - // FIXME(#16847): This code is non-ideal because all these subtype + // FIXME(#16847): this code is non-ideal because all these subtype // relations wind up attributed to the same spans. We need // to associate causes/spans with each of the relations in // the stack to get this right. @@ -384,7 +382,8 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' } fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - assert_eq!(t, t2); // we are abusing TypeRelation here; both LHS and RHS ought to be == + // We are abusing `TypeRelation` here; both LHS and RHS ought to be `==`. + assert_eq!(t, t2); // Check to see whether the type we are genealizing references // any other type variable related to `vid` via @@ -396,8 +395,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' let vid = variables.root_var(vid); let sub_vid = variables.sub_root_var(vid); if sub_vid == self.for_vid_sub_root { - // If sub-roots are equal, then `for_vid` and - // `vid` are related via subtyping. + // If sub-roots are equal, then `for_vid` and `vid` are related via subtyping. return Err(TypeError::CyclicTy(self.root_ty)); } else { match variables.probe(vid) { @@ -410,14 +408,12 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' // Invariant: no need to make a fresh type variable. ty::Invariant => return Ok(t), - // Bivariant: make a fresh var, but we - // may need a WF predicate. See - // comment on `needs_wf` field for - // more info. + // Bivariant: make a fresh var, but we may need a WF predicate. + // See comment on `needs_wf` field for more info. ty::Bivariant => self.needs_wf = true, - // Co/contravariant: this will be - // sufficiently constrained later on. + // Co-/contra-variant: this will be sufficiently constrained + // later on. ty::Covariant | ty::Contravariant => (), } @@ -433,9 +429,8 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' } ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) => { - // No matter what mode we are in, - // integer/floating-point types must be equal to be - // relatable. + // No matter what mode we are in, integer amd floating-point types must be + // equal to be relatable. Ok(t) } _ => { @@ -446,7 +441,8 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' fn regions(&mut self, r: ty::Region<'tcx>, r2: ty::Region<'tcx>) -> RelateResult<'tcx, ty::Region<'tcx>> { - assert_eq!(r, r2); // we are abusing TypeRelation here; both LHS and RHS ought to be == + // We are abusing `TypeRelation` here; both LHS and RHS ought to be `==`. + assert_eq!(r, r2); match *r { // Never make variables for regions bound within the type itself, @@ -484,7 +480,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' } } - // FIXME: This is non-ideal because we don't give a + // FIXME: this is non-ideal because we don't give a // very descriptive origin for this region variable. Ok(self.infcx.next_region_var(MiscVariable(self.span))) } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 705d9c4cf93ea..fe8e7e7c42e23 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1,4 +1,4 @@ -//! Error Reporting Code for the inference engine +//! Error reporting for the inference engine. //! //! Because of the way inference, and in particular region inference, //! works, it often happens that errors are not detected until far after @@ -45,27 +45,26 @@ //! ported to this system, and which relies on string concatenation at the //! time of error detection. -use super::lexical_region_resolve::RegionResolutionError; -use super::region_constraints::GenericKind; -use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs}; -use crate::infer::{self, SuppressRegionErrors}; +mod note; +mod need_type_info; +pub mod nice_region_error; + +use std::{cmp, fmt}; + +use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; +use syntax_pos::{Pos, Span}; use crate::hir; use crate::hir::def_id::DefId; use crate::hir::Node; +use crate::infer::{self, SuppressRegionErrors}; use crate::middle::region; use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::ty::error::TypeError; use crate::ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; -use std::{cmp, fmt}; -use syntax_pos::{Pos, Span}; - -mod note; - -mod need_type_info; - -pub mod nice_region_error; +use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs}; +use super::lexical_region_resolve::RegionResolutionError; +use super::region_constraints::GenericKind; impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn note_and_explain_region( @@ -81,7 +80,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let new_string; let unknown_scope = || { format!( - "{}unknown scope: {:?}{}. Please report a bug.", + "{}unknown scope: {:?}{}. Please report a bug.", prefix, scope, suffix ) }; @@ -133,16 +132,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::RePlaceholder(_) => (format!("any other region"), None), - // FIXME(#13998) RePlaceholder should probably print like - // ReFree rather than dumping Debug output on the user. + // FIXME(#13998): `RePlaceholder` should probably print like + // `ReFree` rather than dumping `Debug` output on the user. // - // We shouldn't really be having unification failures with ReVar - // and ReLateBound though. + // We shouldn't really be having unification failures with `ReVar` + // and `ReLateBound` though. ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => { (format!("lifetime {:?}", region), None) } - // We shouldn't encounter an error message with ReClosureBound. + // We shouldn't encounter an error message with `ReClosureBound`. ty::ReClosureBound(..) => { bug!("encountered unexpected ReClosureBound: {:?}", region,); } @@ -303,8 +302,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return; } - // try to pre-process the errors, which will group some of them - // together into a `ProcessedErrors` group: + // Try to pre-process the errors, which will group some of them + // together into a `ProcessedErrors` group. let errors = self.process_errors(errors); debug!( @@ -323,7 +322,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // attempt to do is go through a number of specific // scenarios and try to find the best way to present // the error. If all of these fails, we fall back to a rather - // general bit of code that displays the error information + // general bit of code that displays the error information. RegionResolutionError::ConcreteFailure(origin, sub, sup) => { if sub.is_placeholder() || sup.is_placeholder() { self.report_placeholder_failure(region_scope_tree, origin, sub, sup) @@ -393,7 +392,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // // The method also attempts to weed out messages that seem like // duplicates that will be unhelpful to the end-user. But - // obviously it never weeds out ALL errors. + // obviously it never weeds out *all* errors. fn process_errors( &self, errors: &Vec>, @@ -401,7 +400,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { debug!("process_errors()"); // We want to avoid reporting generic-bound failures if we can - // avoid it: these have a very high rate of being unhelpful in + // avoid it; these have a very high rate of being unhelpful in // practice. This is because they are basically secondary // checks that test the state of the region graph after the // rest of inference is done, and the other kinds of errors @@ -428,7 +427,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .collect() }; - // sort the errors by span, for better error message stability. + // Sort the errors by span, for better error message stability. errors.sort_by_key(|u| match *u { RegionResolutionError::ConcreteFailure(ref sro, _, _) => sro.span(), RegionResolutionError::GenericBoundFailure(ref sro, _, _) => sro.span(), @@ -437,7 +436,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { errors } - /// Adds a note if the types come from similarly named crates + /// Adds a note if the types come from similarly named crates. fn check_and_note_conflicting_crates( &self, err: &mut DiagnosticBuilder<'_>, @@ -446,14 +445,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ) { let report_path_match = |err: &mut DiagnosticBuilder<'_>, did1: DefId, did2: DefId| { // Only external crates, if either is from a local - // module we could have false positives + // module we could have false positives. if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate { let exp_path = self.tcx.item_path_str(did1); let found_path = self.tcx.item_path_str(did2); let exp_abs_path = self.tcx.absolute_item_path_str(did1); let found_abs_path = self.tcx.absolute_item_path_str(did2); - // We compare strings because DefPath can be different - // for imported and non-imported crates + // We compare strings because `DefPath` can be different + // for imported and non-imported crates. if exp_path == found_path || exp_abs_path == found_abs_path { let crate_name = self.tcx.crate_name(did1.krate); err.span_note( @@ -469,8 +468,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { }; match *terr { TypeError::Sorts(ref exp_found) => { - // if they are both "path types", there's a chance of ambiguity - // due to different versions of the same crate + // If they are both "path types", there's a chance of ambiguity + // due to different versions of the same crate. if let (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) = (&exp_found.expected.sty, &exp_found.found.sty) { @@ -480,7 +479,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { TypeError::Traits(ref exp_found) => { report_path_match(err, exp_found.expected, exp_found.found); } - _ => (), // FIXME(#22750) handle traits and stuff + // FIXME(#22750): handle traits and stuff. + _ => (), } } @@ -552,9 +552,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - /// Given that `other_ty` is the same as a type argument for `name` in `sub`, populate `value` + /// Given that `other_ty` is the same as a type argument for `name` in `sub`, populates `value` /// highlighting `name` and every type argument that isn't at `pos` (which is `other_ty`), and - /// populate `other_value` with `other_ty`. + /// populates `other_value` with `other_ty`. /// /// ```text /// Foo> @@ -582,7 +582,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { value.push_highlighted("<"); } - // Output the lifetimes for the first type + // Output the lifetimes for the first type. let lifetimes = sub.regions() .map(|lifetime| { let s = lifetime.to_string(); @@ -777,8 +777,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { values.0.push_normal(path1); values.1.push_normal(path2); - // Avoid printing out default generic parameters that are common to both - // types. + // Avoid printing out default generic parameters that are common to both types. let len1 = sub_no_defaults_1.len(); let len2 = sub_no_defaults_2.len(); let common_len = cmp::min(len1, len2); @@ -832,6 +831,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // We're comparing two types with the same path, so we compare the type // arguments for both. If they are the same, do not highlight and elide from the // output. + // // Foo<_, Bar> // Foo<_, Qux> // ^ elided type as this type argument was the same in both sides @@ -875,6 +875,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return values; } // Check for case: + // // let x: Bar = y:>>(); // Bar // Foo> @@ -892,6 +893,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } // We couldn't find anything in common, highlight everything. + // // let x: Bar = y::>(); ( DiagnosticStyledString::highlighted(t1.to_string()), @@ -914,7 +916,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { values } - // When encountering &T != &mut T, highlight only the borrow + // When encountering `&T != &mut T`, highlight only the borrow. (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => { @@ -950,8 +952,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { mut values: Option>, terr: &TypeError<'tcx>, ) { - // For some types of errors, expected-found does not make - // sense, so just ignore the values we were given. + // For some types of errors, the expected-found message format does not + // make sense, so just ignore the values we were given. match terr { TypeError::CyclicTy(_) => { values = None; @@ -974,7 +976,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let vals = match self.values_str(&values) { Some((expected, found)) => Some((expected, found)), None => { - // Derived error. Cancel the emitter. + // Derived error; cancel the emitter. self.tcx.sess.diagnostic().cancel(diag); return; } @@ -1036,13 +1038,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.check_and_note_conflicting_crates(diag, terr, span); self.tcx.note_and_explain_type_err(diag, terr, span); - // It reads better to have the error origin as the final - // thing. + // It reads better to have the error origin as the final thing. self.note_error_origin(diag, &cause, exp_found); } /// When encountering a case where `.as_ref()` on a `Result` or `Option` would be appropriate, - /// suggest it. + /// suggests it. fn suggest_as_ref_where_appropriate( &self, span: Span, @@ -1161,7 +1162,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(self.cmp(exp_found.expected, exp_found.found)) } - /// Returns a string of the form "expected `{}`, found `{}`". + /// Returns a string of the form `"expected `{}`, found `{}`"`. fn expected_found_str>( &self, exp_found: &ty::error::ExpectedFound, @@ -1219,7 +1220,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } let sp = hir.span(id); // `sp` only covers `T`, change it so that it covers - // `T:` when appropriate + // `T:` when appropriate. let is_impl_trait = bound_kind.to_string().starts_with("impl "); let sp = if has_bounds && !is_impl_trait { sp.to(self.tcx @@ -1285,7 +1286,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { sp, &consider, suggestion, - Applicability::MaybeIncorrect, // Issue #41966 + // Issue #41966. + Applicability::MaybeIncorrect, ); } else { err.help(&consider); diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 9e0e48e474118..7773fc820bf49 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -79,10 +79,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } pub fn need_type_info_err(&self, - body_id: Option, - span: Span, - ty: Ty<'tcx>) - -> DiagnosticBuilder<'gcx> { + body_id: Option, + span: Span, + ty: Ty<'tcx>) + -> DiagnosticBuilder<'gcx> { let ty = self.resolve_type_vars_if_possible(&ty); let name = self.extract_type_name(&ty); diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index ea748874fc4e2..01f473aad9e38 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -203,7 +203,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { } // The visitor captures the corresponding `hir::Ty` of the anonymous region -// in the case of structs ie. `hir::TyKind::Path`. +// in the case of structs (i.e., `hir::TyKind::Path`). // This visitor would be invoked for each lifetime corresponding to a struct, // and would walk the types like Vec in the above example and Ref looking for the HIR // where that lifetime appears. This allows us to highlight the diff --git a/src/librustc/infer/error_reporting/nice_region_error/mod.rs b/src/librustc/infer/error_reporting/nice_region_error/mod.rs index d995fe92337c4..ee0ce34a87d25 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/mod.rs @@ -1,11 +1,3 @@ -use crate::infer::InferCtxt; -use crate::infer::lexical_region_resolve::RegionResolutionError; -use crate::infer::lexical_region_resolve::RegionResolutionError::*; -use crate::ty::{self, TyCtxt}; -use crate::util::common::ErrorReported; -use errors::DiagnosticBuilder; -use syntax::source_map::Span; - mod different_lifetimes; mod find_anon_type; mod named_anon_conflict; @@ -14,11 +6,21 @@ mod outlives_closure; mod static_impl_trait; mod util; +use errors::DiagnosticBuilder; +use syntax::source_map::Span; + +use crate::infer::InferCtxt; +use crate::infer::lexical_region_resolve::RegionResolutionError; +use crate::infer::lexical_region_resolve::RegionResolutionError::*; +use crate::ty::{self, TyCtxt}; +use crate::util::common::ErrorReported; + impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { pub fn try_report_nice_region_error(&self, error: &RegionResolutionError<'tcx>) -> bool { match *error { ConcreteFailure(..) | SubSupConflict(..) => {} - _ => return false, // inapplicable + // Inapplicable. + _ => return false, } if let Some(tables) = self.in_progress_tables { @@ -80,7 +82,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> { (Some(ConcreteFailure(origin, sub, sup)), None) => (origin.span(), sub, sup), (Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => (origin.span(), sub, sup), (None, Some((span, sub, sup))) => (span, sub, sup), - (Some(_), Some(_)) => panic!("incorrectly built NiceRegionError"), + (Some(_), Some(_)) => panic!("incorrectly built `NiceRegionError`"), _ => panic!("trying to report on an incorrect lifetime failure"), } } diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 3821484d38e5f..6bc3eb25e8069 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -1,5 +1,6 @@ //! Error Reporting for Anonymous Region Lifetime Errors //! where one region is named and the other is anonymous. + use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::ty; use errors::{Applicability, DiagnosticBuilder}; @@ -16,12 +17,12 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { sup ); - // Determine whether the sub and sup consist of one named region ('a) - // and one anonymous (elided) region. If so, find the parameter arg + // Determine whether the sub and sup consist of one named region (`'a`) + // and one anonymous (elided) region. If so, find the parameter `arg` // where the anonymous region appears (there must always be one; we // only introduced anonymous regions in parameters) as well as a - // version new_ty of its type where the anonymous region is replaced - // with the named one.//scope_def_id + // version `new_ty` of its type, where the anonymous region is replaced + // with the named one. let (named, anon, anon_arg_info, region_info) = if self.is_named_region(sub) && self.tcx().is_suitable_region(sup).is_some() && self.find_arg_with_region(sup, sub).is_some() @@ -67,7 +68,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { match br { ty::BrAnon(_) => {} _ => { - /* not an anonymous region */ + // Not an anonymous region. debug!("try_report_named_anon_conflict: not an anonymous region"); return None; } @@ -114,7 +115,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { Some(diag) } - // This method returns whether the given Region is Named + // Returns whether the given `Region` is named. pub(super) fn is_named_region(&self, region: ty::Region<'tcx>) -> bool { match *region { ty::ReStatic => true, diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index 3b2fb7d41008e..e17120230510c 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -16,7 +16,7 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { pub(super) fn try_report_placeholder_conflict(&self) -> Option> { match &self.error { /////////////////////////////////////////////////////////////////////////// - // NB. The ordering of cases in this match is very + // N.B., the ordering of cases in this match is very // sensitive, because we are often matching against // specific cases and then using an `_` to match all // others. @@ -323,7 +323,7 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { // in the types are about to print // - Meanwhile, the `maybe_highlighting_region` calls set up // highlights so that, if they do appear, we will replace - // them `'0` and whatever. (This replacement takes place + // them `'0` and whatever. (This replacement takes place // inside the closure given to `maybe_highlighting_region`.) // // There is some duplication between the calls -- i.e., the diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index 6db1bc382afe9..47f5f8136b59c 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -1,41 +1,39 @@ -//! Helper functions corresponding to lifetime errors due to -//! anonymous regions. +//! Helper functions corresponding to lifetime errors due to anonymous regions. + +use syntax_pos::Span; use crate::hir; +use crate::hir::def_id::DefId; use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::ty::{self, Region, Ty}; -use crate::hir::def_id::DefId; -use syntax_pos::Span; -// The struct contains the information about the anonymous region -// we are searching for. +// Contains the information about the anonymous region we are searching for. #[derive(Debug)] pub(super) struct AnonymousArgInfo<'tcx> { - // the argument corresponding to the anonymous region + /// The argument corresponding to the anonymous region. pub arg: &'tcx hir::Arg, - // the type corresponding to the anonymopus region argument + /// The type corresponding to the anonymopus region argument. pub arg_ty: Ty<'tcx>, - // the ty::BoundRegion corresponding to the anonymous region + /// The `ty::BoundRegion` corresponding to the anonymous region. pub bound_region: ty::BoundRegion, - // arg_ty_span contains span of argument type + /// The span of the argument type. pub arg_ty_span : Span, - // corresponds to id the argument is the first parameter - // in the declaration + /// `true` if corresponds to the ID the argument of the first parameter + /// in the declaration. pub is_first: bool, } impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { - // This method walks the Type of the function body arguments using - // `fold_regions()` function and returns the - // &hir::Arg of the function argument corresponding to the anonymous - // region and the Ty corresponding to the named region. + // Walks the type of the function body arguments using the `fold_regions()` + // function and returns the `&hir::Arg` of the function argument corresponding + // to the anonymous region and the `Ty` corresponding to the named region. // Currently only the case where the function declaration consists of // one named region and one anonymous region is handled. // Consider the example `fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32` - // Here, we would return the hir::Arg for y, we return the type &'a - // i32, which is the type of y but with the anonymous region replaced - // with 'a, the corresponding bound region and is_first which is true if - // the hir::Arg is the first argument in the function declaration. + // Here, we would return the `hir::Arg` for `y`, we return the type `&'a + // i32`, which is the type of y but with the anonymous region replaced + // with `'a`, the corresponding bound region and `is_first` which is true if + // the `hir::Arg` is the first argument in the function declaration. pub(super) fn find_arg_with_region( &self, anon_region: Region<'tcx>, @@ -47,7 +45,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { self.tcx().parent_def_id(ebr.def_id).unwrap(), ty::BoundRegion::BrNamed(ebr.def_id, ebr.name), ), - _ => return None, // not a free region + // Not a free region. + _ => return None, }; let hir = &self.tcx().hir(); @@ -61,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { .iter() .enumerate() .filter_map(|(index, arg)| { - // May return None; sometimes the tables are not yet populated. + // May return `None`; sometimes the tables are not yet populated. let ty_hir_id = fn_decl.inputs[index].hir_id; let arg_ty_span = hir.span(hir.hir_to_node_id(ty_hir_id)); let ty = tables.node_type_opt(arg.hir_id)?; @@ -99,9 +98,9 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { } } - // Here, we check for the case where the anonymous region - // is in the return type. - // FIXME(#42703) - Need to handle certain cases here. + /// Checks for the case where the anonymous region is in the return type. + // + // FIXME(#42703): need to handle certain cases here. pub(super) fn is_return_type_anon( &self, scope_def_id: DefId, @@ -120,10 +119,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { None } - // Here we check for the case where anonymous region - // corresponds to self and if yes, we display E0312. - // FIXME(#42700) - Need to format self properly to - // enable E0621 for it. + /// Check for the case where anonymous region corresponds to `self`, + /// and if so, we display E0312. + // + // FIXME(#42700): need to format self properly to enable E0621 for it. pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool { is_first && self.tcx() diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index c05c6567bbefa..a9f6c74112521 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -375,7 +375,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { E0487, "unsafe use of destructor: destructor might be \ called while references are dead"); - // FIXME (22171): terms "super/subregion" are suboptimal + // FIXME(#22171): terms "super"/"subregion" are suboptimal. self.tcx.note_and_explain_region(region_scope_tree, &mut err, "superregion: ", sup, ""); self.tcx.note_and_explain_region(region_scope_tree, &mut err, diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 201717b34ee41..843903d6a15dd 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -152,7 +152,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::Infer(ty::FreshIntTy(c)) | ty::Infer(ty::FreshFloatTy(c)) => { if c >= self.freshen_count { - bug!("Encountered a freshend type with id {} \ + bug!("Encountered a freshend type with ID {} \ but our counter is only at {}", c, self.freshen_count); diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index 5f6a8802b4def..9575fa7a26f31 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -117,7 +117,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFudger<'a, 'gcx, 'tcx> { match self.type_variables.get(&vid) { None => { // This variable was created before the - // "fudging". Since we refresh all type + // "fudging". Since we refresh all type // variables to their binding anyhow, we know // that it is unbound, so we can just return // it. diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 910c6571853dc..1263857c12bee 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -39,7 +39,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> match variance { ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b), ty::Covariant => self.relate(a, b), - // FIXME(#41044) -- not correct, need test + // FIXME(#41044): not correct, need test. ty::Bivariant => Ok(a.clone()), ty::Contravariant => self.fields.lub(self.a_is_expected).relate(a, b), } diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 7f01078737d73..b2bc68fc77da9 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -23,7 +23,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { // as-is, we need to do some extra work here in order to make sure // that function subtyping works correctly with respect to regions // - // Note: this is a subtle algorithm. For a full explanation, + // Note: this is a subtle algorithm. For a full explanation, // please see the large comment at the end of the file in the (inlined) module // `doc`. @@ -34,8 +34,8 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { let (b_prime, _) = self.infcx.replace_bound_vars_with_placeholders(b); // Next, we instantiate each bound region in the subtype - // with a fresh region variable. These region variables -- - // but no other pre-existing region variables -- can name + // with a fresh region variable. These region variables + // (but no other pre-existing region variables) can name // the placeholders. let (a_prime, _) = self.infcx diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index e40bb97240763..56441ff1129ae 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -68,7 +68,7 @@ pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L, // // Example: if the LHS is a type variable, and RHS is // `Box`, then we current compare `v` to the RHS first, - // which will instantiate `v` with `Box`. Then when `v` + // which will instantiate `v` with `Box`. Then when `v` // is compared to the LHS, we instantiate LHS with `Box`. // But if we did in reverse order, we would create a `v <: // LHS` (or vice versa) constraint and then instantiate diff --git a/src/librustc/infer/lexical_region_resolve/graphviz.rs b/src/librustc/infer/lexical_region_resolve/graphviz.rs index 073a3f74422c6..ca91bc7828634 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -27,20 +27,20 @@ use std::sync::atomic::{AtomicBool, Ordering}; fn print_help_message() { println!("\ --Z print-region-graph by default prints a region constraint graph for every \n\ +`-Z print-region-graph` by default prints a region constraint graph for every \n\ function body, to the path `constraints.nodeXXX.dot`, where the XXX is \n\ -replaced with the node id of the function under analysis. \n\ - \n\ -To select one particular function body, set `RUST_REGION_GRAPH_NODE=XXX`, \n\ -where XXX is the node id desired. \n\ - \n\ -To generate output to some path other than the default \n\ -`constraints.nodeXXX.dot`, set `RUST_REGION_GRAPH=/path/desired.dot`; \n\ -occurrences of the character `%` in the requested path will be replaced with\n\ -the node id of the function under analysis. \n\ - \n\ -(Since you requested help via RUST_REGION_GRAPH=help, no region constraint \n\ -graphs will be printed. \n\ +replaced with the `NodeId` of the function under analysis. \n\ +\n\ +To select one particular function body, set `RUST_REGION_GRAPH_NODE=XXX`, \n\ +where XXX is the `NodeId` desired. \n\ +\n\ +To generate output to some path other than the default \n\ +`constraints.nodeXXX.dot`, set `RUST_REGION_GRAPH=/path/desired.dot`; \n\ +occurrences of the character `%` in the requested path will be replaced with \n\ +the `NodeId` of the function under analysis. \n\ +\n\ +(Since you requested help via RUST_REGION_GRAPH=help, no region constraint \n\ +graphs will be printed. \n\ "); } @@ -175,7 +175,7 @@ impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { let name = || format!("node_{}", node_id); dot::Id::new(name()).unwrap_or_else(|_| - bug!("failed to create graphviz node identified by {}", name())) + bug!("failed to create graphviz `NodeId`entified by {}", name())) } fn node_label(&self, n: &Node) -> dot::LabelText<'_> { match *n { diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 03ade88253682..f1c217fa11cc4 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -262,7 +262,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { // of the parameter environment, we might be able to find a // tighter bound than `'static`. // - // (This might e.g. arise from being asked to prove `for<'a> { 'b: 'a }`.) + // (This might, e.g., arise from being asked to prove `for<'a> { 'b: 'a }`.) let b_universe = self.var_infos[b_vid].universe; if let ty::RePlaceholder(p) = lub { if b_universe.cannot_name(p.universe) { @@ -271,7 +271,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { } debug!( - "Expanding value of {:?} from {:?} to {:?}", + "expanding value of {:?} from {:?} to {:?}", b_vid, cur_region, lub ); @@ -299,11 +299,13 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { } (r @ &ReStatic, _) | (_, r @ &ReStatic) => { - r // nothing lives longer than static + // Nothing lives longer than static. + r } (&ReEmpty, r) | (r, &ReEmpty) => { - r // everything lives longer than empty + // Everything lives longer than empty. + r } (&ReVar(v_id), _) | (_, &ReVar(v_id)) => { @@ -321,8 +323,8 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { | (&ReFree(_), &ReScope(s_id)) | (&ReScope(s_id), &ReFree(_)) => { // A "free" region can be interpreted as "some region - // at least as big as fr.scope". So, we can - // reasonably compare free regions and scopes: + // at least as big as fr.scope". So, we can + // reasonably compare free regions and scopes. let fr_scope = match (a, b) { (&ReEarlyBound(ref br), _) | (_, &ReEarlyBound(ref br)) => self.region_rels .region_scope_tree @@ -336,9 +338,9 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { .region_scope_tree .nearest_common_ancestor(fr_scope, s_id); if r_id == fr_scope { - // if the free region's scope `fr.scope` is bigger than + // If the free region's scope `fr.scope` is bigger than // the scope region `s_id`, then the LUB is the free - // region itself: + // region itself. match (a, b) { (_, &ReScope(_)) => return a, (&ReScope(_), _) => return b, @@ -346,8 +348,8 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { } } - // otherwise, we don't know what the free region is, - // so we must conservatively say the LUB is static: + // Otherwise, we don't know what the free region is, + // so we must conservatively say the LUB is static. tcx.types.re_static } @@ -366,8 +368,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { | (&ReEarlyBound(_), &ReFree(_)) | (&ReFree(_), &ReFree(_)) => self.region_rels.lub_free_regions(a, b), - // For these types, we cannot define any additional - // relationship: + // For these types, we cannot define any additional relationship. (&RePlaceholder(..), _) | (_, &RePlaceholder(..)) => if a == b { a } else { @@ -391,7 +392,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { ); match *constraint { Constraint::RegSubVar(..) | Constraint::VarSubVar(..) => { - // Expansion will ensure that these constraints hold. Ignore. + // Expansion will ensure that these constraints hold; ignore. } Constraint::RegSubReg(sub, sup) => { @@ -482,7 +483,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { // conflicting regions to report to the user. As we walk, we // trip the flags from false to true, and if we find that // we've already reported an error involving any particular - // node we just stop and don't report the current error. The + // node we just stop and don't report the current error. The // idea is to report errors that derive from independent // regions of the graph, but not those that derive from // overlapping locations. @@ -513,7 +514,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { the mere existence of a conflict in a region variable that is not used is not a problem, so if this rule starts to create problems we'll have to revisit - this portion of the code and think hard about it. =) */ + this portion of the code and think hard about it. */ self.collect_error_for_expanding_node(graph, &mut dup_vec, node_vid, errors); } } @@ -553,7 +554,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { graph.add_edge(NodeIndex(a_id.index() as usize), dummy_sink, *constraint); } Constraint::RegSubReg(..) => { - // this would be an edge from `dummy_source` to + // This would be an edge from `dummy_source` to // `dummy_sink`; just ignore it. } } @@ -581,8 +582,8 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { } // We place free regions first because we are special casing - // SubSupConflict(ReFree, ReFree) when reporting error, and so - // the user will more likely get a specific suggestion. + // `SubSupConflict(ReFree, ReFree)` when reporting error, and so + // the user will more likely get a specific suggestion.. fn region_order_key(x: &RegionAndOrigin<'_>) -> u8 { match *x.region { ReEarlyBound(_) => 0, @@ -662,14 +663,14 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { }; state.set.insert(orig_node_idx); - // to start off the process, walk the source node in the - // direction specified + // To start off the process, walk the source node in the + // direction specified. process_edges(&self.data, &mut state, graph, orig_node_idx, dir); while !state.stack.is_empty() { let node_idx = state.stack.pop().unwrap(); - // check whether we've visited this node on some previous walk + // Check whether we've visited this node on some previous walk. if dup_vec[node_idx.index() as usize] == u32::MAX { dup_vec[node_idx.index() as usize] = orig_node_idx.index() as u32; } else if dup_vec[node_idx.index() as usize] != orig_node_idx.index() as u32 { diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index f9eb60d82d17b..4825aed5fc35a 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -39,7 +39,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> match variance { ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b), ty::Covariant => self.relate(a, b), - // FIXME(#41044) -- not correct, need test + // FIXME(#41044): not correct, need test. ty::Bivariant => Ok(a.clone()), ty::Contravariant => self.fields.glb(self.a_is_expected).relate(a, b), } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index a61771b2a4eea..d1fd32ddbcc2c 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -1,11 +1,36 @@ //! See the Book for more information. -pub use self::freshen::TypeFreshener; -pub use self::LateBoundRegionConversionTime::*; -pub use self::RegionVariableOrigin::*; -pub use self::SubregionOrigin::*; -pub use self::ValuePairs::*; -pub use crate::ty::IntVarValue; +pub mod at; +pub mod canonical; +mod combine; +mod equate; +pub mod error_reporting; +mod freshen; +mod fudge; +mod glb; +mod higher_ranked; +pub mod lattice; +mod lexical_region_resolve; +mod lub; +pub mod nll_relate; +pub mod opaque_types; +pub mod outlives; +pub mod region_constraints; +pub mod resolve; +mod sub; +pub mod type_variable; +pub mod unify_key; + +use std::cell::{Cell, Ref, RefCell, RefMut}; +use std::collections::BTreeMap; +use std::fmt; + +use arena::SyncDroplessArena; +use errors::DiagnosticBuilder; +use rustc_data_structures::unify as ut; +use syntax_pos::{self, Span}; +use syntax_pos::symbol::InternedString; +use syntax::ast; use crate::hir; use crate::hir::def_id::DefId; @@ -15,24 +40,19 @@ use crate::middle::lang_items; use crate::middle::region; use crate::session::config::BorrowckMode; use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; +use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; +use crate::ty::{FloatVid, IntVid, TyVid}; +pub use crate::ty::IntVarValue; use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use crate::ty::fold::TypeFoldable; use crate::ty::relate::RelateResult; use crate::ty::subst::{Kind, Substs}; -use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; -use crate::ty::{FloatVid, IntVid, TyVid}; use crate::util::nodemap::FxHashMap; - -use arena::SyncDroplessArena; -use errors::DiagnosticBuilder; -use rustc_data_structures::unify as ut; -use std::cell::{Cell, Ref, RefCell, RefMut}; -use std::collections::BTreeMap; -use std::fmt; -use syntax::ast; -use syntax_pos::symbol::InternedString; -use syntax_pos::Span; - +pub use self::LateBoundRegionConversionTime::*; +pub use self::RegionVariableOrigin::*; +pub use self::SubregionOrigin::*; +pub use self::ValuePairs::*; +pub use self::freshen::TypeFreshener; use self::combine::CombineFields; use self::lexical_region_resolve::LexicalRegionResolutions; use self::outlives::env::OutlivesEnvironment; @@ -41,27 +61,6 @@ use self::region_constraints::{RegionConstraintCollector, RegionSnapshot}; use self::type_variable::TypeVariableOrigin; use self::unify_key::ToType; -pub mod at; -pub mod canonical; -mod combine; -mod equate; -pub mod error_reporting; -mod freshen; -mod fudge; -mod glb; -mod higher_ranked; -pub mod lattice; -mod lexical_region_resolve; -mod lub; -pub mod nll_relate; -pub mod opaque_types; -pub mod outlives; -pub mod region_constraints; -pub mod resolve; -mod sub; -pub mod type_variable; -pub mod unify_key; - #[must_use] #[derive(Debug)] pub struct InferOk<'tcx, T> { @@ -71,12 +70,14 @@ pub struct InferOk<'tcx, T> { pub type InferResult<'tcx, T> = Result, TypeError<'tcx>>; pub type Bound = Option; -pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result" -pub type FixupResult = Result; // "fixup result" +// "Unify result" +pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; +// "Fixup result" +pub type FixupResult = Result; /// A flag that is used to suppress region errors. This is normally -/// false, but sometimes -- when we are doing region checks that the -/// NLL borrow checker will also do -- it might be set to true. +/// `false`, but sometimes -- when we are doing region checks that the +/// NLL borrow checker will also do -- it might be set to `true`. #[derive(Copy, Clone, Default, Debug)] pub struct SuppressRegionErrors { suppressed: bool, @@ -87,16 +88,15 @@ impl SuppressRegionErrors { self.suppressed } - /// Indicates that the MIR borrowck will repeat these region - /// checks, so we should ignore errors if NLL is (unconditionally) - /// enabled. + /// Indicates that the MIR borrowck will repeat these region checks, + /// so we should ignore errors if NLL is (unconditionally) enabled. pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_, '_>) -> Self { match tcx.borrowck_mode() { - // If we're on AST or Migrate mode, report AST region errors + // If we're in AST or Migrate mode, report AST region errors. BorrowckMode::Ast | BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, - // If we're on MIR or Compare mode, don't report AST region errors as they should - // be reported by NLL + // If we're in MIR or Compare mode, don't report AST region errors as they should + // be reported by NLL. BorrowckMode::Compare | BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, } } @@ -122,14 +122,14 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { // order, represented by its upper and lower bounds. pub type_variables: RefCell>, - // Map from integral variable to the kind of integer it represents + // Map from integral variable to the kind of integer it represents. int_unification_table: RefCell>>, - // Map from floating variable to the kind of float it represents + // Map from floating variable to the kind of float it represents. float_unification_table: RefCell>>, // Tracks the set of region variables and the constraints between - // them. This is initially `Some(_)` but when + // them. This is initially `Some(_)` but when // `resolve_regions_and_report_errors` is invoked, this gets set // to `None` -- further attempts to perform unification etc may // fail if new region constraints would've been added. @@ -170,7 +170,7 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { // `tained_by_errors`) to avoid reporting certain kinds of errors. err_count_on_creation: usize, - // This flag is true while there is an active snapshot. + // This flag is `true` while there is an active snapshot. in_snapshot: Cell, // A set of constraints that regionck must validate. Each @@ -188,7 +188,7 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { // can't generally check these things right away because we have // to wait until types are resolved.) // - // These are stored in a map keyed to the id of the innermost + // These are stored in a map keyed to the ID of the innermost // enclosing fn body / static initializer expression. This is // because the location where the obligation was incurred can be // relevant with respect to which sublifetime assumptions are in @@ -196,7 +196,7 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { // something more fine-grained, is so that it is easier for // regionck to be sure that it has found *all* the region // obligations (otherwise, it's easy to fail to walk to a - // particular node-id). + // particular `NodeId`). // // Before running `resolve_regions_and_report_errors`, the creator // of the inference context is expected to invoke @@ -244,30 +244,30 @@ pub struct TypeTrace<'tcx> { /// The origin of a `r1 <= r2` constraint. /// -/// See `error_reporting` module for more details +/// See the `error_reporting` module for more details. #[derive(Clone, Debug)] pub enum SubregionOrigin<'tcx> { - // Arose from a subtyping relation + // Arose from a subtyping relation. Subtype(TypeTrace<'tcx>), // Stack-allocated closures cannot outlive innermost loop - // or function so as to ensure we only require finite stack + // or function so as to ensure we only require finite stack. InfStackClosure(Span), - // Invocation of closure must be within its lifetime + // Invocation of closure must be within its lifetime. InvokeClosure(Span), - // Dereference of reference must be within its lifetime + // Dereference of reference must be within its lifetime. DerefPointer(Span), - // Closure bound must not outlive captured free variables + // Closure bound must not outlive captured free variables. FreeVariable(Span, ast::NodeId), - // Index into slice must be within its lifetime + // Index into slice must be within its lifetime. IndexSlice(Span), // When casting `&'a T` to an `&'b Trait` object, - // relating `'a` to `'b` + // relating `'a` to `'b`. RelateObjectBound(Span), // Some type parameter was instantiated with the given type, @@ -282,16 +282,16 @@ pub enum SubregionOrigin<'tcx> { // the moment of their instantiation. RelateDefaultParamBound(Span, Ty<'tcx>), - // Creating a pointer `b` to contents of another reference + // Creating a pointer `b` to contents of another reference. Reborrow(Span), - // Creating a pointer `b` to contents of an upvar + // Creating a pointer `b` to contents of an upvar. ReborrowUpvar(Span, ty::UpvarId), - // Data with type `Ty<'tcx>` was borrowed + // Data with type `Ty<'tcx>` was borrowed. DataBorrowed(Ty<'tcx>, Span), - // (&'a &'b T) where a >= b + // `(&'a &'b T)` where `a >= b`. ReferenceOutlivesReferent(Ty<'tcx>, Span), // Type or region parameters must be in scope. @@ -300,28 +300,28 @@ pub enum SubregionOrigin<'tcx> { // The type T of an expression E must outlive the lifetime for E. ExprTypeIsNotInScope(Ty<'tcx>, Span), - // A `ref b` whose region does not enclose the decl site + // A `ref b` whose region does not enclose the declaration site. BindingTypeIsNotValidAtDecl(Span), - // Regions appearing in a method receiver must outlive method call + // Regions appearing in a method receiver must outlive method call. CallRcvr(Span), - // Regions appearing in a function argument must outlive func call + // Regions appearing in a function argument must outlive func call. CallArg(Span), - // Region in return type of invoked fn must enclose call + // Region in return type of invoked fn must enclose call. CallReturn(Span), - // Operands must be in scope + // Operands must be in scope. Operand(Span), - // Region resulting from a `&` expr must enclose the `&` expr + // Region resulting from a `&` expr must enclose the `&` expr. AddrOf(Span), - // An auto-borrow that does not enclose the expr where it occurs + // An auto-borrow that does not enclose the expr where it occurs. AutoBorrow(Span), - // Region constraint arriving from destructor safety + // Region constraint arriving from destructor safety. SafeDestructor(Span), // Comparing the signature and requirements of an impl method against @@ -337,51 +337,51 @@ pub enum SubregionOrigin<'tcx> { /// Places that type/region parameters can appear. #[derive(Clone, Copy, Debug)] pub enum ParameterOrigin { - Path, // foo::bar - MethodCall, // foo.bar() <-- parameters on impl providing bar() - OverloadedOperator, // a + b when overloaded - OverloadedDeref, // *a when overloaded + Path, // `foo::bar` + MethodCall, // `foo.bar()` <-- parameters on impl providing `bar()` + OverloadedOperator, // `a + b` when overloaded + OverloadedDeref, // `*a` when overloaded } -/// Times when we replace late-bound regions with variables: +/// Times when we replace late-bound regions with variables. #[derive(Clone, Copy, Debug)] pub enum LateBoundRegionConversionTime { - /// when a fn is called + /// When a fn is called. FnCall, - /// when two higher-ranked types are compared + /// When two higher-ranked types are compared. HigherRankedType, - /// when projecting an associated type + /// When projecting an associated type. AssocTypeProjection(DefId), } /// Reasons to create a region inference variable /// -/// See `error_reporting` module for more details +/// See the `error_reporting` module for more details #[derive(Copy, Clone, Debug)] pub enum RegionVariableOrigin { // Region variables created for ill-categorized reasons, - // mostly indicates places in need of refactoring + // mostly indicates places in need of refactoring. MiscVariable(Span), - // Regions created by a `&P` or `[...]` pattern + // Regions created by a `&P` or `[...]` pattern. PatternRegion(Span), - // Regions created by `&` operator + // Regions created by `&` operator. AddrOfRegion(Span), - // Regions created as part of an autoref of a method receiver + // Regions created as part of an autoref of a method receiver. Autoref(Span), - // Regions created as part of an automatic coercion + // Regions created as part of an automatic coercion. Coercion(Span), - // Region variables created as the values for early-bound regions + // Region variables created as the values for early-bound regions. EarlyBoundRegion(Span, InternedString), // Region variables created for bound regions - // in a function or method that is called + // in a function or method that is called. LateBoundRegion(Span, ty::BoundRegion, LateBoundRegionConversionTime), UpvarRegion(ty::UpvarId, Span), @@ -696,7 +696,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // register obligations, within a snapshot. Very useful, much // better than grovelling through megabytes of RUST_LOG output. // - // HOWEVER, in some cases the flag is unhelpful. In particular, we + // _However_, in some cases the flag is unhelpful. In particular, we // sometimes create a "mini-fulfilment-cx" in which we enroll // obligations. As long as this fulfillment cx is fully drained // before we return, this is not a problem, as there won't be any @@ -828,7 +828,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { r } - // Execute `f` in a snapshot, and commit the bindings it creates + // Execute `f` in a snapshot, and commit the bindings it creates. pub fn in_snapshot(&self, f: F) -> T where F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> T, @@ -894,8 +894,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.at(origin, param_env) .eq(a, b) .map(|InferOk { obligations: _, .. }| { - // Ignore obligations, since we are unrolling - // everything anyway. + // Ignore obligations, since we are unrolling everything anyway. }) }) } @@ -922,10 +921,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // variable, and because type variable's can't (at present, at // least) capture any of the things bound by this binder. // - // Really, there is no *particular* reason to do this - // `shallow_resolve` here except as a - // micro-optimization. Naturally I could not - // resist. -nmatsakis + // NOTE(nmatsakis): really, there is no *particular* reason to do this + // `shallow_resolve` here except as a micro-optimization. + // Naturally I could not resist. let two_unbound_type_vars = { let a = self.shallow_resolve(predicate.skip_binder().a); let b = self.shallow_resolve(predicate.skip_binder().b); @@ -1086,12 +1084,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ); if self.tcx.sess.err_count() > self.err_count_on_creation { - return true; // errors reported since this infcx was made + // Errors have been reported since this infcx was made. + return true; } self.tainted_by_errors_flag.get() } - /// Set the "tainted by errors" flag to true. We call this when we + /// Sets the "tainted by errors" flag to true. We call this when we /// observe an error from a prior pass. pub fn set_tainted_by_errors(&self) { debug!("set_tainted_by_errors()"); @@ -1136,7 +1135,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if !self.is_tainted_by_errors() { // As a heuristic, just skip reporting region errors // altogether if other errors have been reported while - // this infcx was in use. This is totally hokey but + // this infcx was in use. This is totally hokey but // otherwise we have a hard time separating legit region // errors from silly ones. self.report_region_errors(region_map, &errors, suppress); @@ -1201,7 +1200,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.resolve_type_vars_if_possible(t).to_string() } - // We have this force-inlined variant of shallow_resolve() for the one + // We have this force-inlined variant of `shallow_resolve()` for the one // callsite that is extremely hot. All other callsites use the normal // variant. #[inline(always)] @@ -1264,17 +1263,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { where T: TypeFoldable<'tcx>, { - /*! - * Where possible, replaces type/int/float variables in - * `value` with their final value. Note that region variables - * are unaffected. If a type variable has not been unified, it - * is left as is. This is an idempotent operation that does - * not affect inference state in any way and so you can do it - * at will. - */ + // Where possible, replaces type/int/float variables in + // `value` with their final value. Note that region variables + // are unaffected. If a type variable has not been unified, it + // is left as is. This is an idempotent operation that does + // not affect inference state in any way and so you can do it + // at will. if !value.needs_infer() { - return value.clone(); // avoid duplicated subst-folding + // Avoid duplicated subst-folding. + return value.clone(); } let mut r = resolve::OpportunisticTypeResolver::new(self); value.fold_with(&mut r) @@ -1294,28 +1292,26 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } pub fn fully_resolve>(&self, value: &T) -> FixupResult { - /*! - * Attempts to resolve all type/region variables in - * `value`. Region inference must have been run already (e.g., - * by calling `resolve_regions_and_report_errors`). If some - * variable was never unified, an `Err` results. - * - * This method is idempotent, but it not typically not invoked - * except during the writeback phase. - */ + // Attempts to resolve all type/region variables in `value`. + // Region inference must have been run already (e.g., by calling + // `resolve_regions_and_report_errors`). If some variable was never + // unified, an `Err` results. + // + // This method is idempotent, but it not typically not invoked + // except during the writeback phase. resolve::fully_resolve(self, value) } // [Note-Type-error-reporting] - // An invariant is that anytime the expected or actual type is Error (the special - // error type, meaning that an error occurred when typechecking this expression), + // An invariant is that anytime the expected or actual type is `Error` (the special + // error type, meaning that an error occurred when type-checking this expression), // this is a derived error. The error cascaded from another error (that was already // reported), so it's not useful to display it to the user. // The following methods implement this logic. - // They check if either the actual or expected type is Error, and don't print the error - // in this case. The typechecker should only ever report type errors involving mismatched - // types using one of these methods, and should not call span_err directly for such + // They check if either the actual or expected type is `Error`, and don't print the error + // in this case. The type-checker should only ever report type errors involving mismatched + // types using one of these methods, and should not call `span_err` directly for such // errors. pub fn type_error_struct_with_diag( @@ -1395,9 +1391,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem); - // this can get called from typeck (by euv), and moves_by_default + // This can get called from typeck (by euv), and `moves_by_default` // rightly refuses to work with inference variables, but - // moves_by_default has a cache, which we want to use in other + // `moves_by_default` has a cache, which we want to use in other // cases. traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, copy_def_id, span) } diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index f37e24b292e03..58887826112d5 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -219,8 +219,8 @@ where first_free_index: ty::DebruijnIndex, scopes: &[BoundRegionScope<'tcx>], ) -> ty::Region<'tcx> { - // The debruijn index is a "reverse index" into the - // scopes listing. So when we have INNERMOST (0), we + // The De Bruijn index is a "reverse index" into the + // scopes listing. So when we have `INNERMOST` (`0`), we // want the *last* scope pushed, and so forth. let debruijn_index = debruijn.index() - first_free_index.index(); let scope = &scopes[scopes.len() - debruijn_index - 1]; @@ -594,11 +594,11 @@ where /// (these are not explicitly present in the ty representation right /// now). This visitor handles that: it descends the type, tracking /// binder depth, and finds late-bound regions targeting the -/// `for<..`>. For each of those, it creates an entry in +/// `for<..`>. For each of those, it creates an entry in /// `bound_region_scope`. struct ScopeInstantiator<'me, 'tcx: 'me> { next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>, - // The debruijn index of the scope we are instantiating. + // The De Bruijn index of the scope we are instantiating. target_index: ty::DebruijnIndex, bound_region_scope: &'me mut BoundRegionScope<'tcx>, } @@ -829,7 +829,7 @@ where // `self.universe` universe, this also serves to enforce the // universe scoping rules. // - // FIXME(#54105) -- if the ambient variance is bivariant, + // FIXME(#54105): if the ambient variance is bivariant, // though, we may however need to check well-formedness or // risk a problem like #41677 again. diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 1f81321d22d6e..35506c28c3116 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -1,10 +1,11 @@ +use rustc_data_structures::fx::FxHashMap; +use syntax::ast; + use crate::hir::def_id::DefId; use crate::hir; use crate::hir::Node; use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; use crate::infer::outlives::free_region_map::FreeRegionRelations; -use rustc_data_structures::fx::FxHashMap; -use syntax::ast; use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; @@ -290,7 +291,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let span = self.tcx.def_span(def_id); // If there are required region bounds, we can just skip - // ahead. There will already be a registered region + // ahead. There will already be a registered region // obligation related `concrete_ty` to those regions. if opaque_defn.has_required_region_bounds { return; @@ -649,7 +650,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { if let ty::Opaque(def_id, substs) = ty.sty { // Check that this is `impl Trait` type is // declared by `parent_def_id` -- i.e., one whose - // value we are inferring. At present, this is + // value we are inferring. At present, this is // always true during the first phase of // type-check, but not always true later on during // NLL. Once we support named abstract types more fully, @@ -750,7 +751,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { def_id, substs ); - // Use the same type variable if the exact same Opaque appears more + // Use the same type variable if the exact same opaque type appears more // than once in the return type (e.g., if it's passed to a type alias). if let Some(opaque_defn) = self.opaque_types.get(&def_id) { return opaque_defn.concrete_ty; @@ -772,9 +773,9 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { required_region_bounds ); - // make sure that we are in fact defining the *entire* type - // e.g., `existential type Foo: Bar;` needs to be - // defined by a function like `fn foo() -> Foo`. + // Make sure that we are in fact defining the *entire* type + // (e.g., `existential type Foo: Bar;` needs to be + // defined by a function like `fn foo() -> Foo`). debug!( "instantiate_opaque_types: param_env: {:#?}", self.param_env, @@ -836,18 +837,15 @@ pub fn may_define_existential_type( def_id: DefId, opaque_node_id: ast::NodeId, ) -> bool { - let mut node_id = tcx - .hir() - .as_local_node_id(def_id) - .unwrap(); - // named existential types can be defined by any siblings or - // children of siblings + let mut node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + // Named existential types can be defined by any siblings or + // children of siblings. let mod_id = tcx.hir().get_parent(opaque_node_id); - // so we walk up the node tree until we hit the root or the parent - // of the opaque type + // We walk up the node tree until we hit the root or the parent + // of the opaque type. while node_id != mod_id && node_id != ast::CRATE_NODE_ID { node_id = tcx.hir().get_parent(node_id); } - // syntactically we are allowed to define the concrete type + // Syntactically we are allowed to define the concrete type. node_id == mod_id } diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index bbda3d2fdbf84..71d123d352eb5 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -371,7 +371,7 @@ where // particular). :) First off, we have to choose between using the // OutlivesProjectionEnv, OutlivesProjectionTraitDef, and // OutlivesProjectionComponent rules, any one of which is - // sufficient. If there are no inference variables involved, it's + // sufficient. If there are no inference variables involved, it's // not hard to pick the right rule, but if there are, we're in a // bit of a catch 22: if we picked which rule we were going to // use, we could add constraints to the region inference graph diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index 494f708c6a7b7..82d970393b6de 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -112,7 +112,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { let projection_ty_as_ty = self.tcx.mk_projection(projection_ty.item_def_id, projection_ty.substs); - // Search the env for where clauses like `P: 'a`. + // Search the env for where-clauses like `P: 'a`. let env_bounds = self.projection_approx_declared_bounds_from_env(projection_ty) .into_iter() .map(|ty::OutlivesPredicate(ty, r)| { diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index 65d25333c7179..72c2d6b373fd9 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -474,7 +474,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { fn rollback_undo_entry(&mut self, undo_entry: UndoLog<'tcx>) { match undo_entry { Purged => { - // nothing to do here + // Nothing to do here. } AddVar(vid) => { self.var_infos.pop().unwrap(); @@ -586,7 +586,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { // the top of this file for more details. // // This computation is potentially wrong in the face of - // rollover. It's conceivable, if unlikely, that one might + // rollover. It's conceivable, if unlikely, that one might // wind up with accidental capture for nested functions in // that case, if the outer function had bound regions created // a very long time before and the inner function somehow @@ -633,7 +633,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { // cannot add verifys once regions are resolved debug!("RegionConstraintCollector: add_verify({:?})", verify); - // skip no-op cases known to be satisfied + // skip noop cases known to be satisfied if let VerifyBound::AllBounds(ref bs) = verify.bound { if bs.len() == 0 { return; diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 4a8f0c34ead11..c7fa5342393f9 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -129,7 +129,7 @@ pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, } } -// N.B. This type is not public because the protocol around checking the +// N.B., this type is not public because the protocol around checking the // `err` field is not enforcable otherwise. struct FullTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index 0cff42742c30a..6b238c664c3c0 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -123,7 +123,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> debug!("{}.regions({:?}, {:?}) self.cause={:?}", self.tag(), a, b, self.fields.cause); - // FIXME -- we have more fine-grained information available + // FIXME: we have more fine-grained information available // from the "cause" field, we could perhaps give more tailored // error messages. let origin = SubregionOrigin::Subtype(self.fields.trace.clone()); diff --git a/src/librustc/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index 09a0a6ce9c97c..4dd10d24ceec4 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -416,7 +416,7 @@ impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> { fn unify_values(value1: &Self, value2: &Self) -> Result { match (value1, value2) { // We never equate two type variables, both of which - // have known types. Instead, we recursively equate + // have known types. Instead, we recursively equate // those types. (&TypeVariableValue::Known { .. }, &TypeVariableValue::Known { .. }) => { bug!("equating two type variables, both of which have known types") diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 655707ff9bd0d..48c56b6562975 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -195,7 +195,7 @@ declare_lint! { declare_lint! { pub LATE_BOUND_LIFETIME_ARGUMENTS, Warn, - "detects generic lifetime arguments in path segments with late bound lifetime parameters" + "detects generic lifetime arguments in path segments with late-bound lifetime parameters" } declare_lint! { @@ -323,7 +323,7 @@ declare_lint! { declare_lint! { pub WHERE_CLAUSES_OBJECT_SAFETY, Warn, - "checks the object safety of where clauses" + "checks the object safety of where-clauses" } declare_lint! { @@ -492,8 +492,8 @@ impl BuiltinLintDiagnostics { BuiltinLintDiagnostics::AbsPathWithModule(span) => { let (sugg, app) = match sess.source_map().span_to_snippet(span) { Ok(ref s) => { - // FIXME(Manishearth) ideally the emitting code - // can tell us whether or not this is global + // FIXME(Manishearth): ideally, the emitting code + // can tell us whether or not this is global. let opt_colon = if s.trim_start().starts_with("::") { "" } else { diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 9032fcf8b612a..04646b47009f3 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -14,32 +14,32 @@ //! upon. As the ast is traversed, this keeps track of the current lint level //! for all lint attributes. -use self::TargetLint::*; - +use std::default::Default as StdDefault; use std::slice; + +use errors::DiagnosticBuilder; use rustc_data_structures::sync::ReadGuard; +use rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; +use syntax_pos::{MultiSpan, Span, symbol::{LocalInternedString, Symbol}}; +use syntax::ast; +use syntax::edition; +use syntax::util::lev_distance::find_best_match_for_name; +use syntax::visit as ast_visit; + +use crate::hir; +use crate::hir::def_id::LOCAL_CRATE; +use crate::hir::intravisit as hir_visit; use crate::lint::{EarlyLintPass, EarlyLintPassObject, LateLintPassObject}; use crate::lint::{LintArray, Level, Lint, LintId, LintPass, LintBuffer}; use crate::lint::builtin::BuiltinLintDiagnostics; use crate::lint::levels::{LintLevelSets, LintLevelsBuilder}; use crate::middle::privacy::AccessLevels; -use crate::rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; use crate::session::{config, early_error, Session}; use crate::ty::{self, TyCtxt, Ty}; use crate::ty::layout::{LayoutError, LayoutOf, TyLayout}; use crate::util::nodemap::FxHashMap; use crate::util::common::time; - -use std::default::Default as StdDefault; -use syntax::ast; -use syntax::edition; -use syntax_pos::{MultiSpan, Span, symbol::{LocalInternedString, Symbol}}; -use errors::DiagnosticBuilder; -use crate::hir; -use crate::hir::def_id::LOCAL_CRATE; -use crate::hir::intravisit as hir_visit; -use syntax::util::lev_distance::find_best_match_for_name; -use syntax::visit as ast_visit; +use self::TargetLint::*; /// Information about the registered lints. /// @@ -564,7 +564,6 @@ impl LintPassObject for EarlyLintPassObject {} impl LintPassObject for LateLintPassObject {} - pub trait LintContext<'tcx>: Sized { type PassObject: LintPassObject; @@ -1349,12 +1348,12 @@ pub fn check_ast_crate( } // All of the buffered lints should have been emitted at this point. - // If not, that means that we somehow buffered a lint for a node id + // If not, that means that we somehow buffered a lint for a `NodeId` // that was not lint-checked (perhaps it doesn't exist?). This is a bug. // // Rustdoc runs everybody-loops before the early lints and removes // function bodies, so it's totally possible for linted - // node ids to not exist (e.g., macros defined within functions for the + // `NodeId`s to not exist (e.g., macros defined within functions for the // unused_macro lint) anymore. So we only run this check // when we're not in rustdoc mode. (see issue #47639) if !sess.opts.actually_rustdoc { diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 924aa3fde0a08..303ea37824603 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -208,7 +208,7 @@ impl<'a> LintLevelsBuilder<'a> { }; if metas.is_empty() { - // FIXME (#55112): issue unused-attributes lint for `#[level()]` + // FIXME(#55112): issue unused-attributes lint for `#[level()]` continue; } @@ -223,7 +223,7 @@ impl<'a> LintLevelsBuilder<'a> { if item.ident == "reason" { // found reason, reslice meta list to exclude it metas = &metas[0..metas.len()-1]; - // FIXME (#55112): issue unused-attributes lint if we thereby + // FIXME(#55112): issue unused-attributes lint if we thereby // don't have any lint names (`#[level(reason = "foo")]`) if let ast::LitKind::Str(rationale, _) = name_value.node { if !self.sess.features_untracked().lint_reasons { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 859ceb4bd074d..715d736064b4e 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -18,9 +18,6 @@ //! example) requires more effort. See `emit_lint` and `GatherNodeLevels` //! in `context.rs`. -pub use self::Level::*; -pub use self::LintSource::*; - use rustc_data_structures::sync::{self, Lrc}; use crate::hir::def_id::{CrateNum, LOCAL_CRATE}; @@ -45,6 +42,9 @@ pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore check_crate, check_ast_crate, CheckLintNameResult, FutureIncompatibleInfo, BufferedEarlyLint}; +pub use self::Level::*; +pub use self::LintSource::*; + /// Specification of a single lint. #[derive(Copy, Clone, Debug)] pub struct Lint { @@ -810,31 +810,34 @@ pub fn provide(providers: &mut Providers<'_>) { providers.lint_levels = lint_levels; } -/// Returns whether `span` originates in a foreign crate's external macro. +/// Returns `true` if `span` originates in a foreign crate's external macro. /// /// This is used to test whether a lint should be entirely aborted above. pub fn in_external_macro(sess: &Session, span: Span) -> bool { let info = match span.ctxt().outer().expn_info() { Some(info) => info, - // no ExpnInfo means this span doesn't come from a macro + // No `ExpnInfo` means this span doesn't come from a macro. None => return false, }; match info.format { - ExpnFormat::MacroAttribute(..) => return true, // definitely a plugin - ExpnFormat::CompilerDesugaring(_) => return true, // well, it's "external" - ExpnFormat::MacroBang(..) => {} // check below + // Definitely a plugin. + ExpnFormat::MacroAttribute(..) => return true, + // Well, it's "external". + ExpnFormat::CompilerDesugaring(_) => return true, + // See below. + ExpnFormat::MacroBang(..) => {} } let def_site = match info.def_site { Some(span) => span, - // no span for the def_site means it's an external macro + // No span for the `def_site` means it's an external macro. None => return true, }; match sess.source_map().span_to_snippet(def_site) { Ok(code) => !code.starts_with("macro_rules"), - // no snippet = external macro or compiler-builtin expansion + // No snippet means external macro or compiler-builtin expansion. Err(_) => true, } } diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 6e9552a1e9209..b0ea7a4a39081 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -182,7 +182,7 @@ pub trait MetadataLoader { /// functionality should be driven through queries instead! /// /// If you find a method on this trait named `{name}_untracked` it signifies -/// that it's *not* tracked for dependency information throughout compilation +/// that it's **not** tracked for dependency information throughout compilation /// (it'd break incremental compilation) and should only be called pre-HIR (e.g. /// during resolve) pub trait CrateStore { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 569968bd6d4bf..3ad166acc084c 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -484,7 +484,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { && !has_allow_dead_code_or_lang_attr(self.tcx, fi.id, &fi.attrs) } - // id := node id of an item's definition. + // `id`: `NodeId` of an item's definition. fn symbol_is_live( &mut self, id: ast::NodeId, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 8da20ba426663..6e8d4757c7732 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -40,7 +40,7 @@ pub trait Delegate<'tcx> { // The value found at `cmt` has been determined to match the // pattern binding `matched_pat`, and its subparts are being - // copied or moved depending on `mode`. Note that `matched_pat` + // copied or moved depending on `mode`. Note that `matched_pat` // is called on all variant/structs in the pattern (i.e., the // interior nodes of the pattern's tree structure) while // consume_pat is called on the binding identifiers in the pattern @@ -128,7 +128,7 @@ enum TrackMatchMode { impl TrackMatchMode { // Builds up the whole match mode for a pattern from its constituent - // parts. The lattice looks like this: + // parts. The lattice looks like this: // // Conflicting // / \ @@ -801,7 +801,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } /// Walks a pat that occurs in isolation (i.e., top-level of fn argument or - /// let binding, and *not* a match arm or nested pat.) + /// let binding, and **not** a match arm or nested pat.) fn walk_irrefutable_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat) { let mut mode = Unknown; self.determine_pat_move_mode(cmt_discr.clone(), pat, &mut mode); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index d3925f40e09e7..d08c7f3e6fe7a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -214,9 +214,9 @@ impl fmt::Debug for Variable { // Creating ir_maps // // This is the first pass and the one that drives the main -// computation. It walks up and down the IR once. On the way down, +// computation. It walks up and down the IR once. On the way down, // we count for each function the number of variables as well as -// liveness nodes. A liveness node is basically an expression or +// liveness nodes. A liveness node is basically an expression or // capture clause that does something of interest: either it has // interesting control flow or it uses/defines a local variable. // @@ -226,11 +226,11 @@ impl fmt::Debug for Variable { // of live variables at each program point. // // Finally, we run back over the IR one last time and, using the -// computed liveness, check various safety conditions. For example, +// computed liveness, check various safety conditions. For example, // there must be no live nodes at the definition site for a variable -// unless it has an initializer. Similarly, each non-mutable local +// unless it has an initializer. Similarly, each non-mutable local // variable must not be assigned if there is some successor -// assignment. And so forth. +// assignment. And so forth. impl LiveNode { fn is_valid(&self) -> bool { @@ -472,7 +472,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); // Make a live_node for each captured variable, with the span - // being the location that the variable is used. This results + // being the location that the variable is used. This results // in better error messages than just pointing at the closure // construction site. let mut call_caps = Vec::new(); @@ -666,8 +666,8 @@ struct Liveness<'a, 'tcx: 'a> { successors: Vec, rwu_table: RWUTable, - // mappings from loop node ID to LiveNode - // ("break" label should map to loop node ID, + // mappings from loop `NodeId` to LiveNode + // ("break" label should map to loop `NodeId`, // it probably doesn't now) break_ln: NodeMap, cont_ln: NodeMap, @@ -927,15 +927,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn compute(&mut self, body: &hir::Expr) -> LiveNode { debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id)); - // the fallthrough exit is only for those cases where we do not - // explicitly return: + // The fallthrough exit is only for those cases where we do not + // explicitly return. let s = self.s; self.init_from_succ(s.fallthrough_ln, s.exit_ln); self.acc(s.fallthrough_ln, s.clean_exit_var, ACC_READ); let entry_ln = self.propagate_through_expr(body, s.fallthrough_ln); - // hack to skip the loop unless debug! is enabled: + // HACK: skip the loop unless `debug!` is enabled. debug!("^^ liveness computation results for body {} (entry={:?})", { for ln_idx in 0..self.ir.num_live_nodes { debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32))); @@ -962,19 +962,18 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { match stmt.node { hir::StmtKind::Local(ref local) => { - // Note: we mark the variable as defined regardless of whether - // there is an initializer. Initially I had thought to only mark + // N.B., we mark the variable as defined regardless of whether + // there is an initializer. Initially, I had thought to only mark // the live variable as defined if it was initialized, and then we // could check for uninit variables just by scanning what is live // at the start of the function. But that doesn't work so well for - // immutable variables defined in a loop: - // loop { let x; x = 5; } + // immutable variables defined in a loop (e.g., `loop { let x; x = 5; }`), // because the "assignment" loops back around and generates an error. // - // So now we just check that variables defined w/o an + // So now we just check that variables defined without an // initializer are not live at the point of their // initialization, which is mildly more complex than checking - // once at the func header but otherwise equivalent. + // once at the function header, but otherwise equivalent. let succ = self.propagate_through_opt_expr(local.init.as_ref().map(|e| &**e), succ); self.define_bindings_in_pat(&local.pat, succ) @@ -1005,7 +1004,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { debug!("propagate_through_expr: {}", self.ir.tcx.hir().node_to_pretty_string(expr.id)); match expr.node { - // Interesting cases with control flow or which gen/kill + // Interesting cases with control flow or which gen/kill. hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) } @@ -1018,7 +1017,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { debug!("{} is an ExprKind::Closure", self.ir.tcx.hir().node_to_pretty_string(expr.id)); - // the construction of a closure itself is not important, + // The construction of a closure itself is not important, // but we have to consider the closed over variables. let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(|| span_bug!(expr.span, "no registered caps")); @@ -1058,7 +1057,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } // Note that labels have been resolved, so we don't need to look - // at the label ident + // at the label ident. hir::ExprKind::Loop(ref blk, _, _) => { self.propagate_through_loop(expr, LoopLoop, &blk, succ) } @@ -1088,9 +1087,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { arm.guard.as_ref().map(|hir::Guard::If(e)| &**e), body_succ ); - // only consider the first pattern; any later patterns must have + // Only consider the first pattern; any later patterns must have // the same bindings, and we also consider the first pattern to be - // the "authoritative" set of ids + // the "authoritative" set of IDs. let arm_succ = self.define_bindings_in_arm_pats(arm.pats.first().map(|p| &**p), guard_succ); @@ -1101,20 +1100,20 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprKind::Ret(ref o_e) => { - // ignore succ and subst exit_ln: + // Ignore `succ` and `subst exit_ln`. let exit_ln = self.s.exit_ln; self.propagate_through_opt_expr(o_e.as_ref().map(|e| &**e), exit_ln) } hir::ExprKind::Break(label, ref opt_expr) => { - // Find which label this break jumps to + // Find which label this break jumps to. let target = match label.target_id { Ok(node_id) => self.break_ln.get(&node_id), Err(err) => span_bug!(expr.span, "loop scope error: {}", err), }.cloned(); // Now that we know the label we're going to, - // look it up in the break loop nodes table + // look it up in the break loop nodes table. match target { Some(b) => self.propagate_through_opt_expr(opt_expr.as_ref().map(|e| &**e), b), @@ -1123,39 +1122,37 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprKind::Continue(label) => { - // Find which label this expr continues to + // Find which label this expr continues to. let sc = label.target_id.unwrap_or_else(|err| span_bug!(expr.span, "loop scope error: {}", err)); // Now that we know the label we're going to, - // look it up in the continue loop nodes table + // look it up in the continue loop nodes table. self.cont_ln.get(&sc).cloned().unwrap_or_else(|| span_bug!(expr.span, "continue to unknown label")) } hir::ExprKind::Assign(ref l, ref r) => { - // see comment on places in - // propagate_through_place_components() + // See comment on places in `propagate_through_place_components()`. let succ = self.write_place(&l, succ, ACC_WRITE); let succ = self.propagate_through_place_components(&l, succ); self.propagate_through_expr(&r, succ) } hir::ExprKind::AssignOp(_, ref l, ref r) => { - // an overloaded assign op is like a method call + // An overloaded assign op is like a method call. if self.tables.is_method_call(expr) { let succ = self.propagate_through_expr(&l, succ); self.propagate_through_expr(&r, succ) } else { - // see comment on places in - // propagate_through_place_components() + // See comment on places in `propagate_through_place_components()`. let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ); let succ = self.propagate_through_expr(&r, succ); self.propagate_through_place_components(&l, succ) } } - // Uninteresting cases: just propagate in rev exec order + // Uninteresting cases: just propagate in reverse execution order. hir::ExprKind::Array(ref exprs) => { self.propagate_through_exprs(exprs, succ) @@ -1222,8 +1219,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| { - // see comment on places - // in propagate_through_place_components() + // See comment on places in `propagate_through_place_components()`. if o.is_indirect { self.propagate_through_expr(output, succ) } else { @@ -1232,7 +1228,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_place_components(output, succ) }}); - // Inputs are executed first. Propagate last because of rev order + // Inputs are executed first. Propagate last because of reverse order. self.propagate_through_exprs(inputs, succ) } @@ -1242,7 +1238,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } // Note that labels have been resolved, so we don't need to look - // at the label ident + // at the label ident. hir::ExprKind::Block(ref blk, _) => { self.propagate_through_block(&blk, succ) } @@ -1278,28 +1274,28 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // || // ----------------------++----------------------- // - // I will cover the two cases in turn: + // We cover the two cases in turn: // // # Tracked places // - // A tracked place is a local variable/argument `x`. In + // A tracked place is a local variable/argument `x`. In // these cases, the link_node where the write occurs is linked - // to node id of `x`. The `write_place()` routine generates - // the contents of this node. There are no subcomponents to + // to `NodeId` of `x`. The `write_place()` routine generates + // the contents of this node. There are no subcomponents to // consider. // // # Non-tracked places // - // These are places like `x[5]` or `x.f`. In that case, we + // These are places like `x[5]` or `x.f`. In that case, we // basically ignore the value which is written to but generate - // reads for the components---`x` in these two examples. The + // reads for the components---`x` in these two examples. The // components reads are generated by // `propagate_through_place_components()` (this fn). // // # Illegal places // // It is still possible to observe assignments to non-places; - // these errors are detected in the later pass borrowck. We + // these errors are detected in the later pass borrowck. We // just ignore such cases and treat them as reads. match expr.node { @@ -1309,7 +1305,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } - // see comment on propagate_through_place() + // See comment on `propagate_through_place()`. fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { match expr.node { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { @@ -1317,7 +1313,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } // We do not track other places, so just propagate through - // to their subcomponents. Also, it may happen that + // to their subcomponents. Also, it may happen that // non-places occur here, because those are detected in the // later pass borrowck. _ => succ @@ -1370,8 +1366,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { */ - - // first iteration: + // First iteration. let mut first_merge = true; let ln = self.live_node(expr.hir_id, expr.span); self.init_empty(ln, succ); @@ -1400,7 +1395,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let body_ln = self.propagate_through_block(body, cond_ln); - // repeat until fixed point is reached: + // Repeat until fixed point is reached. while self.merge_from_succ(ln, body_ln, first_merge) { first_merge = false; @@ -1501,7 +1496,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { this.visit_expr(input); } - // Output operands must be places + // Output operands must be places. for (o, output) in ia.outputs.iter().zip(outputs) { if !o.is_indirect { this.check_place(output); @@ -1512,7 +1507,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { intravisit::walk_expr(this, expr); } - // no correctness conditions related to liveness + // No correctness conditions related to liveness. hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) | hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Index(..) | hir::ExprKind::Field(..) | @@ -1594,9 +1589,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { if !self.used_on_entry(ln, var) { let r = self.should_warn(var); if let Some(name) = r { - // annoying: for parameters in funcs like `fn(x: i32) + // Annoying: for parameters in funcs like `fn(x: i32) // {ret}`, there is only one node, so asking about - // assigned_on_exit() is not meaningful. + // `assigned_on_exit()` is not meaningful. let is_assigned = if ln == self.s.exit_ln { false } else { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 231dcc9bfd272..0efbc793c4299 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -15,8 +15,8 @@ //! | *E // deref of a ptr //! | E.comp // access to an interior component //! -//! Imagine a routine ToAddr(Expr) that evaluates an expression and returns an -//! address where the result is to be found. If Expr is a place, then this +//! Imagine a routine `ToAddr(Expr)` that evaluates an expression and returns an +//! address where the result is to be found. If `Expr` is a place, then this //! is the address of the place. If `Expr` is an rvalue, this is the address of //! some temporary spot in memory where the result is stored. //! @@ -30,9 +30,9 @@ //! - `ty`: the type of data found at the address `A`. //! //! The resulting categorization tree differs somewhat from the expressions -//! themselves. For example, auto-derefs are explicit. Also, an index a[b] is -//! decomposed into two operations: a dereference to reach the array data and -//! then an index to jump forward to the relevant item. +//! themselves. For example, auto-derefs are explicit. Also, an index `a[b]` is +//! decomposed into two operations: a dereference to reach the array data, and +//! an index to jump forward to the relevant item. //! //! ## By-reference upvars //! @@ -50,37 +50,34 @@ #![allow(non_camel_case_types)] -pub use self::PointerKind::*; -pub use self::InteriorKind::*; -pub use self::MutabilityCategory::*; -pub use self::AliasableReason::*; -pub use self::Note::*; +use std::borrow::Cow; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::rc::Rc; -use self::Aliasability::*; +use rustc_data_structures::indexed_vec::Idx; +use rustc_data_structures::sync::Lrc; +use syntax_pos::Span; +use syntax::ast::{self, Name}; -use crate::middle::region; +use crate::hir::{self, Node}; +use crate::hir::{MutImmutable, MutMutable, PatKind}; +use crate::hir::pat_util::EnumerateAndAdjustIterator; +use crate::hir::def::{Def, CtorKind}; use crate::hir::def_id::{DefId, LocalDefId}; -use crate::hir::Node; use crate::infer::InferCtxt; -use crate::hir::def::{Def, CtorKind}; +use crate::middle::region; use crate::ty::adjustment; use crate::ty::{self, Ty, TyCtxt}; use crate::ty::fold::TypeFoldable; use crate::ty::layout::VariantIdx; - -use crate::hir::{MutImmutable, MutMutable, PatKind}; -use crate::hir::pat_util::EnumerateAndAdjustIterator; -use crate::hir; -use syntax::ast::{self, Name}; -use syntax_pos::Span; - -use std::borrow::Cow; -use std::fmt; -use std::hash::{Hash, Hasher}; -use rustc_data_structures::sync::Lrc; -use rustc_data_structures::indexed_vec::Idx; -use std::rc::Rc; use crate::util::nodemap::ItemLocalSet; +use self::Aliasability::*; +pub use self::AliasableReason::*; +pub use self::InteriorKind::*; +pub use self::MutabilityCategory::*; +pub use self::Note::*; +pub use self::PointerKind::*; #[derive(Clone, Debug, PartialEq)] pub enum Categorization<'tcx> { @@ -96,14 +93,14 @@ pub enum Categorization<'tcx> { // (*1) downcast is only required if the enum has more than one variant } -// Represents any kind of upvar +// Represents any kind of upvar. #[derive(Clone, Copy, PartialEq)] pub struct Upvar { pub id: ty::UpvarId, pub kind: ty::ClosureKind } -// different kinds of pointers: +// Different kinds of pointers. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum PointerKind<'tcx> { /// `Box` @@ -117,7 +114,7 @@ pub enum PointerKind<'tcx> { } // We use the term "interior" to mean "something reachable from the -// base without a pointer dereference", e.g., a field +// base without a pointer dereference", e.g., a field. #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum InteriorKind { InteriorField(FieldIndex), @@ -154,10 +151,10 @@ pub enum MutabilityCategory { McInherited, // Inherited from the fact that owner is mutable. } -// A note about the provenance of a `cmt`. This is used for +// A note about the provenance of a `cmt`. This is used for // special-case handling of upvars such as mutability inference. // Upvar categorization can generate a variable number of nested -// derefs. The note allows detecting them without deep pattern +// derefs. The note allows detecting them without deep pattern // matching on the categorization. #[derive(Clone, Copy, PartialEq, Debug)] pub enum Note { @@ -187,12 +184,12 @@ pub enum Note { // a consistent fashion. For more details, see the method `cat_pattern` #[derive(Clone, Debug, PartialEq)] pub struct cmt_<'tcx> { - pub hir_id: hir::HirId, // HIR id of expr/pat producing this value + pub hir_id: hir::HirId, // `HirId` of expr/pat producing this value pub span: Span, // span of same expr/pat pub cat: Categorization<'tcx>, // categorization of expr pub mutbl: MutabilityCategory, // mutability of expr as place pub ty: Ty<'tcx>, // type of the expr (*see WARNING above*) - pub note: Note, // Note about the provenance of this cmt + pub note: Note, // note about the provenance of this cmt } pub type cmt<'tcx> = Rc>; @@ -210,7 +207,7 @@ impl<'tcx> cmt_<'tcx> { let adt_def = match self.ty.sty { ty::Adt(def, _) => def, ty::Tuple(..) => return None, - // closures get `Categorization::Upvar` rather than `Categorization::Interior` + // Closures get `Categorization::Upvar` rather than `Categorization::Interior`. _ => bug!("interior cmt {:?} is not an ADT", self) }; let variant_def = match self.cat { @@ -659,9 +656,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { if self.tables.is_method_call(expr) { // If this is an index implemented by a method call, then it // will include an implicit deref of the result. - // The call to index() returns a `&T` value, which - // is an rvalue. That is what we will be - // dereferencing. + // The call to `index()` returns a `&T` value, which + // is an rvalue. That is what we will be dereferencing. self.cat_overloaded_place(expr, base, NoteIndex) } else { let base_cmt = Rc::new(self.cat_expr(&base)?); @@ -752,7 +748,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } } - // Categorize an upvar, complete with invisible derefs of closure + // Categorizes an upvar, complete with invisible derefs of closure // environment and upvar reference as appropriate. fn cat_upvar(&self, hir_id: hir::HirId, @@ -767,14 +763,14 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the // field from the environment. // - // `Categorization::Upvar`. Next, we add a deref through the implicit + // `Categorization::Upvar`. Next, we add a deref through the implicit // environment pointer with an anonymous free region 'env and // appropriate borrow kind for closure kinds that take self by - // reference. Finally, if the upvar was captured - // by-reference, we add a deref through that reference. The + // reference. Finally, if the upvar was captured + // by-reference, we add a deref through that reference. The // region of this reference is an inference variable 'up that // was previously generated and recorded in the upvar borrow - // map. The borrow kind bk is inferred by based on how the + // map. The borrow kind bk is inferred by based on how the // upvar is used. // // This results in the following table for concrete closure @@ -791,7 +787,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { ty::Closure(closure_def_id, closure_substs) => { match self.infcx { // During upvar inference we may not know the - // closure kind, just use the LATTICE_BOTTOM value. + // closure kind, just use the `LATTICE_BOTTOM` value. Some(infcx) => infcx.closure_kind(closure_def_id, closure_substs) .unwrap_or(ty::ClosureKind::LATTICE_BOTTOM), @@ -815,7 +811,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { let var_ty = self.node_ty(var_hir_id)?; - // Mutability of original variable itself + // Mutability of original variable itself. let var_mutbl = MutabilityCategory::from_local(self.tcx, self.tables, var_id); // Construct the upvar. This represents access to the field @@ -893,9 +889,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { let var_ty = cmt_result.ty; - // We need to add the env deref. This means + // We need to add the env deref. This means // that the above is actually immutable and - // has a ref type. However, nothing should + // has a ref type. However, nothing should // actually look at the type, so we can get // away with stuffing a `Error` in there // instead of bothering to construct a proper @@ -929,7 +925,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { ret } - /// Returns the lifetime of a temporary created by expr with id `id`. + /// Returns the lifetime of a temporary created by expr with ID `id`. /// This could be `'static` if `id` is part of a constant expression. pub fn temporary_scope(&self, id: hir::ItemLocalId) -> ty::Region<'tcx> { let scope = self.region_scope_tree.temporary_scope(id); @@ -1131,7 +1127,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { base_cmt: cmt<'tcx>, variant_did: DefId) -> cmt<'tcx> { - // univariant enums do not need downcasts + // Univariant enums do not need downcasts. let base_did = self.tcx.parent_def_id(variant_did).unwrap(); if self.tcx.adt_def(base_did).variants.len() != 1 { let base_ty = base_cmt.ty; @@ -1157,7 +1153,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { self.cat_pattern_(cmt, pat, &mut op) } - // FIXME(#19596) This is a workaround, but there should be a better way to do this + // FIXME(#19596): this is a workaround, but there should be a better way to do this. fn cat_pattern_(&self, mut cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McResult<()> where F : FnMut(cmt<'tcx>, &hir::Pat) { @@ -1180,8 +1176,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // come back and I'll dive into a bit more detail here. :) OK, // back? // - // In general, the id of the cmt should be the node that - // "produces" the value---patterns aren't executable code + // In general, the ID of the cmt should be the node that + // "produces" the value -- patterns aren't executable code // exactly, but I consider them to "execute" when they match a // value, and I consider them to produce the value that was // matched. So if you have something like: @@ -1202,9 +1198,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // ^~~~~~~~~~^ `@@y` pattern node @@int @int // ^~~~~~~~~~~~~^ `@y` pattern node @int int // - // You can see that the types of the id and the cmt are in - // sync in the first line, because that id is actually the id - // of an expression. But once we get to pattern ids, the types + // You can see that the types of the ID and the cmt are in + // sync in the first line, because that ID is actually the ID + // of an expression. But once we get to pattern IDs, the types // step out of sync again. So you'll see below that we always // get the type of the *subpattern* and use that. @@ -1305,7 +1301,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } PatKind::Struct(ref qpath, ref field_pats, _) => { - // {f1: p1, ..., fN: pN} + // `{f1: p1, ..., fN: pN}` let def = self.tables.qpath_def(qpath, pat.hir_id); let cmt = match def { Def::Err => { @@ -1333,7 +1329,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } PatKind::Tuple(ref subpats, ddpos) => { - // (p1, ..., pN) + // `(p1, ..., pN)` let expected_len = match self.pat_ty_unadjusted(&pat)?.sty { ty::Tuple(ref tys) => tys.len(), ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty), @@ -1348,7 +1344,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => { - // box p1, &p1, &mut p1. we can ignore the mutability of + // box p1, &p1, &mut p1. we can ignore the mutability of // PatKind::Ref since that information is already contained // in the type. let subcmt = Rc::new(self.cat_deref(pat, cmt, NoteNone)?); diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 99d0c5e88d638..7b634a24dd0a8 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -24,7 +24,7 @@ use crate::hir::intravisit::{Visitor, NestedVisitorMap}; use crate::hir::itemlikevisit::ItemLikeVisitor; use crate::hir::intravisit; -// Returns true if the given item must be inlined because it may be +// Returns whether the given item must be inlined because it may be // monomorphized or it was marked with `#[inline]`. This will only return // true for functions. fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -138,8 +138,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { } impl<'a, 'tcx> ReachableContext<'a, 'tcx> { - // Returns true if the given def ID represents a local item that is - // eligible for inlining and false otherwise. + // Returns whether the given `DefId` represents a local item that is + // eligible for inlining. fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool { let node_id = match self.tcx.hir().as_local_node_id(def_id) { Some(node_id) => node_id, @@ -326,7 +326,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // reachable if they are called from inlinable code. Generally, it's not known until // monomorphization if a specific trait impl item can be reachable or not. So, we // conservatively mark all of them as reachable. -// FIXME: One possible strategy for pruning the reachable set is to avoid marking impl +// FIXME: one possible strategy for pruning the reachable set is to avoid marking impl // items of non-exported traits (or maybe all local traits?) unless their respective // trait items are used from inlinable code through method call syntax or UFCS, or their // trait is a lang item. @@ -378,11 +378,11 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem) {} fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) { - // processed in visit_item above + // Processed in `visit_item` above. } } -// We introduce a new-type here, so we can have a specialized HashStable +// We introduce a `newtype` here, so we can have a specialized `HashStable` // implementation for it. #[derive(Clone)] pub struct ReachableSet(pub Lrc); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index fd188b33d7e1f..c4b9638b35c61 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -125,7 +125,7 @@ pub enum ScopeData { // (they outlive its body). Arguments, - // Scope of destructors for temporaries of node-id. + // Scope of destructors for temporaries of `NodeId`. Destruction, // Scope following a `let id = expr;` binding in a block. @@ -197,7 +197,7 @@ impl Scope { // forward to end of indexed statement. // // (This is the special case aluded to in the - // doc-comment for this method) + // doc-comment for this method.) let stmt_span = blk.stmts[first_statement_index.index()].span; @@ -844,7 +844,7 @@ fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: debug!("resolve_stmt(stmt.id={:?})", stmt_id); // Every statement will clean up the temporaries created during - // execution of that statement. Therefore each statement has an + // execution of that statement. Therefore, each statement has an // associated destruction scope that represents the scope of the // statement plus its destructors, and thus the scope for which // regions referenced by the destructors need to survive. @@ -922,7 +922,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: // The idea is that call.callee_id represents *the time when // the invoked function is actually running* and call.id // represents *the time to prepare the arguments and make the - // call*. See the section "Borrows in Calls" borrowck/README.md + // call*. See the section "Borrows in Calls" borrowck/README.md // for an extended explanation of why this distinction is // important. // @@ -1043,7 +1043,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, } } - // Make sure we visit the initializer first, so expr_and_pat_count remains correct + // Make sure we visit the initializer first, so `expr_and_pat_count` remains correct. if let Some(expr) = init { visitor.visit_expr(expr); } @@ -1286,7 +1286,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { // evaluation of `X` (if at all allowed by CTFE). // // However, `const Y: ... = g(&f());`, like `let y = g(&f());`, - // would *not* let the `f()` temporary escape into an outer scope + // would **not** let the `f()` temporary escape into an outer scope // (i.e., `'static`), which means that after `g` returns, it drops, // and all the associated destruction scope rules apply. self.cx.var_parent = None; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 5f7b9cc33660f..8593b173c113e 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -5,39 +5,39 @@ //! used between functions, and they operate in a purely top-down //! way. Therefore, we break lifetime name resolution into a separate pass. -use crate::hir::def::Def; -use crate::hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; -use crate::hir::map::Map; -use crate::hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName}; -use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; - -use crate::rustc::lint; -use crate::session::Session; -use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet}; -use errors::{Applicability, DiagnosticBuilder}; -use rustc_data_structures::sync::Lrc; use std::borrow::Cow; use std::cell::Cell; use std::mem::replace; + +use errors::{Applicability, DiagnosticBuilder}; +use rustc_data_structures::sync::Lrc; +use syntax_pos::Span; use syntax::ast; use syntax::attr; use syntax::ptr::P; use syntax::symbol::keywords; -use syntax_pos::Span; +use crate::hir::{self, GenericArg, GenericParam, GenericParamKind, ItemLocalId, LifetimeName, + LifetimeParamKind, Node, ParamName}; +use crate::hir::def::Def; +use crate::hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; -use crate::hir::{self, GenericParamKind, LifetimeParamKind}; +use crate::hir::map::Map; +use crate::rustc::lint; +use crate::session::Session; +use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; +use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet}; /// The origin of a named lifetime definition. /// /// This is used to prevent the usage of in-band lifetimes in `Fn`/`fn` syntax. #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)] pub enum LifetimeDefOrigin { - // Explicit binders like `fn foo<'a>(x: &'a u8)` or elided like `impl Foo<&u32>` + // Explicit binders like `fn foo<'a>(x: &'a u8)` or elided like `impl Foo<&u32>`. ExplicitOrElided, - // In-band declarations like `fn foo(x: &'a u8)` + // In-band declarations like `fn foo(x: &'a u8)`. InBand, - // Some kind of erroneous origin + // Some kind of erroneous origin. Error, } @@ -55,7 +55,7 @@ impl LifetimeDefOrigin { } } -// This counts the no of times a lifetime is used +// This counts the no of times a lifetime is used. #[derive(Clone, Copy, Debug)] pub enum LifetimeUseSet<'tcx> { One(&'tcx hir::Lifetime), @@ -66,17 +66,28 @@ pub enum LifetimeUseSet<'tcx> { pub enum Region { Static, EarlyBound( - /* index */ u32, - /* lifetime decl */ DefId, + // Index. + u32, + // Lifetime declaration. + DefId, LifetimeDefOrigin, ), LateBound( ty::DebruijnIndex, - /* lifetime decl */ DefId, + // Lifetime declaration. + DefId, LifetimeDefOrigin, ), - LateBoundAnon(ty::DebruijnIndex, /* anon index */ u32), - Free(DefId, /* lifetime decl */ DefId), + LateBoundAnon( + ty::DebruijnIndex, + // Anonymous index. + u32 + ), + Free( + DefId, + // Lifetime declaration. + DefId + ), } impl Region { @@ -185,20 +196,19 @@ impl Set1 { pub type ObjectLifetimeDefault = Set1; -/// Maps the id of each lifetime reference to the lifetime decl +/// Maps the ID of each lifetime reference to the lifetime declaration /// that it corresponds to. -/// -/// FIXME. This struct gets converted to a `ResolveLifetimes` for -/// actual use. It has the same data, but indexed by `DefIndex`. This -/// is silly. +// +// FIXME: this struct gets converted to a `ResolveLifetimes` for +// actual use. It has the same data, but indexed by `DefIndex`. This is silly. #[derive(Default)] struct NamedRegionMap { - // maps from every use of a named (not anonymous) lifetime to a - // `Region` describing how that region is bound + // Maps from every use of a named (not anonymous) lifetime to a + // `Region` describing how that region is bound. pub defs: NodeMap, - // the set of lifetime def ids that are late-bound; a region can - // be late-bound if (a) it does NOT appear in a where-clause and + // The set of lifetime `DefId`s that are late-bound; a region can + // be late-bound if (a) it does **not** appear in a where-clause and // (b) it DOES appear in the arguments. pub late_bound: NodeSet, @@ -263,7 +273,7 @@ enum Scope<'a> { Binder { lifetimes: FxHashMap, - /// if we extend this scope with another scope, what is the next index + /// If we extend this scope with another scope, what is the next index /// we should use for an early-bound region? next_early_index: u32, @@ -368,7 +378,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { ..*providers }; - // (*) FIXME the query should be defined to take a LocalDefId + // (*) FIXME: the query should be defined to take a `LocalDefId`. } /// Computes the `ResolveLifetimes` map that contains data for the @@ -488,7 +498,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { intravisit::walk_item(self, item); } hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => { - // No lifetime parameters, but implied 'static. + // No lifetime parameters, but implied `'static`. let scope = Scope::Elision { elide: Elide::Exact(Region::Static), s: ROOT_SCOPE, @@ -499,9 +509,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { impl_trait_fn: Some(_), .. }) => { - // currently existential type declarations are just generated from impl Trait - // items. doing anything on this node is irrelevant, as we currently don't need - // it. + // Currently existential type declarations are just generated from `impl Trait` + // items. doing anything on this node is irrelevant, as we currently don't need it. } hir::ItemKind::Ty(_, ref generics) | hir::ItemKind::Existential(hir::ExistTy { @@ -523,7 +532,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }; // These kinds of items have only early-bound lifetime parameters. let mut index = if sub_items_have_self_param(&item.node) { - 1 // Self comes before lifetimes + // Self comes before lifetimes. + 1 } else { 0 }; @@ -595,7 +605,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { abstract_type_parent: false, }; self.with(scope, |old_scope, this| { - // a bare fn has no bounds, so everything + // A bare fn has no bounds, so everything // contained within is scoped within its binder. this.check_lifetime_params(old_scope, &c.generic_params); intravisit::walk_ty(this, ty); @@ -610,7 +620,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { LifetimeName::Implicit => { // If the user does not write *anything*, we // use the object lifetime defaulting - // rules. So e.g., `Box` becomes + // rules. So, e.g., `Box` becomes // `Box`. self.resolve_object_lifetime_default(lifetime) } @@ -618,8 +628,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // If the user writes `'_`, we use the *ordinary* elision // rules. So the `'_` in e.g., `Box` will be // resolved the same as the `'_` in `&'_ Foo`. - // - // cc #48468 + // See issue #48468. self.resolve_elided_lifetimes(vec![lifetime]) } LifetimeName::Param(_) | LifetimeName::Static => { @@ -644,8 +653,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // ^ ^ this gets resolved in the scope of // the exist_ty generics let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node { - // named existential types are reached via TyKind::Path - // this arm is for `impl Trait` in the types of statics, constants and locals + // Named existential types are reached via `TyKind::Path`. + // This arm is for `impl Trait` in the types of statics, constants and locals. hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, .. @@ -653,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { intravisit::walk_ty(self, ty); return; } - // RPIT (return position impl trait) + // RPIT (return-position `impl Trait`). hir::ItemKind::Existential(hir::ExistTy { ref generics, ref bounds, @@ -678,7 +687,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { let def = self.map.defs.get(&lifetime.id).cloned(); if let Some(Region::LateBound(_, def_id, _)) = def { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { - // Ensure that the parent of the def is an item, not HRTB + // Ensure that the parent of the def is an item, not HRTB. let parent_id = self.tcx.hir().get_parent_node(node_id); let parent_impl_id = hir::ImplItemId { node_id: parent_id }; let parent_trait_id = hir::TraitItemId { node_id: parent_id }; @@ -1142,7 +1151,7 @@ fn signal_shadowing_problem( shadower: Shadower, ) { let mut err = if let (ShadowKind::Lifetime, ShadowKind::Lifetime) = (orig.kind, shadower.kind) { - // lifetime/lifetime shadowing is an error + // Lifetime / lifetime shadowing is an error. struct_span_err!( tcx.sess, shadower.span, @@ -1154,7 +1163,7 @@ fn signal_shadowing_problem( orig.kind.desc() ) } else { - // shadowing involving a label is only a warning, due to issues with + // Shadowing involving a label is only a warning, due to issues with // labels and lifetimes not being macro-hygienic. tcx.sess.struct_span_warn( shadower.span, @@ -1196,7 +1205,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn visit_expr(&mut self, ex: &hir::Expr) { if let Some(label) = expression_label(ex) { for prior_label in &self.labels_in_fn[..] { - // FIXME (#24278): non-hygienic comparison + // FIXME(#24278): non-hygienic comparison. if label.name == prior_label.name { signal_shadowing_problem( self.tcx, @@ -1244,7 +1253,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { Scope::Binder { ref lifetimes, s, .. } => { - // FIXME (#24278): non-hygienic comparison + // FIXME(#24278): non-hygienic comparison. if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) { let hir_id = tcx.hir().as_local_hir_id(def.id().unwrap()).unwrap(); @@ -1318,8 +1327,8 @@ fn compute_object_lifetime_defaults( map } -/// Scan the bounds and where-clauses on parameters to extract bounds -/// of the form `T:'a` so as to determine the `ObjectLifetimeDefault` +/// Scans the bounds and where-clauses on parameters to extract bounds +/// of the form `T: 'a` so as to determine the `ObjectLifetimeDefault` /// for each type parameter. fn object_lifetime_defaults_for_item( tcx: TyCtxt<'_, '_, '_>, @@ -1345,7 +1354,7 @@ fn object_lifetime_defaults_for_item( let param_def_id = tcx.hir().local_def_id(param.id); for predicate in &generics.where_clause.predicates { - // Look for `type: ...` where clauses. + // Look for `type: ...` where-clauses. let data = match *predicate { hir::WherePredicate::BoundPredicate(ref data) => data, _ => continue, @@ -1400,7 +1409,7 @@ fn object_lifetime_defaults_for_item( } impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { - // FIXME(#37666) this works around a limitation in the region inferencer + // FIXME(#37666): this works around a limitation in the region inferencer. fn hack(&mut self, f: F) where F: for<'b> FnOnce(&mut LifetimeContext<'b, 'tcx>), @@ -1439,8 +1448,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { self.xcrate_object_lifetime_defaults = this.xcrate_object_lifetime_defaults; } - /// helper method to determine the span to remove when suggesting the - /// deletion of a lifetime + /// Helper method to determine the span to remove when suggesting the + /// deletion of a lifetime. fn lifetime_deletion_span(&self, name: ast::Ident, generics: &hir::Generics) -> Option { generics.params.iter().enumerate().find_map(|(i, param)| { if param.name.ident() == name { @@ -1454,11 +1463,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { Some(param.span) } else { if generics.params.len() == 1 { - // if sole lifetime, remove the entire `<>` brackets + // If sole lifetime, remove the entire `<>` brackets. Some(generics.span) } else { - // if removing within `<>` brackets, we also want to - // delete a leading or trailing comma as appropriate + // If removing within `<>` brackets, we also want to + // delete a leading or trailing comma as appropriate. if i >= generics.params.len() - 1 { Some(generics.params[i - 1].span.shrink_to_hi().to(param.span)) } else { @@ -1472,11 +1481,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }) } - // helper method to issue suggestions from `fn rah<'a>(&'a T)` to `fn rah(&T)` + // Helper method to issue suggestions from `fn rah<'a>(&'a T)` to `fn rah(&T)`. fn suggest_eliding_single_use_lifetime( &self, err: &mut DiagnosticBuilder<'_>, def_id: DefId, lifetime: &hir::Lifetime ) { - // FIXME: future work: also suggest `impl Foo<'_>` for `impl<'a> Foo<'a>` + // FIXME: future work: also suggest `impl Foo<'_>` for `impl<'a> Foo<'a>`. let name = lifetime.name.ident(); let mut remove_decl = None; if let Some(parent_def_id) = self.tcx.parent(def_id) { @@ -1490,7 +1499,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { for input in inputs { if let hir::TyKind::Rptr(lt, _) = input.node { if lt.name.ident() == name { - // include the trailing whitespace between the ampersand and the type name + // Include the trailing whitespace between the ampersand and the type name. let lt_through_ty_span = lifetime.span.to(input.span.shrink_to_hi()); remove_use = Some( self.tcx.sess.source_map() @@ -1520,9 +1529,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } if let (Some(decl_span), Some(use_span)) = (remove_decl, remove_use) { - // if both declaration and use deletion spans start at the same + // If both declaration and use deletion spans start at the same // place ("start at" because the latter includes trailing - // whitespace), then this is an in-band lifetime + // whitespace), then this is an in-band lifetime. if decl_span.shrink_to_lo() == use_span.shrink_to_lo() { err.span_suggestion( use_span, @@ -1560,7 +1569,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }) .collect(); - // ensure that we issue lints in a repeatable order + // Ensure that we issue lints in a repeatable order. def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id)); for def_id in def_ids { @@ -1579,7 +1588,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { match lifetimeuseset { Some(LifetimeUseSet::One(lifetime)) => { let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap(); - debug!("node id first={:?}", node_id); + debug!("`NodeId` first={:?}", node_id); if let Some((id, span, name)) = match self.tcx.hir().get(node_id) { Node::Lifetime(hir_lifetime) => Some(( hir_lifetime.id, @@ -1605,7 +1614,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { ); if span == lifetime.span { - // spans are the same for in-band lifetime declarations + // Spans are the same for in-band lifetime declarations. err.span_label(span, "this lifetime is only used here"); } else { err.span_label(span, "this lifetime..."); @@ -1662,17 +1671,17 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { /// /// Handles visiting fns and methods. These are a bit complicated because we must distinguish /// early- vs late-bound lifetime parameters. We do this by checking which lifetimes appear - /// within type bounds; those are early bound lifetimes, and the rest are late bound. + /// within type bounds; those are early-bound lifetimes, and the rest are late-bound. /// /// For example: /// /// fn foo<'a,'b,'c,T:Trait<'b>>(...) /// - /// Here `'a` and `'c` are late bound but `'b` is early bound. Note that early- and late-bound + /// Here `'a` and `'c` are late-bound but `'b` is early-bound. Note that early- and late-bound /// lifetimes may be interspersed together. /// - /// If early bound lifetimes are present, we separate them into their own list (and likewise - /// for late bound). They will be numbered sequentially, starting from the lowest index that is + /// If early-bound lifetimes are present, we separate them into their own list (and likewise + /// for late-bound). They will be numbered sequentially, starting from the lowest index that is /// already in scope (for a fn item, that will be 0, but for a method it might not be). Late /// bound lifetimes are resolved by name and associated with a binder ID (`binder_id`), so the /// ordering is not important there. @@ -1692,7 +1701,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { if let Some(parent_id) = parent_id { let parent = self.tcx.hir().expect_item(parent_id); if sub_items_have_self_param(&parent.node) { - index += 1; // Self comes before lifetimes + // Self comes before lifetimes. + index += 1; } match parent.node { hir::ItemKind::Trait(_, _, ref generics, ..) @@ -1732,7 +1742,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }; self.with(scope, move |old_scope, this| { this.check_lifetime_params(old_scope, &generics.params); - this.hack(walk); // FIXME(#37666) workaround in place of `walk(this)` + // FIXME(#37666): workaround in place of `walk(this)`. + this.hack(walk); }); } @@ -1759,7 +1770,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - /// Returns the next index one would use for an early-bound-region + /// Returns the next index one would use for an early-bound region /// if extending the current scope. fn next_early_index(&self) -> u32 { self.next_early_index_helper(true) @@ -1846,7 +1857,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - // Check for fn-syntax conflicts with in-band lifetime definitions + // Check for fn-syntax conflicts with in-band lifetime definitions. if self.is_in_fn_syntax { match def { Region::EarlyBound(_, _, LifetimeDefOrigin::InBand) @@ -2097,8 +2108,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // Foreign functions, `fn(...) -> R` and `Trait(...) -> R` (both types and bounds). Node::ForeignItem(_) | Node::Ty(_) | Node::TraitRef(_) => None, - // Everything else (only closures?) doesn't - // actually enjoy elision in return types. + // Everything else (only closures?) doesn't actually enjoy elision in return types. _ => { self.visit_ty(output); return; @@ -2115,7 +2125,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // First (determined here), if `self` is by-reference, then the // implied output region is the region of the self parameter. if has_self { - // Look for `self: &'a Self` - also desugared from `&'a self`, + // Look for `self: &'a Self` -- also desugared from `&'a self`, // and if that matches, use it for elision and return early. let is_self_ty = |def: Def| { if let Def::SelfTy(..) = def { @@ -2177,7 +2187,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { lifetime_count += gather.lifetimes.len(); if lifetime_count == 1 && gather.lifetimes.len() == 1 { - // there's a chance that the unique lifetime of this + // There's a chance that the unique lifetime of this // iteration will be the appropriate lifetime for output // parameters, so lets store it. possible_implied_output_region = gather.lifetimes.iter().cloned().next(); @@ -2243,7 +2253,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { fn visit_generic_param(&mut self, param: &hir::GenericParam) { if let hir::GenericParamKind::Lifetime { .. } = param.kind { - // FIXME(eddyb) Do we want this? It only makes a difference + // FIXME(eddyb): do we want this? It only makes a difference // if this `for<'a>` lifetime parameter is never used. self.have_bound_regions = true; } @@ -2289,7 +2299,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut scope = self.scope; let error = loop { match *scope { - // Do not assign any resolution, it will be inferred. + // Do not assign any resolution; it will be inferred. Scope::Body { .. } => return, Scope::Root => break None, @@ -2548,7 +2558,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { self.resolve_lifetime_ref(lt); } hir::LifetimeName::Error => { - // No need to do anything, error already reported. + // No need to do anything; error already reported. } }, _ => bug!(), @@ -2563,7 +2573,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { param: &'tcx hir::GenericParam, ) { for label in &self.labels_in_fn { - // FIXME (#24278): non-hygienic comparison + // FIXME(#24278): non-hygienic comparison. if param.name.ident().name == label.name { signal_shadowing_problem( self.tcx, @@ -2628,16 +2638,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // A lifetime only used in a fn argument could as well // be replaced with `'_`, as that would generate a - // fresh name, too. + // fresh name too. Scope::Elision { elide: Elide::FreshLateAnon(_), .. } => break true, // In the return type or other such place, `'_` is not - // going to make a fresh name, so we cannot - // necessarily replace a single-use lifetime with - // `'_`. + // going to make a fresh name, so we cannot necessarily + // replace a single-use lifetime with `'_`. Scope::Elision { elide: Elide::Exact(_), .. @@ -2695,17 +2704,16 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - /// Sometimes we resolve a lifetime, but later find that it is an - /// error (esp. around impl trait). In that case, we remove the - /// entry into `map.defs` so as not to confuse later code. + /// Sometimes we resolve a lifetime, but later find that it is an error + /// (especially around `impl Trait`). In that case, we remove the entry + /// into `map.defs` so as not to confuse later code. fn uninsert_lifetime_on_error(&mut self, lifetime_ref: &'tcx hir::Lifetime, bad_def: Region) { let old_value = self.map.defs.remove(&lifetime_ref.id); assert_eq!(old_value, Some(bad_def)); } } -/// Detects late-bound lifetimes and inserts them into -/// `map.late_bound`. +/// Detects late-bound lifetimes and inserts them into `map.late_bound`. /// /// A region declared on a fn is **late-bound** if: /// - it is constrained by an argument type; @@ -2737,7 +2745,7 @@ fn insert_late_bound_lifetimes( constrained_by_input.regions ); - // Walk the lifetimes that appear in where clauses. + // Walk the lifetimes that appear in where-clauses. // // Subtle point: because we disallow nested bindings, we can just // ignore binders here and scrape up all names we see. @@ -2760,10 +2768,10 @@ fn insert_late_bound_lifetimes( appears_in_where_clause.regions ); - // Late bound regions are those that: - // - appear in the inputs - // - do not appear in the where-clauses - // - are not implicitly captured by `impl Trait` + // Late-bound regions are those that: + // - appear in the inputs, + // - do not appear in the where-clauses, + // - are not implicitly captured by `impl Trait`. for param in &generics.params { match param.kind { hir::GenericParamKind::Lifetime { .. } => { /* fall through */ } @@ -2773,12 +2781,12 @@ fn insert_late_bound_lifetimes( } let lt_name = hir::LifetimeName::Param(param.name.modern()); - // appears in the where clauses? early-bound. + // Appears in the where-clauses? Must be early-bound. if appears_in_where_clause.regions.contains(<_name) { continue; } - // does not appear in the inputs, but appears in the return type? early-bound. + // Does not appear in the inputs, but appears in the return type? Must be early-bound. if !constrained_by_input.regions.contains(<_name) && appears_in_output.regions.contains(<_name) { @@ -2786,7 +2794,7 @@ fn insert_late_bound_lifetimes( } debug!( - "insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound", + "insert_late_bound_lifetimes: lifetime {:?} with ID {:?} is late-bound", param.name.ident(), param.id ); diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 30a43c7a92595..237324c6e186d 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -205,7 +205,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { } } - // Propagate unstability. This can happen even for non-staged-api crates in case + // Propagate unstability. This can happen even for non-staged-api crates in case // -Zforce-unstable-if-unmarked is set. if let Some(stab) = self.parent_stab { if stab.level.is_unstable() { @@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } diag.emit(); if id == ast::DUMMY_NODE_ID { - span_bug!(span, "emitted a {} lint with dummy node id: {:?}", lint.name, def_id); + span_bug!(span, "emitted a {} lint with dummy `NodeId`: {:?}", lint.name, def_id); } }; diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index 1cc927b1f720f..c8a8d27fe586e 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -1,18 +1,16 @@ use rustc_data_structures::indexed_vec::IndexVec; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use rustc_data_structures::sync::{RwLock, MappedReadGuard, ReadGuard}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, - StableHasherResult}; +use rustc_serialize as serialize; + use crate::ich::StableHashingContext; use crate::mir::{Mir, BasicBlock}; -use crate::rustc_serialize as serialize; - #[derive(Clone, Debug)] pub struct Cache { predecessors: RwLock>>> } - impl serialize::Encodable for Cache { fn encode(&self, s: &mut S) -> Result<(), S::Error> { serialize::Encodable::encode(&(), s) @@ -29,7 +27,7 @@ impl<'a> HashStable> for Cache { fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) { - // do nothing + // Do nothing. } } @@ -41,7 +39,7 @@ impl Cache { } pub fn invalidate(&self) { - // FIXME: consider being more fine-grained + // FIXME: consider being more fine-grained. *self.predecessors.borrow_mut() = None; } diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index e96392edd64bf..39651939616db 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -135,7 +135,7 @@ impl<'tcx> ::serialize::UseSpecializedDecodable for &'tcx Allocation {} impl<'tcx, Tag, Extra> Allocation { /// Checks if the pointer is "in-bounds". Notice that a pointer pointing at the end /// of an allocation (i.e., at the first *inaccessible* location) *is* considered - /// in-bounds! This follows C's/LLVM's rules. + /// in-bounds! This follows C's/LLVM's rules. /// If you want to check bounds before doing a memory access, better use `check_bounds`. fn check_bounds_ptr( &self, @@ -174,7 +174,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { size: Size, check_defined_and_ptr: bool, ) -> EvalResult<'tcx, &[u8]> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { self.check_bounds(cx, ptr, size)?; @@ -183,7 +183,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { self.check_defined(ptr, size)?; self.check_relocations(cx, ptr, size)?; } else { - // We still don't want relocations on the *edges* + // We still don't want relocations on the *edges*. self.check_relocation_edges(cx, ptr, size)?; } @@ -202,7 +202,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, size: Size, ) -> EvalResult<'tcx, &[u8]> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { self.get_bytes_internal(cx, ptr, size, true) @@ -217,7 +217,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, size: Size, ) -> EvalResult<'tcx, &[u8]> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { self.get_bytes_internal(cx, ptr, size, false) @@ -231,7 +231,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, size: Size, ) -> EvalResult<'tcx, &mut [u8]> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`"); @@ -258,7 +258,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { cx: &impl HasDataLayout, ptr: Pointer, ) -> EvalResult<'tcx, &[u8]> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); @@ -285,7 +285,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { size: Size, allow_ptr_and_undef: bool, ) -> EvalResult<'tcx> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { // Check bounds and relocations on the edges @@ -307,7 +307,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, src: &[u8], ) -> EvalResult<'tcx> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64))?; @@ -323,7 +323,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { val: u8, count: Size ) -> EvalResult<'tcx> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { let bytes = self.get_bytes_mut(cx, ptr, count)?; @@ -347,7 +347,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, size: Size ) -> EvalResult<'tcx, ScalarMaybeUndef> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { // get_bytes_unchecked tests relocation edges @@ -384,7 +384,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { cx: &impl HasDataLayout, ptr: Pointer, ) -> EvalResult<'tcx, ScalarMaybeUndef> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { self.read_scalar(cx, ptr, cx.data_layout().pointer_size) @@ -405,7 +405,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { val: ScalarMaybeUndef, type_size: Size, ) -> EvalResult<'tcx> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { let val = match val { @@ -452,7 +452,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation { ptr: Pointer, val: ScalarMaybeUndef ) -> EvalResult<'tcx> - // FIXME: Working around https://github.com/rust-lang/rust/issues/56209 + // FIXME: working around issue #56209. where Extra: AllocationExtra { let ptr_size = cx.data_layout().pointer_size; @@ -580,7 +580,7 @@ impl<'tcx, Tag, Extra> Allocation { /// Relocations #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] -pub struct Relocations(SortedMap); +pub struct Relocations(SortedMap); impl Relocations { pub fn new() -> Self { diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 29beabdb2abdf..b8e807a9ef761 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -1,22 +1,19 @@ use std::{fmt, env}; -use crate::hir::map::definitions::DefPathData; -use crate::mir; -use crate::ty::{self, Ty, layout}; -use crate::ty::layout::{Size, Align, LayoutError}; -use rustc_target::spec::abi::Abi; - -use super::{RawConst, Pointer, InboundsCheck, ScalarMaybeUndef}; - use backtrace::Backtrace; - -use crate::ty::query::TyCtxtAt; use errors::DiagnosticBuilder; - +use rustc_target::spec::abi::Abi; use syntax_pos::{Pos, Span}; use syntax::ast; use syntax::symbol::Symbol; +use crate::hir::map::definitions::DefPathData; +use crate::mir; +use crate::ty::{self, Ty, layout}; +use crate::ty::layout::{Size, Align, LayoutError}; +use crate::ty::query::TyCtxtAt; +use super::{RawConst, Pointer, InboundsCheck, ScalarMaybeUndef}; + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum ErrorHandled { /// Already reported a lint or an error for this evaluation. @@ -48,7 +45,8 @@ pub struct ConstEvalErr<'tcx> { #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub struct FrameInfo<'tcx> { - pub call_site: Span, // this span is in the caller! + /// This span is in the caller. + pub call_site: Span, pub instance: ty::Instance<'tcx>, pub lint_root: Option, } @@ -145,7 +143,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { struct_error(tcx, message) }; err.span_label(self.span, self.error.to_string()); - // Skip the last, which is just the environment of the constant. The stacktrace + // Skip the last, which is just the environment of the constant. The stacktrace // is sometimes empty because we create "fake" eval contexts in CTFE to do work // on constant values. if self.stacktrace.len() > 0 { @@ -186,12 +184,12 @@ fn print_backtrace(backtrace: &mut Backtrace) { impl<'tcx> From> for EvalError<'tcx> { fn from(kind: EvalErrorKind<'tcx, u64>) -> Self { let backtrace = match env::var("RUST_CTFE_BACKTRACE") { - // matching RUST_BACKTRACE, we treat "0" the same as "not present". + // Matching `RUST_BACKTRACE` -- we treat "0" the same as "not present". Ok(ref val) if val != "0" => { let mut backtrace = Backtrace::new_unresolved(); if val == "immediate" { - // Print it now + // Print it now. print_backtrace(&mut backtrace); None } else { diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 0c43fe4a79faa..29d53656937b6 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -10,34 +10,32 @@ mod value; mod allocation; mod pointer; -pub use self::error::{ - EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstEvalErr, struct_error, - FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, -}; +use std::fmt; +use std::io; +use std::num::NonZeroU32; +use std::sync::atomic::{AtomicU32, Ordering}; -pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue}; +use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian, BigEndian}; +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::sync::{Lock as Mutex, HashMapExt}; +use rustc_data_structures::tiny_list::TinyList; +use rustc_serialize::{Encoder, Decodable, Encodable}; +use crate::mir; +use crate::hir::def_id::DefId; +use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind}; +use crate::ty::codec::TyDecoder; +use crate::ty::layout::{self, Size}; pub use self::allocation::{ InboundsCheck, Allocation, AllocationExtra, Relocations, UndefMask, }; - +pub use self::error::{ + EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstEvalErr, struct_error, + FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, +}; pub use self::pointer::{Pointer, PointerArithmetic}; - -use std::fmt; -use crate::mir; -use crate::hir::def_id::DefId; -use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind}; -use crate::ty::layout::{self, Size}; -use std::io; -use crate::rustc_serialize::{Encoder, Decodable, Encodable}; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::sync::{Lock as Mutex, HashMapExt}; -use rustc_data_structures::tiny_list::TinyList; -use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian, BigEndian}; -use crate::ty::codec::TyDecoder; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::num::NonZeroU32; +pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue}; /// Uniquely identifies a specific constant or static. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)] @@ -53,8 +51,8 @@ pub struct GlobalId<'tcx> { #[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)] pub struct AllocId(pub u64); -impl crate::rustc_serialize::UseSpecializedEncodable for AllocId {} -impl crate::rustc_serialize::UseSpecializedDecodable for AllocId {} +impl rustc_serialize::UseSpecializedEncodable for AllocId {} +impl rustc_serialize::UseSpecializedDecodable for AllocId {} #[derive(RustcDecodable, RustcEncodable)] enum AllocDiscriminant { @@ -236,7 +234,7 @@ impl<'s> AllocDecodingSession<'s> { }, AllocDiscriminant::Static => { assert!(alloc_id.is_none()); - trace!("creating extern static alloc id at"); + trace!("creating extern static alloc ID at"); let did = DefId::decode(decoder)?; let alloc_id = decoder.tcx().alloc_map.lock().intern_static(did); Ok(alloc_id) @@ -312,7 +310,7 @@ impl<'tcx> AllocMap<'tcx> { return alloc_id; } let id = self.reserve(); - debug!("creating alloc_kind {:?} with id {}", alloc_kind, id); + debug!("creating alloc_kind {:?} with ID {}", alloc_kind, id); self.id_to_kind.insert(id, alloc_kind.clone()); self.type_interner.insert(alloc_kind, id); id @@ -325,7 +323,7 @@ impl<'tcx> AllocMap<'tcx> { // We thus generate a new `AllocId` for every mention of a function. This means that // `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true. // However, formatting code relies on function identity (see #58320), so we only do - // this for generic functions. Lifetime parameters are ignored. + // this for generic functions. Lifetime parameters are ignored. let is_generic = instance.substs.into_iter().any(|kind| { match kind.unpack() { UnpackedKind::Lifetime(_) => false, @@ -356,7 +354,7 @@ impl<'tcx> AllocMap<'tcx> { pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation { match self.get(id) { Some(AllocKind::Memory(mem)) => mem, - _ => bug!("expected allocation id {} to point to memory", id), + _ => bug!("expected allocation ID {} to point to memory", id), } } @@ -381,7 +379,7 @@ impl<'tcx> AllocMap<'tcx> { /// call this function twice, even with the same `Allocation` will ICE the compiler. pub fn set_alloc_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) { if let Some(old) = self.id_to_kind.insert(id, AllocKind::Memory(mem)) { - bug!("tried to set allocation id {}, but it was already existing as {:#?}", id, old); + bug!("tried to set allocation ID {}, but it was already existing as {:#?}", id, old); } } diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index 551e7b2fd41ec..a0d7a9ca31500 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -70,7 +70,7 @@ impl PointerArithmetic for T {} /// Pointer is also generic over the `Tag` associated with each pointer, /// which is used to do provenance tracking during execution. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub struct Pointer { +pub struct Pointer { pub alloc_id: Id, pub offset: Size, pub tag: Tag, diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 5ec7de4308a13..a6f43f07e153c 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -73,7 +73,7 @@ impl<'tcx> ConstValue<'tcx> { /// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes /// of a simple value or a pointer into another `Allocation` #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub enum Scalar { +pub enum Scalar { /// The raw bytes of a simple value. Bits { /// The first `size` bytes are the value. @@ -394,7 +394,7 @@ impl From> for Scalar { } #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub enum ScalarMaybeUndef { +pub enum ScalarMaybeUndef { Scalar(Scalar), Undef, } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 3513d652b5346..22b1b67a49abd 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2,11 +2,20 @@ //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/index.html -use crate::hir::def::CtorKind; -use crate::hir::def_id::DefId; -use crate::hir::{self, HirId, InlineAsm}; -use crate::mir::interpret::{ConstValue, EvalErrorKind, Scalar}; -use crate::mir::visit::MirVisitable; +mod cache; +pub mod interpret; +pub mod mono; +pub mod tcx; +pub mod traversal; +pub mod visit; + +use std::borrow::Cow; +use std::fmt::{self, Debug, Formatter, Write}; +use std::ops::{Index, IndexMut}; +use std::slice; +use std::vec::IntoIter; +use std::{iter, mem, option, u32}; + use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::fx::FxHashSet; @@ -15,17 +24,18 @@ use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::MappedReadGuard; -use crate::rustc_serialize::{self as serialize}; +use rustc_serialize::{self as serialize}; use smallvec::SmallVec; -use std::borrow::Cow; -use std::fmt::{self, Debug, Formatter, Write}; -use std::ops::{Index, IndexMut}; -use std::slice; -use std::vec::IntoIter; -use std::{iter, mem, option, u32}; +use syntax_pos::{Span, DUMMY_SP}; use syntax::ast::{self, Name}; use syntax::symbol::InternedString; -use syntax_pos::{Span, DUMMY_SP}; + +use crate::hir::def::CtorKind; +use crate::hir::def_id::DefId; +use crate::hir::{self, HirId, InlineAsm}; +use crate::mir::interpret::{ConstValue, EvalErrorKind, Scalar}; +pub use crate::mir::interpret::AssertMessage; +use crate::mir::visit::MirVisitable; use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use crate::ty::subst::{Subst, Substs}; use crate::ty::layout::VariantIdx; @@ -35,15 +45,6 @@ use crate::ty::{ }; use crate::util::ppaux; -pub use crate::mir::interpret::AssertMessage; - -mod cache; -pub mod interpret; -pub mod mono; -pub mod tcx; -pub mod traversal; -pub mod visit; - /// Types for locals type LocalDecls<'tcx> = IndexVec>; @@ -970,7 +971,7 @@ impl<'tcx> LocalDecl<'tcx> { visibility_scope: OUTERMOST_SOURCE_SCOPE, internal: false, is_block_tail: None, - name: None, // FIXME maybe we do want some name here? + name: None, // FIXME: maybe we do want some name here? is_user_variable: None, } } @@ -1516,7 +1517,7 @@ impl<'tcx> BasicBlockData<'tcx> { } // Splice in the new statements, from the end of the block. - // FIXME(eddyb) This could be more efficient with a "gap buffer" + // FIXME(eddyb): this could be more efficient with a "gap buffer" // where a range of elements ("gap") is left uninitialized, with // splicing adding new elements to the end of that gap and moving // existing elements from before the gap to the end of the gap. @@ -2514,11 +2515,11 @@ impl<'tcx> UserTypeProjections<'tcx> { UserTypeProjections { contents: projs.collect() } } - pub fn projections_and_spans(&self) -> impl Iterator, Span)> { + pub fn projections_and_spans(&self) -> impl Iterator, Span)> { self.contents.iter() } - pub fn projections(&self) -> impl Iterator> { + pub fn projections(&self) -> impl Iterator> { self.contents.iter().map(|&(ref user_type, _span)| user_type) } diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 2296fe5763c94..1fac93706bd74 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -268,7 +268,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> { components: I, special_suffix: Option) -> InternedString - where I: IntoIterator, + where I: IntoIterator, C: fmt::Display, S: fmt::Display, { @@ -291,7 +291,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> { components: I, special_suffix: Option) -> InternedString - where I: IntoIterator, + where I: IntoIterator, C: fmt::Display, S: fmt::Display, { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 65da458efbfff..d1e93576c7bd9 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -249,7 +249,7 @@ impl OutputTypes { self.0.len() } - // True if any of the output types require codegen or linking. + // Returns `true` if any of the output types require codegen or linking. pub fn should_codegen(&self) -> bool { self.0.keys().any(|k| match *k { OutputType::Bitcode @@ -570,7 +570,7 @@ impl OutputFilenames { pub fn host_triple() -> &'static str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've - // actually built. We can't just take LLVM's host triple because they + // actually built. We can't just take LLVM's host triple because they // normalize all ix86 architectures to i386. // // Instead of grabbing the host triple (for the current host), we grab (at @@ -1558,7 +1558,7 @@ impl RustcOptGroup { // The `opt` local module holds wrappers around the `getopts` API that // adds extra rustc-specific metadata to each option; such metadata -// is exposed by . The public +// is exposed by . The public // functions below ending with `_u` are the functions that return // *unstable* options, i.e., options that are only enabled when the // user also passes the `-Z unstable-options` debugging flag. diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs index 77f190e281229..eb66f59d0dc48 100644 --- a/src/librustc/session/filesearch.rs +++ b/src/librustc/session/filesearch.rs @@ -115,7 +115,7 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { } pub fn get_or_default_sysroot() -> PathBuf { - // Follow symlinks. If the resolved path is relative, make it absolute. + // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: Option) -> Option { path.and_then(|path| { match fs::canonicalize(&path) { @@ -141,7 +141,7 @@ pub fn get_or_default_sysroot() -> PathBuf { // The name of the directory rustc expects libraries to be located. fn find_libdir(sysroot: &Path) -> Cow<'static, str> { - // FIXME: This is a quick hack to make the rustc binary able to locate + // FIXME: this is a quick hack to make the rustc binary able to locate // Rust libraries in Linux environments where libraries might be installed // to lib64/lib32. This would be more foolproof by basing the sysroot off // of the directory where librustc is located, rather than where the rustc diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 833785f04076c..14fbbbe56c457 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -75,20 +75,20 @@ pub struct Session { /// if the value stored here has been affected by path remapping. pub working_dir: (PathBuf, bool), - // FIXME: lint_store and buffered_lints are not thread-safe, - // but are only used in a single thread + // FIXME: `lint_store` and buffered_lints are not thread-safe, + // but are only used in a single thread. pub lint_store: RwLock, pub buffered_lints: Lock>, - /// Set of (DiagnosticId, Option, message) tuples tracking + /// Set of `(DiagnosticId, Option, message)` tuples tracking /// (sub)diagnostics that have been set once, but should not be set again, - /// in order to avoid redundantly verbose output (Issue #24690, #44953). + /// in order to avoid redundantly verbose output (issues #24690, #44953). pub one_time_diagnostics: Lock, String)>>, pub plugin_llvm_passes: OneThread>>, pub plugin_attributes: Lock>, pub crate_types: Once>, pub dependency_formats: Once, - /// The crate_disambiguator is constructed out of all the `-C metadata` + /// The `crate_disambiguator` is constructed out of all the `-C metadata` /// arguments passed to the compiler. Its value together with the crate-name /// forms a unique global identifier for the crate. It is used to allow /// multiple crates with the same name to coexist. See the @@ -179,21 +179,21 @@ pub struct PerfStats { pub normalize_projection_ty: AtomicUsize, } -/// Enum to support dispatch of one-time diagnostics (in Session.diag_once) +/// Enum to support dispatch of one-time diagnostics (in `Session.diag_once`). enum DiagnosticBuilderMethod { Note, SpanNote, - SpanSuggestion(String), // suggestion - // add more variants as needed to support one-time diagnostics + SpanSuggestion(String), + // Add more variants as needed to support one-time diagnostics. } /// Diagnostic message ID—used by `Session.one_time_diagnostics` to avoid /// emitting the same message more than once #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum DiagnosticMessageId { - ErrorId(u16), // EXXXX error code as integer + ErrorId(u16 /* EXXXX error code */), LintId(lint::LintId), - StabilityId(u32), // issue number + StabilityId(u32 /* issue number */), } impl From<&'static lint::Lint> for DiagnosticMessageId { @@ -240,7 +240,7 @@ impl Session { ) -> DiagnosticBuilder<'a> { self.diagnostic().struct_span_err_with_code(sp, msg, code) } - // FIXME: This method should be removed (every error should have an associated error code). + // FIXME: this method should be removed (every error should have an associated error code). pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> { self.diagnostic().struct_err(msg) } @@ -395,7 +395,7 @@ impl Session { Some(next) => { self.next_node_id.set(ast::NodeId::from_usize(next)); } - None => bug!("Input too large, ran out of node ids!"), + None => bug!("input too large, ran out of `NodeId`s!"), } id @@ -709,7 +709,7 @@ impl Session { &self.sysroot, self.opts.target_triple.triple(), &self.opts.search_paths, - // target_tlib_path==None means it's the same as host_tlib_path. + // `target_tlib_path == None` means it's the same as `host_tlib_path`. self.target_tlib_path.as_ref().unwrap_or(&self.host_tlib_path), kind, ) @@ -774,7 +774,7 @@ impl Session { ) } - // Note: This will also drop the lock file, thus unlocking the directory + // Note: this will also drop the lock file, thus unlocking the directory. *incr_comp_session = IncrCompSession::Finalized { session_directory: new_directory_path, }; @@ -1034,7 +1034,7 @@ pub fn build_session_with_source_map( source_map: Lrc, emitter_dest: Option>, ) -> Session { - // FIXME: This is not general enough to make the warning lint completely override + // FIXME: this is not general enough to make the warning lint completely override // normal diagnostic warnings, since the warning lint can also be denied and changed // later via the source code. let warnings_allow = sopts @@ -1250,7 +1250,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { // dynamically downstream, rustc generates `__imp_` symbols that help the // MSVC linker deal with this lack of knowledge (#27438). Unfortunately, // these manually generated symbols confuse LLD when it tries to merge - // bitcode during ThinLTO. Therefore we disallow dynamic linking on MSVC + // bitcode during ThinLTO. Therefore, we disallow dynamic linking on MSVC // when compiling for LLD ThinLTO. This way we can validly just not generate // the `dllimport` attributes and `__imp_` symbols in that case. if sess.opts.cg.linker_plugin_lto.enabled() && diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 8957bbaa4ad7d..e38904f057f15 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -1,8 +1,6 @@ //! Support code for rustdoc and external tools . You really don't //! want to be using this unless you need to. -use super::*; - use std::collections::hash_map::Entry; use std::collections::VecDeque; @@ -13,6 +11,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use crate::ty::fold::TypeFolder; use crate::ty::{Region, RegionVid}; +use super::*; + // FIXME(twk): this is obviously not nice to duplicate like that #[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)] pub enum RegionTarget<'tcx> { @@ -115,7 +115,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } }); - // If an explicit impl exists, it always takes priority over an auto impl + // If an explicit impl exists, it always takes priority over an auto impl. if bail_out { return AutoTraitResult::ExplicitImpl; } @@ -609,7 +609,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { finished_map.insert(v1, r1); } (&RegionTarget::Region(_), &RegionTarget::RegionVid(_)) => { - // Do nothing - we don't care about regions that are smaller than vids + // Do nothing; we don't care about regions that are smaller than vids. } (&RegionTarget::RegionVid(_), &RegionTarget::RegionVid(_)) => { if let Entry::Occupied(v) = vid_map.entry(*smaller) { @@ -686,7 +686,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // // Displaying a bound involving a concrete type (instead of a generic // parameter) would be pointless, since it's always true - // (e.g. u8: Copy) + // (e.g., u8: Copy) // Displaying an inference variable is impossible, since they're // an internal compiler detail without a defined visual representation // diff --git a/src/librustc/traits/chalk_fulfill.rs b/src/librustc/traits/chalk_fulfill.rs index d9eb6d8157dfb..4e11837f35792 100644 --- a/src/librustc/traits/chalk_fulfill.rs +++ b/src/librustc/traits/chalk_fulfill.rs @@ -40,7 +40,7 @@ fn in_environment( None if obligation.param_env.caller_bounds.is_empty() => Environment { clauses: ty::List::empty(), }, - _ => bug!("non-empty `ParamEnv` with no def-id"), + _ => bug!("non-empty `ParamEnv` with no `DefId`"), }; InEnvironment { diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index d6b7b3b99cacd..f06fb6a7d3080 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -1,5 +1,5 @@ // This file contains various trait resolution methods used by codegen. -// They all assume regions can be erased and monomorphic types. It +// They all assume regions can be erased and monomorphic types. It // seems likely that they should eventually be merged into more // general routines. @@ -45,8 +45,8 @@ pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>, Ok(Some(selection)) => selection, Ok(None) => { // Ambiguity can happen when monomorphizing during trans - // expands to some humongo type that never occurred - // statically -- this humongo type can then overflow, + // expands to some huge type that never occurred + // statically -- this huge type can then overflow, // leading to an ambiguous result. So report this as an // overflow bug, since I believe this is the only case // where ambiguity can result. diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 35d8e2beef557..0072e5807dc97 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -4,9 +4,10 @@ //! [trait-resolution]: https://rust-lang.github.io/rustc-guide/traits/resolution.html //! [trait-specialization]: https://rust-lang.github.io/rustc-guide/traits/specialization.html -use crate::infer::CombinedSnapshot; -use crate::hir::def_id::{DefId, LOCAL_CRATE}; use syntax_pos::DUMMY_SP; + +use crate::infer::{CombinedSnapshot, InferOk}; +use crate::hir::def_id::{DefId, LOCAL_CRATE}; use crate::traits::{self, Normalized, SelectionContext, Obligation, ObligationCause}; use crate::traits::IntercrateMode; use crate::traits::select::IntercrateAmbiguityCause; @@ -14,10 +15,7 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::fold::TypeFoldable; use crate::ty::subst::Subst; -use crate::infer::{InferOk}; - -/// Whether we do the orphan check relative to this crate or -/// to some remote crate. +/// Represents whether to do the orphan check relative to this crate or to some remote crate. #[derive(Copy, Clone, Debug)] enum InCrate { Local, @@ -34,8 +32,7 @@ pub struct OverlapResult<'tcx> { pub impl_header: ty::ImplHeader<'tcx>, pub intercrate_ambiguity_causes: Vec, - /// `true` if the overlap might've been permitted before the shift - /// to universes. + /// `true` if the overlap might have been permitted before the shift to the universes model. pub involves_placeholder: bool, } @@ -368,16 +365,15 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, } if tcx.features().re_rebalance_coherence { - // Given impl Trait for T0, an impl is valid only + // Given `impl Trait for T0`, an impl is valid only // if at least one of the following is true: // - // - Trait is a local trait + // - Trait is a local trait. // (already checked in orphan_check prior to calling this function) - // - All of - // - At least one of the types T0..=Tn must be a local type. - // Let Ti be the first such type. - // - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti) - // + // - All of: + // - At least one of the types `T0..=Tn` must be a local type. + // Let `Ti` be the first such type. + // - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti` (excluding `Ti`). for input_ty in trait_ref.input_types() { debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty); if ty_is_local(tcx, input_ty, in_crate) { @@ -394,7 +390,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, } else { // First, create an ordered iterator over all the type // parameters to the trait, with the self type appearing - // first. Find the first input type that either references a + // first. Find the first input type that either references a // type parameter OR some local type. for input_ty in trait_ref.input_types() { if ty_is_local(tcx, input_ty, in_crate) { @@ -412,7 +408,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, } } - // OK, found local type, all prior types upheld invariant. + // Ok, found local type; all prior types upheld invariant. return Ok(()); } @@ -466,8 +462,7 @@ fn fundamental_ty(ty: Ty<'_>) -> bool { fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool { match in_crate { - // The type is local to *this* crate - it will not be - // local in any other crate. + // The type is local to *this* crate -- it will not be local in any other crate. InCrate::Remote => false, InCrate::Local => def_id.is_local() } @@ -521,7 +516,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool { ty::Generator(..) | ty::GeneratorWitness(..) | ty::Opaque(..) => { - bug!("ty_is_local invoked on unexpected type: {:?}", ty) + bug!("`ty_is_local` invoked on unexpected type: {:?}", ty) } } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index eb284645d36c8..f53429a94b3e8 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -142,8 +142,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let ty::Predicate::Trait(implication) = implication { let error = error.to_poly_trait_ref(); let implication = implication.to_poly_trait_ref(); - // FIXME: I'm just not taking associated types at all here. - // Eventually I'll need to implement param-env-aware + // FIXME: we're not dealing with associated types at all here. + // Eventually we'll need to implement `ParamEnv`-aware // `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic. let param_env = ty::ParamEnv::empty(); if self.can_sub(param_env, error, implication).is_ok() { @@ -359,9 +359,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code { // FIXME: maybe also have some way of handling methods // from other traits? That would require name resolution, - // which we might want to be some sort of hygienic. + // which we might want to be hygienic in some way. // - // Currently I'm leaving it for what I need for `try`. + // For now, this is sufficient for the purposes of `try`. if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) { let method = self.tcx.item_name(item); flags.push(("from_method".to_owned(), None)); @@ -1274,7 +1274,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>, body_id: Option) { - // Unable to successfully determine, probably means + // Unable to successfully determine; probably means // insufficient type information, but could mean // ambiguous impls. The latter *ought* to be a // coherence violation, so we don't report it here. @@ -1303,7 +1303,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // there are unresolved type inference variables // (otherwise it would suggest a coherence // failure). But given #21974 that is not necessarily - // the case -- we can have multiple where clauses that + // the case -- we can have multiple where-clauses that // are only distinguished by a region, which results // in an ambiguity even when all types are fully // known, since we don't dispatch based on region @@ -1312,16 +1312,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // This is kind of a hack: it frequently happens that some earlier // error prevents types from being fully inferred, and then we get // a bunch of uninteresting errors saying something like " doesn't implement Sized". It may even be true that we + // #0> doesn't implement Sized". It may even be true that we // could just skip over all checks where the self-ty is an // inference variable, but I was afraid that there might be an // inference variable created, registered as an obligation, and // then never forced by writeback, and hence by skipping here we'd - // be ignoring the fact that we don't KNOW the type works + // be ignoring the fact that we don't _know_ the type works // out. Though even that would probably be harmless, given that // we're only talking about builtin traits, which are known to be // inhabited. But in any case I just threw in this check for - // has_errors() to be sure that compilation isn't happening + // `has_errors()` to be sure that compilation isn't happening // anyway. In that case, why inundate the user. if !self.tcx.sess.has_errors() { if @@ -1351,10 +1351,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::Predicate::Subtype(ref data) => { if data.references_error() || self.tcx.sess.has_errors() { - // no need to overload user in such cases + // No need to overload user in such `cases.need_type_info_err`. } else { let &SubtypePredicate { a_is_expected: _, a, b } = data.skip_binder(); - // both must be type variables, or the other would've been instantiated + // Both must be type variables, else the other would've been instantiated. assert!(a.is_ty_var() && b.is_ty_var()); self.need_type_info_err(body_id, obligation.cause.span, @@ -1497,33 +1497,33 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { repeated element will be copied"); } ObligationCauseCode::VariableType(_) => { - err.note("all local variables must have a statically known size"); + err.note("all local variables must have a statically-known size"); if !self.tcx.features().unsized_locals { err.help("unsized locals are gated as an unstable feature"); } } ObligationCauseCode::SizedArgumentType => { - err.note("all function arguments must have a statically known size"); + err.note("all function arguments must have a statically-known size"); if !self.tcx.features().unsized_locals { err.help("unsized locals are gated as an unstable feature"); } } ObligationCauseCode::SizedReturnType => { err.note("the return type of a function must have a \ - statically known size"); + statically-known size"); } ObligationCauseCode::SizedYieldType => { err.note("the yield type of a generator must have a \ - statically known size"); + statically-known size"); } ObligationCauseCode::AssignmentLhsSized => { - err.note("the left-hand-side of an assignment must have a statically known size"); + err.note("the left-hand-side of an assignment must have a statically-known size"); } ObligationCauseCode::TupleInitializerSized => { - err.note("tuples must have a statically known size to be initialized"); + err.note("tuples must have a statically-known size to be initialized"); } ObligationCauseCode::StructInitializerSized => { - err.note("structs must have a statically known size to be initialized"); + err.note("structs must have a statically-known size to be initialized"); } ObligationCauseCode::FieldSized { adt_kind: ref item, last } => { match *item { @@ -1545,7 +1545,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } ObligationCauseCode::ConstSized => { - err.note("constant expressions must have a statically known size"); + err.note("constant expressions must have a statically-known size"); } ObligationCauseCode::SharedStatic => { err.note("shared static variables must have a type that implements `Sync`"); diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 587f57bb09dee..838567e0f8d52 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -155,7 +155,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { debug_assert!(!projection_ty.has_escaping_bound_vars()); - // FIXME(#20304) -- cache + // FIXME(#20304): cache. let mut selcx = SelectionContext::new(infcx); let mut obligations = vec![]; @@ -176,7 +176,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { infcx: &InferCtxt<'a, 'gcx, 'tcx>, obligation: PredicateObligation<'tcx>) { - // this helps to reduce duplicate errors, as well as making + // This helps to reduce duplicate errors, as well as making // debug output much nicer to read and so on. let obligation = infcx.resolve_type_vars_if_possible(&obligation); @@ -311,7 +311,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, // of its type, and those types are resolved at // the same time. // - // FIXME(#32286) logic seems false if no upvars + // FIXME(#32286): logic seems wrong in case of no upvars. pending_obligation.stalled_on = trait_ref_type_vars(self.selcx, data.to_poly_trait_ref()); @@ -498,7 +498,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, fn process_backedge<'c, I>(&mut self, cycle: I, _marker: PhantomData<&'c PendingPredicateObligation<'tcx>>) - where I: Clone + Iterator>, + where I: Clone + Iterator>, { if self.selcx.coinductive_match(cycle.clone().map(|s| s.obligation.predicate)) { debug!("process_child_obligations: coinductive match"); diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 99d1e32d52398..5684ee005dfad 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -19,30 +19,29 @@ pub mod codegen; mod util; pub mod query; +use std::fmt::Debug; +use std::rc::Rc; + use chalk_engine; +use rustc_data_structures::sync::Lrc; +use syntax_pos::{Span, DUMMY_SP}; +use syntax::ast; + use crate::hir; use crate::hir::def_id::DefId; use crate::infer::{InferCtxt, SuppressRegionErrors}; use crate::infer::outlives::env::OutlivesEnvironment; use crate::middle::region; use crate::mir::interpret::ErrorHandled; -use rustc_data_structures::sync::Lrc; -use syntax::ast; -use syntax_pos::{Span, DUMMY_SP}; use crate::ty::subst::Substs; use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; use crate::ty::error::{ExpectedFound, TypeError}; use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; use crate::util::common::ErrorReported; - -use std::fmt::Debug; -use std::rc::Rc; - pub use self::SelectionError::*; pub use self::FulfillmentErrorCode::*; pub use self::Vtable::*; pub use self::ObligationCauseCode::*; - pub use self::coherence::{add_placeholder_note, orphan_check, overlapping_impls}; pub use self::coherence::{OrphanCheckErr, OverlapResult}; pub use self::fulfill::{FulfillmentContext, PendingPredicateObligation}; @@ -178,49 +177,52 @@ pub enum ObligationCauseCode<'tcx> { /// Obligation incurred due to an object cast. ObjectCastObligation(/* Object type */ Ty<'tcx>), - // Various cases where expressions must be sized/copy/etc: - /// L = X implies that L is Sized + // Various cases where expressions must be `Sized`/`Copy`/etc. + + /// `L = X` implies that `L` is `Sized`. AssignmentLhsSized, - /// (x1, .., xn) must be Sized + /// `(x1, .., xn)` must be `Sized`. TupleInitializerSized, - /// S { ... } must be Sized + /// `S { ... }` must be `Sized`. StructInitializerSized, - /// Type of each variable must be Sized + /// Type of each variable must be `Sized`. VariableType(ast::NodeId), - /// Argument type must be Sized + /// Argument type must be `Sized`. SizedArgumentType, - /// Return type must be Sized + /// Returns type must be `Sized`. SizedReturnType, - /// Yield type must be Sized + /// Yield type must be `Sized`. SizedYieldType, - /// [T,..n] --> T must be Copy + /// `[T,..n] --> T` must be `Copy`. RepeatVec, - /// Types of fields (other than the last, except for packed structs) in a struct must be sized. + /// Types of fields (other than the last, except for packed structs) in a struct must be + /// `Sized`. FieldSized { adt_kind: AdtKind, last: bool }, - /// Constant expressions must be sized. + /// Constant expressions must be `Sized`. ConstSized, - /// static items must have `Sync` type + /// Static items must be `Sync`. SharedStatic, BuiltinDerivedObligation(DerivedObligationCause<'tcx>), ImplDerivedObligation(DerivedObligationCause<'tcx>), - /// error derived when matching traits/impls; see ObligationCause for more details + /// Error derived when matching traits/impls; see `ObligationCause` for more details. CompareImplMethodObligation { item_name: ast::Name, impl_item_def_id: DefId, trait_item_def_id: DefId, }, - /// Checking that this expression can be assigned where it needs to be - // FIXME(eddyb) #11161 is the original Expr required? + /// Checking that this expression can be assigned where it needs to be. + // + // FIXME(eddyb): #11161 is the original `Expr` required? ExprAssignable, - /// Computing common supertype in the arms of a match expression + /// Computing common supertype in the arms of a match expression. MatchExpressionArm { arm_span: Span, source: hir::MatchSource, @@ -228,41 +230,41 @@ pub enum ObligationCauseCode<'tcx> { last_ty: Ty<'tcx>, }, - /// Computing common supertype in the pattern guard for the arms of a match expression + /// Computing common supertype in the pattern guard for the arms of a match expression. MatchExpressionArmPattern { span: Span, ty: Ty<'tcx> }, - /// Computing common supertype in an if expression + /// Computing common supertype in an if expression. IfExpression { then: Span, outer: Option, semicolon: Option, }, - /// Computing common supertype of an if expression with no else counter-part + /// Computing common supertype of an if expression with no else counter-part. IfExpressionWithNoElse, - /// `main` has wrong type + /// `main` has wrong type. MainFunctionType, - /// `start` has wrong type + /// `start` has wrong type. StartFunctionType, - /// intrinsic has wrong type + /// Intrinsic has wrong type. IntrinsicType, - /// method receiver + /// Method receiver. MethodReceiver, - /// `return` with no expression + /// `return` with no expression. ReturnNoExpression, - /// `return` with an expression + /// `return` with an expression. ReturnType(ast::NodeId), - /// Block implicit return + /// Block implicit return. BlockTailExpression(ast::NodeId), - /// #[feature(trivial_bounds)] is not enabled + /// `#[feature(trivial_bounds)]` is not enabled. TrivialBound, } @@ -463,18 +465,19 @@ pub struct FulfillmentError<'tcx> { pub enum FulfillmentErrorCode<'tcx> { CodeSelectionError(SelectionError<'tcx>), CodeProjectionError(MismatchedProjectionTypes<'tcx>), + // Always comes from a `SubtypePredicate`. CodeSubtypeError(ExpectedFound>, - TypeError<'tcx>), // always comes from a SubtypePredicate + TypeError<'tcx>), CodeAmbiguity, } /// When performing resolution, it is typically the case that there /// can be one of three outcomes: /// -/// - `Ok(Some(r))`: success occurred with result `r` +/// - `Ok(Some(r))`: success occurred with result `r`. /// - `Ok(None)`: could not definitely determine anything, usually due /// to inconclusive type inference. -/// - `Err(e)`: error `e` occurred +/// - `Err(e)`: error `e` occurred. pub type SelectionResult<'tcx, T> = Result, SelectionError<'tcx>>; /// Given the successful resolution of an obligation, the `Vtable` @@ -672,14 +675,13 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>( // this function's result remains infallible, we must confirm // that guess. While imperfect, I believe this is sound. - // The handling of regions in this area of the code is terrible, + // The handling of regions in this area of the code is terrible; // see issue #29149. We should be able to improve on this with // NLL. let mut fulfill_cx = FulfillmentContext::new_ignoring_regions(); - // We can use a dummy node-id here because we won't pay any mind - // to region obligations that arise (there shouldn't really be any - // anyhow). + // We can use a dummy `NodeId` here because we won't pay any mind + // to region obligations that arise (there shouldn't really be any anyhow). let cause = ObligationCause::misc(span, hir::DUMMY_HIR_ID); fulfill_cx.register_bound(infcx, param_env, ty, def_id, cause); @@ -722,17 +724,17 @@ fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ); let span = cause.span; tcx.infer_ctxt().enter(|infcx| { - // FIXME. We should really... do something with these region - // obligations. But this call just continues the older + // FIXME(nmatsakis): we should really do something with these + // region obligations. But this call just continues the older // behavior (i.e., doesn't cause any new bugs), and it would // take some further refactoring to actually solve them. In // particular, we would have to handle implied bounds // properly, and that code is currently largely confined to // regionck (though I made some efforts to extract it - // out). -nmatsakis + // out). // - // @arielby: In any case, these obligations are checked - // by wfcheck anyway, so I'm not sure we have to check + // NOTE(arielby): in any case, these obligations are checked + // by wfcheck, so I'm not sure we have to check // them here too, and we will remove this function when // we move over to lazy normalization *anyway*. let fulfill_cx = FulfillmentContext::new_ignoring_regions(); @@ -783,15 +785,16 @@ fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.lift_to_global(&predicates) { Some(predicates) => Ok(predicates), None => { - // FIXME: shouldn't we, you know, actually report an error here? or an ICE? + // FIXME: shouldn't we actually report an error/ICE here? Err(ErrorReported) } } }) } -// FIXME: this is gonna need to be removed ... /// Normalizes the parameter environment, reporting errors if they occur. +// +// FIXME: this is gonna need to be removed. pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, region_context: DefId, unnormalized_env: ty::ParamEnv<'tcx>, @@ -979,7 +982,9 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx /// Given a trait `trait_ref`, iterates the vtable entries /// that come from `trait_ref`, including its supertraits. -#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`. +// +// FIXME(#35870): avoid closures being unexported due to `impl Trait`. +#[inline] fn vtable_methods<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) @@ -1017,15 +1022,15 @@ fn vtable_methods<'a, 'tcx>( ) ); - // the trait type may have higher-ranked lifetimes in it; - // so erase them if they appear, so that we get the type - // at some particular call site + // The trait type may have higher-ranked lifetimes in it. + // Erase them if they appear, so that we get the type at some particular + // call site. let substs = tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), &substs ); - // It's possible that the method relies on where clauses that + // It's possible that the method relies on where-clauses that // do not hold for this particular set of type parameters. // Note that this method could then never be called, so we // do not want to try and codegen it, in that case (see #23435). diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index b31aa5998f365..9217f8af02025 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -51,7 +51,7 @@ impl ObjectSafetyViolation { in its arguments or return type", name).into(), ObjectSafetyViolation::Method(name, MethodViolationCode::WhereClauseReferencesSelf(_)) => - format!("method `{}` references the `Self` type in where clauses", name).into(), + format!("method `{}` references the `Self` type in where-clauses", name).into(), ObjectSafetyViolation::Method(name, MethodViolationCode::Generic) => format!("method `{}` has generic type parameters", name).into(), ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver) => @@ -125,7 +125,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { if let ObjectSafetyViolation::Method(_, MethodViolationCode::WhereClauseReferencesSelf(span)) = violation { - // Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id. + // Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise ID. // It's also hard to get a use site span, so we use the method definition span. self.lint_node_note( lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY, @@ -177,7 +177,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { .any(|predicate| { match predicate { ty::Predicate::Trait(ref data) => { - // In the case of a trait predicate, we can skip the "self" type. + // In the case of a trait predicate, we can skip the self type. data.skip_binder().input_types().skip(1).any(|t| t.has_self_ty()) } ty::Predicate::Projection(ref data) => { @@ -187,7 +187,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { // the check to be safe. // // Note that we *do* allow projection *outputs* to contain - // `self` (i.e., `trait Foo: Bar { type Result; }`), + // `self` (i.e., `trait Foo: Bar { type Result; }`), // we just require the user to specify *both* outputs // in the object type (i.e., `dyn Foo`). // @@ -220,10 +220,11 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { fn generics_require_sized_self(self, def_id: DefId) -> bool { let sized_def_id = match self.lang_items().sized_trait() { Some(def_id) => def_id, - None => { return false; /* No Sized trait, can't require it! */ } + // No `Sized` trait; can't require it! + None => return false, }; - // Search for a predicate like `Self : Sized` amongst the trait bounds. + // Search for a predicate like `Self: Sized` amongst the trait bounds. let predicates = self.predicates_of(def_id); let predicates = predicates.instantiate_identity(self).predicates; elaborate_predicates(self, predicates) @@ -253,7 +254,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { -> Option { debug!("object_safety_violation_for_method({:?}, {:?})", trait_def_id, method); - // Any method that has a `Self : Sized` requisite is otherwise + // Any method that has a `Self: Sized` requisite is otherwise // exempt from the regulations. if self.generics_require_sized_self(method.def_id) { return None; @@ -263,16 +264,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { } /// We say a method is *vtable safe* if it can be invoked on a trait - /// object. Note that object-safe traits can have some - /// non-vtable-safe methods, so long as they require `Self:Sized` or - /// otherwise ensure that they cannot be used when `Self=Trait`. + /// object. Note that object-safe traits can have some + /// non-vtable-safe methods, so long as they require `Self: Sized` or + /// otherwise ensure that they cannot be used when `Self = Trait`. pub fn is_vtable_safe_method(self, trait_def_id: DefId, method: &ty::AssociatedItem) -> bool { debug!("is_vtable_safe_method({:?}, {:?})", trait_def_id, method); - // Any method that has a `Self : Sized` requisite can't be called. + // Any method that has a `Self: Sized` requisite can't be called. if self.generics_require_sized_self(method.def_id) { return false; } @@ -285,14 +286,14 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// Returns `Some(_)` if this method cannot be called on a trait /// object; this does not necessarily imply that the enclosing trait - /// is not object safe, because the method might have a where clause + /// is not object safe, because the method might have a where-clause /// `Self:Sized`. fn virtual_call_violation_for_method(self, trait_def_id: DefId, method: &ty::AssociatedItem) -> Option { - // The method's first parameter must be named `self` + // The method's first parameter must be named `self`. if !method.method_has_self_argument { return Some(MethodViolationCode::StaticMethod); } @@ -331,15 +332,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { &sig.map_bound(|sig| sig.inputs()[0]), ); - // until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on. + // Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on. // However, this is already considered object-safe. We allow it as a special case here. - // FIXME(mikeyhew) get rid of this `if` statement once `receiver_is_dispatchable` allows - // `Receiver: Unsize dyn Trait]>` + // FIXME(mikeyhew): get rid of this `if` statement once `receiver_is_dispatchable` allows + // `Receiver: Unsize dyn Trait]>`. if receiver_ty != self.mk_self_type() { if !self.receiver_is_dispatchable(method, receiver_ty) { return Some(MethodViolationCode::UndispatchableReceiver); } else { - // sanity check to make sure the receiver actually has the layout of a pointer + // Perform sanity check to make sure the receiver actually has the layout of a + // pointer. use crate::ty::layout::Abi; @@ -354,7 +356,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { } }; - // e.g., Rc<()> + // e.g., `Rc<()>` let unit_receiver_ty = self.receiver_for_self_ty( receiver_ty, self.mk_unit(), method.def_id ); @@ -376,7 +378,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { trait_def_id, self.mk_region(ty::ReStatic) ); - // e.g., Rc + // e.g., `Rc` let trait_object_receiver = self.receiver_for_self_ty( receiver_ty, trait_object_ty, method.def_id ); @@ -439,14 +441,14 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { .filter(|(_, item)| item.kind == ty::AssociatedKind::Type) .collect::>(); - // existential predicates need to be in a specific order + // Existential predicates need to be in a specific order. associated_types.sort_by_cached_key(|(_, item)| self.def_path_hash(item.def_id)); let projection_predicates = associated_types.into_iter().map(|(super_trait_ref, item)| { // We *can* get bound lifetimes here in cases like // `trait MyTrait: for<'s> OtherTrait<&'s T, Output=bool>`. // - // binder moved to (*)... + // Binder moved to (*) ... let super_trait_ref = super_trait_ref.skip_binder(); ty::ExistentialPredicate::Projection(ty::ExistentialProjection { ty: self.mk_projection(item.def_id, super_trait_ref.substs), @@ -460,7 +462,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { ); let object_ty = self.mk_dynamic( - // (*) ... binder re-introduced here + // (*) ... binder re-introduced here. ty::Binder::bind(existential_predicates), lifetime, ); @@ -499,19 +501,21 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result /// in a new check that `Trait` is object safe, creating a cycle. So instead, we fudge a little /// by introducing a new type parameter `U` such that `Self: Unsize` and `U: Trait + ?Sized`, - /// and use `U` in place of `dyn Trait`. Written as a chalk-style query: + /// and use `U` in place of `dyn Trait`. Written as a Chalk-style query: /// - /// forall (U: Trait + ?Sized) { - /// if (Self: Unsize) { - /// Receiver: DispatchFromDyn U]> - /// } + /// ``` + /// forall (U: Trait + ?Sized) { + /// if (Self: Unsize) { + /// Receiver: DispatchFromDyn U]> /// } + /// } + /// ``` /// - /// for `self: &'a mut Self`, this means `&'a mut Self: DispatchFromDyn<&'a mut U>` - /// for `self: Rc`, this means `Rc: DispatchFromDyn>` - /// for `self: Pin>`, this means `Pin>: DispatchFromDyn>>` + /// For `self: &'a mut Self`, this means `&'a mut Self: DispatchFromDyn<&'a mut U>`. + /// For `self: Rc`, this means `Rc: DispatchFromDyn>`. + /// For `self: Pin>`, this means `Pin>: DispatchFromDyn>>`. // - // FIXME(mikeyhew) when unsized receivers are implemented as part of unsized rvalues, add this + // FIXME(mikeyhew): when unsized receivers are implemented as part of unsized rvalues, add this // fallback query: `Receiver: Unsize U]>` to support receivers like // `self: Wrapper`. #[allow(dead_code)] @@ -531,10 +535,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { return false; }; - // the type `U` in the query - // use a bogus type parameter to mimick a forall(U) query using u32::MAX for now. - // FIXME(mikeyhew) this is a total hack, and we should replace it when real forall queries - // are implemented + // This is the type `U` in the query. + // Use a bogus type parameter to mimick a `forall(U)` query using `u32::MAX` for now. + // FIXME(mikeyhew): this is a total hack, and we should replace it when real forall queries + // are implemented. let unsized_self_ty: Ty<'tcx> = self.mk_ty_param( ::std::u32::MAX, Name::intern("RustaceansAreAwesome").as_interned_str(), @@ -545,18 +549,18 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { receiver_ty, unsized_self_ty, method.def_id ); - // create a modified param env, with `Self: Unsize` and `U: Trait` added to caller bounds - // `U: ?Sized` is already implied here + // Create a modified param env, with `Self: Unsize` and `U: Trait` added to caller + // bounds. `U: ?Sized` is already implied here. let param_env = { let mut param_env = self.param_env(method.def_id); - // Self: Unsize + // `Self: Unsize` let unsize_predicate = ty::TraitRef { def_id: unsize_did, substs: self.mk_substs_trait(self.mk_self_type(), &[unsized_self_ty.into()]), }.to_predicate(); - // U: Trait + // `U: Trait` let trait_predicate = { let substs = Substs::for_item(self, method.container.assert_trait(), |param, _| { if param.index == 0 { @@ -582,7 +586,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { param_env }; - // Receiver: DispatchFromDyn U]> + // Receiver: `DispatchFromDyn U]>` let obligation = { let predicate = ty::TraitRef { def_id: dispatch_from_dyn_did, @@ -597,7 +601,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { }; self.infer_ctxt().enter(|ref infcx| { - // the receiver is dispatchable iff the obligation holds + // The receiver is dispatchable iff the obligation holds. infcx.predicate_must_hold_modulo_regions(&obligation) }) } @@ -655,7 +659,8 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { error = true; } - false // no contained types to walk + // No contained types to walk. + false } ty::Projection(ref data) => { @@ -673,7 +678,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { // SomeTrait` is in fact a supertrait of the // current trait. In that case, this type is // legal, because the type `X` will be specified - // in the object type. Note that we can just use + // in the object type. Note that we can just use // direct equality here because all of these types // are part of the formal parameter listing, and // hence there should be no inference variables. @@ -682,13 +687,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { supertraits.as_ref().unwrap().contains(&projection_trait_ref); if is_supertrait_of_current_trait { - false // do not walk contained types, do not report error, do collect $200 + // Do not walk contained types, do not report error. + false } else { - true // DO walk contained types, POSSIBLY reporting an error + // Walk contained types, possibly reporting an error. + true } } - _ => true, // walk contained types, if any + // Walk contained types, if any. + _ => true, } }); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 5a44d886e3c0a..43ee6f1e98d84 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -117,7 +117,7 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> { *self = ProjectionTyCandidateSet::Error(err); } - // Returns true if the push was successful, or false if the candidate + // Returns `true` if the push was successful, or `false` if the candidate // was discarded -- this could be because of ambiguity, or because // a higher-priority candidate is already there. fn push_candidate(&mut self, candidate: ProjectionTyCandidate<'tcx>) -> bool { @@ -141,16 +141,16 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> { } Single(current) => { - // Duplicates can happen inside ParamEnv. In the case, we + // Duplicates can happen inside `ParamEnv`. In the case, we // perform a lazy deduplication. if current == &candidate { return false; } // Prefer where-clauses. As in select, if there are multiple - // candidates, we prefer where-clause candidates over impls. This + // candidates, we prefer where-clause candidates over impls. This // may seem a bit surprising, since impls are the source of - // "truth" in some sense, but in fact some of the impls that SEEM + // "truth" in some sense, but in fact some of the impls that _seem_ // applicable are not, because of nested obligations. Where // clauses are the safer choice. See the comment on // `select::SelectionCandidate` and #21974 for more details. @@ -512,11 +512,11 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( projection_ty, depth); - // FIXME(#20304) For now, I am caching here, which is good, but it + // FIXME(#20304): for now, I am caching here, which is good, but it // means we don't capture the type variables that are created in // the case of ambiguity. Which means we may create a large stream // of such variables. OTOH, if we move the caching up a level, we - // would not benefit from caching when proving `T: Trait` + // would not benefit from caching when proving `T: Trait` // bounds. It might be the case that we want two distinct caches, // or else another kind of cache entry. @@ -531,8 +531,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( // types, which can transition from having a fixed kind to // no kind with no visible change in the key. // - // FIXME(#32286) refactor this so that closure type - // changes + // FIXME(#32286): refactor this so that closure type changes. debug!("opt_normalize_projection_type: \ found cache entry: ambiguous"); if !projection_ty.has_closure_types() { @@ -540,14 +539,14 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( } } Err(ProjectionCacheEntry::InProgress) => { - // If while normalized A::B, we are asked to normalize - // A::B, just return A::B itself. This is a conservative - // answer, in the sense that A::B *is* clearly equivalent + // If while normalized `A::B`, we are asked to normalize + // `A::B`, just return `A::B` itself. This is a conservative + // answer, in the sense that `A::B` *is* clearly equivalent // to A::B, though there may be a better value we can // find. // Under lazy normalization, this can arise when - // bootstrapping. That is, imagine an environment with a + // bootstrapping. That is, imagine an environment with a // where-clause like `A::B == u32`. Now, if we are asked // to normalize `A::B`, we will want to check the // where-clauses in scope. So we will try to unify `A::B` @@ -946,14 +945,14 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>( debug!("assemble_candidates_from_trait_def(..)"); let tcx = selcx.tcx(); - // Check whether the self-type is itself a projection. + // Check whether the self type is itself a projection. let (def_id, substs) = match obligation_trait_ref.self_ty().sty { ty::Projection(ref data) => { (data.trait_ref(tcx).def_id, data.substs) } ty::Opaque(def_id, substs) => (def_id, substs), ty::Infer(ty::TyVar(_)) => { - // If the self-type is an inference variable, then it MAY wind up + // If the self type is an inference variable, then it MAY wind up // being a projected type, so induce an ambiguity. candidate_set.mark_ambiguous(); return; @@ -999,7 +998,7 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>( infcx.at(&obligation.cause, obligation.param_env) .sup(obligation_poly_trait_ref, data_poly_trait_ref) .map(|InferOk { obligations: _, value: () }| { - // FIXME(#32730) -- do we need to take obligations + // FIXME(#32730): do we need to take obligations // into account in any way? At the moment, no. }) .is_ok() @@ -1138,7 +1137,7 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( // resolve `T::Foo`? And of course it does, but in fact // that single predicate is desugared into two predicates // in the compiler: a trait predicate (`T : SomeTrait`) and a - // projection. And the projection where clause is handled + // projection. And the projection where-clause is handled // in `assemble_candidates_from_param_env`. false } @@ -1540,7 +1539,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( } else { // This is saying that neither the trait nor // the impl contain a definition for this - // associated type. Normally this situation + // associated type. Normally this situation // could only arise through a compiler bug -- // if the user wrote a bad item name, it // should have failed in astconv. diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index e6f9c7ebe6fe4..6d02892035e20 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -96,7 +96,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> { tcx.sess, span, E0320, - "overflow while adding drop-check rules for {}", + "overflow while adding drop-check rules for `{}`", ty, ); err.note(&format!("overflowed on {}", overflow_ty)); diff --git a/src/librustc/traits/query/method_autoderef.rs b/src/librustc/traits/query/method_autoderef.rs index 6b9bdfd63f4d0..a131b04146752 100644 --- a/src/librustc/traits/query/method_autoderef.rs +++ b/src/librustc/traits/query/method_autoderef.rs @@ -6,7 +6,7 @@ use crate::ty::Ty; pub struct CandidateStep<'tcx> { pub self_ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, pub autoderefs: usize, - // true if the type results from a dereference of a raw pointer. + // `true` if the type results from a dereference of a raw pointer. // when assembling candidates, we include these steps, but not when // picking methods. This so that if we have `foo: *const Foo` and `Foo` has methods // `fn by_raw_ptr(self: *const Self)` and `fn by_ref(&self)`, then diff --git a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs index c48ca33b13fbc..abccd951804c0 100644 --- a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs +++ b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs @@ -28,7 +28,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds< tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, ) -> Fallible> { - // FIXME this `unchecked_map` is only necessary because the + // FIXME: this `unchecked_map` is only necessary because the // query is defined as taking a `ParamEnvAnd`; it should // take a `ImpliedOutlivesBounds` instead let canonicalized = canonicalized.unchecked_map(|ParamEnvAnd { param_env, value }| { diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index fd13acc7796f8..8c47133b12794 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -93,7 +93,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: return Ok(result); } - // FIXME(#33684) -- We need to use + // FIXME(#33684): we need to use // `canonicalize_hr_query_hack` here because of things // like the subtype query, which go awry around // `'static` otherwise. diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs index fc0c1c022fc80..544432b296bc4 100644 --- a/src/librustc/traits/query/type_op/outlives.rs +++ b/src/librustc/traits/query/type_op/outlives.rs @@ -46,7 +46,7 @@ where // know we are not registering any subregion relations or // other things). - // FIXME convert to the type expected by the `dropck_outlives` + // FIXME: convert to the type expected by the `dropck_outlives` // query. This should eventually be fixed by changing the // *underlying query*. let canonicalized = canonicalized.unchecked_map(|ParamEnvAnd { param_env, value }| { diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index c2c05ce7af50b..2d912dd8cf2b0 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -2,13 +2,26 @@ //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/resolution.html#selection -use self::EvaluationResult::*; -use self::SelectionCandidate::*; +use std::cmp; +use std::fmt::{self, Display}; +use std::iter; +use std::rc::Rc; -use super::coherence::{self, Conflict}; -use super::project; -use super::project::{normalize_with_depth, Normalized, ProjectionCacheKey}; -use super::util; +use rustc_data_structures::bit_set::GrowableBitSet; +use rustc_data_structures::sync::Lock; +use rustc_target::spec::abi::Abi; + +use crate::dep_graph::{DepKind, DepNodeIndex}; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::infer::{InferCtxt, InferOk, TypeFreshener}; +use crate::middle::lang_items; +use crate::mir::interpret::GlobalId; +use crate::ty::fast_reject; +use crate::ty::relate::TypeRelation; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use crate::util::nodemap::{FxHashMap, FxHashSet}; use super::DerivedObligationCause; use super::Selection; use super::SelectionResult; @@ -26,26 +39,12 @@ use super::{ VtableAutoImplData, VtableBuiltinData, VtableClosureData, VtableFnPointerData, VtableGeneratorData, VtableImplData, VtableObjectData, VtableTraitAliasData, }; - -use crate::dep_graph::{DepKind, DepNodeIndex}; -use crate::hir::def_id::DefId; -use crate::infer::{InferCtxt, InferOk, TypeFreshener}; -use crate::middle::lang_items; -use crate::mir::interpret::GlobalId; -use crate::ty::fast_reject; -use crate::ty::relate::TypeRelation; -use crate::ty::subst::{Subst, Substs}; -use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; - -use crate::hir; -use rustc_data_structures::bit_set::GrowableBitSet; -use rustc_data_structures::sync::Lock; -use rustc_target::spec::abi::Abi; -use std::cmp; -use std::fmt::{self, Display}; -use std::iter; -use std::rc::Rc; -use crate::util::nodemap::{FxHashMap, FxHashSet}; +use super::coherence::{self, Conflict}; +use super::project; +use super::project::{normalize_with_depth, Normalized, ProjectionCacheKey}; +use super::util; +use self::EvaluationResult::*; +use self::SelectionCandidate::*; pub struct SelectionContext<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, @@ -1057,8 +1056,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { dep_node: DepNodeIndex, result: EvaluationResult, ) { - // Avoid caching results that depend on more than just the trait-ref - // - the stack can create recursion. + // Avoid caching results that depend on more than just the trait-ref; + // the stack can create recursion. if result.is_stack_dependent() { return; } @@ -1070,9 +1069,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { trait_ref, result, ); // This may overwrite the cache with the same value - // FIXME: Due to #50507 this overwrites the different values - // This should be changed to use HashMapExt::insert_same - // when that is fixed + // FIXME: due to #50507 this overwrites the different values + // This should be changed to use `HashMapExt::insert_same` + // when that is fixed. self.tcx() .evaluation_cache .hashmap @@ -1319,7 +1318,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // impl Vec { fn push_clone(...) { ... } } // // and we were to see some code `foo.push_clone()` where `boo` - // is a `Vec` and `Bar` does not implement `Clone`. If + // is a `Vec` and `Bar` does not implement `Clone`. If // we were to winnow, we'd wind up with zero candidates. // Instead, we select the right impl now but report `Bar does // not implement Clone`. @@ -1413,9 +1412,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let predicate = self.infcx() .resolve_type_vars_if_possible(&obligation.predicate); - // OK to skip binder because of the nature of the + // Ok to skip binder because of the nature of the // trait-ref-is-knowable check, which does not care about - // bound regions + // bound regions. let trait_ref = predicate.skip_binder().trait_ref; let result = coherence::trait_ref_is_knowable(self.tcx(), trait_ref); @@ -1492,7 +1491,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { /// since it was usually produced directly from a DefId. However, /// certain cases (currently only librustdoc's blanket impl finder), /// a ParamEnv may be explicitly constructed with inference types. - /// When this is the case, we do *not* want to cache the resulting selection + /// When this is the case, we do **not** want to cache the resulting selection /// candidate. This is due to the fact that it might not always be possible /// to equate the obligation's trait ref and the candidate's trait ref, /// if more constraints end up getting added to an inference variable. @@ -1655,7 +1654,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { debug!("assemble_candidates_for_projected_tys({:?})", obligation); // before we go into the whole placeholder thing, just - // quickly check if the self-type is a projection at all. + // quickly check if the self type is a projection at all. match obligation.predicate.skip_binder().trait_ref.self_ty().sty { ty::Projection(_) | ty::Opaque(..) => {} ty::Infer(ty::TyVar(_)) => { @@ -1788,7 +1787,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let matching_bounds = all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id()); - // keep only those bounds which may apply, and propagate overflow if it occurs + // Keep only those bounds which may apply, and propagate overflow if it occurs. let mut param_candidates = vec![]; for bound in matching_bounds { let wc = self.evaluate_where_clause(stack, bound.clone())?; @@ -1826,9 +1825,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { return Ok(()); } - // OK to skip binder because the substs on generator types never + // Ok to skip binder because the substs on generator types never // touch bound regions, they just capture the in-scope - // type/region parameters + // type/region parameters. let self_ty = *obligation.self_ty().skip_binder(); match self_ty.sty { ty::Generator(..) => { @@ -1840,7 +1839,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { candidates.vec.push(GeneratorCandidate); } ty::Infer(ty::TyVar(_)) => { - debug!("assemble_generator_candidates: ambiguous self-type"); + debug!("assemble_generator_candidates: ambiguous self type"); candidates.ambiguous = true; } _ => {} @@ -1870,7 +1869,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } }; - // OK to skip binder because the substs on closure types never + // Ok to skip binder because the substs on closure types never // touch bound regions, they just capture the in-scope // type/region parameters match obligation.self_ty().skip_binder().sty { @@ -1896,7 +1895,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } } ty::Infer(ty::TyVar(_)) => { - debug!("assemble_unboxed_closure_candidates: ambiguous self-type"); + debug!("assemble_unboxed_closure_candidates: ambiguous self type"); candidates.ambiguous = true; } _ => {} @@ -1920,11 +1919,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { return Ok(()); } - // OK to skip binder because what we are inspecting doesn't involve bound regions + // Ok to skip binder because what we are inspecting doesn't involve bound regions let self_ty = *obligation.self_ty().skip_binder(); match self_ty.sty { ty::Infer(ty::TyVar(_)) => { - debug!("assemble_fn_pointer_candidates: ambiguous self-type"); + debug!("assemble_fn_pointer_candidates: ambiguous self type"); candidates.ambiguous = true; // could wind up being a fn() type } // provide an impl, but only for suitable `fn` pointers @@ -1977,7 +1976,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { obligation: &TraitObligation<'tcx>, candidates: &mut SelectionCandidateSet<'tcx>, ) -> Result<(), SelectionError<'tcx>> { - // OK to skip binder here because the tests we do below do not involve bound regions + // Ok to skip binder here because the tests we do below do not involve bound regions. let self_ty = *obligation.self_ty().skip_binder(); debug!("assemble_candidates_from_auto_impls(self_ty={:?})", self_ty); @@ -1999,7 +1998,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } ty::Param(..) | ty::Projection(..) => { // In these cases, we don't know what the actual - // type is. Therefore, we cannot break it down + // type is. Therefore, we cannot break it down // into its constituent types. So we don't // consider the `..` impl but instead just add no // candidates: this means that typeck will only @@ -2127,10 +2126,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // A `T: Unsize` obligation is always used as part of a `T: CoerceUnsize` // impl, and those are generally applied to concrete types. // - // That said, one might try to write a fn with a where clause like + // That said, one might try to write a fn with a where-clause like // for<'a> Foo<'a, T>: Unsize> // where the `'a` is kind of orthogonal to the relevant part of the `Unsize`. - // Still, you'd be more likely to write that where clause as + // Still, you'd be more likely to write that where-clause as // T: Trait // so it seems ok if we (conservatively) fail to accept that `Unsize` // obligation above. Should be possible to extend this in the future. @@ -2162,7 +2161,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // 2. Tightening the region bound, e.g., `Foo+'a` to `Foo+'b` if `'a : 'b` // // Note that neither of these changes requires any - // change at runtime. Eventually this will be + // change at runtime. Eventually this will be // generalized. // // We always upcast when we can because of reason @@ -2209,7 +2208,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { obligation: &TraitObligation<'tcx>, candidates: &mut SelectionCandidateSet<'tcx>, ) -> Result<(), SelectionError<'tcx>> { - // OK to skip binder here because the tests we do below do not involve bound regions + // Ok to skip binder here because the tests we do below do not involve bound regions. let self_ty = *obligation.self_ty().skip_binder(); debug!("assemble_candidates_for_trait_alias(self_ty={:?})", self_ty); @@ -2274,7 +2273,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { | BuiltinUnsizeCandidate | BuiltinCandidate { .. } | TraitAliasCandidate(..) => { - // Global bounds from the where clause should be ignored + // Global bounds from the where-clause should be ignored // here (see issue #50825). Otherwise, we have a where // clause so don't go around looking for impls. !is_global(cand) @@ -2325,7 +2324,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { other_def, victim_def).is_some(); } ParamCandidate(ref cand) => { - // Prefer the impl to a global where clause candidate. + // Prefer the impl to a global where-clause candidate. return is_global(cand); } _ => (), @@ -2678,7 +2677,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // // Confirmation unifies the output type parameters of the trait // with the values found in the obligation, possibly yielding a - // type error. See the [rustc guide] for more details. + // type error. See the [rustc guide] for more details. // // [rustc guide]: // https://rust-lang.github.io/rustc-guide/traits/resolution.html#confirmation @@ -2780,7 +2779,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { Ok(obligations) => obligations, Err(()) => { bug!( - "Where clause `{:?}` was applicable to `{:?}` but now is not", + "where-clause `{:?}` was applicable to `{:?}` but now is not", param, obligation ); @@ -2891,8 +2890,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ) }); - // Adds the predicates from the trait. Note that this contains a `Self: Trait` - // predicate as usual. It won't have any effect since auto traits are coinductive. + // Adds the predicates from the trait. Note that this contains a `Self: Trait` + // predicate as usual. It won't have any effect since auto traits are coinductive. obligations.extend(trait_obligations); debug!("vtable_auto_impl: obligations={:?}", obligations); @@ -2956,7 +2955,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // are sufficient to determine the impl substs, without // relying on projections in the impl-trait-ref. // - // e.g., `impl> Foo<::T> for V` + // E.g., `impl> Foo<::T> for V`. impl_obligations.append(&mut substs.obligations); VtableImplData { @@ -2972,7 +2971,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ) -> VtableObjectData<'tcx, PredicateObligation<'tcx>> { debug!("confirm_object_candidate({:?})", obligation); - // FIXME(nmatsakis) skipping binder here seems wrong -- we should + // FIXME(nmatsakis): skipping binder here seems wrong -- we should // probably flatten the binder from the obligation and the binder // from the object. Have to try to make a broken test case that // results. @@ -3030,7 +3029,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { debug!("confirm_fn_pointer_candidate({:?})", obligation); - // OK to skip binder; it is reintroduced below + // Ok to skip binder; it is reintroduced below. let self_ty = self.infcx .shallow_resolve(*obligation.self_ty().skip_binder()); let sig = self_ty.fn_sig(self.tcx()); @@ -3108,9 +3107,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { &mut self, obligation: &TraitObligation<'tcx>, ) -> Result>, SelectionError<'tcx>> { - // OK to skip binder because the substs on generator types never + // Ok to skip binder because the substs on generator types never // touch bound regions, they just capture the in-scope - // type/region parameters + // type/region parameters. let self_ty = self.infcx .shallow_resolve(obligation.self_ty().skip_binder()); let (generator_def_id, substs) = match self_ty.sty { @@ -3166,9 +3165,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { .fn_trait_kind(obligation.predicate.def_id()) .unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation)); - // OK to skip binder because the substs on closure types never + // Ok to skip binder because the substs on closure types never // touch bound regions, they just capture the in-scope - // type/region parameters + // type/region parameters. let self_ty = self.infcx .shallow_resolve(obligation.self_ty().skip_binder()); let (closure_def_id, substs) = match self_ty.sty { @@ -3262,7 +3261,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { let tcx = self.tcx(); - // assemble_candidates_for_unsizing should ensure there are no late bound + // `assemble_candidates_for_unsizing` should ensure there are no late-bound // regions here. See the comment there for more details. let source = self.infcx .shallow_resolve(obligation.self_ty().no_bound_vars().unwrap()); @@ -3494,7 +3493,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // Matching // // Matching is a common path used for both evaluation and - // confirmation. It basically unifies types that appear in impls + // confirmation. It basically unifies types that appear in impls // and traits. This does affect the surrounding environment; // therefore, when used during evaluation, match routines must be // run inside of a `probe()` so that their side-effects are @@ -3674,7 +3673,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ); // (1) Feels icky to skip the binder here, but OTOH we know - // that the self-type is an unboxed closure type and hence is + // that the self type is an unboxed closure type and hence is // in fact unparameterized (or at least does not reference any // regions bound in the obligation). Still probably some // refactoring could make this nicer. @@ -3697,7 +3696,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let gen_sig = substs.poly_sig(closure_def_id, self.tcx()); // (1) Feels icky to skip the binder here, but OTOH we know - // that the self-type is an generator type and hence is + // that the self type is an generator type and hence is // in fact unparameterized (or at least does not reference any // regions bound in the obligation). Still probably some // refactoring could make this nicer. @@ -3730,7 +3729,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // each predicate must be preceded by the obligations required // to normalize it. // for example, if we have: - // impl> Foo for V where U::Item: Copy + // impl> Foo for V where U::Item: Copy // the impl will have the following predicates: // ::Item = U, // U: Iterator, U: Sized, @@ -3769,8 +3768,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // types. // // This code is hot enough that it's worth avoiding the allocation - // required for the FxHashSet when possible. Special-casing lengths 0, - // 1 and 2 covers roughly 75--80% of the cases. + // required for the FxHashSet when possible. Special-casing lengths `0`, + // `1` and `2` covers roughly 75 to 80% of the cases. if predicates.len() <= 1 { // No possibility of duplicates. } else if predicates.len() == 2 { diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 804f1b9d820a2..8826076091174 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -165,11 +165,11 @@ pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // We determine whether there's a subset relationship by: // - // - skolemizing impl1, - // - assuming the where clauses for impl1, - // - instantiating impl2 with fresh inference variables, + // - skolemizing `impl1`, + // - assuming the where-clauses for `impl1`, + // - instantiating `impl2` with fresh inference variables, // - unifying, - // - attempting to prove the where clauses for impl2 + // - attempting to prove the where-clauses for `impl2`. // // The last three steps are encapsulated in `fulfill_implication`. // @@ -180,11 +180,11 @@ pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return false; } - // create a parameter environment corresponding to a (placeholder) instantiation of impl1 + // Create a parameter environment corresponding to a (placeholder) instantiation of `impl1`. let penv = tcx.param_env(impl1_def_id); let impl1_trait_ref = tcx.impl_trait_ref(impl1_def_id).unwrap(); - // Create a infcx, taking the predicates of impl1 as assumptions: + // Create a infcx, taking the predicates of `impl1` as assumptions: tcx.infer_ctxt().enter(|infcx| { // Normalize the trait reference. The WF rules ought to ensure // that this always succeeds. @@ -200,7 +200,7 @@ pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } }; - // Attempt to prove that impl2 applies, given all of the above. + // Attempt to prove that `impl2` applies, given all of the above. fulfill_implication(&infcx, penv, impl1_trait_ref, impl2_def_id).is_ok() }) } @@ -227,7 +227,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, debug!("fulfill_implication: target_trait_ref={:?}, obligations={:?}", target_trait_ref, obligations); - // do the impls unify? If not, no specialization. + // Do the impls unify? If not, no specialization. match infcx.at(&ObligationCause::dummy(), param_env) .eq(source_trait_ref, target_trait_ref) { Ok(InferOk { obligations: o, .. }) => { @@ -241,8 +241,8 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, } } - // attempt to prove all of the predicates for impl2 given those for impl1 - // (which are packed up in penv) + // Attempt to prove all of the predicates for `impl2` given those for `impl1` + // (which are packed up in penv). infcx.save_and_restore_in_snapshot_flag(|infcx| { // If we came from `translate_substs`, we already know that the @@ -251,7 +251,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, // we only want to process the projections to determine the // the types in our substs using RFC 447, so we can safely // ignore region obligations, which allows us to avoid threading - // a node-id to assign them with. + // a `NodeId` to assign them with. // // If we came from specialization graph construction, then // we already make a mockery out of the region system, so @@ -262,7 +262,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, } match fulfill_cx.select_all_or_error(infcx) { Err(errors) => { - // no dice! + // No dice! debug!("fulfill_implication: for impls on {:?} and {:?}, \ could not fulfill: {:?} given {:?}", source_trait_ref, @@ -401,7 +401,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option< let substs = Substs::identity_for_item(tcx, impl_def_id); - // FIXME: Currently only handles ?Sized. + // FIXME: currently only handles ?Sized. // Needs to support ?Move and ?DynSized when they are implemented. let mut types_without_default_bounds = FxHashSet::default(); let sized_trait = tcx.lang_items().sized_trait(); diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index b5be1777fa0d8..5ff62c497376a 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -10,11 +10,11 @@ use std::fmt; use std::rc::Rc; use std::collections::{BTreeSet, BTreeMap}; -// structural impls for the structs in traits +// Structural impls for the structs in `traits`. impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Normalized({:?},{:?})", self.value, self.obligations) + write!(f, "Normalized({:?}, {:?})", self.value, self.obligations) } } @@ -23,13 +23,13 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> { if ty::tls::with(|tcx| tcx.sess.verbose()) { write!( f, - "Obligation(predicate={:?},cause={:?},param_env={:?},depth={})", + "Obligation(predicate={:?}, cause={:?}, param_env={:?}, depth={})", self.predicate, self.cause, self.param_env, self.recursion_depth ) } else { write!( f, - "Obligation(predicate={:?},depth={})", + "Obligation(predicate={:?}, depth={})", self.predicate, self.recursion_depth ) } diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 754cc94073b10..28f20eda863a0 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -133,8 +133,8 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> { data, predicates); // Only keep those bounds that we haven't already - // seen. This is necessary to prevent infinite - // recursion in some cases. One common case is when + // seen. This is necessary to prevent infinite + // recursion in some cases. One common case is when // people define `trait Sized: Sized { }` rather than `trait // Sized { }`. predicates.retain(|r| self.visited.insert(r)); @@ -269,7 +269,7 @@ pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>, } /////////////////////////////////////////////////////////////////////////// -// Iterator over def-ids of supertraits +// Iterator over `DefId`s of supertraits pub struct SupertraitDefIds<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index ff4fc87542dc3..3b7488582a3d6 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -3,7 +3,6 @@ use crate::hir::def_id::DefId; use crate::ty::{self, Ty, TyCtxt}; use crate::ty::subst::Substs; - /// Represents coercing a value to a different type of value. /// /// We transform values by following a number of `Adjust` steps in order. @@ -112,15 +111,17 @@ impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> { /// At least for initial deployment, we want to limit two-phase borrows to /// only a few specific cases. Right now, those are mostly "things that desugar" /// into method calls: +/// /// - using `x.some_method()` syntax, where some_method takes `&mut self`, /// - using `Foo::some_method(&mut x, ...)` syntax, /// - binary assignment operators (`+=`, `-=`, `*=`, etc.). +/// /// Anything else should be rejected until generalized two-phase borrow support /// is implemented. Right now, dataflow can't handle the general case where there /// is more than one use of a mutable borrow, and we don't want to accept too much /// new code via two-phase borrows, so we try to limit where we create two-phase /// capable mutable borrows. -/// See #49434 for tracking. +/// See issue #49434 for tracking. #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] pub enum AllowTwoPhase { Yes, @@ -144,10 +145,10 @@ impl From for hir::Mutability { #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] pub enum AutoBorrow<'tcx> { - /// Converts from T to &T. + /// Converts from `T` to `&T`. Ref(ty::Region<'tcx>, AutoBorrowMutability), - /// Converts from T to *T. + /// Converts from `T` to `*T`. RawPtr(hir::Mutability), } diff --git a/src/librustc/ty/cast.rs b/src/librustc/ty/cast.rs index 0b2112f42d595..af388a255fae0 100644 --- a/src/librustc/ty/cast.rs +++ b/src/librustc/ty/cast.rs @@ -1,10 +1,10 @@ // Helpers for handling cast expressions, used in both // typeck and codegen. -use crate::ty::{self, Ty}; - use syntax::ast; +use crate::ty::{self, Ty}; + /// Types that are represented as ints. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum IntTy { @@ -15,23 +15,23 @@ pub enum IntTy { Char } -// Valid types for the result of a non-coercion cast +// Valid types for the result of a non-coercion cast. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum CastTy<'tcx> { /// Various types that are represented as ints and handled mostly /// in the same way, merged for easier matching. Int(IntTy), - /// Floating-Point types + /// Floating-Point types. Float, - /// Function Pointers + /// Function pointers. FnPtr, - /// Raw pointers + /// Raw pointers. Ptr(ty::TypeAndMut<'tcx>), - /// References + /// References. RPtr(ty::TypeAndMut<'tcx>), } -/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs) +/// Cast kind. See RFC 401 (or `librustc_typeck/check/cast.rs`). #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)] pub enum CastKind { CoercionCast, @@ -49,7 +49,7 @@ pub enum CastKind { impl<'tcx> CastTy<'tcx> { /// Returns `Some` for integral/pointer casts. - /// casts like unsizing casts will return `None` + /// Casts like unsizing casts will return `None`. pub fn from_ty(t: Ty<'tcx>) -> Option> { match t.sty { ty::Bool => Some(CastTy::Int(IntTy::Bool)), diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index e93de32f7257b..15186d258792c 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -6,12 +6,14 @@ // The functionality in here is shared between persisting to crate metadata and // persisting to incr. comp. caches. -use crate::hir::def_id::{DefId, CrateNum}; -use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; -use rustc_data_structures::fx::FxHashMap; -use crate::rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque}; use std::hash::Hash; use std::intrinsics; + +use rustc_data_structures::fx::FxHashMap; +use rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque}; + +use crate::hir::def_id::{DefId, CrateNum}; +use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; use crate::ty::{self, Ty, TyCtxt}; use crate::ty::subst::Substs; use crate::mir::interpret::Allocation; @@ -277,14 +279,15 @@ macro_rules! __impl_decoder_methods { macro_rules! implement_ty_decoder { ($DecoderName:ident <$($typaram:tt),*>) => { mod __ty_decoder_impl { - use super::$DecoderName; + use std::borrow::Cow; + use rustc_serialize::{Decoder, SpecializedDecoder}; + use $crate::infer::canonical::CanonicalVarInfos; use $crate::ty; use $crate::ty::codec::*; use $crate::ty::subst::Substs; use $crate::hir::def_id::{CrateNum}; - use crate::rustc_serialize::{Decoder, SpecializedDecoder}; - use std::borrow::Cow; + use super::$DecoderName; impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> { type Error = String; @@ -318,8 +321,8 @@ macro_rules! implement_ty_decoder { } } - // FIXME(#36588) These impls are horribly unsound as they allow - // the caller to pick any lifetime for 'tcx, including 'static, + // FIXME(#36588): these impls are horribly unsound as they allow + // the caller to pick any lifetime for `'tcx`, including `'static`, // by using the unspecialized proxies to them. impl<$($typaram),*> SpecializedDecoder diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 18b0afe1fd91e..4725e776bd727 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1,20 +1,50 @@ //! Type context book-keeping. +use std::any::Any; +use std::borrow::Borrow; +use std::cmp::Ordering; +use std::collections::hash_map::{self, Entry}; +use std::hash::{Hash, Hasher}; +use std::iter; +use std::fmt; +use std::marker::PhantomData; +use std::mem; +use std::ops::{Deref, Bound}; +use std::ptr; +use std::sync::mpsc; +use std::sync::Arc; + +use arena::{TypedArena, SyncDroplessArena}; +use errors::DiagnosticBuilder; +use rustc_data_structures::indexed_vec::{Idx, IndexVec}; +use rustc_data_structures::interner::HashInterner; +use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, + StableHasher, StableHasherResult, + StableVec}; +use rustc_data_structures::sync::{self, Lrc, Lock, WorkerLocal}; +use rustc_target::spec::abi; +use smallvec::SmallVec; +use syntax_pos::Span; +use syntax::ast::{self, NodeId}; +use syntax::attr; +use syntax::source_map::MultiSpan; +use syntax::edition::Edition; +use syntax::feature_gate; +use syntax::symbol::{Symbol, keywords, InternedString}; + use crate::dep_graph::DepGraph; use crate::dep_graph::{self, DepNode, DepConstructor}; -use crate::session::Session; -use crate::session::config::{BorrowckMode, OutputFilenames}; -use crate::session::config::CrateType; -use crate::middle; +use crate::hir; use crate::hir::{TraitCandidate, HirId, ItemKind, ItemLocalId, Node}; use crate::hir::def::{Def, Export}; use crate::hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE}; use crate::hir::map as hir_map; use crate::hir::map::DefPathHash; -use crate::lint::{self, Lint}; use crate::ich::{StableHashingContext, NodeIdHashingMode}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::infer::outlives::free_region_map::FreeRegionMap; +use crate::lint::{self, Lint}; +use crate::middle; use crate::middle::cstore::CrateStoreDyn; use crate::middle::cstore::EncodedMetadata; use crate::middle::lang_items; @@ -22,58 +52,28 @@ use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::{self, Mir, interpret, ProjectionKind}; use crate::mir::interpret::Allocation; -use crate::ty::subst::{Kind, Substs, Subst}; -use crate::ty::ReprOptions; +use crate::session::Session; +use crate::session::config::{BorrowckMode, OutputFilenames}; +use crate::session::config::CrateType; use crate::traits; use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals}; use crate::ty::{self, Ty, TypeAndMut}; +use crate::ty::{BoundVar, BindingMode}; use crate::ty::{TyS, TyKind, List}; use crate::ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const, LazyConst}; use crate::ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; -use crate::ty::RegionKind; use crate::ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; -use crate::ty::TyKind::*; +use crate::ty::CanonicalPolyFnSig; use crate::ty::GenericParamDefKind; +use crate::ty::RegionKind; +use crate::ty::ReprOptions; +use crate::ty::TyKind::*; use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx}; use crate::ty::query; use crate::ty::steal::Steal; -use crate::ty::subst::{UserSubsts, UnpackedKind}; -use crate::ty::{BoundVar, BindingMode}; -use crate::ty::CanonicalPolyFnSig; +use crate::ty::subst::{Kind, Substs, Subst, UserSubsts, UnpackedKind}; use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap}; use crate::util::nodemap::{FxHashMap, FxHashSet}; -use errors::DiagnosticBuilder; -use rustc_data_structures::interner::HashInterner; -use smallvec::SmallVec; -use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, - StableHasher, StableHasherResult, - StableVec}; -use arena::{TypedArena, SyncDroplessArena}; -use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use rustc_data_structures::sync::{self, Lrc, Lock, WorkerLocal}; -use std::any::Any; -use std::borrow::Borrow; -use std::cmp::Ordering; -use std::collections::hash_map::{self, Entry}; -use std::hash::{Hash, Hasher}; -use std::fmt; -use std::mem; -use std::ops::{Deref, Bound}; -use std::ptr; -use std::iter; -use std::sync::mpsc; -use std::sync::Arc; -use std::marker::PhantomData; -use rustc_target::spec::abi; -use syntax::ast::{self, NodeId}; -use syntax::attr; -use syntax::source_map::MultiSpan; -use syntax::edition::Edition; -use syntax::feature_gate; -use syntax::symbol::{Symbol, keywords, InternedString}; -use syntax_pos::Span; - -use crate::hir; pub struct AllArenas<'tcx> { pub global: WorkerLocal>, @@ -91,30 +91,30 @@ impl<'tcx> AllArenas<'tcx> { } } -/// Internal storage +/// Internal storage. #[derive(Default)] pub struct GlobalArenas<'tcx> { - // internings + // Internings layout: TypedArena, - // references + // References generics: TypedArena, trait_def: TypedArena, adt_def: TypedArena, steal_mir: TypedArena>>, mir: TypedArena>, tables: TypedArena>, - /// miri allocations + /// Miri allocations. const_allocs: TypedArena, } type InternedSet<'tcx, T> = Lock, ()>>; pub struct CtxtInterners<'tcx> { - /// The arena that types, regions, etc are allocated from + /// The arena that types, regions, etc. are allocated from. arena: &'tcx SyncDroplessArena, - /// Specifically use a speedy hash algorithm for these hash sets, + /// Specifically use a speedy hash algorithm for these hash sets, since /// they're accessed quite often. type_: InternedSet<'tcx, TyS<'tcx>>, type_list: InternedSet<'tcx, List>>, @@ -149,7 +149,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { } } - /// Intern a type + /// Interns a type. #[inline(never)] fn intern_ty( local: &CtxtInterners<'tcx>, @@ -158,9 +158,9 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { ) -> Ty<'tcx> { let flags = super::flags::FlagComputation::for_sty(&st); - // HACK(eddyb) Depend on flags being accurate to + // HACK(eddyb): depend on flags being accurate to // determine that all contents are in the global tcx. - // See comments on Lift for why we can't use that. + // See comments on `Lift` for why we can't use that. if flags.flags.intersects(ty::TypeFlags::KEEP_IN_LOCAL_TCX) { local.type_.borrow_mut().intern(st, |st| { let ty_struct = TyS { @@ -170,7 +170,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { }; // Make sure we don't end up with inference - // types/regions in the global interner + // types/regions in the global interner. if ptr::eq(local, global) { bug!("Attempted to intern `{:?}` which contains \ inference types/regions in the global type context", @@ -187,8 +187,8 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { outer_exclusive_binder: flags.outer_exclusive_binder, }; - // This is safe because all the types the ty_struct can point to - // already is in the global arena + // This is safe because all the types the `ty_struct` can point to + // already is in the global arena. let ty_struct: TyS<'gcx> = unsafe { mem::transmute(ty_struct) }; @@ -230,10 +230,10 @@ pub struct LocalTableInContext<'a, V: 'a> { data: &'a ItemLocalMap } -/// Validate that the given HirId (respectively its `local_id` part) can be -/// safely used as a key in the tables of a TypeckTable. For that to be -/// the case, the HirId must have the same `owner` as all the other IDs in -/// this table (signified by `local_id_root`). Otherwise the HirId +/// Validates that the given `HirId` (respectively its `local_id` part) can be +/// safely used as a key in the tables of a `TypeckTable`. For that to be +/// the case, the `HirId` must have the same `owner` as all the other IDs in +/// this table (signified by `local_id_root`). Otherwise, the `HirId` /// would be in a different frame of reference and using its `local_id` /// would result in lookup errors, or worse, in silently wrong data being /// stored/returned. @@ -254,9 +254,9 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option, }); } } else { - // We use "Null Object" TypeckTables in some of the analysis passes. + // We use "Null Object" `TypeckTables` in some of the analysis passes. // These are just expected to be empty and their `local_id_root` is - // `None`. Therefore we cannot verify whether a given `HirId` would + // `None`. Therefore, we cannot verify whether a given `HirId` would // be a valid key for the given table. Instead we make sure that // nobody tries to write to such a Null Object table. if mut_access { @@ -319,7 +319,7 @@ impl<'a, V> LocalTableInContextMut<'a, V> { #[derive(RustcEncodable, RustcDecodable, Debug)] pub struct TypeckTables<'tcx> { - /// The HirId::owner all ItemLocalIds in this table are relative to. + /// The `HirId::owner` to which all `ItemLocalId`s in this table are relative. pub local_id_root: Option, /// Resolved definitions for `::X` associated paths and @@ -334,12 +334,12 @@ pub struct TypeckTables<'tcx> { /// Stores the types for various nodes in the AST. Note that this table /// is not guaranteed to be populated until after typeck. See - /// typeck::check::fn_ctxt for details. + /// `typeck::check::fn_ctxt` for details. node_types: ItemLocalMap>, /// Stores the type parameters which were substituted to obtain the type /// of this node. This only applies to nodes that refer to entities - /// parameterized by type parameters, such as generic fns, types, or + /// parameterized by type parameters, such as generic functions, types, or /// other items. node_substs: ItemLocalMap<&'tcx Substs<'tcx>>, @@ -351,16 +351,17 @@ pub struct TypeckTables<'tcx> { /// For example, if the user wrote `foo.collect::>()`, then the /// canonical substitutions would include only `for { Vec }`. /// - /// See also `AscribeUserType` statement in MIR. + /// See also the `AscribeUserType` statement in MIR. user_provided_types: ItemLocalMap>, - /// Stores the canonicalized types provided by the user. See also - /// `AscribeUserType` statement in MIR. + /// Stores the canonicalized types provided by the user. + /// + /// See also the `AscribeUserType` statement in MIR. pub user_provided_sigs: DefIdMap>, adjustments: ItemLocalMap>>, - /// Stores the actual binding mode for all instances of hir::BindingAnnotation. + /// Stores the actual binding mode for all instances of `hir::BindingAnnotation`. pat_binding_modes: ItemLocalMap, /// Stores the types which were implicitly dereferenced in pattern binding modes @@ -374,11 +375,11 @@ pub struct TypeckTables<'tcx> { /// ``` /// leads to a `vec![&&Option, &Option]`. Empty vectors are not stored. /// - /// See: - /// https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#definitions + /// See + /// . pat_adjustments: ItemLocalMap>>, - /// Borrows + /// Borrows. pub upvar_capture_map: ty::UpvarCaptureMap<'tcx>, /// Records the reasons that we picked the kind of each closure; @@ -393,7 +394,7 @@ pub struct TypeckTables<'tcx> { liberated_fn_sigs: ItemLocalMap>, /// For each FRU expression, record the normalized types of the fields - /// of the struct - this is needed because it is non-trivial to + /// of the struct -- this is needed because it is non-trivial to /// normalize while preserving regions. This table is used only in /// MIR construction and hence is not serialized to metadata. fru_field_types: ItemLocalMap>>, @@ -421,8 +422,8 @@ pub struct TypeckTables<'tcx> { /// by this function pub concrete_existential_types: FxHashMap>, - /// Given the closure ID this map provides the list of UpvarIDs used by it. - /// The upvarID contains the HIR node ID and it also contains the full path + /// Given the closure ID this map provides the list of `UpvarId`s used by it. + /// The `UpvarId` contains the HIR node ID and it also contains the full path /// leading to the member of the struct or tuple that is used instead of the /// entire variable. pub upvar_list: ty::UpvarListMap, @@ -566,10 +567,10 @@ impl<'tcx> TypeckTables<'tcx> { // Returns the type of an expression as a monotype. // - // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in + // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in // some cases, we insert `Adjustment` annotations such as auto-deref or - // auto-ref. The type returned by this function does not consider such - // adjustments. See `expr_ty_adjusted()` instead. + // auto-ref. The type returned by this function does not consider such + // adjustments. See `expr_ty_adjusted()` instead. // // NB (2): This type doesn't provide type parameter substitutions; e.g., if you // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize" @@ -937,11 +938,11 @@ impl<'tcx> CommonTypes<'tcx> { // conflict. #[derive(Debug)] pub struct FreeRegionInfo { - // def id corresponding to FreeRegion + // The `DefId` corresponding to `FreeRegion`. pub def_id: DefId, - // the bound region corresponding to FreeRegion + // The bound region corresponding to `FreeRegion`. pub boundregion: ty::BoundRegion, - // checks if bound region is in Impl Item + // `true` if the bound region is in an impl item. pub is_impl_item: bool, } @@ -979,8 +980,8 @@ pub struct GlobalCtxt<'tcx> { /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, - /// Map indicating what traits are in scope for places where this - /// is relevant; generated by resolve. + /// Map indicating what traits are in scope for places where this is relevant; + /// generated by resolve. trait_map: FxHashMap>>>>, @@ -990,7 +991,7 @@ pub struct GlobalCtxt<'tcx> { hir_map: hir_map::Map<'tcx>, - /// A map from DefPathHash -> DefId. Includes DefIds from the local crate + /// A map from `DefPathHash` to `DefId`. Includes `DefId`s from the local crate /// as well as all upstream crates. Only populated in incremental mode. pub def_path_hash_to_def_id: Option>, @@ -1003,7 +1004,7 @@ pub struct GlobalCtxt<'tcx> { maybe_unused_trait_imports: FxHashSet, maybe_unused_extern_crates: Vec<(DefId, Span)>, - /// A map of glob use to a set of names it actually imports. Currently only + /// A map of glob use to a set of names it actually imports. Currently, only /// used in save-analysis. glob_map: FxHashMap>, /// Extern prelude entries. The value is `true` if the entry was introduced @@ -1031,7 +1032,7 @@ pub struct GlobalCtxt<'tcx> { stability_interner: Lock>, - /// Stores the value of constants (and deduplicates the actual memory) + /// Stores the value of constants (and deduplicates the actual memory). allocation_interner: Lock>, pub alloc_map: Lock>, @@ -1101,9 +1102,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }) } - /// Allocates a byte or string literal for `mir::interpret`, read-only + /// Allocates a byte or string literal for `mir::interpret`, read-only. pub fn allocate_bytes(self, bytes: &[u8]) -> interpret::AllocId { - // create an allocation that just contains these bytes + // Create an allocation that just contains these bytes. let alloc = interpret::Allocation::from_byte_aligned_bytes(bytes, ()); let alloc = self.intern_const_alloc(alloc); self.alloc_map.lock().allocate(alloc) @@ -1197,7 +1198,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { .chain(iter::once((LOCAL_CRATE, hir.definitions().def_path_table()))) }; - // Precompute the capacity of the hashmap so we don't have to + // Precompute the capacity of the hashmap so that we don't have to // re-allocate when populating it. let capacity = def_path_tables().map(|(_, t)| t.size()).sum::(); @@ -1296,7 +1297,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.get_lang_items(LOCAL_CRATE) } - /// Due to missing llvm support for lowering 128 bit math to software emulation + /// Due to missing LLVM support for lowering 128-bit math to software emulation /// (on some targets), the lowering can be done in MIR. /// /// This function only exists until said support is implemented. @@ -1354,7 +1355,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// `DefId` is really just an interned def-path). /// /// Note that if `id` is not local to this crate, the result will - /// be a non-local `DefPath`. + /// be a non-local `DefPath`. pub fn def_path(self, id: DefId) -> hir_map::DefPath { if id.is_local() { self.hir().def_path(id) @@ -1374,7 +1375,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn def_path_debug_str(self, def_id: DefId) -> String { // We are explicitly not going through queries here in order to get - // crate name and disambiguator since this code is called from debug!() + // crate name and disambiguator since this code is called from `debug!()` // statements within the query system and we'd run into endless // recursion otherwise. let (crate_name, crate_disambiguator) = if def_id.is_local() { @@ -1398,7 +1399,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } // Note that this is *untracked* and should only be used within the query - // system if the result is otherwise tracked through queries + // system if the result is otherwise tracked through queries. pub fn crate_data_as_rc_any(self, cnum: CrateNum) -> Lrc { self.cstore.crate_data_as_rc_any(cnum) } @@ -1413,28 +1414,29 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.cstore) } - // This method makes sure that we have a DepNode and a Fingerprint for + // This method makes sure that we have a `DepNode` and a `Fingerprint` for // every upstream crate. It needs to be called once right after the tcx is // created. // With full-fledged red/green, the method will probably become unnecessary // as this will be done on-demand. pub fn allocate_metadata_dep_nodes(self) { - // We cannot use the query versions of crates() and crate_hash(), since - // those would need the DepNodes that we are allocating here. + // We cannot use the query versions of `crates()` and `crate_hash()`, since + // those would need the `DepNode`s that we are allocating here. for cnum in self.cstore.crates_untracked() { let dep_node = DepNode::new(self, DepConstructor::CrateMetadata(cnum)); let crate_hash = self.cstore.crate_hash_untracked(cnum); self.dep_graph.with_task(dep_node, self, crate_hash, - |_, x| x, // No transformation needed + // No transformation needed. + |_, x| x, dep_graph::hash_result, ); } } - // This method exercises the `in_scope_traits_map` query for all possible - // values so that we have their fingerprints available in the DepGraph. + // Executes the `in_scope_traits_map` query for all possible values, + // so that we have their fingerprints available in the `DepGraph`. // This is only required as long as we still use the old dependency tracking // which needs to have the fingerprints of all input nodes beforehand. pub fn precompute_in_scope_traits_hashes(self) { @@ -1451,8 +1453,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.queries.on_disk_cache.serialize(self.global_tcx(), encoder) } - /// This checks whether one is allowed to have pattern bindings - /// that bind-by-move on a match arm that has a guard, e.g.: + /// Checks whether one is allowed to have pattern bindings that + /// bind-by-move on a match arm that has a guard, e.g., /// /// ```rust /// match foo { A(inner) if { /* something */ } => ..., ... } @@ -1465,8 +1467,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.features().bind_by_move_pattern_guards && self.use_mir_borrowck() } - /// If true, we should use a naive AST walk to determine if match - /// guard could perform bad mutations (or mutable-borrows). + /// Returns `true` if we should use a naive AST walk to determine if match + /// guard could perform bad mutations (or mutable borrows). pub fn check_for_mutation_in_guard_via_ast_walk(self) -> bool { // If someone requests the feature, then be a little more // careful and ensure that MIR-borrowck is enabled (which can @@ -1479,46 +1481,46 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { return true; } - /// If true, we should use the AST-based borrowck (we may *also* use + /// Returns `true` if we should use the AST-based borrowck (we may *also* use /// the MIR-based borrowck). pub fn use_ast_borrowck(self) -> bool { self.borrowck_mode().use_ast() } - /// If true, we should use the MIR-based borrowck (we may *also* use + /// Returns `true` if we should use the MIR-based borrowck (we may *also* use /// the AST-based borrowck). pub fn use_mir_borrowck(self) -> bool { self.borrowck_mode().use_mir() } - /// If true, we should use the MIR-based borrow check, but also + /// Returns `true` if we should use the MIR-based borrow check, but also /// fall back on the AST borrow check if the MIR-based one errors. pub fn migrate_borrowck(self) -> bool { self.borrowck_mode().migrate() } - /// If true, make MIR codegen for `match` emit a temp that holds a + /// Returns `true` if we should make MIR codegen for `match` emit a temp that holds a /// borrow of the input to the match expression. pub fn generate_borrow_of_any_match_input(&self) -> bool { self.emit_read_for_match() } - /// If true, make MIR codegen for `match` emit FakeRead - /// statements (which simulate the maximal effect of executing the - /// patterns in a match arm). + /// Returns `true` if we should make MIR codegen for `match` emit `FakeRead` + /// statements (which simulate the maximal effect of executing the patterns + /// in a match arm). pub fn emit_read_for_match(&self) -> bool { self.use_mir_borrowck() && !self.sess.opts.debugging_opts.nll_dont_emit_read_for_match } - /// If true, pattern variables for use in guards on match arms + /// Returns `true` if pattern variables for use in guards on match arms /// will be bound as references to the data, and occurrences of /// those variables in the guard expression will implicitly - /// dereference those bindings. (See rust-lang/rust#27282.) + /// dereference those bindings (see issue #27282). pub fn all_pat_vars_are_implicit_refs_within_guards(self) -> bool { self.borrowck_mode().use_mir() } - /// If true, we should enable two-phase borrows checks. This is + /// Returns `true` if we should enable two-phase borrows checks. This is /// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`, /// or by opting into an edition after 2015. pub fn two_phase_borrows(self) -> bool { @@ -1526,7 +1528,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.sess.opts.debugging_opts.two_phase_borrows } - /// What mode(s) of borrowck should we run? AST? MIR? both? + /// Checks what mode(s) of borrowck we should run (i.e., AST, MIR, or both). /// (Also considers the `#![feature(nll)]` setting.) pub fn borrowck_mode(&self) -> BorrowckMode { // Here are the main constraints we need to deal with: @@ -1587,7 +1589,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }) } - // This method returns the DefId and the BoundRegion corresponding to the given region. + // Returns the `DefId` and the `BoundRegion` corresponding to the given region. pub fn is_suitable_region(&self, region: Region<'tcx>) -> Option { let (suitable_region_binding_scope, bound_region) = match *region { ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region), @@ -1595,7 +1597,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.parent_def_id(ebr.def_id).unwrap(), ty::BoundRegion::BrNamed(ebr.def_id, ebr.name), ), - _ => return None, // not a free region + // Not a free region. + _ => return None, }; let node_id = self.hir() @@ -1620,18 +1623,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { &self, scope_def_id: DefId, ) -> Option> { - // HACK: `type_of_def_id()` will fail on these (#55796), so return None + // HACK: `type_of_def_id()` will fail on these (#55796), so return `None`. let node_id = self.hir().as_local_node_id(scope_def_id).unwrap(); match self.hir().get(node_id) { Node::Item(item) => { match item.node { - ItemKind::Fn(..) => { /* type_of_def_id() will work */ } - _ => { - return None; - } + // `type_of_def_id()` will work. + ItemKind::Fn(..) => (), + _ => return None, } } - _ => { /* type_of_def_id() will work or panic */ } + // `type_of_def_id()` will work or panic. + _ => (), } let ret_ty = self.type_of(scope_def_id); @@ -1649,7 +1652,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - // Here we check if the bound region is in Impl Item. + // Checks if the bound region is in impl item. pub fn is_bound_region_in_impl_item( &self, suitable_region_binding_scope: DefId, @@ -1663,7 +1666,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // change the fn signature, but they may not be free to do so, // since the signature must match the trait. // - // FIXME(#42706) -- in some cases, we could do better here. + // FIXME(#42706): in some cases, we could do better here. return true; } false @@ -1686,7 +1689,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'gcx> GlobalCtxt<'gcx> { /// Call the closure with a local `TyCtxt` using the given arena. - /// `interners` is a slot passed so we can create a CtxtInterners + /// `interners` is a slot passed so we can create a `CtxtInterner`s /// with the same lifetime as `arena`. pub fn enter_local<'tcx, F, R>( &'gcx self, @@ -1719,21 +1722,21 @@ impl<'gcx> GlobalCtxt<'gcx> { } } -/// A trait implemented for all X<'a> types which can be safely and -/// efficiently converted to X<'tcx> as long as they are part of the -/// provided TyCtxt<'tcx>. -/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx> +/// A trait implemented for all `X<'a>` types which can be safely and +/// efficiently converted to `X<'tcx>` as long as they are part of the +/// provided `TyCtxt<'tcx>`. +/// This can be done, for example, for `Ty<'tcx>` or `&'tcx Substs<'tcx>` /// by looking them up in their respective interners. /// /// However, this is still not the best implementation as it does /// need to compare the components, even for interned values. -/// It would be more efficient if TypedArena provided a way to +/// It would be more efficient if `TypedArena` provided a way to /// determine whether the address is in the allocated range. /// /// None is returned if the value or one of the components is not part /// of the provided context. -/// For Ty, None can be returned if either the type interner doesn't -/// contain the TyKind key or if the address of the interned +/// For `Ty`, `None` can be returned if either the type interner doesn't +/// contain the `TyKind` key or if the address of the interned /// pointer differs. The latter case is possible if a primitive type, /// e.g., `()` or `u8`, was interned in a different context. pub trait Lift<'tcx>: fmt::Debug { @@ -1796,7 +1799,7 @@ nop_list_lift!{Predicate<'a> => Predicate<'tcx>} nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo} nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>} -// this is the impl for `&'a Substs<'a>` +// This is the impl for `&'a Substs<'a>`. nop_list_lift!{Kind<'a> => Kind<'tcx>} impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { @@ -1829,35 +1832,35 @@ pub mod tls { use rustc_rayon_core as rayon_core; /// This is the implicit state of rustc. It contains the current - /// TyCtxt and query. It is updated when creating a local interner or - /// executing a new query. Whenever there's a TyCtxt value available - /// you should also have access to an ImplicitCtxt through the functions + /// `TyCtxt` and query. It is updated when creating a local interner or + /// executing a new query. Whenever there's a `TyCtxt` value available + /// you should also have access to an `ImplicitCtxt` through the functions /// in this module. #[derive(Clone)] pub struct ImplicitCtxt<'a, 'gcx: 'tcx, 'tcx> { - /// The current TyCtxt. Initially created by `enter_global` and updated - /// by `enter_local` with a new local interner + /// The current `TyCtxt`. Initially created by `enter_global` and updated + /// by `enter_local` with a new local interner. pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>, - /// The current query job, if any. This is updated by JobOwner::start in - /// ty::query::plumbing when executing a query + /// The current query job, if any. This is updated by `JobOwner::start` in + /// `ty::query::plumbing` when executing a query. pub query: Option>>, /// Where to store diagnostics for the current query job, if any. - /// This is updated by JobOwner::start in ty::query::plumbing when executing a query + /// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query. pub diagnostics: Option<&'a Lock>>, /// Used to prevent layout from recursing too deeply. pub layout_depth: usize, /// The current dep graph task. This is used to add dependencies to queries - /// when executing them + /// when executing them. pub task_deps: Option<&'a Lock>, } /// Sets Rayon's thread local variable which is preserved for Rayon jobs /// to `value` during the call to `f`. It is restored to its previous value after. - /// This is used to set the pointer to the new ImplicitCtxt. + /// This is used to set the pointer to the new `ImplicitCtxt`. #[cfg(parallel_compiler)] #[inline] fn set_tlv R, R>(value: usize, f: F) -> R { @@ -1865,20 +1868,20 @@ pub mod tls { } /// Gets Rayon's thread local variable which is preserved for Rayon jobs. - /// This is used to get the pointer to the current ImplicitCtxt. + /// This is used to get the pointer to the current `ImplicitCtxt`. #[cfg(parallel_compiler)] #[inline] fn get_tlv() -> usize { rayon_core::tlv::get() } - /// A thread local variable which stores a pointer to the current ImplicitCtxt + /// A thread local variable which stores a pointer to the current `ImplicitCtxt`. #[cfg(not(parallel_compiler))] thread_local!(static TLV: Cell = Cell::new(0)); /// Sets TLV to `value` during the call to `f`. /// It is restored to its previous value after. - /// This is used to set the pointer to the new ImplicitCtxt. + /// This is used to set the pointer to the new `ImplicitCtxt`. #[cfg(not(parallel_compiler))] #[inline] fn set_tlv R, R>(value: usize, f: F) -> R { @@ -1888,14 +1891,14 @@ pub mod tls { f() } - /// This is used to get the pointer to the current ImplicitCtxt. + /// This is used to get the pointer to the current `ImplicitCtxt`. #[cfg(not(parallel_compiler))] fn get_tlv() -> usize { TLV.with(|tlv| tlv.get()) } /// This is a callback from libsyntax as it cannot access the implicit state - /// in librustc otherwise + /// in librustc otherwise. fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { with_opt(|tcx| { if let Some(tcx) = tcx { @@ -1920,7 +1923,7 @@ pub mod tls { }) } - /// Sets up the callbacks from libsyntax on the current thread + /// Sets up the callbacks from libsyntax on the current thread. pub fn with_thread_locals(f: F) -> R where F: FnOnce() -> R { @@ -1945,7 +1948,7 @@ pub mod tls { }) } - /// Sets `context` as the new current ImplicitCtxt for the duration of the function `f` + /// Sets `context` as the new current `ImplicitCtxt` for the duration of the function `f`. #[inline] pub fn enter_context<'a, 'gcx: 'tcx, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'gcx, 'tcx>, f: F) -> R @@ -1956,19 +1959,19 @@ pub mod tls { }) } - /// Enters GlobalCtxt by setting up libsyntax callbacks and - /// creating a initial TyCtxt and ImplicitCtxt. - /// This happens once per rustc session and TyCtxts only exists + /// Enters `GlobalCtxt` by setting up libsyntax callbacks and + /// creating a initial `TyCtxt` and `ImplicitCtxt`. + /// This happens once per rustc session and `TyCtxts` only exists /// inside the `f` function. pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R where F: FnOnce(TyCtxt<'gcx, 'gcx, 'gcx>) -> R { with_thread_locals(|| { - // Update GCX_PTR to indicate there's a GlobalCtxt available + // Update `GCX_PTR` to indicate there's a `GlobalCtxt` available. GCX_PTR.with(|lock| { *lock.lock() = gcx as *const _ as usize; }); - // Set GCX_PTR back to 0 when we exit + // Set `GCX_PTR` back to `0` when we exit. let _on_drop = OnDrop(move || { GCX_PTR.with(|lock| *lock.lock() = 0); }); @@ -1991,12 +1994,11 @@ pub mod tls { }) } - /// Stores a pointer to the GlobalCtxt if one is available. - /// This is used to access the GlobalCtxt in the deadlock handler - /// given to Rayon. + /// Stores a pointer to the `GlobalCtxt` if one is available. + /// This is used to access the `GlobalCtxt` in the deadlock handler given to Rayon. scoped_thread_local!(pub static GCX_PTR: Lock); - /// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local. + /// Creates a `TyCtxt` and `ImplicitCtxt` based on the `GCX_PTR` thread local. /// This is used in the deadlock handler. pub unsafe fn with_global(f: F) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R @@ -2019,7 +2021,7 @@ pub mod tls { enter_context(&icx, |_| f(tcx)) } - /// Allows access to the current ImplicitCtxt in a closure if one is available + /// Allows access to the current `ImplicitCtxt` in a closure if one is available. #[inline] pub fn with_context_opt(f: F) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'gcx, 'tcx>>) -> R @@ -2028,16 +2030,16 @@ pub mod tls { if context == 0 { f(None) } else { - // We could get a ImplicitCtxt pointer from another thread. - // Ensure that ImplicitCtxt is Sync + // We could get a `ImplicitCtxt` pointer from another thread. + // Ensure that `ImplicitCtxt` is `Sync`. sync::assert_sync::>(); unsafe { f(Some(&*(context as *const ImplicitCtxt<'_, '_, '_>))) } } } - /// Allows access to the current ImplicitCtxt. - /// Panics if there is no ImplicitCtxt available + /// Allows access to the current `ImplicitCtxt`. + /// Panics if there is no `ImplicitCtxt` available. #[inline] pub fn with_context(f: F) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(&ImplicitCtxt<'a, 'gcx, 'tcx>) -> R @@ -2045,11 +2047,11 @@ pub mod tls { with_context_opt(|opt_context| f(opt_context.expect("no ImplicitCtxt stored in tls"))) } - /// Allows access to the current ImplicitCtxt whose tcx field has the same global - /// interner as the tcx argument passed in. This means the closure is given an ImplicitCtxt - /// with the same 'gcx lifetime as the TyCtxt passed in. - /// This will panic if you pass it a TyCtxt which has a different global interner from - /// the current ImplicitCtxt's tcx field. + /// Allows access to the current `ImplicitCtxt` whose `tcx` field has the same global + /// interner as the `tcx` argument passed in. This means the closure is given an `ImplicitCtxt` + /// with the same `'gcx` lifetime as the `TyCtxt` passed in. + /// This will panic if you pass it a `TyCtxt` which has a different global interner from + /// the current `ImplicitCtxt`'s `tcx` field. #[inline] pub fn with_related_context<'a, 'gcx, 'tcx1, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx1>, f: F) -> R where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R @@ -2063,11 +2065,12 @@ pub mod tls { }) } - /// Allows access to the current ImplicitCtxt whose tcx field has the same global - /// interner and local interner as the tcx argument passed in. This means the closure - /// is given an ImplicitCtxt with the same 'tcx and 'gcx lifetimes as the TyCtxt passed in. - /// This will panic if you pass it a TyCtxt which has a different global interner or - /// a different local interner from the current ImplicitCtxt's tcx field. + /// Allows access to the current `ImplicitCtxt` whose `tcx` field has the same global + /// interner and local interner as the `tcx` argument passed in. This means the closure + /// is given an `ImplicitCtxt` with the same `'tcx` and `'gcx` lifetimes as the `TyCtxt` + /// passed in. + /// Panics if you pass it a `TyCtxt` which has a different global interner or a different + /// local interner from the current `ImplicitCtxt`'s tcx field. #[inline] pub fn with_fully_related_context<'a, 'gcx, 'tcx, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx>, f: F) -> R where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R @@ -2082,8 +2085,8 @@ pub mod tls { }) } - /// Allows access to the TyCtxt in the current ImplicitCtxt. - /// Panics if there is no ImplicitCtxt available + /// Allows access to the `TyCtxt` in the current `ImplicitCtxt`. + /// Panics if there is no `ImplicitCtxt` available. #[inline] pub fn with(f: F) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R @@ -2091,8 +2094,8 @@ pub mod tls { with_context(|context| f(context.tcx)) } - /// Allows access to the TyCtxt in the current ImplicitCtxt. - /// The closure is passed None if there is no ImplicitCtxt available + /// Allows access to the `TyCtxt` in the current `ImplicitCtxt`. + /// The closure is passed `None` if there is no `ImplicitCtxt` available. #[inline] pub fn with_opt(f: F) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(Option>) -> R @@ -2103,8 +2106,7 @@ pub mod tls { macro_rules! sty_debug_print { ($ctxt: expr, $($variant: ident),*) => {{ - // curious inner module to allow variant names to be used as - // variable names. + // Curious inner module to allow variant names to be used as variable names. #[allow(non_snake_case)] mod inner { use crate::ty::{self, TyCtxt}; @@ -2129,7 +2131,8 @@ macro_rules! sty_debug_print { let variant = match t.sty { ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Str | ty::Never => continue, - ty::Error => /* unimportant */ continue, + // Unimportant. + ty::Error => continue, $(ty::$variant(..) => &mut $variant,)* }; let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER); @@ -2313,9 +2316,9 @@ macro_rules! intern_method { pub fn $method(self, v: $alloc) -> &$lt_tcx $ty { let key = ($alloc_to_key)(&v); - // HACK(eddyb) Depend on flags being accurate to + // HACK(eddyb): depend on flags being accurate to // determine that all contents are in the global tcx. - // See comments on Lift for why we can't use that. + // See comments on `Lift` for why we can't use that. if ($keep_in_local_tcx)(&v) { self.interners.$name.borrow_mut().intern_ref(key, || { // Make sure we don't end up with inference @@ -2330,12 +2333,12 @@ macro_rules! intern_method { }).0 } else { self.global_interners.$name.borrow_mut().intern_ref(key, || { - // This transmutes $alloc<'tcx> to $alloc<'gcx> + // This transmutes `$alloc<'tcx>` to `$alloc<'gcx>`. let v = unsafe { mem::transmute(v) }; let i: &$lt_tcx $ty = $alloc_method(&self.global_interners.arena, v); - // Cast to 'gcx + // Cast to `'gcx`. let i = unsafe { mem::transmute(i) }; Interned(i) }).0 @@ -2402,7 +2405,7 @@ slice_interners!( // This isn't a perfect fit: CanonicalVarInfo slices are always // allocated in the global arena, so this `intern_method!` macro is -// overly general. But we just return false for the code that checks +// overly general. But we just return false for the code that checks // whether they belong in the thread-local arena, so no harm done, and // seems better than open-coding the rest. intern_method! { @@ -2428,8 +2431,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } /// Given a closure signature `sig`, returns an equivalent `fn` - /// type with the same signature. Detuples and so forth -- so - /// e.g., if we have a sig with `Fn<(u32, i32)>` then you would get + /// type with the same signature. De-tuples, and so forth. + /// E.g., if we have a sig with `Fn<(u32, i32)>` then you would get /// a `fn(u32, i32)`. pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> { let converted_sig = sig.map_bound(|s| { @@ -2497,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { - // take a copy of substs so that we own the vectors inside + // Take a copy of `substs` so that we own the vectors inside. self.mk_ty(Adt(def, substs)) } @@ -2706,7 +2709,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) -> &'tcx List> { - // FIXME consider asking the input slice to be sorted to avoid + // FIXME: consider asking the input slice to be sorted to avoid // re-interning permutations, in which case that would be asserted // here. if preds.len() == 0 { @@ -2946,7 +2949,7 @@ pub trait InternAs { impl InternAs<[T], R> for I where E: InternIteratorElement, - I: Iterator { + I: Iterator { type Output = E::Output; fn intern_with(self, f: F) -> Self::Output where F: FnOnce(&[T]) -> R { @@ -2956,12 +2959,12 @@ impl InternAs<[T], R> for I pub trait InternIteratorElement: Sized { type Output; - fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output; + fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output; } impl InternIteratorElement for T { type Output = R; - fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { + fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { f(&iter.collect::>()) } } @@ -2970,14 +2973,14 @@ impl<'a, T, R> InternIteratorElement for &'a T where T: Clone + 'a { type Output = R; - fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { + fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { f(&iter.cloned().collect::>()) } } impl InternIteratorElement for Result { type Output = Result; - fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { + fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { Ok(f(&iter.collect::, _>>()?)) } } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e3e0ce147741f..3c0f5df8c5b82 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -252,7 +252,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if ty.is_closure() || ty.is_generator() { db.note("closures cannot capture themselves or take themselves as argument;\n\ this error may be the result of a recent compiler bug-fix,\n\ - see https://github.com/rust-lang/rust/issues/46062 for more details"); + see for more\n\ + details"); } } _ => {} diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 59ab4561f2c87..aa4498ad5a72a 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -171,7 +171,7 @@ impl<'a, 'gcx, D> HashStable> for SimplifiedTypeGen NeverSimplifiedType | ParameterSimplifiedType | MarkerTraitObjectSimplifiedType => { - // nothing to do + // Nothing to do. } IntSimplifiedType(t) => t.hash_stable(hcx, hasher), UintSimplifiedType(t) => t.hash_stable(hcx, hasher), diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index aa4d1e5ea90cb..a58ce3413b571 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -75,62 +75,73 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { fn has_type_flags(&self, flags: TypeFlags) -> bool { self.visit_with(&mut HasTypeFlagsVisitor { flags }) } + fn has_projections(&self) -> bool { self.has_type_flags(TypeFlags::HAS_PROJECTION) } + fn references_error(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_ERR) } + fn has_param_types(&self) -> bool { self.has_type_flags(TypeFlags::HAS_PARAMS) } + fn has_self_ty(&self) -> bool { self.has_type_flags(TypeFlags::HAS_SELF) } + fn has_infer_types(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_INFER) } + fn needs_infer(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_RE_INFER) } + fn has_placeholders(&self) -> bool { self.has_type_flags(TypeFlags::HAS_RE_PLACEHOLDER | TypeFlags::HAS_TY_PLACEHOLDER) } + fn needs_subst(&self) -> bool { self.has_type_flags(TypeFlags::NEEDS_SUBST) } + fn has_re_placeholders(&self) -> bool { self.has_type_flags(TypeFlags::HAS_RE_PLACEHOLDER) } + fn has_closure_types(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_CLOSURE) } + + /// Returns `true` if there are any free regions. /// "Free" regions in this context means that it has any region /// that is not (a) erased or (b) late-bound. fn has_free_regions(&self) -> bool { self.has_type_flags(TypeFlags::HAS_FREE_REGIONS) } - /// True if there are any un-erased free regions. + /// Returns `true` if there are any un-erased free regions. fn has_erasable_regions(&self) -> bool { self.has_type_flags(TypeFlags::HAS_FREE_REGIONS) } - /// Indicates whether this value references only 'global' + /// Returns `true` if this value references only 'global' /// types/lifetimes that are the same regardless of what fn we are /// in. This is used for caching. fn is_global(&self) -> bool { !self.has_type_flags(TypeFlags::HAS_FREE_LOCAL_NAMES) } - /// True if there are any late-bound regions + /// Returns `true` if there are any late-bound regions. fn has_late_bound_regions(&self) -> bool { self.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND) } /// A visitor that does not recurse into types, works like `fn walk_shallow` in `Ty`. fn visit_tys_shallow(&self, visit: impl FnMut(Ty<'tcx>) -> bool) -> bool { - pub struct Visitor(F); impl<'tcx, F: FnMut(Ty<'tcx>) -> bool> TypeVisitor<'tcx> for Visitor { @@ -345,13 +356,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// regions (aka "lifetimes") that are bound within a type are not /// visited by this folder; only regions that occur free will be /// visited by `fld_r`. - pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, skipped_regions: &'a mut bool, /// Stores the index of a binder *just outside* the stuff we have - /// visited. So this begins as INNERMOST; when we pass through a + /// visited. So this begins as `INNERMOST`; when we pass through a /// binder, it is incremented (via `shift_in`). current_index: ty::DebruijnIndex, @@ -410,7 +420,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> { /////////////////////////////////////////////////////////////////////////// // Bound vars replacer -/// Replaces the escaping bound vars (late bound regions or bound types) in a type. +/// Replaces the escaping bound vars (late-bound regions or bound types) in a type. struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, @@ -483,8 +493,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> let region = fld_r(br); if let ty::ReLateBound(debruijn1, br) = *region { // If the callback returns a late-bound region, - // that region should always use the INNERMOST - // debruijn index. Then we adjust it to the + // that region should always use the `INNERMOST` + // De Bruijn index. Then we adjust it to the // correct depth. assert_eq!(debruijn1, ty::INNERMOST); self.tcx.mk_region(ty::ReLateBound(debruijn, br)) @@ -507,7 +517,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// returned at the end with each bound region and the free region /// that replaced it. /// - /// This method only replaces late bound regions and the result may still + /// This method only replaces late-bound regions and the result may still /// contain escaping bound types. pub fn replace_late_bound_regions( self, @@ -887,9 +897,9 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector { } fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - // if we are only looking for "constrained" region, we have to + // If we are only looking for "constrained" region, we have to // ignore the inputs to a projection, as they may not appear - // in the normalized form + // in the normalized form. if self.just_constrained { match t.sty { ty::Projection(..) | ty::Opaque(..) => { return false; } diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 3b393c3ca15bb..e00508487583e 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { /// Calculate the intersection of a collection of forests. pub fn intersection(tcx: TyCtxt<'a, 'gcx, 'tcx>, iter: I) -> DefIdForest - where I: IntoIterator + where I: IntoIterator { let mut iter = iter.into_iter(); let mut ret = if let Some(first) = iter.next() { @@ -99,7 +99,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { /// Calculate the union of a collection of forests. pub fn union(tcx: TyCtxt<'a, 'gcx, 'tcx>, iter: I) -> DefIdForest - where I: IntoIterator + where I: IntoIterator { let mut ret = DefIdForest::empty(); let mut next_ret = SmallVec::new(); diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 5fc22e3c02b60..72564040cf9ba 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -411,7 +411,7 @@ fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind, Ok(false) } (ty::ClosureKind::Fn, ty::ClosureKind::FnMut) => { - // The closure fn `llfn` is a `fn(&self, ...)`. We want a + // The closure fn `llfn` is a `fn(&self, ...)`. We want a // `fn(&mut self, ...)`. In fact, at codegen time, these are // basically the same thing, so we can just return llfn. Ok(false) @@ -419,7 +419,7 @@ fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind, (ty::ClosureKind::Fn, ty::ClosureKind::FnOnce) | (ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => { // The closure fn `llfn` is a `fn(&self, ...)` or `fn(&mut - // self, ...)`. We want a `fn(self, ...)`. We can produce + // self, ...)`. We want a `fn(self, ...)`. We can produce // this by doing something like: // // fn call_once(self, ...) { call_mut(&self, ...) } diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 26e2705a7a034..934fc1d774c38 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -1,12 +1,13 @@ -use crate::hir::map::DefPathData; -use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use crate::ty::{self, DefIdTree, Ty, TyCtxt}; -use crate::middle::cstore::{ExternCrate, ExternCrateSource}; +use std::cell::Cell; +use std::fmt::Debug; + use syntax::ast; use syntax::symbol::{keywords, LocalInternedString, Symbol}; -use std::cell::Cell; -use std::fmt::Debug; +use crate::hir::map::DefPathData; +use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use crate::middle::cstore::{ExternCrate, ExternCrateSource}; +use crate::ty::{self, DefIdTree, Ty, TyCtxt}; thread_local! { static FORCE_ABSOLUTE: Cell = Cell::new(false); @@ -71,12 +72,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { buffer.into_string() } - /// Returns a string identifying this local node-id. + /// Returns a string identifying this local `NodeId`. pub fn node_path_str(self, id: ast::NodeId) -> String { self.item_path_str(self.hir().local_def_id(id)) } - /// Returns a string identifying this def-id. This string is + /// Returns a string identifying this `DefId`. This string is /// suitable for user output. It always begins with a crate identifier. pub fn absolute_item_path_str(self, def_id: DefId) -> String { let mut buffer = LocalPathBuffer::new(RootMode::Absolute); @@ -378,7 +379,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // Decide whether to print the parent path for the impl. // Logically, since impls are global, it's never needed, but // users may find it useful. Currently, we omit the parent if - // the impl is either in the same module as the self-type or + // the impl is either in the same module as the self type or // as the trait. let self_ty = self.type_of(impl_def_id); let in_self_mod = match characteristic_def_id_of_type(self_ty) { @@ -393,7 +394,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }; if !in_self_mod && !in_trait_mod { - // If the impl is not co-located with either self-type or + // If the impl is not co-located with either self type or // trait-type, then fallback to a format that identifies // the module more clearly. self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); @@ -415,7 +416,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } // Inherent impls. Try to print `Foo::bar` for an inherent - // impl on `Foo`, but fallback to `::bar` if self-type is + // impl on `Foo`, but fallback to `::bar` if self type is // anything other than a simple path. match self_ty.sty { ty::Adt(adt_def, substs) => { @@ -452,7 +453,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { where T: ItemPathBuffer + Debug { // If no type info is available, fall back to - // pretty printing some span information. This should + // pretty-printing some span information. This should // only occur very early in the compiler pipeline. let parent_def_id = self.parent_def_id(impl_def_id).unwrap(); self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 6c507c0015d7b..1b89d04dac816 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -750,7 +750,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { // A variant is absent if it's uninhabited and only has ZST fields. // Present uninhabited variants only require space for their fields, - // but *not* an encoding of the discriminant (e.g., a tag value). + // but **not** an encoding of the discriminant (e.g., a tag value). // See issue #49298 for more details on the need to leave space // for non-ZST uninhabited data (mostly partial initialization). let absent = |fields: &[TyLayout<'_>]| { @@ -1370,7 +1370,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { } ty::Adt(def, substs) => { - // Only newtypes and enums w/ nullable pointer optimization. + // Only newtypes and enums with nullable pointer optimization. if def.is_union() || def.variants.is_empty() || def.variants.len() > 2 { return Err(err); } @@ -1780,9 +1780,9 @@ impl Niche { } impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { - /// Find the offset of a niche leaf field, starting from + /// Finds the offset of a niche leaf field, starting from /// the given type and recursing through aggregates. - // FIXME(eddyb) traverse already optimized enums. + // FIXME(eddyb): traverse already optimized enums. fn find_niche(&self, layout: TyLayout<'tcx>) -> Result, LayoutError<'tcx>> { let scalar_niche = |scalar: &Scalar, offset| { let Scalar { value, valid_range: ref v } = *scalar; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 18dba3092ad5a..6ad25f23c54c2 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -196,13 +196,13 @@ impl AssociatedItem { } /// Tests whether the associated item admits a non-trivial implementation - /// for ! + /// for `!`. pub fn relevant_for_never<'tcx>(&self) -> bool { match self.kind { AssociatedKind::Existential | AssociatedKind::Const | AssociatedKind::Type => true, - // FIXME(canndrew): Be more thorough here, check if any argument is uninhabited. + // FIXME(canndrew): be more thorough here, check if any argument is uninhabited. AssociatedKind::Method => !self.method_has_self_argument, } } @@ -212,7 +212,7 @@ impl AssociatedItem { ty::AssociatedKind::Method => { // We skip the binder here because the binder would deanonymize all // late-bound regions, and we don't want method signatures to show up - // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound + // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound // regions just fine, showing `fn(&MyType)`. tcx.fn_sig(self.def_id).skip_binder().to_string() } @@ -302,7 +302,7 @@ impl Visibility { self.is_accessible_from(vis_restriction, tree) } - // Returns `true` if this item is visible anywhere in the local crate. + // Returns whether this item is visible anywhere in the local crate. pub fn is_visible_locally(self) -> bool { match self { Visibility::Public => true, @@ -430,7 +430,7 @@ bitflags! { const HAS_TY_ERR = 1 << 7; const HAS_PROJECTION = 1 << 8; - // FIXME: Rename this to the actual property since it's used for generators too + // FIXME: rename this to the actual property since it's used for generators too const HAS_TY_CLOSURE = 1 << 9; // `true` if there are "names" of types and regions and so forth @@ -442,7 +442,7 @@ bitflags! { const KEEP_IN_LOCAL_TCX = 1 << 11; // Is there a projection that does not involve a bound region? - // Currently we can't normalize projections w/ bound regions. + // Currently we can't normalize projections with bound regions. const HAS_NORMALIZABLE_PROJECTION = 1 << 12; /// Does this have any `ReLateBound` regions? Used to check @@ -823,7 +823,7 @@ impl ty::EarlyBoundRegion { ty::BoundRegion::BrNamed(self.def_id, self.name) } - /// Does this early bound region have a name? Early bound regions normally + /// Does this early-bound region have a name? Early-bound regions normally /// always have names except when using anonymous lifetimes (`'_`). pub fn has_name(&self) -> bool { self.name != keywords::UnderscoreLifetime.name().as_interned_str() @@ -863,7 +863,7 @@ impl GenericParamDef { name: self.name, } } else { - bug!("cannot convert a non-lifetime parameter def to an early bound region") + bug!("cannot convert a non-lifetime parameter def to an early-bound region") } } @@ -871,7 +871,7 @@ impl GenericParamDef { if let GenericParamDefKind::Lifetime = self.kind { self.to_early_bound_region_data().to_bound_region() } else { - bug!("cannot convert a non-lifetime parameter def to an early bound region") + bug!("cannot convert a non-lifetime parameter def to an early-bound region") } } } @@ -1118,7 +1118,7 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> { // // In terms of why this is sound, the idea is that whenever there // is an impl of `T:Foo<'a>`, it must show that `T:Bar<'a,'a>` - // holds. So if there is an impl of `T:Foo<'a>` that applies to + // holds. So if there is an impl of `T:Foo<'a>` that applies to // all `'a`, then we must know that `T:Bar<'a,'a>` holds for all // `'a`. // @@ -1130,7 +1130,7 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> { // Here, if we have `for<'x> T: Foo1<'x>`, then what do we know? // The answer is that we know `for<'x,'b> T: Bar1<'x,'b>`. The // reason is similar to the previous example: any impl of - // `T:Foo1<'x>` must show that `for<'b> T: Bar1<'x, 'b>`. So + // `T:Foo1<'x>` must show that `for<'b> T: Bar1<'x, 'b>`. So // basically we would want to collapse the bound lifetimes from // the input (`trait_ref`) and the supertraits. // @@ -1198,7 +1198,7 @@ impl<'tcx> TraitPredicate<'tcx> { self.trait_ref.def_id } - pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { + pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { self.trait_ref.input_types() } @@ -1209,14 +1209,14 @@ impl<'tcx> TraitPredicate<'tcx> { impl<'tcx> PolyTraitPredicate<'tcx> { pub fn def_id(&self) -> DefId { - // ok to skip binder since trait def-id does not care about regions + // Ok to skip binder since trait `DefId` does not care about regions. self.skip_binder().def_id() } } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] -pub struct OutlivesPredicate(pub A, pub B); // `A: B` -pub type PolyOutlivesPredicate = ty::Binder>; +pub struct OutlivesPredicate(pub A, pub B); // `A: B` +pub type PolyOutlivesPredicate = ty::Binder>; pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate, ty::Region<'tcx>>; pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate, @@ -1277,7 +1277,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> { /// Note that this is not the `DefId` of the `TraitRef` containing this /// associated type, which is in `tcx.associated_item(projection_def_id()).container`. pub fn projection_def_id(&self) -> DefId { - // okay to skip binder since trait def-id does not care about regions + // ok to skip binder since trait `DefId` does not care about regions self.skip_binder().projection_ty.item_def_id } } @@ -1958,7 +1958,7 @@ bitflags! { const IS_C = 1 << 0; const IS_SIMD = 1 << 1; const IS_TRANSPARENT = 1 << 2; - // Internal only for now. If true, don't reorder fields. + // Internal only for now. If set, then don't reorder fields. const IS_LINEAR = 1 << 3; // Any of these flags being set prevent field reordering optimisation. @@ -2269,7 +2269,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { }; match tcx.const_eval(param_env.and(cid)) { Ok(val) => { - // FIXME: Find the right type and use it instead of `val.ty` here + // FIXME: find the right type and use it instead of `val.ty` here if let Some(b) = val.assert_bits(tcx.global_tcx(), param_env.and(val.ty)) { trace!("discriminants: {} ({:?})", b, repr_type); Some(Discr { @@ -2399,7 +2399,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { Foreign(..) | Error | GeneratorWitness(..) => { - // these are never sized - return the target type + // These are never sized; return the target type. vec![ty] } @@ -2411,7 +2411,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { } Adt(adt, substs) => { - // recursive case + // Recursive case. let adt_tys = adt.sized_constraint(tcx); debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys); @@ -2422,7 +2422,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { } Projection(..) | Opaque(..) => { - // must calculate explicitly. + // Must calculate explicitly. // FIXME: consider special-casing always-Sized projections vec![ty] } @@ -2430,7 +2430,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { UnnormalizedProjection(..) => bug!("only used with chalk-engine"), Param(..) => { - // perf hack: if there is a `T: Sized` bound, then + // Performance hack: if there is a `T: Sized` bound, then // we know that `T` is Sized and do not need to check // it on the impl. @@ -2476,9 +2476,9 @@ impl<'a, 'gcx, 'tcx> FieldDef { /// `tcx.closure_env_ty()`. #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] pub enum ClosureKind { - // Warning: Ordering is significant here! The ordering is chosen - // because the trait Fn is a subtrait of FnMut and so in turn, and - // hence we order it so that Fn < FnMut < FnOnce. + // Warning: ordering is significant here! The ordering is chosen + // because the trait `Fn` is a subtrait of `FnMut` and so in turn, and + // hence we order it so that `Fn < FnMut < FnOnce`. Fn, FnMut, FnOnce, @@ -2682,10 +2682,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { e.span } Some(f) => { - bug!("Node id {} is not an expr: {:?}", id, f); + bug!("`NodeId` {} is not an expr: {:?}", id, f); } None => { - bug!("Node id {} is not present in the node map", id); + bug!("`NodeId` {} is not present in the node map", id); } } } @@ -2709,7 +2709,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { _ => false, } } else { - match self.describe_def(def_id).expect("no def for def-id") { + match self.describe_def(def_id).expect("no def for `DefId`") { Def::AssociatedConst(_) | Def::Method(_) | Def::AssociatedTy(_) => true, _ => false, } @@ -2872,16 +2872,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - /// Given a `VariantDef`, returns the def-id of the `AdtDef` of which it is a part. + /// Given a `VariantDef`, returns the `DefId` of the `AdtDef` of which it is a part. pub fn adt_def_id_of_variant(self, variant_def: &'tcx VariantDef) -> DefId { let def_key = self.def_key(variant_def.did); match def_key.disambiguated_data.data { - // for enum variants and tuple structs, the def-id of the ADT itself - // is the *parent* of the variant + // For enum variants and tuple structs, the `DefId` of the ADT itself + // is the *parent* of the variant. DefPathData::EnumVariant(..) | DefPathData::StructCtor => DefId { krate: variant_def.did.krate, index: def_key.parent.unwrap() }, - // otherwise, for structs and unions, they share a def-id + // Otherwise, for structs and unions, they share a `DefId`. _ => variant_def.did, } } @@ -2891,7 +2891,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.original_crate_name(id.krate).as_interned_str() } else { let def_key = self.def_key(id); - // The name of a StructCtor is that of its struct parent. + // The name of a `StructCtor` is that of its struct parent. if let hir_map::DefPathData::StructCtor = def_key.disambiguated_data.data { self.item_name(DefId { krate: id.krate, @@ -3151,17 +3151,17 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> { - // The param_env of an impl Trait type is its defining function's param_env + // The `ParamEnv` of an `impl Trait` type is its defining function's `ParamEnv`. if let Some(parent) = is_impl_trait_defn(tcx, def_id) { return param_env(tcx, parent); } - // Compute the bounds on Self and the type parameters. + // Compute the bounds on `Self` and the type parameters. let InstantiatedPredicates { predicates } = tcx.predicates_of(def_id).instantiate_identity(tcx); @@ -3248,7 +3248,7 @@ fn issue33140_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return None; } - // impl must be `impl Trait for dyn Marker1 + Marker2 + ...` + // Impl must be `impl Trait for dyn Marker1 + Marker2 + ...`. if trait_ref.substs.len() != 1 { debug!("issue33140_self_ty - impl has substs!"); return None; @@ -3310,7 +3310,7 @@ pub struct CrateInherentImpls { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable)] pub struct SymbolName { - // FIXME: we don't rely on interning or equality here - better have + // FIXME: we don't rely on interning or equality here -- better have // this be a `&'tcx str`. pub name: InternedString } diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index 5b21ed5abd77b..703edc1df9c3a 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -105,7 +105,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { out.push(Component::Projection(*data)); } else { // fallback case: hard code - // OutlivesProjectionComponents. Continue walking + // OutlivesProjectionComponents. Continue walking // through and constrain Pi. let subcomponents = self.capture_components(ty); out.push(Component::EscapingProjection(subcomponents)); @@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::Error => { // (*) Bare functions and traits are both binders. In the // RFC, this means we would add the bound regions to the - // "bound regions list". In our representation, no such + // "bound regions list". In our representation, no such // list is maintained explicitly, because bound regions // themselves can be readily identified. diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 1870812893c14..3bae60673bd01 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -68,7 +68,7 @@ pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { } } -impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M { +impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M { default fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { if !tcx.sess.verbose() { format!("processing `{}`", tcx.item_path_str(def_id)).into() @@ -745,7 +745,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::named_region_map<'tcx> { impl<'tcx> QueryDescription<'tcx> for queries::is_late_bound_map<'tcx> { fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { - "testing if a region is late bound".into() + "testing if a region is late-bound".into() } } diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 22211468412c1..089e090ac07b4 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -87,9 +87,9 @@ impl<'tcx> QueryJob<'tcx> { condvar: Condvar::new(), }); self.latch.r#await(&waiter); - // FIXME: Get rid of this lock. We have ownership of the QueryWaiter + // FIXME: get rid of this lock. We have ownership of the `QueryWaiter`. // although another thread may still have a Lrc reference so we cannot - // use Lrc::get_mut + // use `Lrc::get_mut`. let mut cycle = waiter.cycle.lock(); match cycle.take() { None => Ok(()), @@ -104,7 +104,7 @@ impl<'tcx> QueryJob<'tcx> { tcx: TyCtxt<'_, 'tcx, 'lcx>, span: Span, ) -> CycleError<'tcx> { - // Get the current executing query (waiter) and find the waitee amongst its parents + // Get the current executing query (waiter) and find the waitee amongst its parents. let mut current_job = tls::with_related_context(tcx, |icx| icx.query.clone()); let mut cycle = Vec::new(); @@ -114,12 +114,12 @@ impl<'tcx> QueryJob<'tcx> { if ptr::eq(&*job, self) { cycle.reverse(); - // This is the end of the cycle + // This is the end of the cycle. // The span entry we included was for the usage // of the cycle itself, and not part of the cycle - // Replace it with the span which caused the cycle to form + // Replace it with the span which caused the cycle to form. cycle[0].span = span; - // Find out why the cycle itself was used + // Find out why the cycle itself was used. let usage = job.parent.as_ref().map(|parent| { (job.info.span, parent.info.query.clone()) }); @@ -196,13 +196,13 @@ impl<'tcx> QueryLatch<'tcx> { // If this detects a deadlock and the deadlock handler wants to resume this thread // we have to be in the `wait` call. This is ensured by the deadlock handler - // getting the self.info lock. + // getting the `self.info` lock. rayon_core::mark_blocked(); waiter.condvar.wait(&mut info); } } - /// Sets the latch and resumes all waiters on it + /// Sets the latch and resumes all waiters on it. fn set(&self) { let mut info = self.info.lock(); debug_assert!(!info.complete); @@ -221,12 +221,13 @@ impl<'tcx> QueryLatch<'tcx> { ) -> Lrc> { let mut info = self.info.lock(); debug_assert!(!info.complete); - // Remove the waiter from the list of waiters + // Remove the waiter from the list of waiters. info.waiters.remove(waiter) } } -/// A resumable waiter of a query. The usize is the index into waiters in the query's latch +/// Represents a resumable waiter of a query. The `usize` is the index into waiters in the query's +/// latch. #[cfg(parallel_compiler)] type Waiter<'tcx> = (Lrc>, usize); @@ -238,24 +239,24 @@ type Waiter<'tcx> = (Lrc>, usize); /// For visits of non-resumable waiters it returns the return value of `visit`. /// For visits of resumable waiters it returns Some(Some(Waiter)) which has the /// required information to resume the waiter. -/// If all `visit` calls returns None, this function also returns None. +/// If all `visit` calls return `None`, this function also returns `None`. #[cfg(parallel_compiler)] fn visit_waiters<'tcx, F>(query: Lrc>, mut visit: F) -> Option>> where F: FnMut(Span, Lrc>) -> Option>> { - // Visit the parent query which is a non-resumable waiter since it's on the same stack + // Visit the parent query which is a non-resumable waiter since it's on the same stack. if let Some(ref parent) = query.parent { if let Some(cycle) = visit(query.info.span, parent.clone()) { return Some(cycle); } } - // Visit the explicit waiters which use condvars and are resumable + // Visit the explicit waiters which use condvars and are resumable. for (i, waiter) in query.latch.info.lock().waiters.iter().enumerate() { if let Some(ref waiter_query) = waiter.query { if visit(waiter.span, waiter_query.clone()).is_some() { - // Return a value which indicates that this waiter can be resumed + // Return a value which indicates that this waiter can be resumed. return Some(Some((query.clone(), i))); } } @@ -275,11 +276,11 @@ fn cycle_check<'tcx>(query: Lrc>, ) -> Option>> { if !visited.insert(query.as_ptr()) { return if let Some(p) = stack.iter().position(|q| q.1.as_ptr() == query.as_ptr()) { - // We detected a query cycle, fix up the initial span and return Some + // We detected a query cycle, fix up the initial span and return `Some`. - // Remove previous stack entries + // Remove previous stack entries. stack.drain(0..p); - // Replace the span for the first query with the cycle cause + // Replace the span for the first query with the cycle cause. stack[0].0 = span; Some(None) } else { @@ -287,15 +288,15 @@ fn cycle_check<'tcx>(query: Lrc>, } } - // Query marked as visited is added it to the stack + // Add the query marked as visited to the stack. stack.push((span, query.clone())); - // Visit all the waiters + // Visit all the waiters. let r = visit_waiters(query, |span, successor| { cycle_check(successor, span, stack, visited) }); - // Remove the entry in our stack if we didn't find a cycle + // Remove the entry in our stack if we didn't find a cycle. if r.is_none() { stack.pop(); } @@ -311,12 +312,12 @@ fn connected_to_root<'tcx>( query: Lrc>, visited: &mut FxHashSet<*const QueryJob<'tcx>> ) -> bool { - // We already visited this or we're deliberately ignoring it + // We already visited this or we're deliberately ignoring it. if !visited.insert(query.as_ptr()) { return false; } - // This query is connected to the root (it has no query parent), return true + // This query is connected to the root (it has no query parent); return `true`. if query.parent.is_none() { return true; } @@ -330,23 +331,23 @@ fn connected_to_root<'tcx>( }).is_some() } -// Deterministically pick an query from a list +// Deterministically picks an query from a list. #[cfg(parallel_compiler)] fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc>)>( tcx: TyCtxt<'_, 'tcx, '_>, queries: &'a [T], f: F ) -> &'a T { - // Deterministically pick an entry point - // FIXME: Sort this instead + // Deterministically pick an entry point. + // FIXME: sort this instead. let mut hcx = tcx.create_stable_hashing_context(); queries.iter().min_by_key(|v| { let (span, query) = f(v); let mut stable_hasher = StableHasher::::new(); query.info.query.hash_stable(&mut hcx, &mut stable_hasher); - // Prefer entry points which have valid spans for nicer error messages + // Prefer entry points which have valid spans for nicer error messages. // We add an integer to the tuple ensuring that entry points - // with valid spans are picked first + // with valid spans are picked first. let span_cmp = if span == DUMMY_SP { 1 } else { 0 }; (span_cmp, stable_hasher.finish()) }).unwrap() @@ -365,22 +366,22 @@ fn remove_cycle<'tcx>( ) -> bool { let mut visited = FxHashSet::default(); let mut stack = Vec::new(); - // Look for a cycle starting with the last query in `jobs` + // Look for a cycle starting with the last query in `jobs`. if let Some(waiter) = cycle_check(jobs.pop().unwrap(), DUMMY_SP, &mut stack, &mut visited) { // The stack is a vector of pairs of spans and queries; reverse it so that - // the earlier entries require later entries + // the earlier entries require later entries. let (mut spans, queries): (Vec<_>, Vec<_>) = stack.into_iter().rev().unzip(); - // Shift the spans so that queries are matched with the span for their waitee + // Shift the spans so that queries are matched with the span for their waitee. spans.rotate_right(1); - // Zip them back together + // Zip them back together. let mut stack: Vec<_> = spans.into_iter().zip(queries).collect(); - // Remove the queries in our cycle from the list of jobs to look at + // Remove the queries in our cycle from the list of jobs to look at. for r in &stack { if let Some(pos) = jobs.iter().position(|j| j.as_ptr() == r.1.as_ptr()) { jobs.remove(pos); @@ -388,16 +389,16 @@ fn remove_cycle<'tcx>( } // Find the queries in the cycle which are - // connected to queries outside the cycle + // connected to queries outside the cycle. let entry_points = stack.iter().filter_map(|(span, query)| { if query.parent.is_none() { - // This query is connected to the root (it has no query parent) + // This query is connected to the root (it has no query parent). Some((*span, query.clone(), None)) } else { let mut waiters = Vec::new(); - // Find all the direct waiters who lead to the root + // Find all the direct waiters who lead to the root. visit_waiters(query.clone(), |span, waiter| { - // Mark all the other queries in the cycle as already visited + // Mark all the other queries in the cycle as already visited. let mut visited = FxHashSet::from_iter(stack.iter().map(|q| q.1.as_ptr())); if connected_to_root(waiter.clone(), &mut visited) { @@ -409,17 +410,17 @@ fn remove_cycle<'tcx>( if waiters.is_empty() { None } else { - // Deterministically pick one of the waiters to show to the user + // Deterministically pick one of the waiters to show to the user. let waiter = pick_query(tcx, &waiters, |s| s.clone()).clone(); Some((*span, query.clone(), Some(waiter))) } } }).collect::>, Option<(Span, Lrc>)>)>>(); - // Deterministically pick an entry point + // Deterministically pick an entry point. let (_, entry_point, usage) = pick_query(tcx, &entry_points, |e| (e.0, e.1.clone())); - // Shift the stack so that our entry point is first + // Shift the stack so that our entry point is first. let entry_point_pos = stack.iter().position(|(_, query)| { query.as_ptr() == entry_point.as_ptr() }); @@ -429,7 +430,7 @@ fn remove_cycle<'tcx>( let usage = usage.as_ref().map(|(span, query)| (*span, query.info.query.clone())); - // Create the cycle error + // Create the cycle error. let mut error = CycleError { usage, cycle: stack.iter().map(|&(s, ref q)| QueryInfo { @@ -439,16 +440,16 @@ fn remove_cycle<'tcx>( }; // We unwrap `waiter` here since there must always be one - // edge which is resumeable / waited using a query latch + // edge which is resumeable / waited using a query latch. let (waitee_query, waiter_idx) = waiter.unwrap(); - // Extract the waiter we want to resume + // Extract the waiter we want to resume. let waiter = waitee_query.latch.extract_waiter(waiter_idx); - // Set the cycle error so it will be picked up when resumed + // Set the cycle error so it will be picked up when resumed. *waiter.cycle.lock() = Some(error); - // Put the waiter on the list of things to resume + // Put the waiter on the list of things to resume. wakelist.push(waiter); true @@ -526,7 +527,7 @@ fn deadlock(tcx: TyCtxt<'_, '_, '_>, registry: &rayon_core::Registry) { // only considers the true dependency and won't detect a cycle. assert!(found_cycle); - // FIXME: Ensure this won't cause a deadlock before we return + // FIXME: ensure this won't cause a deadlock before we return. for waiter in wakelist.into_iter() { waiter.notify(registry); } diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 740875109d029..29cd7e09b7a06 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -168,44 +168,43 @@ define_queries! { <'tcx> DefId ) -> Result, NoSolution>, - /// True if this is a const fn, use the `is_const_fn` to know whether your crate actually - /// sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have - /// the feature gate active) + /// Returns `true` if this is a const fn. Use `is_const_fn` to know whether your crate + /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might + /// not have the feature gate active). /// /// **Do not call this function manually.** It is only meant to cache the base data for the /// `is_const_fn` function. [] fn is_const_fn_raw: IsConstFn(DefId) -> bool, - - /// Returns true if calls to the function may be promoted + /// Returns `true` if calls to the function may be promoted. /// - /// This is either because the function is e.g., a tuple-struct or tuple-variant + /// This is either because the function is e.g., a tuple struct or tuple variant /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should /// be removed in the future in favour of some form of check which figures out whether the /// function does not inspect the bits of any of its arguments (so is essentially just a /// constructor function). [] fn is_promotable_const_fn: IsPromotableConstFn(DefId) -> bool, - /// True if this is a foreign item (i.e., linked via `extern { ... }`). + /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`). [] fn is_foreign_item: IsForeignItem(DefId) -> bool, - /// Get a map with the variance of every item; use `item_variance` + /// Gets a map with the variance of every item; use `item_variance` /// instead. [] fn crate_variances: crate_variances(CrateNum) -> Lrc, - /// Maps from def-id of a type or region parameter to its + /// Maps from `DefId` of a type or region parameter to its /// (inferred) variance. [] fn variances_of: ItemVariances(DefId) -> Lrc>, }, TypeChecking { - /// Maps from def-id of a type to its (inferred) outlives. + /// Maps from `DefId` of a type to its (inferred) outlives. [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum) -> Lrc>, }, Other { - /// Maps from an impl/trait def-id to a list of the def-ids of its items + /// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc>, /// Maps from a trait item to the trait item "descriptor" diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index c16f861dedb50..54e6a156747c9 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -1,3 +1,18 @@ +use std::mem; + +use errors::Diagnostic; +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::thin_vec::ThinVec; +use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once}; +use rustc_data_structures::indexed_vec::{IndexVec, Idx}; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque, + SpecializedDecoder, SpecializedEncoder, + UseSpecializedDecodable, UseSpecializedEncodable}; +use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile}; +use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo}; +use syntax::ast::NodeId; +use syntax::source_map::{SourceMap, StableSourceFileId}; + use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; use crate::hir; use crate::hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; @@ -5,26 +20,12 @@ use crate::hir::map::definitions::DefPathHash; use crate::ich::{CachingSourceMapView, Fingerprint}; use crate::mir::{self, interpret}; use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState}; -use crate::rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque, - SpecializedDecoder, SpecializedEncoder, - UseSpecializedDecodable, UseSpecializedEncodable}; use crate::session::{CrateDisambiguator, Session}; use crate::ty; use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; use crate::ty::context::TyCtxt; use crate::util::common::time; -use errors::Diagnostic; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::thin_vec::ThinVec; -use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once}; -use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use std::mem; -use syntax::ast::NodeId; -use syntax::source_map::{SourceMap, StableSourceFileId}; -use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile}; -use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo}; - const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE; const TAG_CLEAR_CROSS_CRATE_CLEAR: u8 = 0; @@ -248,13 +249,13 @@ impl<'sess> OnDiskCache<'sess> { Ok(()) })?; - // Encode diagnostics + // Encode diagnostics. let diagnostics_index: EncodedDiagnosticsIndex = self.current_diagnostics.borrow() .iter() .map(|(dep_node_index, diagnostics)| { let pos = AbsoluteBytePos::new(encoder.position()); - // Let's make sure we get the expected type here: + // Let's make sure we get the expected type here. let diagnostics: &EncodedDiagnostics = diagnostics; let dep_node_index = SerializedDepNodeIndex::new(dep_node_index.index()); encoder.encode_tagged(dep_node_index, diagnostics)?; @@ -268,9 +269,9 @@ impl<'sess> OnDiskCache<'sess> { let mut n = 0; loop { let new_n = encoder.interpret_allocs_inverse.len(); - // if we have found new ids, serialize those, too + // If we have found new IDs, serialize those too. if n == new_n { - // otherwise, abort + // Otherwise, abort. break; } interpret_alloc_index.reserve(new_n - n); @@ -296,7 +297,7 @@ impl<'sess> OnDiskCache<'sess> { (cnum.as_u32(), crate_name, crate_disambiguator) }).collect(); - // Encode the file footer + // Encode the file footer. let footer_pos = encoder.position() as u64; encoder.encode_tagged(TAG_FILE_FOOTER, &Footer { file_index_to_stable_id, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 37cb6753ed5b2..3636957e6618e 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -2,31 +2,29 @@ //! generate the actual methods on tcx which find and execute the provider, //! manage the caches, and so forth. -use crate::dep_graph::{DepNodeIndex, DepNode, DepKind, SerializedDepNodeIndex}; -use crate::ty::tls; -use crate::ty::{TyCtxt}; -use crate::ty::query::Query; -use crate::ty::query::config::{QueryConfig, QueryDescription}; -use crate::ty::query::job::{QueryJob, QueryResult, QueryInfo}; -use crate::ty::item_path; - -use crate::util::common::{profq_msg, ProfileQueriesMsg, QueryMsg}; +use std::mem; +use std::ptr; +use std::collections::hash_map::Entry; -use errors::DiagnosticBuilder; -use errors::Level; -use errors::Diagnostic; -use errors::FatalError; +use errors::{Diagnostic, DiagnosticBuilder, FatalError, Level}; use rustc_data_structures::fx::{FxHashMap}; use rustc_data_structures::sync::{Lrc, Lock}; use rustc_data_structures::thin_vec::ThinVec; #[cfg(not(parallel_compiler))] use rustc_data_structures::cold_path; -use std::mem; -use std::ptr; -use std::collections::hash_map::Entry; + use syntax_pos::Span; use syntax::source_map::DUMMY_SP; +use crate::dep_graph::{DepNodeIndex, DepNode, DepKind, SerializedDepNodeIndex}; +use crate::ty::tls; +use crate::ty::{TyCtxt}; +use crate::ty::query::Query; +use crate::ty::query::config::{QueryConfig, QueryDescription}; +use crate::ty::query::job::{QueryJob, QueryResult, QueryInfo}; +use crate::ty::item_path; +use crate::util::common::{profq_msg, ProfileQueriesMsg, QueryMsg}; + pub struct QueryCache<'tcx, D: QueryConfig<'tcx> + ?Sized> { pub(super) results: FxHashMap>, pub(super) active: FxHashMap>, @@ -61,7 +59,7 @@ impl<'tcx, M: QueryConfig<'tcx>> Default for QueryCache<'tcx, M> { } } -// If enabled, send a message to the profile-queries thread +// If enabled, sends a message to the profile-queries thread. macro_rules! profq_msg { ($tcx:expr, $msg:expr) => { if cfg!(debug_assertions) { @@ -72,7 +70,7 @@ macro_rules! profq_msg { } } -// If enabled, format a key using its debug string, which can be +// If enabled, formats a key using its debug string, which can be // expensive to compute (in terms of time). macro_rules! profq_query_msg { ($query:expr, $tcx:expr, $key:expr) => {{ @@ -162,14 +160,14 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { mem::drop(lock); // If we are single-threaded we know that we have cycle error, - // so we just return the error + // so we just return the error. #[cfg(not(parallel_compiler))] return TryGetJob::Cycle(cold_path(|| { Q::handle_cycle_error(tcx, job.find_cycle_in_stack(tcx, span)) })); // With parallel queries we might just have to wait on some other - // thread + // thread. #[cfg(parallel_compiler)] { let result = job.r#await(tcx, span); @@ -186,12 +184,12 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { /// signals the waiter and forgets the JobOwner, so it won't poison the query #[inline(always)] pub(super) fn complete(self, result: &Q::Value, dep_node_index: DepNodeIndex) { - // We can move out of `self` here because we `mem::forget` it below + // We can move out of `self` here because we `mem::forget` it below. let key = unsafe { ptr::read(&self.key) }; let job = unsafe { ptr::read(&self.job) }; let cache = self.cache; - // Forget ourself so our destructor won't poison the query + // Forget ourself so our destructor won't poison the query. mem::forget(self); let value = QueryValue::new(result.clone(), dep_node_index); @@ -219,17 +217,16 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> Drop for JobOwner<'a, 'tcx, Q> { #[inline(never)] #[cold] fn drop(&mut self) { - // Poison the query so jobs waiting on it panic + // Poison the query so jobs waiting on it panic. self.cache.borrow_mut().active.insert(self.key.clone(), QueryResult::Poisoned); - // Also signal the completion of the job, so waiters - // will continue execution + // Also signal the completion of the job, so waiters will continue execution. self.job.signal_complete(); } } #[derive(Clone)] pub struct CycleError<'tcx> { - /// The query and related span which uses the cycle + /// The query and related span which uses the cycle. pub(super) usage: Option<(Span, Query<'tcx>)>, pub(super) cycle: Vec>, } @@ -262,11 +259,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { where F: for<'b, 'lcx> FnOnce(TyCtxt<'b, 'gcx, 'lcx>) -> R { - // The TyCtxt stored in TLS has the same global interner lifetime - // as `self`, so we use `with_related_context` to relate the 'gcx lifetimes - // when accessing the ImplicitCtxt + // The `TyCtxt` stored in TLS has the same global interner lifetime + // as `self`, so we use `with_related_context` to relate the `'gcx` lifetimes + // when accessing the `ImplicitCtxt`. tls::with_related_context(self, move |current_icx| { - // Update the ImplicitCtxt to point to our new query job + // Update the `ImplicitCtxt` to point to our new query job. let new_icx = tls::ImplicitCtxt { tcx: self.global_tcx(), query: Some(job), @@ -275,7 +272,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { task_deps: current_icx.task_deps, }; - // Use the ImplicitCtxt while we execute the query + // Use the `ImplicitCtxt` while we execute the query. tls::enter_context(&new_icx, |_| { compute(self.global_tcx()) }) @@ -379,8 +376,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } }; - // Fast path for when incr. comp. is off. `to_dep_node` is - // expensive for some DepKinds. + // Fast path for when incrimental compilation is off. `to_dep_node` is + // expensive for some `DepKind`s. if !self.dep_graph.is_fully_enabled() { let null_dep_node = DepNode::new_no_params(crate::dep_graph::DepKind::Null); return self.force_query_with_job::(key, job, null_dep_node).0; @@ -418,7 +415,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if !dep_node.kind.is_input() { // The diagnostics for this query will be // promoted to the current session during - // try_mark_green(), so we can ignore them here. + // `try_mark_green()`, so we can ignore them here. let loaded = self.start_query(job.job.clone(), None, |tcx| { let marked = tcx.dep_graph.try_mark_green_and_read(tcx, &dep_node); marked.map(|(prev_dep_node_index, dep_node_index)| { @@ -450,11 +447,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ) -> Q::Value { // Note this function can be called concurrently from the same query - // We must ensure that this is handled correctly + // We must ensure that this is handled correctly. debug_assert!(self.dep_graph.is_green(dep_node)); - // First we try to load the result from the on-disk cache + // First, we try to load the result from the on-disk cache let result = if Q::cache_on_disk(self.global_tcx(), key.clone()) && self.sess.opts.debugging_opts.incremental_queries { self.sess.profiler(|p| p.incremental_load_result_start(Q::NAME)); @@ -462,7 +459,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.sess.profiler(|p| p.incremental_load_result_end(Q::NAME)); // We always expect to find a cached result for things that - // can be forced from DepNode. + // can be forced from `DepNode`. debug_assert!(!dep_node.kind.can_reconstruct_query_key() || result.is_some(), "Missing on-disk cache entry for {:?}", @@ -484,8 +481,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.sess.profiler(|p| p.start_query(Q::NAME, Q::CATEGORY)); - // The dep-graph for this computation is already in - // place + // The dep-graph for this computation is already in place. let result = self.dep_graph.with_ignore(|| { Q::compute(self, key) }); @@ -494,7 +490,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { result }; - // If -Zincremental-verify-ich is specified, re-hash results from + // If `-Zincremental-verify-ich` is specified, re-hash results from // the cache and make sure that they have the expected fingerprint. if unlikely!(self.sess.opts.debugging_opts.incremental_verify_ich) { self.incremental_verify_ich::(&result, dep_node, dep_node_index); @@ -542,10 +538,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { dep_node: DepNode) -> (Q::Value, DepNodeIndex) { // If the following assertion triggers, it can have two reasons: - // 1. Something is wrong with DepNode creation, either here or - // in DepGraph::try_mark_green() - // 2. Two distinct query keys get mapped to the same DepNode - // (see for example #48923) + // 1. Something is wrong with `DepNode` creation, either here or + // in `DepGraph::try_mark_green()`. + // 2. Two distinct query keys get mapped to the same `DepNode` + // (see for example #48923). assert!(!self.dep_graph.dep_node_exists(&dep_node), "Forcing query with already existing DepNode.\n\ - query-key: {:?}\n\ @@ -592,24 +588,24 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { (result, dep_node_index) } - /// Ensure that either this query has all green inputs or been executed. - /// Executing query::ensure(D) is considered a read of the dep-node D. + /// Ensures that either this query has all green inputs or been executed. + /// Executing `query::ensure(D)` is considered a read of the dep-node `D`. /// /// This function is particularly useful when executing passes for their - /// side-effects -- e.g., in order to report errors for erroneous programs. + /// side-effects (e.g., in order to report errors for erroneous programs.) /// - /// Note: The optimization is only available during incr. comp. + /// Note: the optimization is only available during incremental compilation. pub(super) fn ensure_query>(self, key: Q::Key) -> () { let dep_node = Q::to_dep_node(self, &key); - // Ensuring an "input" or anonymous query makes no sense + // Ensuring an "input" or anonymous query makes no sense. assert!(!dep_node.kind.is_anon()); assert!(!dep_node.kind.is_input()); if self.dep_graph.try_mark_green_and_read(self, &dep_node).is_none() { - // A None return from `try_mark_green_and_read` means that this is either + // A `None` returned from `try_mark_green_and_read` means that this is either // a new dep node or that the dep node has already been marked red. // Either way, we can't call `dep_graph.read()` as we don't have the - // DepNodeIndex. We must invoke the query itself. The performance cost + // `DepNodeIndex`. We must invoke the query itself. The performance cost // this introduces should be negligible as we'll immediately hit the // in-memory cache, or another query down the line will. @@ -632,8 +628,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ProfileQueriesMsg::QueryBegin(span.data(), profq_query_msg!(Q::NAME, self, key)) ); - // We may be concurrently trying both execute and force a query - // Ensure that only one of them runs the query + // We may be concurrently trying both execute and force a query. + // Ensure that only one of them runs the query. let job = match JobOwner::try_get(self, span, &key) { TryGetJob::NotYetStarted(job) => job, TryGetJob::Cycle(_) | @@ -738,8 +734,8 @@ macro_rules! define_queries_inner { pub fn collect_active_jobs(&self) -> Vec>> { let mut jobs = Vec::new(); - // We use try_lock here since we are only called from the - // deadlock handler, and this shouldn't be locked + // We use `try_lock` here since we are only called from the + // deadlock handler, and this shouldn't be locked. $( jobs.extend( self.$name.try_lock().unwrap().active.values().filter_map(|v| @@ -877,13 +873,13 @@ macro_rules! define_queries_inner { } } - // FIXME(eddyb) Get more valid Span's on queries. + // FIXME(eddyb): get more valid Span's on queries. pub fn default_span(&self, tcx: TyCtxt<'_, $tcx, '_>, span: Span) -> Span { if !span.is_dummy() { return span; } - // The def_span query is used to calculate default_span, - // so exit to avoid infinite recursion + // The `def_span` query is used to calculate `default_span`, + // so exit to avoid infinite recursion. if let Query::def_span(..) = *self { return span } @@ -954,7 +950,7 @@ macro_rules! define_queries_inner { fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value { __query_compute::$name(move || { let provider = tcx.queries.providers.get(key.query_crate()) - // HACK(eddyb) it's possible crates may be loaded after + // HACK(eddyb): it's possible crates may be loaded after // the query engine is created, and because crate loading // is not yet integrated with the query engine, such crates // would be missing appropriate entries in `providers`. @@ -1089,23 +1085,22 @@ macro_rules! define_provider_struct { }; } - -/// The red/green evaluation system will try to mark a specific DepNode in the +/// The red/green evaluation system will try to mark a specific `DepNode` in the /// dependency graph as green by recursively trying to mark the dependencies of -/// that DepNode as green. While doing so, it will sometimes encounter a DepNode +/// that `DepNode` as green. While doing so, it will sometimes encounter a `DepNode` /// where we don't know if it is red or green and we therefore actually have /// to recompute its value in order to find out. Since the only piece of -/// information that we have at that point is the DepNode we are trying to +/// information that we have at that point is the `DepNode` we are trying to /// re-evaluate, we need some way to re-run a query from just that. This is what /// `force_from_dep_node()` implements. /// -/// In the general case, a DepNode consists of a DepKind and an opaque +/// In the general case, a `DepNode` consists of a `DepKind` and an opaque /// GUID/fingerprint that will uniquely identify the node. This GUID/fingerprint /// is usually constructed by computing a stable hash of the query-key that the /// DepNode corresponds to. Consequently, it is not in general possible to go /// back from hash to query-key (since hash functions are not reversible). For /// this reason `force_from_dep_node()` is expected to fail from time to time -/// because we just cannot find out, from the DepNode alone, what the +/// because we just cannot find out, from the `DepNode` alone, what the /// corresponding query-key is and therefore cannot re-run the query. /// /// The system deals with this case letting `try_mark_green` fail which forces @@ -1137,9 +1132,9 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, -> bool { use crate::hir::def_id::LOCAL_CRATE; - // We must avoid ever having to call force_from_dep_node() for a - // DepNode::CodegenUnit: - // Since we cannot reconstruct the query key of a DepNode::CodegenUnit, we + // We must avoid ever having to call `force_from_dep_node()` for a + // `DepNode::CodegenUnit`: + // Since we cannot reconstruct the query key of a `DepNode::CodegenUnit`, we // would always end up having to evaluate the first caller of the // `codegen_unit` query that *is* reconstructible. This might very well be // the `compile_codegen_unit` query, thus re-codegenning the whole CGU just @@ -1162,7 +1157,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, if let Some(def_id) = dep_node.extract_def_id(tcx) { def_id } else { - // return from the whole function + // Return from the whole function. return false } } @@ -1180,22 +1175,20 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, } }; - // FIXME(#45015): We should try move this boilerplate code into a macro - // somehow. + // FIXME(#45015): we should try move this boilerplate code into a macro somehow. match dep_node.kind { // These are inputs that are expected to be pre-allocated and that - // should therefore always be red or green already + // should therefore always be red or green already. DepKind::AllLocalTraitImpls | DepKind::Krate | DepKind::CrateMetadata | DepKind::HirBody | DepKind::Hir | - // This are anonymous nodes + // These are anonymous nodes. DepKind::TraitSelect | - // We don't have enough information to reconstruct the query key of - // these + // We don't have enough information to reconstruct the query key of these. DepKind::IsCopy | DepKind::IsSized | DepKind::IsFreeze | @@ -1233,12 +1226,12 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::InstanceDefSizeEstimate | DepKind::ProgramClausesForEnv | - // This one should never occur in this context + // This one should never occur in this context. DepKind::Null => { bug!("force_from_dep_node() - Encountered {:?}", dep_node) } - // These are not queries + // These are not queries. DepKind::CoherenceCheckTrait | DepKind::ItemVarianceConstraints => { return false @@ -1437,13 +1430,13 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, } -// FIXME(#45015): Another piece of boilerplate code that could be generated in -// a combined define_dep_nodes!()/define_queries!() macro. +// FIXME(#45015): another piece of boilerplate code that could be generated in +// a combined `define_dep_nodes!()` / `define_queries!()` macro. macro_rules! impl_load_from_cache { ($($dep_kind:ident => $query_name:ident,)*) => { impl DepNode { // Check whether the query invocation corresponding to the given - // DepNode is eligible for on-disk-caching. + // `DepNode` is eligible for on-disk-caching. pub fn cache_on_disk(&self, tcx: TyCtxt<'_, '_, '_>) -> bool { use crate::ty::query::queries; use crate::ty::query::QueryDescription; @@ -1458,7 +1451,7 @@ macro_rules! impl_load_from_cache { } // This is method will execute the query corresponding to the given - // DepNode. It is only expected to work for DepNodes where the + // `DepNode`. It is only expected to work for `DepNode`s where the // above `cache_on_disk` methods returns true. // Also, as a sanity check, it expects that the corresponding query // invocation has been marked as green already. diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index db248072d9b50..803507a3c078e 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -259,7 +259,7 @@ impl<'tcx> Relate<'tcx> for Vec> { { // To be compatible, `a` and `b` must be for precisely the // same set of traits and item names. We always require that - // projection bounds lists are sorted by trait-def-id and item-name, + // projection bounds lists are sorted by trait `DefId` and item-name, // so we can just iterate through the lists pairwise, so long as they are the // same length. if a.len() != b.len() { @@ -421,7 +421,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, &ty::Generator(b_id, b_substs, _)) if a_id == b_id => { - // All Generator types with the same id represent + // All Generator types with the same ID represent // the (anonymous) type of the same generator expression. So // all of their regions should be equated. let substs = relation.relate(&a_substs, &b_substs)?; @@ -443,8 +443,8 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, &ty::Closure(b_id, b_substs)) if a_id == b_id => { - // All Closure types with the same id represent - // the (anonymous) type of the same closure expression. So + // All closure types with the same ID represent + // the (anonymous) type of the same closure expression, so // all of their regions should be equated. let substs = relation.relate(&a_substs, &b_substs)?; Ok(tcx.mk_closure(a_id, substs)) @@ -471,7 +471,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, let to_u64 = |x: ty::LazyConst<'tcx>| -> Result { match x { ty::LazyConst::Unevaluated(def_id, substs) => { - // FIXME(eddyb) get the right param_env. + // FIXME(eddyb): get the right param_env. let param_env = ty::ParamEnv::empty(); if let Some(substs) = tcx.lift_to_global(&substs) { let instance = ty::Instance::resolve( diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 66efd2aea155a..16689399ad559 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -68,8 +68,8 @@ impl BoundRegion { } /// When canonicalizing, we replace unbound inference variables and free - /// regions with anonymous late bound regions. This method asserts that - /// we have an anonymous late bound region, which hence may refer to + /// regions with anonymous late-bound regions. This method asserts that + /// we have an anonymous late-bound region, which hence may refer to /// a canonical variable. pub fn assert_bound_var(&self) -> BoundVar { match *self { @@ -336,7 +336,7 @@ impl<'tcx> ClosureSubsts<'tcx> { #[inline] pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_, '_>) -> - impl Iterator> + 'tcx + impl Iterator> + 'tcx { let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { @@ -420,7 +420,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { #[inline] pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_, '_>) -> - impl Iterator> + 'tcx + impl Iterator> + 'tcx { let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { @@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> GeneratorSubsts<'tcx> { self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>, - ) -> impl Iterator> + Captures<'gcx> + 'a { + ) -> impl Iterator> + Captures<'gcx> + 'a { let state = tcx.generator_layout(def_id).fields.iter(); state.map(move |d| d.ty.subst(tcx, self.substs)) } @@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> GeneratorSubsts<'tcx> { /// is available before the generator transformation. /// It includes the upvars and the state discriminant which is u32. pub fn pre_transforms_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> - impl Iterator> + 'a + impl Iterator> + 'a { self.upvar_tys(def_id, tcx).chain(iter::once(tcx.types.u32)) } @@ -487,7 +487,7 @@ impl<'a, 'gcx, 'tcx> GeneratorSubsts<'tcx> { /// This is the types of all the fields stored in a generator. /// It includes the upvars, state types and the state discriminant which is u32. pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> - impl Iterator> + Captures<'gcx> + 'a + impl Iterator> + Captures<'gcx> + 'a { self.pre_transforms_tys(def_id, tcx).chain(self.state_tys(def_id, tcx)) } @@ -502,7 +502,7 @@ pub enum UpvarSubsts<'tcx> { impl<'tcx> UpvarSubsts<'tcx> { #[inline] pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_, '_>) -> - impl Iterator> + 'tcx + impl Iterator> + 'tcx { let upvar_kinds = match self { UpvarSubsts::Closure(substs) => substs.split(def_id, tcx).upvar_kinds, @@ -608,7 +608,7 @@ impl<'tcx> List> { #[inline] pub fn projection_bounds<'a>(&'a self) -> - impl Iterator> + 'a { + impl Iterator> + 'a { self.iter().filter_map(|predicate| { match *predicate { ExistentialPredicate::Projection(p) => Some(p), @@ -618,7 +618,7 @@ impl<'tcx> List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { self.iter().filter_map(|predicate| { match *predicate { ExistentialPredicate::AutoTrait(d) => Some(d), @@ -639,17 +639,17 @@ impl<'tcx> Binder<&'tcx List>> { #[inline] pub fn projection_bounds<'a>(&'a self) -> - impl Iterator> + 'a { + impl Iterator> + 'a { self.skip_binder().projection_bounds().map(Binder::bind) } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { self.skip_binder().auto_traits() } pub fn iter<'a>(&'a self) - -> impl DoubleEndedIterator>> + 'tcx { + -> impl DoubleEndedIterator>> + 'tcx { self.skip_binder().iter().cloned().map(Binder::bind) } } @@ -746,7 +746,7 @@ pub struct ExistentialTraitRef<'tcx> { } impl<'a, 'gcx, 'tcx> ExistentialTraitRef<'tcx> { - pub fn input_types<'b>(&'b self) -> impl DoubleEndedIterator> + 'b { + pub fn input_types<'b>(&'b self) -> impl DoubleEndedIterator> + 'b { // Select only the "input types" from a trait-reference. For // now this is all the types that appear in the // trait-reference, but it should eventually exclude @@ -1533,7 +1533,7 @@ impl RegionKind { /// /// ``` /// impl<'a> Foo { - /// ^^ -- early bound, declared on an impl + /// ^^ -- early-bound, declared on an impl /// /// fn bar<'b, 'c>(x: &self, y: &'b u32, z: &'c u64) where 'static: 'c /// ^^ ^^ ^ anonymous, late-bound @@ -1591,7 +1591,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } ty::Adt(def, _) => { // Any ADT is uninhabited if either: - // (a) It has no variants (i.e. an empty `enum`); + // (a) It has no variants (i.e., an empty `enum`); // (b) Each of its variants (a single one in the case of a `struct`) has at least // one uninhabited field. def.variants.iter().all(|var| { diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 1ba7c3bba797c..5e706958c1f29 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -36,7 +36,7 @@ impl<'tcx> fmt::Display for Discr<'tcx> { Integer::from_attr(&tcx, SignedInt(ity)).size().bits() }); let x = self.val as i128; - // sign extend the raw representation to be an i128 + // Sign-extend the raw representation to be an `i128`. let x = (x << (128 - bits)) >> (128 - bits); write!(fmt, "{}", x) }, @@ -75,7 +75,7 @@ impl<'tcx> Discr<'tcx> { } else { val + n }; - // zero the upper bits + // Zero the upper bits. let val = val as u128; let val = (val << shift) >> shift; (Self { @@ -178,7 +178,7 @@ impl<'tcx> ty::ParamEnv<'tcx> { tcx: TyCtxt<'a, 'tcx, 'tcx>, self_type: Ty<'tcx>) -> Result<(), CopyImplementationError<'tcx>> { - // FIXME: (@jroesch) float this code up + // FIXME(jroesch): float this code up. tcx.infer_ctxt().enter(|infcx| { let (adt, substs) = match self_type.sty { // These types used to have a builtin impl. @@ -231,8 +231,8 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { let mut hasher = StableHasher::new(); let mut hcx = self.create_stable_hashing_context(); - // We want the type_id be independent of the types free regions, so we - // erase them. The erase_regions() call will also anonymize bound + // We want the `type_id` to be independent of the types free regions, so we + // erase them. The `erase_regions()` call will also anonymize bound // regions, which is desirable too. let ty = self.erase_regions(&ty); @@ -369,9 +369,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { None } ty::Predicate::TypeOutlives(predicate) => { - // Search for a bound of the form `erased_self_ty - // : 'a`, but be wary of something like `for<'a> - // erased_self_ty : 'a` (we interpret a + // Search for a bound of the form `erased_self_ty: 'a`, + // but be wary of something like `for<'a> + // erased_self_ty: 'a` (we interpret a // higher-ranked bound like that as 'static, // though at present the code in `fulfill.rs` // considers such bounds to be unsatisfiable, so @@ -452,8 +452,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let impl_def_id = self.associated_item(dtor).container.id(); let impl_generics = self.generics_of(impl_def_id); - // We have a destructor - all the parameters that are not - // pure_wrt_drop (i.e, don't have a #[may_dangle] attribute) + // We have a destructor -- all the parameters that are not + // pure_wrt_drop (i.e, don't have a `#[may_dangle]` attribute) // must be live. // We need to return the list of parameters from the ADTs @@ -495,7 +495,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { !impl_generics.type_param(pt, self).pure_wrt_drop } UnpackedKind::Lifetime(_) | UnpackedKind::Type(_) => { - // not a type or region param - this should be reported + // Not a type or region param; this should be reported // as an error. false } @@ -771,15 +771,15 @@ impl<'a, 'tcx> ty::TyS<'tcx> { } } - /// Check whether a type is representable. This means it cannot contain unboxed + /// Checks whether a type is representable. This means it cannot contain unboxed /// structural recursion. This check is needed for structs and enums. pub fn is_representable(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span) -> Representability { - // Iterate until something non-representable is found - fn fold_repr>(iter: It) -> Representability { + // Iterate until something non-representable is found. + fn fold_repr>(iter: It) -> Representability { iter.fold(Representability::Representable, |r1, r2| { match (r1, r2) { (Representability::SelfRecursive(v1), @@ -800,18 +800,18 @@ impl<'a, 'tcx> ty::TyS<'tcx> { { match ty.sty { Tuple(ref ts) => { - // Find non representable + // Find non-representable. fold_repr(ts.iter().map(|ty| { is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty) })) } // Fixed-length vectors. - // FIXME(#11924) Behavior undecided for zero-length vectors. + // FIXME(#11924): behavior undecided for zero-length vectors. Array(ty, _) => { is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty) } Adt(def, substs) => { - // Find non representable fields with their spans + // Find non-representable fields with their spans. fold_repr(def.all_fields().map(|field| { let ty = field.ty(tcx, substs); let span = tcx.hir().span_if_local(field.did).unwrap_or(sp); @@ -826,8 +826,8 @@ impl<'a, 'tcx> ty::TyS<'tcx> { })) } Closure(..) => { - // this check is run on type definitions, so we don't expect - // to see closure types + // This check is run on type definitions, so we don't expect + // to see closure types. bug!("requires check invoked on inapplicable type: {:?}", ty) } _ => Representability::Representable, @@ -880,12 +880,13 @@ impl<'a, 'tcx> ty::TyS<'tcx> { let mut iter = seen.iter(); // The first item in `seen` is the type we are actually curious about. - // We want to return SelfRecursive if this type contains itself. - // It is important that we DON'T take generic parameters into account - // for this check, so that Bar in this example counts as SelfRecursive: + // We want to return `SelfRecursive` if this type contains itself. + // It is important that we *don't* take generic parameters into account + // for this check, so that `Bar` in this example counts as + // `SelfRecursive`: // - // struct Foo; - // struct Bar { x: Bar } + // struct Foo; + // struct Bar { x: Bar } if let Some(&seen_type) = iter.next() { if same_struct_or_enum(seen_type, def) { @@ -1008,28 +1009,28 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, assert!(!ty.needs_infer()); NeedsDrop(match ty.sty { - // Fast-path for primitive types + // Fast-path for primitive types. ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) | ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never | ty::FnDef(..) | ty::FnPtr(_) | ty::Char | ty::GeneratorWitness(..) | ty::RawPtr(_) | ty::Ref(..) | ty::Str => false, - // Foreign types can never have destructors + // Foreign types can never have destructors. ty::Foreign(..) => false, // `ManuallyDrop` doesn't have a destructor regardless of field types. ty::Adt(def, _) if Some(def.did) == tcx.lang_items().manually_drop() => false, - // Issue #22536: We first query `is_copy_modulo_regions`. It sees a + // Issue #22536: we first query `is_copy_modulo_regions`. It sees a // normalized version of the type, and therefore will definitely // know whether the type implements Copy (and thus needs no // cleanup/drop/zeroing) ... _ if ty.is_copy_modulo_regions(tcx, param_env, DUMMY_SP) => false, - // ... (issue #22536 continued) but as an optimization, still use - // prior logic of asking for the structural "may drop". + // ... but as an optimization, still use the prior logic of asking for + // the structural "may drop". - // FIXME(#22815): Note that this is a conservative heuristic; + // FIXME(#22815): note that this is a conservative heuristic; // it may report that the type "may drop" when actual type does // not actually have a destructor associated with it. But since // the type absolutely did not have the `Copy` bound attached @@ -1039,7 +1040,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::Adt(def, _) if def.has_dtor(tcx) => true, // Can refer to a type which may drop. - // FIXME(eddyb) check this against a ParamEnv. + // FIXME(eddyb): check this against a `ParamEnv`. ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Bound(..) | ty::Placeholder(..) | ty::Opaque(..) | ty::Infer(_) | ty::Error => true, @@ -1051,13 +1052,13 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::Closure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop), // Pessimistically assume that all generators will require destructors - // as we don't know if a destructor is a noop or not until after the MIR - // state transformation pass + // as we don't know if a destructor is a no-op or not until after the MIR + // state transformation pass. ty::Generator(..) => true, ty::Tuple(ref tys) => tys.iter().cloned().any(needs_drop), - // unions don't have destructors because of the child types, + // Unions don't have destructors because of the child types, // only if they manually implement `Drop` (handled above). ty::Adt(def, _) if def.is_union() => false, diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 282bf1219fa5c..45c961edd0921 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -32,12 +32,13 @@ pub fn obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, debug!("wf::obligations({:?}, body_id={:?}) ~~> {:?}", ty, body_id, result); Some(result) } else { - None // no progress made, return None + // No progress made; return `None`. + None } } /// Returns the obligations that make this trait reference -/// well-formed. For example, if there is a trait `Set` defined like +/// well-formed. For example, if there is a trait `Set` defined like /// `trait Set`, then the trait reference `Foo: Set` is WF /// if `Bar: Eq`. pub fn trait_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, @@ -61,7 +62,7 @@ pub fn predicate_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, { let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![] }; - // (*) ok to skip binders, because wf code is prepared for it + // (*) ok to skip binders, because WF code is prepared for it. match *predicate { ty::Predicate::Trait(ref t) => { wf.compute_trait_ref(&t.skip_binder().trait_ref, Elaborate::None); // (*) @@ -189,7 +190,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { /// into `self.out`. fn compute_projection(&mut self, data: ty::ProjectionTy<'tcx>) { // A projection is well-formed if (a) the trait ref itself is - // WF and (b) the trait-ref holds. (It may also be + // WF and (b) the trait-ref holds. (It may also be // normalizable and be WF that way.) let trait_ref = data.trait_ref(self.infcx.tcx); self.compute_trait_ref(&trait_ref, Elaborate::None); @@ -375,9 +376,9 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { // regions. This is perhaps not ideal. self.from_object_ty(ty, data, r); - // FIXME(#27579) RFC also considers adding trait - // obligations that don't refer to Self and - // checking those + // FIXME(#27579): RFC also considers adding trait + // obligations that don't refer to `Self` and + // checking those. let cause = self.cause(traits::MiscObligation); let component_traits = @@ -395,7 +396,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { // know what type they are. We do two things: // // 1. Check if they have been resolved, and if so proceed with - // THAT type. + // _that_ type. // 2. If not, check whether this is the type that we // started with (ty0). In that case, we've made no // progress at all, so return false. Otherwise, @@ -480,7 +481,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { // `Foo<'x>+Bar<'y>`, we know that the type outlives *both* 'x and // 'y.) // - // Note: in fact we only permit builtin traits, not `Bar<'d>`, I + // Note: in fact, we only permit builtin traits, not `Bar<'d>`, I // am looking forward to the future here. if !data.has_escaping_bound_vars() { diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index dd635e5c946f0..7344592c469d6 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -17,7 +17,7 @@ use crate::dep_graph::{DepNode}; use lazy_static; use crate::session::Session; -// The name of the associated type for `Fn` return types +// The name of the associated type for `Fn` return types. pub const FN_OUTPUT_NAME: &str = "Output"; // Useful type to use with `Result<>` indicate that an error has already @@ -44,16 +44,16 @@ fn panic_hook(info: &panic::PanicInfo<'_>) { TyCtxt::try_print_query_stack(); } - #[cfg(windows)] - unsafe { - if env::var("RUSTC_BREAK_ON_ICE").is_ok() { - extern "system" { - fn DebugBreak(); - } - // Trigger a debugger if we crashed during bootstrap - DebugBreak(); + #[cfg(windows)] + unsafe { + if env::var("RUSTC_BREAK_ON_ICE").is_ok() { + extern "system" { + fn DebugBreak(); } + // Trigger a debugger if we crashed during bootstrap. + DebugBreak(); } + } } pub fn install_panic_hook() { @@ -79,42 +79,42 @@ pub struct QueryMsg { } /// A sequence of these messages induce a trace of query-based incremental compilation. -/// FIXME(matthewhammer): Determine whether we should include cycle detection here or not. +// FIXME(matthewhammer): determine whether we should include cycle detection here or not. #[derive(Clone,Debug)] pub enum ProfileQueriesMsg { - /// begin a timed pass + /// Begin a timed pass. TimeBegin(String), - /// end a timed pass + /// End a timed pass. TimeEnd, - /// begin a task (see dep_graph::graph::with_task) + /// Begin a task (see `dep_graph::graph::with_task`). TaskBegin(DepNode), - /// end a task + /// End a task. TaskEnd, - /// begin a new query - /// can't use `Span` because queries are sent to other thread + /// Begin a new query. + /// Cannot use `Span` because queries are sent to other thread. QueryBegin(SpanData, QueryMsg), - /// query is satisfied by using an already-known value for the given key + /// Query is satisfied by using an already-known value for the given key. CacheHit, - /// query requires running a provider; providers may nest, permitting queries to nest. + /// Query requires running a provider; providers may nest, permitting queries to nest. ProviderBegin, - /// query is satisfied by a provider terminating with a value + /// Query is satisfied by a provider terminating with a value. ProviderEnd, - /// dump a record of the queries to the given path + /// Dump a record of the queries to the given path. Dump(ProfQDumpParams), - /// halt the profiling/monitoring background thread + /// Halt the profiling/monitoring background thread. Halt } -/// If enabled, send a message to the profile-queries thread +/// If enabled, send a message to the profile-queries thread. pub fn profq_msg(sess: &Session, msg: ProfileQueriesMsg) { if let Some(s) = sess.profile_channel.borrow().as_ref() { s.send(msg).unwrap() } else { - // Do nothing + // Do nothing. } } -/// Set channel for profile queries channel +/// Sets channel for profile queries channel. pub fn profq_set_chan(sess: &Session, s: Sender) -> bool { let mut channel = sess.profile_channel.borrow_mut(); if channel.is_none() { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 1cb9f47bb31f1..a0001075387a7 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -435,7 +435,7 @@ impl PrintContext { // to be a value or type-def or something in there // *somewhere* item_def_id.index = key.parent.unwrap_or_else(|| { - bug!("finding type for {:?}, encountered def-id {:?} with no \ + bug!("finding type for {:?}, encountered `DefId` {:?} with no \ parent", did, item_def_id); }); } @@ -538,8 +538,8 @@ impl PrintContext { // This happens when the value of the region // parameter is not easily serialized. This may be // because the user omitted it in the first place, - // or because it refers to some block in the code, - // etc. I'm not sure how best to serialize this. + // or because it refers to some block in the code, etc. + // I'm not sure how best to serialize this. write!(f, "'_")?; } else { write!(f, "{}", s)?; @@ -931,9 +931,9 @@ define_print! { return write!(f, "'{:?}", n); } - // These printouts are concise. They do not contain all the information + // These printouts are concise. They do not contain all the information // the user might want to diagnose an error, but there is basically no way - // to fit that into a short string. Hence the recommendation to use + // to fit that into a short string. ence the recommendation to use // `explain_region()` or `note_and_explain_region()`. match *self { ty::ReEarlyBound(ref data) => { @@ -1192,7 +1192,7 @@ define_print! { } debug { // when printing out the debug representation, we don't need - // to enumerate the `for<...>` etc because the debruijn index + // to enumerate the `for<...>` etc because the De Bruijn index // tells you everything you need to know. print!(f, cx, write("<"), @@ -1321,7 +1321,7 @@ define_print! { return Ok(()); } // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, - // by looking up the projections associated with the def_id. + // by looking up the projections associated with `def_id`. let predicates_of = tcx.predicates_of(def_id); let substs = tcx.lift(&substs).unwrap_or_else(|| { tcx.intern_substs(&[]) @@ -1378,8 +1378,8 @@ define_print! { Ok(()) })? } else { - // cross-crate closure types should only be - // visible in codegen bug reports, I imagine. + // Cross-crate closure types should only be + // visible in codegen bug reports. write!(f, "@{:?}", did)?; let mut sep = " "; for (index, upvar_ty) in upvar_tys.enumerate() { @@ -1418,8 +1418,8 @@ define_print! { Ok(()) })? } else { - // cross-crate closure types should only be - // visible in codegen bug reports, I imagine. + // Cross-crate closure types should only be + // visible in codegen bug reports. write!(f, "@{:?}", did)?; let mut sep = " "; for (index, upvar_ty) in upvar_tys.enumerate() { @@ -1523,7 +1523,7 @@ define_print! { ('tcx) ty::ProjectionTy<'tcx>, (self, f, cx) { display { // FIXME(tschottdorf): use something like - // parameterized(f, self.substs, self.item_def_id, &[]) + // `parameterized(f, self.substs, self.item_def_id, &[])` // (which currently ICEs). let (trait_ref, item_name) = ty::tls::with(|tcx| (self.trait_ref(tcx), tcx.associated_item(self.item_def_id).ident) diff --git a/src/librustc_apfloat/ieee.rs b/src/librustc_apfloat/ieee.rs index 9f68d770b9e87..1079ebd54ae7b 100644 --- a/src/librustc_apfloat/ieee.rs +++ b/src/librustc_apfloat/ieee.rs @@ -124,12 +124,12 @@ pub trait Semantics: Sized { } } Category::Zero => { - // FIXME(eddyb) Maybe we should guarantee an invariant instead? + // FIXME(eddyb): maybe we should guarantee an invariant instead? significand = 0; Self::MIN_EXP - 1 } Category::Infinity => { - // FIXME(eddyb) Maybe we should guarantee an invariant instead? + // FIXME(eddyb): maybe we should guarantee an invariant instead? significand = 0; Self::MAX_EXP + 1 } @@ -234,12 +234,12 @@ impl Semantics for X87DoubleExtendedS { } } Category::Zero => { - // FIXME(eddyb) Maybe we should guarantee an invariant instead? + // FIXME(eddyb): maybe we should guarantee an invariant instead? significand = 0; Self::MIN_EXP - 1 } Category::Infinity => { - // FIXME(eddyb) Maybe we should guarantee an invariant instead? + // FIXME(eddyb): maybe we should guarantee an invariant instead? significand = 1 << (Self::PRECISION - 1); Self::MAX_EXP + 1 } @@ -373,7 +373,7 @@ impl fmt::Display for IeeeFloat { // We use enough digits so the number can be round-tripped back to an // APFloat. The formula comes from "How to Print Floating-Point Numbers // Accurately" by Steele and White. - // FIXME: Using a formula based purely on the precision is conservative; + // FIXME: using a formula based purely on the precision is conservative; // we can print fewer digits depending on the actual value being printed. // precision = 2 + floor(S::PRECISION / lg_2(10)) @@ -645,7 +645,7 @@ impl Float for IeeeFloat { marker: PhantomData, }; - // FIXME(eddyb) remove when qnan becomes const fn. + // FIXME(eddyb): remove when qnan becomes const fn. const NAN: Self = IeeeFloat { sig: [S::QNAN_SIGNIFICAND], exp: S::MAX_EXP + 1, @@ -2005,7 +2005,7 @@ impl IeeeFloat { } } - // Calculate pow(5, abs(dec_exp)) into `pow5_full`. + // Calculate `pow(5, abs(dec_exp))` into `pow5_full`. // The *_calc Vec's are reused scratch space, as an optimization. let (pow5_full, mut pow5_calc, mut sig_calc, mut sig_scratch_calc) = { let mut power = dec_exp.abs() as usize; @@ -2421,7 +2421,7 @@ mod sig { let _: Loss = shift_right(&mut dst[..dst_limbs], &mut 0, shift); // We now have (dst_limbs * LIMB_BITS - shift) bits from `src` - // in `dst`. If this is less that src_bits, append the rest, else + // in `dst`. If this is less that src_bits, append the rest, else // clear the high bits. let n = dst_limbs * LIMB_BITS - shift; if n < src_bits { diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 46d046d7b41b4..e8515c9a487b6 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -258,19 +258,19 @@ pub trait Float const INFINITY: Self; /// NaN (Not a Number). - // FIXME(eddyb) provide a default when qnan becomes const fn. + // FIXME(eddyb): provide a default when qnan becomes const fn. const NAN: Self; /// Factory for QNaN values. - // FIXME(eddyb) should be const fn. + // FIXME(eddyb): should be const fn. fn qnan(payload: Option) -> Self; /// Factory for SNaN values. - // FIXME(eddyb) should be const fn. + // FIXME(eddyb): should be const fn. fn snan(payload: Option) -> Self; /// Largest finite number. - // FIXME(eddyb) should be const (but FloatPair::largest is nontrivial). + // FIXME(eddyb): should be const (but FloatPair::largest is nontrivial). fn largest() -> Self; /// Smallest (by magnitude) finite number. @@ -278,7 +278,7 @@ pub trait Float const SMALLEST: Self; /// Smallest (by magnitude) normalized finite number. - // FIXME(eddyb) should be const (but FloatPair::smallest_normalized is nontrivial). + // FIXME(eddyb): should be const (but FloatPair::smallest_normalized is nontrivial). fn smallest_normalized() -> Self; // Arithmetic diff --git a/src/librustc_apfloat/ppc.rs b/src/librustc_apfloat/ppc.rs index ddccfd6ca623b..9dae59916b602 100644 --- a/src/librustc_apfloat/ppc.rs +++ b/src/librustc_apfloat/ppc.rs @@ -27,9 +27,9 @@ pub type DoubleDouble = DoubleFloat; // DoubleDouble -> (Double, Double) -> // DoubleDouble's Fallback -> IEEE operations // -// FIXME: Implement all operations in DoubleDouble, and delete these +// FIXME: implement all operations in DoubleDouble, and delete these // semantics. -// FIXME(eddyb) This shouldn't need to be `pub`, it's only used in bounds. +// FIXME(eddyb): this shouldn't need to be `pub`, it's only used in bounds. pub struct FallbackS(F); type Fallback = ieee::IeeeFloat>; impl ieee::Semantics for FallbackS { @@ -40,11 +40,11 @@ impl ieee::Semantics for FallbackS { const MIN_EXP: ExpInt = F::MIN_EXP as ExpInt + F::PRECISION as ExpInt; } -// Convert number to F. To avoid spurious underflows, we re- -// normalize against the F exponent range first, and only *then* +// Convert number to `F`. To avoid spurious underflows, we re- +// normalize against the `F` exponent range first, and only *then* // truncate the mantissa. The result of that second conversion // may be inexact, but should never underflow. -// FIXME(eddyb) This shouldn't need to be `pub`, it's only used in bounds. +// FIXME(eddyb): this shouldn't need to be `pub`, it's only used in bounds. pub struct FallbackExtendedS(F); type FallbackExtended = ieee::IeeeFloat>; impl ieee::Semantics for FallbackExtendedS { @@ -142,7 +142,7 @@ where const INFINITY: Self = DoubleFloat(F::INFINITY, F::ZERO); - // FIXME(eddyb) remove when qnan becomes const fn. + // FIXME(eddyb): remove when qnan becomes const fn. const NAN: Self = DoubleFloat(F::NAN, F::ZERO); fn qnan(payload: Option) -> Self { diff --git a/src/librustc_apfloat/tests/ppc.rs b/src/librustc_apfloat/tests/ppc.rs index 02cdeb90a12be..4dd12e8e81895 100644 --- a/src/librustc_apfloat/tests/ppc.rs +++ b/src/librustc_apfloat/tests/ppc.rs @@ -364,7 +364,7 @@ fn ppc_double_double_multiply() { #[test] fn ppc_double_double_divide() { - // FIXME: Only a sanity check for now. Add more edge cases when the + // FIXME: only a sanity check for now. Add more edge cases when the // double-double algorithm is implemented. let data = [ // 1 / 3 = 1/3 diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index b528967dd65ff..0251d4c63c1e1 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -26,7 +26,7 @@ use log::debug; use std::rc::Rc; -// FIXME (#16118): These functions are intended to allow the borrow checker to +// FIXME(#16118): These functions are intended to allow the borrow checker to // be less precise in its handling of Box while still allowing moves out of a // Box. They should be removed when Unique is removed from LoanPath. diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index cf6053b71b6a8..bac8e9aeec59e 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -2,8 +2,8 @@ // Gathering loans // // The borrow check proceeds in two phases. In phase one, we gather the full -// set of loans that are required at any point. These are sorted according to -// their associated scopes. In phase two, checking loans, we will then make +// set of loans that are required at any point. These are sorted according to +// their associated scopes. In phase two, checking loans, we will then make // sure that all of these loans are honored. use crate::borrowck::*; @@ -277,7 +277,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { lp); } None => { - // This can occur with e.g., `*foo() = 5`. In such + // This can occur with e.g., `*foo() = 5`. In such // cases, there is no need to check for conflicts // with moves etc, just ignore. } @@ -336,7 +336,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { // Create the loan record (if needed). let loan = match restr { RestrictionResult::Safe => { - // No restrictions---no loan record necessary + // No restrictions -- no loan record necessary return; } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 307df16386639..9c2cc9b0b7357 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -359,7 +359,7 @@ impl<'tcx> LoanPath<'tcx> { } } -// FIXME (pnkfelix): See discussion here +// FIXME(pnkfelix): See discussion here // https://github.com/pnkfelix/rust/commit/ // b2b39e8700e37ad32b486b9a8409b50a8a53aa51#commitcomment-7892003 const DOWNCAST_PRINTED_OPERATOR: &'static str = " as "; @@ -391,7 +391,7 @@ impl ToInteriorKind for mc::InteriorKind { // `DefId` is present when the field is part of struct that is in // a variant of an enum. For instance in: // `enum E { X { foo: u32 }, Y { foo: u32 }}` -// each `foo` is qualified by the definitition id of the variant (`X` or `Y`). +// each `foo` is qualified by the definitition ID of the variant (`X` or `Y`). #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum LoanPathElem<'tcx> { LpDeref(mc::PointerKind<'tcx>), diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 325d3559f0ab6..9947c40b31bb8 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -491,7 +491,7 @@ impl<'a, 'tcx> MoveData<'tcx> { return true; } - // FIXME(#19596) This is a workaround, but there should be better way to do this + // FIXME(#19596): this is a workaround, but there should be better way to do this. fn each_extending_path_(&self, index: MovePathIndex, f: &mut F) -> bool where F: FnMut(MovePathIndex) -> bool, { diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 60a9c18e95ee9..11b352e041800 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { } for (_name, ids) in mutables { - // If any id for this name was used mutably then consider them all + // If any ID for this name was used mutably then consider them all // ok, so move on to the next if ids.iter().any(|&(ref hir_id, _)| self.used_mut.contains(hir_id)) { continue; diff --git a/src/librustc_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs index de2a3c4cb22a8..607d55d25c9a8 100644 --- a/src/librustc_borrowck/dataflow.rs +++ b/src/librustc_borrowck/dataflow.rs @@ -3,22 +3,20 @@ //! and thus uses bitvectors. Your job is simply to specify the so-called //! GEN and KILL bits for each expression. -use rustc::cfg; -use rustc::cfg::CFGIndex; -use rustc::ty::TyCtxt; use std::io; use std::mem; use std::usize; -use syntax::print::pprust::PrintState; -use log::debug; +use log::debug; use rustc_data_structures::graph::implementation::OUTGOING; - -use rustc::util::nodemap::FxHashMap; +use rustc::cfg; +use rustc::cfg::CFGIndex; use rustc::hir; use rustc::hir::intravisit; use rustc::hir::print as pprust; - +use rustc::ty::TyCtxt; +use rustc::util::nodemap::FxHashMap; +use syntax::print::pprust::PrintState; #[derive(Copy, Clone, Debug)] pub enum EntryOrExit { @@ -44,11 +42,11 @@ pub struct DataFlowContext<'a, 'tcx: 'a, O> { words_per_id: usize, // mapping from node to cfg node index - // FIXME (#6298): Shouldn't this go with CFG? + // FIXME(#6298): Shouldn't this go with CFG? local_id_to_index: FxHashMap>, - // Bit sets per cfg node. The following three fields (`gens`, `kills`, - // and `on_entry`) all have the same structure. For each id in + // Bit sets per cfg node. The following three fields (`gens`, `kills`, + // and `on_entry`) all have the same structure. For each ID in // `id_range`, there is a range of words equal to `words_per_id`. // So, to access the bits for any given id, you take a slice of // the full vector (see the method `compute_id_range()`). @@ -92,14 +90,14 @@ fn get_cfg_indices<'a>(id: hir::ItemLocalId, index.get(&id).map_or(&[], |v| &v[..]) } -impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { +impl<'a, 'tcx, O: DataFlowOperator> DataFlowContext<'a, 'tcx, O> { fn has_bitset_for_local_id(&self, n: hir::ItemLocalId) -> bool { assert!(n != hir::DUMMY_ITEM_LOCAL_ID); self.local_id_to_index.contains_key(&n) } } -impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> { +impl<'a, 'tcx, O: DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> { fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> { pprust::PpAnn::nested(self.tcx.hir(), state, nested) } @@ -161,8 +159,8 @@ fn build_local_id_to_index(body: Option<&hir::Body>, -> FxHashMap> { let mut index = FxHashMap::default(); - // FIXME(#15020) Would it be better to fold formals from decl - // into cfg itself? i.e., introduce a fn-based flow-graph in + // FIXME(#15020): would it be better to fold formals from decl + // into cfg itself? I.e., introduce a fn-based flow-graph in // addition to the current block-based flow-graph, rather than // have to put traversals like this here? if let Some(body) = body { @@ -225,7 +223,7 @@ pub enum KillFrom { Execution, } -impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { +impl<'a, 'tcx, O: DataFlowOperator> DataFlowContext<'a, 'tcx, O> { pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, analysis_name: &'static str, body: Option<&hir::Body>, @@ -356,7 +354,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { //! Only useful after `propagate()` has been called. if self.bits_per_id == 0 { - // Skip the surprisingly common degenerate case. (Note + // Skip the surprisingly common degenerate case. (Note // compute_id_range requires self.words_per_id > 0.) return true; } @@ -387,7 +385,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } if self.bits_per_id == 0 { - // Skip the surprisingly common degenerate case. (Note + // Skip the surprisingly common degenerate case. (Note // compute_id_range requires self.words_per_id > 0.) return true; } @@ -421,10 +419,10 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { if (word & bit) != 0 { // N.B., we round up the total number of bits // that we store in any given bit set so that - // it is an even multiple of usize::BITS. This + // it is an even multiple of usize::BITS. This // means that there may be some stray bits at // the end that do not correspond to any - // actual value. So before we callback, check + // actual value. So before we callback, check // whether the bit_index is greater than the // actual value the user specified and stop // iterating if so. @@ -453,7 +451,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { debug!("{} add_kills_from_flow_exits", self.analysis_name); if self.bits_per_id == 0 { - // Skip the surprisingly common degenerate case. (Note + // Skip the surprisingly common degenerate case. (Note // compute_id_range requires self.words_per_id > 0.) return; } @@ -500,8 +498,8 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } } -impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> { -// ^^^^^^^^^^^^^ only needed for pretty printing +// N.B., `Clone + 'static` only needed for pretty-printing. +impl<'a, 'tcx, O: DataFlowOperator + Clone + 'static> DataFlowContext<'a, 'tcx, O> { pub fn propagate(&mut self, cfg: &cfg::CFG, body: &hir::Body) { //! Performs the data flow analysis. @@ -538,7 +536,7 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> { } } -impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { +impl<'a, 'b, 'tcx, O: DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { fn walk_cfg(&mut self, cfg: &cfg::CFG, nodes_po: &[CFGIndex], @@ -547,7 +545,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { bits_to_string(in_out), self.dfcx.analysis_name); assert!(self.dfcx.bits_per_id > 0); - // Iterate over nodes in reverse postorder + // Iterate over nodes in reverse post-order. for &node_index in nodes_po.iter().rev() { let node = cfg.graph.node(node_index); debug!("DataFlowContext::walk_cfg idx={:?} id={:?} begin in_out={}", @@ -631,9 +629,9 @@ fn bits_to_string(words: &[usize]) -> String { } #[inline] -fn bitwise(out_vec: &mut [usize], - in_vec: &[usize], - op: &Op) -> bool { +fn bitwise(out_vec: &mut [usize], + in_vec: &[usize], + op: &Op) -> bool { assert_eq!(out_vec.len(), in_vec.len()); let mut changed = false; for (out_elt, in_elt) in out_vec.iter_mut().zip(in_vec) { diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index f7d2699a27e3f..7c43dd84e014f 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -207,7 +207,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> { bx.store(val, cast_dst, self.layout.align.abi); } else { // The actual return type is a struct, but the ABI - // adaptation code has cast it into some scalar type. The + // adaptation code has cast it into some scalar type. The // code that follows is the only reliable way I have // found to do a transform like i64 -> {i32,i32}. // Basically we dump the data onto the stack then memcpy it. @@ -343,7 +343,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { if arg_idx == Some(0) { let fat_pointer_ty = if layout.is_unsized() { // unsized `self` is passed as a pointer to `self` - // FIXME (mikeyhew) change this to use &own if it is ever added to the language + // FIXME(mikeyhew): change this to use &own if it is ever added to the language cx.tcx.mk_mut_ptr(layout.ty) } else { match layout.abi { @@ -520,7 +520,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { } } - // FIXME(eddyb) other ABIs don't have logic for scalar pairs. + // FIXME(eddyb): other ABIs don't have logic for scalar pairs. if !is_return && rust_abi { if let layout::Abi::ScalarPair(ref a, ref b) = arg.layout.abi { let mut a_attrs = ArgAttributes::new(); diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 5c1a8b070c993..3b21e7e945969 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -95,7 +95,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { } // Store mark in a metadata node so we can map LLVM errors - // back to source locations. See #17552. + // back to source locations. See #17552. unsafe { let key = "srcloc"; let kind = llvm::LLVMGetMDKindIDInContext(self.llcx, diff --git a/src/librustc_codegen_llvm/back/archive.rs b/src/librustc_codegen_llvm/back/archive.rs index e02f7df2efcc9..ea070e617d1ae 100644 --- a/src/librustc_codegen_llvm/back/archive.rs +++ b/src/librustc_codegen_llvm/back/archive.rs @@ -131,7 +131,7 @@ impl<'a> ArchiveBuilder<'a> { return true } - // Otherwise if this is *not* a rust object and we're skipping + // Otherwise if this is **not** a rust object and we're skipping // objects then skip this file if skip_objects && (!fname.starts_with(&obj_start) || !fname.ends_with(".o")) { return true diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 548c94abc076f..1987d41d31b47 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -1,30 +1,3 @@ -use back::wasm; -use super::archive::{ArchiveBuilder, ArchiveConfig}; -use super::bytecode::RLIB_BYTECODE_EXTENSION; -use rustc_codegen_ssa::back::linker::Linker; -use rustc_codegen_ssa::back::link::{remove, ignored_for_lto, each_linked_rlib, linker_and_flavor, - get_linker}; -use rustc_codegen_ssa::back::command::Command; -use super::rpath::RPathConfig; -use super::rpath; -use metadata::METADATA_FILENAME; -use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest}; -use rustc::session::config::{RUST_CGU_EXT, Lto, Sanitizer}; -use rustc::session::filesearch; -use rustc::session::search_paths::PathKind; -use rustc::session::Session; -use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; -use rustc::middle::dependency_format::Linkage; -use rustc_codegen_ssa::CodegenResults; -use rustc::util::common::time; -use rustc_fs_util::fix_windows_verbatim_for_gcc; -use rustc::hir::def_id::CrateNum; -use tempfile::{Builder as TempFileBuilder, TempDir}; -use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor}; -use rustc_data_structures::fx::FxHashSet; -use context::get_reloc_model; -use llvm; - use std::ascii; use std::char; use std::env; @@ -35,13 +8,39 @@ use std::iter; use std::path::{Path, PathBuf}; use std::process::{Output, Stdio}; use std::str; + +use back::wasm; +use context::get_reloc_model; +use llvm; +use metadata::METADATA_FILENAME; +use rustc_codegen_ssa::CodegenResults; +use rustc_codegen_ssa::back::command::Command; +use rustc_codegen_ssa::back::linker::Linker; +use rustc_codegen_ssa::back::link::{remove, ignored_for_lto, each_linked_rlib, linker_and_flavor, + get_linker}; +use rustc_data_structures::fx::FxHashSet; +use rustc_fs_util::fix_windows_verbatim_for_gcc; +use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor}; +use rustc::hir::def_id::CrateNum; +use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; +use rustc::middle::dependency_format::Linkage; +use rustc::session::Session; +use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest}; +use rustc::session::config::{RUST_CGU_EXT, Lto, Sanitizer}; +use rustc::session::filesearch; +use rustc::session::search_paths::PathKind; +use rustc::util::common::time; use syntax::attr; +use tempfile::{Builder as TempFileBuilder, TempDir}; + +use super::archive::{ArchiveBuilder, ArchiveConfig}; +use super::bytecode::RLIB_BYTECODE_EXTENSION; +use super::rpath::{self, RPathConfig}; pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target, invalid_output_for_target, filename_for_metadata, out_filename, check_file_is_writeable}; - /// Performs the linkage portion of the compilation phase. This will generate all /// of the requested outputs for this compilation session. pub(crate) fn link_binary(sess: &Session, @@ -50,7 +49,7 @@ pub(crate) fn link_binary(sess: &Session, crate_name: &str) -> Vec { let mut out_filenames = Vec::new(); for &crate_type in sess.crate_types.borrow().iter() { - // Ignore executable crates if we have -Z no-codegen, as they will error. + // Ignore executable crates if we have `-Z no-codegen`, as they will error. let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata); if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen()) && !output_metadata && @@ -70,7 +69,7 @@ pub(crate) fn link_binary(sess: &Session, out_filenames.extend(out_files); } - // Remove the temporary object file and metadata if we aren't saving temps + // Remove the temporary object file and metadata if we aren't saving temps. if !sess.opts.cg.save_temps { if sess.opts.output_types.should_codegen() && !preserve_objects_for_their_debuginfo(sess) { for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) { @@ -114,15 +113,15 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool { return false } - // If we're on OSX then the equivalent of split dwarf is turned on by + // If we're on macOS then the equivalent of split dwarf is turned on by // default. The final executable won't actually have any debug information // except it'll have pointers to elsewhere. Historically we've always run // `dsymutil` to "link all the dwarf together" but this is actually sort of // a bummer for incremental compilation! (the whole point of split dwarf is // that you don't do this sort of dwarf link). // - // Basically as a result this just means that if we're on OSX and we're - // *not* running dsymutil then the object files are the only source of truth + // Basically as a result this just means that if we're on macOS and we're + // **not** running dsymutil then the object files are the only source of truth // for debug information, so we must preserve them. if sess.target.target.options.is_like_osx { match sess.opts.debugging_opts.run_dsymutil { @@ -241,7 +240,7 @@ enum RlibFlavor { StaticlibBase, } -// Create an 'rlib' +// Creates an 'rlib'. // // An rlib in its current incarnation is essentially a renamed .a file. The // rlib primarily contains the object file of the crate, but it also contains @@ -349,7 +348,7 @@ fn link_rlib<'a>(sess: &'a Session, ab } -// Create a static archive +// Creates a static archive. // // This is essentially the same thing as an rlib, but it also involves adding // all of the upstream crates' objects into the archive. This will slurp in @@ -442,7 +441,7 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) { sess.note_without_error("Link against the following native artifacts when linking \ against this static library. The order and any duplication \ can be significant on some platforms."); - // Prefix for greppability + // Prefix for grep-ability. sess.note_without_error(&format!("native-static-libs: {}", &lib_args.join(" "))); } } @@ -462,10 +461,10 @@ fn get_file_path(sess: &Session, name: &str) -> PathBuf { PathBuf::from(name) } -// Create a dynamic library or executable +// Creates a dynamic library or executable. // -// This will invoke the system linker/cc to create the resulting file. This -// links to all upstream files as well. +// This will invoke the system linker or cc to create the resulting file. +// This links to all upstream files as well. fn link_natively(sess: &Session, crate_type: config::CrateType, out_filename: &Path, @@ -474,7 +473,7 @@ fn link_natively(sess: &Session, info!("preparing {:?} to {:?}", crate_type, out_filename); let (linker, flavor) = linker_and_flavor(sess); - // The invocations of cc share some flags across platforms + // The invocations of cc share some flags across platforms. let (pname, mut cmd) = get_linker(sess, &linker, flavor); if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) { @@ -554,22 +553,22 @@ fn link_natively(sess: &Session, // May have not found libraries in the right formats. sess.abort_if_errors(); - // Invoke the system linker + // Invoke the system linker. // // Note that there's a terribly awful hack that really shouldn't be present // in any compiler. Here an environment variable is supported to // automatically retry the linker invocation if the linker looks like it // segfaulted. // - // Gee that seems odd, normally segfaults are things we want to know about! - // Unfortunately though in rust-lang/rust#38878 we're experiencing the - // linker segfaulting on Travis quite a bit which is causing quite a bit of - // pain to land PRs when they spuriously fail due to a segfault. + // That seems odd... normally segfaults are things we want to know about! + // Unfortunately, however, in issue #38878 we're experiencing the + // linker segfaulting on Travis quite a bit, which is causing a lot of + // pain when trying to land PRs due to them spuriously failing from segfaults. // - // The issue #38878 has some more debugging information on it as well, but + // Issue #38878 has some more debugging information on it as well, but // this unfortunately looks like it's just a race condition in macOS's linker // with some thread pool working in the background. It seems that no one - // currently knows a fix for this so in the meantime we're left with this... + // currently knows a fix for this so in the meantime we're left with this. info!("{:?}", &cmd); let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok(); let mut prog; @@ -590,8 +589,8 @@ fn link_natively(sess: &Session, out.extend(&output.stdout); let out = String::from_utf8_lossy(&out); - // Check to see if the link failed with "unrecognized command line option: - // '-no-pie'" for gcc or "unknown argument: '-no-pie'" for clang. If so, + // Check to see if the link failed with `unrecognized command line option: + // '-no-pie'` for gcc or `unknown argument: '-no-pie'` for clang. If so, // reperform the link step without the -no-pie option. This is safe because // if the linker doesn't support -no-pie then it should not default to // linking executables as pie. Different versions of gcc seem to use @@ -675,7 +674,7 @@ fn link_natively(sess: &Session, linker_error.emit(); if sess.target.target.options.is_like_msvc && linker_not_found { - sess.note_without_error("the msvc targets depend on the msvc linker \ + sess.note_without_error("the MSVC targets depend on the MSVC linker \ but `link.exe` was not found"); sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017 \ was installed with the Visual C++ option"); @@ -1019,7 +1018,7 @@ fn link_args(cmd: &mut dyn Linker, cmd.pgo_gen(); } - // FIXME (#2397): At some point we want to rpath our guesses as to + // FIXME(#2397): At some point we want to rpath our guesses as to // where extern libraries might live, based on the // addl_lib_search_paths if sess.opts.cg.rpath { @@ -1094,28 +1093,28 @@ fn add_local_native_libraries(cmd: &mut dyn Linker, } } -// # Rust Crate linking +// Rust crate linking. // // Rust crates are not considered at all when creating an rlib output. All // dependencies will be linked when producing the final output (instead of -// the intermediate rlib version) +// the intermediate rlib version). fn add_upstream_rust_crates(cmd: &mut dyn Linker, sess: &Session, codegen_results: &CodegenResults, crate_type: config::CrateType, tmpdir: &Path) { // All of the heavy lifting has previously been accomplished by the - // dependency_format module of the compiler. This is just crawling the + // `dependency_format` module of the compiler. This is just crawling the // output of that module, adding crates as necessary. // // Linking to a rlib involves just passing it to the linker (the linker - // will slurp up the object files inside), and linking to a dynamic library - // involves just passing the right -l flag. + // will gather up the object files inside), and linking to a dynamic library + // involves just passing the right `-l` flag. let formats = sess.dependency_formats.borrow(); let data = formats.get(&crate_type).unwrap(); - // Invoke get_used_crates to ensure that we get a topological sorting of + // Invoke `get_used_crates` to ensure that we get a topological sorting of // crates. let deps = &codegen_results.crate_info.used_crates_dynamic; @@ -1201,7 +1200,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker, } } - // compiler-builtins are always placed last to ensure that they're + // Compiler builtins are always placed last to ensure that they're // linked correctly. // We must always link the `compiler_builtins` crate statically. Even if it // was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic` @@ -1237,7 +1236,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker, // rpath to the library as well (the rpath should be absolute, see // PR #41352 for details). // - // FIXME: Remove this logic into librustc_*san once Cargo supports it + // FIXME: remove this logic into librustc_*san once Cargo supports it. let rpath = cratepath.parent().unwrap(); let rpath = rpath.to_str().expect("non-utf8 component in path"); cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); @@ -1301,8 +1300,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker, let cratepath = &src.rlib.as_ref().unwrap().0; // See the comment above in `link_staticlib` and `link_rlib` for why if - // there's a static library that's not relevant we skip all object - // files. + // there's a static library that's not relevant we skip all object files. let native_libs = &codegen_results.crate_info.native_libraries[&cnum]; let skip_native = native_libs.iter().any(|lib| { lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib) @@ -1413,7 +1411,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker, } } -// Link in all of our upstream crates' native dependencies. Remember that +// Links in all of our upstream crates' native dependencies. Remember that // all of these upstream native dependencies are all non-static // dependencies. We've got two cases then: // @@ -1436,12 +1434,12 @@ fn add_upstream_native_libraries(cmd: &mut dyn Linker, codegen_results: &CodegenResults, crate_type: config::CrateType) { // Be sure to use a topological sorting of crates because there may be - // interdependencies between native libraries. When passing -nodefaultlibs, + // interdependencies between native libraries. When passing `-nodefaultlibs`, // for example, almost all native libraries depend on libc, so we have to // make sure that's all the way at the right (liblibc is near the base of // the dependency chain). // - // This passes RequireStatic, but the actual requirement doesn't matter, + // This passes `RequireStatic`, but the actual requirement doesn't matter, // we're just getting an ordering of crate numbers, we're not worried about // the paths. let formats = sess.dependency_formats.borrow(); @@ -1462,16 +1460,16 @@ fn add_upstream_native_libraries(cmd: &mut dyn Linker, NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), NativeLibraryKind::NativeStaticNobundle => { // Link "static-nobundle" native libs only if the crate they originate from - // is being linked statically to the current crate. If it's linked dynamically + // is being linked statically to the current crate. If it's linked dynamically // or is an rlib already included via some other dylib crate, the symbols from // native libs will have already been included in that dylib. if data[cnum.as_usize() - 1] == Linkage::Static { cmd.link_staticlib(&name.as_str()) } }, - // ignore statically included native libraries here as we've + // Ignore statically included native libraries here as we've // already included them when we included the rust library - // previously + // previously. NativeLibraryKind::NativeStatic => {} } } diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index fc3ab7f734a79..d5432d41cbf23 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -1,12 +1,19 @@ +use std::ffi::{CStr, CString}; +use std::ptr; +use std::slice; +use std::sync::Arc; + use back::bytecode::{DecodedBytecode, RLIB_BYTECODE_EXTENSION}; +use back::write::{self, DiagnosticHandlers, with_llvm_pmb, save_temp_bitcode, to_llvm_opt_settings}; +use errors::{FatalError, Handler}; +use libc; +use llvm::{self, True, False}; +use llvm::archive_ro::ArchiveRO; +use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; use rustc_codegen_ssa::back::symbol_export; use rustc_codegen_ssa::back::write::{ModuleConfig, CodegenContext, FatLTOInput}; use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinShared, ThinModule}; use rustc_codegen_ssa::traits::*; -use back::write::{self, DiagnosticHandlers, with_llvm_pmb, save_temp_bitcode, to_llvm_opt_settings}; -use errors::{FatalError, Handler}; -use llvm::archive_ro::ArchiveRO; -use llvm::{self, True, False}; use rustc::dep_graph::WorkProduct; use rustc::dep_graph::cgu_reuse_tracker::CguReuse; use rustc::hir::def_id::LOCAL_CRATE; @@ -15,15 +22,8 @@ use rustc::session::config::{self, Lto}; use rustc::util::common::time_ext; use rustc_data_structures::fx::FxHashMap; use time_graph::Timeline; -use {ModuleLlvm, LlvmCodegenBackend}; -use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; -use libc; - -use std::ffi::{CStr, CString}; -use std::ptr; -use std::slice; -use std::sync::Arc; +use crate::{LlvmCodegenBackend, ModuleLlvm}; pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool { match crate_type { @@ -43,10 +43,10 @@ fn prepare_lto(cgcx: &CodegenContext, -> Result<(Vec, Vec<(SerializedModule, CString)>), FatalError> { let export_threshold = match cgcx.lto { - // We're just doing LTO for our one crate + // We're just doing LTO for our one crate. Lto::ThinLocal => SymbolExportLevel::Rust, - // We're doing LTO for the entire crate graph + // We're doing LTO for the entire crate graph. Lto::Fat | Lto::Thin => { symbol_export::crates_export_threshold(&cgcx.crate_types) } @@ -76,8 +76,8 @@ fn prepare_lto(cgcx: &CodegenContext, // upstream dependencies, find the corresponding rlib and load the bitcode // from the archive. // - // We save off all the bytecode and LLVM module ids for later processing - // with either fat or thin LTO + // We save off all the bytecode and LLVM module IDs for later processing + // with either fat or thin LTO. let mut upstream_modules = Vec::new(); if cgcx.lto != Lto::ThinLocal { if cgcx.opts.cg.prefer_dynamic { @@ -88,10 +88,10 @@ fn prepare_lto(cgcx: &CodegenContext, return Err(FatalError) } - // Make sure we actually can run LTO + // Make sure we can actually run LTO. for crate_type in cgcx.crate_types.iter() { if !crate_type_allows_lto(*crate_type) { - let e = diag_handler.fatal("lto can only be run for executables, cdylibs and \ + let e = diag_handler.fatal("LTO can only be run for executables, cdylibs and \ static library outputs"); return Err(e) } @@ -155,7 +155,7 @@ pub(crate) fn run_fat(cgcx: &CodegenContext, /// Performs thin LTO by performing necessary global analysis and returning two /// lists, one of the modules that need optimization and another for modules that -/// can simply be copied over from the incr. comp. cache. +/// can simply be copied over from the incrimental compilation cache. pub(crate) fn run_thin(cgcx: &CodegenContext, modules: Vec<(String, ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, @@ -168,7 +168,7 @@ pub(crate) fn run_thin(cgcx: &CodegenContext, .map(|c| c.as_ptr()) .collect::>(); if cgcx.opts.cg.linker_plugin_lto.enabled() { - unreachable!("We should never reach this case if the LTO step \ + unreachable!("we should never reach this case if the LTO step \ is deferred to the linker"); } thin_lto(cgcx, @@ -361,7 +361,7 @@ impl Drop for Linker<'a> { } } -/// Prepare "thin" LTO to get run on these modules. +/// Prepares "thin" LTO to get run on these modules. /// /// The general structure of ThinLTO is quite different from the structure of /// "fat" LTO above. With "fat" LTO all LLVM modules in question are merged into @@ -426,7 +426,7 @@ fn thin_lto(cgcx: &CodegenContext, timeline.record(&name); } - // FIXME: All upstream crates are deserialized internally in the + // FIXME: all upstream crates are deserialized internally in the // function below to extract their summary and modules. Note that // unlike the loop above we *must* decode and/or read something // here as these are all just serialized files on disk. An @@ -545,8 +545,8 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext, // Now we have one massive module inside of llmod. Time to run the // LTO-specific optimization passes that LLVM provides. // - // This code is based off the code found in llvm's LTO code generator: - // tools/lto/LTOCodeGenerator.cpp + // This code is based off the code found in LLVM's LTO code generator + // (see `tools/lto/LTOCodeGenerator.cpp`). debug!("running the pass manager"); unsafe { let pm = llvm::LLVMCreatePassManager(); @@ -557,7 +557,7 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext, llvm::LLVMRustAddPass(pm, pass.unwrap()); } - // When optimizing for LTO we don't actually pass in `-O0`, but we force + // When optimizing for LTO, we don't actually pass in `-O0`, but we force // it to always happen at least with `-O1`. // // With ThinLTO we mess around a lot with symbol visibility in a way diff --git a/src/librustc_codegen_llvm/back/rpath.rs b/src/librustc_codegen_llvm/back/rpath.rs index a5c828e089f39..e6be3ebdf5080 100644 --- a/src/librustc_codegen_llvm/back/rpath.rs +++ b/src/librustc_codegen_llvm/back/rpath.rs @@ -107,7 +107,7 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String let output = fs::canonicalize(&output).unwrap_or(output); let relative = path_relative_from(&lib, &output).unwrap_or_else(|| panic!("couldn't create relative path from {:?} to {:?}", output, lib)); - // FIXME (#9639): This needs to handle non-utf8 paths + // FIXME(#9639): This needs to handle non-utf8 paths format!("{}/{}", prefix, relative.to_str().expect("non-utf8 component in path")) } @@ -157,7 +157,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option { fn get_install_prefix_rpath(config: &mut RPathConfig) -> String { let path = (config.get_install_prefix_lib_path)(); let path = env::current_dir().unwrap().join(&path); - // FIXME (#9639): This needs to handle non-utf8 paths + // FIXME(#9639): This needs to handle non-utf8 paths path.to_str().expect("non-utf8 component in rpath").to_owned() } diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index e78715319727b..59d7fae3ade16 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -766,7 +766,7 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module, // Create a `__imp_ = &symbol` global for every public static `symbol`. // This is required to satisfy `dllimport` references to static data in .rlibs -// when using MSVC linker. We do this only for data, as linker can fix up +// when using MSVC linker. We do this only for data, as linker can fix up // code references on its own. // See #26591, #27438 fn create_msvc_imps( diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 70986a4e17941..d663e39880c92 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -13,36 +13,32 @@ //! but one `llvm::Type` corresponds to many `Ty`s; for instance, `tup(int, int, //! int)` and `rec(x=int, y=int, z=int)` will have the same `llvm::Type`. -use super::ModuleLlvm; -use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; -use rustc_codegen_ssa::base::maybe_create_entry_wrapper; -use super::LlvmCodegenBackend; +use std::ffi::CString; +use std::time::Instant; +use builder::Builder; +use common; +use context::CodegenCx; use llvm; use metadata; +use monomorphize::partitioning::CodegenUnitExt; +use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; +use rustc_codegen_ssa::back::write::submit_codegened_module_to_llvm; +use rustc_codegen_ssa::base::maybe_create_entry_wrapper; +use rustc_codegen_ssa::mono_item::MonoItemExt; +use rustc_codegen_ssa::traits::*; +use rustc_data_structures::small_c_str::SmallCStr; use rustc::dep_graph; +use rustc::hir::CodegenFnAttrs; use rustc::mir::mono::{Linkage, Visibility, Stats}; use rustc::middle::cstore::{EncodedMetadata}; -use rustc::ty::TyCtxt; use rustc::middle::exported_symbols; use rustc::session::config::{self, DebugInfo}; -use builder::Builder; -use common; -use context::CodegenCx; -use monomorphize::partitioning::CodegenUnitExt; -use rustc_codegen_ssa::mono_item::MonoItemExt; -use rustc_data_structures::small_c_str::SmallCStr; - -use rustc_codegen_ssa::traits::*; -use rustc_codegen_ssa::back::write::submit_codegened_module_to_llvm; - -use std::ffi::CString; -use std::time::Instant; +use rustc::ty::TyCtxt; use syntax_pos::symbol::InternedString; -use rustc::hir::CodegenFnAttrs; - use value::Value; +use crate::{LlvmCodegenBackend, ModuleLlvm}; pub fn write_metadata<'a, 'gcx>( tcx: TyCtxt<'a, 'gcx, 'gcx>, diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index 9426328da327d..7238e98377aac 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -47,8 +47,8 @@ pub fn get_fn( let llfn = if let Some(llfn) = cx.get_declared_value(&sym) { // This is subtle and surprising, but sometimes we have to bitcast - // the resulting fn pointer. The reason has to do with external - // functions. If you have two crates that both bind the same C + // the resulting fn pointer. The reason has to do with external + // functions. If you have two crates that both bind the same C // library, they may not use precisely the same types: for // example, they will probably each declare their own structs, // which are distinct types from LLVM's point of view (nominal diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index ca9e2c87be237..7af73a3c2c35b 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -82,7 +82,7 @@ fn set_global_alignment(cx: &CodegenCx<'ll, '_>, mut align: Align) { // The target may require greater alignment for globals than the type does. // Note: GCC and Clang also allow `__attribute__((aligned))` on variables, - // which can force it to be smaller. Rust doesn't support this yet. + // which can force it to be smaller. Rust doesn't support this yet. if let Some(min) = cx.sess().target.target.options.min_global_align { match Align::from_bits(min) { Ok(min) => align = align.max(min), @@ -127,7 +127,7 @@ fn check_and_apply_linkage( llvm::LLVMRustSetLinkage(g1, base::linkage_to_llvm(linkage)); // Declare an internal global `extern_with_linkage_foo` which - // is initialized with the address of `foo`. If `foo` is + // is initialized with the address of `foo`. If `foo` is // discarded during linking (for example, if `foo` has weak // linkage and there are no definitions), then // `extern_with_linkage_foo` will instead be initialized to diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 3a7864cb7a5a8..e113e027a76de 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -66,7 +66,7 @@ impl fmt::Debug for llvm::Metadata { } // From DWARF 5. -// See http://www.dwarfstd.org/ShowIssue.php?issue=140129.1 +// See . const DW_LANG_RUST: c_uint = 0x1c; #[allow(non_upper_case_globals)] const DW_ATE_boolean: c_uint = 0x02; @@ -87,24 +87,24 @@ pub const NO_SCOPE_METADATA: Option<&DIScope> = None; #[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)] pub struct UniqueTypeId(ast::Name); -// The TypeMap is where the CrateDebugContext holds the type metadata nodes -// created so far. The metadata nodes are indexed by UniqueTypeId, and, for -// faster lookup, also by Ty. The TypeMap is responsible for creating -// UniqueTypeIds. +// The `TypeMap` is where the `CrateDebugContext` holds the type metadata nodes +// created so far. The metadata nodes are indexed by `UniqueTypeId`, and, for +// faster lookup, also by `Ty`. The `TypeMap` is responsible for creating +// `UniqueTypeId`s. #[derive(Default)] pub struct TypeMap<'ll, 'tcx> { - // The UniqueTypeIds created so far + // The `UniqueTypeId`s created so far. unique_id_interner: Interner, - // A map from UniqueTypeId to debuginfo metadata for that type. This is a 1:1 mapping. + // A map from `UniqueTypeId` to debuginfo metadata for that type. This is a one-to-one mapping. unique_id_to_metadata: FxHashMap, - // A map from types to debuginfo metadata. This is a N:1 mapping. + // A map from types to debuginfo metadata. This is a many-to-one mapping. type_to_metadata: FxHashMap, &'ll DIType>, - // A map from types to UniqueTypeId. This is a N:1 mapping. + // A map from types to `UniqueTypeId`. This is a many-to-one mapping. type_to_unique_id: FxHashMap, UniqueTypeId> } impl TypeMap<'ll, 'tcx> { - // Adds a Ty to metadata mapping to the TypeMap. The method will fail if + // Adds a `Ty` to metadata mapping to the `TypeMap`. The method will fail if // the mapping already exists. fn register_type_with_metadata( &mut self, @@ -116,7 +116,7 @@ impl TypeMap<'ll, 'tcx> { } } - // Adds a UniqueTypeId to metadata mapping to the TypeMap. The method will + // Adds a `UniqueTypeId` to metadata mapping to the `TypeMap`. The method will // fail if the mapping already exists. fn register_unique_id_with_metadata( &mut self, @@ -124,7 +124,7 @@ impl TypeMap<'ll, 'tcx> { metadata: &'ll DIType, ) { if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() { - bug!("Type metadata for unique id '{}' is already in the TypeMap!", + bug!("type metadata for unique id '{}' is already in the `TypeMap`!", self.get_unique_type_id_as_string(unique_type_id)); } } @@ -137,26 +137,26 @@ impl TypeMap<'ll, 'tcx> { self.unique_id_to_metadata.get(&unique_type_id).cloned() } - // Get the string representation of a UniqueTypeId. This method will fail if - // the id is unknown. + // Get the string representation of a `UniqueTypeId`. This method will fail if + // the ID is unknown. fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> &str { let UniqueTypeId(interner_key) = unique_type_id; self.unique_id_interner.get(interner_key) } - // Get the UniqueTypeId for the given type. If the UniqueTypeId for the given + // Get the `UniqueTypeId` for the given type. If the `UniqueTypeId` for the given // type has been requested before, this is just a table lookup. Otherwise an // ID will be generated and stored for later lookup. fn get_unique_type_id_of_type<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>, type_: Ty<'tcx>) -> UniqueTypeId { - // Let's see if we already have something in the cache + // Let's see if we already have something in the cache. if let Some(unique_type_id) = self.type_to_unique_id.get(&type_).cloned() { return unique_type_id; } - // if not, generate one + // If not, generate one. - // The hasher we are using to generate the UniqueTypeId. We want - // something that provides more than the 64 bits of the DefaultHasher. + // The hasher we are using to generate the `UniqueTypeId`. We want + // something that provides more than the 64 bits of the `DefaultHasher`. let mut hasher = StableHasher::::new(); let mut hcx = cx.tcx.create_stable_hashing_context(); let type_ = cx.tcx.erase_regions(&type_); @@ -173,9 +173,9 @@ impl TypeMap<'ll, 'tcx> { return UniqueTypeId(key); } - // Get the UniqueTypeId for an enum variant. Enum variants are not really + // Get the `UniqueTypeId` for an enum variant. Enum variants are not really // types of their own, so they need special handling. We still need a - // UniqueTypeId for them, since to debuginfo they *are* real types. + // `UniqueTypeId` for them, since to debuginfo they *are* real types. fn get_unique_type_id_of_enum_variant<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>, enum_type: Ty<'tcx>, @@ -191,7 +191,7 @@ impl TypeMap<'ll, 'tcx> { } // A description of some recursive type. It can either be already finished (as -// with FinalMetadata) or it is not yet finished, but contains all information +// with `FinalMetadata`) or it is not yet finished, but contains all information // needed to generate the missing parts of the description. See the // documentation section on Recursive Types at the top of this file for more // information. @@ -215,7 +215,7 @@ fn create_and_register_recursive_type_forward_declaration( member_description_factory: MemberDescriptionFactory<'ll, 'tcx>, ) -> RecursiveTypeDescription<'ll, 'tcx> { - // Insert the stub into the TypeMap in order to allow for recursive references + // Insert the stub into the `TypeMap` in order to allow for recursive references. let mut type_map = debug_context(cx).type_map.borrow_mut(); type_map.register_unique_id_with_metadata(unique_type_id, metadata_stub); type_map.register_type_with_metadata(unfinished_type, metadata_stub); @@ -245,9 +245,9 @@ impl RecursiveTypeDescription<'ll, 'tcx> { } => { // Make sure that we have a forward declaration of the type in // the TypeMap so that recursive references are possible. This - // will always be the case if the RecursiveTypeDescription has + // will always be the case if the `RecursiveTypeDescription` has // been properly created through the - // create_and_register_recursive_type_forward_declaration() + // `create_and_register_recursive_type_forward_declaration()` // function. { let type_map = debug_context(cx).type_map.borrow(); @@ -259,7 +259,7 @@ impl RecursiveTypeDescription<'ll, 'tcx> { } } - // ... then create the member descriptions ... + // ... then create the member descriptions, ... let member_descriptions = member_description_factory.create_member_descriptions(cx); @@ -275,7 +275,7 @@ impl RecursiveTypeDescription<'ll, 'tcx> { } // Returns from the enclosing function if the type metadata with the given -// unique id can be found in the type map +// unique ID can be found in the type map. macro_rules! return_if_metadata_created_in_meantime { ($cx: expr, $unique_type_id: expr) => ( if let Some(metadata) = debug_context($cx).type_map @@ -388,13 +388,13 @@ fn subroutine_type_metadata( ); let signature_metadata: Vec<_> = iter::once( - // return type + // Return type. match signature.output().sty { ty::Tuple(ref tys) if tys.is_empty() => None, _ => Some(type_metadata(cx, signature.output(), span)) } ).chain( - // regular arguments + // Regular arguments. signature.inputs().iter().map(|argument_type| { Some(type_metadata(cx, argument_type, span)) }) @@ -412,11 +412,11 @@ fn subroutine_type_metadata( false); } -// FIXME(1563) This is all a bit of a hack because 'trait pointer' is an ill- -// defined concept. For the case of an actual trait pointer (i.e., Box, -// &Trait), trait_object_type should be the whole thing (e.g, Box) and -// trait_type should be the actual trait (e.g., Trait). Where the trait is part -// of a DST struct, there is no trait_object_type and the results of this +// FIXME(1563): this is all a bit of a hack because 'trait pointer' is an ill- +// defined concept. For the case of an actual trait pointer (i.e., `Box`, +// `&Trait`), `trait_object_type` should be the whole thing (e.g, `Box`) and +// `trait_type` should be the actual trait (e.g., `Trait`). Where the trait is part +// of a DST struct, there is no `trait_object_type`, and the results of this // function will be a little bit weird. fn trait_pointer_metadata( cx: &CodegenCx<'ll, 'tcx>, @@ -489,25 +489,25 @@ pub fn type_metadata( t: Ty<'tcx>, usage_site_span: Span, ) -> &'ll DIType { - // Get the unique type id of this type. + // Get the unique type ID of this type. let unique_type_id = { let mut type_map = debug_context(cx).type_map.borrow_mut(); - // First, try to find the type in TypeMap. If we have seen it before, we + // First, try to find the type in `TypeMap`. If we have seen it before, we // can exit early here. match type_map.find_metadata_for_type(t) { Some(metadata) => { return metadata; }, None => { - // The Ty is not in the TypeMap but maybe we have already seen + // The `Ty` is not in the `TypeMap` but maybe we have already seen // an equivalent type (e.g., only differing in region arguments). - // In order to find out, generate the unique type id and look + // In order to find out, generate the unique type ID and look // that up. let unique_type_id = type_map.get_unique_type_id_of_type(cx, t); match type_map.find_metadata_for_unique_id(unique_type_id) { Some(metadata) => { - // There is already an equivalent type in the TypeMap. - // Register this Ty as an alias in the cache and + // There is already an equivalent type in the `TypeMap`. + // Register this `Ty` as an alias in the cache and // return the cached metadata. type_map.register_type_with_metadata(t, metadata); return metadata; @@ -607,7 +607,7 @@ pub fn type_metadata( return metadata; } - // This is actually a function pointer, so wrap it in pointer DI + // This is actually a function pointer, so wrap it in pointer DI. MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false) } @@ -666,12 +666,12 @@ pub fn type_metadata( let mut type_map = debug_context(cx).type_map.borrow_mut(); if already_stored_in_typemap { - // Also make sure that we already have a TypeMap entry for the unique type id. + // Also make sure that we already have a `TypeMap` entry for the unique type ID. let metadata_for_uid = match type_map.find_metadata_for_unique_id(unique_type_id) { Some(metadata) => metadata, None => { span_bug!(usage_site_span, - "Expected type metadata for unique \ + "expected type metadata for unique \ type id '{}' to already be in \ the debuginfo::TypeMap but it \ was not. (Ty = {})", @@ -826,8 +826,8 @@ pub fn compile_unit_metadata(tcx: TyCtxt, None => PathBuf::from(&*tcx.crate_name(LOCAL_CRATE).as_str()), }; - // The OSX linker has an idiosyncrasy where it will ignore some debuginfo - // if multiple object files with the same DW_AT_name are linked together. + // The macOS linker has an idiosyncrasy where it will ignore some debuginfo + // if multiple object files with the same `DW_AT_name` are linked together. // As a workaround we generate unique names for each object file. Those do // not correspond to an actual source file but that should be harmless. if tcx.sess.target.target.options.is_like_osx { @@ -836,7 +836,7 @@ pub fn compile_unit_metadata(tcx: TyCtxt, } debug!("compile_unit_metadata: {:?}", name_in_debuginfo); - // FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice. + // FIXME(#41252): remove "clang LLVM" if we can get GDB and LLVM to play nice. let producer = format!("clang LLVM (rustc version {})", (option_env!("CFG_VERSION")).expect("CFG_VERSION")); @@ -924,8 +924,8 @@ struct MemberDescription<'ll> { discriminant: Option, } -// A factory for MemberDescriptions. It produces a list of member descriptions -// for some record-like type. MemberDescriptionFactories are used to defer the +// A factory for `MemberDescription`s. It produces a list of member descriptions +// for some record-like type. `MemberDescriptionFactory`s are used to defer the // creation of type member descriptions in order to break cycles arising from // recursive type definitions. enum MemberDescriptionFactory<'ll, 'tcx> { @@ -963,7 +963,7 @@ impl MemberDescriptionFactory<'ll, 'tcx> { // Structs //=----------------------------------------------------------------------------- -// Creates MemberDescriptions for the fields of a struct +// Creates `MemberDescription`s for the fields of a struct. struct StructMemberDescriptionFactory<'tcx> { ty: Ty<'tcx>, variant: &'tcx ty::VariantDef, @@ -1160,22 +1160,22 @@ fn prepare_union_metadata( // Although the earlier enum debug info output did not work properly // in all situations, it is better for the time being to continue to // sometimes emit the old style rather than emit something completely -// useless when rust is compiled against LLVM 6 or older. This +// useless when rust is compiled against LLVM 6 or older. This // function decides which representation will be emitted. fn use_enum_fallback(cx: &CodegenCx) -> bool { // On MSVC we have to use the fallback mode, because LLVM doesn't // lower variant parts to PDB. return cx.sess().target.target.options.is_like_msvc - // LLVM version 7 did not release with an important bug fix; - // but the required patch is in the LLVM 8. Rust LLVM reports - // 8 as well. + // LLVM version 7 did not release with an important bug fix, + // but the required patch is in the LLVM 8. Rust LLVM reports + // version 8 as well. || llvm_util::get_major_version() < 8; } // Describes the members of an enum value: An enum is described as a union of -// structs in DWARF. This MemberDescriptionFactory provides the description for +// structs in DWARF. This `MemberDescriptionFactory` provides the description for // the members of this union; so for every variant of the given enum, this -// factory will produce one MemberDescription (all with no name and a fixed +// factory will produce one `MemberDescription` (all with no name and a fixed // offset of zero bytes). struct EnumMemberDescriptionFactory<'ll, 'tcx> { enum_type: Ty<'tcx>, @@ -1283,7 +1283,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { } => { if fallback { let variant = self.layout.for_variant(cx, dataful_variant); - // Create a description of the non-null variant + // Create a description of the non-null variant. let (variant_type_metadata, member_description_factory) = describe_enum_variant(cx, variant, @@ -1386,9 +1386,9 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { } } -// Creates MemberDescriptions for the fields of a single enum variant. +// Creates `MemberDescription`s for the fields of a single enum variant. struct VariantMemberDescriptionFactory<'ll, 'tcx> { - // Cloned from the layout::Struct describing the variant. + // Cloned from the `layout::Struct` describing the variant. offsets: Vec, args: Vec<(String, Ty<'tcx>)>, discriminant_type_metadata: Option<&'ll DIType>, @@ -1427,10 +1427,10 @@ enum EnumDiscriminantInfo<'ll> { NoDiscriminant } -// Returns a tuple of (1) type_metadata_stub of the variant, (2) a -// MemberDescriptionFactory for producing the descriptions of the +// Returns a tuple of (1) `type_metadata_stub` of the variant, (2) a +// `MemberDescriptionFactory` for producing the descriptions of the // fields of the variant. This is a rudimentary version of a full -// RecursiveTypeDescription. +// `RecursiveTypeDescription`. fn describe_enum_variant( cx: &CodegenCx<'ll, 'tcx>, layout: layout::TyLayout<'tcx>, @@ -1520,7 +1520,7 @@ fn prepare_enum_metadata( let enum_name = compute_debuginfo_type_name(cx, enum_type, false); let containing_scope = get_namespace_for_item(cx, enum_def_id); - // FIXME: This should emit actual file metadata for the enum, but we + // FIXME: this should emit actual file metadata for the enum, but we // currently can't get the necessary information when it comes to types // imported from other crates. Formerly we violated the ODR when performing // LTO because we emitted debuginfo for the same type with varying file @@ -1538,7 +1538,7 @@ fn prepare_enum_metadata( Some(llvm::LLVMRustDIBuilderCreateEnumerator( DIB(cx), name.as_ptr(), - // FIXME: what if enumeration has i128 discriminant? + // FIXME: what if enumeration has `i128` discriminant? discr.val as u64)) } }) @@ -1613,7 +1613,7 @@ fn prepare_enum_metadata( layout.align.abi.bits() as u32, DIFlags::FlagZero, None, - 0, // RuntimeLang + 0, // `RuntimeLang` unique_type_id_str.as_ptr()) }; @@ -1760,7 +1760,7 @@ fn composite_type_metadata( _file_metadata: &'ll DIFile, _definition_span: Span, ) -> &'ll DICompositeType { - // Create the (empty) struct metadata node ... + // Create the (empty) struct metadata node, ... let composite_type_metadata = create_struct_stub(cx, composite_type, composite_type_name, @@ -1782,7 +1782,7 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, // In some rare cases LLVM metadata uniquing would lead to an existing type // description being used instead of a new one created in // create_struct_stub. This would cause a hard to trace assertion in - // DICompositeType::SetTypeArray(). The following check makes sure that we + // `DICompositeType::SetTypeArray()`. The following check makes sure that we // get a better error message if this should happen again due to some // regression. { @@ -1828,8 +1828,7 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, } } -// Compute the type parameters for a type, if any, for the given -// metadata. +// Computes the type parameters for a type, if any, for the given metadata. fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'ll DIArray> { if let ty::Adt(def, substs) = ty.sty { if !substs.types().next().is_none() { @@ -1874,9 +1873,9 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&' } } -// A convenience wrapper around LLVMRustDIBuilderCreateStructType(). Does not do +// A convenience wrapper around `LLVMRustDIBuilderCreateStructType()`. Does not do // any caching, does not add any fields to the struct. This can be done later -// with set_members_of_composite_type(). +// with `set_members_of_composite_type()`. fn create_struct_stub( cx: &CodegenCx<'ll, 'tcx>, struct_type: Ty<'tcx>, @@ -1891,9 +1890,9 @@ fn create_struct_stub( debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id) ); let metadata_stub = unsafe { - // LLVMRustDIBuilderCreateStructType() wants an empty array. A null + // `LLVMRustDIBuilderCreateStructType()` wants an empty array. A null // pointer will lead to hard to trace and debug LLVM assertions - // later on in llvm/lib/IR/Value.cpp. + // later on in `llvm/lib/IR/Value.cpp`. let empty_array = create_DIArray(DIB(cx), &[]); llvm::LLVMRustDIBuilderCreateStructType( @@ -1929,9 +1928,9 @@ fn create_union_stub( debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id) ); let metadata_stub = unsafe { - // LLVMRustDIBuilderCreateUnionType() wants an empty array. A null + // `LLVMRustDIBuilderCreateUnionType()` wants an empty array. A null // pointer will lead to hard to trace and debug LLVM assertions - // later on in llvm/lib/IR/Value.cpp. + // later on in `llvm/lib/IR/Value.cpp`. let empty_array = create_DIArray(DIB(cx), &[]); llvm::LLVMRustDIBuilderCreateUnionType( @@ -1971,8 +1970,8 @@ pub fn create_global_var_metadata( } let no_mangle = attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE); - // We may want to remove the namespace scope if we're in an extern block, see: - // https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952 + // We may want to remove the namespace scope if we're in an extern block, see + // . let var_scope = get_namespace_for_item(cx, def_id); let span = tcx.def_span(def_id); @@ -2031,14 +2030,14 @@ pub fn create_vtable_metadata( let type_metadata = type_metadata(cx, ty, syntax_pos::DUMMY_SP); unsafe { - // LLVMRustDIBuilderCreateStructType() wants an empty array. A null + // `LLVMRustDIBuilderCreateStructType()` wants an empty array. A null // pointer will lead to hard to trace and debug LLVM assertions - // later on in llvm/lib/IR/Value.cpp. + // later on in `llvm/lib/IR/Value.cpp`. let empty_array = create_DIArray(DIB(cx), &[]); let name = const_cstr!("vtable"); - // Create a new one each time. We don't want metadata caching + // Create a new one each time. We don't want metadata caching // here, because each vtable will refer to a unique containing // type. let vtable_type = llvm::LLVMRustDIBuilderCreateStructType( diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 625f6cd45fb3e..15de3f91d230a 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -113,7 +113,7 @@ pub fn finalize(cx: &CodegenCx) { if gdb::needs_gdb_debug_scripts_section(cx) { // Add a .debug_gdb_scripts section to this compile-unit. This will // cause GDB to try and load the gdb_load_rust_pretty_printers.py file, - // which activates the Rust pretty printers for binary this section is + // which activates the Rust pretty-printers for binary this section is // contained in. gdb::get_or_insert_gdb_debug_scripts_section_global(cx); } @@ -471,9 +471,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { ) -> &'ll DIScope { // First, let's see if this is a method within an inherent impl. Because // if yes, we want to make the result subroutine DIE a child of the - // subroutine's self-type. + // subroutine's self type. let self_type = cx.tcx.impl_of_method(instance.def_id()).and_then(|impl_def_id| { - // If the method does *not* belong to a trait, proceed + // If the method does **not** belong to a trait, proceed if cx.tcx.trait_id_of_impl(impl_def_id).is_none() { let impl_self_ty = cx.tcx.subst_and_normalize_erasing_regions( instance.substs, diff --git a/src/librustc_codegen_llvm/debuginfo/source_loc.rs b/src/librustc_codegen_llvm/debuginfo/source_loc.rs index ccf56c11e735d..f989fcc8864a2 100644 --- a/src/librustc_codegen_llvm/debuginfo/source_loc.rs +++ b/src/librustc_codegen_llvm/debuginfo/source_loc.rs @@ -65,7 +65,7 @@ pub fn set_debug_location( KnownLocation { scope, line, col } => { // For MSVC, set the column number to zero. // Otherwise, emit it. This mimics clang behaviour. - // See discussion in https://github.com/rust-lang/rust/issues/42921 + // See discussion in issue #42921. let col_used = if bx.sess().target.target.options.is_like_msvc { UNKNOWN_COLUMN_NUMBER } else { diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 58b466dbe6faa..7370fd7ef3db0 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -243,7 +243,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { } return; } - // Effectively no-ops + // Effectively noops "uninit" | "forget" => { return; } @@ -367,7 +367,8 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { ), "bswap" => { if width == 8 { - args[0].immediate() // byte swap a u8/i8 is just a no-op + // Byte-swapping a `u8`/`i8` is just a no-op. + args[0].immediate() } else { self.call( self.get_intrinsic( @@ -888,8 +889,8 @@ fn codegen_msvc_try( bx.store(ret, dest, i32_align); } -// Definition of the standard "try" function for Rust using the GNU-like model -// of exceptions (e.g., the normal semantics of LLVM's landingpad and invoke +// Definition of the standard `try` function for Rust using the GNU-like model +// of exceptions (e.g., the normal semantics of LLVM's `landingpad` and `invoke` // instructions). // // This codegen is a little surprising because we always call a shim @@ -936,7 +937,7 @@ fn codegen_gnu_try( // Type indicator for the exception being thrown. // // The first value in this tuple is a pointer to the exception object - // being thrown. The second value is a "selector" indicating which of + // being thrown. The second value is a "selector" indicating which of // the landing pad clauses the exception's type had been matched to. // rust_try ignores the selector. let lpad_ty = bx.type_struct(&[bx.type_i8p(), bx.type_i32()], false); @@ -1854,10 +1855,9 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, span_bug!(span, "unknown SIMD intrinsic"); } -// Returns the width of an int Ty, and if it's signed or not -// Returns None if the type is not an integer -// FIXME: there’s multiple of this functions, investigate using some of the already existing -// stuffs. +// Returns the width of an integer `Ty`, and if it's signed or not +// Returns `None` if the type is not an integer. +// FIXME: there’s multiple of this functions, investigate using some of the already existing stuff. fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> { match ty.sty { ty::Int(t) => Some((match t { @@ -1880,8 +1880,8 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> { } } -// Returns the width of a float TypeVariant -// Returns None if the type is not a float +// Returns the width of a float `TypeVariant`, or +// `None` if the type is not a float. fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option { match *sty { ty::Float(t) => Some(t.bit_width() as u64), diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index b605badc153f0..f593cf1229a5f 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -104,7 +104,7 @@ mod debuginfo; mod declare; mod intrinsic; -// The following is a work around that replaces `pub mod llvm;` and that fixes issue 53912. +// The following is a work around that replaces `pub mod llvm;` and that fixes issue #53912. #[path = "llvm/mod.rs"] mod llvm_; pub mod llvm { pub use super::llvm_::*; } mod llvm_util; diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index b46e6ef84b98b..f6743f0cca84a 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -72,7 +72,7 @@ unsafe fn configure_llvm(sess: &Session) { } } - // HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes + // HACK(eddyb): LLVM inserts `llvm.assume` calls to preserve align attributes // during inlining. Unfortunately these may block other optimizations. add("-preserve-alignment-assumptions-during-inlining=false"); diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 39f48b266c219..8e5482e8d1644 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -48,7 +48,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ty::Closure(..) | ty::Generator(..) | ty::Adt(..) | - // FIXME(eddyb) producing readable type names for trait objects can result + // FIXME(eddyb): producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). // ty::Dynamic(..) | ty::Foreign(..) | @@ -334,7 +334,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { fn scalar_pair_element_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize, immediate: bool) -> &'a Type { - // HACK(eddyb) special-case fat pointers until LLVM removes + // HACK(eddyb): special-case fat pointers until LLVM removes // pointee types, to avoid bitcasting every `OperandRef::deref`. match self.ty.sty { ty::Ref(..) | @@ -355,10 +355,10 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { let scalar = [a, b][index]; // Make sure to return the same type `immediate_llvm_type` would when - // dealing with an immediate pair. This means that `(bool, bool)` is + // dealing with an immediate pair. This means that `(bool, bool)` is // effectively represented as `{i8, i8}` in memory and two `i1`s as an // immediate, just like `bool` is typically `i8` in memory and only `i1` - // when immediate. We need to load/store `bool` as `i8` to avoid + // when immediate. We need to load/store `bool` as `i8` to avoid // crippling LLVM optimizations or triggering other LLVM bugs with `i1`. if immediate && scalar.is_bool() { return cx.type_i1(); @@ -487,7 +487,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { if field_start <= offset { let field = variant.field(cx, i); if ptr_end <= field_start + field.size { - // We found the right field, look inside it. + // We found the right field; look inside it. result = field.pointee_info_at(cx, offset - field_start); break; } @@ -495,7 +495,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { } } - // FIXME(eddyb) This should be for `ptr::Unique`, not `Box`. + // FIXME(eddyb): this should be for `ptr::Unique`, not `Box`. if let Some(ref mut pointee) = result { if let ty::Adt(def, _) = self.ty.sty { if def.is_box() && offset.bytes() == 0 { diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 7f1aebace8fc6..de27fecbd9ff6 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -32,12 +32,12 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB // If our linker looks like a batch script on Windows then to execute this // we'll need to spawn `cmd` explicitly. This is primarily done to handle - // emscripten where the linker is `emcc.bat` and needs to be spawned as + // Emscripten where the linker is `emcc.bat` and needs to be spawned as // `cmd /c emcc.bat ...`. // // This worked historically but is needed manually since #42436 (regression // was tagged as #42791) and some more info can be found on #44443 for - // emscripten itself. + // Emscripten itself. let mut cmd = match linker.to_str() { Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), _ => match flavor { diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 356bb8d50ad0d..21feeba77626e 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -1,23 +1,23 @@ -use super::symbol_export; -use super::command::Command; -use super::archive; - -use rustc_data_structures::fx::FxHashMap; use std::ffi::{OsStr, OsString}; use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, BufWriter}; use std::path::{Path, PathBuf}; +use rustc_data_structures::fx::FxHashMap; +use rustc_target::spec::{LinkerFlavor, LldFlavor}; use rustc::hir::def_id::{LOCAL_CRATE, CrateNum}; use rustc::middle::dependency_format::Linkage; use rustc::session::Session; use rustc::session::config::{self, CrateType, OptLevel, DebugInfo, LinkerPluginLto, Lto}; use rustc::ty::TyCtxt; -use rustc_target::spec::{LinkerFlavor, LldFlavor}; use serialize::{json, Encoder}; +use super::symbol_export; +use super::command::Command; +use super::archive; + /// For all the linkers we support, and information they might /// need out of the shared crate context before we get rid of it. pub struct LinkerInfo { @@ -128,7 +128,7 @@ pub trait Linker { fn group_start(&mut self); fn group_end(&mut self); fn linker_plugin_lto(&mut self); - // Should have been finalize(self), but we don't support self-by-value on trait objects (yet?). + // Should be `finalize(self)`, but we don't support self-by-value on trait objects (yet?). fn finalize(&mut self) -> Command; } @@ -136,8 +136,9 @@ pub struct GccLinker<'a> { cmd: Command, sess: &'a Session, info: &'a LinkerInfo, - hinted_static: bool, // Keeps track of the current hinting mode. - // Link as ld + // Keeps track of the current hinting mode. + hinted_static: bool, + // Link as `ld`. is_ld: bool, target_cpu: &'a str, } @@ -166,7 +167,7 @@ impl<'a> GccLinker<'a> { // Some platforms take hints about whether a library is static or dynamic. // For those that support this, we ensure we pass the option if the library // was flagged "static" (most defaults are dynamic) to ensure that if - // libfoo.a and libfoo.so both exist that the right one is chosen. + // `libfoo.a` and `libfoo.so` both exist that the right one is chosen. fn hint_static(&mut self) { if !self.takes_hints() { return } if !self.hinted_static { @@ -246,7 +247,7 @@ impl<'a> Linker for GccLinker<'a> { self.linker_arg("--whole-archive").cmd.arg(format!("-l{}", lib)); self.linker_arg("--no-whole-archive"); } else { - // -force_load is the macOS equivalent of --whole-archive, but it + // `-force_load` is the macOS equivalent of `--whole-archive`, but it // involves passing the full path to the library to link. self.linker_arg("-force_load"); let lib = archive::find_library(lib, search_path, &self.sess); @@ -266,7 +267,7 @@ impl<'a> Linker for GccLinker<'a> { } fn gc_sections(&mut self, keep_metadata: bool) { - // The dead_strip option to the linker specifies that functions and data + // The `dead_strip` option to the linker specifies that functions and data // unreachable by the entry point will be removed. This is quite useful // with Rust's compilation model of compiling libraries at a time into // one object file. For example, this brings hello world from 1.7MB to @@ -277,8 +278,8 @@ impl<'a> Linker for GccLinker<'a> { // stripped away as much as it could. This has not been seen to impact // link times negatively. // - // -dead_strip can't be part of the pre_link_args because it's also used - // for partial linking when using multiple codegen units (-r). So we + // `-dead_strip` can't be part of the `pre_link_args` because it's also used + // for partial linking when using multiple codegen units (`-r`). So we // insert it here. if self.sess.target.target.options.is_like_osx { self.linker_arg("-dead_strip"); @@ -288,7 +289,7 @@ impl<'a> Linker for GccLinker<'a> { // If we're building a dylib, we don't use --gc-sections because LLVM // has already done the best it can do, and we also don't want to // eliminate the metadata. If we're building an executable, however, - // --gc-sections drops the size of hello world from 1.8MB to 597K, a 67% + // `--gc-sections` drops the size of hello world from 1.8MB to 597K, a 67% // reduction. } else if !keep_metadata { self.linker_arg("--gc-sections"); @@ -298,7 +299,7 @@ impl<'a> Linker for GccLinker<'a> { fn optimize(&mut self) { if !self.sess.target.target.options.linker_is_gnu { return } - // GNU-style linkers support optimization with -O. GNU ld doesn't + // GNU-style linkers support optimization with `-O`. GNU ld doesn't // need a numeric argument, but other linkers do. if self.sess.opts.optimize == config::OptLevel::Default || self.sess.opts.optimize == config::OptLevel::Aggressive { @@ -342,7 +343,7 @@ impl<'a> Linker for GccLinker<'a> { } fn build_dylib(&mut self, out_filename: &Path) { - // On mac we need to tell the linker to let this library be rpathed + // On mac we need to tell the linker to let this library be rpath'd. if self.sess.target.target.options.is_like_osx { self.cmd.arg("-dynamiclib"); self.linker_arg("-dylib"); @@ -381,7 +382,7 @@ impl<'a> Linker for GccLinker<'a> { debug!("EXPORTED SYMBOLS:"); if self.sess.target.target.options.is_like_osx { - // Write a plain, newline-separated list of symbols + // Write a plain, newline-separated list of symbols. let res = (|| -> io::Result<()> { let mut f = BufWriter::new(File::create(&path)?); for sym in self.info.exports[&crate_type].iter() { @@ -394,7 +395,7 @@ impl<'a> Linker for GccLinker<'a> { self.sess.fatal(&format!("failed to write lib.def file: {}", e)); } } else { - // Write an LD version script + // Write an LD version script. let res = (|| -> io::Result<()> { let mut f = BufWriter::new(File::create(&path)?); writeln!(f, "{{\n global:")?; @@ -457,7 +458,7 @@ impl<'a> Linker for GccLinker<'a> { fn linker_plugin_lto(&mut self) { match self.sess.opts.cg.linker_plugin_lto { LinkerPluginLto::Disabled => { - // Nothing to do + // Nothing to do. } LinkerPluginLto::LinkerPluginAuto => { self.push_linker_plugin_lto_args(None); @@ -488,7 +489,7 @@ impl<'a> Linker for MsvcLinker<'a> { } fn build_static_executable(&mut self) { - // noop + // No-op. } fn gc_sections(&mut self, _keep_metadata: bool) { @@ -524,23 +525,23 @@ impl<'a> Linker for MsvcLinker<'a> { } fn position_independent_executable(&mut self) { - // noop + // No-op. } fn no_position_independent_executable(&mut self) { - // noop + // No-op. } fn full_relro(&mut self) { - // noop + // No-op. } fn partial_relro(&mut self) { - // noop + // No-op. } fn no_relro(&mut self) { - // noop + // No-op. } fn no_default_libraries(&mut self) { @@ -575,11 +576,11 @@ impl<'a> Linker for MsvcLinker<'a> { } fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) { - // not supported? + // Not supported? self.link_staticlib(lib); } fn link_whole_rlib(&mut self, path: &Path) { - // not supported? + // Not supported? self.link_rlib(path); } fn optimize(&mut self) { @@ -599,7 +600,7 @@ impl<'a> Linker for MsvcLinker<'a> { let natvis_dir_path = self.sess.sysroot.join("lib\\rustlib\\etc"); if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) { // LLVM 5.0.0's lld-link frontend doesn't yet recognize, and chokes - // on, the /NATVIS:... flags. LLVM 6 (or earlier) should at worst ignore + // on, the /NATVIS:... flags. LLVM 6 (or earlier) should at worst ignore // them, eventually mooting this workaround, per this landed patch: // https://github.com/llvm-mirror/lld/commit/27b9c4285364d8d76bb43839daa100 if let Some(ref linker_path) = self.sess.opts.cg.linker { @@ -683,7 +684,7 @@ impl<'a> Linker for MsvcLinker<'a> { // subsystem to be `mainCRTStartup` to get everything booted up // correctly. // - // For more information see RFC #1665 + // For more information see RFC #1665. if subsystem == "windows" { self.cmd.arg("/ENTRY:mainCRTStartup"); } @@ -693,12 +694,12 @@ impl<'a> Linker for MsvcLinker<'a> { ::std::mem::replace(&mut self.cmd, Command::new("")) } - // MSVC doesn't need group indicators + // MSVC doesn't need group indicators. fn group_start(&mut self) {} fn group_end(&mut self) {} fn linker_plugin_lto(&mut self) { - // Do nothing + // Do nothing. } } @@ -726,17 +727,17 @@ impl<'a> Linker for EmLinker<'a> { } fn link_dylib(&mut self, lib: &str) { - // Emscripten always links statically + // Emscripten always links statically. self.link_staticlib(lib); } fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) { - // not supported? + // Not supported? self.link_staticlib(lib); } fn link_whole_rlib(&mut self, lib: &Path) { - // not supported? + // Not supported? self.link_rlib(lib); } @@ -749,23 +750,23 @@ impl<'a> Linker for EmLinker<'a> { } fn position_independent_executable(&mut self) { - // noop + // No-op. } fn no_position_independent_executable(&mut self) { - // noop + // No-op. } fn full_relro(&mut self) { - // noop + // No-op. } fn partial_relro(&mut self) { - // noop + // No-op. } fn no_relro(&mut self) { - // noop + // No-op. } fn args(&mut self, args: &[String]) { @@ -781,11 +782,11 @@ impl<'a> Linker for EmLinker<'a> { } fn gc_sections(&mut self, _keep_metadata: bool) { - // noop + // No-op. } fn optimize(&mut self) { - // Emscripten performs own optimizations + // Emscripten performs own optimizations. self.cmd.arg(match self.sess.opts.optimize { OptLevel::No => "-O0", OptLevel::Less => "-O1", @@ -794,16 +795,16 @@ impl<'a> Linker for EmLinker<'a> { OptLevel::Size => "-Os", OptLevel::SizeMin => "-Oz" }); - // Unusable until https://github.com/rust-lang/rust/issues/38454 is resolved + // Unusable until issue #38454 is resolved. self.cmd.args(&["--memory-init-file", "0"]); } fn pgo_gen(&mut self) { - // noop, but maybe we need something like the gnu linker? + // No-op, but maybe we need something like the GNU linker? } fn debuginfo(&mut self) { - // Preserve names or generate source maps depending on debug info + // Preserve names or generate source maps depending on debug info. self.cmd.arg(match self.sess.opts.debuginfo { DebugInfo::None => "-g0", DebugInfo::Limited => "-g3", @@ -820,7 +821,7 @@ impl<'a> Linker for EmLinker<'a> { } fn build_static_executable(&mut self) { - // noop + // No-op. } fn export_symbols(&mut self, _tmpdir: &Path, crate_type: CrateType) { @@ -854,19 +855,19 @@ impl<'a> Linker for EmLinker<'a> { } fn subsystem(&mut self, _subsystem: &str) { - // noop + // No-op. } fn finalize(&mut self) -> Command { ::std::mem::replace(&mut self.cmd, Command::new("")) } - // Appears not necessary on Emscripten + // Appears to be unnecessary for Emscripten. fn group_start(&mut self) {} fn group_end(&mut self) {} fn linker_plugin_lto(&mut self) { - // Do nothing + // Do nothing. } } @@ -890,9 +891,9 @@ impl<'a> WasmLd<'a> { // By default LLD's memory layout is: // - // 1. First, a blank page - // 2. Next, all static data - // 3. Finally, the main stack (which grows down) + // 1. First, a blank page. + // 2. Next, all static data. + // 3. Finally, the main stack (which grows down). // // This has the unfortunate consequence that on stack overflows you // corrupt static data and can cause some exceedingly weird bugs. To @@ -912,7 +913,7 @@ impl<'a> WasmLd<'a> { // stick to this and hopefully fix it before stabilization happens. cmd.arg("--allow-undefined"); - // For now we just never have an entry symbol + // For now we just never have an entry symbol. cmd.arg("--no-entry"); // Rust code should never have warnings, and warnings are often @@ -920,7 +921,7 @@ impl<'a> WasmLd<'a> { cmd.arg("--fatal-warnings"); // The symbol visibility story is a bit in flux right now with LLD. - // It's... not entirely clear to me what's going on, but this looks to + // It's not entirely clear to me what's going on, but this looks to // make everything work when `export_symbols` isn't otherwise called for // things like executables. cmd.arg("--export-dynamic"); @@ -1008,8 +1009,7 @@ impl<'a> Linker for WasmLd<'a> { OptLevel::Less => "-O1", OptLevel::Default => "-O2", OptLevel::Aggressive => "-O3", - // Currently LLD doesn't support `Os` and `Oz`, so pass through `O2` - // instead. + // Currently LLD doesn't support `Os` and `Oz`, so pass through `O2` instead. OptLevel::Size => "-O2", OptLevel::SizeMin => "-O2" }); @@ -1043,12 +1043,12 @@ impl<'a> Linker for WasmLd<'a> { ::std::mem::replace(&mut self.cmd, Command::new("")) } - // Not needed for now with LLD + // Not needed for now with LLD. fn group_start(&mut self) {} fn group_end(&mut self) {} fn linker_plugin_lto(&mut self) { - // Do nothing for now + // Do nothing for now. } } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index c372892c521be..ce3569e726bac 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -81,7 +81,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // statically included symbols, it's an export of our library which // needs to be passed on to the linker and encoded in the metadata. // - // As a result, if this id is an FFI item (foreign item) then we only + // As a result, if this ID is an FFI item (foreign item) then we only // let it through if it's included statically. match tcx.hir().get(node_id) { Node::ForeignItem(..) => { diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 20842553c2666..04145973c1b8c 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -66,7 +66,7 @@ pub struct ModuleConfig { pub emit_ir: bool, pub emit_asm: bool, pub emit_obj: bool, - // Miscellaneous flags. These are mostly copied from command-line + // Miscellaneous flags. These are mostly copied from command-line // options. pub verify_llvm_ir: bool, pub no_prepopulate_passes: bool, @@ -78,7 +78,7 @@ pub struct ModuleConfig { pub inline_threshold: Option, // Instead of creating an object file by doing LLVM codegen, just // make the object file bitcode. Provides easy compatibility with - // emscripten's ecc compiler, when used as the linker. + // Emscripten's ecc compiler, when used as the linker. pub obj_is_bitcode: bool, pub no_integrated_as: bool, pub embed_bitcode: bool, @@ -154,7 +154,7 @@ impl ModuleConfig { // Some targets (namely, NVPTX) interact badly with the MergeFunctions // pass. This is because MergeFunctions can generate new function calls - // which may interfere with the target calling convention; e.g. for the + // which may interfere with the target calling convention; e.g., for the // NVPTX target, PTX kernels should not call other PTX kernels. // MergeFunctions can also be configured to generate aliases instead, // but aliases are not supported by some backends (again, NVPTX). @@ -184,7 +184,7 @@ pub struct AssemblerCommand { cmd: Command, } -// HACK(eddyb) work around `#[derive]` producing wrong bounds for `Clone`. +// HACK(eddyb): work around `#[derive]` producing wrong bounds for `Clone`. pub struct TargetMachineFactory( pub Arc Result + Send + Sync>, ); @@ -517,7 +517,7 @@ fn produce_final_output_artifacts(sess: &Session, let copy_if_one_unit = |output_type: OutputType, keep_numbered: bool| { if compiled_modules.modules.len() == 1 { - // 1) Only one codegen unit. In this case it's no difficulty + // 1) Only one codegen unit. In this case it's no difficulty // to copy `foo.0.x` to `foo.x`. let module_name = Some(&compiled_modules.modules[0].name[..]); let path = crate_output.temp_path(output_type, module_name); @@ -536,17 +536,17 @@ fn produce_final_output_artifacts(sess: &Session, .to_owned(); if crate_output.outputs.contains_key(&output_type) { - // 2) Multiple codegen units, with `--emit foo=some_name`. We have + // 2) Multiple codegen units, with `--emit foo=some_name`. We have // no good solution for this case, so warn the user. sess.warn(&format!("ignoring emit path because multiple .{} files \ were produced", ext)); } else if crate_output.single_output_file.is_some() { - // 3) Multiple codegen units, with `-o some_name`. We have + // 3) Multiple codegen units, with `-o some_name`. We have // no good solution for this case, so warn the user. sess.warn(&format!("ignoring -o because multiple .{} files \ were produced", ext)); } else { - // 4) Multiple codegen units, but no explicit name. We + // 4) Multiple codegen units, but no explicit name. We // just leave the `foo.0.x` files in place. // (We don't have to do any work in this case.) } @@ -560,7 +560,7 @@ fn produce_final_output_artifacts(sess: &Session, match *output_type { OutputType::Bitcode => { user_wants_bitcode = true; - // Copy to .bc, but always keep the .0.bc. There is a later + // Copy to .bc, but always keep the .0.bc. There is a later // check to figure out if we should delete .0.bc files, or keep // them for making an rlib. copy_if_one_unit(OutputType::Bitcode, true); @@ -595,7 +595,7 @@ fn produce_final_output_artifacts(sess: &Session, // `-C save-temps` or `--emit=` flags). if !sess.opts.cg.save_temps { - // Remove the temporary .#module-name#.o objects. If the user didn't + // Remove the temporary .#module-name#.o objects. If the user didn't // explicitly request bitcode (with --emit=bc), and the bitcode is not // needed for building an rlib, then we must remove .#module-name#.bc as // well. @@ -652,7 +652,7 @@ fn produce_final_output_artifacts(sess: &Session, } pub fn dump_incremental_data(_codegen_results: &CodegenResults) { - // FIXME(mw): This does not work at the moment because the situation has + // FIXME(mw): this does not work at the moment because the situation has // become more complicated due to incremental LTO. Now a CGU // can have more than two caching states. // println!("[incremental] Re-using {} out of {} modules", @@ -1858,12 +1858,12 @@ impl OngoingCodegen { pub fn wait_for_signal_to_codegen_item(&self) { match self.codegen_worker_receive.recv() { Ok(Message::CodegenItem) => { - // Nothing to do + // Nothing to do. } Ok(_) => panic!("unexpected message"), Err(_) => { - // One of the LLVM threads must have panicked, fall through so - // error handling can be reached. + // One of the LLVM threads must have panicked; fall through so + // that error handling can be reached. } } } diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 7aa75f139d2ae..68675b7509cc1 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -237,7 +237,7 @@ pub fn unsize_thin_ptr<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( result = Some(unsize_thin_ptr(bx, src, src_f.ty, dst_f.ty)); } let (lldata, llextra) = result.unwrap(); - // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. + // HACK(eddyb): have to bitcast pointers until LLVM removes pointee types. (bx.bitcast(lldata, bx.cx().scalar_pair_element_backend_type(dst_layout, 0, true)), bx.bitcast(llextra, bx.cx().scalar_pair_element_backend_type(dst_layout, 1, true))) } @@ -336,7 +336,7 @@ fn cast_shift_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( if lhs_sz < rhs_sz { bx.trunc(rhs, lhs_llty) } else if lhs_sz > rhs_sz { - // FIXME (#1877: If in the future shifting by negative + // FIXME(#1877: If in the future shifting by negative // values is no longer undefined then this is wrong. bx.zext(rhs, lhs_llty) } else { @@ -484,7 +484,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( ); if cx.get_defined_value("main").is_some() { - // FIXME: We should be smart and show a better diagnostic here. + // FIXME: we should be smart and show a better diagnostic here. cx.sess().struct_span_err(sp, "entry symbol `main` defined multiple times") .help("did you use #[no_mangle] on `fn main`? Use #[start] instead") .emit(); diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs index 1b87f160cc35d..973b6cb631ff2 100644 --- a/src/librustc_codegen_ssa/common.rs +++ b/src/librustc_codegen_ssa/common.rs @@ -76,7 +76,7 @@ pub enum AtomicOrdering { NotAtomic, Unordered, Monotonic, - // Consume, // Not specified yet. + // Consume, // Not specified yet. Acquire, Release, AcquireRelease, @@ -112,13 +112,13 @@ pub enum TypeKind { Token, } -// FIXME(mw): Anything that is produced via DepGraph::with_task() must implement -// the HashStable trait. Normally DepGraph::with_task() calls are +// FIXME(mw): Anything that is produced via `DepGraph::with_task()` must implement +// the `HashStable` trait. Normally `DepGraph::with_task()` calls are // hidden behind queries, but CGU creation is a special case in two // ways: (1) it's not a query and (2) CGU are output nodes, so their -// Fingerprints are not actually needed. It remains to be clarified +// `Fingerprint`s are not actually needed. It remains to be clarified // how exactly this case will be handled in the red/green system but -// for now we content ourselves with providing a no-op HashStable +// for now we content ourselves with providing a no-op `HashStable` // implementation for CGUs. mod temp_stable_hash_impls { use rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher, @@ -129,7 +129,7 @@ mod temp_stable_hash_impls { fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { - // do nothing + // Do nothing. } } } @@ -159,7 +159,7 @@ pub fn build_unchecked_lshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( rhs: Bx::Value ) -> Bx::Value { let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs); - // #1877, #10183: Ensure that input is always valid + // #1877, #10183: ensure that input is always valid. let rhs = shift_mask_rhs(bx, rhs); bx.shl(lhs, rhs) } @@ -171,7 +171,7 @@ pub fn build_unchecked_rshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( rhs: Bx::Value ) -> Bx::Value { let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs); - // #1877, #10183: Ensure that input is always valid + // #1877, #10183: ensure that input is always valid. let rhs = shift_mask_rhs(bx, rhs); let is_signed = lhs_t.is_signed(); if is_signed { diff --git a/src/librustc_codegen_ssa/glue.rs b/src/librustc_codegen_ssa/glue.rs index e2b49de05bd11..2b358911faef5 100644 --- a/src/librustc_codegen_ssa/glue.rs +++ b/src/librustc_codegen_ssa/glue.rs @@ -53,7 +53,7 @@ pub fn size_and_align_of_dst<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( let field_ty = layout.field(bx, i).ty; let (unsized_size, mut unsized_align) = size_and_align_of_dst(bx, field_ty, info); - // FIXME (#26403, #27023): We should be adding padding + // FIXME(#26403, #27023): We should be adding padding // to `sized_size` (to accommodate the `unsized_align` // required of the unsized field that follows) before // summing it with `sized_size`. (Note that since #26403 diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index a083bd5d8d18a..444a8bfa7bc1b 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -1,3 +1,7 @@ +//! This crate contains codegen code that is used by all codegen backends (LLVM and others). +//! The backend-agnostic functions of this crate use functions defined in various traits that +//! have to be implemented by each backends. + #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] @@ -16,10 +20,6 @@ #![recursion_limit="256"] -//! This crate contains codegen code that is used by all codegen backends (LLVM and others). -//! The backend-agnostic functions of this crate use functions defined in various traits that -//! have to be implemented by each backends. - #[macro_use] extern crate log; #[macro_use] extern crate rustc; #[macro_use] extern crate syntax; @@ -145,7 +145,6 @@ pub struct CrateInfo { pub missing_lang_items: FxHashMap>, } - pub struct CodegenResults { pub crate_name: Symbol, pub modules: Vec, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index caca1789fc98c..98d940822b755 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -1,21 +1,19 @@ +use rustc_mir::monomorphize; +use rustc_target::abi::call::{ArgType, FnType, PassMode}; +use rustc_target::spec::abi::Abi; use rustc::middle::lang_items; -use rustc::ty::{self, Ty, TypeFoldable}; -use rustc::ty::layout::{self, LayoutOf, HasTyCtxt}; use rustc::mir; use rustc::mir::interpret::EvalErrorKind; -use rustc_target::abi::call::{ArgType, FnType, PassMode}; -use rustc_target::spec::abi::Abi; -use rustc_mir::monomorphize; -use crate::base; +use rustc::ty::{self, Ty, TypeFoldable}; +use rustc::ty::layout::{self, LayoutOf, HasTyCtxt}; +use syntax_pos::Pos; +use syntax::symbol::Symbol; + use crate::MemFlags; +use crate::base; use crate::common::{self, IntPredicate}; use crate::meth; - use crate::traits::*; - -use syntax::symbol::Symbol; -use syntax_pos::Pos; - use super::{FunctionCx, LocalRef}; use super::place::PlaceRef; use super::operand::OperandRef; @@ -51,7 +49,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let span = terminator.source_info.span; let funclet_bb = self.cleanup_kinds[bb].funclet_bb(bb); - // HACK(eddyb) force the right lifetimes, NLL can't figure them out. + // HACK(eddyb): force the right lifetimes; NLL can't figure them out. fn funclet_closure_factory<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( funclet_bb: Option ) -> impl for<'b> Fn( @@ -75,7 +73,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if f == t_f || !base::wants_msvc_seh(tcx.sess) => (lltarget, false), (None, Some(_)) => { - // jump *into* cleanup - need a landing pad if GNU + // Jump *into* cleanup -- need a landing pad if GNU. (this.landing_pad_to(target), false) } (Some(_), None) => span_bug!(span, "{:?} - jump out of cleanup?", terminator), @@ -88,8 +86,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let llblock = |this: &mut Self, target: mir::BasicBlock| { let (lltarget, is_cleanupret) = lltarget(this, target); if is_cleanupret { - // MSVC cross-funclet jump - need a trampoline - + // MSVC cross-funclet jump -- need a trampoline. debug!("llblock: creating cleanup trampoline for {:?}", target); let name = &format!("{:?}_cleanup_trampoline_{:?}", bb, target); let mut trampoline = this.new_block(name); @@ -104,7 +101,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |this: &mut Self, bx: &mut Bx, target: mir::BasicBlock| { let (lltarget, is_cleanupret) = lltarget(this, target); if is_cleanupret { - // micro-optimization: generate a `ret` rather than a jump + // Micro-optimization: generate a `ret` rather than a jump. // to a trampoline. bx.cleanup_ret(funclet(this).unwrap(), Some(lltarget)); } else { @@ -146,7 +143,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // Cleanup is always the cold path. Don't inline // drop glue. Also, when there is a deeply-nested // struct, there are "symmetry" issues that cause - // exponential inlining - see issue #41696. + // exponential inlining (see issue #41696). bx.do_not_inline(llret); } @@ -333,10 +330,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let mut const_cond = bx.const_to_opt_u128(cond, false).map(|c| c == 1); // This case can currently arise only from functions marked - // with #[rustc_inherit_overflow_checks] and inlined from - // another crate (mostly core::num generic/#[inline] fns), + // with `#[rustc_inherit_overflow_checks]` and inlined from + // another crate (mostly `core::num` generic/inline fns), // while the current crate doesn't use overflow checks. - // NOTE: Unlike binops, negation doesn't have its own + // N.B., unlike binops, negation doesn't have its own // checked operation, just a comparison with the minimum // value, so we have to check for the assert message. if !bx.check_overflow() { @@ -363,7 +360,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.cond_br(cond, panic_block.llbb(), lltarget); } - // After this point, bx is the block for the call to panic. + // After this point, `bx` is the block for the call to panic. bx = panic_block; self.set_debug_loc(&mut bx, terminator.source_info); @@ -455,7 +452,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ); let abi = sig.abi; - // Handle intrinsics old codegen wants Expr's for, ourselves. + // Handle intrinsics old codegen wants `Expr`s for, ourselves. let intrinsic = match def { Some(ty::InstanceDef::Intrinsic(def_id)) => Some(bx.tcx().item_name(def_id).as_str()), @@ -492,7 +489,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.new_vtable(sig, &extra_args) } Some(ty::InstanceDef::DropGlue(_, None)) => { - // empty drop glue - a nop. + // Empty drop glue; a no-op. let &(_, target) = destination.as_ref().unwrap(); funclet_br(self, &mut bx, target); return; @@ -500,7 +497,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bx.new_fn_type(sig, &extra_args) }; - // emit a panic or a NOP for `panic_if_uninhabited` + // Emit a panic or a NOP for `panic_if_uninhabited`. if intrinsic == Some("panic_if_uninhabited") { let ty = instance.unwrap().substs.type_at(0); let layout = bx.layout_of(ty); @@ -515,7 +512,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { .max(tcx.data_layout.pointer_align.abi); let str = format!( - "Attempted to instantiate uninhabited type {}", + "attempted to instantiate uninhabited type `{}`", ty ); let msg_str = Symbol::intern(&str).as_str(); @@ -548,7 +545,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { cleanup, ); } else { - // a NOP + // A NOP. funclet_br(self, &mut bx, destination.as_ref().unwrap().1); } return; @@ -558,7 +555,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let arg_count = fn_ty.args.len() + fn_ty.ret.is_indirect() as usize; let mut llargs = Vec::with_capacity(arg_count); - // Prepare the return value destination + // Prepare the return value destination. let ret_dest = if let Some((ref dest, _)) = *destination { let is_intrinsic = intrinsic.is_some(); self.make_return_dest(&mut bx, dest, &fn_ty.ret, &mut llargs, @@ -663,21 +660,21 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let (0, Some(ty::InstanceDef::Virtual(_, idx))) = (i, def) { if let Pair(..) = op.val { - // In the case of Rc, we need to explicitly pass a - // *mut RcBox with a Scalar (not ScalarPair) ABI. This is a hack - // that is understood elsewhere in the compiler as a method on + // In the case of `Rc`, we need to explicitly pass a + // `*mut RcBox` with a `Scalar` (not `ScalarPair`) ABI. This is a + // hack that is understood elsewhere in the compiler as a method on // `dyn Trait`. // To get a `*mut RcBox`, we just keep unwrapping newtypes until - // we get a value of a built-in pointer type + // we get a value of a built-in pointer type. 'descend_newtypes: while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_region_ptr() { 'iter_fields: for i in 0..op.layout.fields.count() { let field = op.extract_field(&mut bx, i); if !field.layout.is_zst() { - // we found the one non-zero-sized field that is allowed + // We found the one non-zero-sized field that is allowed // now find *its* non-zero-sized field, or stop if it's a - // pointer + // pointer. op = field; continue 'descend_newtypes } @@ -686,9 +683,9 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { span_bug!(span, "receiver has no non-zero-sized fields {:?}", op); } - // now that we have `*dyn Trait` or `&dyn Trait`, split it up into its + // Now that we have `*dyn Trait` or `&dyn Trait`, split it up into its // data pointer and vtable. Look up the method in the vtable, and pass - // the data pointer as the first argument + // the data pointer as the first argument. match op.val { Pair(data_ptr, meta) => { llfn = Some(meth::VirtualIndex::from_index(idx) @@ -699,7 +696,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { other => bug!("expected a Pair, got {:?}", other) } } else if let Ref(data_ptr, Some(meta), _) = op.val { - // by-value dynamic dispatch + // By-value dynamic dispatch. llfn = Some(meth::VirtualIndex::from_index(idx) .get_fn(&mut bx, meta, &fn_ty)); llargs.push(data_ptr); @@ -830,7 +827,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.range_metadata(llval, 0..2); } } - // We store bools as i8 so we need to truncate to i1. + // We store bools as `i8` so we need to truncate to `i1`. llval = base::to_immediate(bx, llval, arg.layout); } } @@ -960,7 +957,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn_ret: &ArgType<'tcx, Ty<'tcx>>, llargs: &mut Vec, is_intrinsic: bool ) -> ReturnDest<'tcx, Bx::Value> { - // If the return is ignored, we can just return a do-nothing ReturnDest + // If the return is ignored, we can just return a do-nothing `ReturnDest`. if fn_ret.is_ignore() { return ReturnDest::Nothing; } @@ -969,8 +966,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { LocalRef::Place(dest) => dest, LocalRef::UnsizedPlace(_) => bug!("return type must be sized"), LocalRef::Operand(None) => { - // Handle temporary places, specifically Operand ones, as - // they don't have allocas + // Handle temporary places, specifically `Operand` ones, as + // they don't have `alloca`s. return if fn_ret.is_indirect() { // Odd, but possible, case, we have an operand temporary, // but the calling convention has an indirect return. @@ -980,8 +977,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ReturnDest::IndirectOperand(tmp, index) } else if is_intrinsic { // Currently, intrinsics always need a location to store - // the result. so we create a temporary alloca for the - // result + // the result, so we create a temporary `alloca` for the + // result. let tmp = PlaceRef::alloca(bx, fn_ret.layout, "tmp_ret"); tmp.storage_live(bx); ReturnDest::IndirectOperand(tmp, index) @@ -1000,7 +997,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if dest.align < dest.layout.align.abi { // Currently, MIR code generation does not create calls // that store directly to fields of packed structs (in - // fact, the calls it creates write only to temps), + // fact, the calls it creates write only to temps). // // If someone changes that, please update this code path // to create a temporary. @@ -1095,12 +1092,12 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } enum ReturnDest<'tcx, V> { - // Do nothing, the return value is indirect or ignored + // Do nothing; the return value is indirect or ignored. Nothing, - // Store the return value to the pointer + // Store the return value to the pointer. Store(PlaceRef<'tcx, V>), - // Stores an indirect return value to an operand local place + // Store an indirect return value to an operand local place. IndirectOperand(PlaceRef<'tcx, V>, mir::Local), - // Stores a direct return value to an operand local place + // Store a direct return value to an operand local place. DirectOperand(mir::Local) } diff --git a/src/librustc_codegen_ssa/mir/mod.rs b/src/librustc_codegen_ssa/mir/mod.rs index 203d84bff5bb3..e5ec7b2f8ddea 100644 --- a/src/librustc_codegen_ssa/mir/mod.rs +++ b/src/librustc_codegen_ssa/mir/mod.rs @@ -1,3 +1,11 @@ +mod analyze; +mod block; +pub mod constant; +pub mod place; +pub mod operand; +mod rvalue; +mod statement; + use libc::c_uint; use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts}; use rustc::ty::layout::{TyLayout, HasTyCtxt}; @@ -143,9 +151,9 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - // DILocations inherit source file name from the parent DIScope. Due to macro expansions + // DILocations inherit source file name from the parent DIScope. Due to macro expansions // it may so happen that the current span belongs to a different file than the DIScope - // corresponding to span's containing source scope. If so, we need to create a DIScope + // corresponding to span's containing source scope. If so, we need to create a DIScope // "extension" into that file. fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos) -> Option { @@ -250,7 +258,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( let memory_locals = analyze::non_ssa_locals(&fx); - // Allocate variable and temp allocas + // Allocate variable and temp allocas. fx.locals = { let args = arg_local_refs(&mut bx, &fx, &fx.scopes, &memory_locals); @@ -274,7 +282,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( if layout.is_unsized() { let indirect_place = PlaceRef::alloca_unsized_indirect(&mut bx, layout, &name.as_str()); - // FIXME: add an appropriate debuginfo + // FIXME: add an appropriate debuginfo. LocalRef::UnsizedPlace(indirect_place) } else { let place = PlaceRef::alloca(&mut bx, layout, &name.as_str()); @@ -337,16 +345,15 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( let rpo = traversal::reverse_postorder(&mir); let mut visited = BitSet::new_empty(mir.basic_blocks().len()); - // Codegen the body of each block using reverse postorder + // Codegen the body of each block using reverse post-order. for (bb, _) in rpo { visited.insert(bb.index()); fx.codegen_block(bb); } - // Remove blocks that haven't been visited, or have no - // predecessors. + // Remove blocks that haven't been visited, or have no predecessors. for bb in mir.basic_blocks().indices() { - // Unreachable block + // Unreachable block. if !visited.contains(bb.index()) { debug!("codegen_mir: block {:?} was not visited", bb); unsafe { @@ -506,8 +513,8 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( if arg_scope.is_none() && !memory_locals.contains(local) { // We don't have to cast or keep the argument in the alloca. - // FIXME(eddyb): We should figure out how to use llvm.dbg.value instead - // of putting everything in allocas just so we can use llvm.dbg.declare. + // FIXME(eddyb): we should figure out how to use `llvm.dbg.value` instead + // of putting everything in allocas just so we can use `llvm.dbg.declare`. let local = |op| LocalRef::Operand(Some(op)); match arg.mode { PassMode::Ignore => { @@ -541,7 +548,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( let place = if arg.is_sized_indirect() { // Don't copy an indirect argument to an alloca, the caller // already put it in a temporary alloca and gave it up. - // FIXME: lifetimes + // FIXME: lifetimes. let llarg = bx.get_param(bx.llfn(), llarg_idx as c_uint); bx.set_value_name(llarg, &name); llarg_idx += 1; @@ -568,8 +575,8 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( if arg_index > 0 || mir.upvar_decls.is_empty() { // The Rust ABI passes indirect variables using a pointer and a manual copy, so we // need to insert a deref here, but the C ABI uses a pointer and a copy using the - // byval attribute, for which LLVM always does the deref itself, - // so we must not add it. + // byval attribute, for which LLVM always does the deref itself, so we must not + // add it. let variable_access = VariableAccess::DirectVariable { alloca: place.llval }; @@ -644,11 +651,3 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } }).collect() } - -mod analyze; -mod block; -pub mod constant; -pub mod place; -pub mod operand; -mod rvalue; -mod statement; diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 2c6d968bb032a..fbdc054716a77 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -1,16 +1,14 @@ -use rustc::mir::interpret::{ConstValue, ErrorHandled}; +use std::fmt; + use rustc::mir; +use rustc::mir::interpret::{ConstValue, ErrorHandled}; use rustc::ty; use rustc::ty::layout::{self, Align, LayoutOf, TyLayout}; use crate::base; use crate::MemFlags; use crate::glue; - use crate::traits::*; - -use std::fmt; - use super::{FunctionCx, LocalRef}; use super::place::PlaceRef; @@ -79,7 +77,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { ConstValue::Scalar(x) => { let scalar = match layout.abi { layout::Abi::Scalar(ref x) => x, - _ => bug!("from_const: invalid ByVal layout: {:#?}", layout) + _ => bug!("from_const: invalid `ByVal` layout: {:#?}", layout) }; let llval = bx.cx().scalar_to_backend( x, @@ -91,7 +89,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { ConstValue::Slice(a, b) => { let a_scalar = match layout.abi { layout::Abi::ScalarPair(ref a, _) => a, - _ => bug!("from_const: invalid ScalarPair layout: {:#?}", layout) + _ => bug!("from_const: invalid `ScalarPair` layout: {:#?}", layout) }; let a_llval = bx.cx().scalar_to_backend( a, @@ -130,7 +128,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { let (llptr, llextra) = match self.val { OperandValue::Immediate(llptr) => (llptr, None), OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)), - OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self) + OperandValue::Ref(..) => bug!("deref of by-ref operand {:?}", self) }; let layout = cx.layout_of(projected_ty); PlaceRef { @@ -228,7 +226,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { _ => bug!("OperandRef::extract_field({:?}): not applicable", self) }; - // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. + // HACK(eddyb): have to bitcast pointers until LLVM removes pointee types. // Bools in union fields needs to be truncated. let to_immediate_or_cast = |bx: &mut Bx, val, ty| { if ty == bx.cx().type_i1() { @@ -402,7 +400,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::ProjectionElem::Index(_) | mir::ProjectionElem::ConstantIndex { .. } => { // ZSTs don't require any actual memory access. - // FIXME(eddyb) deduplicate this with the identical + // FIXME(eddyb): deduplicate this with the identical // checks in `codegen_consume` and `extract_field`. let elem = o.layout.field(bx.cx(), 0); if elem.is_zst() { diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 9d6826d8756b7..b508318731496 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -120,7 +120,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { bx.struct_gep(self.llval, bx.cx().backend_field_index(self.layout, ix)) }; PlaceRef { - // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. + // HACK(eddyb): have to bitcast pointers until LLVM removes pointee types. llval: bx.pointercast(llval, bx.cx().type_ptr_to(bx.cx().backend_type(field))), llextra: if bx.cx().type_has_metadata(field.ty) { self.llextra @@ -134,7 +134,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // Simple cases, which don't need DST adjustment: // * no metadata available - just log the case - // * known alignment - sized types, [T], str or a foreign type + // * known alignment - sized types, `[T]`, `str` or a foreign type // * packed struct - there is no alignment padding match field.ty.sty { _ if self.llextra.is_none() => { @@ -146,7 +146,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(), ty::Adt(def, _) => { if def.repr.packed() { - // FIXME(eddyb) generalize the adjustment when we + // FIXME(eddyb): generalize the adjustment when we // start supporting packing to larger alignments. assert_eq!(self.layout.align.abi.bytes(), 1); return simple(); @@ -156,18 +156,19 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } // We need to get the pointer manually now. - // We do this by casting to a *i8, then offsetting it by the appropriate amount. + // We do this by casting to a `*i8`, then offsetting it by the appropriate amount. // We do this instead of, say, simply adjusting the pointer from the result of a GEP // because the field may have an arbitrary alignment in the LLVM representation // anyway. // // To demonstrate: - // struct Foo { - // x: u16, - // y: T - // } // - // The type Foo> is represented in LLVM as { u16, { u16, u8 }}, meaning that + // struct Foo { + // x: u16, + // y: T + // } + // + // The type `Foo>` is represented in LLVM as `{ u16, { u16, u8 }}`, meaning that // the `y` field has 16-bit alignment. let meta = self.llextra; @@ -180,9 +181,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // Bump the unaligned offset up to the appropriate alignment using the // following expression: // - // (unaligned offset + (align - 1)) & -align + // (unaligned offset + (align - 1)) & -align - // Calculate offset + // Calculate offset. let align_sub_1 = bx.sub(unsized_align, bx.cx().const_usize(1u64)); let and_lhs = bx.add(unaligned_offset, align_sub_1); let and_rhs = bx.neg(unsized_align); @@ -190,11 +191,11 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { debug!("struct_field_ptr: DST field offset: {:?}", offset); - // Cast and adjust pointer + // Cast and adjust pointer. let byte_ptr = bx.pointercast(self.llval, bx.cx().type_i8p()); let byte_ptr = bx.gep(byte_ptr, &[offset]); - // Finally, cast back to the type expected + // Finally, cast back to the type expected. let ll_fty = bx.cx().backend_type(field); debug!("struct_field_ptr: Field type is {:?}", ll_fty); @@ -236,7 +237,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // We use `i1` for bytes that are always `0` or `1`, // e.g., `#[repr(i8)] enum E { A, B }`, but we can't // let LLVM interpret the `i1` as signed, because - // then `i1 1` (i.e., E::B) is effectively `i8 -1`. + // then `i1 1` (i.e., `E::B`) is effectively `i8 -1`. layout::Int(_, signed) => !tag.is_bool() && signed, _ => false }; @@ -250,9 +251,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } => { let niche_llty = bx.cx().immediate_backend_type(discr.layout); if niche_variants.start() == niche_variants.end() { - // FIXME(eddyb) Check the actual primitive type here. + // FIXME(eddyb): check the actual primitive type here. let niche_llval = if niche_start == 0 { - // HACK(eddyb) Using `c_null` as it works on all types. + // HACK(eddyb): using `c_null` as it works on all types. bx.cx().const_null(niche_llty) } else { bx.cx().const_uint_big(niche_llty, niche_start) @@ -310,7 +311,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { if variant_index != dataful_variant { if bx.cx().sess().target.target.arch == "arm" || bx.cx().sess().target.target.arch == "aarch64" { - // Issue #34427: As workaround for LLVM bug on ARM, + // FIXME(#34427): as workaround for LLVM bug on ARM, // use memset of 0 before assigning niche value. let fill_byte = bx.cx().const_u8(0); let size = bx.cx().const_usize(self.layout.size.bytes()); @@ -322,9 +323,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { let niche_value = variant_index.as_u32() - niche_variants.start().as_u32(); let niche_value = (niche_value as u128) .wrapping_add(niche_start); - // FIXME(eddyb) Check the actual primitive type here. + // FIXME(eddyb): check the actual primitive type here. let niche_llval = if niche_value == 0 { - // HACK(eddyb) Using `c_null` as it works on all types. + // HACK(eddyb): using `c_null` as it works on all types. bx.cx().const_null(niche_llty) } else { bx.cx().const_uint_big(niche_llty, niche_value) @@ -407,7 +408,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } let result = match *place { - mir::Place::Local(_) => bug!(), // handled above + // Handled above. + mir::Place::Local(_) => bug!(), mir::Place::Promoted(box (index, ty)) => { let param_env = ty::ParamEnv::reveal_all(); let cid = mir::interpret::GlobalId { @@ -423,10 +425,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bug!("promoteds should have an allocation: {:?}", val), }, Err(_) => { - // this is unreachable as long as runtime + // This is unreachable as long as runtime // and compile-time agree on values - // With floats that won't always be true - // so we generate an abort + // With floats that won't always be true, + // so we generate an abort. bx.abort(); let llval = bx.cx().const_undef( bx.cx().type_ptr_to(bx.cx().backend_type(layout)) @@ -489,7 +491,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } // Cast the place pointer type to the new - // array or slice type (*[%_; new_len]). + // array or slice type (`*[%_; new_len]`). subslice.llval = bx.pointercast(subslice.llval, bx.cx().type_ptr_to(bx.cx().backend_type(subslice.layout))); diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 25a7754d118d7..469c56d82b2cc 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -227,26 +227,25 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } mir::CastKind::UnsafeFnPointer => { - // this is a no-op at the LLVM level + // This is a no-op at the LLVM level. operand.val } mir::CastKind::Unsize => { assert!(bx.cx().is_backend_scalar_pair(cast)); match operand.val { OperandValue::Pair(lldata, llextra) => { - // unsize from a fat pointer - this is a - // "trait-object-to-supertrait" coercion, for - // example, - // &'a fmt::Debug+Send => &'a fmt::Debug, + // Unsize from a fat pointer -- this is a + // trait-object-to-supertrait coercion (e.g., + // `&'a fmt::Debug + Send => &'a fmt::Debug`). - // HACK(eddyb) have to bitcast pointers + // HACK(eddyb): have to bitcast pointers // until LLVM removes pointee types. let lldata = bx.pointercast(lldata, bx.cx().scalar_pair_element_backend_type(cast, 0, true)); OperandValue::Pair(lldata, llextra) } OperandValue::Immediate(lldata) => { - // "standard" unsize + // "Standard" unsize. let (lldata, llextra) = base::unsize_thin_ptr(&mut bx, lldata, operand.layout.ty, cast.ty); OperandValue::Pair(lldata, llextra) @@ -263,7 +262,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let data_cast = bx.pointercast(data_ptr, bx.cx().scalar_pair_element_backend_type(cast, 0, true)); OperandValue::Pair(data_cast, meta) - } else { // cast to thin-ptr + } else { + // Cast to thin-ptr. // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and // pointer-cast of that pointer to desired pointer type. let llcast_ty = bx.cx().immediate_backend_type(cast); @@ -902,7 +902,7 @@ fn cast_float_to_int<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( // Step 3: NaN replacement. // For unsigned types, the above step already yielded int_ty::MIN == 0 if x is NaN. - // Therefore we only need to execute this step for signed integer types. + // Therefore, we only need to execute this step for signed integer types. if signed { // LLVM has no isNaN predicate, so we use (x == x) instead let zero = bx.cx().const_uint(int_ty, 0); diff --git a/src/librustc_codegen_ssa/traits/type_.rs b/src/librustc_codegen_ssa/traits/type_.rs index 7c5e615f22452..1d1ce9dc960ad 100644 --- a/src/librustc_codegen_ssa/traits/type_.rs +++ b/src/librustc_codegen_ssa/traits/type_.rs @@ -111,12 +111,12 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> { } fn type_pointee_for_align(&self, align: Align) -> Self::Type { - // FIXME(eddyb) We could find a better approximation if ity.align < align. + // FIXME(eddyb): we could find a better approximation if `ity.align < align`. let ity = layout::Integer::approximate_align(self, align); self.type_from_integer(ity) } - /// Return a LLVM type that has at most the required alignment, + /// Returns an LLVM type that has at most the required alignment, /// and exactly the required size, as a best-effort padding array. fn type_padding_filler(&self, size: Size, align: Align) -> Self::Type { let unit = layout::Integer::approximate_align(self, align); diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 28d7d18422841..3c1561f47f734 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -1,4 +1,4 @@ -//! The Rust compiler. +//! The code generation back-end. //! //! # Note //! @@ -15,23 +15,22 @@ use std::fs; use std::path::Path; use std::sync::{mpsc, Arc}; -use rustc_data_structures::owning_ref::OwningRef; use flate2::Compression; use flate2::write::DeflateEncoder; +use rustc_data_structures::owning_ref::OwningRef; +pub use rustc_data_structures::sync::MetadataRef; -use syntax::symbol::Symbol; +use rustc_target::spec::Target; +use rustc::dep_graph::DepGraph; use rustc::hir::def_id::LOCAL_CRATE; +use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc::session::{Session, CompileIncomplete}; use rustc::session::config::{CrateType, OutputFilenames, PrintRequest}; use rustc::ty::TyCtxt; use rustc::ty::query::Providers; -use rustc::middle::cstore::EncodedMetadata; -use rustc::middle::cstore::MetadataLoader; -use rustc::dep_graph::DepGraph; -use rustc_target::spec::Target; -use crate::link::out_filename; +use syntax::symbol::Symbol; -pub use rustc_data_structures::sync::MetadataRef; +use crate::link::out_filename; pub trait CodegenBackend { fn init(&self, _sess: &Session) {} @@ -50,7 +49,7 @@ pub trait CodegenBackend { rx: mpsc::Receiver> ) -> Box; - /// This is called on the returned `Box` from `codegen_backend` + /// This is called on the returned `Box` from `codegen_backend`. /// /// # Panics /// @@ -113,7 +112,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { crate::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { - Default::default() // Just a dummy + // Just a dummy. + Default::default() }; providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); @@ -133,7 +133,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { crate::symbol_names_test::report_symbol_names(tcx); rustc_incremental::assert_dep_graph(tcx); rustc_incremental::assert_module_sources::assert_module_sources(tcx); - // FIXME: Fix this + // FIXME: fix this. // rustc::middle::dependency_format::calculate(tcx); let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE); diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index f3a1b219f8a84..5458054306ce7 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -20,9 +20,9 @@ pub fn out_filename(sess: &Session, out_filename } -// Make sure files are writeable. Mac, FreeBSD, and Windows system linkers +// Make sure files are writeable. Mac, FreeBSD, and Windows system linkers // check this already -- however, the Linux linker will happily overwrite a -// read-only file. We should be consistent. +// read-only file. We should be consistent. pub fn check_file_is_writeable(file: &Path, sess: &Session) { if !is_writeable(file) { sess.fatal(&format!("output file {} is not writeable -- check its \ diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 8d105853d92f1..9264164ee70ce 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -255,7 +255,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance } } - // FIXME(eddyb) Precompute a custom symbol name based on attributes. + // FIXME(eddyb): precompute a custom symbol name based on attributes. let is_foreign = if let Some(id) = node_id { match tcx.hir().get(id) { Node::ForeignItem(_) => true, @@ -303,7 +303,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance // *somewhere* ty_def_id.index = key.parent.unwrap_or_else(|| { bug!( - "finding type for {:?}, encountered def-id {:?} with no \ + "finding type for {:?}, encountered `DefId` {:?} with no \ parent", def_id, ty_def_id diff --git a/src/librustc_data_structures/bit_set.rs b/src/librustc_data_structures/bit_set.rs index ff7964646d608..f758a8fc648c9 100644 --- a/src/librustc_data_structures/bit_set.rs +++ b/src/librustc_data_structures/bit_set.rs @@ -174,7 +174,7 @@ impl BitSet { /// Duplicates the set as a hybrid set. pub fn to_hybrid(&self) -> HybridBitSet { - // Note: we currently don't bother trying to make a Sparse set. + // Note: we currently don't bother trying to make a `Sparse` set. HybridBitSet::Dense(self.to_owned()) } } @@ -681,7 +681,7 @@ impl BitMatrix { } /// Do the bits from `row` contain `column`? Put another way, is - /// the matrix cell at `(row, column)` true? Put yet another way, + /// the matrix cell at `(row, column)` true? Put yet another way, /// if the matrix represents (transitive) reachability, can /// `row` reach `column`? pub fn contains(&self, row: R, column: C) -> bool { @@ -799,7 +799,7 @@ impl SparseBitMatrix { } /// Do the bits from `row` contain `column`? Put another way, is - /// the matrix cell at `(row, column)` true? Put yet another way, + /// the matrix cell at `(row, column)` true? Put yet another way, /// if the matrix represents (transitive) reachability, can /// `row` reach `column`? pub fn contains(&self, row: R, column: C) -> bool { diff --git a/src/librustc_data_structures/fingerprint.rs b/src/librustc_data_structures/fingerprint.rs index c4c0db5801209..d0b6af515cb95 100644 --- a/src/librustc_data_structures/fingerprint.rs +++ b/src/librustc_data_structures/fingerprint.rs @@ -27,7 +27,7 @@ impl Fingerprint { #[inline] pub fn combine(self, other: Fingerprint) -> Fingerprint { - // See https://stackoverflow.com/a/27952689 on why this function is + // See on why this function is // implemented this way. Fingerprint( self.0.wrapping_mul(3).wrapping_add(other.0), diff --git a/src/librustc_data_structures/graph/dominators/mod.rs b/src/librustc_data_structures/graph/dominators/mod.rs index aaed41d9fa362..a8fb07d7c25b9 100644 --- a/src/librustc_data_structures/graph/dominators/mod.rs +++ b/src/librustc_data_structures/graph/dominators/mod.rs @@ -126,7 +126,7 @@ impl Dominators { } pub fn is_dominated_by(&self, node: Node, dom: Node) -> bool { - // FIXME -- could be optimized by using post-order-rank + // FIXME: could be optimized by using post-order-rank self.dominators(node).any(|n| n == dom) } diff --git a/src/librustc_data_structures/graph/scc/test.rs b/src/librustc_data_structures/graph/scc/test.rs index da3a1ceefe94b..fb074bf64f676 100644 --- a/src/librustc_data_structures/graph/scc/test.rs +++ b/src/librustc_data_structures/graph/scc/test.rs @@ -103,7 +103,7 @@ fn test_find_state_2() { // 0 -> 1 -> 2 -> 1 // // and at this point detect a cycle. The state of 2 will thus be - // `InCycleWith { 1 }`. We will then visit the 1 -> 3 edge, which + // `InCycleWith { 1 }`. We will then visit the 1 -> 3 edge, which // will attempt to visit 0 as well, thus going to the state // `InCycleWith { 0 }`. Finally, node 1 will complete; the lowest // depth of any successor was 3 which had depth 0, and thus it diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 09aec50e4bb11..00ac41a5aa07c 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -601,7 +601,7 @@ impl IndexVec { #[inline] pub fn drain<'a, R: RangeBounds>( - &'a mut self, range: R) -> impl Iterator + 'a { + &'a mut self, range: R) -> impl Iterator + 'a { self.raw.drain(range) } @@ -731,7 +731,7 @@ impl Extend for IndexVec { impl FromIterator for IndexVec { #[inline] - fn from_iter(iter: J) -> Self where J: IntoIterator { + fn from_iter(iter: J) -> Self where J: IntoIterator { IndexVec { raw: FromIterator::from_iter(iter), _marker: PhantomData } } } diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 4490e5f86d2bd..e227fd450ab11 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -121,7 +121,7 @@ pub trait ObligationProcessor { fn process_backedge<'c, I>(&mut self, cycle: I, _marker: PhantomData<&'c Self::Obligation>) - where I: Clone + Iterator; + where I: Clone + Iterator; } /// The result type used by `process_obligation`. @@ -282,7 +282,7 @@ impl ObligationForest { let _ = self.register_obligation_at(obligation, None); } - // returns Err(()) if we already know this obligation failed. + // Returns `Err(())` if we already know this obligation failed. fn register_obligation_at(&mut self, obligation: O, parent: Option) -> Result<(), ()> { @@ -386,7 +386,7 @@ impl ObligationForest { /// This _cannot_ be unrolled (presently, at least). pub fn process_obligations

(&mut self, processor: &mut P, do_completed: DoCompleted) -> Outcome - where P: ObligationProcessor + where P: ObligationProcessor { debug!("process_obligations(len={})", self.nodes.len()); @@ -466,7 +466,7 @@ impl ObligationForest { /// after `mark_as_waiting` marks all nodes with pending /// subobligations as NodeState::Waiting. fn process_cycles

(&mut self, processor: &mut P) - where P: ObligationProcessor + where P: ObligationProcessor { let mut stack = self.scratch.take().unwrap(); debug_assert!(stack.is_empty()); @@ -476,7 +476,7 @@ impl ObligationForest { for index in 0..self.nodes.len() { // For rustc-benchmarks/inflate-0.1.0 this state test is extremely // hot and the state is almost always `Pending` or `Waiting`. It's - // a win to handle the no-op cases immediately to avoid the cost of + // a win to handle the noop cases immediately to avoid the cost of // the function call. let state = self.nodes[index].state.get(); match state { @@ -493,7 +493,7 @@ impl ObligationForest { fn find_cycles_from_node

(&self, stack: &mut Vec, processor: &mut P, index: usize) - where P: ObligationProcessor + where P: ObligationProcessor { let node = &self.nodes[index]; let state = node.state.get(); @@ -682,7 +682,7 @@ impl ObligationForest { if let Some(index) = node.parent { let new_index = node_rewrites[index.get()]; if new_index >= nodes_len { - // parent dead due to error + // Parent is dead due to error. node.parent = None; } else { node.parent = Some(NodeIndex::new(new_index)); @@ -731,7 +731,7 @@ impl Node { } } -// I need a Clone closure +// I need a `Clone` closure. #[derive(Clone)] struct GetObligation<'a, O>(&'a [Node]); diff --git a/src/librustc_data_structures/obligation_forest/test.rs b/src/librustc_data_structures/obligation_forest/test.rs index 27d4bf4959e63..fdf7771107927 100644 --- a/src/librustc_data_structures/obligation_forest/test.rs +++ b/src/librustc_data_structures/obligation_forest/test.rs @@ -49,7 +49,7 @@ impl ObligationProcessor for ClosureObligationProcessor(&mut self, _cycle: I, _marker: PhantomData<&'c Self::Obligation>) - where I: Clone + Iterator + where I: Clone + Iterator { } } diff --git a/src/librustc_data_structures/owning_ref/mod.rs b/src/librustc_data_structures/owning_ref/mod.rs index 236559dcd7c10..94176040eb3c5 100644 --- a/src/librustc_data_structures/owning_ref/mod.rs +++ b/src/librustc_data_structures/owning_ref/mod.rs @@ -509,13 +509,13 @@ impl OwningRef { // TODO: wrap_owner - // FIXME: Naming convention? + // FIXME: naming convention? /// A getter for the underlying owner. pub fn owner(&self) -> &O { &self.owner } - // FIXME: Naming convention? + // FIXME: naming convention? /// Discards the reference and retrieves the owner. pub fn into_inner(self) -> O { self.owner @@ -755,13 +755,13 @@ impl OwningRefMut { // TODO: wrap_owner - // FIXME: Naming convention? + // FIXME: naming convention? /// A getter for the underlying owner. pub fn owner(&self) -> &O { &self.owner } - // FIXME: Naming convention? + // FIXME: naming convention? /// Discards the reference and retrieves the owner. pub fn into_inner(self) -> O { self.owner @@ -996,7 +996,7 @@ impl From> for OwningRef } } -// ^ FIXME: Is a Into impl for calling into_inner() possible as well? +// ^ FIXME: is a Into impl for calling into_inner() possible as well? impl Debug for OwningRef where O: Debug, diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index 91d6e29237002..d7bb783989816 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -14,7 +14,7 @@ pub struct SnapshotMap num_open_snapshots: usize, } -// HACK(eddyb) manual impl avoids `Default` bounds on `K` and `V`. +// HACK(eddyb): manual impl avoids `Default` bounds on `K` and `V`. impl Default for SnapshotMap where K: Hash + Clone + Eq { diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index ba1f6eb56fe88..25479c342a91e 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -215,7 +215,7 @@ cfg_if! { } } - // FIXME: Probably a bad idea (in the threaded case) + // FIXME: probably a bad idea (in the threaded case) impl Clone for MTLock { #[inline] fn clone(&self) -> Self { @@ -539,7 +539,7 @@ impl Default for Lock { } } -// FIXME: Probably a bad idea +// FIXME: probably a bad idea impl Clone for Lock { #[inline] fn clone(&self) -> Self { @@ -631,7 +631,7 @@ impl RwLock { } } -// FIXME: Probably a bad idea +// FIXME: probably a bad idea impl Clone for RwLock { #[inline] fn clone(&self) -> Self { diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 0974607fabea8..ff01701ec7451 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -32,7 +32,7 @@ pub struct TransitiveRelation { closure: Lock>>, } -// HACK(eddyb) manual impl avoids `Default` bound on `T`. +// HACK(eddyb): manual impl avoids `Default` bound on `T`. impl Default for TransitiveRelation { fn default() -> Self { TransitiveRelation { @@ -231,7 +231,7 @@ impl TransitiveRelation { // values. So here is what we do: // // 1. Find the vector `[X | a < X && b < X]` of all values - // `X` where `a < X` and `b < X`. In terms of the + // `X` where `a < X` and `b < X`. In terms of the // graph, this means all values reachable from both `a` // and `b`. Note that this vector is also a set, but we // use the term vector because the order matters diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index e5b290b55c22e..1396098738fd9 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -392,7 +392,7 @@ pub struct CompileController<'a> { pub after_analysis: PhaseController<'a>, pub compilation_done: PhaseController<'a>, - // FIXME we probably want to group the below options together and offer a + // FIXME: we probably want to group the below options together and offer a // better API, rather than this ad-hoc approach. // Whether the compiler should keep the ast beyond parsing. pub keep_ast: bool, @@ -1400,7 +1400,7 @@ fn generated_output_paths( } // Runs `f` on every output file path and returns the first non-None result, or None if `f` -// returns None for every file path. +// returns `None` for every file path. fn check_output(output_paths: &[PathBuf], f: F) -> Option where F: Fn(&PathBuf) -> Option, diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 990ad4ada01a2..d74957f644519 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -685,7 +685,7 @@ pub trait CompilerCalls<'a> { #[derive(Copy, Clone)] pub struct RustcDefaultCalls; -// FIXME remove these and use winapi 0.3 instead +// FIXME: remove these and use winapi 0.3 instead // Duplicates: bootstrap/compile.rs, librustc_errors/emitter.rs #[cfg(unix)] fn stdout_isatty() -> bool { @@ -1447,7 +1447,7 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec(name: String, f: F) -> Result pprust::PpAnn for HygieneAnnotation<'a> { match node { pprust::AnnNode::Ident(&ast::Ident { name, span }) => { s.s.space()?; - // FIXME #16420: this doesn't display the connections + // FIXME(#16420): this doesn't display the connections // between syntax contexts s.synth_comment(format!("{}{:?}", name.as_u32(), span.ctxt())) } @@ -627,9 +627,9 @@ impl UserIdentifiedItem { } } -// Note: Also used by librustdoc, see PR #43348. Consider moving this struct elsewhere. +// Note: also used by librustdoc (see PR #43348). Consider moving this struct elsewhere. // -// FIXME: Currently the `everybody_loops` transformation is not applied to: +// FIXME: currently the `everybody_loops` transformation is not applied to: // * `const fn`, due to issue #43636 that `loop` is not supported for const evaluation. We are // waiting for miri to fix that. // * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging. @@ -818,7 +818,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { } } - // in general the pretty printer processes unexpanded code, so + // In general, the pretty-printer processes unexpanded code, so // we override the default `visit_mac` method which panics. fn visit_mac(&mut self, mac: &mut ast::Mac) { noop_visit_mac(mac, self) @@ -863,8 +863,8 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec, return expand_err_details(r); } blocks::Code::Expr(_) => { - tcx.sess.err("--pretty flowgraph with -Z flowgraph-print annotations requires \ - fn-like node id."); + tcx.sess.err("`--pretty` flowgraph with `-Z flowgraph-print` annotations requires \ + fn-like `NodeId`."); return Ok(()); } blocks::Code::FnLike(fn_like) => { @@ -915,7 +915,7 @@ fn write_output(out: Vec, ofile: Option<&Path>) { Some(p) => { match File::create(p) { Ok(mut w) => w.write_all(&out).unwrap(), - Err(e) => panic!("print-print failed to open {} due to {}", p.display(), e), + Err(e) => panic!("pretty-print failed to open {} due to {}", p.display(), e), } } } @@ -935,7 +935,7 @@ pub fn print_after_parsing(sess: &Session, // Silently ignores an identified node. let out: &mut dyn Write = &mut out; s.call_with_pp_support(sess, None, move |annotation| { - debug!("pretty printing source code {:?}", s); + debug!("pretty-printing source code {:?}", s); let sess = annotation.sess(); pprust::print_crate(sess.source_map(), &sess.parse_sess, @@ -982,14 +982,36 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, let mut rdr = &src[..]; let mut out = Vec::new(); - match (ppm, opt_uii) { - (PpmSource(s), _) => { - // Silently ignores an identified node. - let out: &mut dyn Write = &mut out; - s.call_with_pp_support(sess, Some(hir_map), move |annotation| { - debug!("pretty printing source code {:?}", s); - let sess = annotation.sess(); - pprust::print_crate(sess.source_map(), + let res = match (ppm, opt_uii) { + (PpmSource(s), _) => { + // Silently ignores an identified node. + let out: &mut dyn Write = &mut out; + s.call_with_pp_support(sess, Some(hir_map), move |annotation| { + debug!("pretty-printing source code {:?}", s); + let sess = annotation.sess(); + pprust::print_crate(sess.source_map(), + &sess.parse_sess, + krate, + src_name, + &mut rdr, + box out, + annotation.pp_ann(), + true) + }) + } + + (PpmHir(s), None) => { + let out: &mut dyn Write = &mut out; + s.call_with_pp_support_hir(sess, + cstore, + hir_map, + resolutions, + output_filenames, + crate_name, + move |annotation, krate| { + debug!("pretty-printing source code {:?}", s); + let sess = annotation.sess(); + pprust_hir::print_crate(sess.source_map(), &sess.parse_sess, krate, src_name, @@ -997,98 +1019,76 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, box out, annotation.pp_ann(), true) - }) - } - - (PpmHir(s), None) => { - let out: &mut dyn Write = &mut out; - s.call_with_pp_support_hir(sess, - cstore, - hir_map, - resolutions, - output_filenames, - crate_name, - move |annotation, krate| { - debug!("pretty printing source code {:?}", s); - let sess = annotation.sess(); - pprust_hir::print_crate(sess.source_map(), - &sess.parse_sess, - krate, - src_name, - &mut rdr, - box out, - annotation.pp_ann(), - true) - }) - } - - (PpmHirTree(s), None) => { - let out: &mut dyn Write = &mut out; - s.call_with_pp_support_hir(sess, - cstore, - hir_map, - resolutions, - output_filenames, - crate_name, - move |_annotation, krate| { - debug!("pretty printing source code {:?}", s); - write!(out, "{:#?}", krate) - }) - } + }) + } - (PpmHir(s), Some(uii)) => { - let out: &mut dyn Write = &mut out; - s.call_with_pp_support_hir(sess, - cstore, - hir_map, - resolutions, - output_filenames, - crate_name, - move |annotation, _| { - debug!("pretty printing source code {:?}", s); - let sess = annotation.sess(); - let hir_map = annotation.hir_map().expect("-Z unpretty missing HIR map"); - let mut pp_state = pprust_hir::State::new_from_input(sess.source_map(), - &sess.parse_sess, - src_name, - &mut rdr, - box out, - annotation.pp_ann(), - true); - for node_id in uii.all_matching_node_ids(hir_map) { - let node = hir_map.get(node_id); - pp_state.print_node(node)?; - pp_state.s.space()?; - let path = annotation.node_path(node_id) - .expect("-Z unpretty missing node paths"); - pp_state.synth_comment(path)?; - pp_state.s.hardbreak()?; - } - pp_state.s.eof() - }) - } + (PpmHirTree(s), None) => { + let out: &mut dyn Write = &mut out; + s.call_with_pp_support_hir(sess, + cstore, + hir_map, + resolutions, + output_filenames, + crate_name, + move |_annotation, krate| { + debug!("pretty-printing source code {:?}", s); + write!(out, "{:#?}", krate) + }) + } - (PpmHirTree(s), Some(uii)) => { - let out: &mut dyn Write = &mut out; - s.call_with_pp_support_hir(sess, - cstore, - hir_map, - resolutions, - output_filenames, - crate_name, - move |_annotation, _krate| { - debug!("pretty printing source code {:?}", s); - for node_id in uii.all_matching_node_ids(hir_map) { - let node = hir_map.get(node_id); - write!(out, "{:#?}", node)?; - } - Ok(()) - }) - } + (PpmHir(s), Some(uii)) => { + let out: &mut dyn Write = &mut out; + s.call_with_pp_support_hir(sess, + cstore, + hir_map, + resolutions, + output_filenames, + crate_name, + move |annotation, _| { + debug!("pretty-printing source code {:?}", s); + let sess = annotation.sess(); + let hir_map = annotation.hir_map().expect("`-Z unpretty` missing HIR map"); + let mut pp_state = pprust_hir::State::new_from_input(sess.source_map(), + &sess.parse_sess, + src_name, + &mut rdr, + box out, + annotation.pp_ann(), + true); + for node_id in uii.all_matching_node_ids(hir_map) { + let node = hir_map.get(node_id); + pp_state.print_node(node)?; + pp_state.s.space()?; + let path = annotation.node_path(node_id) + .expect("`-Z unpretty` missing node paths"); + pp_state.synth_comment(path)?; + pp_state.s.hardbreak()?; + } + pp_state.s.eof() + }) + } - _ => unreachable!(), + (PpmHirTree(s), Some(uii)) => { + let out: &mut dyn Write = &mut out; + s.call_with_pp_support_hir(sess, + cstore, + hir_map, + resolutions, + output_filenames, + crate_name, + move |_annotation, _krate| { + debug!("pretty-printing source code {:?}", s); + for node_id in uii.all_matching_node_ids(hir_map) { + let node = hir_map.get(node_id); + write!(out, "{:#?}", node)?; + } + Ok(()) + }) } - .unwrap(); + + _ => unreachable!(), + }; + res.unwrap(); write_output(out, ofile); } @@ -1106,11 +1106,11 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, ppm: PpMode, uii: Option, ofile: Option<&Path>) { - let nodeid = if let Some(uii) = uii { - debug!("pretty printing for {:?}", uii); + let node_id = if let Some(uii) = uii { + debug!("pretty-printing for {:?}", uii); Some(uii.to_one_node_id("-Z unpretty", sess, &hir_map)) } else { - debug!("pretty printing for whole crate"); + debug!("pretty-printing for whole crate"); None }; @@ -1119,64 +1119,66 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, let control = &driver::CompileController::basic(); let codegen_backend = ::get_codegen_backend(sess); let mut arenas = AllArenas::new(); - abort_on_err(driver::phase_3_run_analysis_passes(&*codegen_backend, - control, - sess, - cstore, - hir_map.clone(), - resolutions.clone(), - &mut arenas, - crate_name, - output_filenames, - |tcx, _, _| { - match ppm { - PpmMir | PpmMirCFG => { - if let Some(nodeid) = nodeid { - let def_id = tcx.hir().local_def_id(nodeid); - match ppm { - PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out), - PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out), - _ => unreachable!(), - }?; - } else { - match ppm { - PpmMir => write_mir_pretty(tcx, None, &mut out), - PpmMirCFG => write_mir_graphviz(tcx, None, &mut out), - _ => unreachable!(), - }?; - } - Ok(()) - } - PpmFlowGraph(mode) => { - let nodeid = - nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \ - suffix (b::c::d)"); - let node = tcx.hir().find(nodeid).unwrap_or_else(|| { - tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid)) - }); - - match blocks::Code::from_node(&tcx.hir(), nodeid) { - Some(code) => { - let variants = gather_flowgraph_variants(tcx.sess); - - let out: &mut dyn Write = &mut out; - - print_flowgraph(variants, tcx, code, mode, out) + let res = abort_on_err(driver::phase_3_run_analysis_passes( + &*codegen_backend, + control, + sess, + cstore, + hir_map.clone(), + resolutions.clone(), + &mut arenas, + crate_name, + output_filenames, + |tcx, _, _| { + match ppm { + PpmMir | PpmMirCFG => { + if let Some(node_id) = node_id { + let def_id = tcx.hir().local_def_id(node_id); + match ppm { + PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out), + PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out), + _ => unreachable!(), + }?; + } else { + match ppm { + PpmMir => write_mir_pretty(tcx, None, &mut out), + PpmMirCFG => write_mir_graphviz(tcx, None, &mut out), + _ => unreachable!(), + }?; } - None => { - let message = format!("--pretty=flowgraph needs block, fn, or method; \ - got {:?}", - node); + Ok(()) + } + PpmFlowGraph(mode) => { + let node_id = + node_id.expect("`pretty flowgraph=..` needs `NodeId` (int) or unique \ + path suffix (b::c::d)"); + let node = tcx.hir().find(node_id).unwrap_or_else(|| { + tcx.sess.fatal(&format!("`--pretty` flowgraph couldn't find `NodeId`: {}", + node_id)) + }); + + match blocks::Code::from_node(&tcx.hir(), node_id) { + Some(code) => { + let variants = gather_flowgraph_variants(tcx.sess); + + let out: &mut dyn Write = &mut out; + + print_flowgraph(variants, tcx, code, mode, out) + } + None => { + let message = format!("`--pretty=flowgraph` needs block, fn, \ + or method; got {:?}", + node); - tcx.sess.span_fatal(tcx.hir().span(nodeid), &message) + tcx.sess.span_fatal(tcx.hir().span(node_id), &message) + } } } + _ => unreachable!(), } - _ => unreachable!(), } - }), - sess) - .unwrap(); + ), sess); + res.unwrap(); write_output(out, ofile); } diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index eb13a5668f927..655582fc1b131 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -27,7 +27,7 @@ pub fn dump(sess: &Session, path: String) { let params = ProfQDumpParams { path, ack: tx, - // FIXME: Add another compiler flag to toggle whether this log + // FIXME: add another compiler flag to toggle whether this log // is written; false for now dump_profq_msg_log: true, }; @@ -69,7 +69,7 @@ fn profile_queries_thread(r: Receiver) { loop { let msg = r.recv(); if let Err(_recv_err) = msg { - // FIXME: Perhaps do something smarter than simply quitting? + // FIXME: perhaps do something smarter than simply quitting? break }; let msg = msg.unwrap(); diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 2ec755bd62691..bdf4bf1479cfe 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -474,17 +474,17 @@ fn sub_bound_free_true() { }) } -/// Test substituting a bound region into a function, which introduces another level of binding. -/// This requires adjusting the Debruijn index. +/// Tests substituting a bound region into a function, which introduces another level of binding. +/// This requires adjusting the De Bruijn index. #[test] fn subst_ty_renumber_bound() { test_env(EMPTY_SOURCE_STR, errors(&[]), |env| { // Situation: - // Theta = [A -> &'a foo] + // `Theta = [A -> &'a foo]` let t_rptr_bound1 = env.t_rptr_late_bound(1); - // t_source = fn(A) + // `t_source = fn(A)` let t_source = { let t_param = env.t_param(0); env.t_fn(&[t_param], env.t_nil()) @@ -493,7 +493,7 @@ fn subst_ty_renumber_bound() { let substs = env.infcx.tcx.intern_substs(&[t_rptr_bound1.into()]); let t_substituted = t_source.subst(env.infcx.tcx, substs); - // t_expected = fn(&'a isize) + // `t_expected = fn(&'a isize)` let t_expected = { let t_ptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); env.t_fn(&[t_ptr_bound2], env.t_nil()) @@ -529,7 +529,7 @@ fn subst_ty_renumber_some_bounds() { // `t_expected = (&'a isize, fn(&'a isize))` // - // However, note that the Debruijn index is different in the different cases. + // However, note that the De Bruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_nil())) @@ -589,7 +589,7 @@ fn subst_region_renumber_region() { // `t_expected = fn(&'a isize)` // - // but not that the Debruijn index is different in the different cases. + // but not that the De Bruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); env.t_fn(&[t_rptr_bound2], env.t_nil()) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index e9f269b6e2410..c64e74625f692 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1471,11 +1471,11 @@ fn emit_to_destination(rendered_buffer: &[Vec], // // On Unix systems, we write into a buffered terminal rather than directly to a terminal. When // the .flush() is called we take the buffer created from the buffered writes and write it at - // one shot. Because the Unix systems use ANSI for the colors, which is a text-based styling + // one shot. Because the Unix systems use ANSI for the colors, which is a text-based styling // scheme, this buffered approach works and maintains the styling. // // On Windows, styling happens through calls to a terminal API. This prevents us from using the - // same buffering approach. Instead, we use a global Windows mutex, which we acquire long + // same buffering approach. Instead, we use a global Windows mutex, which we acquire long // enough to output the full error message, then we release. let _buffer_lock = lock::acquire_global_lock("rustc_errors"); for (pos, line) in rendered_buffer.iter().enumerate() { diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 87b4751526835..8dac0ed2ab57a 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -78,7 +78,7 @@ pub enum SuggestionStyle { /// Do not display this suggestion in the cli output, it is only meant for tools. CompletelyHidden, /// Always show the suggested code. - /// This will *not* show the code if the suggestion is inline *and* the suggested code is + /// This will **not** show the code if the suggestion is inline *and* the suggested code is /// empty. ShowCode, } @@ -476,7 +476,7 @@ impl Handler { result.code(code); result } - // FIXME: This method should be removed (every error should have an associated error code). + // FIXME: this method should be removed (every error should have an associated error code). pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> { DiagnosticBuilder::new(self, Level::Error, msg) } @@ -559,7 +559,7 @@ impl Handler { } pub fn delay_span_bug>(&self, sp: S, msg: &str) { if self.flags.treat_err_as_bug { - // FIXME: don't abort here if report_delayed_bugs is off + // FIXME: don't abort here if `report_delayed_bugs` is off. self.span_bug(sp, msg); } let mut diagnostic = Diagnostic::new(Level::Bug, msg); diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index fe44e0cbe6143..52dd34b7b026a 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -103,7 +103,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> { Some(word) if value.is_none() => value = Some(word.name()), _ => - // FIXME better-encapsulate meta_item (don't directly access `node`) + // FIXME: better-encapsulate meta_item (don't directly access `node`) span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item.node), } } @@ -359,7 +359,7 @@ fn walk_between<'q>(query: &'q DepGraphQuery, { // This is a bit tricky. We want to include a node only if it is: // (a) reachable from a source and (b) will reach a target. And we - // have to be careful about cycles etc. Luckily efficiency is not + // have to be careful about cycles etc. Luckily efficiency is not // a big concern! #[derive(Copy, Clone, PartialEq)] diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index c13a3533032a8..1125a48cca690 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -15,6 +15,8 @@ use std::iter::FromIterator; use std::vec::Vec; + +use rustc_data_structures::fx::FxHashSet; use rustc::dep_graph::{DepNode, label_strs}; use rustc::hir; use rustc::hir::{ItemKind as HirItem, ImplItemKind, TraitItemKind}; @@ -23,25 +25,25 @@ use rustc::hir::def_id::DefId; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::intravisit; use rustc::ich::{ATTR_DIRTY, ATTR_CLEAN}; -use syntax::ast::{self, Attribute, NestedMetaItem}; -use rustc_data_structures::fx::FxHashSet; -use syntax_pos::Span; use rustc::ty::TyCtxt; +use syntax_pos::Span; +use syntax::ast::{self, Attribute, NestedMetaItem}; const EXCEPT: &str = "except"; const LABEL: &str = "label"; const CFG: &str = "cfg"; -// Base and Extra labels to build up the labels +// `Base` and `Extra` labels to build up the labels +// ------------------------------------------------ -/// For typedef, constants, and statics +/// `DepNode`s for typedefs, constants, and statics. const BASE_CONST: &[&str] = &[ label_strs::TypeOfItem, ]; -/// DepNodes for functions + methods +/// `DepNode`s for functions and methods. const BASE_FN: &[&str] = &[ - // Callers will depend on the signature of these items, so we better test + // Callers will depend on the signature of these items, so we better test. label_strs::FnSignature, label_strs::GenericsOfItem, label_strs::PredicatesOfItem, @@ -52,28 +54,28 @@ const BASE_FN: &[&str] = &[ label_strs::TypeckTables, ]; -/// DepNodes for Hir, which is pretty much everything +/// `DepNode`s for `Hir`, which is pretty much everything. const BASE_HIR: &[&str] = &[ - // Hir and HirBody should be computed for all nodes + // `Hir` and `HirBody` should be computed for all nodes. label_strs::Hir, label_strs::HirBody, ]; -/// `impl` implementation of struct/trait +/// `DepNode`s for `impl` implementations of structs/traits. const BASE_IMPL: &[&str] = &[ label_strs::AssociatedItemDefIds, label_strs::GenericsOfItem, label_strs::ImplTraitRef, ]; -/// DepNodes for MirBuilt/Optimized, which is relevant in "executable" -/// code, i.e., functions+methods +/// `DepNode`s for `MirValidated`/`MirOptimized`, which is relevant in "executable" +/// code (i.e., functions and methods). const BASE_MIR: &[&str] = &[ label_strs::MirOptimized, label_strs::MirBuilt, ]; -/// Struct, Enum and Union DepNodes +/// Struct, enum and union `DepNode`s. /// /// Note that changing the type of a field does not change the type of the struct or enum, but /// adding/removing fields or changing a fields name or visibility does. @@ -103,21 +105,22 @@ const EXTRA_TRAIT: &[&str] = &[ label_strs::TraitOfItem, ]; -// Fully Built Labels +// Fully-built labels +// ------------------ const LABELS_CONST: &[&[&str]] = &[ BASE_HIR, BASE_CONST, ]; -/// Constant/Typedef in an impl +/// Impl constant/typedef `DepNode`s. const LABELS_CONST_IN_IMPL: &[&[&str]] = &[ BASE_HIR, BASE_CONST, EXTRA_ASSOCIATED, ]; -/// Trait-Const/Typedef DepNodes +/// Trait constant/typedef `DepNode`s. const LABELS_CONST_IN_TRAIT: &[&[&str]] = &[ BASE_HIR, BASE_CONST, @@ -174,16 +177,14 @@ const LABELS_TRAIT: &[&[&str]] = &[ ]; -// FIXME: Struct/Enum/Unions Fields (there is currently no way to attach these) +// FIXME: there is currently no way to attach struct/enum/union fields. // // Fields are kind of separate from their containers, as they can change independently from -// them. We should at least check -// -// TypeOfItem for these. +// them. We should at least check `TypeOfItem` for these. type Labels = FxHashSet; -/// Represents the requested configuration by rustc_clean/dirty +/// Represents the requested configuration by rustc_clean/dirty. struct Assertion { clean: Labels, dirty: Labels, @@ -206,7 +207,7 @@ impl Assertion { } pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - // can't add `#[rustc_dirty]` etc without opting in to this feature + // Can't add `#[rustc_dirty]`, etc., without opting in to this feature. if !tcx.features().rustc_attrs { return; } @@ -249,11 +250,11 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { } else if attr.check_name(ATTR_CLEAN) { true } else { - // skip: not rustc_clean/dirty + // Skip: not rustc_clean/dirty. return None }; if !check_config(self.tcx, attr) { - // skip: not the correct `cfg=` + // Skip: not the correct `cfg=`. return None; } let assertion = if let Some(labels) = self.labels(attr) { @@ -315,19 +316,19 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { return self.resolve_labels(&item, value.as_str().as_ref()); } } - // if no `label` or `except` is given, only the node's group are asserted + // If no `label` or `except` is given, only the node's group are asserted. Labels::default() } - /// Return all DepNode labels that should be asserted for this item. - /// index=0 is the "name" used for error messages + /// Returns all DepNode labels that should be asserted for this item. + /// `index = 0` is the "name" used for error messages fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) { let node = self.tcx.hir().get(item_id); let (name, labels) = match node { HirNode::Item(item) => { match item.node { - // note: these are in the same order as hir::Item_; - // FIXME(michaelwoerister): do commented out ones + // N.B., these are in the same order as `hir::Item_;` + // FIXME(michaelwoerister): do commented out ones. // // An `extern crate` item, with optional original crate name, // HirItem::ExternCrate(..), // intentionally no assertions @@ -335,37 +336,37 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // // `use foo::bar::*;` or `use foo::bar::baz as quux;` // HirItem::Use(..), // intentionally no assertions - // A `static` item + // A `static` item. HirItem::Static(..) => ("ItemStatic", LABELS_CONST), - // A `const` item + // A `const` item. HirItem::Const(..) => ("ItemConst", LABELS_CONST), - // A function declaration + // A function declaration. HirItem::Fn(..) => ("ItemFn", LABELS_FN), - // // A module + // A module. HirItem::Mod(..) =>("ItemMod", LABELS_HIR_ONLY), - // // An external module + // An external module. HirItem::ForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), - // Module-level inline assembly (from global_asm!) + // Module-level inline assembly (from `global_asm!`). HirItem::GlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), - // A type alias, e.g., `type Foo = Bar` + // A type alias (e.g., `type Foo = Bar`) HirItem::Ty(..) => ("ItemTy", LABELS_HIR_ONLY), - // An enum definition, e.g., `enum Foo {C, D}` + // An enum definition (e.g., `enum Foo {C, D}`). HirItem::Enum(..) => ("ItemEnum", LABELS_ADT), - // A struct definition, e.g., `struct Foo {x: A}` + // A struct definition (e.g., `struct Foo {x: A}`). HirItem::Struct(..) => ("ItemStruct", LABELS_ADT), - // A union definition, e.g., `union Foo {x: A, y: B}` + // A union definition (e.g., `union Foo {x: A, y: B}`). HirItem::Union(..) => ("ItemUnion", LABELS_ADT), - // Represents a Trait Declaration + // Represents a trait declaration // FIXME(michaelwoerister): trait declaration is buggy because sometimes some of // the depnodes don't exist (because they legitametely didn't need to be // calculated) @@ -381,7 +382,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // //HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT), - // An implementation, eg `impl Trait for Foo { .. }` + // An implementation (e.g., `impl Trait for Foo { .. }`). HirItem::Impl(..) => ("ItemKind::Impl", LABELS_IMPL), _ => self.tcx.sess.span_fatal( diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 7dcd5c94bf298..a24c6adda35e9 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -524,7 +524,7 @@ fn find_source_directory(crate_dir: &Path, fn find_source_directory_in_iter(iter: I, source_directories_already_tried: &FxHashSet) -> Option - where I: Iterator + where I: Iterator { let mut best_candidate = (UNIX_EPOCH, None); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 28e01bd9793fd..e6b0fa85436da 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -21,17 +21,16 @@ //! If you define a new `LateLintPass`, you will also need to add it to the //! `late_lint_methods!` invocation in `lib.rs`. +// Hardwired lints from librustc. +use log::debug; +use rustc::hir::{self, GenericParamKind, Node, PatKind}; use rustc::hir::def::Def; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::lint::{LateContext, LintContext, LintArray}; +use rustc::lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext}; +pub use rustc::lint::builtin::*; use rustc::ty::{self, Ty}; -use rustc::{lint, util}; -use hir::Node; -use util::nodemap::NodeSet; -use lint::{LateContext, LintContext, LintArray}; -use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext}; - -use rustc::util::nodemap::FxHashSet; - +use rustc::util::nodemap::{FxHashSet, NodeSet}; use syntax::tokenstream::{TokenTree, TokenStream}; use syntax::ast; use syntax::ptr::P; @@ -48,15 +47,8 @@ use syntax::print::pprust::expr_to_string; use syntax::visit::FnKind; use syntax::struct_span_err; -use rustc::hir::{self, GenericParamKind, PatKind}; - use crate::nonstandard_style::{MethodLateContext, method_context}; -use log::debug; - -// hardwired lints from librustc -pub use lint::builtin::*; - declare_lint! { WHILE_TRUE, Warn, @@ -193,17 +185,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { continue; } if fieldpat.span.ctxt().outer().expn_info().is_some() { - // Don't lint if this is a macro expansion: macro authors - // shouldn't have to worry about this kind of style issue - // (Issue #49588) + // Don't lint if this is a macro expansion; macro authors + // shouldn't have to worry about this kind of style problem + // (see issue #49588). continue; } if let PatKind::Binding(_, _, _, ident, None) = fieldpat.node.pat.node { if cx.tcx.find_field_index(ident, &variant) == Some(cx.tcx.field_index(fieldpat.node.id, cx.tables)) { - let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, - fieldpat.span, - &format!("the `{}:` in this pattern is redundant", ident)); + let mut err = cx.struct_span_lint( + NON_SHORTHAND_FIELD_PATTERNS, + fieldpat.span, + &format!("the `{}:` in this pattern is redundant", ident)); let subspan = cx.tcx.sess.source_map().span_through_char(fieldpat.span, ':'); err.span_suggestion_short( @@ -241,7 +234,7 @@ impl LintPass for UnsafeCode { impl UnsafeCode { fn report_unsafe(&self, cx: &EarlyContext<'_>, span: Span, desc: &'static str) { - // This comes from a macro that has #[allow_internal_unsafe]. + // This comes from a macro that has `#[allow_internal_unsafe]`. if span.allows_unsafe() { return; } @@ -319,6 +312,7 @@ declare_lint! { report_in_external_macro: true } +#[derive(Clone)] pub struct MissingDoc { /// Stack of whether `#[doc(hidden)]` is set at each level which has lint attributes. doc_hidden_stack: Vec, @@ -378,7 +372,7 @@ impl MissingDoc { // Only check publicly-visible items, using the result from the privacy pass. // It's an option so the crate root can also use this function (it doesn't - // have a NodeId). + // have a `NodeId`). if let Some(id) = id { if !cx.access_levels.is_exported(id) { return; @@ -442,7 +436,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { hir::ItemKind::Struct(..) => "a struct", hir::ItemKind::Union(..) => "a union", hir::ItemKind::Trait(.., ref trait_item_refs) => { - // Issue #11592, traits are always considered exported, even when private. + // Issue #11592: traits are always considered exported, even when private. if let hir::VisibilityKind::Inherited = it.vis.node { self.private_traits.insert(it.id); for trait_item_ref in trait_item_refs { @@ -454,7 +448,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } hir::ItemKind::Ty(..) => "a type alias", hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => { - // If the trait is private, add the impl items to private_traits so they don't get + // If the trait is private, add the impl items to `private_traits` so they don't get // reported for missing docs. let real_trait = trait_ref.path.def.def_id(); if let Some(node_id) = cx.tcx.hir().as_local_node_id(real_trait) { @@ -605,6 +599,7 @@ declare_lint! { "detects missing implementations of fmt::Debug" } +#[derive(Clone)] pub struct MissingDebugImplementations { impling_types: Option, } @@ -800,7 +795,7 @@ impl LintPass for UnusedDocComment { impl UnusedDocComment { fn warn_if_doc<'a, 'tcx, - I: Iterator, + I: Iterator, C: LintContext<'tcx>>(&self, mut attrs: I, cx: &C) { if let Some(attr) = attrs.find(|a| a.is_value_str() && a.check_name("doc")) { cx.struct_span_lint(UNUSED_DOC_COMMENTS, attr.span, "doc comment not used by rustdoc") @@ -859,8 +854,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { Some(cnum) => cx.tcx.plugin_registrar_fn(cnum), None => { // Probably means we aren't linking the crate for some reason. - // - // Not sure if / when this could happen. + // Not sure if/when this could happen. return; } }; @@ -917,7 +911,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { "remove this attribute", String::new(), // Use of `#[no_mangle]` suggests FFI intent; correct - // fix may be to monomorphize source by hand + // fix may be to monomorphize source by hand. Applicability::MaybeIncorrect ); err.emit(); @@ -930,15 +924,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { hir::ItemKind::Const(..) => { if attr::contains_name(&it.attrs, "no_mangle") { // Const items do not refer to a particular location in memory, and therefore - // don't have anything to attach a symbol to + // don't have anything to attach a symbol to. let msg = "const items should never be #[no_mangle]"; let mut err = cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg); - // account for "pub const" (#45562) + // Account for `pub const` (#45562). let start = cx.tcx.sess.source_map().span_to_snippet(it.span) .map(|snippet| snippet.find("const").unwrap_or(0)) .unwrap_or(0) as u32; - // `const` is 5 chars + // `const` is 5 chars. let const_span = it.span.with_hi(BytePos(it.span.lo().0 + start + 5)); err.span_suggestion( const_span, @@ -1017,14 +1011,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { } } -/// Forbids using the `#[feature(...)]` attribute +/// Forbids using the `#[feature(...)]` attribute. #[derive(Copy, Clone)] pub struct UnstableFeatures; declare_lint! { UNSTABLE_FEATURES, Allow, - "enabling unstable features (deprecated. do not use)" + "enabling unstable features (deprecated, do not use)" } impl LintPass for UnstableFeatures { @@ -1050,6 +1044,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures { } /// Lint for unions that contain fields with possibly non-trivial destructors. +#[derive(Copy, Clone)] pub struct UnionsWithDropFields; declare_lint! { @@ -1162,7 +1157,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub { /// Lint for trait and lifetime bounds in type aliases being mostly ignored. /// They are relevant when using associated types, but otherwise neither checked /// at definition site nor enforced at use site. - +#[derive(Copy, Clone)] pub struct TypeAliasBounds; declare_lint! { @@ -1202,7 +1197,7 @@ impl TypeAliasBounds { fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder<'_>) { // Access to associates types should use `::Assoc`, which does not need a - // bound. Let's see if this type does that. + // bound. Let's see if this type does that. // We use a HIR visitor to walk the type. use rustc::hir::intravisit::{self, Visitor}; @@ -1238,12 +1233,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { _ => return, }; let mut suggested_changing_assoc_types = false; - // There must not be a where clause + // There must not be a where-clause. if !type_alias_generics.where_clause.predicates.is_empty() { let spans : Vec<_> = type_alias_generics.where_clause.predicates.iter() .map(|pred| pred.span()).collect(); let mut err = cx.struct_span_lint(TYPE_ALIAS_BOUNDS, spans, - "where clauses are not enforced in type aliases"); + "where-clauses are not enforced in type aliases"); err.help("the clause will not be checked when the type alias is used, \ and should be removed"); if !suggested_changing_assoc_types { @@ -1252,7 +1247,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { } err.emit(); } - // The parameters must not have bounds + // The parameters must not have bounds. for param in type_alias_generics.params.iter() { let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect(); if !spans.is_empty() { @@ -1277,6 +1272,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { /// Without this lint, we might not get any diagnostic if the constant is /// unused within this crate, even though downstream crates can't use it /// without producing an error. +#[derive(Copy, Clone)] pub struct UnusedBrokenConst; impl LintPass for UnusedBrokenConst { @@ -1288,6 +1284,7 @@ impl LintPass for UnusedBrokenConst { lint_array!() } } + fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) { let def_id = cx.tcx.hir().body_owner_def_id(body_id); let is_static = cx.tcx.is_static(def_id).is_some(); @@ -1301,7 +1298,7 @@ fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) { instance: ty::Instance::mono(cx.tcx, def_id), promoted: None }; - // trigger the query once for all constants since that will already report the errors + // Trigger the query once for all constants, since that will already report the errors. let _ = cx.tcx.const_eval(param_env.and(cid)); } @@ -1321,6 +1318,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst { /// Lint for trait and lifetime bounds that don't depend on type parameters /// which either do nothing, or stop the item from being used. +#[derive(Copy, Clone)] pub struct TrivialConstraints; declare_lint! { @@ -1348,7 +1346,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints { use rustc::ty::fold::TypeFoldable; use rustc::ty::Predicate::*; - if cx.tcx.features().trivial_bounds { let def_id = cx.tcx.hir().local_def_id(item.id); let predicates = cx.tcx.predicates_of(def_id); @@ -1359,9 +1356,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints { RegionOutlives(..) => "Lifetime", // Ignore projections, as they can only be global - // if the trait bound is global + // if the trait bound is global. Projection(..) | - // Ignore bounds that a user can't type + // Ignore bounds that a user can't type. WellFormed(..) | ObjectSafe(..) | ClosureKind(..) | @@ -1411,7 +1408,7 @@ impl LintPass for SoftLints { UNIONS_WITH_DROP_FIELDS, UNREACHABLE_PUB, TYPE_ALIAS_BOUNDS, - TRIVIAL_BOUNDS + TRIVIAL_BOUNDS, ) } } @@ -1422,7 +1419,7 @@ declare_lint! { "`...` range patterns are deprecated" } - +#[derive(Copy, Clone)] pub struct EllipsisInclusiveRangePatterns; impl LintPass for EllipsisInclusiveRangePatterns { @@ -1489,8 +1486,10 @@ declare_lint! { report_in_external_macro: true } +#[derive(Copy, Clone)] pub struct UnnameableTestItems { - boundary: ast::NodeId, // NodeId of the item under which things are not nameable + // `NodeId` of the item under which things are not nameable. + boundary: ast::NodeId, items_nameable: bool, } @@ -1565,7 +1564,7 @@ impl KeywordIdents { for tt in tokens.into_trees() { match tt { TokenTree::Token(span, tok) => match tok.ident() { - // only report non-raw idents + // Only report non-raw idents. Some((ident, false)) => { self.check_ident(cx, ast::Ident { span: span.substitute_dummy(ident.span), @@ -1634,7 +1633,7 @@ impl EarlyLintPass for KeywordIdents { }, }; - // don't lint `r#foo` + // Don't lint `r#foo`. if is_raw_ident(ident) { return; } @@ -1656,7 +1655,7 @@ impl EarlyLintPass for KeywordIdents { } } - +#[derive(Copy, Clone)] pub struct ExplicitOutlivesRequirements; impl LintPass for ExplicitOutlivesRequirements { @@ -1679,9 +1678,9 @@ impl ExplicitOutlivesRequirements { infer_static: bool ) -> Vec<(usize, Span)> { // For lack of a more elegant strategy for comparing the `ty::Predicate`s - // returned by this query with the params/bounds grabbed from the HIR—and - // with some regrets—we're going to covert the param/lifetime names to - // strings + // returned by this query with the params/bounds grabbed from the HIR (and + // with some regrets), we're going to covert the param/lifetime names to + // strings. let inferred_outlives = cx.tcx.inferred_outlives_of(item_def_id); let ty_lt_names = inferred_outlives.iter().filter_map(|pred| { @@ -1711,7 +1710,8 @@ impl ExplicitOutlivesRequirements { _ => false }; if is_static && !infer_static { - // infer-outlives for 'static is still feature-gated (tracking issue #44493) + // `infer-outlives` for `'static` is still feature-gated + // (tracking issue #44493). continue; } @@ -1734,9 +1734,9 @@ impl ExplicitOutlivesRequirements { return Vec::new(); } if bound_spans.len() == bounds.len() { - let (_, last_bound_span) = bound_spans[bound_spans.len()-1]; + let (_, last_bound_span) = bound_spans[bound_spans.len() - 1]; // If all bounds are inferable, we want to delete the colon, so - // start from just after the parameter (span passed as argument) + // start from just after the parameter (span passed as argument). vec![lo.to(last_bound_span)] } else { let mut merged = Vec::new(); @@ -1745,18 +1745,18 @@ impl ExplicitOutlivesRequirements { let mut from_start = true; for (i, bound_span) in bound_spans { match last_merged_i { - // If the first bound is inferable, our span should also eat the trailing `+` + // If the first bound is inferable, our span should also eat the trailing `+`. None if i == 0 => { merged.push(bound_span.to(bounds[1].span().shrink_to_lo())); last_merged_i = Some(0); }, - // If consecutive bounds are inferable, merge their spans - Some(h) if i == h+1 => { + // If consecutive bounds are inferable, merge their spans. + Some(h) if i == h + 1 => { if let Some(tail) = merged.last_mut() { // Also eat the trailing `+` if the first - // more-than-one bound is inferable + // more-than-one bound is inferable. let to_span = if from_start && i < bounds.len() { - bounds[i+1].span().shrink_to_lo() + bounds[i + 1].span().shrink_to_lo() } else { bound_span }; @@ -1769,9 +1769,9 @@ impl ExplicitOutlivesRequirements { _ => { // When we find a non-inferable bound, subsequent inferable bounds // won't be consecutive from the start (and we'll eat the leading - // `+` rather than the trailing one) + // `+` rather than the trailing one). from_start = false; - merged.push(bounds[i-1].span().shrink_to_hi().to(bound_span)); + merged.push(bounds[i - 1].span().shrink_to_hi().to(bound_span)); last_merged_i = Some(i); } } @@ -1860,7 +1860,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { if num_predicates > 0 && dropped_predicate_count == num_predicates { let full_where_span = generics.span.shrink_to_hi() .to(generics.where_clause.span() - .expect("span of (nonempty) where clause should exist")); + .expect("span of (nonempty) where-clause should exist")); lint_spans.push( full_where_span ); @@ -1885,8 +1885,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { ); err.emit(); } - } } - } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 5c243e1389073..cba17b504b4e3 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -196,7 +196,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { // macros are ready for this yet. // UNREACHABLE_PUB, - // FIXME macro crates are not up for this yet, too much + // FIXME: macro crates are not up for this yet, too much // breakage is seen if we try to encourage this lint. // MACRO_USE_EXTERN_CRATE, ); diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 34f8fc40597f1..aa5a90003e49d 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -440,11 +440,12 @@ enum FfiResult<'tcx> { }, } -/// Check if this enum can be safely exported based on the +/// Checks if this enum can be safely exported based on the /// "nullable pointer optimization". Currently restricted /// to function pointers and references, but could be -/// expanded to cover NonZero raw pointers and newtypes. -/// FIXME: This duplicates code in codegen. +/// expanded to cover `NonZero` raw pointers and newtypes. +// +// FIXME: this duplicates code in codegen. fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def: &'tcx ty::AdtDef, substs: &Substs<'tcx>) @@ -490,7 +491,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Protect against infinite recursion, for example // `struct S(*mut S);`. - // FIXME: A recursion limit is necessary as well, for irregular + // FIXME: a recursion limit is necessary as well, for irregular // recursive types. if !cache.insert(ty) { return FfiSafe; @@ -592,7 +593,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } AdtKind::Enum => { if def.variants.is_empty() { - // Empty enums are okay... although sort of useless. + // Empty enums are ok... although sort of useless. return FfiSafe; } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 407e684293515..2a9690f0fa79a 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -119,7 +119,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { fn_warned = check_must_use(cx, def_id, s.span, "return value of ", ""); } else if type_permits_lack_of_use { // We don't warn about unused unit or uninhabited types. - // (See https://github.com/rust-lang/rust/issues/43806 for details.) + // (See issue #43806 for details.) return; } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 6f2718381c2ec..2fbe905f26d63 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -707,7 +707,7 @@ impl<'a> CrateLoader<'a> { fn inject_sanitizer_runtime(&mut self) { if let Some(ref sanitizer) = self.sess.opts.debugging_opts.sanitizer { // Sanitizers can only be used on some tested platforms with - // executables linked to `std` + // executables linked to `std`. const ASAN_SUPPORTED_TARGETS: &[&str] = &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"]; const TSAN_SUPPORTED_TARGETS: &[&str] = &["x86_64-unknown-linux-gnu", @@ -729,17 +729,17 @@ impl<'a> CrateLoader<'a> { return } - // firstyear 2017 - during testing I was unable to access an OSX machine + // NOTE: in 2017, during testing, I was unable to access an macOS machine // to make this work on different crate types. As a result, today I have - // only been able to test and support linux as a target. + // only been able to test and support Linux as a target. if self.sess.target.target.llvm_target == "x86_64-unknown-linux-gnu" { if !self.sess.crate_types.borrow().iter().all(|ct| { match *ct { - // Link the runtime + // Link the runtime. config::CrateType::Staticlib | config::CrateType::Executable => true, // This crate will be compiled with the required - // instrumentation pass + // instrumentation pass. config::CrateType::Rlib | config::CrateType::Dylib | config::CrateType::Cdylib => diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index f49b88f14e60e..dd9b6047b7cb0 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -145,7 +145,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, cdata.get_deprecation(def_id.index).map(DeprecationEntry::external) } item_attrs => { cdata.get_item_attrs(def_id.index, tcx.sess) } - // FIXME(#38501) We've skipped a `read` on the `HirBody` of + // FIXME(#38501): we've skipped a `read` on the `HirBody` of // a `fn` when encoding, so the dep-tracking wouldn't work. // This is only used by rustdoc anyway, which shouldn't have // incremental recompilation ever enabled. @@ -253,7 +253,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, } pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { - // FIXME(#44234) - almost all of these queries have no sub-queries and + // FIXME(#44234): almost all of these queries have no subqueries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about *providers = Providers { @@ -309,8 +309,8 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { assert_eq!(cnum, LOCAL_CRATE); let mut visible_parent_map: DefIdMap = Default::default(); - // Issue 46112: We want the map to prefer the shortest - // paths when reporting the path to an item. Therefore we + // Issue #46112: We want the map to prefer the shortest + // paths when reporting the path to an item. Therefore, we // build up the map via a breadth-first search (BFS), // which naturally yields minimal-length paths. // @@ -500,8 +500,8 @@ impl CrateStore for cstore::CStore { /// parent `DefId` as well as some idea of what kind of data the /// `DefId` refers to. fn def_key(&self, def: DefId) -> DefKey { - // Note: loading the def-key (or def-path) for a def-id is not - // a *read* of its metadata. This is because the def-id is + // Note: loading the def-key (or def-path) for a `DefId` is not + // a *read* of its metadata. This is because the `DefId` is // really just an interned shorthand for a def-path, which is the // canonical name for an item. // diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 1c4e3bc6a50e7..a07b9ac7f5cad 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -701,7 +701,7 @@ impl<'a, 'tcx> CrateMetadata { /// Iterates over all the stability attributes in the given crate. pub fn get_lib_features(&self) -> Vec<(ast::Name, Option)> { - // FIXME: For a proc macro crate, not sure whether we should return the "host" + // FIXME: for a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. self.root .lib_features @@ -777,7 +777,7 @@ impl<'a, 'tcx> CrateMetadata { // Hand off the item to the callback. match child.kind { - // FIXME(eddyb) Don't encode these in children. + // FIXME(eddyb): don't encode these in children. EntryKind::ForeignMod => { for child_index in child.children.decode((self, sess)) { if let Some(def) = self.get_def(child_index) { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 40d3ee9cc0b11..db8bc30328338 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -413,7 +413,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let def_path_table = self.encode_def_path_table(); let def_path_table_bytes = self.position() - i; - // Encode the def IDs of impls, for coherence checking. + // Encode the `DefId`s of impls, for coherence checking. i = self.position(); let impls = self.tracked(IsolatedEncoder::encode_impls, ()); let impl_bytes = self.position() - i; @@ -433,19 +433,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let items = self.encode_info_for_items(); let item_bytes = self.position() - i; - // Encode the allocation index + // Encode the allocation index. let interpret_alloc_index = { let mut interpret_alloc_index = Vec::new(); let mut n = 0; - trace!("beginning to encode alloc ids"); + trace!("beginning to encode alloc IDs"); loop { let new_n = self.interpret_allocs_inverse.len(); - // if we have found new ids, serialize those, too + // If we have found new IDs, serialize those too. if n == new_n { - // otherwise, abort + // otherwise, abort. break; } - trace!("encoding {} further alloc ids", new_n - n); + trace!("encoding {} further alloc IDs", new_n - n); for idx in n..new_n { let id = self.interpret_allocs_inverse[idx]; let pos = self.position() as u32; @@ -461,7 +461,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { self.lazy_seq(interpret_alloc_index) }; - // Index the items + // Index the items. i = self.position(); let index = items.write_index(&mut self.opaque); let index_bytes = self.position() - i; @@ -544,9 +544,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } // These are methods for encoding various things. They are meant to be used with -// IndexBuilder::record() and EncodeContext::tracked(). They actually -// would not have to be methods of IsolatedEncoder (free standing functions -// taking IsolatedEncoder as first argument would be just fine) but by making +// `IndexBuilder::record()` and `EncodeContext::tracked()`. They actually +// would not have to be methods of `IsolatedEncoder` (free standing functions +// taking `IsolatedEncoder` as first argument would be just fine) but by making // them methods we don't have to repeat the lengthy `<'a, 'b: 'a, 'tcx: 'b>` // clause again and again. impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { @@ -1405,9 +1405,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } fn encode_attributes(&mut self, attrs: &[ast::Attribute]) -> LazySeq { - // NOTE: This must use lazy_seq_from_slice(), not lazy_seq() because - // we rely on the HashStable specialization for [Attribute] - // to properly filter things out. + // NOTE: this must use `lazy_seq_from_slice()`, not `lazy_seq()` because + // we rely on the `HashStable` specialization for `[Attribute]` + // to properly filter things out. self.lazy_seq_from_slice(attrs) } @@ -1450,7 +1450,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { // We're just going to write a list of crate 'name-hash-version's, with // the assumption that they are numbered 1 to n. - // FIXME (#2166): This is not nearly enough to support correct versioning + // FIXME(#2166): This is not nearly enough to support correct versioning // but is enough to get transitive crate dependencies working. self.lazy_seq_ref(deps.iter().map(|&(_, ref dep)| dep)) } diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 6a1aada5ac706..86c2d60cdea29 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -462,12 +462,12 @@ impl<'a> Context<'a> { // exact crate name and a possibly an exact hash. // // During this step, we can filter all found libraries based on the - // name and id found in the crate id (we ignore the path portion for + // name and ID found in the crate ID (we ignore the path portion for // filename matching), as well as the exact hash (if specified). If we // end up having many candidates, we must look at the metadata to - // perform exact matches against hashes/crate ids. Note that opening up + // perform exact matches against hashes/crate IDs. Note that opening up // the metadata is where we do an exact match against the full contents - // of the crate id (path/name/id). + // of the crate ID (path/name/ID). // // The goal of this step is to look at as little metadata as possible. self.filesearch.search(|path, kind| { @@ -521,7 +521,7 @@ impl<'a> Context<'a> { // (per hash), to a Library candidate for returning. // // A Library candidate is created if the metadata for the set of - // libraries corresponds to the crate id and hash criteria that this + // libraries corresponds to the crate ID and hash criteria that this // search is being performed for. let mut libraries = FxHashMap::default(); for (_hash, (rlibs, rmetas, dylibs)) in candidates { @@ -876,7 +876,7 @@ fn get_metadata_section_imp(target: &Target, CrateFlavor::Rlib => loader.get_rlib_metadata(target, filename)?, CrateFlavor::Dylib => { let buf = loader.get_dylib_metadata(target, filename)?; - // The header is uncompressed + // The header is uncompressed. let header_len = METADATA_HEADER.len(); debug!("checking {} bytes of metadata-version stamp", header_len); let header = &buf[..cmp::min(header_len, buf.len())]; @@ -885,7 +885,7 @@ fn get_metadata_section_imp(target: &Target, filename.display())); } - // Header is okay -> inflate the actual metadata + // Header is ok, so inflate the actual metadata. let compressed_bytes = &buf[header_len..]; debug!("inflating {} bytes of compressed metadata", compressed_bytes.len()); let mut inflated = Vec::new(); @@ -900,7 +900,7 @@ fn get_metadata_section_imp(target: &Target, } } CrateFlavor::Rmeta => { - // mmap the file, because only a small fraction of it is read. + // Memory-map the file, because only a small fraction of it is read. let file = std::fs::File::open(filename).map_err(|_| format!("failed to open rmeta metadata: '{}'", filename.display()))?; let mmap = unsafe { memmap::Mmap::map(&file) }; diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index af79ea37dff55..209012c89fee8 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -75,7 +75,7 @@ impl Lazy { } /// Returns the minimum encoded size of a value of type `T`. - // FIXME(eddyb) Give better estimates for certain types. + // FIXME(eddyb): give better estimates for certain types. pub fn min_size() -> usize { 1 } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 4d65862375a96..31c857f362014 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -621,7 +621,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let desc_second = self.describe_place(second_borrowed_place) .unwrap_or_else(|| "_".to_owned()); - // Also compute the name of the union type, eg. `Foo` so we + // Also compute the name of the union type (e.g., `Foo`), so we // can add a helpful note with it. let ty = base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx); @@ -1046,7 +1046,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ) -> DiagnosticBuilder<'cx> { let tcx = self.infcx.tcx; - // FIXME use a better heuristic than Spans + // FIXME: use a better heuristic than Spans let reference_desc = if return_span == self.mir.source_info(borrow.reserve_location).span { "reference to" } else { @@ -1770,7 +1770,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } ty::Array(ty, _) | ty::Slice(ty) => self.describe_field_from_ty(&ty, field), ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { - // Convert the def-id into a node-id. node-ids are only valid for + // Convert the `DefId` into a `NodeId`. `NodeId`s are only valid for // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: @@ -1783,7 +1783,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } _ => { // Might need a revision when the fields in trait RFC is implemented - // (https://github.com/rust-lang/rfcs/pull/1546) + // (RFC #1546). bug!( "End-user description not implemented for field access on `{:?}`", ty.sty @@ -2297,11 +2297,11 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { } } - /// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime + /// Returns the name of the provided `Ty` (that must be a reference) with a synthesized lifetime /// name where required. fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String { // We need to add synthesized lifetimes where appropriate. We do - // this by hooking into the pretty printer and telling it to label the + // this by hooking into the pretty-printer and telling it to label the // lifetimes without names with the value `'0`. match ty.sty { ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index f7d079c5494ef..4b2ec83aca8d6 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -94,9 +94,9 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC // } // ``` // The problem here is that `(_0.0: Q) = move _1;` is valid only if `Q` is - // of statically known size, which is not known to be true because of the + // of statically-known size, which is not known to be true because of the // `Q: ?Sized` constraint. However, it is true because the constructor can be - // called only when `Q` is of statically known size. + // called only when `Q` is of statically-known size. return_early = true; } @@ -516,7 +516,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx // assert that a place is safe and live. So we don't have to // do any checks here. // - // FIXME: Remove check that the place is initialized. This is + // FIXME: remove check that the place is initialized. This is // needed for now because matches don't have never patterns yet. // So this is the only place we prevent // let x: !; @@ -549,7 +549,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx let context = ContextKind::InlineAsm.new(location); for (o, output) in asm.outputs.iter().zip(outputs.iter()) { if o.is_indirect { - // FIXME(eddyb) indirect inline asm outputs should + // FIXME(eddyb): indirect inline asm outputs should // be encoeded through MIR place derefs instead. self.access_place( context, @@ -983,8 +983,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // reservation (or even prior activating uses of same // borrow); so don't check if they interfere. // - // NOTE: *reservations* do conflict with themselves; - // thus aren't injecting unsoundenss w/ this check.) + // NOTE: *reservations* do conflict with themselves, + // thus aren't injecting unsoundenss with this check. (Activation(_, activating), _) if activating == borrow_index => { debug!( "check_access_for_conflict place_span: {:?} sd: {:?} rw: {:?} \ @@ -1008,7 +1008,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => { - // Reading from mere reservations of mutable-borrows is OK. + // Reading from mere reservations of mutable-borrows is ok. if !is_active(&this.dominators, borrow, context.loc) { assert!(allow_two_phase_borrow(&this.infcx.tcx, borrow.kind)); return Control::Continue; @@ -1084,7 +1084,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { mode: MutateMode, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) { - // Write of P[i] or *P, or WriteAndRead of any P, requires P init'd. + // Write of `P[i]` or `*P`, or `WriteAndRead` of any `P` requires `P` to be initialized. match mode { MutateMode::WriteAndRead => { self.check_if_path_or_subpath_is_moved( @@ -1516,7 +1516,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // ancestors; dataflow recurs on children when parents // move (to support partial (re)inits). // - // (I.e., querying parents breaks scenario 7; but may want + // (I.e., querying parents breaks scenario 7, but may want // to do such a query based on partial-init feature-gate.) } } @@ -1600,7 +1600,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } fn move_path_for_place(&mut self, place: &Place<'tcx>) -> Option { - // If returns None, then there is no move path corresponding + // If it returns `None`, then there is no move path corresponding // to a direct owner of `place` (which means there is nothing // that borrowck tracks for its analysis). @@ -1633,7 +1633,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ProjectionElem::ConstantIndex { .. } | // assigning to P[i] requires P to be valid. ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) => - // assigning to (P->variant) is okay if assigning to `P` is okay + // assigning to (P->variant) is ok if assigning to `P` is ok // // FIXME: is this true even if P is a adt with a dtor? { } @@ -1721,15 +1721,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // // and also this: // - // 3. `let mut s = ...; drop(s); s.x=Val;` + // 3. `let mut s = ...; drop(s); s.x = Val;` // - // This does not use check_if_path_or_subpath_is_moved, + // This does not use `check_if_path_or_subpath_is_moved`, // because we want to *allow* reinitializations of fields: // e.g., want to allow // - // `let mut s = ...; drop(s.x); s.x=Val;` + // `let mut s = ...; drop(s.x); s.x = Val;` // - // This does not use check_if_full_path_is_moved on + // This does not use `check_if_full_path_is_moved` on // `base`, because that would report an error about the // `base` as a whole, but in this scenario we *really* // want to report an error about the actual thing that was @@ -1740,7 +1740,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let maybe_uninits = &flow_state.uninits; // Find the shortest uninitialized prefix you can reach - // without going over a Deref. + // without going over a `Deref`. let mut shortest_uninit_seen = None; for prefix in this.prefixes(base, PrefixSet::Shallow) { let mpi = match this.move_path_for_place(prefix) { @@ -2104,7 +2104,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // `self.foo` -- we want to double // check that the context `*self` // is mutable (i.e., this is not a - // `Fn` closure). But if that + // `Fn` closure). But if that // check succeeds, we want to // *blame* the mutability on // `place` (that is, diff --git a/src/librustc_mir/borrow_check/nll/constraints/mod.rs b/src/librustc_mir/borrow_check/nll/constraints/mod.rs index b1091eb5ac81f..d30ae3e0ab9e8 100644 --- a/src/librustc_mir/borrow_check/nll/constraints/mod.rs +++ b/src/librustc_mir/borrow_check/nll/constraints/mod.rs @@ -66,11 +66,11 @@ impl Deref for ConstraintSet { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct OutlivesConstraint { - // NB. The ordering here is not significant for correctness, but + // N.B., the ordering here is not significant for correctness, but // it is for convenience. Before we dump the constraints in the // debugging logs, we sort them, and we'd like the "super region" // to be first, etc. (In particular, span should remain last.) - /// The region SUP must outlive SUB... + /// The region SUP must outlive SUB. pub sup: RegionVid, /// Region that must be outlived. diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 3255899c86cb3..2533bff0b6ab8 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -26,7 +26,7 @@ pub(super) fn generate_invalidates<'cx, 'gcx, 'tcx>( borrow_set: &BorrowSet<'tcx>, ) { if all_facts.is_none() { - // Nothing to do if we don't have any facts + // Nothing to do if we don't have any facts. return; } @@ -105,7 +105,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { let context = ContextKind::InlineAsm.new(location); for (o, output) in asm.outputs.iter().zip(outputs.iter()) { if o.is_indirect { - // FIXME(eddyb) indirect inline asm outputs should + // FIXME(eddyb): indirect inline ASM outputs should // be encoeded through MIR place derefs instead. self.access_place( context, @@ -203,7 +203,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { for arg in args { self.consume_operand(ContextKind::CallOperand.new(location), arg); } - if let Some((ref dest, _ /*bb*/)) = *destination { + if let Some((ref dest, _ /* bb */)) = *destination { self.mutate_place( ContextKind::CallDest.new(location), dest, @@ -233,7 +233,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { } => { self.consume_operand(ContextKind::Yield.new(location), value); - // Invalidate all borrows of local places + // Invalidate all borrows of local places. let borrow_set = self.borrow_set.clone(); let resume = self.location_table.start_index(resume.start_location()); for i in borrow_set.borrows.indices() { @@ -243,7 +243,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { } } TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => { - // Invalidate all borrows of local places + // Invalidate all borrows of local places. let borrow_set = self.borrow_set.clone(); let start = self.location_table.start_index(location); for i in borrow_set.borrows.indices() { @@ -263,7 +263,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { real_target: _, unwind: _, } => { - // no data used, thus irrelevant to borrowck + // No data used, thus irrelevant to borrowck. } } @@ -315,14 +315,14 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { } } - // Simulates consumption of an rvalue + // Simulates consumption of an rvalue. fn consume_rvalue( &mut self, context: Context, rvalue: &Rvalue<'tcx>, ) { match *rvalue { - Rvalue::Ref(_ /*rgn*/, bk, ref place) => { + Rvalue::Ref(_ /* rgn */, bk, ref place) => { let access_kind = match bk { BorrowKind::Shallow => { (Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk))) @@ -348,8 +348,8 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { Rvalue::Use(ref operand) | Rvalue::Repeat(ref operand, _) - | Rvalue::UnaryOp(_ /*un_op*/, ref operand) - | Rvalue::Cast(_ /*cast_kind*/, ref operand, _ /*ty*/) => { + | Rvalue::UnaryOp(_ /* un_op */, ref operand) + | Rvalue::Cast(_ /* cast_kind */, ref operand, _ /* ty */) => { self.consume_operand(context, operand) } @@ -393,7 +393,8 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { _is_local_mutation_allowed: LocalMutationIsAllowed, ) { let (sd, rw) = kind; - // note: not doing check_access_permissions checks because they don't generate invalidates + // N.B., we don't do `check_access_permissions` checks here because they don't generate + // invalidations. self.check_access_for_conflict(context, place, sd, rw); } @@ -430,28 +431,28 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { // reservation (or even prior activating uses of same // borrow); so don't check if they interfere. // - // NOTE: *reservations* do conflict with themselves; - // thus aren't injecting unsoundenss w/ this check.) + // N.B., *reservations* do conflict with themselves, + // thus aren't injecting unsoundenss with this check. (Activation(_, activating), _) if activating == borrow_index => { // Activating a borrow doesn't generate any invalidations, since we - // have already taken the reservation + // have already taken the reservation. } (Read(_), BorrowKind::Shallow) | (Reservation(..), BorrowKind::Shallow) | (Read(_), BorrowKind::Shared) | (Reservation(..), BorrowKind::Shared) => { - // Reads/reservations don't invalidate shared or shallow borrows + // Reads/reservations don't invalidate shared or shallow borrows. } (Read(_), BorrowKind::Unique) | (Read(_), BorrowKind::Mut { .. }) => { - // Reading from mere reservations of mutable-borrows is OK. + // Reading from mere reservations of mutable-borrows is ok. if !is_active(&this.dominators, borrow, context.loc) { - // If the borrow isn't active yet, reads don't invalidate it + // If the borrow isn't active yet, reads don't invalidate it. assert!(allow_two_phase_borrow(&this.tcx, borrow.kind)); return Control::Continue; } // Unique and mutable borrows are invalidated by reads from any - // involved path + // involved path. this.generate_invalidates(borrow_index, context.loc); } @@ -459,10 +460,10 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { | (Reservation(_), BorrowKind::Mut { .. }) | (Activation(_, _), _) | (Write(_), _) => { - // unique or mutable borrows are invalidated by writes. + // Unique or mutable borrows are invalidated by writes. // Reservations count as writes since we need to check - // that activating the borrow will be OK - // FIXME(bob_twinkles) is this actually the right thing to do? + // that activating the borrow will be ok. + // FIXME(bob_twinkles): is this actually the right thing to do? this.generate_invalidates(borrow_index, context.loc); } } @@ -486,13 +487,13 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { return; } - // Two-phase borrow support: For each activation that is newly + // Two-phase borrow support: for each activation that is newly // generated at this statement, check if it interferes with // another borrow. for &borrow_index in self.borrow_set.activations_at_location(location) { let borrow = &self.borrow_set[borrow_index]; - // only mutable borrows should be 2-phase + // Only mutable borrows should be two-phase. assert!(match borrow.kind { BorrowKind::Shared | BorrowKind::Shallow => false, BorrowKind::Unique | BorrowKind::Mut { .. } => true, diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index 84fdbb9423e0a..93b83f4f433da 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -284,7 +284,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>( // When the enclosing function is tagged with `#[rustc_regions]`, // we dump out various bits of state as warnings. This is useful - // for verifying that the compiler is behaving as expected. These + // for verifying that the compiler is behaving as expected. These // warnings focus on the closure region requirements -- for // viewing the intraprocedural state, the -Zdump-mir output is // better. diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 081c458bfc17a..660341b7a9b0d 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -1,25 +1,26 @@ -use crate::borrow_check::nll::constraints::OutlivesConstraint; -use crate::borrow_check::nll::region_infer::RegionInferenceContext; -use crate::borrow_check::nll::type_check::Locations; -use crate::borrow_check::nll::universal_regions::DefiningTy; -use crate::borrow_check::nll::ConstraintDescription; -use crate::util::borrowck_errors::{BorrowckErrors, Origin}; +mod region_name; +mod var_name; + +use std::collections::VecDeque; + +use rustc_data_structures::indexed_vec::IndexVec; +use rustc_errors::{Diagnostic, DiagnosticBuilder}; use rustc::hir::def_id::DefId; use rustc::infer::error_reporting::nice_region_error::NiceRegionError; use rustc::infer::InferCtxt; use rustc::infer::NLLRegionVariableOrigin; use rustc::mir::{ConstraintCategory, Location, Mir}; use rustc::ty::{self, RegionVid}; -use rustc_data_structures::indexed_vec::IndexVec; -use rustc_errors::{Diagnostic, DiagnosticBuilder}; -use std::collections::VecDeque; +use syntax_pos::Span; use syntax::errors::Applicability; use syntax::symbol::keywords; -use syntax_pos::Span; - -mod region_name; -mod var_name; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::universal_regions::DefiningTy; +use crate::borrow_check::nll::ConstraintDescription; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; crate use self::region_name::{RegionName, RegionNameSource}; impl ConstraintDescription for ConstraintCategory { @@ -67,7 +68,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> (ConstraintCategory, bool, Span) { debug!("best_blame_constraint(from_region={:?})", from_region); - // Find all paths + // Find all paths. let (path, target_region) = self.find_constraint_paths_between_regions(from_region, target_test) .unwrap(); @@ -112,7 +113,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // '5: '6 ('6 is the target) // // Some of those regions are unified with `'6` (in the same - // SCC). We want to screen those out. After that point, the + // SCC). We want to screen those out. After that point, the // "closest" constraint we have to the end is going to be the // most likely to be the point where the value escapes -- but // we still want to screen for an "interesting" point to @@ -151,7 +152,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// `results`. The paths are stored as a series of /// `ConstraintIndex` values -- in other words, a list of *edges*. /// - /// Returns: a series of constraints as well as the region `R` + /// Returns a series of constraints as well as the region `R` /// that passed the target test. fn find_constraint_paths_between_regions( &self, @@ -383,9 +384,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { diag.note( "`FnMut` closures only have access to their captured variables while they are \ - executing...", + executing ...", ); - diag.note("...therefore, they cannot allow references to captured variables to escape"); + diag.note("... therefore, they cannot allow references to captured variables to escape"); diag.buffer(errors_buffer); } @@ -585,7 +586,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Check whether or not the impl trait return type is intended to capture // data with the static lifetime. // - // eg. check for `impl Trait + 'static` instead of `impl Trait`. + // E.g., check for `impl Trait + 'static` instead of `impl Trait`. let has_static_predicate = { let predicates_of = infcx.tcx.predicates_of(*did); let bounds = predicates_of.instantiate(infcx.tcx, substs); diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 089640ab7024b..d437f3a85a6f8 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -492,7 +492,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { match path.def { // Type parameters of the type alias have no reason to // be the same as those of the ADT. - // FIXME: We should be able to do something similar to + // FIXME: we should be able to do something similar to // match_adt_and_segment in this case. hir::def::Def::TyAlias(_) => (), _ => if let Some(last_segment) = path.segments.last() { @@ -526,7 +526,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } _ => { - // FIXME there are other cases that we could trace + // FIXME: there are other cases that we could trace } } } @@ -650,7 +650,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Checks for arguments appearing in the (closure) return type. It /// must be a closure since, in a free fn, such an argument would /// have to either also appear in an argument (if using elision) - /// or be early bound (named, not in argument). + /// or be early-bound (named, not in argument). fn give_name_if_anonymous_region_appears_in_output( &self, infcx: &InferCtxt<'_, '_, 'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index cbeb5dc206ee6..8039376b626d3 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -755,7 +755,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // // This is needed because -- particularly in the case // where `ur` is a local bound -- we are sometimes in a - // position to prove things that our caller cannot. See + // position to prove things that our caller cannot. See // #53570 for an example. if self.eval_verify_bound(tcx, mir, generic_ty, ur, &type_test.verify_bound) { continue; @@ -1398,7 +1398,7 @@ impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequi ); // Extract the values of the free regions in `closure_substs` - // into a vector. These are the regions that we will be + // into a vector. These are the regions that we will be // relating to one another. let closure_mapping = &UniversalRegions::closure_mapping( tcx, diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index 3b663ef6dad61..b570ff834637e 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -1,19 +1,21 @@ -use crate::borrow_check::nll::type_check::constraint_conversion; -use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; -use crate::borrow_check::nll::universal_regions::UniversalRegions; -use crate::borrow_check::nll::ToRegionVid; +use std::rc::Rc; + +use rustc_data_structures::transitive_relation::TransitiveRelation; +use rustc::infer::InferCtxt; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::outlives::free_region_map::FreeRegionRelations; use rustc::infer::region_constraints::GenericKind; -use rustc::infer::InferCtxt; use rustc::mir::ConstraintCategory; use rustc::traits::query::outlives_bounds::{self, OutlivesBound}; use rustc::traits::query::type_op::{self, TypeOp}; use rustc::ty::{self, RegionVid, Ty}; -use rustc_data_structures::transitive_relation::TransitiveRelation; -use std::rc::Rc; use syntax_pos::DUMMY_SP; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::type_check::constraint_conversion; +use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::universal_regions::UniversalRegions; + #[derive(Debug)] crate struct UniversalRegionRelations<'tcx> { universal_regions: Rc>, @@ -121,7 +123,7 @@ impl UniversalRegionRelations<'tcx> { let upper_bounds = self.non_local_upper_bounds(&fr); // In case we find more than one, reduce to one for - // convenience. This is to prevent us from generating more + // convenience. This is to prevent us from generating more // complex constraints, but it will cause spurious errors. let post_dom = self .inverse_outlives @@ -154,7 +156,7 @@ impl UniversalRegionRelations<'tcx> { let lower_bounds = self.non_local_bounds(&self.outlives, &fr); // In case we find more than one, reduce to one for - // convenience. This is to prevent us from generating more + // convenience. This is to prevent us from generating more // complex constraints, but it will cause spurious errors. let post_dom = self .outlives diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 4a0b4b7c205c6..e81dd51303d26 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -280,7 +280,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> { debug_assert!(self.drop_live_at.contains(term_point)); // Otherwise, scan backwards through the statements in the - // block. One of them may be either a definition or use + // block. One of them may be either a definition or use // live point. let term_location = self.cx.elements.to_location(term_point); debug_assert_eq!( @@ -328,7 +328,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> { // would have been a "use-live" transition in the earlier // loop, and we'd have returned already. // - // NB. It's possible that the pred-block ends in a call + // N.B., it's possible that the pred-block ends in a call // which stores to the variable; in that case, the // variable may be uninitialized "at exit" because this // call only considers the *unconditional effects* of the @@ -397,7 +397,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> { // However, the current code would, when walking back from BB2, // simply stop and never explore BB0. This seems bad! But it turns // out this code is flawed anyway -- note that the existing value of - // `X` would leak in the case where unwinding did *not* occur. + // `X` would leak in the case where unwinding did **not** occur. // // What we *actually* generate is a store to a temporary // for the call (`TMP = call()...`) and then a diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 49f90eb90aaf0..a354a4a5d4722 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -456,7 +456,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { }, Place::Promoted(box (_index, sty)) => { let sty = self.sanitize_type(place, sty); - // FIXME -- promoted MIR return types reference + // FIXME: promoted MIR return types reference // various "free regions" (e.g., scopes and things) // that they ought not to do. We have to figure out // how best to handle that -- probably we want treat @@ -1062,7 +1062,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { if let TyKind::Opaque(..) = sup.sty { // When you have `let x: impl Foo = ...` in a closure, // the resulting inferend values are stored with the - // def-id of the base function. + // `DefId` of the base function. let parent_def_id = self.tcx().closure_base_def_id(self.mir_def_id); return self.eq_opaque_type_and_type(sub, sup, parent_def_id, locations, category); } else { @@ -1378,7 +1378,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { | TerminatorKind::Drop { .. } | TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => { - // no checks needed for these + // No checks needed for these. } TerminatorKind::DropAndReplace { @@ -1428,7 +1428,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { if !switch_ty.is_integral() && !switch_ty.is_char() && !switch_ty.is_bool() { span_mirbug!(self, term, "bad SwitchInt discr ty {:?}", switch_ty); } - // FIXME: check the values + // FIXME: check the values. } TerminatorKind::Call { ref func, @@ -1586,7 +1586,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } None => { if !sig.output().conservative_is_privately_uninhabited(self.tcx()) { - span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig); + span_mirbug!(self, term, "call to converging function {:?} without dest", sig); } } } @@ -1739,12 +1739,12 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { fn check_local(&mut self, mir: &Mir<'tcx>, local: Local, local_decl: &LocalDecl<'tcx>) { match mir.local_kind(local) { LocalKind::ReturnPointer | LocalKind::Arg => { - // return values of normal functions are required to be + // Return values of normal functions are required to be // sized by typeck, but return values of ADT constructors are // not because we don't include a `Self: Sized` bounds on them. // // Unbound parts of arguments were never required to be Sized - // - maybe we should make that a warning. + // -- maybe we should make that a warning. return; } LocalKind::Var | LocalKind::Temp => {} @@ -1762,7 +1762,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { fn ensure_place_sized(&mut self, ty: Ty<'tcx>, span: Span) { let tcx = self.tcx(); - // Erase the regions from `ty` to get a global type. The + // Erase the regions from `ty` to get a global type. The // `Sized` bound in no way depends on precise regions, so this // shouldn't affect `is_sized`. let gcx = tcx.global_tcx(); @@ -1992,7 +1992,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { self.add_reborrow_constraint(location, region, borrowed_place); } - // FIXME: These other cases have to be implemented in future PRs + // FIXME: these other cases have to be implemented in future PRs Rvalue::Use(..) | Rvalue::Len(..) | Rvalue::BinaryOp(..) @@ -2041,7 +2041,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { self.prove_aggregate_predicates(aggregate_kind, location); if *aggregate_kind == AggregateKind::Tuple { - // tuple rvalue field type is always the type of the op. Nothing to check here. + // Tuple rvalue field type is always the type of the op; nothing to check here. return; } @@ -2280,7 +2280,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { match k1.unpack() { UnpackedKind::Lifetime(r1) => { - // constraint is r1: r2 + // Constraint is `r1: r2`. let r1_vid = borrowck_context.universal_regions.to_region_vid(r1); let r2_vid = borrowck_context.universal_regions.to_region_vid(r2); let outlives_requirements = @@ -2443,7 +2443,7 @@ impl MirPass for TypeckMir { } if tcx.sess.err_count() > 0 { - // compiling a broken program can obviously result in a + // Compiling a broken program can obviously result in a // broken MIR, so try not to report duplicate errors. return; } @@ -2470,7 +2470,7 @@ impl MirPass for TypeckMir { ); // For verification purposes, we just ignore the resulting - // region constraint sets. Not our problem. =) + // region constraint sets -- not our problem. }); } } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index a5bf158257700..518ade49b2562 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -317,9 +317,9 @@ impl<'tcx> UniversalRegions<'tcx> { &substs.substs[..] )); - // FIXME: It'd be nice to print the late-bound regions + // FIXME: it'd be nice to print the late-bound regions // here, but unfortunately these wind up stored into - // tests, and the resulting print-outs include def-ids + // tests, and the resulting print-outs include `DefId`s // and other things that are not stable across tests! // So we just include the region-vid. Annoying. let closure_base_def_id = tcx.closure_base_def_id(def_id); @@ -337,7 +337,7 @@ impl<'tcx> UniversalRegions<'tcx> { &substs.substs[..] )); - // FIXME: As above, we'd like to print out the region + // FIXME: as above, we'd like to print out the region // `r` but doing so is not stable across architectures // and so forth. let closure_base_def_id = tcx.closure_base_def_id(def_id); @@ -573,7 +573,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { inputs_and_output, |closure_ty, inputs_and_output| { // The "inputs" of the closure in the - // signature appear as a tuple. The MIR side + // signature appear as a tuple. The MIR side // flattens this tuple. let (&output, tuplized_inputs) = inputs_and_output.split_last().unwrap(); assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs"); diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 9073ae6bed5b2..911758614ae0a 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -39,15 +39,15 @@ pub(super) fn each_borrow_involving_path<'a, 'tcx, 'gcx: 'tcx, F, I, S> ( mut op: F, ) where F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control, - I: Iterator + I: Iterator { let (access, place) = access_place; - // FIXME: analogous code in check_loans first maps `place` to - // its base_path. + // FIXME: analogous code in `check_loans` first maps `place` to + // its `base_path`. - // check for loan restricting path P being used. Accounts for - // borrows of P, P.a.b, etc. + // Check for loan restricting path `P` being used. Accounts for + // borrows of `P`, `P.a.b`, etc. for i in candidates { let borrowed = &borrow_set[i]; diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index d6d2861b557ab..76aa6d427b8b6 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -67,7 +67,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { match ty.sty { // For both derefs of raw pointers and `&T` // references, the original path is `Copy` and - // therefore not significant. In particular, + // therefore not significant. In particular, // there is nothing the user can do to the // original path that would invalidate the // newly created reference -- and if there diff --git a/src/librustc_mir/build/expr/as_operand.rs b/src/librustc_mir/build/expr/as_operand.rs index 38fae8539c8d7..438725cd5709c 100644 --- a/src/librustc_mir/build/expr/as_operand.rs +++ b/src/librustc_mir/build/expr/as_operand.rs @@ -11,7 +11,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// scope expression. /// /// The operand returned from this function will *not be valid* after - /// an ExprKind::Scope is passed, so please do *not* return it from + /// an ExprKind::Scope is passed, so please do **not** return it from /// functions to avoid bad miscompiles. pub fn as_local_operand(&mut self, block: BasicBlock, expr: M) -> BlockAnd> where diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index ed444191226a1..ec010552adab4 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -73,7 +73,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let (usize_ty, bool_ty) = (this.hir.usize_ty(), this.hir.bool_ty()); let slice = unpack!(block = this.as_place(block, lhs)); - // region_scope=None so place indexes live forever. They are scalars so they + // `region_scope = None`, so place indexes live forever. They are scalars so they // do not need storage annotations, and they are often copied between // places. // Making this a *fresh* temporary also means we do not have to worry about diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 88dbd93939e54..f5ba94f4f126e 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -2,16 +2,16 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; - -use crate::build::expr::category::{Category, RvalueFunc}; -use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::hair::*; use rustc::middle::region; use rustc::mir::interpret::EvalErrorKind; use rustc::mir::*; use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts}; use syntax_pos::Span; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; + impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// See comment on `as_local_operand` pub fn as_local_rvalue(&mut self, block: BasicBlock, expr: M) -> BlockAnd> @@ -189,7 +189,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // (b) distinguish the case where the type `Foo` has a // destructor, in which case creating an instance // as a whole "arms" the destructor, and you can't - // write individual fields; and, + // write individual fields; and // (c) handle the case where the type Foo has no // fields. We don't want `let x: ();` to compile // to the same MIR as `let x = ();`. diff --git a/src/librustc_mir/build/expr/category.rs b/src/librustc_mir/build/expr/category.rs index ca7d435e62229..aac455d7a5cc3 100644 --- a/src/librustc_mir/build/expr/category.rs +++ b/src/librustc_mir/build/expr/category.rs @@ -77,8 +77,7 @@ impl Category { | ExprKind::Break { .. } | ExprKind::Continue { .. } | ExprKind::Return { .. } => - // FIXME(#27840) these probably want their own - // category, like "nonterminating" + // FIXME(#27840): these probably want their own category, like "nonterminating". { Some(Category::Rvalue(RvalueFunc::Into)) } diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 05231bc7b3f16..7b33fe28bd55e 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -1,12 +1,12 @@ //! See docs in build/expr/mod.rs -use crate::build::expr::category::{Category, RvalueFunc}; -use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use crate::hair::*; +use rustc_target::spec::abi::Abi; use rustc::mir::*; use rustc::ty; -use rustc_target::spec::abi::Abi; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::hair::*; impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// Compile `expr`, storing the result into `destination`, which diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index aadc2368f5aec..63f8ddfd57679 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -61,11 +61,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { block.unit() } ExprKind::AssignOp { op, lhs, rhs } => { - // FIXME(#28160) there is an interesting semantics + // FIXME(#28160): there is an interesting semantics // question raised here -- should we "freeze" the - // value of the lhs here? I'm inclined to think not, + // value of the lhs here? I'm inclined to think not, // since it seems closer to the semantics of the - // overloaded version, which takes `&mut self`. This + // overloaded version, which takes `&mut self`. This // only affects weird things like `x += {x += 1; x}` // -- is that equal to `x + (x + 1)` or `2*(x+1)`? diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 28d2a397f3ed6..8f9244a377c92 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1,30 +1,31 @@ -//! Code related to match expressions. These are sufficiently complex -//! to warrant their own module and submodules. :) This main module -//! includes the high-level algorithm, the submodules contain the -//! details. +//! Match expressions. +//! +//! This logic is sufficiently complex to warrant its own module and submodules. +//! This main module includes the high-level algorithm, while the submodules contain +//! the details. -use crate::build::scope::{CachedBlock, DropKind}; -use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; -use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; -use crate::hair::{self, *}; -use rustc::mir::*; -use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty}; -use rustc::ty::layout::VariantIdx; -use rustc_data_structures::bit_set::BitSet; -use rustc_data_structures::fx::FxHashMap; -use syntax::ast::{Name, NodeId}; -use syntax_pos::Span; - -// helper functions, broken out by category: +// Helper functions, organised by category. mod simplify; mod test; mod util; use std::convert::TryFrom; -/// ArmHasGuard is isomorphic to a boolean flag. It indicates whether -/// a match arm has a guard expression attached to it. +use rustc_data_structures::bit_set::BitSet; +use rustc_data_structures::fx::FxHashMap; +use rustc::mir::*; +use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty}; +use rustc::ty::layout::VariantIdx; +use syntax_pos::Span; +use syntax::ast::{Name, NodeId}; + +use crate::build::scope::{CachedBlock, DropKind}; +use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; +use crate::hair::{self, *}; + +/// Indicates whether a match arm has a guard expression attached to it. #[derive(Copy, Clone, Debug)] pub(crate) struct ArmHasGuard(pub bool); @@ -48,10 +49,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // around a `match` equivalent to `std::intrinsics::unreachable()`. // See issue #47412 for this hole being discovered in the wild. // - // HACK(eddyb) Work around the above issue by adding a dummy inspection + // HACK(eddyb): work around the above issue by adding a dummy inspection // of `discriminant_place`, specifically by applying `ReadForMatch`. // - // NOTE: ReadForMatch also checks that the discriminant is initialized. + // NOTE: `ReadForMatch` also checks that the discriminant is initialized. // This is currently needed to not allow matching on an uninitialized, // uninhabited value. If we get never patterns, those will check that // the place is initialized, and so this read would only be used to @@ -73,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Get the arm bodies and their scopes, while declaring bindings. let arm_bodies: Vec<_> = arms.iter() .map(|arm| { - // BUG: use arm lint level + // BUG: use arm lint level. let body = self.hir.mirror(arm.body.clone()); let scope = self.declare_bindings( None, @@ -87,7 +88,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }) .collect(); - // create binding start block for link them by false edges + // Create binding start block for link them by false edges. let candidate_count = arms.iter().map(|c| c.patterns.len()).sum::(); let pre_binding_blocks: Vec<_> = (0..=candidate_count) .map(|_| self.cfg.start_new_block()) @@ -95,11 +96,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let mut has_guard = false; - // assemble a list of candidates: there is one candidate per + // Assemble a list of candidates. There is one candidate per // pattern, which means there may be more than one candidate // *per arm*. These candidates are kept sorted such that the - // highest priority candidate comes first in the list. - // (i.e., same order as in source) + // highest priority candidate comes first in the list + // (i.e., same order as in source). let candidates: Vec<_> = arms.iter() .enumerate() @@ -126,21 +127,19 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // using the `discriminant_place` directly, as it is doing here? // // The basic answer is that if you do that, then you end up with - // accceses to a shared borrow of the input and that conflicts with - // any arms that look like e.g. + // accceses to a shared borrow of the input, and that conflicts with + // any arms that look like, e.g., // - // match Some(&4) { - // ref mut foo => { - // ... /* mutate `foo` in arm body */ ... + // match Some(&4) { + // ref mut foo => { + // ... /* mutate `foo` in arm body */ ... + // } // } - // } // - // (Perhaps we could further revise the MIR - // construction here so that it only does a - // shared borrow at the outset and delays doing - // the mutable borrow until after the pattern is - // matched *and* the guard (if any) for the arm - // has been run.) + // Perhaps we could further revise the MIR construction here so that + // it only does a shared borrow at the outset, and delays doing the + // mutable borrow until after the pattern is matched *and* the guard + // (if any) for the arm has been run. Candidate { span: pattern.span, @@ -164,8 +163,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TerminatorKind::Unreachable, ); - // Maps a place to the kind of Fake borrow that we want to perform on - // it: either Shallow or Shared, depending on whether the place is + // Maps a place to the kind of `Fake` borrow that we want to perform on + // it: either `Shallow` or `Shared`, depending on whether the place is // bound in the match, or just switched on. // If there are no match guards then we don't need any fake borrows, // so don't track them. @@ -180,8 +179,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { .map(|cand| (cand.pre_binding_block, cand.span)) .collect(); - // this will generate code to test discriminant_place and - // branch to the appropriate arm block + // This will generate code to test `discriminant_place` and + // branch to the appropriate arm block. let otherwise = self.match_candidates( discriminant_span, &mut arm_blocks, @@ -201,7 +200,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let mut otherwise = otherwise; otherwise.sort(); - otherwise.dedup(); // variant switches can introduce duplicate target blocks + // Variant switches can introduce duplicate target blocks. + otherwise.dedup(); for block in otherwise { self.cfg .terminate(block, source_info, TerminatorKind::Unreachable); @@ -212,7 +212,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.add_fake_borrows(&pre_binding_blocks, fake_borrows, source_info, block); } - // all the arm blocks will rejoin here + // All the arm blocks will rejoin here. let end_block = self.cfg.start_new_block(); let outer_source_info = self.source_info(span); @@ -239,7 +239,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { initializer: ExprRef<'tcx>, ) -> BlockAnd<()> { match *irrefutable_pat.kind { - // Optimize the case of `let x = ...` to write directly into `x` + // Optimize the case of `let x = ...` to write directly into `x`. PatternKind::Binding { mode: BindingMode::ByValue, var, @@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { unpack!(block = self.into(&place, block, initializer)); - // Inject a fake read, see comments on `FakeReadCause::ForLet`. + // Inject a fake read; see comments on `FakeReadCause::ForLet`. let source_info = self.source_info(irrefutable_pat.span); self.cfg.push( block, @@ -293,7 +293,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard); unpack!(block = self.into(&place, block, initializer)); - // Inject a fake read, see comments on `FakeReadCause::ForLet`. + // Inject a fake read; see comments on `FakeReadCause::ForLet`. let pattern_source_info = self.source_info(irrefutable_pat.span); self.cfg.push( block, @@ -318,12 +318,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // We always use invariant as the variance here. This is because the // variance field from the ascription refers to the variance to use // when applying the type to the value being matched, but this - // ascription applies rather to the type of the binding. e.g., in this - // example: + // ascription applies rather to the type of the binding, e.g., in // - // ``` - // let x: T = - // ``` + // let x: T = // // We are creating an ascription that defines the type of `x` to be // exactly `T` (i.e., with invariance). The variance field, in @@ -352,7 +349,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { initializer: &Place<'tcx>, set_match_place: bool, ) -> BlockAnd<()> { - // create a dummy candidate + // Create a dummy candidate. let mut candidate = Candidate { span: irrefutable_pat.span, match_pairs: vec![MatchPair::new(initializer.clone(), &irrefutable_pat)], @@ -360,7 +357,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ascriptions: vec![], guard: None, - // since we don't call `match_candidates`, next fields is unused + // Since we don't call `match_candidates`, next fields are unused. arm_index: 0, pat_index: 0, pre_binding_block: block, @@ -368,7 +365,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }; // Simplify the candidate. Since the pattern is irrefutable, this should - // always convert all match-pairs into bindings. + // always convert all match pairs into bindings. self.simplify_candidate(&mut candidate); if !candidate.match_pairs.is_empty() { @@ -380,10 +377,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ); } - // for matches and function arguments, the place that is being matched + // For matches and function arguments, the place that is being matched // can be set when creating the variables. But the place for - // let PATTERN = ... might not even exist until we do the assignment. - // so we set it here instead + // `let PATTERN = ...` might not even exist until we do the assignment, + // so we set it here instead. if set_match_place { for binding in &candidate.bindings { let local = self.var_local_id(binding.var_id, OutsideGuard); @@ -402,7 +399,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.ascribe_types(block, &candidate.ascriptions); - // now apply the bindings, which will also declare the variables + // Now apply the bindings, which will also declare the variables. self.bind_matched_candidate_for_arm_body(block, &candidate.bindings); block.unit() @@ -410,8 +407,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// Declares the bindings of the given patterns and returns the visibility /// scope for the bindings in these patterns, if such a scope had to be - /// created. NOTE: Declaring the bindings should always be done in their - /// drop scope. + /// created. + /// + /// NOTE: declaring the bindings should always be done in their drop scope. pub fn declare_bindings( &mut self, mut visibility_scope: Option, @@ -570,9 +568,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } => { // This corresponds to something like // - // ``` - // let A::<'a>(_): A<'static> = ...; - // ``` + // let A::<'a>(_): A<'static> = ...; // // Note that the variance doesn't apply here, as we are tracking the effect // of `user_ty` on any bindings contained with subpattern. @@ -608,37 +604,36 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } -/// List of blocks for each arm (and potentially other metadata in the -/// future). +/// List of blocks for each arm (and potentially other metadata in the future). struct ArmBlocks { blocks: Vec, } #[derive(Clone, Debug)] pub struct Candidate<'pat, 'tcx: 'pat> { - // span of the original pattern that gave rise to this candidate + /// The span of the original pattern that gave rise to this candidate. span: Span, - // all of these must be satisfied... + /// The match pairs to be satisfied. match_pairs: Vec>, - // ...these bindings established... + /// The bindings to be established. bindings: Vec>, - // ...these types asserted... + /// The types to be asserted. ascriptions: Vec>, - // ...and the guard must be evaluated... + /// The guard to be evaluated. guard: Option>, - // ...and then we branch to arm with this index. + /// The index of the arm to which we branch. arm_index: usize, - // ...and the blocks for add false edges between candidates + // The blocks for adding false edges between candidates. pre_binding_block: BasicBlock, next_candidate_pre_binding_block: BasicBlock, - // This uniquely identifies this candidate *within* the arm. + // Uniquely identifies this candidate *within* the arm. pat_index: usize, } @@ -666,45 +661,45 @@ struct Ascription<'tcx> { #[derive(Clone, Debug)] pub struct MatchPair<'pat, 'tcx: 'pat> { - // this place... + // This place ... place: Place<'tcx>, // ... must match this pattern. pattern: &'pat Pattern<'tcx>, - // HACK(eddyb) This is used to toggle whether a Slice pattern + // HACK(eddyb): this is used to toggle whether a Slice pattern // has had its length checked. This is only necessary because - // the "rest" part of the pattern right now has type &[T] and - // as such, it requires an Rvalue::Slice to be generated. + // the "rest" part of the pattern right now has type `&[T]` and + // as such, it requires an `Rvalue::Slice` to be generated. // See RFC 495 / issue #23121 for the eventual (proper) solution. slice_len_checked: bool, } #[derive(Clone, Debug, PartialEq)] enum TestKind<'tcx> { - // test the branches of enum + // Test the branches of enum. Switch { adt_def: &'tcx ty::AdtDef, variants: BitSet, }, - // test the branches of enum + // Test the branches of enum. SwitchInt { switch_ty: Ty<'tcx>, options: Vec, indices: FxHashMap, usize>, }, - // test for equality + // Test for equality. Eq { value: ty::Const<'tcx>, ty: Ty<'tcx>, }, - // test whether the value falls within an inclusive or exclusive range + // Test whether the value falls within an inclusive or exclusive range. Range(PatternRange<'tcx>), - // test length of the slice is equal to len + // Test length of the slice is equal to len. Len { len: u64, op: BinOp, @@ -862,7 +857,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn join_otherwise_blocks(&mut self, span: Span, mut otherwise: Vec) -> BasicBlock { let source_info = self.source_info(span); otherwise.sort(); - otherwise.dedup(); // variant switches can introduce duplicate target blocks + // Variant switches can introduce duplicate target blocks. + otherwise.dedup(); if otherwise.len() == 1 { otherwise[0] } else { @@ -880,17 +876,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// This is the most subtle part of the matching algorithm. At /// this point, the input candidates have been fully simplified, - /// and so we know that all remaining match-pairs require some + /// and so we know that all remaining match pairs require some /// sort of test. To decide what test to do, we take the highest /// priority candidate (last one in the list) and extract the - /// first match-pair from the list. From this we decide what kind + /// first match pair from the list. From this we decide what kind /// of test is needed using `test`, defined in the `test` module. /// /// *Note:* taking the first match pair is somewhat arbitrary, and /// we might do better here by choosing more carefully what to /// test. /// - /// For example, consider the following possible match-pairs: + /// For example, consider the following possible match pairs: /// /// 1. `x @ Some(P)` -- we will do a `Switch` to decide what variant `x` has /// 2. `x @ 22` -- we will do a `SwitchInt` @@ -904,7 +900,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// candidates. For example, if we are testing the current /// variant of `x.0`, and we have a candidate `{x.0 @ Some(v), x.1 /// @ 22}`, then we would have a resulting candidate of `{(x.0 as - /// Some).0 @ v, x.1 @ 22}`. Note that the first match-pair is now + /// Some).0 @ v, x.1 @ 22}`. Note that the first match pair is now /// simpler (and, in fact, irrefutable). /// /// But there may also be candidates that the test just doesn't @@ -923,8 +919,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// In that case, after we test on `x`, there are 2 overlapping candidate /// sets: /// - /// - If the outcome is that `x` is true, candidates 0, 1, and 3 - /// - If the outcome is that `x` is false, candidates 1 and 2 + /// - If the outcome is that `x` is `true`, candidates 0, 1, and 3. + /// - If the outcome is that `x` is `false`, candidates 1 and 2. /// /// Here, the traditional "decision tree" method would generate 2 /// separate code-paths for the 2 separate cases. @@ -961,7 +957,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// } /// ``` /// - /// Here we first test the match-pair `x @ "foo"`, which is an `Eq` test. + /// Here we first test the match pair `x @ "foo"`, which is an `Eq` test. /// /// It might seem that we would end up with 2 disjoint candidate /// sets, consisting of the first candidate or the other 3, but our @@ -971,11 +967,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// of tests. /// /// To avoid these kinds of problems, our algorithm tries to ensure - /// the amount of generated tests is linear. When we do a k-way test, + /// the amount of generated tests is linear. When we do a `k`-way test, /// we return an additional "unmatched" set alongside the obvious `k` /// sets. When we encounter a candidate that would be present in more /// than one of the sets, we put it and all candidates below it into the - /// "unmatched" set. This ensures these `k+1` sets are disjoint. + /// "unmatched" set. This ensures these `k + 1` sets are disjoint. /// /// After we perform our test, we branch into the appropriate candidate /// set and recurse with `match_candidates`. These sub-matches are @@ -998,14 +994,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { block: BasicBlock, fake_borrows: &mut Option, BorrowKind>>, ) -> (Vec, usize) { - // extract the match-pair from the highest priority candidate + // Extract the `MarchPair` from the highest priority candidate. let match_pair = &candidates.first().unwrap().match_pairs[0]; let mut test = self.test(match_pair); - // most of the time, the test to perform is simply a function - // of the main candidate; but for a test like SwitchInt, we + // Most of the time, the test to perform is simply a function + // of the main candidate, but for a test like `SwitchInt`, we // may want to add cases based on the candidates that are - // available + // available. match test.kind { TestKind::SwitchInt { switch_ty, @@ -1037,13 +1033,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { _ => {} } - // Insert a Shallow borrow of any places that is switched on. + // Insert a `Shallow` borrow of any places that is switched on. fake_borrows.as_mut().map(|fb| { fb.entry(match_pair.place.clone()).or_insert(BorrowKind::Shallow) }); - // perform the test, branching to one of N blocks. For each of - // those N possible outcomes, create a (initially empty) + // Perform the test, branching to one of `N` blocks. For each of + // those `N` possible outcomes, create a (initially empty) // vector of candidates. Those are the candidates that still // apply if the test has that particular outcome. debug!( @@ -1063,7 +1059,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.sort_candidate(&match_pair.place, &test, c, &mut target_candidates) }) .count(); - assert!(tested_candidates > 0); // at least the last candidate ought to be tested + // At least the last candidate ought to be tested. + assert!(tested_candidates > 0); debug!("tested_candidates: {}", tested_candidates); debug!( "untested_candidates: {}", @@ -1101,8 +1098,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// self-consistency of this fn, but the reason for it should be /// clear: after we've done the assignments, if there were move /// bindings, further tests would be a use-after-move (which would - /// in turn be detected by the borrowck code that runs on the - /// MIR). + /// in turn be detected by the borrowck code that runs on the MIR). fn bind_and_guard_matched_candidate<'pat>( &mut self, mut block: BasicBlock, @@ -1139,7 +1135,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }, ); - // rust-lang/rust#27282: The `autoref` business deserves some + // Issue #27282: The `autoref` business deserves some // explanation here. // // The intent of the `autoref` flag is that when it is true, @@ -1157,7 +1153,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // ``` // let place = Foo::new(); // match place { foo if inspect(foo) - // => feed(foo), ... } + // => feed(foo), ... } // ``` // // will be treated as if it were really something like: @@ -1172,7 +1168,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // ``` // let place = Foo::new(); // match place { ref mut foo if inspect(foo) - // => feed(foo), ... } + // => feed(foo), ... } // ``` // // will be treated as if it were really something like: @@ -1244,8 +1240,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.bind_matched_candidate_for_arm_body(block, &candidate.bindings); } - // the block to branch to if the guard fails; if there is no - // guard, this block is simply unreachable + // The block to branch to if the guard fails; if there is no + // guard, this block is simply unreachable. let guard = match guard { Guard::If(e) => self.hir.mirror(e), }; @@ -1316,9 +1312,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ); Some(otherwise) } else { - // (Here, it is not too early to bind the matched + // Here, it is not too early to bind the matched // candidate on `block`, because there is no guard result - // that we have to inspect before we bind them.) + // that we have to inspect before we bind them. self.bind_matched_candidate_for_arm_body(block, &candidate.bindings); self.cfg.terminate( block, @@ -1329,8 +1325,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } - /// Append `AscribeUserType` statements onto the end of `block` - /// for each ascription + /// Appends `AscribeUserType` statements onto the end of `block` + /// for each ascription. fn ascribe_types<'pat>( &mut self, block: BasicBlock, @@ -1365,7 +1361,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } - // Only called when all_pat_vars_are_implicit_refs_within_guards, + // Only called when `all_pat_vars_are_implicit_refs_within_guards` is `true`, // and thus all code/comments assume we are in that context. fn bind_matched_candidate_for_guard( &mut self, @@ -1385,15 +1381,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { for binding in bindings { let source_info = self.source_info(binding.span); - // For each pattern ident P of type T, `ref_for_guard` is - // a reference R: &T pointing to the location matched by - // the pattern, and every occurrence of P within a guard - // denotes *R. + // For each pattern ident `P` of type `T`, `ref_for_guard` is + // a reference `R: &T` pointing to the location matched by + // the pattern, and every occurrence of `P` within a guard + // denotes `*R`. let ref_for_guard = self.storage_live_binding(block, binding.var_id, binding.span, RefWithinGuard); // Question: Why schedule drops if bindings are all - // shared-&'s? Answer: Because schedule_drop_for_binding - // also emits StorageDead's for those locals. + // shared-`&`'s? Answer: Because `schedule_drop_for_binding` + // also emits `StorageDead`'s for those locals. self.schedule_drop_for_binding(binding.var_id, binding.span, RefWithinGuard); match binding.binding_mode { BindingMode::ByValue => { @@ -1402,7 +1398,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { .push_assign(block, source_info, &ref_for_guard, rvalue); } BindingMode::ByRef(borrow_kind) => { - // Tricky business: For `ref id` and `ref mut id` + // Tricky business: for `ref id` and `ref mut id` // patterns, we want `id` within the guard to // correspond to a temp of type `& &T` or `& &mut // T` (i.e., a "borrow of a borrow") that is @@ -1412,7 +1408,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // to point to. So, create a temp for the inner // borrow, and then take a reference to it. // - // Note: the temp created here is *not* the one + // Note: the temp created here is **not** the one // used by the arm body itself. This eases // observing two-phase borrow restrictions. let val_for_guard = self.storage_live_binding( @@ -1427,12 +1423,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ValWithinGuard(pat_index), ); - // rust-lang/rust#27282: We reuse the two-phase + // Issue #27282: We reuse the two-phase // borrow infrastructure so that the mutable // borrow (whose mutabilty is *unusable* within // the guard) does not conflict with the implicit // borrow of the whole match input. See additional - // discussion on rust-lang/rust#49870. + // discussion on issue #49870. let borrow_kind = match borrow_kind { BorrowKind::Shared | BorrowKind::Shallow @@ -1484,15 +1480,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// Each binding (`ref mut var`/`ref var`/`mut var`/`var`, where /// the bound `var` has type `T` in the arm body) in a pattern - /// maps to `2+N` locals. The first local is a binding for + /// maps to `2 + N` locals. The first local is a binding for /// occurrences of `var` in the guard, which will all have type - /// `&T`. The N locals are bindings for the `T` that is referenced + /// `&T`. The `N` locals are bindings for the `T` that is referenced /// by the first local; they are not used outside of the /// guard. The last local is a binding for occurrences of `var` in /// the arm body, which will have type `T`. /// - /// The reason we have N locals rather than just 1 is to - /// accommodate rust-lang/rust#51348: If the arm has N candidate + /// The reason we have `N` locals rather than just `1` is to + /// accommodate rust-lang/rust#51348: If the arm has `N` candidate /// patterns, then in general they can correspond to distinct /// parts of the matched data, and we want them to be distinct /// temps in order to simplify checks performed by our internal @@ -1535,9 +1531,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { is_block_tail: None, is_user_variable: Some(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm { binding_mode, - // hypothetically, `visit_bindings` could try to unzip - // an outermost hir::Ty as we descend, matching up - // idents in pat; but complex w/ unclear UI payoff. + // Hypothetically, `visit_bindings` could try to unzip + // an outermost `hir::Ty` as we descend, matching up + // idents in pat, but complex with unclear UI payoff. // Instead, just abandon providing diagnostic info. opt_ty_info: None, opt_match_place, @@ -1564,7 +1560,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { name: Some(name), source_info, visibility_scope, - // FIXME: should these secretly injected ref_for_guard's be marked as `internal`? + // FIXME: should these secretly injected `ref_for_guard`'s be marked as `internal`? internal: false, is_block_tail: None, is_user_variable: Some(ClearCrossCrate::Set(BindingForm::RefForGuard)), @@ -1597,7 +1593,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let mut all_fake_borrows = Vec::with_capacity(fake_borrows.len()); - // Insert a Shallow borrow of the prefixes of any fake borrows. + // Insert a `Shallow` borrow of the prefixes of any fake borrows. for (place, borrow_kind) in fake_borrows { { @@ -1640,10 +1636,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { borrowed_input_temps.push(borrowed_input_temp); } - // FIXME: This could be a lot of reads (#fake borrows * #patterns). + // FIXME: this could be a lot of reads (`#fake borrows * #patterns`). // The false edges that we currently generate would allow us to only do - // this on the last Candidate, but it's possible that there might not be - // so many false edges in the future, so we read for all Candidates for + // this on the last `Candidate`, but it's possible that there might not be + // so many false edges in the future, so we read for all `Candidate`s for // now. // Another option would be to make our own block and add our own false // edges to it. diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index b8e38e40b6347..ada3f6353903f 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -1,31 +1,32 @@ -//! Simplifying Candidates +//! Simplifying candidates. //! //! *Simplifying* a match pair `place @ pattern` means breaking it down //! into bindings or other, simpler match pairs. For example: //! -//! - `place @ (P1, P2)` can be simplified to `[place.0 @ P1, place.1 @ P2]` -//! - `place @ x` can be simplified to `[]` by binding `x` to `place` +//! - `place @ (P1, P2)` can be simplified to `[place.0 @ P1, place.1 @ P2]`. +//! - `place @ x` can be simplified to `[]` by binding `x` to `place`. //! //! The `simplify_candidate` routine just repeatedly applies these //! sort of simplifications until there is nothing left to //! simplify. Match pairs cannot be simplified if they require some -//! sort of test: for example, testing which variant an enum is, or +//! sort of test; for example, testing which variant an enum is, or //! testing a value against a constant. -use crate::build::Builder; -use crate::build::matches::{Ascription, Binding, MatchPair, Candidate}; -use crate::hair::{self, *}; +use std::mem; + +use rustc::hir::RangeEnd; use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; use syntax::attr::{SignedInt, UnsignedInt}; -use rustc::hir::RangeEnd; -use std::mem; +use crate::build::Builder; +use crate::build::matches::{Ascription, Binding, MatchPair, Candidate}; +use crate::hair::{self, *}; impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { pub fn simplify_candidate<'pat>(&mut self, candidate: &mut Candidate<'pat, 'tcx>) { - // repeatedly simplify match pairs until fixed point is reached + // Repeatedly simplify match pairs until fixed point is reached. loop { let match_pairs = mem::replace(&mut candidate.match_pairs, vec![]); let mut changed = false; @@ -40,15 +41,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } if !changed { - return; // if we were not able to simplify any, done. + // If we were not able to simplify any, done. + return; } } } - /// Tries to simplify `match_pair`, returning true if + /// Tries to simplify `match_pair`, returning `true` if /// successful. If successful, new match pairs and bindings will /// have been pushed into the candidate. If no simplification is - /// possible, Err is returned and no changes are made to + /// possible, `Err` is returned, and no changes are made to /// candidate. fn simplify_match_pair<'pat>(&mut self, match_pair: MatchPair<'pat, 'tcx>, @@ -79,7 +81,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } PatternKind::Wild => { - // nothing left to do + // Nothing left to do. Ok(()) } @@ -95,7 +97,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }); if let Some(subpattern) = subpattern.as_ref() { - // this is the `x @ P` case; have to keep matching against `P` now + // This is the `x @ P` case; have to keep matching against `P` now. candidate.match_pairs.push(MatchPair::new(match_pair.place, subpattern)); } @@ -103,7 +105,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } PatternKind::Constant { .. } => { - // FIXME normalize patterns when possible + // FIXME: normalize patterns when possible. Err(match_pair) } @@ -132,7 +134,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // We want to compare ranges numerically, but the order of the bitwise // representation of signed integers does not match their numeric order. // Thus, to correct the ordering, we need to shift the range of signed - // integers to correct the comparison. This is achieved by XORing with a + // integers to correct the comparison. This is achieved by XOR-ing with a // bias (see pattern/_match.rs for another pertinent example of this // pattern). let (lo, hi) = (lo ^ bias, hi ^ bias); @@ -147,7 +149,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { PatternKind::Slice { ref prefix, ref slice, ref suffix } => { if prefix.is_empty() && slice.is_some() && suffix.is_empty() { - // irrefutable + // Irrefutable. self.prefix_slice_suffix(&mut candidate.match_pairs, &match_pair.place, prefix, @@ -186,7 +188,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } PatternKind::Leaf { ref subpatterns } => { - // tuple struct, match subpats (if any) + // Tuple struct; match subpatterns (if any). candidate.match_pairs .extend(self.field_match_pairs(match_pair.place, subpatterns)); Ok(()) diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 75189777aa311..2e1fdd44bbe08 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -1,4 +1,4 @@ -// Testing candidates +// Testing candidates. // // After candidates have been simplified, the only match pairs that // remain are those that require some sort of test. The functions here @@ -179,7 +179,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let source_info = self.source_info(test.span); match test.kind { TestKind::Switch { adt_def, ref variants } => { - // Variants is a BitVec of indexes into adt_def.variants. + // Variants is a `BitVec` of indexes into `adt_def.variants`. let num_enum_variants = adt_def.variants.len(); let used_variants = variants.count(); let mut otherwise_block = None; @@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { true_bb, false_bb)) } else { // The switch may be inexhaustive so we - // add a catch all block + // add a catch all block. let otherwise = self.cfg.start_new_block(); let targets: Vec<_> = options.iter() @@ -253,12 +253,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TestKind::Eq { value, mut ty } => { let val = Operand::Copy(place.clone()); let mut expect = self.literal_operand(test.span, ty, value); - // Use PartialEq::eq instead of BinOp::Eq - // (the binop can only handle primitives) + // Use `PartialEq::eq` instead of `BinOp::Eq` + // (the binop can only handle primitives). let fail = self.cfg.start_new_block(); if !ty.is_scalar() { - // If we're using b"..." as a pattern, we need to insert an - // unsizing coercion, as the byte string has the type &[u8; N]. + // If we're using `b"..."` as a pattern, we need to insert an + // unsizing coercion, as the byte string has the type `&[u8; N]`. // // We want to do this even when the scrutinee is a reference to an // array, so we can call `<[u8]>::eq` rather than having to find an @@ -274,12 +274,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let opt_ref_test_ty = unsize(value.ty); let mut place = place.clone(); match (opt_ref_ty, opt_ref_test_ty) { - // nothing to do, neither is an array + // Nothing to do, since neither is an array. (None, None) => {}, (Some((region, elem_ty, _)), _) | (None, Some((region, elem_ty, _))) => { let tcx = self.hir.tcx(); - // make both a slice + // Make both a slice. ty = tcx.mk_imm_ref(region, tcx.mk_slice(elem_ty)); if opt_ref_ty.is_some() { place = self.temp(ty, test.span); @@ -305,24 +305,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let method = self.hir.tcx().mk_lazy_const(ty::LazyConst::Evaluated(method)); let re_erased = self.hir.tcx().types.re_erased; - // take the argument by reference + // Take the argument by reference. let tam = ty::TypeAndMut { ty, mutbl: Mutability::MutImmutable, }; let ref_ty = self.hir.tcx().mk_ref(re_erased, tam); - // let lhs_ref_place = &lhs; + // `let lhs_ref_place = &lhs;` let ref_rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, place); let lhs_ref_place = self.temp(ref_ty, test.span); self.cfg.push_assign(block, source_info, &lhs_ref_place, ref_rvalue); let val = Operand::Move(lhs_ref_place); - // let rhs_place = rhs; + // `let rhs_place = rhs;` let rhs_place = self.temp(ty, test.span); self.cfg.push_assign(block, source_info, &rhs_place, Rvalue::Use(expect)); - // let rhs_ref_place = &rhs_place; + // `let rhs_ref_place = &rhs_place;` let ref_rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, rhs_place); let rhs_ref_place = self.temp(ref_ty, test.span); self.cfg.push_assign(block, source_info, &rhs_ref_place, ref_rvalue); @@ -337,12 +337,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { span: test.span, ty: mty, - // FIXME(#54571): This constant comes from user - // input (a constant in a pattern). Are + // FIXME(#54571): this constant comes from user + // input (a constant in a pattern). Are // there forms where users can add type - // annotations here? For example, an - // associated constant? Need to - // experiment. + // annotations here? For example, an + // associated constant? Need to experiment. user_ty: None, literal: method, @@ -353,7 +352,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { from_hir_call: false, }); - // check the result + // Check the result. let block = self.cfg.start_new_block(); self.cfg.terminate(eq_block, source_info, TerminatorKind::if_(self.hir.tcx(), @@ -387,20 +386,20 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let (actual, result) = (self.temp(usize_ty, test.span), self.temp(bool_ty, test.span)); - // actual = len(place) + // `actual == len(place)` self.cfg.push_assign(block, source_info, &actual, Rvalue::Len(place.clone())); - // expected = + // `expected == ` let expected = self.push_usize(block, source_info, len); - // result = actual == expected OR result = actual < expected + // `result == actual == expected` OR `result == actual < expected` self.cfg.push_assign(block, source_info, &result, Rvalue::BinaryOp(op, Operand::Move(actual), Operand::Move(expected))); - // branch based on result + // Branch based on result. let (false_bb, true_bb) = (self.cfg.start_new_block(), self.cfg.start_new_block()); self.cfg.terminate(block, source_info, @@ -421,12 +420,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let bool_ty = self.hir.bool_ty(); let result = self.temp(bool_ty, span); - // result = op(left, right) + // `result == op(left, right)` let source_info = self.source_info(span); self.cfg.push_assign(block, source_info, &result, Rvalue::BinaryOp(op, left, right)); - // branch based on result + // Branch based on result. let target_block = self.cfg.start_new_block(); self.cfg.terminate(block, source_info, TerminatorKind::if_(self.hir.tcx(), Operand::Move(result), @@ -455,22 +454,22 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// without doing anything. This is used by the overall `match_candidates` /// algorithm to structure the match as a whole. See `match_candidates` for /// more details. - /// - /// FIXME(#29623). In some cases, we have some tricky choices to - /// make. for example, if we are testing that `x == 22`, but the - /// candidate is `x @ 13..55`, what should we do? In the event - /// that the test is true, we know that the candidate applies, but - /// in the event of false, we don't know that it *doesn't* - /// apply. For now, we return false, indicate that the test does - /// not apply to this candidate, but it might be we can get - /// tighter match code if we do something a bit different. + // + // FIXME(#29623): in some cases, we have some tricky choices to + // make. for example, if we are testing that `x == 22`, but the + // candidate is `x @ 13..55`, what should we do? In the event + // that the test is `true`, we know that the candidate applies, but + // in the event of `false`, we don't know that it *doesn't* + // apply. For now, we return false, indicate that the test does + // not apply to this candidate, but it might be we can get + // tighter match code if we do something a bit different. pub fn sort_candidate<'pat>(&mut self, test_place: &Place<'tcx>, test: &Test<'tcx>, candidate: &Candidate<'pat, 'tcx>, resulting_candidates: &mut [Vec>]) -> bool { - // Find the match_pair for this place (if any). At present, + // Find the `match_pair` for this place (if any). At present, // afaik, there can be at most one. (In the future, if we // adopted a more general `@` operator, there might be more // than one, but it'd be very unusual to have two sides that @@ -508,7 +507,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // If we are performing a switch over integers, then this informs integer // equality, but nothing else. // - // FIXME(#29623) we could use PatternKind::Range to rule + // FIXME(#29623): we could use `PatternKind::Range` to rule // things out here, in some cases. (&TestKind::SwitchInt { switch_ty: _, options: _, ref indices }, &PatternKind::Constant { ref value }) @@ -545,8 +544,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let pat_len = (prefix.len() + suffix.len()) as u64; match (test_len.cmp(&pat_len), slice) { (Ordering::Equal, &None) => { - // on true, min_len = len = $actual_length, - // on false, len != $actual_length + // On true, `min_len == len == $actual_length`. + // On false, `len != $actual_length`. resulting_candidates[0].push( self.candidate_after_slice_test(match_pair_index, candidate, @@ -557,20 +556,20 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { true } (Ordering::Less, _) => { - // test_len < pat_len. If $actual_len = test_len, - // then $actual_len < pat_len and we don't have + // `test_len < pat_len`. If `$actual_len == test_len`, + // then also`$actual_len < pat_len`, and we don't have // enough elements. resulting_candidates[1].push(candidate.clone()); true } (Ordering::Equal, &Some(_)) | (Ordering::Greater, &Some(_)) => { - // This can match both if $actual_len = test_len >= pat_len, - // and if $actual_len > test_len. We can't advance. + // This can match both if `$actual_len == test_len >= pat_len`, + // and if `$actual_len > test_len`. We can't advance. false } (Ordering::Greater, &None) => { - // test_len != pat_len, so if $actual_len = test_len, then - // $actual_len != pat_len. + // `test_len != pat_len`, so if `$actual_len == test_len`, then + // `$actual_len != pat_len`. resulting_candidates[1].push(candidate.clone()); true } @@ -579,11 +578,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { (&TestKind::Len { len: test_len, op: BinOp::Ge }, &PatternKind::Slice { ref prefix, ref slice, ref suffix }) => { - // the test is `$actual_len >= test_len` + // The test is `$actual_len >= test_len`. let pat_len = (prefix.len() + suffix.len()) as u64; match (test_len.cmp(&pat_len), slice) { (Ordering::Equal, &Some(_)) => { - // $actual_len >= test_len = pat_len, + // `$actual_len >= test_len == pat_len`, // so we can match. resulting_candidates[0].push( self.candidate_after_slice_test(match_pair_index, @@ -595,20 +594,20 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { true } (Ordering::Less, _) | (Ordering::Equal, &None) => { - // test_len <= pat_len. If $actual_len < test_len, - // then it is also < pat_len, so the test passing is + // `test_len <= pat_len`. If `$actual_len < test_len`, + // then it is also `< pat_len`, so the test passing is // necessary (but insufficient). resulting_candidates[0].push(candidate.clone()); true } (Ordering::Greater, &None) => { - // test_len > pat_len. If $actual_len >= test_len > pat_len, + // `test_len > pat_len`. If `$actual_len >= test_len > pat_len`, // then we know we won't have a match. resulting_candidates[1].push(candidate.clone()); true } (Ordering::Greater, &Some(_)) => { - // test_len < pat_len, and is therefore less + // `test_len < pat_len`, and is therefore less // strict. This can still go both ways. false } @@ -637,10 +636,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let hi = compare_const_vals(tcx, test.hi, pat.lo, param_env)?; match (test.end, pat.end, lo, hi) { - // pat < test + // `pat < test` (_, _, Greater, _) | (_, Excluded, Equal, _) | - // pat > test + // `pat > test` (_, _, _, Less) | (Excluded, _, _, Equal) => Some(true), _ => Some(false), @@ -675,7 +674,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { (&TestKind::Len { .. }, _) => { // These are all binary tests. // - // FIXME(#29623) we can be more clever here + // FIXME(#29623): we can be more clever here. let pattern_test = self.test(&match_pair); if pattern_test.kind == test.kind { let new_candidate = self.candidate_without_match_pair(match_pair_index, @@ -744,7 +743,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // we want to create a set of derived match-patterns like // `(x as Variant).0 @ P1` and `(x as Variant).1 @ P1`. let elem = ProjectionElem::Downcast(adt_def, variant_index); - let downcast_place = match_pair.place.clone().elem(elem); // `(x as Variant)` + // I.e., `(x as Variant)`. + let downcast_place = match_pair.place.clone().elem(elem); let consequent_match_pairs = subpatterns.iter() .map(|subpattern| { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 64ab491cbd5b0..59d381bee7b03 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -76,8 +76,8 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t let mut mir = if cx.tables().tainted_by_errors { build::construct_error(cx, body_id) } else if cx.body_owner_kind.is_fn_or_closure() { - // fetch the fully liberated fn signature (that is, all bound - // types/lifetimes replaced) + // Fetch the fully liberated fn signature (that is, all bound + // types/lifetimes replaced). let fn_hir_id = tcx.hir().node_to_hir_id(id); let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone(); let fn_def_id = tcx.hir().local_def_id(id); @@ -86,7 +86,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t let mut abi = fn_sig.abi; let implicit_argument = match ty.sty { ty::Closure(..) => { - // HACK(eddyb) Avoid having RustCall on closures, + // HACK(eddyb): avoid having `RustCall` on closures, // as it adds unnecessary (and wrong) auto-tupling. abi = Abi::Rust; Some(ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None)) @@ -141,7 +141,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t ty::Generator(gen_def_id, gen_substs, ..) => gen_substs.sig(gen_def_id, tcx), _ => - span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty), + span_bug!(tcx.hir().span(id), "generator without generator type: {:?}", ty), }; (Some(gen_sig.yield_ty), gen_sig.return_ty) } else { @@ -154,7 +154,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t build::construct_const(cx, body_id, return_ty_span) }; - // Convert the Mir to global types. + // Convert the MIR to global types. let mut globalizer = GlobalizeMir { tcx, span: mir.span @@ -233,7 +233,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.infer_ctxt().enter(|infcx| { let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span); - // Convert the Mir to global types. + // Convert the MIR to global types. let tcx = infcx.tcx.global_tcx(); let mut globalizer = GlobalizeMir { tcx, @@ -434,7 +434,7 @@ impl BlockContext { /// whether its one that would discard a block tail result. /// /// Unlike `currently_within_ignored_tail_expression`, this does - /// *not* skip over `SubExpr` frames: here, we want to know + /// **not** skip over `SubExpr` frames: here, we want to know /// whether the block result itself is discarded. fn currently_ignores_tail_results(&self) -> bool { match self.0.last() { @@ -598,16 +598,16 @@ fn should_abort_on_panic<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool { - // Not callable from C, so we can safely unwind through these + // Not callable from C, so we can safely unwind through these. if abi == Abi::Rust || abi == Abi::RustCall { return false; } - // We never unwind, so it's not relevant to stop an unwind + // We never unwind, so it's not relevant to stop an unwind. if tcx.sess.panic_strategy() != PanicStrategy::Unwind { return false; } - // We cannot add landing pads, so don't add one + // We cannot add landing pads, so don't add one. if tcx.sess.no_landing_pads() { return false; } - // This is a special case: some functions have a C abi but are meant to + // This is a special case: some functions have a C ABI but are meant to // unwind anyway. Don't stop them. let attrs = &tcx.get_attrs(fn_def_id); match attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs) { @@ -635,7 +635,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, return_ty_span: Span, body: &'gcx hir::Body) -> Mir<'tcx> - where A: Iterator> + where A: Iterator> { let arguments: Vec<_> = arguments.collect(); @@ -716,7 +716,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, unpack!(block = builder.in_scope(arg_scope_s, LintLevel::Inherited, block, |builder| { builder.args_and_body(block, &arguments, arg_scope, &body.value) })); - // Attribute epilogue to function's closing brace + // Attribute epilogue to function's closing brace. let fn_end = span.shrink_to_hi(); let source_info = builder.source_info(fn_end); let return_block = builder.return_block(); @@ -724,7 +724,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, TerminatorKind::Goto { target: return_block }); builder.cfg.terminate(return_block, source_info, TerminatorKind::Return); - // Attribute any unreachable codepaths to the function's closing brace + // Attribute any unreachable codepaths to the function's closing brace. if let Some(unreachable_block) = builder.cached_unreachable_block { builder.cfg.terminate(unreachable_block, source_info, TerminatorKind::Unreachable); @@ -868,7 +868,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ast_body: &'gcx hir::Expr) -> BlockAnd<()> { - // Allocate locals for the function arguments + // Allocate locals for the function arguments. for &ArgInfo(ty, _, pattern, _) in arguments.iter() { // If this is a simple binding pattern, give the local a name for // debuginfo and so that error reporting knows that this is a user @@ -903,9 +903,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } let mut scope = None; - // Bind the argument patterns + // Bind the argument patterns. for (index, arg_info) in arguments.iter().enumerate() { - // Function arguments always get the first Local indices after the return place + // Function arguments always get the first Local indices after the return place. let local = Local::new(index + 1); let place = Place::Local(local); let &ArgInfo(ty, opt_ty_info, pattern, ref self_binding) = arg_info; @@ -922,7 +922,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let span = pattern.span; match *pattern.kind { - // Don't introduce extra copies for simple bindings + // Don't introduce extra copies for simple bindings. PatternKind::Binding { mutability, var, mode: BindingMode::ByValue, .. } => { self.local_decls[local].mutability = mutability; self.local_decls[local].is_user_variable = diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 3392495f7a11b..aaa8ba38fb619 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -47,7 +47,7 @@ loop { ``` When processing the `let x`, we will add one drop to the scope for -`x`. The break will then insert a drop for `x`. When we process `let +`x`. The break will then insert a drop for `x`. When we process `let y`, we will add another drop (in fact, to a subscope, but let's ignore that for now); any later drops would also drop `y`. @@ -686,7 +686,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let this_scope = scope.region_scope == region_scope; // When building drops, we try to cache chains of drops in such a way so these drops // could be reused by the drops which would branch into the cached (already built) - // blocks. This, however, means that whenever we add a drop into a scope which already + // blocks. This, however, means that whenever we add a drop into a scope which already // had some blocks built (and thus, cached) for it, we must invalidate all caches which // might branch into the scope which had a drop just added to it. This is necessary, // because otherwise some other code might use the cache to branch into already built diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 7be7f4b439289..fa3bf347eb1e8 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -1,4 +1,4 @@ -// Not in interpret to make sure we do not use private implementation details +// This is not in `interpret` to make sure we do not use private implementation details. use std::fmt; use std::error::Error; @@ -62,13 +62,13 @@ pub(crate) fn eval_promoted<'a, 'mir, 'tcx>( eval_body_using_ecx(&mut ecx, cid, Some(mir), param_env) } -// FIXME: These two conversion functions are bad hacks. We should just always use allocations. +// FIXME: these two conversion functions are bad hacks. We should just always use allocations. pub fn op_to_const<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, op: OpTy<'tcx>, may_normalize: bool, ) -> EvalResult<'tcx, ty::Const<'tcx>> { - // We do not normalize just any data. Only scalar layout and slices. + // We do not normalize just any data, only scalar layout and slices. let normalize = may_normalize && match op.layout.abi { layout::Abi::Scalar(..) => true, @@ -85,7 +85,7 @@ pub fn op_to_const<'tcx>( }; let val = match normalized_op { Err(MemPlace { ptr, align, meta }) => { - // extract alloc-offset pair + // Extract alloc-offset pair. assert!(meta.is_none()); let ptr = ptr.to_ptr()?; let alloc = ecx.memory.get(ptr.alloc_id)?; @@ -93,8 +93,8 @@ pub fn op_to_const<'tcx>( assert!(alloc.bytes.len() as u64 - ptr.offset.bytes() >= op.layout.size.bytes()); let mut alloc = alloc.clone(); alloc.align = align; - // FIXME shouldn't it be the case that `mark_static_initialized` has already - // interned this? I thought that is the entire point of that `FinishStatic` stuff? + // FIXME: shouldn't it be the case that `mark_static_initialized` has already + // interned this? I thought that is the entire point of that `FinishStatic` stuff? let alloc = ecx.tcx.intern_const_alloc(alloc); ConstValue::ByRef(ptr.alloc_id, alloc, ptr.offset) }, @@ -112,8 +112,8 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>( mir: Option<&'mir mir::Mir<'tcx>>, param_env: ty::ParamEnv<'tcx>, ) -> (EvalResult<'tcx, MPlaceTy<'tcx>>, CompileTimeEvalContext<'a, 'mir, 'tcx>) { - // we start out with the best span we have - // and try improving it down the road when more information is available + // We start out with the best span we have, and try improving it down the road when more + // information becomes available. let span = tcx.def_span(cid.instance.def_id()); let span = mir.map(|mir| mir.span).unwrap_or(span); let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new()); @@ -121,7 +121,7 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>( (r, ecx) } -// Returns a pointer to where the result lives +// Returns a pointer to where the result lives. fn eval_body_using_ecx<'mir, 'tcx>( ecx: &mut CompileTimeEvalContext<'_, 'mir, 'tcx>, cid: GlobalId<'tcx>, @@ -156,7 +156,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( // The main interpreter loop. ecx.run()?; - // Intern the result + // Intern the result. let internally_mutable = !layout.ty.is_freeze(tcx, param_env, mir.span); let is_static = tcx.is_static(cid.instance.def_id()); let mutability = if is_static == Some(hir::Mutability::MutMutable) || internally_mutable { @@ -209,7 +209,7 @@ impl Error for ConstEvalError { } } -// Extra machine state for CTFE, and the Machine instance +// Extra machine state for CTFE, and the machine instance. pub struct CompileTimeInterpreter<'a, 'mir, 'tcx: 'a+'mir> { /// When this value is negative, it indicates the number of interpreter /// steps *until* the loop detector is enabled. When it is positive, it is @@ -297,7 +297,7 @@ type CompileTimeEvalContext<'a, 'mir, 'tcx> = impl interpret::MayLeak for ! { #[inline(always)] fn may_leak(self) -> bool { - // `self` is uninhabited + // `self` is uninhabited. self } } @@ -314,11 +314,13 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> type MemoryMap = FxHashMap, Allocation)>; - const STATIC_KIND: Option = None; // no copying of statics allowed + // No copying of statics is allowed. + const STATIC_KIND: Option = None; #[inline(always)] fn enforce_validity(_ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { - false // for now, we don't enforce validity + // For now, we don't enforce validity. + false } fn find_fn( @@ -329,24 +331,25 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> ret: Option, ) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>> { debug!("eval_fn_call: {:?}", instance); - // Only check non-glue functions + // Only check non-glue functions. if let ty::InstanceDef::Item(def_id) = instance.def { // Execution might have wandered off into other crates, so we cannot to a stability- - // sensitive check here. But we can at least rule out functions that are not const + // sensitive check here. But we can at least rule out functions that are not const // at all. if !ecx.tcx.is_const_fn_raw(def_id) { // Some functions we support even if they are non-const -- but avoid testing - // that for const fn! We certainly do *not* want to actually call the fn + // that for const fn! We certainly do **not** want to actually call the fn // though, so be sure we return here. return if ecx.hook_fn(instance, args, dest)? { - ecx.goto_block(ret)?; // fully evaluated and done + // Fully evaluated and done. + ecx.goto_block(ret)?; Ok(None) } else { err!(MachineError(format!("calling non-const function `{}`", instance))) }; } } - // This is a const fn. Call it. + // This is a const fn; call it. Ok(Some(match ecx.load_mir(instance.def) { Ok(mir) => mir, Err(err) => { @@ -370,7 +373,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> if ecx.emulate_intrinsic(instance, args, dest)? { return Ok(()); } - // An intrinsic that we do not support + // An intrinsic that we do not support. let intrinsic_name = &ecx.tcx.item_name(instance.def_id()).as_str()[..]; Err( ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", intrinsic_name)).into() @@ -401,7 +404,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> alloc: &'b Allocation, _memory_extra: &(), ) -> Cow<'b, Allocation> { - // We do not use a tag so we can just cheaply forward the reference + // We do not use a tag so that we can just cheaply forward the reference. Cow::Borrowed(alloc) } @@ -475,16 +478,16 @@ pub fn const_field<'a, 'tcx>( trace!("const_field: {:?}, {:?}", field, value); let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env); let result = (|| { - // get the operand again + // Get the operand again. let op = ecx.lazy_const_to_op(ty::LazyConst::Evaluated(value), value.ty)?; - // downcast + // Downcast, ... let down = match variant { None => op, Some(variant) => ecx.operand_downcast(op, variant)? }; - // then project + // ... then project, ... let field = ecx.operand_field(down, field.index() as u64)?; - // and finally move back to the const world, always normalizing because + // ... and finally move back to the const world, always normalizing because // this is not called for statics. op_to_const(&ecx, field, true) })(); @@ -524,7 +527,7 @@ fn validate_and_turn_into_const<'a, 'tcx>( let ecx = mk_eval_cx(tcx, tcx.def_span(key.value.instance.def_id()), key.param_env); let val = (|| { let op = ecx.raw_const_to_mplace(constant)?.into(); - // FIXME: Once the visitor infrastructure landed, change validation to + // FIXME: once the visitor infrastructure landed, change validation to // work directly on `MPlaceTy`. let mut ref_tracking = RefTracking::new(op); while let Some((op, path)) = ref_tracking.todo.pop() { @@ -545,9 +548,10 @@ fn validate_and_turn_into_const<'a, 'tcx>( let err = error_to_const_error(&ecx, error); match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") { Ok(mut diag) => { - diag.note("The rules on what exactly is undefined behavior aren't clear, \ - so this check might be overzealous. Please open an issue on the rust compiler \ - repository if you believe it should not be considered undefined behavior", + diag.note( + "the rules on what exactly is undefined behavior aren't clear, \ + so this check might be overzealous. please open an issue on the compiler \ + repository if you believe it should not be considered undefined behavior", ); diag.emit(); ErrorHandled::Reported @@ -561,18 +565,18 @@ pub fn const_eval_provider<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { - // see comment in const_eval_provider for what we're doing here + // See comment in `const_eval_provider` for what we're doing here. if key.param_env.reveal == Reveal::All { let mut key = key.clone(); key.param_env.reveal = Reveal::UserFacing; match tcx.const_eval(key) { - // try again with reveal all as requested + // Try again with "reveal all", as requested. Err(ErrorHandled::TooGeneric) => { // Promoteds should never be "too generic" when getting evaluated. - // They either don't get evaluated, or we are in a monomorphic context + // They either don't get evaluated, or we are in a monomorphic context. assert!(key.value.promoted.is_none()); }, - // dedupliate calls + // Dedupliate calls. other => return other, } } @@ -597,9 +601,9 @@ pub fn const_eval_raw_provider<'a, 'tcx>( let mut key = key.clone(); key.param_env.reveal = Reveal::UserFacing; match tcx.const_eval_raw(key) { - // try again with reveal all as requested + // Try again with "reveal all" as requested. Err(ErrorHandled::TooGeneric) => {}, - // dedupliate calls + // Dedupliate calls. other => return other, } } @@ -618,7 +622,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( if let Some(id) = tcx.hir().as_local_node_id(def_id) { let tables = tcx.typeck_tables_of(def_id); - // Do match-check before building MIR + // Do match-check before building MIR. if let Err(ErrorReported) = tcx.check_match(def_id) { return Err(ErrorHandled::Reported) } @@ -627,7 +631,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.mir_const_qualif(def_id); } - // Do not continue into miri if typeck errors occurred; it will fail horribly + // Do not continue into Miri if typeck errors occurred; it will fail horribly. if tables.tainted_by_errors { return Err(ErrorHandled::Reported) } @@ -641,7 +645,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( }) }).map_err(|error| { let err = error_to_const_error(&ecx, error); - // errors in statics are always emitted as fatal errors + // Errors in statics are always emitted as fatal errors. if tcx.is_static(def_id).is_some() { let reported_err = err.report_as_error(ecx.tcx, "could not evaluate static initializer"); @@ -654,14 +658,15 @@ pub fn const_eval_raw_provider<'a, 'tcx>( } reported_err } else if def_id.is_local() { - // constant defined in this crate, we can figure out a lint level! + // Constant defined in this crate -- we can figure out a lint level! match tcx.describe_def(def_id) { - // constants never produce a hard error at the definition site. Anything else is - // a backwards compatibility hazard (and will break old versions of winapi for sure) + // Constants never produce a hard error at the definition site. Anything else is + // a backwards compatibility hazard (and will break old versions of WINAPI for + // sure). // - // note that validation may still cause a hard error on this very same constant, + // Note that validation may still cause a hard error on this very same constant, // because any code that existed before validation could not have failed validation - // thus preventing such a hard error from being a backwards compatibility hazard + // thus preventing such a hard error from being a backwards compatibility hazard. Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => { let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); err.report_as_lint( @@ -670,8 +675,8 @@ pub fn const_eval_raw_provider<'a, 'tcx>( node_id, ) }, - // promoting runtime code is only allowed to error if it references broken constants - // any other kind of error will be reported to the user as a deny-by-default lint + // Promoting runtime code is only allowed to error if it references broken constants + // any other kind of error will be reported to the user as a deny-by-default lint. _ => if let Some(p) = cid.promoted { let span = tcx.optimized_mir(def_id).promoted[p].span; if let EvalErrorKind::ReferencedConstant = err.error { @@ -686,8 +691,8 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.hir().as_local_node_id(def_id).unwrap(), ) } - // anything else (array lengths, enum initializers, constant patterns) are reported - // as hard errors + // Anything else (array lengths, enum initializers, constant patterns) are reported + // as hard errors. } else { err.report_as_error( ecx.tcx, @@ -696,7 +701,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( }, } } else { - // use of broken constant from other crate + // Use of broken constant from other crate. err.report_as_error(ecx.tcx, "could not evaluate constant") } }) diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs index d43fa4257e06c..adf99b1e1b588 100644 --- a/src/librustc_mir/dataflow/at_location.rs +++ b/src/librustc_mir/dataflow/at_location.rs @@ -21,7 +21,7 @@ pub trait FlowsAtLocation { /// terminator of block `bb`. /// /// **Important:** In the case of a `Call` terminator, these - /// effects do *not* include the result of storing the destination + /// effects do **not** include the result of storing the destination /// of the call, since that is edge-dependent (in other words, the /// effects don't apply to the unwind edge). fn reset_to_exit_of(&mut self, bb: BasicBlock); diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index c7f6983be6192..71388a8f0f024 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -118,13 +118,13 @@ impl<'a, 'tcx, MWF, P> Graph<'a, 'tcx, MWF, P> where MWF: MirWithFlowState<'tcx>, P: Fn(&MWF::BD, >::Idx) -> DebugFormatted, { - /// Generate the node label + /// Generates the node label. fn node_label_internal(&self, n: &Node, w: &mut W, block: BasicBlock, mir: &Mir<'_>) -> io::Result<()> { - // Header rows + // Header rows. const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"]; const HDR_FMT: &str = "bgcolor=\"grey\""; write!(w, "")?; - // Data row + // Data row. self.node_label_verbose_row(n, w, block, mir)?; self.node_label_final_row(n, w, block, mir)?; write!(w, "
", HDRS.len())?; @@ -135,7 +135,7 @@ where MWF: MirWithFlowState<'tcx>, } write!(w, "
")?; @@ -168,10 +168,10 @@ where MWF: MirWithFlowState<'tcx>, } write!(w, "")?; - // Entry + // Entry. dump_set_for!(on_entry_set_for, interpret_set); - // MIR statements + // MIR statements. write!(w, "")?; { let data = &mir[block]; @@ -182,10 +182,10 @@ where MWF: MirWithFlowState<'tcx>, } write!(w, "")?; - // Gen + // Gen. dump_set_for!(gen_set_for, interpret_hybrid_set); - // Kill + // Kill. dump_set_for!(kill_set_for, interpret_hybrid_set); write!(w, "")?; @@ -206,11 +206,11 @@ where MWF: MirWithFlowState<'tcx>, write!(w, "")?; - // Entry + // Entry. let set = flow.sets.on_entry_set_for(i); write!(w, "{:?}", dot::escape_html(&set.to_string()))?; - // Terminator + // Terminator. write!(w, "")?; { let data = &mir[block]; @@ -220,11 +220,11 @@ where MWF: MirWithFlowState<'tcx>, } write!(w, "")?; - // Gen + // Gen. let set = flow.sets.gen_set_for(i); write!(w, "{:?}", dot::escape_html(&format!("{:?}", set)))?; - // Kill + // Kill. let set = flow.sets.kill_set_for(i); write!(w, "{:?}", dot::escape_html(&format!("{:?}", set)))?; diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index 51d628ce6c5c2..6970b0f4a27a5 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -68,21 +68,23 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> { _dest_bb: mir::BasicBlock, _dest_place: &mir::Place<'tcx>, ) { - // Nothing to do when a call returns successfully + // Nothing to do when a call returns successfully. } } impl<'a, 'tcx> BitSetOperator for HaveBeenBorrowedLocals<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { - inout_set.union(in_set) // "maybe" means we union effects of both preds + // "maybe" means we union effects of both preds. + inout_set.union(in_set) } } impl<'a, 'tcx> InitialFlow for HaveBeenBorrowedLocals<'a, 'tcx> { #[inline] fn bottom_value() -> bool { - false // bottom = unborrowed + // Bottom value means unborrowed. + false } } diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index beb0b3187082b..8f8e8fe00ce14 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -160,12 +160,12 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { &self.borrow_set.borrows[idx].reserve_location } - /// Add all borrows to the kill set, if those borrows are out of scope at `location`. + /// Adds all borrows to the kill set, if those borrows are out of scope at `location`. /// That means they went out of a nonlexical scope fn kill_loans_out_of_scope_at_location(&self, sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { - // NOTE: The state associated with a given `location` + // NOTE: the state associated with a given `location` // reflects the dataflow on entry to the statement. // Iterate over each of the borrows that we've precomputed // to have went out of scope at this location and kill them. diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index cc92ebfab89b7..540429f948817 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -173,6 +173,13 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 't /// Similarly, at a given `drop` statement, the set-difference between /// this data and `MaybeInitializedPlaces` yields the set of places /// that would require a dynamic drop-flag at that statement. +// +// FIXME: note that once flow-analysis is complete, this should be +// the set-complement of `MaybeUninitializedPlaces`; thus we can get rid +// of one or the other of these two. I'm inclined to get rid of +// `MaybeUninitializedPlaces`, simply because the sets will tend to be +// smaller in this analysis and thus easier for humans to process +// when debugging. pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, mir: &'a Mir<'tcx>, diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index efd979a7da4fb..fadc69a58e2df 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -268,7 +268,7 @@ pub enum LookupResult { impl<'tcx> MovePathLookup<'tcx> { // Unlike the builder `fn move_path_for` below, this lookup - // alternative will *not* create a MovePath on the fly for an + // alternative will **not** create a MovePath on the fly for an // unknown place, but will rather return the nearest available // parent. pub fn find(&self, place: &Place<'tcx>) -> LookupResult { diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index 31aa3c2782697..8b6c2f9857e36 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -287,7 +287,7 @@ match x { E0030: r##" When matching against a range, the compiler verifies that the range is -non-empty. Range patterns include both end-points, so this is equivalent to +non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. @@ -538,7 +538,7 @@ match Some("hi".to_string()) { The `op_string_ref` binding has type `&Option<&String>` in both cases. -See also https://github.com/rust-lang/rust/issues/14587 +See also . "##, E0010: r##" @@ -573,7 +573,7 @@ const Y: i32 = A; ``` "##, -// FIXME(#57563) Change the language here when const fn stabilizes +// FIXME(#57563): change the language here when const fn feature stabilizes. E0015: r##" The only functions that can be called in static or constant expressions are `const` functions, and struct/enum constructors. `const` functions are only @@ -690,7 +690,7 @@ fn main() { } ``` -See also https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html +See also . "##, E0373: r##" @@ -828,7 +828,7 @@ with `#[derive(Clone)]`. Some types have no ownership semantics at all and are trivial to duplicate. An example is `i32` and the other number types. We don't have to call `.clone()` to -clone them, because they are marked `Copy` in addition to `Clone`. Implicit +clone them, because they are marked `Copy` in addition to `Clone`. Implicit cloning is more convenient in this case. We can mark our own types `Copy` if all their members also are marked `Copy`. @@ -981,7 +981,7 @@ fn mutable() { foo(|| x = 2); } -// Attempts to take a mutable reference to closed-over data. Error message +// Attempts to take a mutable reference to closed-over data. Error message // reads: `cannot borrow data mutably in a captured outer variable...` fn mut_addr() { let mut x = 0u32; @@ -2255,8 +2255,8 @@ gets called when they go out of scope. This destructor gets exclusive access to the fields of the struct when it runs. This means that when `s` reaches the end of `demo`, its destructor -gets exclusive access to its `&mut`-borrowed string data. allowing -another borrow of that string data (`p`), to exist across the drop of +gets exclusive access to its `&mut`-borrowed string data. Allowing +another borrow of that string data (`p`) to exist across the drop of `s` would be a violation of the principle that `&mut`-borrows have exclusive, unaliased access to their referenced data. diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 10d04a80d7341..7518fa883a9de 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -352,9 +352,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![lhs.to_ref(), rhs.to_ref()]) } else { - // FIXME overflow + // FIXME: overflow match (op.node, cx.constness) { - // FIXME(eddyb) use logical ops in constants when + // FIXME(eddyb): use logical ops in constants when // they can handle that kind of control-flow. (hir::BinOpKind::And, hir::Constness::Const) => { cx.control_flow_destroyed.push(( @@ -526,7 +526,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, (def_id, UpvarSubsts::Generator(substs), Some(movability)) } _ => { - span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty); + span_bug!(expr.span, "closure expr without closure type: {:?}", closure_ty); } }; let upvars = cx.tcx.with_freevars(expr.id, |freevars| { @@ -646,7 +646,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let user_ty = user_provided_types.get(cast_ty.hir_id); debug!( - "cast({:?}) has ty w/ hir_id {:?} and user provided ty {:?}", + "cast({:?}) has ty with hir_id {:?} and user provided ty {:?}", expr, cast_ty.hir_id, user_ty, @@ -739,8 +739,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }; if let Some(user_ty) = user_ty { - // NOTE: Creating a new Expr and wrapping a Cast inside of it may be - // inefficient, revisit this when performance becomes an issue. + // NOTE: creating a new `Expr` and wrapping a `Cast` inside of it may be + // inefficient, revisit this when performance becomes an issue. let cast_expr = Expr { temp_lifetime, ty: expr_ty, @@ -801,7 +801,7 @@ fn user_substs_applied_to_def( debug!("user_substs_applied_to_def: def={:?}", def); let user_provided_type = match def { // A reference to something callable -- e.g., a fn, method, or - // a tuple-struct or tuple-variant. This has the type of a + // a tuple struct or tuple variant. This has the type of a // `Fn` but with the user-given substitutions. Def::Fn(_) | Def::Method(_) | @@ -982,11 +982,11 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let var_hir_id = cx.tcx.hir().node_to_hir_id(var_id); let var_ty = cx.tables().node_type(var_hir_id); - // FIXME free regions in closures are not right + // FIXME: free regions in closures are not right let closure_ty = cx.tables() .node_type(cx.tcx.hir().node_to_hir_id(closure_expr_id)); - // FIXME we're just hard-coding the idea that the + // FIXME: we're just hard-coding the idea that the // signature will be &self or &mut self and hence will // have a bound region with number 0 let closure_def_id = cx.tcx.hir().local_def_id(closure_expr_id); diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index cd937d702fd77..3b2a0f1944f1f 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -66,11 +66,11 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { let attrs = tcx.hir().attrs(src_id); // Some functions always have overflow checks enabled, - // however, they may not get codegen'd, depending on + // however, they may not get codegen'ed, depending on // the settings for the crate they are codegened in. let mut check_overflow = attr::contains_name(attrs, "rustc_inherit_overflow_checks"); - // Respect -C overflow-checks. + // Respect `-C overflow-checks`. check_overflow |= tcx.sess.overflow_checks(); // Constants always need overflow checks. @@ -139,13 +139,13 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { match lit_to_const(lit, self.tcx, ty, neg) { Ok(c) => c, Err(LitToConstError::UnparseableFloat) => { - // FIXME(#31407) this is only necessary because float parsing is buggy + // FIXME(#31407): this is only necessary because float parsing is buggy. self.tcx.sess.span_err(sp, "could not evaluate float literal (see issue #31407)"); - // create a dummy value and continue compiling + // Create a dummy value and continue compiling. Const::from_bits(self.tcx, 0, self.param_env.and(ty)) }, Err(LitToConstError::Reported) => { - // create a dummy value and continue compiling + // Create a dummy value and continue compiling. Const::from_bits(self.tcx, 0, self.param_env.and(ty)) } } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 1c7e1aa4d71e0..2327cbc6ddc7f 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -340,7 +340,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { impl<'p, 'tcx> FromIterator; 2]>> for Matrix<'p, 'tcx> { fn from_iter(iter: T) -> Self - where T: IntoIterator; 2]>> + where T: IntoIterator; 2]>> { Matrix(iter.into_iter().collect()) } @@ -712,7 +712,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>( cx: &mut MatchCheckCtxt<'a, 'tcx>, patterns: I) -> u64 - where I: Iterator> + where I: Iterator> { // The exhaustiveness-checking paper does not include any details on // checking variable-length slice patterns. However, they are matched @@ -1069,10 +1069,10 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, let &Matrix(ref rows) = matrix; debug!("is_useful({:#?}, {:#?})", matrix, v); - // The base case. We are pattern-matching on () and the return value is + // The base case. We are pattern-matching on `()` and the return value is // based on whether our matrix has a row or not. - // NOTE: This could potentially be optimized by checking rows.is_empty() - // first and then, if v is non-empty, the return value is based on whether + // N.B., this could potentially be optimized by checking `rows.is_empty()` + // first, and then, if `v` is non-empty, the return value is based on whether // the type of the tuple we're checking is inhabited or not. if v.is_empty() { return if rows.is_empty() { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 8c2ab6437f9a2..b052029a8536f 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -1,32 +1,29 @@ -use super::_match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful}; -use super::_match::Usefulness::*; -use super::_match::WitnessPreference::*; - -use super::{Pattern, PatternContext, PatternError, PatternKind}; +use std::slice; +use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc::hir::def::*; +use rustc::hir::def_id::DefId; +use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use rustc::hir::{self, Pat, PatKind}; +use rustc::lint; +use rustc::middle::expr_use_visitor as euv; use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor}; use rustc::middle::expr_use_visitor::{LoanCause, MutateMode}; -use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization::cmt_; use rustc::middle::region; use rustc::session::Session; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::Substs; -use rustc::lint; -use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc::util::common::ErrorReported; - -use rustc::hir::def::*; -use rustc::hir::def_id::DefId; -use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; -use rustc::hir::{self, Pat, PatKind}; - use smallvec::smallvec; -use std::slice; - +use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use syntax::ast; use syntax::ptr::P; -use syntax_pos::{Span, DUMMY_SP, MultiSpan}; + +use super::{Pattern, PatternContext, PatternError, PatternKind}; +use super::_match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful}; +use super::_match::Usefulness::*; +use super::_match::WitnessPreference::*; pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { for def_id in tcx.body_owners() { @@ -118,7 +115,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self.span_e0158(span, "associated consts cannot be referenced in patterns") } PatternError::FloatBug => { - // FIXME(#31407) this is only necessary because float parsing is buggy + // FIXME(#31407): this is only necessary because float parsing is buggy. ::rustc::mir::interpret::struct_error( self.tcx.at(pat_span), "could not evaluate float literal (see issue #31407)", diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 2012086ea6649..2f7b7cbc91a68 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -465,8 +465,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { "lower bound larger than upper bound", ); if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("When matching against a range, the compiler \ - verifies that the range is non-empty. Range \ + err.note("when matching against a range, the compiler \ + verifies that the range is non-empty. range \ patterns include both end-points, so this is \ equivalent to requiring the start of the range \ to be less than or equal to the end of the range."); @@ -527,7 +527,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::Slice(..) | ty::Array(..) => self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix), - ty::Error => { // Avoid ICE + ty::Error => { + // Avoid ICE. return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } ref sty => @@ -552,7 +553,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatternKind::Leaf { subpatterns } } - ty::Error => { // Avoid ICE (#50577) + ty::Error => { + // Avoid ICE (#50577). return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } ref sty => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", sty), @@ -562,7 +564,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatKind::Binding(_, id, _, ident, ref sub) => { let var_ty = self.tables.node_type(pat.hir_id); if let ty::Error = var_ty.sty { - // Avoid ICE + // Avoid ICE. return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; }; let bm = *self.tables.pat_binding_modes().get(pat.hir_id) @@ -672,7 +674,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let orig_prefix = prefix; let orig_suffix = suffix; - // dance because of intentional borrow-checker stupidity. + // Dance because of intentional borrow-checker stupidity. let kind = *orig_slice.kind; match kind { PatternKind::Slice { prefix, slice, mut suffix } | @@ -742,7 +744,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let substs = match ty.sty { ty::Adt(_, substs) | ty::FnDef(_, substs) => substs, - ty::Error => { // Avoid ICE (#50585) + ty::Error => { + // Avoid ICE (#50585). return PatternKind::Wild; } _ => bug!("inappropriate type for def: {:?}", ty.sty), @@ -967,7 +970,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } }, ty::Adt(adt_def, _) if adt_def.is_union() => { - // Matching on union fields is unsafe, we can't hide it in constants + // Matching on union fields is unsafe; we can't hide it in constants. self.tcx.sess.span_err(span, "cannot use unions in constant patterns"); PatternKind::Wild } @@ -1243,7 +1246,7 @@ pub fn compare_const_vals<'a, 'gcx, 'tcx>( let tcx = tcx.global_tcx(); let (a, b, ty) = (a, b, ty).lift_to_tcx(tcx).unwrap(); - // FIXME: This should use assert_bits(ty) instead of use_bits + // FIXME: this should use assert_bits(ty) instead of use_bits // but triggers possibly bugs due to mismatching of arrays and slices if let (Some(a), Some(b)) = (a.to_bits(tcx, ty), b.to_bits(tcx, ty)) { use ::rustc_apfloat::Float; diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index ce62d79e585a8..9aed285782e2b 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -1,13 +1,12 @@ -use rustc::ty::{self, Ty, TypeAndMut}; -use rustc::ty::layout::{self, TyLayout, Size}; -use syntax::ast::{FloatTy, IntTy, UintTy}; - +use rustc_apfloat::Float; use rustc_apfloat::ieee::{Single, Double}; use rustc::mir::interpret::{ Scalar, EvalResult, Pointer, PointerArithmetic, EvalErrorKind, truncate }; use rustc::mir::CastKind; -use rustc_apfloat::Float; +use rustc::ty::{self, Ty, TypeAndMut}; +use rustc::ty::layout::{self, TyLayout, Size}; +use syntax::ast::{FloatTy, IntTy, UintTy}; use super::{EvalContext, Machine, PlaceTy, OpTy, ImmTy, Immediate}; diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 0c1b5d65b8b68..e9bc64c955d38 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -115,7 +115,7 @@ pub struct LocalState<'tcx, Tag=(), Id=AllocId> { /// State of a local variable #[derive(Copy, Clone, PartialEq, Eq, Hash)] -pub enum LocalValue { +pub enum LocalValue { Dead, // Mostly for convenience, we re-use the `Operand` type here. // This is an optimization over just always having a pointer here; @@ -369,16 +369,16 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc ); // Recurse to get the size of the dynamically sized field (must be - // the last field). Can't have foreign types here, how would we + // the last field). Can't have foreign types here, how would we // adjust alignment and size for them? let field = layout.field(self, layout.fields.count() - 1)?; let (unsized_size, unsized_align) = match self.size_and_align_of(metadata, field)? { Some(size_and_align) => size_and_align, None => { - // A field with extern type. If this field is at offset 0, we behave + // A field with extern type. If this field is at offset 0, we behave // like the underlying extern type. - // FIXME: Once we have made decisions for how to handle size and alignment - // of `extern type`, this should be adapted. It is just a temporary hack + // FIXME: once we have made decisions for how to handle size and alignment + // of `extern type`, this should be adapted. It is just a temporary hack // to get some code to work that probably ought to work. if sized_size == Size::ZERO { return Ok(None) @@ -388,7 +388,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc } }; - // FIXME (#26403, #27023): We should be adding padding + // FIXME(#26403, #27023): We should be adding padding // to `sized_size` (to accommodate the `unsized_align` // required of the unsized field that follows) before // summing it with `sized_size`. (Note that since #26403 @@ -450,20 +450,21 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc return_place: Option>, return_to_block: StackPopCleanup, ) -> EvalResult<'tcx> { - if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc... + // FIXME: should be `> 0`, but printing topmost frame crashes rustc. + if self.stack.len() > 1 { info!("PAUSING({}) {}", self.cur_frame(), self.frame().instance); } ::log_settings::settings().indentation += 1; - // first push a stack frame so we have access to the local substs + // First, push a stack frame so we have access to the local substs. let extra = M::stack_push(self)?; self.stack.push(Frame { mir, block: mir::START_BLOCK, return_to_block, return_place, - // empty local array, we fill it in below, after we are inside the stack frame and - // all methods actually know about the frame + // Empty local array -- we fill it in below, after we are inside the stack frame and + // all methods actually know about the frame. locals: IndexVec::new(), span, instance, @@ -471,10 +472,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc extra, }); - // don't allocate at all for trivial constants + // Don't allocate at all for trivial constants. if mir.local_decls.len() > 1 { // We put some marker immediate into the locals that we later want to initialize. - // This can be anything except for LocalValue::Dead -- because *that* is the + // This can be anything except for `LocalValue::Dead` -- because *that* is the // value we use for things that we know are initially dead. let dummy = LocalState { state: LocalValue::Live(Operand::Immediate(Immediate::Scalar( @@ -486,9 +487,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc // Return place is handled specially by the `eval_place` functions, and the // entry in `locals` should never be used. Make it dead, to be sure. locals[mir::RETURN_PLACE].state = LocalValue::Dead; - // Now mark those locals as dead that we do not want to initialize + // Now mark those locals that we do not want to initialize as dead. match self.tcx.describe_def(instance.def_id()) { - // statics and constants don't have `Storage*` statements, no need to look for them + // Statics and constants don't have `Storage*` statements; no need to look for them. Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {}, _ => { trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len()); @@ -506,7 +507,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc } }, } - // Finally, properly initialize all those that still have the dummy value + // Finally, properly initialize all those that still have the dummy value. for (idx, local) in locals.iter_enumerated_mut() { match local.state { LocalValue::Live(_) => { @@ -517,15 +518,16 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc local.layout = Cell::new(Some(layout)); } LocalValue::Dead => { - // Nothing to do + // Nothing to do. } } } - // done + // Done. self.frame_mut().locals = locals; } - if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE + // FIXME: should be `> 0`, but printing topmost frame crashes rustc. + if self.stack.len() > 1 { info!("ENTERING({}) {}", self.cur_frame(), self.frame().instance); } @@ -537,7 +539,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc } pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> { - if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE + // FIXME: should be `> 0`, but printing topmost frame crashes rustc. + if self.stack.len() > 1 { info!("LEAVING({}) {}", self.cur_frame(), self.frame().instance); } ::log_settings::settings().indentation -= 1; @@ -567,7 +570,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc if M::enforce_validity(self) { // Data got changed, better make sure it matches the type! // It is still possible that the return place held invalid data while - // the function is running, but that's okay because nobody could have + // the function is running, but that's ok because nobody could have // accessed that same data from the "outside" to observe any broken // invariant -- that is, unless a function somehow has a ptr to // its return place... but the way MIR is currently generated, the @@ -591,7 +594,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc StackPopCleanup::None { .. } => {} } - if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc... + // FIXME: should be `> 0`, but printing topmost frame crashes rustc. + if self.stack.len() > 1 { info!("CONTINUING({}) {}", self.cur_frame(), self.frame().instance); } @@ -645,9 +649,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc } else { self.param_env }; - // We use `const_eval_raw` here, and get an unvalidated result. That is okay: + // We use `const_eval_raw` here, and get an unvalidated result. That is ok: // Our result will later be validated anyway, and there seems no good reason - // to have to fail early here. This is also more consistent with + // to have to fail early here. This is also more consistent with // `Memory::get_static_alloc` which has to use `const_eval_raw` to avoid cycles. let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| { match err { diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 88b936afaa4c1..e2ac05757ff67 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -79,7 +79,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout } } -// FIXME: Really we shouldn't clone memory, ever. Snapshot machinery should instead +// FIXME: really we shouldn't clone memory, ever. Snapshot machinery should instead // carefully copy only the reachable parts. impl<'a, 'mir, 'tcx, M> Clone @@ -286,7 +286,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { /// Checks if the pointer is "in-bounds". Notice that a pointer pointing at the end /// of an allocation (i.e., at the first *inaccessible* location) *is* considered - /// in-bounds! This follows C's/LLVM's rules. + /// in-bounds! This follows C's/LLVM's rules. /// If you want to check bounds before doing a memory access, better first obtain /// an `Allocation` and call `check_bounds`. pub fn check_bounds_ptr( @@ -356,7 +356,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } pub fn get(&self, id: AllocId) -> EvalResult<'tcx, &Allocation> { - // The error type of the inner closure here is somewhat funny. We have two + // The error type of the inner closure here is somewhat funny. We have two // ways of "erroring": An actual error, or because we got a reference from // `get_static_alloc` that we can actually use directly without inserting anything anywhere. // So the error type is `EvalResult<'tcx, &Allocation>`. @@ -609,14 +609,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } } -/// Interning (for CTFE) +/// Interning (for CTFE). impl<'a, 'mir, 'tcx, M> Memory<'a, 'mir, 'tcx, M> where M: Machine<'a, 'mir, 'tcx, PointerTag=(), AllocExtra=(), MemoryExtra=()>, - // FIXME: Working around https://github.com/rust-lang/rust/issues/24159 + // FIXME: working around issue #24159. M::MemoryMap: AllocMap, Allocation)>, { - /// mark an allocation as static and initialized, either mutable or not + /// Mark an allocation as static and initialized, either mutable or not. pub fn intern_static( &mut self, alloc_id: AllocId, @@ -627,29 +627,29 @@ where alloc_id, mutability ); - // remove allocation + // Remove allocation. let (kind, mut alloc) = self.alloc_map.remove(&alloc_id).unwrap(); match kind { MemoryKind::Machine(_) => bug!("Static cannot refer to machine memory"), MemoryKind::Stack | MemoryKind::Vtable => {}, } - // ensure llvm knows not to put this into immutable memory + // Ensure that LLVM knows not to put this into immutable memory. alloc.mutability = mutability; let alloc = self.tcx.intern_const_alloc(alloc); self.tcx.alloc_map.lock().set_alloc_id_memory(alloc_id, alloc); - // recurse into inner allocations + // Recurse into inner allocations. for &(_, alloc) in alloc.relocations.values() { - // FIXME: Reusing the mutability here is likely incorrect. It is originally + // FIXME: reusing the mutability here is likely incorrect. It is originally // determined via `is_freeze`, and data is considered frozen if there is no // `UnsafeCell` *immediately* in that data -- however, this search stops - // at references. So whenever we follow a reference, we should likely + // at references. So whenever we follow a reference, we should likely // assume immutability -- and we should make sure that the compiler // does not permit code that would break this! if self.alloc_map.contains_key(&alloc) { - // Not yet interned, so proceed recursively + // Not yet interned, so proceed recursively. self.intern_static(alloc, mutability)?; } else if self.dead_alloc_map.contains_key(&alloc) { - // dangling pointer + // Dangling pointer. return err!(ValidationFailure( "encountered dangling pointer in final constant".into(), )) @@ -773,7 +773,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { /// Undefined bytes impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { - // FIXME: Add a fast version for the common, nonoverlapping case + // FIXME: add a fast version for the common, nonoverlapping case fn copy_undef_mask( &mut self, src: Pointer, diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 7da907028eebf..cc99feecd68bf 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -4,28 +4,28 @@ use std::convert::TryInto; use rustc::{mir, ty}; -use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerExt, VariantIdx}; - +pub use rustc::mir::interpret::ScalarMaybeUndef; use rustc::mir::interpret::{ GlobalId, AllocId, InboundsCheck, ConstValue, Pointer, Scalar, EvalResult, EvalErrorKind, }; +use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerExt, VariantIdx}; + use super::{ EvalContext, Machine, AllocMap, Allocation, AllocationExtra, MemPlace, MPlaceTy, PlaceTy, Place, MemoryKind, }; -pub use rustc::mir::interpret::ScalarMaybeUndef; /// A `Value` represents a single immediate self-contained Rust value. /// /// For optimization of a few very common cases, there is also a representation for a pair of -/// primitive values (`ScalarPair`). It allows Miri to avoid making allocations for checked binary +/// primitive values (`ScalarPair`). It allows miri to avoid making allocations for checked binary /// operations and fat pointers. This idea was taken from rustc's codegen. /// In particular, thanks to `ScalarPair`, arithmetic operations and casts can be entirely /// defined on `Immediate`, and do not have to work with a `Place`. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Immediate { +pub enum Immediate { Scalar(ScalarMaybeUndef), ScalarPair(ScalarMaybeUndef, ScalarMaybeUndef), } @@ -106,7 +106,7 @@ impl<'tcx, Tag> Immediate { } /// Converts the value into its metadata. - /// Throws away the first half of a ScalarPair! + /// Throws away the first half of a `ScalarPair`. #[inline] pub fn to_meta(self) -> EvalResult<'tcx, Option>> { Ok(match self { @@ -116,7 +116,7 @@ impl<'tcx, Tag> Immediate { } } -// ScalarPair needs a type to interpret, so we often have an immediate and a type together +// `ScalarPair` needs a type to interpret, so we often have an immediate and a type together // as input for binary and cast operations. #[derive(Copy, Clone, Debug)] pub struct ImmTy<'tcx, Tag=()> { @@ -136,7 +136,7 @@ impl<'tcx, Tag> ::std::ops::Deref for ImmTy<'tcx, Tag> { /// or still in memory. The latter is an optimization, to delay reading that chunk of /// memory and to avoid having to store arbitrary-sized data here. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Operand { +pub enum Operand { Immediate(Immediate), Indirect(MemPlace), } @@ -267,14 +267,14 @@ pub(super) fn from_known_layout<'tcx>( } impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { - /// Try reading an immediate in memory; this is interesting particularly for ScalarPair. + /// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`. /// Returns `None` if the layout does not permit loading this as a value. pub(super) fn try_read_immediate_from_mplace( &self, mplace: MPlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx, Option>> { if mplace.layout.is_unsized() { - // Don't touch unsized + // Don't touch unsized places. return Ok(None); } let (ptr, ptr_align) = mplace.to_scalar_ptr_align(); @@ -286,7 +286,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> return Ok(Some(Immediate::Scalar(Scalar::zst().into()))); } - // check for integer pointers before alignment to report better errors + // Check for integer pointers before alignment to report better errors. let ptr = ptr.to_ptr()?; self.memory.check_align(ptr.into(), ptr_align)?; match mplace.layout.abi { @@ -301,7 +301,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let (a_size, b_size) = (a.size(self), b.size(self)); let a_ptr = ptr; let b_offset = a_size.align_to(b.align(self).abi); - assert!(b_offset.bytes() > 0); // we later use the offset to test which field to use + // We later use the offset to test which field to use. + assert!(b_offset.bytes() > 0); let b_ptr = ptr.offset(b_offset, self)?; let a_val = self.memory .get(ptr.alloc_id)? @@ -317,11 +318,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } } - /// Try returning an immediate for the operand. - /// If the layout does not permit loading this as an immediate, return where in memory + /// Tries returning an `Immediate` for the operand. + /// If the layout does not permit loading this as an `Immediate`, return where in memory /// we can find the data. /// Note that for a given layout, this operation will either always fail or always - /// succeed! Whether it succeeds depends on whether the layout can be represented + /// succeed! Whether it succeeds depends on whether the layout can be represented /// in a `Immediate`, not on which data is stored there currently. pub(crate) fn try_read_immediate( &self, @@ -339,7 +340,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> }) } - /// Read an immediate from a place, asserting that that is possible with the given layout. + /// Reads an immediate from a place, asserting that that is possible with the given layout. #[inline(always)] pub fn read_immediate( &self, @@ -352,7 +353,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } } - /// Read a scalar from a place + /// Reads a scalar from a place. pub fn read_scalar( &self, op: OpTy<'tcx, M::PointerTag> @@ -360,7 +361,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Ok(self.read_immediate(op)?.to_scalar_or_undef()) } - // Turn the MPlace into a string (must already be dereferenced!) + // Turns the `MPlace` into a string. Must already be dereferenced! pub fn read_str( &self, mplace: MPlaceTy<'tcx, M::PointerTag>, @@ -376,7 +377,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> &mut self, layout: TyLayout<'tcx> ) -> EvalResult<'tcx, Operand> { - // This decides which types we will use the Immediate optimization for, and hence should + // This decides which types we will use the `Immediate` optimization for, and hence should // match what `try_read_immediate` and `eval_place_to_op` support. if layout.is_zst() { return Ok(Operand::Immediate(Immediate::Scalar(Scalar::zst().into()))); @@ -399,7 +400,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> }) } - /// Projection functions + /// Projection functions. pub fn operand_field( &self, op: OpTy<'tcx, M::PointerTag>, @@ -407,7 +408,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { let base = match op.try_as_mplace() { Ok(mplace) => { - // The easy case + // The easy case. let field = self.mplace_field(mplace, field)?; return Ok(field.into()); }, @@ -422,9 +423,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } let offset = op.layout.fields.offset(field); let immediate = match base { - // the field covers the entire type + // The field covers the entire type. _ if offset.bytes() == 0 && field_layout.size == op.layout.size => base, - // extract fields from types with `ScalarPair` ABI + // Extract fields from types with `ScalarPair` ABI. Immediate::ScalarPair(a, b) => { let val = if offset.bytes() == 0 { a } else { b }; Immediate::Scalar(val) @@ -440,7 +441,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> op: OpTy<'tcx, M::PointerTag>, variant: VariantIdx, ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { - // Downcasts only change the layout + // Downcasts only change the layout. Ok(match op.try_as_mplace() { Ok(mplace) => { self.mplace_downcast(mplace, variant)?.into() @@ -465,19 +466,19 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Subslice { .. } | ConstantIndex { .. } | Index(_) => if base.layout.is_zst() { OpTy { op: Operand::Immediate(Immediate::Scalar(Scalar::zst().into())), - // the actual index doesn't matter, so we just pick a convenient one like 0 + // The actual index doesn't matter, so we just pick a convenient one like 0. layout: base.layout.field(self, 0)?, } } else { - // The rest should only occur as mplace, we do not use Immediates for types - // allowing such operations. This matches place_projection forcing an allocation. + // The rest should only occur as mplace, we do not use `Immediate`s for types + // allowing such operations. This matches `place_projection` forcing an allocation. let mplace = base.to_mem_place(); self.mplace_projection(mplace, proj_elem)?.into() } }) } - /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local + /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an `OpTy` from a local. pub fn access_local( &self, frame: &super::Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>, @@ -490,7 +491,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Ok(OpTy { op, layout }) } - /// Every place can be read from, so we can turm them into an operand + /// Converts a place into an operator. Always possible, since every place can be read from. #[inline(always)] pub fn place_to_op( &self, @@ -506,7 +507,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Ok(OpTy { op, layout: place.layout }) } - // Evaluate a place with the goal of reading from it. This lets us sometimes + // Evaluates a place with the goal of reading from it. This lets us sometimes // avoid allocations. fn eval_place_to_op( &self, @@ -530,7 +531,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Ok(op) } - /// Evaluate the operand, returning a place where you can then find the data. + /// Evaluates the operand, returning a place where you can then find the data. /// if you already know the layout, you can save two some table lookups /// by passing it in here. pub fn eval_operand( @@ -540,7 +541,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { use rustc::mir::Operand::*; let op = match *mir_op { - // FIXME: do some more logic on `move` to invalidate the old location + // FIXME: do some more logic on `move` to invalidate the old location. Copy(ref place) | Move(ref place) => self.eval_place_to_op(place, layout)?, @@ -558,7 +559,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Ok(op) } - /// Evaluate a bunch of operands at once + /// Evaluates a collection of operands at once. pub(super) fn eval_operands( &self, ops: &[mir::Operand<'tcx>], @@ -568,7 +569,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> .collect() } - // Used when Miri runs into a constant, and (indirectly through lazy_const_to_op) by CTFE. + // Used when Miri runs into a constant, and (indirectly through `lazy_const_to_op`) by CTFE. fn const_value_to_op( &self, val: ty::LazyConst<'tcx>, @@ -602,7 +603,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } } - /// Read discriminant, return the runtime value as well as the variant index. + /// Reads discriminant, return the runtime value as well as the variant index. pub fn read_discriminant( &self, rval: OpTy<'tcx, M::PointerTag>, @@ -619,12 +620,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {}, } - // read raw discriminant value + // Read raw discriminant value. let discr_op = self.operand_field(rval, 0)?; let discr_val = self.read_immediate(discr_op)?; let raw_discr = discr_val.to_scalar_or_undef(); trace!("discr value: {:?}", raw_discr); - // post-process + // Post-process. Ok(match rval.layout.variants { layout::Variants::Single { .. } => bug!(), layout::Variants::Tagged { .. } => { @@ -634,11 +635,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> }; let real_discr = if discr_val.layout.ty.is_signed() { let i = bits_discr as i128; - // going from layout tag type to typeck discriminant type - // requires first sign extending with the layout discriminant + // Going from layout tag type to typeck discriminant type + // requires first sign extending with the layout discriminant, ... let shift = 128 - discr_val.layout.size.bits(); let sexted = (i << shift) >> shift; - // and then zeroing with the typeck discriminant type + // ... and then zeroing with the typeck discriminant type. let discr_ty = rval.layout.ty .ty_adt_def().expect("tagged layout corresponds to adt") .repr @@ -650,7 +651,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } else { bits_discr }; - // Make sure we catch invalid discriminants + // Make sure we catch invalid discriminants. let index = rval.layout.ty .ty_adt_def() .expect("tagged layout for non adt") @@ -669,7 +670,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let variants_end = niche_variants.end().as_u32() as u128; match raw_discr { ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) => { - // The niche must be just 0 (which an inbounds pointer value never is) + // The niche must be just 0 (which an inbounds pointer value never is). let ptr_valid = niche_start == 0 && variants_start == variants_end && self.memory.check_bounds_ptr(ptr, InboundsCheck::MaybeDead).is_ok(); if !ptr_valid { @@ -705,7 +706,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> impl<'a, 'mir, 'tcx, M> EvalContext<'a, 'mir, 'tcx, M> where M: Machine<'a, 'mir, 'tcx, PointerTag=()>, - // FIXME: Working around https://github.com/rust-lang/rust/issues/24159 + // FIXME: working around issue #24159. M::MemoryMap: AllocMap, Allocation<(), M::AllocExtra>)>, M::AllocExtra: AllocationExtra<(), M::MemoryExtra>, { diff --git a/src/librustc_mir/interpret/operator.rs b/src/librustc_mir/interpret/operator.rs index b3b9c742d6c28..6b7a598c97143 100644 --- a/src/librustc_mir/interpret/operator.rs +++ b/src/librustc_mir/interpret/operator.rs @@ -1,13 +1,12 @@ +use rustc_apfloat::Float; +use rustc_apfloat::ieee::{Double, Single}; use rustc::mir; +use rustc::mir::interpret::{EvalResult, Scalar}; use rustc::ty::{self, layout::{Size, TyLayout}}; use syntax::ast::FloatTy; -use rustc_apfloat::ieee::{Double, Single}; -use rustc_apfloat::Float; -use rustc::mir::interpret::{EvalResult, Scalar}; use super::{EvalContext, PlaceTy, Immediate, Machine, ImmTy}; - impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { /// Applies the binary operation `op` to the two operands and writes a tuple of the result /// and a boolean signifying the potential overflow to the destination. @@ -53,7 +52,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> Le => l <= r, Gt => l > r, Ge => l >= r, - _ => bug!("Invalid operation on char: {:?}", bin_op), + _ => bug!("invalid operation on char: {:?}", bin_op), }; return Ok((Scalar::from_bool(res), false)); } @@ -76,7 +75,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> BitAnd => l & r, BitOr => l | r, BitXor => l ^ r, - _ => bug!("Invalid operation on bool: {:?}", bin_op), + _ => bug!("invalid operation on bool: {:?}", bin_op), }; return Ok((Scalar::from_bool(res), false)); } @@ -85,7 +84,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> &self, bin_op: mir::BinOp, fty: FloatTy, - // passing in raw bits + // Passing in raw bits. l: u128, r: u128, ) -> EvalResult<'tcx, (Scalar, bool)> { @@ -123,7 +122,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> fn binary_int_op( &self, bin_op: mir::BinOp, - // passing in raw bits + // Passing in raw bits. l: u128, left_layout: TyLayout<'tcx>, r: u128, @@ -160,7 +159,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> return Ok((Scalar::from_uint(truncated, size), oflo)); } - // For the remaining ops, the types must be the same on both sides + // For the remaining ops, the types must be the same on both sides. if left_layout.ty != right_layout.ty { let msg = format!( "unimplemented asymmetric binary op {:?}: {:?} ({:?}), {:?} ({:?})", @@ -173,7 +172,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> return err!(Unimplemented(msg)); } - // Operations that need special treatment for signed integers + // Operations that need special treatment for signed integers. if left_layout.abi.is_signed() { let op: Option bool> = match bin_op { Lt => Some(i128::lt), @@ -203,7 +202,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let size = left_layout.size; match bin_op { Rem | Div => { - // int_min / -1 + // `int_min / -1` if r == -1 && l == (1 << (size.bits() - 1)) { return Ok((Scalar::from_uint(l, size), true)); } @@ -217,7 +216,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let max = 1 << (size.bits() - 1); oflo = result >= max || result < -max; } - // this may be out-of-bounds for the result type, so we have to truncate ourselves + // This may be out-of-bounds for the result type, so we have to truncate ourselves. let result = result as u128; let truncated = self.truncate(result, left_layout); return Ok((Scalar::from_uint(truncated, size), oflo)); @@ -226,7 +225,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let size = left_layout.size; - // only ints left + // Only ints left. let val = match bin_op { Eq => Scalar::from_bool(l == r), Ne => Scalar::from_bool(l != r), @@ -303,13 +302,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> self.binary_float_op(bin_op, fty, left, right) } _ => { - // Must be integer(-like) types. Don't forget about == on fn pointers. + // Must be integer(-like) types. Don't forget about `==` on fn pointers. assert!(left.layout.ty.is_integral() || left.layout.ty.is_unsafe_ptr() || left.layout.ty.is_fn()); assert!(right.layout.ty.is_integral() || right.layout.ty.is_unsafe_ptr() || right.layout.ty.is_fn()); - // Handle operations that support pointer values + // Handle operations that support pointer values. if left.to_scalar_ptr()?.is_ptr() || right.to_scalar_ptr()?.is_ptr() || bin_op == mir::BinOp::Offset @@ -317,7 +316,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> return M::ptr_op(self, bin_op, left, right); } - // Everything else only works with "proper" bits + // Everything else only works with "proper" bits. let l = left.to_bits().expect("we checked is_ptr"); let r = right.to_bits().expect("we checked is_ptr"); self.binary_int_op(bin_op, l, left.layout, r, right.layout) @@ -336,14 +335,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let layout = val.layout; let val = val.to_scalar()?; - trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty.sty); + trace!("running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty.sty); match layout.ty.sty { ty::Bool => { let val = val.to_bool()?; let res = match un_op { Not => !val, - _ => bug!("Invalid bool op {:?}", un_op) + _ => bug!("invalid bool op {:?}", un_op) }; Ok(Scalar::from_bool(res)) } @@ -352,7 +351,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let res = match (un_op, fty) { (Neg, FloatTy::F32) => Single::to_bits(-Single::from_bits(val)), (Neg, FloatTy::F64) => Double::to_bits(-Double::from_bits(val)), - _ => bug!("Invalid float op {:?}", un_op) + _ => bug!("invalid float op {:?}", un_op) }; Ok(Scalar::from_uint(res, layout.size)) } @@ -366,7 +365,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> (-(val as i128)) as u128 } }; - // res needs tuncating + // `res` needs truncating. Ok(Scalar::from_uint(self.truncate(res, layout), layout.size)) } } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index b29e09900f6b1..4cf35cbba08c5 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -18,7 +18,7 @@ use super::{ }; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub struct MemPlace { +pub struct MemPlace { /// A place may have an integral pointer for ZSTs, and since it might /// be turned back into a reference before ever being dereferenced. /// However, it may never be undef. @@ -31,7 +31,7 @@ pub struct MemPlace { } #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Place { +pub enum Place { /// A place referring to a value allocated in the `Memory` system. Ptr(MemPlace), @@ -226,7 +226,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> { _ => bug!("len not supported on unsized type {:?}", self.layout.ty), } } else { - // Go through the layout. There are lots of types that support a length, + // Go through the layout. There are lots of types that support a length, // e.g., SIMD types. match self.layout.fields { layout::FieldPlacement::Array { count, .. } => Ok(count), @@ -303,20 +303,20 @@ impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> { } } -// separating the pointer tag for `impl Trait`, see https://github.com/rust-lang/rust/issues/54385 +// Separating the pointer tag for `impl Trait`, see issue #54385. impl<'a, 'mir, 'tcx, Tag, M> EvalContext<'a, 'mir, 'tcx, M> where - // FIXME: Working around https://github.com/rust-lang/rust/issues/54385 + // FIXME: working around issue #54385. Tag: ::std::fmt::Debug+Default+Copy+Eq+Hash+'static, M: Machine<'a, 'mir, 'tcx, PointerTag=Tag>, - // FIXME: Working around https://github.com/rust-lang/rust/issues/24159 + // FIXME: working around issue #24159. M::MemoryMap: AllocMap, Allocation)>, M::AllocExtra: AllocationExtra, { /// Take a value, which represents a (thin or fat) reference, and make it a place. - /// Alignment is just based on the type. This is the inverse of `MemPlace::to_ref()`. + /// Alignment is just based on the type. This is the inverse of `MemPlace::to_ref()`. /// This does NOT call the "deref" machine hook, so it does NOT count as a - /// deref as far as Stacked Borrows is concerned. Use `deref_operand` for that! + /// deref as far as Stacked Borrows is concerned. Use `deref_operand` for that! pub fn ref_to_mplace( &self, val: ImmTy<'tcx, M::PointerTag>, @@ -333,7 +333,7 @@ where } // Take an operand, representing a pointer, and dereference it to a place -- that - // will always be a MemPlace. Lives in `place.rs` because it creates a place. + // will always be a MemPlace. Lives in `place.rs` because it creates a place. // This calls the "deref" machine hook, and counts as a deref as far as // Stacked Borrows is concerned. pub fn deref_operand( @@ -392,8 +392,8 @@ where Some((_, align)) => align, None if offset == Size::ZERO => // An extern type at offset 0, we fall back to its static alignment. - // FIXME: Once we have made decisions for how to handle size and alignment - // of `extern type`, this should be adapted. It is just a temporary hack + // FIXME: once we have made decisions for how to handle size and alignment + // of `extern type`, this should be adapted. It is just a temporary hack // to get some code to work that probably ought to work. field_layout.align.abi, None => @@ -417,7 +417,7 @@ where &self, base: MPlaceTy<'tcx, Tag>, ) -> - EvalResult<'tcx, impl Iterator>> + 'a> + EvalResult<'tcx, impl Iterator>> + 'a> { let len = base.len(self)?; // also asserts that we have a type where this makes sense let stride = match base.layout.fields { @@ -469,12 +469,12 @@ where base: MPlaceTy<'tcx, M::PointerTag>, variant: VariantIdx, ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { - // Downcasts only change the layout + // Downcasts only change the layout. assert!(base.meta.is_none()); Ok(MPlaceTy { layout: base.layout.for_variant(self, variant), ..base }) } - /// Project into an mplace + /// Projects into an mplace. pub fn mplace_projection( &self, base: MPlaceTy<'tcx, M::PointerTag>, @@ -525,7 +525,7 @@ where base: PlaceTy<'tcx, M::PointerTag>, field: u64, ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { - // FIXME: We could try to be smarter and avoid allocation for fields that span the + // FIXME: we could try to be smarter and avoid allocation for fields that span the // entire place. let mplace = self.force_allocation(base)?; Ok(self.mplace_field(mplace, field)?.into()) @@ -597,9 +597,9 @@ where // and it knows how to deal with alloc_id that are present in the // global table but not in its local memory: It calls back into tcx through // a query, triggering the CTFE machinery to actually turn this lazy reference - // into a bunch of bytes. IOW, statics are evaluated with CTFE even when - // this EvalContext uses another Machine (e.g., in miri). This is what we - // want! This way, computing statics works concistently between codegen + // into a bunch of bytes. That is, statics are evaluated with CTFE even when + // this `EvalContext` uses another Machine (e.g., in miri). This is what we + // want! This way, computing statics works concistently between codegen // and miri: They use the same query to eventually obtain a `ty::Const` // and use that for further computation. let alloc = self.tcx.alloc_map.lock().intern_static(cid.instance.def_id()); @@ -694,7 +694,7 @@ where "Size mismatch when writing bits"), Immediate::Scalar(ScalarMaybeUndef::Undef) => {}, // undef can have any size Immediate::ScalarPair(_, _) => { - // FIXME: Can we check anything here? + // FIXME: can we check anything here? } } } @@ -735,17 +735,17 @@ where // to handle padding properly, which is only correct if we never look at this data with the // wrong type. - // Nothing to do for ZSTs, other than checking alignment + // Nothing to do for ZSTs, other than checking alignment. if dest.layout.is_zst() { return self.memory.check_align(ptr, ptr_align); } - // check for integer pointers before alignment to report better errors + // Check for integer pointers before alignment to report better errors. let ptr = ptr.to_ptr()?; self.memory.check_align(ptr.into(), ptr_align)?; let tcx = &*self.tcx; - // FIXME: We should check that there are dest.layout.size many bytes available in - // memory. The code below is not sufficient, with enough padding it might not + // FIXME: we should check that there are `dest.layout.size` many bytes available in + // memory. The code below is not sufficient, with enough padding it might not // cover all the bytes! match value { Immediate::Scalar(scalar) => { @@ -862,11 +862,11 @@ where assert!(src.layout.size == dest.layout.size, "Size mismatch when transmuting!\nsrc: {:#?}\ndest: {:#?}", src, dest); - // The hard case is `ScalarPair`. `src` is already read from memory in this case, + // The hard case is `ScalarPair`. `src` is already read from memory in this case, // using `src.layout` to figure out which bytes to use for the 1st and 2nd field. // We have to write them to `dest` at the offsets they were *read at*, which is // not necessarily the same as the offsets in `dest.layout`! - // Hence we do the copy with the source layout on both sides. We also make sure to write + // Hence we do the copy with the source layout on both sides. We also make sure to write // into memory, because if `dest` is a local we would not even have a way to write // at the `src` offsets; the fact that we came from a different layout would // just be lost. @@ -898,10 +898,10 @@ where Operand::Indirect(mplace) => mplace, Operand::Immediate(value) => { // We need to make an allocation. - // FIXME: Consider not doing anything for a ZST, and just returning - // a fake pointer? Are we even called for ZST? + // FIXME: consider not doing anything for a ZST, and just returning + // a fake pointer? Are we even called for ZST? - // We need the layout of the local. We can NOT use the layout we got, + // We need the layout of the local. We can NOT use the layout we got, // that might e.g., be an inner field of a struct with `Scalar` layout, // that has different alignment than the outer field. let local_layout = self.layout_of_local(&self.stack[frame], local, None)?; @@ -930,7 +930,7 @@ where ) -> MPlaceTy<'tcx, M::PointerTag> { if layout.is_unsized() { assert!(self.tcx.features().unsized_locals, "cannot alloc memory for unsized type"); - // FIXME: What should we do here? We should definitely also tag! + // FIXME: what should we do here? We should definitely also tag! MPlaceTy::dangling(layout, self) } else { let ptr = self.memory.allocate(layout.size, layout.align.abi, kind); diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index ee295116ba962..ca7094b9315c5 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -2,7 +2,7 @@ //! during const-evaluation by taking snapshots of the state of the interpreter //! at regular intervals. -// This lives in `interpret` because it needs access to all sots of private state. However, +// This lives in `interpret` because it needs access to all sots of private state. However, // it is not used by the general miri engine, just by CTFE. use std::hash::{Hash, Hasher}; @@ -400,11 +400,11 @@ impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx> } } - // Used to compare two snapshots + // Used to compare two snapshots. fn snapshot(&'b self) -> Vec> { - // Start with the stack, iterate and recursively snapshot + // Start with the stack, iterate, and recursively snapshot. self.stack.iter().map(|frame| frame.snapshot(&self.memory)).collect() } @@ -413,7 +413,7 @@ impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx> impl<'a, 'mir, 'tcx> Hash for EvalSnapshot<'a, 'mir, 'tcx> { fn hash(&self, state: &mut H) { - // Implement in terms of hash stable, so that k1 == k2 -> hash(k1) == hash(k2) + // Implement in terms of hash stable, so that `k1 == k2` -> `hash(k1) == hash(k2)`. let mut hcx = self.memory.tcx.get_stable_hashing_context(); let mut hasher = StableHasher::::new(); self.hash_stable(&mut hcx, &mut hasher); @@ -422,7 +422,7 @@ impl<'a, 'mir, 'tcx> Hash for EvalSnapshot<'a, 'mir, 'tcx> } impl_stable_hash_for!(impl<'tcx, 'b, 'mir> for struct EvalSnapshot<'b, 'mir, 'tcx> { - // Not hashing memory: Avoid hashing memory all the time during execution + // Not hashing memory: avoid hashing memory all the time during execution. memory -> _, stack, }); @@ -433,8 +433,8 @@ impl<'a, 'mir, 'tcx> Eq for EvalSnapshot<'a, 'mir, 'tcx> impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx> { fn eq(&self, other: &Self) -> bool { - // FIXME: This looks to be a *ridicolously expensive* comparison operation. - // Doesn't this make tons of copies? Either `snapshot` is very badly named, + // FIXME: this looks to be a *ridicolously expensive* comparison operation. + // Doesn't this make tons of copies? Either `snapshot` is very badly named, // or it does! self.snapshot() == other.snapshot() } diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index c2ee3f5715bd3..4c919ee52e01b 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -186,7 +186,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } // Compare layout match (&caller.abi, &callee.abi) { - // Different valid ranges are okay (once we enforce validity, + // Different valid ranges are ok (once we enforce validity, // that will take care to make it UB to leave the range, just // like for transmute). (layout::Abi::Scalar(ref caller), layout::Abi::Scalar(ref callee)) => @@ -203,7 +203,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> fn pass_argument( &mut self, rust_abi: bool, - caller_arg: &mut impl Iterator>, + caller_arg: &mut impl Iterator>, callee_arg: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { if rust_abi && callee_arg.layout.is_zst() { @@ -294,7 +294,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> )?; // We want to pop this frame again in case there was an error, to put - // the blame in the right location. Until the 2018 edition is used in + // the blame in the right location. Until the 2018 edition is used in // the compiler, we have to do this with an immediately invoked function. let res = (||{ trace!( @@ -323,7 +323,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> }; // For where they come from: If the ABI is RustCall, we untuple the - // last incoming argument. These two iterators do not have the same type, + // last incoming argument. These two iterators do not have the same type, // so to keep the code paths uniform we accept an allocation // (for RustCall ABI only). let caller_args : Cow<'_, [OpTy<'tcx, M::PointerTag>]> = @@ -346,7 +346,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> .map(|op| *op); // Now we have to spread them out across the callee's locals, - // taking into account the `spread_arg`. If we could write + // taking into account the `spread_arg`. If we could write // this is a single iterator (that handles `spread_arg`), then // `pass_argument` would be the loop body. It takes care to // not advance `caller_iter` for ZSTs. @@ -437,8 +437,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> target: mir::BasicBlock, ) -> EvalResult<'tcx> { trace!("drop_in_place: {:?},\n {:?}, {:?}", *place, place.layout.ty, instance); - // We take the address of the object. This may well be unaligned, which is fine - // for us here. However, unaligned accesses will probably make the actual drop + // We take the address of the object. This may well be unaligned, which is fine + // for us here. However, unaligned accesses will probably make the actual drop // implementation fail -- a problem shared by rustc. let place = self.force_allocation(place)?; diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 8b97d9ded7449..9daed3ba8474d 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -104,7 +104,7 @@ fn path_format(path: &Vec) -> String { ArrayElem(idx) => write!(out, "[{}]", idx), Deref => // This does not match Rust syntax, but it is more readable for long paths -- and - // some of the other items here also are not Rust syntax. Actually we can't + // some of the other items here also are not Rust syntax. Actually we can't // even use the usual syntax because we are just showing the projections, // not the root. write!(out, "."), @@ -288,22 +288,22 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> value, self.path, "a valid unicode codepoint"); }, ty::Float(_) | ty::Int(_) | ty::Uint(_) => { - // NOTE: Keep this in sync with the array optimization for int/float + // NOTE: keep this in sync with the array optimization for int/float // types below! let size = value.layout.size; let value = value.to_scalar_or_undef(); if self.const_mode { - // Integers/floats in CTFE: Must be scalar bits, pointers are dangerous + // Integers/floats in CTFE: must be scalar bits; pointers are dangerous try_validation!(value.to_bits(size), value, self.path, "initialized plain (non-pointer) bytes"); } else { - // At run-time, for now, we accept *anything* for these types, including + // At runtime, for now, we accept *anything* for these types, including // undef. We should fix that, but let's start low. } } ty::RawPtr(..) => { if self.const_mode { - // Integers/floats in CTFE: For consistency with integers, we do not + // Integers/floats in CTFE: for consistency with integers, we do not // accept undef. let _ptr = try_validation!(value.to_scalar_ptr(), "undefined address in raw pointer", self.path); @@ -331,7 +331,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> "invalid drop fn in vtable", self.path); try_validation!(self.ecx.read_size_and_align_from_vtable(vtable), "invalid size or align in vtable", self.path); - // FIXME: More checks for the vtable. + // FIXME: more checks for the vtable. } ty::Slice(..) | ty::Str => { try_validation!(meta.unwrap().to_usize(self.ecx), @@ -380,9 +380,9 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> let alloc_kind = self.ecx.tcx.alloc_map.lock().get(ptr.alloc_id); if let Some(AllocKind::Static(did)) = alloc_kind { // `extern static` cannot be validated as they have no body. - // FIXME: Statics from other crates are also skipped. + // FIXME: statics from other crates are also skipped. // They might be checked at a different type, but for now we - // want to avoid recursing too deeply. This is not sound! + // want to avoid recursing too deeply. This is not sound! if !did.is_local() || self.ecx.tcx.is_foreign_item(did) { return Ok(()); } @@ -396,7 +396,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> "dangling (not entirely in bounds) reference", self.path); } // Check if we have encountered this pointer+layout combination - // before. Proceed recursively even for integer pointers, no + // before. Proceed recursively even for integer pointers, no // reason to skip them! They are (recursively) valid for some ZST, // but not for others (e.g., `!` is a ZST). let op = place.into(); @@ -418,7 +418,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> value, self.path, "a pointer"); let _fn = try_validation!(self.ecx.memory.get_fn(ptr), value, self.path, "a function pointer"); - // FIXME: Check if the signature matches + // FIXME: check if the signature matches } // This should be all the primitive types _ => bug!("Unexpected primitive type {}", value.layout.ty) @@ -505,7 +505,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> fn visit_aggregate( &mut self, op: OpTy<'tcx, M::PointerTag>, - fields: impl Iterator>, + fields: impl Iterator>, ) -> EvalResult<'tcx> { match op.layout.ty.sty { ty::Str => { @@ -540,12 +540,12 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> let ptr = mplace.ptr.to_ptr()?; - // NOTE: Keep this in sync with the handling of integer and float + // NOTE: keep this in sync with the handling of integer and float // types above, in `visit_primitive`. - // In run-time mode, we accept pointers in here. This is actually more + // In run-time mode, we accept pointers in here. This is actually more // permissive than a per-element check would be, e.g., we accept // an &[u8] that contains a pointer even though bytewise checking would - // reject it. However, that's good: We don't inherently want + // reject it. However, that's good: We don't inherently want // to reject those pointers, we just do not have the machinery to // talk about parts of a pointer. // We also accept undef, for consistency with the type-based checks. diff --git a/src/librustc_mir/interpret/visitor.rs b/src/librustc_mir/interpret/visitor.rs index e2abf2ffc849c..f137133bcc92b 100644 --- a/src/librustc_mir/interpret/visitor.rs +++ b/src/librustc_mir/interpret/visitor.rs @@ -154,7 +154,7 @@ macro_rules! make_value_visitor { fn visit_aggregate( &mut self, v: Self::V, - fields: impl Iterator>, + fields: impl Iterator>, ) -> EvalResult<'tcx> { self.walk_aggregate(v, fields) } @@ -197,7 +197,7 @@ macro_rules! make_value_visitor { } /// Called whenever we reach a value with uninhabited layout. - /// Recursing to fields will *always* continue after this! This is not meant to control + /// Recursing to fields will *always* continue after this! This is not meant to control /// whether and how we descend recursively/ into the scalar's fields if there are any, /// it is meant to provide the chance for additional checks when a value of uninhabited /// layout is detected. @@ -207,7 +207,7 @@ macro_rules! make_value_visitor { /// Called whenever we reach a value with scalar layout. /// We do NOT provide a `ScalarMaybeUndef` here to avoid accessing memory if the /// visitor is not even interested in scalars. - /// Recursing to fields will *always* continue after this! This is not meant to control + /// Recursing to fields will *always* continue after this! This is not meant to control /// whether and how we descend recursively/ into the scalar's fields if there are any, /// it is meant to provide the chance for additional checks when a value of scalar /// layout is detected. @@ -217,7 +217,7 @@ macro_rules! make_value_visitor { /// Called whenever we reach a value of primitive type. There can be no recursion /// below such a value. This is the leaf function. - /// We do *not* provide an `ImmTy` here because some implementations might want + /// We do **not** provide an `ImmTy` here because some implementations might want /// to write to the place this primitive lives in. #[inline(always)] fn visit_primitive(&mut self, _v: Self::V) -> EvalResult<'tcx> @@ -227,7 +227,7 @@ macro_rules! make_value_visitor { fn walk_aggregate( &mut self, v: Self::V, - fields: impl Iterator>, + fields: impl Iterator>, ) -> EvalResult<'tcx> { // Now iterate over it. for (idx, field_val) in fields.enumerate() { @@ -271,7 +271,7 @@ macro_rules! make_value_visitor { // Things can be aggregates and have scalar layout at the same time, and that // is very relevant for `NonNull` and similar structs: We need to visit them // at their scalar layout *before* descending into their fields. - // FIXME: We could avoid some redundant checks here. For newtypes wrapping + // FIXME: we could avoid some redundant checks here. For newtypes wrapping // scalars, we do the same check on every "level" (e.g., first we check // MyNewtype and then the scalar in there). match v.layout().abi { @@ -281,12 +281,12 @@ macro_rules! make_value_visitor { layout::Abi::Scalar(ref layout) => { self.visit_scalar(v, layout)?; } - // FIXME: Should we do something for ScalarPair? Vector? + // FIXME: should we do something for `ScalarPair` and `Vector`? _ => {} } - // Check primitive types. We do this after checking the scalar layout, - // just to have that done as well. Primitives can have varying layout, + // Check primitive types. We do this after checking the scalar layout, + // just to have that done as well. Primitives can have varying layout, // so we check them separately and before aggregate handling. // It is CRITICAL that we get this check right, or we might be // validating the wrong thing! @@ -303,7 +303,7 @@ macro_rules! make_value_visitor { match v.layout().fields { layout::FieldPlacement::Union(fields) => { // Empty unions are not accepted by rustc. That's great, it means we can - // use that as an unambiguous signal for detecting primitives. Make sure + // use that as an unambiguous signal for detecting primitives. Make sure // we did not miss any primitive. debug_assert!(fields > 0); self.visit_union(v) @@ -323,7 +323,7 @@ macro_rules! make_value_visitor { Ok(()) } _ => { - // FIXME: We collect in a vec because otherwise there are lifetime + // FIXME: we collect in a vec because otherwise there are lifetime // errors: Projecting to a field needs access to `ecx`. let fields: Vec> = (0..offsets.len()).map(|i| { diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 6b6e8fcdc82cf..4602fe1287b2a 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -22,11 +22,11 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, def_id: DefId) { if let FnKind::Closure(_) = fn_kind { - // closures can't recur, so they don't matter. + // Closures can't recur, so they don't matter. return; } - //FIXME(#54444) rewrite this lint to use the dataflow framework + //FIXME(#54444): rewrite this lint to use the dataflow framework. // Walk through this function (say `f`) looking to see if // every possible path references itself, i.e., the function is @@ -36,7 +36,7 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, // pretending that calls of `f` are sinks (i.e., ignoring any // exit edges from them). // - // NB. this has an edge case with non-returning statements, + // N.B., this has an edge case with non-returning statements, // like `loop {}` or `panic!()`: control flow never reaches // the exit node through these, so one can have a function // that never actually calls itself but is still picked up by @@ -132,9 +132,9 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); let sp = tcx.sess.source_map().def_span(tcx.hir().span(node_id)); let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION, - node_id, - sp, - "function cannot return without recursing"); + node_id, + sp, + "function cannot return without recursing"); db.span_label(sp, "cannot return without recursing"); // offer some help to the programmer. for location in &self_call_locations { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index a76aa7454cbe4..4f1259807ac29 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -708,7 +708,7 @@ fn visit_instance_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -// Returns true if we should codegen an instance in the local crate. +// Returns whether we should codegen an instance in the local crate. // Returns false if we can just link to the upstream crate and therefore don't // need a mono item. fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instance<'tcx>) diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 6e639c3a1179a..ee4f2a2cd709c 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -241,8 +241,8 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { // Pushes the type name of the specified type to the provided string. // If 'debug' is true, printing normally unprintable types is allowed - // (e.g. ty::GeneratorWitness). This parameter should only be set when - // this method is being used for logging purposes (e.g. with debug! or info!) + // (e.g., `ty::GeneratorWitness`). This parameter should only be set when + // this method is being used for logging purposes (e.g., with `debug!` or `info!`) // When being used for codegen purposes, 'debug' should be set to 'false' // in order to catch unexpected types that should never end up in a type name pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String, debug: bool) { diff --git a/src/librustc_mir/monomorphize/mod.rs b/src/librustc_mir/monomorphize/mod.rs index 7fa904d32cbb4..6160e324687a1 100644 --- a/src/librustc_mir/monomorphize/mod.rs +++ b/src/librustc_mir/monomorphize/mod.rs @@ -1,19 +1,20 @@ +pub mod collector; +pub mod item; +pub mod partitioning; + use rustc::hir::def_id::DefId; use rustc::middle::lang_items::DropInPlaceFnLangItem; use rustc::traits; use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::ty::{self, Ty, TyCtxt}; - pub use rustc::ty::Instance; -pub use self::item::{MonoItem, MonoItemExt}; -pub mod collector; -pub mod item; -pub mod partitioning; +pub use self::item::{MonoItem, MonoItemExt}; -#[inline(never)] // give this a place in the profiler +// Give this a place in the profiler. +#[inline(never)] pub fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mono_items: I) - where I: Iterator> + where I: Iterator> { let mut symbols: Vec<_> = mono_items.map(|mono_item| { (mono_item, mono_item.symbol_name(tcx)) @@ -92,7 +93,7 @@ fn needs_fn_once_adapter_shim(actual_closure_kind: ty::ClosureKind, Ok(false) } (ty::ClosureKind::Fn, ty::ClosureKind::FnMut) => { - // The closure fn `llfn` is a `fn(&self, ...)`. We want a + // The closure fn `llfn` is a `fn(&self, ...)`. We want a // `fn(&mut self, ...)`. In fact, at codegen time, these are // basically the same thing, so we can just return llfn. Ok(false) @@ -100,7 +101,7 @@ fn needs_fn_once_adapter_shim(actual_closure_kind: ty::ClosureKind, (ty::ClosureKind::Fn, ty::ClosureKind::FnOnce) | (ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => { // The closure fn `llfn` is a `fn(&self, ...)` or `fn(&mut - // self, ...)`. We want a `fn(self, ...)`. We can produce + // self, ...)`. We want a `fn(self, ...)`. We can produce // this by doing something like: // // fn call_once(self, ...) { call_mut(&self, ...) } diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index f342017603ed6..d55a5148cbfd4 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -764,7 +764,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; // If this is a method, we want to put it into the same module as - // its self-type. If the self-type does not provide a characteristic + // its self type. If the self type does not provide a characteristic // DefId, we use the location of the impl after all. if tcx.trait_of_item(def_id).is_some() { @@ -775,7 +775,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let Some(impl_def_id) = tcx.impl_of_method(def_id) { // This is a method within an inherent impl, find out what the - // self-type is: + // self type is: let impl_self_ty = tcx.subst_and_normalize_erasing_regions( instance.substs, ty::ParamEnv::reveal_all(), @@ -864,7 +864,7 @@ fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, label: &str, cgus: I) - where I: Iterator>, + where I: Iterator>, 'tcx: 'a + 'b { if cfg!(debug_assertions) { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index d4145b8e47ea2..4b75a407a6555 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -71,7 +71,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ) } ty::InstanceDef::Virtual(def_id, _) => { - // We are generating a call back to our def-id, which the + // We are generating a call back to our `DefId`, which the // codegen backend knows to turn to an actual virtual call. build_call_shim( tcx, diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index 4d4c89b8b6a40..7df3122a5ceed 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -10,8 +10,8 @@ use crate::util; // struct to a separate local before dropping them, to ensure that // they are dropped from an aligned address. // -// For example, if we have something like -// ```Rust +// For example, if we have something like: +// // #[repr(packed)] // struct Foo { // dealign: u8, @@ -19,7 +19,6 @@ use crate::util; // } // // let foo = ...; -// ``` // // We want to call `drop_in_place::>` on `data` from an aligned // address. This means we can't simply drop `foo.data` directly, because diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index e66c11aa36e0e..abb66c4ee087f 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -13,19 +13,19 @@ pub struct AddRetag; /// Determines whether this place is "stable": Whether, if we evaluate it again /// after the assignment, we can be sure to obtain the same place value. /// (Concurrent accesses by other threads are no problem as these are anyway non-atomic -/// copies. Data races are UB.) +/// copies. Data races are UB.) fn is_stable<'tcx>( place: &Place<'tcx>, ) -> bool { use rustc::mir::Place::*; match *place { - // Locals and statics have stable addresses, for sure + // Locals and statics have stable addresses, for sure. Local { .. } | Promoted { .. } | Static { .. } => true, - // Recurse for projections + // Recurse for projections. Projection(ref proj) => { match proj.elem { // Which place this evaluates to can change with any memory write, @@ -51,16 +51,16 @@ fn is_stable<'tcx>( /// not below references. fn may_have_reference<'a, 'gcx, 'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool { match ty.sty { - // Primitive types that are not references + // Primitive types that are not references. ty::Bool | ty::Char | ty::Float(_) | ty::Int(_) | ty::Uint(_) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Str | ty::FnDef(..) | ty::Never => false, - // References + // References. ty::Ref(..) => true, ty::Adt(..) if ty.is_box() => true, - // Compound types + // Compound types. ty::Array(ty, ..) | ty::Slice(ty) => may_have_reference(ty, tcx), ty::Tuple(tys) => @@ -69,7 +69,7 @@ fn may_have_reference<'a, 'gcx, 'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) adt.variants.iter().any(|v| v.fields.iter().any(|f| may_have_reference(f.ty(tcx, substs), tcx) )), - // Conservative fallback + // Conservative fallback. _ => true, } } @@ -86,7 +86,7 @@ impl MirPass for AddRetag { let (span, arg_count) = (mir.span, mir.arg_count); let (basic_blocks, local_decls) = mir.basic_blocks_and_local_decls_mut(); let needs_retag = |place: &Place<'tcx>| { - // FIXME: Instead of giving up for unstable places, we should introduce + // FIXME: instead of giving up for unstable places, we should introduce // a temporary and retag on that. is_stable(place) && may_have_reference(place.ty(&*local_decls, tcx).to_ty(tcx), tcx) }; @@ -96,10 +96,10 @@ impl MirPass for AddRetag { { let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, - span: span, // FIXME: Consider using just the span covering the function - // argument declaration. + // FIXME: consider using just the span covering the function argument declaration. + span: span, }; - // Gather all arguments, skip return value. + // Gather all arguments; skip return value. let places = local_decls.iter_enumerated().skip(1).take(arg_count) .map(|(local, _)| Place::Local(local)) .filter(needs_retag) @@ -114,13 +114,13 @@ impl MirPass for AddRetag { } // PART 2 - // Retag return values of functions. Also escape-to-raw the argument of `drop`. + // Retag return values of functions. Also escape-to-raw the argument of `drop`. // We collect the return destinations because we cannot mutate while iterating. let mut returns: Vec<(SourceInfo, Place<'tcx>, BasicBlock)> = Vec::new(); for block_data in basic_blocks.iter_mut() { match block_data.terminator().kind { TerminatorKind::Call { ref destination, .. } => { - // Remember the return destination for later + // Remember the return destination for later. if let Some(ref destination) = destination { if needs_retag(&destination.0) { returns.push(( @@ -136,7 +136,7 @@ impl MirPass for AddRetag { // `Drop` is also a call, but it doesn't return anything so we are good. } _ => { - // Not a block ending in a Call -> ignore. + // Not a block ending in a `Call`, so ignore. } } } @@ -151,7 +151,7 @@ impl MirPass for AddRetag { // PART 3 // Add retag after assignment. for block_data in basic_blocks { - // We want to insert statements as we iterate. To this end, we + // We want to insert statements as we iterate. To this end, we // iterate backwards using indices. for i in (0..block_data.statements.len()).rev() { let (retag_kind, place) = match block_data.statements[i].kind { @@ -167,12 +167,12 @@ impl MirPass for AddRetag { assert!(dest_ty.is_unsafe_ptr()); (RetagKind::Raw, place) } else { - // Some other cast, no retag + // Some other cast, no retag. continue } } // Assignments of reference or ptr type are the ones where we may have - // to update tags. This includes `x = &[mut] ...` and hence + // to update tags. This includes `x = &[mut] ...` and hence // we also retag after taking a reference! StatementKind::Assign(ref place, box ref rvalue) if needs_retag(place) => { let kind = match rvalue { @@ -185,7 +185,7 @@ impl MirPass for AddRetag { }; (kind, place) } - // Do nothing for the rest + // Do nothing for the rest. _ => continue, }; // Insert a retag after the statement. diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 66529e579835d..77584403cf799 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -1,22 +1,20 @@ +use std::ops::Bound; + use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::sync::Lrc; - -use rustc::ty::query::Providers; -use rustc::ty::{self, TyCtxt}; -use rustc::ty::cast::CastTy; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; use rustc::mir::*; use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext}; - +use rustc::ty::{self, TyCtxt}; +use rustc::ty::cast::CastTy; +use rustc::ty::query::Providers; use syntax::ast; use syntax::symbol::Symbol; -use std::ops::Bound; - use crate::util; pub struct UnsafetyChecker<'a, 'tcx: 'a> { @@ -42,7 +40,7 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> { tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> Self { - // sanity check + // Sanity check. if min_const_fn { assert!(const_context); } @@ -85,7 +83,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { TerminatorKind::Unreachable | TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => { - // safe (at least as emitted during MIR construction) + // Safe (at least as emitted during MIR construction). } TerminatorKind::Call { ref func, .. } => { @@ -116,7 +114,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { StatementKind::Retag { .. } | StatementKind::AscribeUserType(..) | StatementKind::Nop => { - // safe (at least as emitted during MIR construction) + // Safe (at least as emitted during MIR construction). } StatementKind::InlineAsm { .. } => { @@ -157,9 +155,9 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { } } }, - // casting pointers to ints is unsafe in const fn because the const evaluator cannot + // Casting pointers to ints is unsafe in const fn because the const evaluator cannot // possibly know what the result of various operations like `address / 2` would be - // pointers during const evaluation have no integral address, only an abstract one + // pointers during const evaluation have no integral address, only an abstract one. Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) if self.const_context && self.tcx.features().const_raw_ptr_to_usize_cast => { let operand_ty = operand.ty(self.mir, self.tcx); @@ -179,7 +177,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { _ => {}, } } - // raw pointer and fn pointer operations are unsafe as it is not clear whether one + // Raw pointer and fn pointer operations are unsafe, as it is not clear whether one // pointer would be "less" or "equal" to another, because we cannot know where llvm // or the linker will place various statics in memory. Without this information the // result of a comparison of addresses would differ between runtime and compile-time. @@ -230,12 +228,12 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { .ty(self.mir, self.tcx) .to_ty(self.tcx) .is_freeze(self.tcx, self.param_env, self.source_info.span); - // prevent - // * `&mut x.field` - // * `x.field = y;` - // * `&x.field` if `field`'s type has interior mutability - // because either of these would allow modifying the layout constrained field and - // insert values that violate the layout constraints. + // Prevent + // * `&mut x.field`, + // * `x.field = y;`, + // * `&x.field` if `field`'s type has interior mutability, + // since any of these would allow modifying the layout-constrained field and + // would insert values that violate the layout constraints. if context.is_mutating_use() || is_borrow_of_interior_mut { self.check_mut_borrowing_layout_constrained_field( place, context.is_mutating_use(), @@ -284,7 +282,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { causes undefined behavior if the field was not properly \ initialized", UnsafetyViolationKind::General) } else { - // write to non-move union, safe + // Write to non-move union; safe. } } else { self.require_unsafe("access to union field", @@ -299,7 +297,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { self.source_info = old_source_info; } &Place::Local(..) => { - // locals are safe + // Locals are safe. } &Place::Promoted(_) => { bug!("unsafety checking should happen before promotion") @@ -352,7 +350,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { unsafe_blocks: &[(ast::NodeId, bool)]) { let safety = self.source_scope_local_data[self.source_info.scope].safety; let within_unsafe = match safety { - // `unsafe` blocks are required in safe code + // `unsafe` blocks are required in safe code. Safety::Safe => { for violation in violations { let mut violation = violation.clone(); @@ -361,9 +359,9 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { UnsafetyViolationKind::General => {}, UnsafetyViolationKind::BorrowPacked(_) | UnsafetyViolationKind::ExternStatic(_) => if self.min_const_fn { - // const fns don't need to be backwards compatible and can - // emit these violations as a hard error instead of a backwards - // compat lint + // Const fns don't need to be backwards-compatible, and can + // emit these violations as a hard error instead of a backwards- + // compatibility lint. violation.kind = UnsafetyViolationKind::General; }, } @@ -373,27 +371,27 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { } false } - // `unsafe` function bodies allow unsafe without additional unsafe blocks + // `unsafe` function bodies allow unsafe without additional unsafe blocks. Safety::BuiltinUnsafe | Safety::FnUnsafe => true, Safety::ExplicitUnsafe(node_id) => { - // mark unsafe block as used if there are any unsafe operations inside + // Mark unsafe block as used if there are any unsafe operations inside. if !violations.is_empty() { self.used_unsafe.insert(node_id); } - // only some unsafety is allowed in const fn + // Only some unsafety is allowed in const fn. if self.min_const_fn { for violation in violations { match violation.kind { - // these unsafe things are stable in const fn + // These unsafe things are stable in const fn. UnsafetyViolationKind::GeneralAndConstFn => {}, - // these things are forbidden in const fns + // These things are forbidden in const fns. UnsafetyViolationKind::General | UnsafetyViolationKind::BorrowPacked(_) | UnsafetyViolationKind::ExternStatic(_) => { let mut violation = violation.clone(); - // const fns don't need to be backwards compatible and can - // emit these violations as a hard error instead of a backwards - // compat lint + // Const fns don't need to be backwards-compatible, and can + // emit these violations as a hard error instead of a backwards- + // compatibility lint. violation.kind = UnsafetyViolationKind::General; if !self.violations.contains(&violation) { self.violations.push(violation) @@ -517,8 +515,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { debug!("unsafety_violations({:?})", def_id); - // N.B., this borrow is valid because all the consumers of - // `mir_built` force this. + // N.B., this borrow is valid because all the consumers of `mir_built` force this. let mir = &tcx.mir_built(def_id).borrow(); let source_scope_local_data = match mir.source_scope_local_data { @@ -556,11 +553,10 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { let lint_node_id = match tcx.hir().as_local_node_id(def_id) { Some(node_id) => node_id, - None => bug!("checking unsafety for non-local def id {:?}", def_id) + None => bug!("checking unsafety for non-local `DefId` {:?}", def_id) }; - // FIXME: when we make this a hard error, this should have its - // own error code. + // FIXME: when we make this a hard error, this should have its own error code. let message = if tcx.generics_of(def_id).own_counts().types != 0 { "#[derive] can't be used on a #[repr(packed)] struct with \ type parameters (error E0133)".to_string() @@ -631,7 +627,7 @@ fn builtin_derive_def_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - pub fn check_unsafety<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { debug!("check_unsafety({:?})", def_id); - // closures are handled by their parent fn. + // Closures are handled by their parent fn. if tcx.is_closure(def_id) { return; } diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index 7d907ca3a215e..033d363e7dea2 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -119,7 +119,7 @@ impl MirPass for CopyPropagation { } changed = action.perform(mir, &def_use_analysis, dest_local, location) || changed; - // FIXME(pcwalton): Update the use-def chains to delete the instructions instead of + // FIXME(pcwalton): update the use-def chains to delete the instructions instead of // regenerating the chains. break } @@ -239,7 +239,7 @@ impl<'tcx> Action<'tcx> { // // First, remove all markers. // - // FIXME(pcwalton): Don't do this. Merge live ranges instead. + // FIXME(pcwalton): don't do this. Merge live ranges instead. debug!(" Replacing all uses of {:?} with {:?} (local)", dest_local, src_local); @@ -266,7 +266,7 @@ impl<'tcx> Action<'tcx> { Action::PropagateConstant(src_constant) => { // First, remove all markers. // - // FIXME(pcwalton): Don't do this. Merge live ranges instead. + // FIXME(pcwalton): don't do this. Merge live ranges instead. debug!(" Replacing all uses of {:?} with {:?} (constant)", dest_local, src_constant); diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 9061dfff76fe8..c05840b5acba4 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -14,10 +14,10 @@ impl MirPass for Deaggregator { let local_decls = &*local_decls; for bb in basic_blocks { bb.expand_statements(|stmt| { - // FIXME(eddyb) don't match twice on `stmt.kind` (post-NLL). + // FIXME(eddyb): don't match twice on `stmt.kind` (post-NLL). if let StatementKind::Assign(_, ref rhs) = stmt.kind { if let Rvalue::Aggregate(ref kind, _) = **rhs { - // FIXME(#48193) Deaggregate arrays when it's cheaper to do so. + // FIXME(#48193): deaggregate arrays when it's cheaper to do so. if let AggregateKind::Array(_) = **kind { return None; } @@ -60,12 +60,12 @@ impl MirPass for Deaggregator { Some(operands.into_iter().enumerate().map(move |(i, op)| { let lhs_field = if let AggregateKind::Array(_) = *kind { - // FIXME(eddyb) `offset` should be u64. + // FIXME(eddyb): `offset` should be u64. let offset = i as u32; assert_eq!(offset as usize, i); lhs.clone().elem(ProjectionElem::ConstantIndex { offset, - // FIXME(eddyb) `min_length` doesn't appear to be used. + // FIXME(eddyb): `min_length` doesn't appear to be used. min_length: offset + 1, from_end: false }) diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 0866b87cf17e6..9c0ab97027c48 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -156,21 +156,21 @@ struct TransformVisitor<'a, 'tcx: 'a> { state_adt_ref: &'tcx AdtDef, state_substs: &'tcx Substs<'tcx>, - // The index of the generator state in the generator struct + // The index of the generator state in the generator struct. state_field: usize, - // Mapping from Local to (type of local, generator struct index) - // FIXME(eddyb) This should use `IndexVec>`. + // Mapping from Local to (type of local, generator struct index). + // FIXME(eddyb): this should use `IndexVec>`. remap: FxHashMap, usize)>, // A map from a suspension point in a block to the locals which have live storage at that point - // FIXME(eddyb) This should use `IndexVec>`. + // FIXME(eddyb): this should use `IndexVec>`. storage_liveness: FxHashMap>, - // A list of suspension points, generated during the transform + // A list of suspension points, generated during the transform. suspension_points: Vec, - // The original RETURN_PLACE local + // The original `RETURN_PLACE` local. new_ret_local: Local, } diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 07ebbf6d0ebe3..8574b4cfb2fca 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -1,24 +1,23 @@ -//! Inlining pass for MIR functions +//! Inlining pass for MIR functions. -use rustc::hir::CodegenFnAttrFlags; -use rustc::hir::def_id::DefId; +use std::collections::VecDeque; +use std::iter; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; +use syntax::attr; +use rustc_target::spec::abi::Abi; +use rustc::hir::CodegenFnAttrFlags; +use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::mir::visit::*; use rustc::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; use rustc::ty::subst::{Subst,Substs}; -use std::collections::VecDeque; -use std::iter; use crate::transform::{MirPass, MirSource}; use super::simplify::{remove_dead_blocks, CfgSimplifier}; -use syntax::attr; -use rustc_target::spec::abi::Abi; - const DEFAULT_THRESHOLD: usize = 50; const HINT_THRESHOLD: usize = 100; @@ -59,7 +58,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { // advantage of the fact that queries detect cycles here to // allow us to try and fetch the fully optimized MIR of a // call; if it succeeds, we can inline it and we know that - // they do not call us. Otherwise, we just don't try to + // they do not call us. Otherwise, we just don't try to // inline. // // We use a queue so that we inline "broadly" before we inline @@ -136,7 +135,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { } debug!("attempting to inline callsite {:?} - success", callsite); - // Add callsites from inlined function + // Add callsites from inlined function. for (bb, bb_data) in caller_mir.basic_blocks().iter_enumerated().skip(start) { if let Some(new_callsite) = self.get_valid_function_call(bb, bb_data, @@ -221,7 +220,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { let tcx = self.tcx; // Don't inline closures that have captures - // FIXME: Handle closures better + // FIXME: handle closures better if callee_mir.upvar_decls.len() > 0 { debug!(" upvar decls present - not inlining"); return false; @@ -284,7 +283,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { } debug!(" final inline threshold = {}", threshold); - // FIXME: Give a bonus to functions with only a single caller + // FIXME: give a bonus to functions with only a single caller let param_env = tcx.param_env(self.source.def_id()); @@ -397,7 +396,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { mut callee_mir: Mir<'tcx>) -> bool { let terminator = caller_mir[callsite.bb].terminator.take().unwrap(); match terminator.kind { - // FIXME: Handle inlining of diverging calls + // FIXME: handle inlining of diverging calls TerminatorKind::Call { args, destination: Some(destination), cleanup, .. } => { debug!("Inlined {:?} into {:?}", callsite.callee, self.source); @@ -596,7 +595,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { callsite: &CallSite<'tcx>, caller_mir: &mut Mir<'tcx>, ) -> Local { - // FIXME: Analysis of the usage of the arguments to avoid + // FIXME: analysis of the usage of the arguments to avoid // unnecessary temporaries. if let Operand::Move(Place::Local(local)) = arg { diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 28b9e082851c0..6c90cbb38d0b5 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -261,7 +261,7 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx // elaboration. &add_moves_for_packed_drops::AddMovesForPackedDrops, // AddRetag needs to run after ElaborateDrops, and it needs - // an AllCallEdges pass right before it. Otherwise it should + // an AllCallEdges pass right before it. Otherwise it should // run fairly late, but before optimizations begin. &add_call_guards::AllCallEdges, &add_retag::AddRetag, diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index a6726718e2d23..5b6eb946c7d30 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -86,7 +86,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> { } // Ignore drops, if the temp gets promoted, - // then it's constant and thus drop is noop. + // then it's constant and thus drop is no-op. // Non-uses are also irrelevent. if context.is_drop() || !context.is_use() { debug!( diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 51168f650aeb7..d184e184148a4 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1,7 +1,7 @@ //! A pass that qualifies constness of temporaries in constants, //! static initializers and functions and also drives promotion. //! -//! The Qualif flags below can be used to also provide better +//! The `Qualif` flags below can be used to also provide better //! diagnostics as to why a constant rvalue wasn't promoted. use rustc_data_structures::bit_set::BitSet; @@ -31,7 +31,7 @@ use std::usize; use crate::transform::{MirPass, MirSource}; use super::promote_consts::{self, Candidate, TempState}; -/// What kind of item we are in. +/// The kind of item we are in. #[derive(Copy, Clone, Debug, PartialEq, Eq)] enum Mode { Const, @@ -54,7 +54,7 @@ impl fmt::Display for Mode { const QUALIF_COUNT: usize = 4; -// FIXME(eddyb) once we can use const generics, replace this array with +// FIXME(eddyb): once we can use const generics, replace this array with // something like `IndexVec` but for fixed-size arrays (`IndexArray`?). #[derive(Copy, Clone, Default)] struct PerQualif([T; QUALIF_COUNT]); @@ -137,13 +137,13 @@ enum ValueSource<'a, 'tcx> { trait Qualif { const IDX: usize; - /// Return the qualification that is (conservatively) correct for any value + /// Returns the qualification that is (conservatively) correct for any value /// of the type, or `None` if the qualification is not value/type-based. fn in_any_value_of_ty(_cx: &ConstCx<'_, 'tcx>, _ty: Ty<'tcx>) -> Option { None } - /// Return a mask for the qualification, given a type. This is `false` iff + /// Return a mask for the qualification, given a type. This is `false` if /// no value of that type can have the qualification. fn mask_for_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { Self::in_any_value_of_ty(cx, ty).unwrap_or(true) @@ -154,7 +154,7 @@ trait Qualif { } fn in_static(_cx: &ConstCx<'_, 'tcx>, _static: &Static<'tcx>) -> bool { - // FIXME(eddyb) should we do anything here for value properties? + // FIXME(eddyb): should we do anything here for value properties? false } @@ -208,9 +208,9 @@ trait Qualif { let qualif = PerQualif::decode_from_bits(bits).0[Self::IDX]; - // Just in case the type is more specific than - // the definition, e.g., impl associated const - // with type parameters, take it into account. + // Just in case the type is more specific than the definition, + // e.g., an impl associated const with type parameters, + // take it into account. qualif && Self::mask_for_ty(cx, constant.ty) } } else { @@ -238,7 +238,7 @@ trait Qualif { } Rvalue::Ref(_, _, ref place) => { - // Special-case reborrows to be more like a copy of the reference. + // Special-case reborrows to make them more like a copy of the reference. if let Place::Projection(ref proj) = *place { if let ProjectionElem::Deref = proj.elem { let base_ty = proj.base.ty(cx.mir, cx.tcx).to_ty(cx.tcx); @@ -281,7 +281,7 @@ trait Qualif { } } -// Constant containing interior mutability (UnsafeCell). +// Constant containing interior mutability (i.e., `UnsafeCell`). struct HasMutInterior; impl Qualif for HasMutInterior { @@ -301,10 +301,10 @@ impl Qualif for HasMutInterior { if let BorrowKind::Mut { .. } = kind { // In theory, any zero-sized value could be borrowed - // mutably without consequences. However, only &mut [] + // mutably without consequences. However, only `&mut []` // is allowed right now, and only in functions. if cx.mode == Mode::StaticMut { - // Inside a `static mut`, &mut [...] is also allowed. + // Inside a `static mut`, `&mut [...]` is also allowed. match ty.sty { ty::Array(..) | ty::Slice(_) => {} _ => return true, @@ -338,7 +338,7 @@ impl Qualif for HasMutInterior { } } -// Constant containing an ADT that implements Drop. +// Constant containing an ADT that implements `Drop`. struct NeedsDrop; impl Qualif for NeedsDrop { @@ -361,8 +361,8 @@ impl Qualif for NeedsDrop { } } -// Not constant at all - non-`const fn` calls, asm!, -// pointer comparisons, ptr-to-int casts, etc. +// Not constant at all (e.g., non-`const fn` calls, `asm!`, pointer comparisons, +// ptr-to-int casts, etc.). struct IsNotConst; impl Qualif for IsNotConst { @@ -409,7 +409,7 @@ impl Qualif for IsNotConst { match (cast_in, cast_out) { (CastTy::Ptr(_), CastTy::Int(_)) | (CastTy::FnPtr, CastTy::Int(_)) => { - // in normal functions, mark such casts as not promotable + // In normal functions, mark such casts as non-promotable. return true; } _ => {} @@ -423,7 +423,7 @@ impl Qualif for IsNotConst { op == BinOp::Ge || op == BinOp::Gt || op == BinOp::Offset); - // raw pointer operations are not allowed inside promoteds + // Raw pointer operations are not allowed inside promoteds. return true; } } @@ -497,8 +497,8 @@ impl Qualif for IsNotConst { } } -// Refers to temporaries which cannot be promoted as -// promote_consts decided they weren't simple enough. +// Refers to temporaries that cannot be promoted because `promote_consts` decided they weren't +// simple enough. struct IsNotPromotable; impl Qualif for IsNotPromotable { @@ -512,22 +512,22 @@ impl Qualif for IsNotPromotable { ) -> bool { if cx.mode == Mode::Fn { if let ty::FnDef(def_id, _) = callee.ty(cx.mir, cx.tcx).sty { - // Never promote runtime `const fn` calls of - // functions without `#[rustc_promotable]`. + // Never promote runtime `const fn` calls of functions without + // `#[rustc_promotable]`. if !cx.tcx.is_promotable_const_fn(def_id) { return true; } } } - // FIXME(eddyb) do we need "not promotable" in anything + // FIXME(eddyb): do we need "not promotable" in anything // other than `Mode::Fn` by any chance? false } } -// Ensure the `IDX` values are sequential (`0..QUALIF_COUNT`). +// Ensure the `IDX` values are sequential (i.e., `0..QUALIF_COUNT`). macro_rules! static_assert_seq_qualifs { ($i:expr => $first:ident $(, $rest:ident)*) => { static_assert!(SEQ_QUALIFS: { @@ -654,9 +654,8 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { } } - // FIXME(eddyb) we could split the errors into meaningful - // categories, but enabling full miri would make that - // slightly pointless (even with feature-gating). + // FIXME(eddyb): we could split the errors into meaningful categories, but enabling full Miri + // would make that slightly pointless (even with feature-gating). fn not_const(&mut self) { unleash_miri!(self); if self.mode != Mode::Fn { @@ -668,10 +667,10 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { self.mode ); if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("A function call isn't allowed in the const's initialization expression \ - because the expression's value must be known at compile-time."); - err.note("Remember: you can't use a function call inside a const's initialization \ - expression! However, you can use it anywhere else."); + err.note("a function call isn't allowed in the const's initialization expression \ + because the expression's value must be known at compile-time"); + err.note("remember: you can't use a function call inside a const's initialization \ + expression! however, you can use it anywhere else."); } err.emit(); } @@ -689,7 +688,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { // due to either a mutable borrow (with some exceptions), // or an shared borrow of a value with interior mutability. // Then `HasMutInterior` is replaced with `IsNotConst`, - // to avoid duplicate errors (e.g. from reborrowing). + // to avoid duplicate errors (e.g., from reborrowing). if qualifs[HasMutInterior] { qualifs[HasMutInterior] = false; qualifs[IsNotConst] = true; @@ -702,14 +701,14 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { err.span_label(self.span, format!("{}s require immutable values", self.mode)); if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("References in statics and constants may only refer to \ + err.note("references in statics and constants may only refer to \ immutable values.\n\n\ - Statics are shared everywhere, and if they refer to \ + statics are shared everywhere, and if they refer to \ mutable data one might violate memory safety since \ holding multiple mutable references to shared data is \ not allowed.\n\n\ - If you really want global mutable state, try using \ - static mut or a global UnsafeCell."); + if you really want global mutable state, try using \ + static mut or a global `UnsafeCell`."); } err.emit(); } else { @@ -737,8 +736,8 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { // (from `in_rvalue`), so we can safely ignore // `HasMutInterior` from the local's qualifications. // This allows borrowing fields which don't have - // `HasMutInterior`, from a type that does, e.g.: - // `let _: &'static _ = &(Cell::new(1), 2).1;` + // `HasMutInterior`, from a type that does, e.g., + // `let _: &'static _ = &(Cell::new(1), 2).1;`. let mut local_qualifs = self.qualifs_in_local(local); local_qualifs[HasMutInterior] = false; if !local_qualifs.0.iter().any(|&qualif| qualif) { @@ -753,14 +752,14 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { let mut dest = dest; let index = loop { match dest { - // We treat all locals equal in constants + // We treat all locals equal in constants. Place::Local(index) => break *index, - // projections are transparent for assignments - // we qualify the entire destination at once, even if just a field would have - // stricter qualification + // Projections are transparent for assignments. + // We qualify the entire destination at once, even if just a field would have + // stricter qualification. Place::Projection(proj) => { // Catch more errors in the destination. `visit_place` also checks various - // projection rules like union field access and raw pointer deref + // projection rules like union field access and raw pointer derefencing. self.visit_place( dest, PlaceContext::MutatingUse(MutatingUseContext::Store), @@ -793,7 +792,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { } } - // this is overly restrictive, because even full assignments do not clear the qualif + // This is overly restrictive, since even full assignments do not clear `qualif`. // While we could special case full assignments, this would be inconsistent with // aggregates where we overwrite all fields via assignments, which would not get // that feature. @@ -804,7 +803,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { } // Ensure the `IsNotPromotable` qualification is preserved. - // NOTE(eddyb) this is actually unnecessary right now, as + // NOTE(eddyb): this is actually unnecessary right now, as // we never replace the local's qualif, but we might in // the future, and so it serves to catch changes that unset // important bits (in which case, asserting `contains` could @@ -892,8 +891,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { let mut qualifs = self.qualifs_in_local(RETURN_PLACE); - // Account for errors in consts by using the - // conservative type qualification instead. + // Account for errors in consts by using conservative type qualification instead. if qualifs[IsNotConst] { qualifs = self.qualifs_in_any_value_of_ty(mir.return_ty()); } @@ -902,11 +900,9 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { } } -/// Checks MIR for const-correctness, using `ConstCx` -/// for value qualifications, and accumulates writes of -/// rvalue/call results to locals, in `local_qualif`. -/// For functions (constant or not), it also records -/// candidates for promotion in `promotion_candidates`. +/// Checks MIR for const-correctness, using `ConstCx` for value qualifications, and accumulates +/// writes of rvalue/call results to locals, in `local_qualif`. For functions (constant or not), +/// it also records candidates for promotion in `promotion_candidates`. impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { fn visit_place(&mut self, place: &Place<'tcx>, @@ -933,10 +929,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // Only allow statics (not consts) to refer to other statics. if self.mode == Mode::Static || self.mode == Mode::StaticMut { if self.mode == Mode::Static && context.is_mutating_use() { - // this is not strictly necessary as miri will also bail out - // For interior mutability we can't really catch this statically as that - // goes through raw pointers and intermediate temporaries, so miri has - // to catch this anyway + // This is not strictly necessary, as Miri will also bail out. + // For interior mutability, we can't really catch this statically, as that + // goes through raw pointers and intermediate temporaries, so Miri has + // to catch this anyway. self.tcx.sess.span_err( self.span, "cannot mutate statics in the initializer of another static", @@ -952,11 +948,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { a constant instead", self.mode); if self.tcx.sess.teach(&err.get_code().unwrap()) { err.note( - "Static and const variables can refer to other const variables. But a \ - const variable cannot refer to a static variable." + "static and const variables can refer to other const variables, but a \ + const variable cannot refer to a static variable" ); err.help( - "To fix this, the value can be extracted as a const and then used." + "to fix this, the value can be extracted as a const and then used" ); } err.emit() @@ -966,7 +962,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { match proj.elem { ProjectionElem::Deref => { if context.is_mutating_use() { - // `not_const` errors out in const contexts + // `not_const` errors out in const contexts. self.not_const() } let base_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); @@ -1031,7 +1027,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { match *operand { Operand::Move(ref place) => { - // Mark the consumed locals to indicate later drops are noops. + // Mark the consumed locals to indicate later drops are no-ops. if let Place::Local(local) = *place { self.cx.per_local[NeedsDrop].remove(local); } @@ -1105,8 +1101,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { (CastTy::FnPtr, CastTy::Int(_)) if self.mode != Mode::Fn => { unleash_miri!(self); if !self.tcx.features().const_raw_ptr_to_usize_cast { - // in const fn and constants require the feature gate - // FIXME: make it unsafe inside const fn and constants + // In const fn and constants, require the feature gate. + // FIXME: make it unsafe inside const fn and constants. emit_feature_err( &self.tcx.sess.parse_sess, "const_raw_ptr_to_usize_cast", self.span, GateIssue::Language, @@ -1130,8 +1126,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { unleash_miri!(self); if self.mode != Mode::Fn && !self.tcx.features().const_compare_raw_pointers { - // require the feature gate inside constants and const fn - // FIXME: make it unsafe to use these operations + // Require the feature gate inside constants and const fn. + // FIXME: make it unsafe to use these operations. emit_feature_err( &self.tcx.sess.parse_sess, "const_compare_raw_pointers", @@ -1151,8 +1147,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { err.span_label(self.span, format!("allocation not allowed in {}s", self.mode)); if self.tcx.sess.teach(&err.get_code().unwrap()) { err.note( - "The value of statics and constants must be known at compile time, \ - and they live for the entire lifetime of a program. Creating a boxed \ + "the value of statics and constants must be known at compile time, \ + and they live for the entire lifetime of a program. creating a boxed \ value allocates memory on the heap at runtime, and therefore cannot \ be done at compile time." ); @@ -1188,18 +1184,19 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { Abi::PlatformIntrinsic => { assert!(!self.tcx.is_const_fn(def_id)); match &self.tcx.item_name(def_id).as_str()[..] { - // special intrinsic that can be called diretly without an intrinsic - // feature gate needs a language feature gate + // Special intrinsic that can be called diretly without an intrinsic + // feature gate needs a language feature gate. "transmute" => { - // never promote transmute calls + // Never promote `transmute` calls. if self.mode != Mode::Fn { - // const eval transmute calls only with the feature gate + // Const eval `transmute` calls only with the feature gate. if !self.tcx.features().const_transmute { emit_feature_err( &self.tcx.sess.parse_sess, "const_transmute", self.span, GateIssue::Language, - &format!("The use of std::mem::transmute() \ - is gated in {}s", self.mode)); + &format!("the use of `std::mem::transmute()` \ + is gated in {}s", + self.mode)); } } } @@ -1208,8 +1205,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { is_shuffle = true; } - // no need to check feature gates, intrinsics are only callable - // from the libstd or with forever unstable feature gates + // No need to check feature gates; intrinsics are only callable + // from the libstd or with forever-unstable feature gates. _ => {} } } @@ -1223,13 +1220,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { .debugging_opts .unleash_the_miri_inside_of_you; if self.tcx.is_const_fn(def_id) || unleash_miri { - // stable const fns or unstable const fns + // Stable const fns or unstable const fns // with their feature gate active - // FIXME(eddyb) move stability checks from `is_const_fn` here. + // FIXME(eddyb): move stability checks from `is_const_fn` here. } else if self.is_const_panic_fn(def_id) { - // Check the const_panic feature gate. + // Check the `const_panic` feature gate. // FIXME: cannot allow this inside `allow_internal_unstable` - // because that would make `panic!` insta stable in constants, + // because that would make `panic!` insta-stable in constants, // since the macro is marked with the attribute. if !self.tcx.features().const_panic { // Don't allow panics in constants without the feature gate. @@ -1249,7 +1246,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { if !self.span.allows_unstable(&feature.as_str()) { let mut err = self.tcx.sess.struct_span_err(self.span, &format!("`{}` is not yet stable as a const fn", - self.tcx.item_path_str(def_id))); + self.tcx.item_path_str(def_id))); if nightly_options::is_nightly_build() { help!(&mut err, "add `#![feature({})]` to the \ @@ -1385,7 +1382,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { StatementKind::Assign(..) => { self.super_statement(bb, statement, location); } - // FIXME(eddyb) should these really do nothing? + // FIXME(eddyb): should these really do nothing? StatementKind::FakeRead(..) | StatementKind::SetDiscriminant { .. } | StatementKind::StorageLive(_) | @@ -1469,7 +1466,7 @@ impl MirPass for QualifyAndPromoteConstants { debug!("run_pass: mode={:?}", mode); if mode == Mode::Fn || mode == Mode::ConstFn { - // This is ugly because Checker holds onto mir, + // This is ugly because `Checker` holds onto MIR, // which can't be mutated until its scope ends. let (temps, candidates) = { let mut checker = Checker::new(tcx, def_id, mir, mode); @@ -1477,12 +1474,12 @@ impl MirPass for QualifyAndPromoteConstants { if tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { checker.check_const(); } else if tcx.is_min_const_fn(def_id) { - // enforce `min_const_fn` for stable const fns + // Enforce `min_const_fn` for stable const fns. use super::qualify_min_const_fn::is_min_const_fn; if let Err((span, err)) = is_min_const_fn(tcx, def_id, mir) { tcx.sess.span_err(span, &err); } else { - // this should not produce any errors, but better safe than sorry + // This should not produce any errors, but better safe than sorry. // FIXME(#53819) checker.check_const(); } @@ -1509,18 +1506,21 @@ impl MirPass for QualifyAndPromoteConstants { let mut error = tcx.sess.struct_span_err( span, &format!( - "new features like let bindings are not permitted in {}s \ - which also use short circuiting operators", + "new features like `let` bindings are not permitted in {}s \ + which also use short circuiting operators", mode, ), ); for (span, kind) in mir.control_flow_destroyed.iter() { error.span_note( *span, - &format!("use of {} here does not actually short circuit due to \ - the const evaluator presently not being able to do control flow. \ - See https://github.com/rust-lang/rust/issues/49146 for more \ - information.", kind), + &format!( + "use of {} here does not actually short circuit due to \ + the const evaluator presently not being able to do control flow. \ + see for more \ + information.", + kind + ), ); } for local in locals { @@ -1567,7 +1567,7 @@ impl MirPass for QualifyAndPromoteConstants { } } - // Statics must be Sync. + // Statics must be `Sync`. if mode == Mode::Static { // `#[thread_local]` statics don't have to be `Sync`. for attr in &tcx.get_attrs(def_id)[..] { diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 40e02e712c156..e44cb61f6fb8d 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -88,7 +88,7 @@ pub fn sanity_check_via_rustc_peek<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: ast::NodeId, _attributes: &[ast::Attribute], results: &DataflowResults<'tcx, O>) - where O: BitDenotation<'tcx, Idx=MovePathIndex> + HasMoveData<'tcx> + where O: BitDenotation<'tcx, Idx = MovePathIndex> + HasMoveData<'tcx> { debug!("sanity_check_via_rustc_peek id: {:?}", id); // FIXME: this is not DRY. Figure out way to abstract this and @@ -104,7 +104,7 @@ fn each_block<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, results: &DataflowResults<'tcx, O>, bb: mir::BasicBlock) where - O: BitDenotation<'tcx, Idx=MovePathIndex> + HasMoveData<'tcx> + O: BitDenotation<'tcx, Idx = MovePathIndex> + HasMoveData<'tcx> { let move_data = results.0.operator.move_data(); let mir::BasicBlockData { ref statements, ref terminator, is_cleanup: _ } = mir[bb]; @@ -134,7 +134,7 @@ fn each_block<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut kill_set = results.0.sets.kill_set_for(bb.index()).clone(); // Emulate effect of all statements in the block up to (but not - // including) the borrow within `peek_arg_place`. Do *not* include + // including) the borrow within `peek_arg_place`. Do **not** include // call to `peek_arg_place` itself (since we are peeking the state // of the argument at time immediate preceding Call to // `rustc_peek`). diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index 14e7895af0419..3e3e07a883841 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -48,7 +48,7 @@ pub fn simplify_cfg(mir: &mut Mir<'_>) { CfgSimplifier::new(mir).simplify(); remove_dead_blocks(mir); - // FIXME: Should probably be moved into some kind of pass manager + // FIXME: should probably be moved into some kind of pass manager mir.basic_blocks_mut().raw.shrink_to_fit(); } @@ -348,7 +348,7 @@ impl<'tcx> Visitor<'tcx> for DeclMarker { fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) { // Ignore storage markers altogether, they get removed along with their otherwise unused // decls. - // FIXME: Extend this to all non-uses. + // FIXME: extend this to all non-uses. if !ctx.is_storage_marker() { self.locals.insert(*local); } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index bf5514c5335f0..8abda9ec22dfd 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -1,4 +1,4 @@ -// Validate AST before lowering it to HIR +// Validate AST before lowering it to HIR. // // This pass is supposed to catch things that fit into AST data structures, // but not permitted by the language. It runs after expansion when AST is frozen, @@ -7,34 +7,35 @@ // or type checking or some other kind of complex analysis. use std::mem; -use syntax::print::pprust; -use rustc::lint; -use rustc::session::Session; -use rustc_data_structures::fx::FxHashMap; + +use errors::Applicability; +use log::debug; +use syntax_ext::proc_macro_decls::is_proc_macro_attr; +use syntax_pos::Span; +use syntax::{span_err, struct_span_err, walk_list}; use syntax::ast::*; use syntax::attr; +use syntax::print::pprust; +use syntax::ptr::P; use syntax::source_map::Spanned; use syntax::symbol::keywords; -use syntax::ptr::P; use syntax::visit::{self, Visitor}; -use syntax::{span_err, struct_span_err, walk_list}; -use syntax_ext::proc_macro_decls::is_proc_macro_attr; -use syntax_pos::Span; -use errors::Applicability; -use log::debug; +use rustc_data_structures::fx::FxHashMap; +use rustc::lint; +use rustc::session::Session; struct AstValidator<'a> { session: &'a Session, has_proc_macro_decls: bool, has_global_allocator: bool, - // Used to ban nested `impl Trait`, e.g., `impl Into`. - // Nested `impl Trait` _is_ allowed in associated type position, - // e.g `impl Iterator` + // Used to ban nested `impl Trait` (e.g., `impl Into`). + // Nested `impl Trait` _is_ allowed in associated type position + // (e.g., `impl Iterator`). outer_impl_trait: Option, - // Used to ban `impl Trait` in path projections like `::Item` - // or `Foo::Bar` + // Used to ban `impl Trait` in path projections (e.g., `::Item` + // or `Foo::Bar`). is_impl_trait_banned: bool, } @@ -51,7 +52,7 @@ impl<'a> AstValidator<'a> { self.outer_impl_trait = old; } - // Mirrors visit::walk_ty, but tracks relevant state + // Mirrors `visit::walk_ty`, but tracks relevant state. fn walk_ty(&mut self, t: &'a Ty) { match t.node { TyKind::ImplTrait(..) => { @@ -59,28 +60,28 @@ impl<'a> AstValidator<'a> { } TyKind::Path(ref qself, ref path) => { // We allow these: - // - `Option` - // - `option::Option` - // - `option::Option::Foo + // - `Option`, + // - `option::Option`, + // - `option::Option::Foo`, // - // But not these: - // - `::Foo` - // - `option::Option::Foo`. + // but not these: + // - `::Foo`, + // - `option::Option::Foo`. // // To implement this, we disallow `impl Trait` from `qself` // (for cases like `::Foo>`) // but we allow `impl Trait` in `GenericArgs` - // iff there are no more PathSegments. + // iff there are no more `PathSegment`s. if let Some(ref qself) = *qself { - // `impl Trait` in `qself` is always illegal + // `impl Trait` in `qself` is always illegal. self.with_banned_impl_trait(|this| this.visit_ty(&qself.ty)); } // Note that there should be a call to visit_path here, // so if any logic is added to process `Path`s a call to it should be - // added both in visit_path and here. This code mirrors visit::walk_path. + // added both in `visit_path` and here. This code mirrors `visit::walk_path`. for (i, segment) in path.segments.iter().enumerate() { - // Allow `impl Trait` iff we're on the final path segment + // Allow `impl Trait` iff we're on the final path segment. if i == path.segments.len() - 1 { self.visit_path_segment(path.span, segment); } else { @@ -593,7 +594,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_foreign_item(self, fi) } - // Mirrors visit::walk_generic_args, but tracks relevant state + // Mirrors `visit::walk_generic_args`, but tracks relevant state. fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) { match *generic_args { GenericArgs::AngleBracketed(ref data) => { @@ -605,7 +606,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { GenericArg::Const(..) => ParamKindOrd::Const, }, arg.span(), None) }), GenericPosition::Arg, generic_args.span()); - // Type bindings such as `Item=impl Debug` in `Iterator` + // Type bindings such as `Item = impl Debug` in `Iterator` // are allowed to contain nested `impl Trait`. self.with_impl_trait(None, |this| { walk_list!(this, visit_assoc_type_binding, &data.bindings); @@ -653,7 +654,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { if let WherePredicate::EqPredicate(ref predicate) = *predicate { self.err_handler() .span_err(predicate.span, "equality constraints are not yet \ - supported in where clauses (see #20041)"); + supported in where-clauses (see #20041)"); } } @@ -684,7 +685,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { fn visit_where_predicate(&mut self, p: &'a WherePredicate) { if let &WherePredicate::BoundPredicate(ref bound_predicate) = p { - // A type binding, eg `for<'c> Foo: Send+Clone+'c` + // A type binding (e.g., `for<'c> Foo: Send + Clone + 'c`). self.check_late_bound_lifetime_defs(&bound_predicate.bound_generic_params); } visit::walk_where_predicate(self, p); @@ -696,8 +697,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } fn visit_mac(&mut self, mac: &Spanned) { - // when a new macro kind is added but the author forgets to set it up for expansion - // because that's the only part that won't cause a compiler error + // When a new macro kind is added but the author forgets to set it up for expansion + // because that's the only part that won't cause a compiler error. self.session.diagnostic() .span_bug(mac.span, "macro invocation missed in expansion; did you forget to override \ the relevant `fold_*()` method in `PlaceholderExpander`?"); diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 20f31b3ebc173..63c090feb791f 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -54,7 +54,7 @@ fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, assert!(def_id.is_local()); let node_id = tcx.hir().as_local_node_id(def_id) - .expect("rvalue_promotable_map invoked with non-local def-id"); + .expect("rvalue_promotable_map invoked with non-local `DefId`"); let body_id = tcx.hir().body_owned_by(node_id); tcx.rvalue_promotable_map(def_id).contains(&body_id.hir_id.local_id) } @@ -81,7 +81,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // `def_id` should be a `Body` owner let node_id = tcx.hir().as_local_node_id(def_id) - .expect("rvalue_promotable_map invoked with non-local def-id"); + .expect("rvalue_promotable_map invoked with non-local `DefId`"); let body_id = tcx.hir().body_owned_by(node_id); let _ = visitor.check_nested_body(body_id); @@ -135,7 +135,7 @@ impl BitOr for Promotability { } impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { - // Returns true iff all the values of the type are promotable. + // Returns whetherf all the values of the type are promotable. fn type_promotability(&mut self, ty: Ty<'gcx>) -> Promotability { debug!("type_promotability({})", ty); diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index c1ba4d7b3d867..406ab7a34b040 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -63,7 +63,6 @@ fn plugin_registrar_fn<'tcx>( } } - pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { plugin_registrar_fn, diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 91651ad29dfa4..9f1ea92993ab1 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -29,8 +29,10 @@ use syntax::attr; use syntax::symbol::keywords; use syntax_pos::Span; -use std::{cmp, fmt, mem}; +use std::cmp; +use std::fmt; use std::marker::PhantomData; +use std::mem; mod diagnostics; @@ -192,7 +194,7 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V> // Skip repeated `Opaque`s to avoid infinite recursion. if self.visited_opaque_tys.insert(def_id) { // The intent is to treat `impl Trait1 + Trait2` identically to - // `dyn Trait1 + Trait2`. Therefore we ignore def-id of the opaque type itself + // `dyn Trait1 + Trait2`. Therefore, we ignore `DefId` of the opaque type itself // (it either has no visibility, or its visibility is insignificant, like // visibilities of type aliases) and recurse into predicates instead to go // through the trait list (default type visitor doesn't visit those traits). @@ -203,8 +205,8 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V> } } } - // These types don't have their own def-ids (but may have subcomponents - // with def-ids that should be visited recursively). + // These types don't have their own `DefId`s (but may have subcomponents + // with `DefId`s that should be visited recursively). ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Str | ty::Never | ty::Array(..) | ty::Slice(..) | ty::Tuple(..) | @@ -346,7 +348,7 @@ trait VisibilityLike: Sized { const SHALLOW: bool = false; fn new_min<'a, 'tcx>(find: &FindMin<'a, 'tcx, Self>, def_id: DefId) -> Self; - // Returns an over-approximation (`skip_assoc_tys` = true) of visibility due to + // Returns an over-approximation (`skip_assoc_tys = true`) of visibility due to // associated types for which we can't determine visibility precisely. fn of_impl<'a, 'tcx>(node_id: ast::NodeId, tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &'a AccessLevels) -> Self { @@ -369,7 +371,7 @@ impl VisibilityLike for Option { const MAX: Self = Some(AccessLevel::Public); // Type inference is very smart sometimes. // It can make an impl reachable even some components of its type or trait are unreachable. - // E.g. methods of `impl ReachableTrait for ReachableTy { ... }` + // E.g., methods of `impl ReachableTrait for ReachableTy { ... }` // can be usable from other crates (#57264). So we skip substs when calculating reachability // and consider an impl reachable if its "shallow" type and trait are reachable. // @@ -931,7 +933,7 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> { def_id_visibility(self.tcx, did).0.is_accessible_from(self.current_item, self.tcx) } - // Take node-id of an expression or pattern and check its type for privacy. + // Take `NodeId` of an expression or pattern and check its type for privacy. fn check_expr_pat_type(&mut self, id: hir::HirId, span: Span) -> bool { self.span = span; if self.visit(self.tables.node_type(id)) || self.visit(self.tables.node_substs(id)) { @@ -986,7 +988,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { } } else { // Types in signatures. - // FIXME: This is very ineffective. Ideally each HIR type should be converted + // FIXME: this is very ineffective. Ideally, each HIR type should be converted // into a semantic type only once and the result should be cached somehow. if self.visit(rustc_typeck::hir_ty_to_ty(self.tcx, hir_ty)) { return; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index a82f8df154725..65e4fb522d445 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -3,32 +3,23 @@ //! Here we build the "reduced graph": the graph of the module tree without //! any imports resolved. -use crate::macros::{InvocationData, ParentScope, LegacyScope}; -use crate::resolve_imports::ImportDirective; -use crate::resolve_imports::ImportDirectiveSubclass::{self, GlobImport, SingleImport}; -use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; -use crate::{ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas, ExternPreludeEntry}; -use crate::Namespace::{self, TypeNS, ValueNS, MacroNS}; -use crate::{resolve_error, resolve_struct_error, ResolutionError}; +use std::cell::Cell; +use std::ptr; +use errors::Applicability; +use log::debug; +use rustc_data_structures::sync::Lrc; +use rustc_metadata::cstore::LoadedMacro; use rustc::bug; use rustc::hir::def::*; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; -use rustc::ty; use rustc::middle::cstore::CrateStore; -use rustc_metadata::cstore::LoadedMacro; - -use std::cell::Cell; -use std::ptr; -use rustc_data_structures::sync::Lrc; - -use errors::Applicability; - +use rustc::ty; +use syntax_pos::{Span, DUMMY_SP}; use syntax::ast::{Name, Ident}; -use syntax::attr; - use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; use syntax::ast::{MetaItemKind, Mutability, StmtKind, TraitItem, TraitItemKind, Variant}; +use syntax::attr; use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::base::Determinacy::Undetermined; use syntax::ext::hygiene::Mark; @@ -40,9 +31,13 @@ use syntax::std_inject::injected_crate_name; use syntax::symbol::keywords; use syntax::visit::{self, Visitor}; -use syntax_pos::{Span, DUMMY_SP}; - -use log::debug; +use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; +use crate::{ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas, ExternPreludeEntry}; +use crate::Namespace::{self, TypeNS, ValueNS, MacroNS}; +use crate::{resolve_error, resolve_struct_error, ResolutionError}; +use crate::macros::{InvocationData, ParentScope, LegacyScope}; +use crate::resolve_imports::ImportDirective; +use crate::resolve_imports::ImportDirectiveSubclass::{self, GlobImport, SingleImport}; impl<'a> ToNameBinding<'a> for (Module<'a>, ty::Visibility, Span, Mark) { fn to_name_binding(self, arenas: &'a ResolverArenas<'a>) -> &'a NameBinding<'a> { @@ -110,12 +105,12 @@ impl<'a> Resolver<'a> { fn build_reduced_graph_for_use_tree( &mut self, - // This particular use tree + // This particular `use` tree. use_tree: &ast::UseTree, id: NodeId, parent_prefix: &[Segment], nested: bool, - // The whole `use` item + // The whole `use` item. parent_scope: ParentScope<'a>, item: &Item, vis: ty::Visibility, @@ -127,7 +122,7 @@ impl<'a> Resolver<'a> { let mut prefix_iter = parent_prefix.iter().cloned() .chain(use_tree.prefix.segments.iter().map(|seg| seg.into())).peekable(); - // On 2015 edition imports are resolved as crate-relative by default, + // On 2015 edition, imports are resolved as crate-relative by default, // so prefixes are prepended with crate root segment if necessary. // The root is prepended lazily, when the first non-empty prefix or terminating glob // appears, so imports in braced groups can have roots prepended independently. @@ -162,7 +157,7 @@ impl<'a> Resolver<'a> { let mut type_ns_only = false; if nested { - // Correctly handle `self` + // Correctly handle `self`. if source.ident.name == keywords::SelfLower.name() { type_ns_only = true; @@ -176,14 +171,14 @@ impl<'a> Resolver<'a> { return; } - // Replace `use foo::self;` with `use foo;` + // Replace `use foo::self;` with `use foo;`. source = module_path.pop().unwrap(); if rename.is_none() { ident = source.ident; } } } else { - // Disallow `self` + // Disallow `self`. if source.ident.name == keywords::SelfLower.name() { resolve_error(self, use_tree.span, @@ -197,7 +192,7 @@ impl<'a> Resolver<'a> { ModuleKind::Def(_, name) => name, ModuleKind::Block(..) => unreachable!(), }; - // HACK(eddyb) unclear how good this is, but keeping `$crate` + // HACK(eddyb): unclear how good this is, but keeping `$crate` // in `source` breaks `src/test/compile-fail/import-crate-var.rs`, // while the current crate doesn't have a valid `crate_name`. if crate_name != keywords::Invalid.name() { @@ -274,7 +269,7 @@ impl<'a> Resolver<'a> { ); } ast::UseTreeKind::Nested(ref items) => { - // Ensure there is at most one `self` in the list + // Ensure there is at most one `self` in the list. let self_spans = items.iter().filter_map(|&(ref use_tree, _)| { if let ast::UseTreeKind::Simple(..) = use_tree.kind { if use_tree.ident().name == keywords::SelfLower.name() { @@ -298,9 +293,9 @@ impl<'a> Resolver<'a> { for &(ref tree, id) in items { self.build_reduced_graph_for_use_tree( - // This particular use tree + // This particular `use` tree. tree, id, &prefix, true, - // The whole `use` item + // The whole `use` item. parent_scope.clone(), item, vis, root_span, ); } @@ -322,9 +317,9 @@ impl<'a> Resolver<'a> { span: use_tree.span, }; self.build_reduced_graph_for_use_tree( - // This particular use tree + // This particular `use` tree. &tree, id, &prefix, true, - // The whole `use` item + // The whole `use` item. parent_scope, item, ty::Visibility::Invisible, root_span, ); } @@ -343,9 +338,9 @@ impl<'a> Resolver<'a> { match item.node { ItemKind::Use(ref use_tree) => { self.build_reduced_graph_for_use_tree( - // This particular use tree + // This particular `use` tree. use_tree, item.id, &[], false, - // The whole `use` item + // The whole `use` item. parent_scope, item, vis, use_tree.span, ); } @@ -421,7 +416,8 @@ impl<'a> Resolver<'a> { ItemKind::GlobalAsm(..) => {} - ItemKind::Mod(..) if ident == keywords::Invalid.ident() => {} // Crate root + // Crate root. + ItemKind::Mod(..) if ident == keywords::Invalid.ident() => {} ItemKind::Mod(..) => { let def_id = self.definitions.local_def_id(item.id); @@ -628,19 +624,21 @@ impl<'a> Resolver<'a> { expansion, block.span); self.block_map.insert(block.id, module); - self.current_module = module; // Descend into the block. + // Descend into the block. + self.current_module = module; } } /// Builds the reduced graph for a single item in an external crate. fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'a>, child: Export) { let Export { ident, def, vis, span } = child; - // FIXME: We shouldn't create the gensym here, it should come from metadata, + // FIXME: we shouldn't create the gensym here, it should come from metadata, // but metadata cannot encode gensyms currently, so we create it here. // This is only a guess, two equivalent idents may incorrectly get different gensyms here. let ident = ident.gensym_if_underscore(); let def_id = def.def_id(); - let expansion = Mark::root(); // FIXME(jseyfried) intercrate hygiene + // FIXME(jseyfried): inter-crate hygiene. + let expansion = Mark::root(); match def { Def::Mod(..) | Def::Enum(..) => { let module = self.new_module(parent, @@ -880,10 +878,10 @@ impl<'a> Resolver<'a> { fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool { for attr in attrs { if attr.check_name("macro_escape") { - let msg = "macro_escape is a deprecated synonym for macro_use"; + let msg = "`macro_escape` is a deprecated synonym for `macro_use`"; let mut err = self.session.struct_span_warn(attr.span, msg); if let ast::AttrStyle::Inner = attr.style { - err.help("consider an outer attribute, #[macro_use] mod ...").emit(); + err.help("consider an outer attribute, `#[macro_use] mod ...`").emit(); } else { err.emit(); } @@ -892,7 +890,7 @@ impl<'a> Resolver<'a> { } if !attr.is_word() { - self.session.span_err(attr.span, "arguments to macro_use are not allowed here"); + self.session.span_err(attr.span, "arguments to `macro_use` are not allowed here"); } return true; } @@ -1012,13 +1010,15 @@ impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> { (Def::Method(item_def_id), ValueNS) } TraitItemKind::Type(..) => (Def::AssociatedTy(item_def_id), TypeNS), - TraitItemKind::Macro(_) => bug!(), // handled above + // Handled above. + TraitItemKind::Macro(_) => bug!(), }; let vis = ty::Visibility::Public; self.resolver.define(parent, item.ident, ns, (def, vis, item.span, self.expansion)); - self.resolver.current_module = parent.parent.unwrap(); // nearest normal ancestor + // Nearest normal ancestor. + self.resolver.current_module = parent.parent.unwrap(); visit::walk_trait_item(self, item); self.resolver.current_module = parent; } @@ -1039,7 +1039,7 @@ impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> { module: self.resolver.current_module.nearest_item_scope(), expansion: self.expansion, legacy: self.current_legacy_scope, - // Let's hope discerning built-in attributes from derive helpers is not necessary + // Let's hope discerning built-in attributes from derive helpers is not necessary. derives: Vec::new(), }; parent_scope.module.builtin_attrs.borrow_mut().push(( diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 3b6179f78558b..4342cdafe3bb3 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -1,5 +1,4 @@ -// -// Unused import checking +// Checks for unused imports. // // Although this is mostly a lint pass, it lives in here because it depends on // resolve data structures and because it finalises the privacy information for @@ -25,15 +24,15 @@ use std::ops::{Deref, DerefMut}; -use crate::Resolver; -use crate::resolve_imports::ImportDirectiveSubclass; - +use rustc_data_structures::fx::FxHashSet; use rustc::util::nodemap::NodeMap; use rustc::{lint, ty}; -use rustc_data_structures::fx::FxHashSet; +use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use syntax::ast; use syntax::visit::{self, Visitor}; -use syntax_pos::{Span, MultiSpan, DUMMY_SP}; + +use crate::Resolver; +use crate::resolve_imports::ImportDirectiveSubclass; struct UnusedImport<'a> { use_tree: &'a ast::UseTree, diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 5c095994a1bbd..f6bbb8e8d005f 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -2,8 +2,8 @@ use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics}; -// Error messages for EXXXX errors. Each message should start and end with a -// new line, and be wrapped to 80 characters. In vim you can `:set tw=80` and +// Error messages for EXXXX errors. Each message should start and end with a +// new line, and be wrapped to 80 characters. In vim you can `:set tw=80` and // use `gq` to wrap paragraphs. Use `:set tw=0` to disable. register_long_diagnostics! { @@ -12,7 +12,7 @@ Type parameter defaults can only use parameters that occur before them. Erroneous code example: ```compile_fail,E0128 -struct Foo { +struct Foo { field1: T, filed2: U, } @@ -24,7 +24,7 @@ Since type parameters are evaluated in-order, you may be able to fix this issue by doing: ``` -struct Foo { +struct Foo { field1: T, filed2: U, } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index fbed1145cd156..c145444ebbffd 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -10,69 +10,63 @@ #![deny(rust_2018_idioms)] -pub use rustc::hir::def::{Namespace, PerNS}; +// N.B., this module needs to be declared first so diagnostics are +// registered before they are used. +mod diagnostics; +mod error_reporting; +mod macros; +mod check_unused; +mod build_reduced_graph; +mod resolve_imports; -use GenericParameters::*; -use RibKind::*; +use std::{cmp, fmt, iter, mem, ptr}; +use std::cell::{Cell, RefCell}; +use std::collections::BTreeSet; +use std::mem::replace; +use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use log::debug; +use rustc_data_structures::ptr_key::PtrKey; +use rustc_data_structures::sync::Lrc; +use rustc_metadata::creader::CrateLoader; +use rustc_metadata::cstore::CStore; +use rustc::{bug, span_bug}; +pub use rustc::hir::def::{Namespace, PerNS}; use rustc::hir::map::{Definitions, DefCollector}; use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str}; -use rustc::middle::cstore::CrateStore; -use rustc::session::Session; -use rustc::lint; use rustc::hir::def::*; use rustc::hir::def::Namespace::*; use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap}; +use rustc::lint; +use rustc::middle::cstore::CrateStore; +use rustc::session::Session; use rustc::ty::{self, DefIdTree}; use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap}; -use rustc::{bug, span_bug}; - -use rustc_metadata::creader::CrateLoader; -use rustc_metadata::cstore::CStore; - -use syntax::source_map::SourceMap; -use syntax::ext::hygiene::{Mark, Transparency, SyntaxContext}; -use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy}; -use syntax::ext::base::SyntaxExtension; -use syntax::ext::base::Determinacy::{self, Determined, Undetermined}; -use syntax::ext::base::MacroKind; -use syntax::symbol::{Symbol, keywords}; +use syntax_pos::{BytePos, Span, DUMMY_SP, MultiSpan}; +use syntax::{span_err, struct_span_err, unwrap_or, walk_list}; use syntax::util::lev_distance::find_best_match_for_name; - use syntax::visit::{self, FnKind, Visitor}; use syntax::attr; +use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy}; use syntax::ast::{CRATE_NODE_ID, Arm, IsAsync, BindingMode, Block, Crate, Expr, ExprKind}; use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, GenericParamKind, Generics}; use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind}; use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path}; use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind}; +use syntax::ext::base::Determinacy::{self, Determined, Undetermined}; +use syntax::ext::base::MacroKind; +use syntax::ext::base::SyntaxExtension; +use syntax::ext::hygiene::{Mark, Transparency, SyntaxContext}; use syntax::ptr::P; -use syntax::{span_err, struct_span_err, unwrap_or, walk_list}; - -use syntax_pos::{BytePos, Span, DUMMY_SP, MultiSpan}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; - -use log::debug; - -use std::cell::{Cell, RefCell}; -use std::{cmp, fmt, iter, mem, ptr}; -use std::collections::BTreeSet; -use std::mem::replace; -use rustc_data_structures::ptr_key::PtrKey; -use rustc_data_structures::sync::Lrc; - -use resolve_imports::{ImportDirective, ImportDirectiveSubclass, NameResolution, ImportResolver}; -use macros::{InvocationData, LegacyBinding, ParentScope}; +use syntax::source_map::SourceMap; +use syntax::symbol::{Symbol, keywords}; -// N.B., this module needs to be declared first so diagnostics are -// registered before they are used. -mod diagnostics; -mod error_reporting; -mod macros; -mod check_unused; -mod build_reduced_graph; -mod resolve_imports; +use crate::resolve_imports::{NameResolution, ImportDirective, ImportDirectiveSubclass, + ImportResolver}; +use crate::macros::{InvocationData, LegacyBinding, ParentScope}; +use self::GenericParameters::*; +use self::RibKind::*; fn is_known_tool(name: Name) -> bool { ["clippy", "rustfmt"].contains(&&*name.as_str()) @@ -243,7 +237,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>, // a local type or const parameter. let sugg_msg = &format!("try using a local generic parameter instead"); if let Some((sugg_span, new_snippet)) = cm.generate_local_type_param_snippet(span) { - // Suggest the modification to the user + // Suggest the modification to the user. err.span_suggestion( sugg_span, sugg_msg, @@ -491,7 +485,7 @@ enum PathSource<'a> { TupleStruct, // `m::A::B` in `::B::C`. TraitItem(Namespace), - // Path in `pub(path)` + // Path in `pub(path)`. Visibility, } @@ -537,8 +531,8 @@ impl<'a> PathSource<'a> { MacroNS => bug!("associated macro"), }, PathSource::Expr(parent) => match parent.map(|p| &p.node) { - // "function" here means "anything callable" rather than `Def::Fn`, - // this is not precise but usually more helpful than just "value". + // "Function" here means "anything callable" rather than `Def::Fn`; + // this is not precise, but usually more helpful than just "value". Some(&ExprKind::Call(..)) => "function", _ => "value", }, @@ -705,28 +699,28 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder { visit::walk_mod(self, module); return; } - // find a use statement + // Find a `use` statement. for item in &module.items { match item.node { ItemKind::Use(..) => { - // don't suggest placing a use before the prelude - // import or other generated ones + // Don't suggest placing a use before the prelude + // import or other generated ones. if item.span.ctxt().outer().expn_info().is_none() { self.span = Some(item.span.shrink_to_lo()); self.found_use = true; return; } }, - // don't place use before extern crate + // Don't place use before `extern crate` ... ItemKind::ExternCrate(_) => {} - // but place them before the first other item + // ... but do place them before the first other item. _ => if self.span.map_or(true, |span| item.span < span ) { if item.span.ctxt().outer().expn_info().is_none() { - // don't insert between attributes and an item + // Don't insert between attributes and an item. if item.attrs.is_empty() { self.span = Some(item.span.shrink_to_lo()); } else { - // find the first attribute on the item + // Find the first attribute on the item. for attr in &item.attrs { if self.span.map_or(true, |span| attr.span < span) { self.span = Some(attr.span.shrink_to_lo()); @@ -745,24 +739,30 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { fn visit_item(&mut self, item: &'tcx Item) { self.resolve_item(item); } + fn visit_arm(&mut self, arm: &'tcx Arm) { self.resolve_arm(arm); } + fn visit_block(&mut self, block: &'tcx Block) { self.resolve_block(block); } + fn visit_anon_const(&mut self, constant: &'tcx ast::AnonConst) { debug!("visit_anon_const {:?}", constant); self.with_constant_rib(|this| { visit::walk_anon_const(this, constant); }); } + fn visit_expr(&mut self, expr: &'tcx Expr) { self.resolve_expr(expr, None); } + fn visit_local(&mut self, local: &'tcx Local) { self.resolve_local(local); } + fn visit_ty(&mut self, ty: &'tcx Ty) { match ty.node { TyKind::Path(ref qself, ref path) => { @@ -778,13 +778,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { } visit::walk_ty(self, ty); } + fn visit_poly_trait_ref(&mut self, - tref: &'tcx ast::PolyTraitRef, + tr: &'tcx ast::PolyTraitRef, m: &'tcx ast::TraitBoundModifier) { - self.smart_resolve_path(tref.trait_ref.ref_id, None, - &tref.trait_ref.path, PathSource::Trait(AliasPossibility::Maybe)); - visit::walk_poly_trait_ref(self, tref, m); + self.smart_resolve_path(tr.trait_ref.ref_id, None, + &tr.trait_ref.path, PathSource::Trait(AliasPossibility::Maybe)); + visit::walk_poly_trait_ref(self, tr, m); } + fn visit_foreign_item(&mut self, foreign_item: &'tcx ForeignItem) { let generic_params = match foreign_item.node { ForeignItemKind::Fn(_, ref generics) => { @@ -798,6 +800,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { visit::walk_foreign_item(this, foreign_item); }); } + fn visit_fn(&mut self, function_kind: FnKind<'tcx>, declaration: &'tcx FnDecl, @@ -812,7 +815,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { (TraitOrImplItemRibKind, sig.header.asyncness), FnKind::Closure(_) => // Async closures aren't resolved through `visit_fn`-- they're - // processed separately + // processed separately. (ClosureRibKind(node_id), IsAsync::NotAsync), }; @@ -833,7 +836,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { } visit::walk_fn_ret_ty(self, &declaration.output); - // Resolve the function body, potentially inside the body of an async closure + // Resolve the function body, potentially inside the body of an async closure. if let IsAsync::Async { closure_id, .. } = asyncness { let rib_kind = ClosureRibKind(closure_id); self.ribs[ValueNS].push(Rib::new(rib_kind)); @@ -919,11 +922,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { #[derive(Copy, Clone)] enum GenericParameters<'a, 'b> { NoGenericParams, - HasGenericParams(// Type parameters. - &'b Generics, - - // The kind of the rib used for type parameters. - RibKind<'a>), + HasGenericParams( + // Type parameters. + &'b Generics, + // The kind of the rib used for type parameters. + RibKind<'a>, + ), } /// The rib kind controls the translation of local @@ -1083,7 +1087,7 @@ pub struct ModuleData<'a> { parent: Option>, kind: ModuleKind, - // The def id of the closest normal module (`mod`) ancestor (including this module). + // The `DefId` of the closest normal module (`mod`) ancestor (including this module). normal_ancestor_id: DefId, resolutions: RefCell>>>, @@ -1343,7 +1347,7 @@ impl<'a> NameBinding<'a> { } } - // We sometimes need to treat variants as `pub` for backwards compatibility + // We sometimes need to treat variants as `pub` for backwards compatibility. fn pseudo_vis(&self) -> ty::Visibility { if self.is_variant() && self.def().def_id().is_local() { ty::Visibility::Public @@ -1423,9 +1427,9 @@ impl<'a> NameBinding<'a> { // Then this function returns `true` if `self` may emerge from a macro *after* that // in some later round and screw up our previously found resolution. // See more detailed explanation in - // https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049 + // . fn may_appear_after(&self, invoc_parent_expansion: Mark, binding: &NameBinding<'_>) -> bool { - // self > max(invoc, binding) => !(self <= invoc || self <= binding) + // `self > max(invoc, binding) => !(self <= invoc || self <= binding)` // Expansions are partially ordered, so "may appear after" is an inversion of // "certainly appears before or simultaneously" and includes unordered cases. let self_parent_expansion = self.expansion; @@ -1513,7 +1517,8 @@ pub struct Resolver<'a> { current_module: Module<'a>, /// The current set of local scopes for types and values. - /// FIXME #4948: Reuse ribs to avoid allocation. + // + // FIXME(#4948): reuse ribs to avoid allocation. ribs: PerNS>>, /// The current set of local scopes, for labels. @@ -1528,9 +1533,10 @@ pub struct Resolver<'a> { /// The current self item if inside an ADT (used for better errors). current_self_item: Option, - /// FIXME: Refactor things so that these fields are passed through arguments and not resolver. - /// We are resolving a last import segment during import validation. + // FIXME: refactor things so that these fields are passed through arguments and not resolver. + // We are resolving a last import segment during import validation. last_import_segment: bool, + /// This binding should be ignored during in-module resolution, so that we don't get /// "self-confirming" import resolutions during import validation. blacklisted_binding: Option<&'a NameBinding<'a>>, @@ -1855,8 +1861,7 @@ impl<'a> Resolver<'a> { definitions, - // The outermost module has def ID 0; this is not reflected in the - // AST. + // The outermost module has `DefId` `0`; this is not reflected in the AST. graph_root, prelude: None, extern_prelude, @@ -2038,12 +2043,12 @@ impl<'a> Resolver<'a> { record_used_id: Option, path_span: Span) -> Option> { - assert!(ns == TypeNS || ns == ValueNS); + assert!(ns == TypeNS || ns == ValueNS); if ident.name == keywords::Invalid.name() { return Some(LexicalScopeBinding::Def(Def::Err)); } ident.span = if ident.name == keywords::SelfUpper.name() { - // FIXME(jseyfried) improve `Self` hygiene + // FIXME(jseyfried): improve `Self` hygiene ident.span.with_ctxt(SyntaxContext::empty()) } else if ns == TypeNS { ident.span.modern() @@ -2087,7 +2092,8 @@ impl<'a> Resolver<'a> { } match module.kind { - ModuleKind::Block(..) => {}, // We can see through blocks + // We can see through blocks. + ModuleKind::Block(..) => {}, _ => break, } } @@ -2103,7 +2109,8 @@ impl<'a> Resolver<'a> { }; module = unwrap_or!(opt_module, break); let orig_current_module = self.current_module; - self.current_module = module; // Lexical resolutions can never be a privacy error. + // Lexical resolutions can never be a privacy error. + self.current_module = module; let result = self.resolve_ident_in_module_unadjusted( ModuleOrUniformRoot::Module(module), ident, @@ -2180,7 +2187,7 @@ impl<'a> Resolver<'a> { return module; } - // We need to support the next case under a deprecation warning + // We need to support the next case under a deprecation warning. // ``` // struct MyStruct; // ---- begin: this comes from a proc macro derive @@ -2195,7 +2202,7 @@ impl<'a> Resolver<'a> { // Inner module is inside the macro, parent module is outside of the macro. if module.expansion != parent.expansion && module.expansion.is_descendant_of(parent.expansion) { - // The macro is a proc macro derive + // The macro is a proc macro derive. if module.expansion.looks_like_proc_macro_derive() { if parent.expansion.is_descendant_of(span.ctxt().outer()) { *poisoned = Some(node_id); @@ -2261,7 +2268,7 @@ impl<'a> Resolver<'a> { // When resolving `$crate` from a `macro_rules!` invoked in a `macro`, // we don't want to pretend that the `macro_rules!` definition is in the `macro` // as described in `SyntaxContext::apply_mark`, so we ignore prepended modern marks. - // FIXME: This is only a guess and it doesn't work correctly for `macro_rules!` + // FIXME: this is only a guess and it doesn't work correctly for `macro_rules!` // definitions actually produced by `macro` and `macro` definitions produced by // `macro_rules!`, but at least such configurations are not stable yet. ctxt = ctxt.modern_and_legacy(); @@ -2305,7 +2312,7 @@ impl<'a> Resolver<'a> { module } - // AST resolution + // # AST resolution // // We maintain a list of value ribs and type ribs. // @@ -2364,7 +2371,7 @@ impl<'a> Resolver<'a> { } } _ => { - // Do not resolve labels across function boundary + // Do not resolve labels across function boundary. return None; } } @@ -2472,7 +2479,7 @@ impl<'a> Resolver<'a> { this.visit_ty(ty); // Only impose the restrictions of - // ConstRibKind for an actual constant + // `ConstRibKind` for an actual constant // expression in a provided default. if let Some(ref expr) = *default{ this.with_constant_rib(|this| { @@ -2530,7 +2537,7 @@ impl<'a> Resolver<'a> { ItemKind::ExternCrate(..) | ItemKind::MacroDef(..) | ItemKind::GlobalAsm(..) => { - // do nothing, these are just around to be encoded + // Do nothing; these are just around to be encoded. } ItemKind::Mac(_) => panic!("unexpanded macro in resolve!"), @@ -2637,7 +2644,7 @@ impl<'a> Resolver<'a> { fn with_current_self_type(&mut self, self_type: &Ty, f: F) -> T where F: FnOnce(&mut Resolver<'_>) -> T { - // Handle nested impls (inside fn bodies) + // Handle nested impls (inside fn bodies). let previous_value = replace(&mut self.current_self_type, Some(self_type.clone())); let result = f(self); self.current_self_type = previous_value; @@ -2696,7 +2703,7 @@ impl<'a> Resolver<'a> { { let mut self_type_rib = Rib::new(NormalRibKind); - // plain insert (no renaming, types are not currently hygienic....) + // Plain insert (no renaming, since types are not currently hygienic). self_type_rib.bindings.insert(keywords::SelfUpper.ident(), self_def); self.ribs[TypeNS].push(self_type_rib); f(self); @@ -2755,7 +2762,7 @@ impl<'a> Resolver<'a> { "resolve_implementation ImplItemKind::Const", ); // If this is a trait impl, ensure the const - // exists in trait + // exists in trait. this.check_trait_item( impl_item.ident, ValueNS, @@ -2769,7 +2776,7 @@ impl<'a> Resolver<'a> { } ImplItemKind::Method(..) => { // If this is a trait impl, ensure the method - // exists in trait + // exists in trait. this.check_trait_item(impl_item.ident, ValueNS, impl_item.span, @@ -2789,7 +2796,7 @@ impl<'a> Resolver<'a> { } ImplItemKind::Existential(ref bounds) => { // If this is a trait impl, ensure the type - // exists in trait + // exists in trait. this.check_trait_item(impl_item.ident, TypeNS, impl_item.span, @@ -2815,7 +2822,7 @@ impl<'a> Resolver<'a> { fn check_trait_item(&mut self, ident: Ident, ns: Namespace, span: Span, err: F) where F: FnOnce(Name, &str) -> ResolutionError<'_> { - // If there is a TraitRef in scope for an impl, then the method must be in the + // If there is a `TraitRef` in scope for an impl, then the method must be in the // trait. if let Some((module, _)) = self.current_trait_ref { if self.resolve_ident_in_module( @@ -2843,7 +2850,7 @@ impl<'a> Resolver<'a> { self.resolve_pattern(&local.pat, PatternSource::Let, &mut FxHashMap::default()); } - // build a map from pattern identifiers to binding-info's. + // Build a map from pattern identifiers to binding-info's. // this is done hygienically. This could arise for a macro // that expands into an or-pattern where one 'x' was from the // user and one 'x' came from the macro. @@ -2866,7 +2873,7 @@ impl<'a> Resolver<'a> { binding_map } - // check that all of the arms in an or-pattern have exactly the + // Check that all of the arms in an or-pattern have exactly the // same set of bindings, with the same binding modes for each. fn check_consistent_bindings(&mut self, pats: &[P]) { if pats.is_empty() { @@ -2885,8 +2892,9 @@ impl<'a> Resolver<'a> { let map_j = self.binding_mode_map(&q); for (&key, &binding_i) in &map_i { - if map_j.is_empty() { // Account for missing bindings when - let binding_error = missing_vars // map_j has none. + // Account for missing bindings when `map_j` has none. + if map_j.is_empty() { + let binding_error = missing_vars .entry(key.name) .or_insert(BindingError { name: key.name, @@ -2898,7 +2906,8 @@ impl<'a> Resolver<'a> { } for (&key_j, &binding_j) in &map_j { match map_i.get(&key_j) { - None => { // missing binding + None => { + // Missing binding. let binding_error = missing_vars .entry(key_j.name) .or_insert(BindingError { @@ -2909,7 +2918,8 @@ impl<'a> Resolver<'a> { binding_error.origin.insert(binding_j.span); binding_error.target.insert(p.span); } - Some(binding_i) => { // check consistent binding + Some(binding_i) => { + // Check consistent binding. if binding_i.binding_mode != binding_j.binding_mode { inconsistent_vars .entry(key.name) @@ -2943,7 +2953,7 @@ impl<'a> Resolver<'a> { self.resolve_pattern(&pattern, PatternSource::Match, &mut bindings_list); } - // This has to happen *after* we determine which pat_idents are variants. + // This has to happen *after* we determine which `pat_idents` are variants. self.check_consistent_bindings(&arm.pats); if let Some(ast::Guard::If(ref expr)) = arm.guard { @@ -2958,7 +2968,8 @@ impl<'a> Resolver<'a> { debug!("(resolving block) entering block"); // Move down in the graph, if there's an anonymous module rooted here. let orig_module = self.current_module; - let anonymous_module = self.block_map.get(&block.id).cloned(); // clones a reference + // Clones a reference. + let anonymous_module = self.block_map.get(&block.id).cloned(); let mut num_macro_definition_ribs = 0; if let Some(anonymous_module) = anonymous_module { @@ -3014,7 +3025,7 @@ impl<'a> Resolver<'a> { let mut def = Def::Local(pat_id); match bindings.get(&ident).cloned() { Some(id) if id == outer_pat_id => { - // `Variant(a, a)`, error + // `Variant(a, a)`; error. resolve_error( self, ident.span, @@ -3023,7 +3034,7 @@ impl<'a> Resolver<'a> { ); } Some(..) if pat_src == PatternSource::FnParam => { - // `fn f(a: u8, a: u8)`, error + // `fn f(a: u8, a: u8)`; error. resolve_error( self, ident.span, @@ -3034,7 +3045,7 @@ impl<'a> Resolver<'a> { Some(..) if pat_src == PatternSource::Match || pat_src == PatternSource::IfLet || pat_src == PatternSource::WhileLet => { - // `Variant1(a) | Variant2(a)`, ok + // `Variant1(a) | Variant2(a)`; ok. // Reuse definition from the first `a`. def = self.ribs[ValueNS].last_mut().unwrap().bindings[&ident]; } @@ -3043,7 +3054,7 @@ impl<'a> Resolver<'a> { unexpected pattern source {:?}", pat_src); } None => { - // A completely fresh binding, add to the lists if it's valid. + // A completely fresh binding; add to the lists if it's valid. if ident.name != keywords::Invalid.name() { bindings.insert(ident, outer_pat_id); self.ribs[ValueNS].last_mut().unwrap().bindings.insert(ident, def); @@ -3057,7 +3068,7 @@ impl<'a> Resolver<'a> { fn resolve_pattern(&mut self, pat: &Pat, pat_src: PatternSource, - // Maps idents to the node ID for the + // Maps idents to the `NodeId` for the // outermost pattern that binds them. bindings: &mut FxHashMap) { // Visit all direct subpatterns of this pattern. @@ -3137,7 +3148,7 @@ impl<'a> Resolver<'a> { // High-level and context dependent path resolution routine. // Resolves the path and records the resolution into definition map. - // If resolution fails tries several techniques to find likely + // If resolution fails, then tries several techniques to find likely // resolution candidates, suggest imports or other help, and report // errors in user friendly way. fn smart_resolve_path(&mut self, @@ -3243,8 +3254,8 @@ impl<'a> Resolver<'a> { _ => report_errors(self, None) }; + // Avoid recording definition of `A::B` in `::B::C`. if let PathSource::TraitItem(..) = source {} else { - // Avoid recording definition of `A::B` in `::B::C`. self.record_def(id, resolution); } resolution @@ -3259,7 +3270,7 @@ impl<'a> Resolver<'a> { if let Some(sp) = self.current_type_ascription.last() { let mut sp = *sp; loop { - // Try to find the `:`; bail on first non-':' / non-whitespace. + // Try to find the `:`; bail on the first non-':' / non-whitespace. sp = cm.next_point(sp); if let Ok(snippet) = cm.span_to_snippet(sp.to(cm.next_point(sp))) { debug!("snippet {:?}", snippet); @@ -3301,7 +3312,7 @@ impl<'a> Resolver<'a> { if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false } } - // Resolve in alternative namespaces if resolution in the primary namespace fails. + // Resolves in alternative namespaces if resolution in the primary namespace fails. fn resolve_qpath_anywhere(&mut self, id: NodeId, qself: Option<&QSelf>, @@ -3318,7 +3329,7 @@ impl<'a> Resolver<'a> { for (i, ns) in [primary_ns, TypeNS, ValueNS, /*MacroNS*/].iter().cloned().enumerate() { if i == 0 || ns != primary_ns { match self.resolve_qpath(id, qself, path, ns, span, global_by_default, crate_lint) { - // If defer_to_typeck, then resolution > no resolution, + // If `defer_to_typeck`, then resolution > no resolution, // otherwise full resolution > partial resolution > no resolution. Some(res) if res.unresolved_segments() == 0 || defer_to_typeck => return Some(res), @@ -3332,7 +3343,7 @@ impl<'a> Resolver<'a> { .and_then(NameBinding::macro_kind) == Some(MacroKind::Bang) || self.macro_use_prelude.get(&path[0].ident.name).cloned() .and_then(NameBinding::macro_kind) == Some(MacroKind::Bang)) { - // Return some dummy definition, it's enough for error reporting. + // Return some dummy definition; it's enough for error reporting. return Some( PathResolution::new(Def::Macro(DefId::local(CRATE_DEF_INDEX), MacroKind::Bang)) ); @@ -3364,7 +3375,7 @@ impl<'a> Resolver<'a> { if let Some(qself) = qself { if qself.position == 0 { // This is a case like `::B`, where there is no - // trait to resolve. In that case, we leave the `B` + // trait to resolve. In that case, we leave the `B` // segment to be resolved by type-check. return Some(PathResolution::with_unresolved_segments( Def::Mod(DefId::local(CRATE_DEF_INDEX)), path.len() @@ -3374,7 +3385,7 @@ impl<'a> Resolver<'a> { // Make sure `A::B` in `::C` is a trait item. // // Currently, `path` names the full item (`A::B::C`, in - // our example). so we extract the prefix of that that is + // our example). so we extract the prefix of that that is // the trait (the slice upto and including // `qself.position`). And then we recursively resolve that, // but with `qself` set to `None`. @@ -3482,7 +3493,7 @@ impl<'a> Resolver<'a> { crate_lint: CrateLint, ) -> PathResult<'a> { // Macro and import paths must have full parent scope available during resolution, - // other paths will do okay with parent module alone. + // other paths will do ok with parent module alone. assert!(opt_ns != None && opt_ns != Some(MacroNS)); let parent_scope = ParentScope { module: self.current_module, ..self.dummy_parent_scope() }; self.resolve_path(path, opt_ns, &parent_scope, record_used, path_span, crate_lint) @@ -3566,14 +3577,14 @@ impl<'a> Resolver<'a> { } if name == keywords::PathRoot.name() && ident.span.rust_2015() && self.session.rust_2018() { - // `::a::b` from 2015 macro on 2018 global edition + // `::a::b` from 2015 macro on 2018 global edition. module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude); continue; } if name == keywords::PathRoot.name() || name == keywords::Crate.name() || name == keywords::DollarCrate.name() { - // `::a::b`, `crate::a::b` or `$crate::a::b` + // `::a::b`, `crate::a::b`, or `$crate::a::b`. module = Some(ModuleOrUniformRoot::Module( self.resolve_crate_root(ident))); continue; @@ -3607,9 +3618,9 @@ impl<'a> Resolver<'a> { let record_used_id = if record_used { crate_lint.node_id().or(Some(CRATE_NODE_ID)) } else { None }; match self.resolve_ident_in_lexical_scope(ident, ns, record_used_id, path_span) { - // we found a locally-imported or available item/module + // We found a locally-imported or available item/module. Some(LexicalScopeBinding::Item(binding)) => Ok(binding), - // we found a local variable or type param + // We found a local variable or type param. Some(LexicalScopeBinding::Def(def)) if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => { record_segment_def(self, def); @@ -3721,7 +3732,7 @@ impl<'a> Resolver<'a> { }; let first_name = match path.get(0) { - // In the 2018 edition this lint is a hard error, so nothing to do + // In the 2018 edition this lint is a hard error, so nothing to do. Some(seg) if seg.ident.span.rust_2015() && self.session.rust_2015() => seg.ident.name, _ => return, }; @@ -3733,13 +3744,13 @@ impl<'a> Resolver<'a> { } match path.get(1) { - // If this import looks like `crate::...` it's already good + // If this import looks like `crate::...` it's already good. Some(Segment { ident, .. }) if ident.name == keywords::Crate.name() => return, - // Otherwise go below to see if it's an extern crate + // Otherwise, go below to see if it's an extern crate. Some(_) => {} - // If the path has length one (and it's `PathRoot` most likely) + // If the path has length one (and it's `PathRoot` most likely), // then we don't know whether we're gonna be importing a crate or an - // item in our crate. Defer this lint to elsewhere + // item in our crate. Defer this lint to elsewhere. None => return, } @@ -3766,7 +3777,7 @@ impl<'a> Resolver<'a> { diag); } - // Resolve a local definition, potentially adjusting for closures. + // Resolves a local definition, potentially adjusting for closures. fn adjust_local_def(&mut self, ns: Namespace, rib_index: usize, @@ -3797,7 +3808,7 @@ impl<'a> Resolver<'a> { match rib.kind { NormalRibKind | ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind => { - // Nothing to do. Continue. + // Nothing to do; continue. } ClosureRibKind(function_id) => { let prev_def = def; @@ -3836,7 +3847,7 @@ impl<'a> Resolver<'a> { } } ConstantItemRibKind => { - // Still doesn't deal with upvars + // Still doesn't deal with upvars. if record_used { resolve_error(self, span, AttemptToUseNonConstantValueInConstant); } @@ -3855,7 +3866,7 @@ impl<'a> Resolver<'a> { NormalRibKind | TraitOrImplItemRibKind | ClosureRibKind(..) | ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind | ConstantItemRibKind => { - // Nothing to do. Continue. + // Nothing to do; continue. } ItemRibKind => { // This was an attempt to use a type parameter outside its scope. @@ -3907,7 +3918,7 @@ impl<'a> Resolver<'a> { TyKind::Path(None, _) => Some(t.id), TyKind::Rptr(_, ref mut_ty) => extract_node_id(&mut_ty.ty), // This doesn't handle the remaining `Ty` variants as they are not - // that commonly the self_type, it might be interesting to provide + // that commonly the self type, it might be interesting to provide // support for those in future. _ => None, } @@ -3916,7 +3927,7 @@ impl<'a> Resolver<'a> { // Fields are generally expected in the same contexts as locals. if filter_fn(Def::Local(ast::DUMMY_NODE_ID)) { if let Some(node_id) = self.current_self_type.as_ref().and_then(extract_node_id) { - // Look for a field with the same name in the current self_type. + // Look for a field with the same name in the current self type. if let Some(resolution) = self.def_map.get(&node_id) { match resolution.base_def() { Def::Struct(did) | Def::Union(did) @@ -3996,15 +4007,15 @@ impl<'a> Resolver<'a> { }); } } - // Items in scope + // Items in scope. if let ModuleRibKind(module) = rib.kind { - // Items from this module + // Items from this module. add_module_candidates(module, &mut names); if let ModuleKind::Block(..) = module.kind { - // We can see through blocks + // We can see through blocks. } else { - // Items from the prelude + // Items from the prelude. if !module.no_implicit_prelude { names.extend(self.extern_prelude.iter().map(|(ident, _)| { TypoSuggestion { @@ -4021,7 +4032,7 @@ impl<'a> Resolver<'a> { } } } - // Add primitive types to the mix + // Add primitive types to the mix. if filter_fn(Def::PrimTy(Bool)) { names.extend( self.primitive_type_table.primitive_types.iter().map(|(name, _)| { @@ -4084,7 +4095,6 @@ impl<'a> Resolver<'a> { fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) { // First, record candidate traits for this expression if it could // result in the invocation of a method call. - self.record_candidate_traits_for_expr_if_necessary(expr); // Next, resolve the node. @@ -4105,9 +4115,9 @@ impl<'a> Resolver<'a> { }); match def { None => { - // Search again for close matches... + // Search again for close matches. // Picks the first label that is "close enough", which is not necessarily - // the closest match + // the closest match. let close_match = self.search_label(label.ident, |rib, ident| { let names = rib.bindings.iter().map(|(id, _)| &id.name); find_best_match_for_name(names, &*ident.as_str(), None) @@ -4128,7 +4138,7 @@ impl<'a> Resolver<'a> { } } - // visit `break` argument if any + // Visit `break` argument, if there is one. visit::walk_expr(self, expr); } @@ -4140,7 +4150,7 @@ impl<'a> Resolver<'a> { for pat in pats { self.resolve_pattern(pat, PatternSource::IfLet, &mut bindings_list); } - // This has to happen *after* we determine which pat_idents are variants + // This has to happen *after* we determine which `pat_idents` are variants. self.check_consistent_bindings(pats); self.visit_block(if_block); self.ribs[ValueNS].pop(); @@ -4165,7 +4175,7 @@ impl<'a> Resolver<'a> { for pat in pats { this.resolve_pattern(pat, PatternSource::WhileLet, &mut bindings_list); } - // This has to happen *after* we determine which pat_idents are variants. + // This has to happen *after* we determine which `pat_idents` are variants. this.check_consistent_bindings(pats); this.visit_block(block); this.ribs[ValueNS].pop(); @@ -4184,7 +4194,7 @@ impl<'a> Resolver<'a> { ExprKind::Block(ref block, label) => self.resolve_labeled_block(label, block.id, block), - // Equivalent to `visit::walk_expr` + passing some context to children. + // Equivalent to `visit::walk_expr` plus passing some context to children. ExprKind::Field(ref subexpression, _) => { self.resolve_expr(subexpression, Some(expr)); } @@ -4208,7 +4218,7 @@ impl<'a> Resolver<'a> { visit::walk_expr(self, expr); self.current_type_ascription.pop(); } - // Resolve the body of async exprs inside the async closure to which they desugar + // Resolve the body of async exprs inside the async closure to which they desugar. ExprKind::Async(_, async_closure_id, ref block) => { let rib_kind = ClosureRibKind(async_closure_id); self.ribs[ValueNS].push(Rib::new(rib_kind)); @@ -4227,24 +4237,24 @@ impl<'a> Resolver<'a> { let rib_kind = ClosureRibKind(expr.id); self.ribs[ValueNS].push(Rib::new(rib_kind)); self.label_ribs.push(Rib::new(rib_kind)); - // Resolve arguments: + // Resolve the arguments. let mut bindings_list = FxHashMap::default(); for argument in &fn_decl.inputs { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); self.visit_ty(&argument.ty); } - // No need to resolve return type-- the outer closure return type is - // FunctionRetTy::Default + // No need to resolve return type -- the outer closure return type is + // `FunctionRetTy::Default`. - // Now resolve the inner closure + // Now resolve the inner closure. { let rib_kind = ClosureRibKind(inner_closure_id); self.ribs[ValueNS].push(Rib::new(rib_kind)); self.label_ribs.push(Rib::new(rib_kind)); // No need to resolve arguments: the inner closure has none. - // Resolve the return type: + // Resolve the return type. visit::walk_fn_ret_ty(self, &fn_decl.output); - // Resolve the body + // Resolve the body. self.visit_expr(body); self.label_ribs.pop(); self.ribs[ValueNS].pop(); @@ -4261,7 +4271,7 @@ impl<'a> Resolver<'a> { fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) { match expr.node { ExprKind::Field(_, ident) => { - // FIXME(#6890): Even though you can't treat a method like a + // FIXME(#6890): even though you can't treat a method like a // field, we need to add any trait methods we find that match // the field name so that we can do some nice error reporting // later on in typeck. @@ -4269,7 +4279,7 @@ impl<'a> Resolver<'a> { self.trait_map.insert(expr.id, traits); } ExprKind::MethodCall(ref segment, ..) => { - debug!("(recording candidate traits for expr) recording traits for {}", + debug!("(recording candidate traits for expr) recording traits for node {}", expr.id); let traits = self.get_traits_containing_item(segment.ident, ValueNS); self.trait_map.insert(expr.id, traits); @@ -4364,12 +4374,12 @@ impl<'a> Resolver<'a> { } fn lookup_import_candidates_from_module(&mut self, - lookup_ident: Ident, - namespace: Namespace, - start_module: &'a ModuleData<'a>, - crate_name: Ident, - filter_fn: FilterFn) - -> Vec + lookup_ident: Ident, + namespace: Namespace, + start_module: &'a ModuleData<'a>, + crate_name: Ident, + filter_fn: FilterFn) + -> Vec where FilterFn: Fn(Def) -> bool { let mut candidates = Vec::new(); @@ -4383,21 +4393,21 @@ impl<'a> Resolver<'a> { self.populate_module_if_necessary(in_module); // We have to visit module children in deterministic order to avoid - // instabilities in reported imports (#43552). + // instabilities in reported imports (see issue #43552). in_module.for_each_child_stable(|ident, ns, name_binding| { - // avoid imports entirely + // Avoid imports entirely. if name_binding.is_import() && !name_binding.is_extern_crate() { return; } - // avoid non-importable candidates as well + // Avoid non-importable candidates as well. if !name_binding.is_importable() { return; } - // collect results based on the filter function + // Collect results based on the filter function. if ident.name == lookup_ident.name && ns == namespace { let def = name_binding.def(); if filter_fn(def) { - // create the path + // Create the path. let mut segms = path_segments.clone(); if lookup_ident.span.rust_2018() { - // crate-local absolute paths start with `crate::` in edition 2018 + // Crate-local absolute paths start with `crate::` in edition 2018 // FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660) segms.insert( 0, ast::PathSegment::from_ident(crate_name) @@ -4409,13 +4419,13 @@ impl<'a> Resolver<'a> { span: name_binding.span, segments: segms, }; - // the entity is accessible in the following cases: - // 1. if it's defined in the same crate, it's always - // accessible (since private entities can be made public) - // 2. if it's defined in another crate, it's accessible + // The entity is accessible in the following cases: + // 1. If it's defined in the same crate, it's always + // accessible (since private entities can be made public). + // 2. If it's defined in another crate, it's accessible // only if both the module is public and the entity is // declared as public (due to pruning, we don't explore - // outside crate private modules => no need to check this) + // outside crate private modules, so no need to check this). if !in_module_is_extern || name_binding.vis == ty::Visibility::Public { let did = match def { Def::StructCtor(did, _) | Def::VariantCtor(did, _) => @@ -4427,9 +4437,9 @@ impl<'a> Resolver<'a> { } } - // collect submodules to explore + // Collect submodules to explore. if let Some(module) = name_binding.module() { - // form the path + // Form the path. let mut path_segments = path_segments.clone(); path_segments.push(ast::PathSegment::from_ident(ident)); @@ -4441,7 +4451,7 @@ impl<'a> Resolver<'a> { !in_module_is_extern || name_binding.vis == ty::Visibility::Public; if !is_extern_crate_that_also_appears_in_prelude && is_visible_to_user { - // add the module to the lookup + // Add the module to the lookup. let is_extern = in_module_is_extern || name_binding.is_extern_crate(); if seen_modules.insert(module.def_id().unwrap()) { worklist.push((module, path_segments, is_extern)); @@ -4500,13 +4510,13 @@ impl<'a> Resolver<'a> { let mut worklist = vec![(self.graph_root, Vec::new())]; while let Some((in_module, path_segments)) = worklist.pop() { - // abort if the module is already found + // Abort if the module is already found. if result.is_some() { break; } self.populate_module_if_necessary(in_module); in_module.for_each_child_stable(|ident, _, name_binding| { - // abort if the module is already found or if name_binding is private external + // Abort if the module is already found or if `name_binding` is private external. if result.is_some() || !name_binding.vis.is_visible_locally() { return } @@ -4522,7 +4532,7 @@ impl<'a> Resolver<'a> { let did = module.def().and_then(|def| def.opt_def_id()); result = Some((module, ImportSuggestion { did, path })); } else { - // add the module to the lookup + // Add the module to the lookup. if seen_modules.insert(module.def_id().unwrap()) { worklist.push((module, path_segments)); } @@ -4536,7 +4546,7 @@ impl<'a> Resolver<'a> { fn collect_enum_variants(&mut self, enum_def: Def) -> Option> { if let Def::Enum(..) = enum_def {} else { - panic!("Non-enum def passed to collect_enum_variants: {:?}", enum_def) + panic!("non-enum def passed to collect_enum_variants: {:?}", enum_def) } self.find_module(enum_def).map(|(enum_module, enum_import_suggestion)| { @@ -4558,7 +4568,7 @@ impl<'a> Resolver<'a> { } fn record_def(&mut self, node_id: NodeId, resolution: PathResolution) { - debug!("(recording def) recording {:?} for {}", resolution, node_id); + debug!("(recording def) recording {:?} for node {}", resolution, node_id); if let Some(prev_res) = self.def_map.insert(node_id, resolution) { panic!("path resolved multiple times ({:?} before, {:?} now)", prev_res, resolution); } @@ -4786,7 +4796,7 @@ impl<'a> Resolver<'a> { ns: Namespace, new_binding: &NameBinding<'b>, old_binding: &NameBinding<'b>) { - // Error on the second of two conflicting names + // Error on the second of two conflicting names. if old_binding.span.lo() > new_binding.span.lo() { return self.report_conflict(parent, ident, ns, old_binding, new_binding); } @@ -4851,7 +4861,7 @@ impl<'a> Resolver<'a> { format!("previous {} of the {} `{}` here", old_noun, old_kind, name), ); - // See https://github.com/rust-lang/rust/issues/32354 + // See issue #32354. use NameBindingKind::Import; let directive = match (&new_binding.kind, &old_binding.kind) { // If there are two imports where one or both have attributes then prefer removing the @@ -5086,7 +5096,7 @@ impl<'a> Resolver<'a> { fn extern_prelude_get(&mut self, ident: Ident, speculative: bool) -> Option<&'a NameBinding<'a>> { if ident.is_path_segment_keyword() { - // Make sure `self`, `super` etc produce an error when passed to here. + // Make sure `self`, `super`, etc. produce an error when passed to here. return None; } self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| { @@ -5157,16 +5167,16 @@ fn import_candidate_to_enum_paths(suggestion: &ImportSuggestion) -> (String, Str /// When an entity with a given name is not available in scope, we search for /// entities with that name in all crates. This method allows outputting the -/// results of this search in a programmer-friendly way +/// results of this search in a programmer-friendly way. fn show_candidates(err: &mut DiagnosticBuilder<'_>, - // This is `None` if all placement locations are inside expansions + // `None` if all placement locations are inside expansions. span: Option, candidates: &[ImportSuggestion], better: bool, found_use: bool) { - // we want consistent results across executions, but candidates are produced - // by iterating through a hash map, so make sure they are ordered: + // We want consistent results across executions, but candidates are produced + // by iterating through a hash map, so make sure they are ordered. let mut path_strings: Vec<_> = candidates.into_iter().map(|c| path_names_to_string(&c.path)).collect(); path_strings.sort(); @@ -5180,7 +5190,7 @@ fn show_candidates(err: &mut DiagnosticBuilder<'_>, if let Some(span) = span { for candidate in &mut path_strings { - // produce an additional newline to separate the new use statement + // Produce an additional newline to separate the new use-statement // from the directly following item. let additional_newline = if found_use { "" @@ -5217,7 +5227,7 @@ fn module_to_string(module: Module<'_>) -> Option { collect_mod(names, parent); } } else { - // danger, shouldn't be ident? + // Danger; shouldn't be ident? names.push(Ident::from_str("")); collect_mod(names, module.parent.unwrap()); } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 63f752ac9c942..3d869dd8e8319 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -1,20 +1,17 @@ -use crate::{AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; -use crate::{CrateLint, Resolver, ResolutionError, ScopeSet, Weak}; -use crate::{Module, ModuleKind, NameBinding, NameBindingKind, PathResult, Segment, ToNameBinding}; -use crate::{is_known_tool, resolve_error}; -use crate::ModuleOrUniformRoot; -use crate::Namespace::*; -use crate::build_reduced_graph::{BuildReducedGraphVisitor, IsMacroExport}; -use crate::resolve_imports::ImportResolver; +use std::cell::Cell; +use std::{mem, ptr}; + +use errors::{Applicability, DiagnosticBuilder}; +use rustc_data_structures::sync::Lrc; +use rustc::{ty, lint}; +use rustc::{bug, span_bug}; use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex, CrateNum, DefIndexAddressSpace}; use rustc::hir::def::{Def, NonMacroAttrKind}; use rustc::hir::map::{self, DefCollector}; -use rustc::{ty, lint}; -use rustc::{bug, span_bug}; +use syntax_pos::{Span, DUMMY_SP}; use syntax::ast::{self, Ident}; use syntax::attr; -use syntax::errors::DiagnosticBuilder; use syntax::ext::base::{self, Determinacy}; use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::expand::{AstFragment, Invocation, InvocationKind}; @@ -26,12 +23,15 @@ use syntax::feature_gate::{ use syntax::symbol::{Symbol, keywords}; use syntax::visit::Visitor; use syntax::util::lev_distance::find_best_match_for_name; -use syntax_pos::{Span, DUMMY_SP}; -use errors::Applicability; -use std::cell::Cell; -use std::{mem, ptr}; -use rustc_data_structures::sync::Lrc; +use crate::{AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; +use crate::{CrateLint, Resolver, ResolutionError, ScopeSet, Weak}; +use crate::{Module, ModuleKind, NameBinding, NameBindingKind, PathResult, Segment, ToNameBinding}; +use crate::{is_known_tool, resolve_error}; +use crate::ModuleOrUniformRoot; +use crate::Namespace::*; +use crate::build_reduced_graph::{BuildReducedGraphVisitor, IsMacroExport}; +use crate::resolve_imports::ImportResolver; #[derive(Clone, Debug)] pub struct InvocationData<'a> { @@ -411,7 +411,7 @@ impl<'a> Resolver<'a> { let path_span = path.span; let mut path = Segment::from_path(path); - // Possibly apply the macro helper hack + // Possibly apply the macro helper hack. if kind == MacroKind::Bang && path.len() == 1 && path[0].ident.span.ctxt().outer().expn_info() .map_or(false, |info| info.local_inner_macros) { @@ -458,7 +458,7 @@ impl<'a> Resolver<'a> { } } - // Resolve an identifier in lexical scope. + // Resolves an identifier in lexical scope. // This is a variation of `fn resolve_ident_in_lexical_scope` that can be run during // expansion and import resolution (perhaps they can be merged in the future). // The function is used for resolving initial segments of macro paths (e.g., `foo` in @@ -479,7 +479,7 @@ impl<'a> Resolver<'a> { // 2. "Closed set" below means new names cannot appear after the current resolution attempt. // Places to search (in order of decreasing priority): // (Type NS) - // 1. FIXME: Ribs (type parameters), there's no necessary infrastructure yet + // 1. FIXME: ribs (type parameters), there's no necessary infrastructure yet // (open set, not controlled). // 2. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents // (open, not controlled). @@ -488,7 +488,7 @@ impl<'a> Resolver<'a> { // 5. Standard library prelude (de-facto closed, controlled). // 6. Language prelude (closed, controlled). // (Value NS) - // 1. FIXME: Ribs (local variables), there's no necessary infrastructure yet + // 1. FIXME: ribs (local variables), there's no necessary infrastructure yet // (open set, not controlled). // 2. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents // (open, not controlled). @@ -542,7 +542,8 @@ impl<'a> Resolver<'a> { } } - assert!(force || !record_used); // `record_used` implies `force` + // `record_used` implies `force`. + assert!(force || !record_used); let mut ident = orig_ident.modern(); // Make sure `self`, `super` etc produce an error when passed to here. @@ -869,16 +870,19 @@ impl<'a> Resolver<'a> { WhereToResolve::MacroUsePrelude => WhereToResolve::BuiltinMacros, WhereToResolve::BuiltinMacros => WhereToResolve::BuiltinAttrs, WhereToResolve::BuiltinAttrs => WhereToResolve::LegacyPluginHelpers, - WhereToResolve::LegacyPluginHelpers => break, // nowhere else to search + // Nowhere else to search. + WhereToResolve::LegacyPluginHelpers => break, WhereToResolve::ExternPrelude if is_absolute_path => break, WhereToResolve::ExternPrelude => WhereToResolve::ToolPrelude, WhereToResolve::ToolPrelude => WhereToResolve::StdLibPrelude, WhereToResolve::StdLibPrelude => match ns { TypeNS => WhereToResolve::BuiltinTypes, - ValueNS => break, // nowhere else to search + // Nowhere else to search. + ValueNS => break, MacroNS => unreachable!(), } - WhereToResolve::BuiltinTypes => break, // nowhere else to search + // Nowhere else to search. + WhereToResolve::BuiltinTypes => break, }; continue; @@ -982,7 +986,7 @@ impl<'a> Resolver<'a> { let macro_resolutions = mem::replace(&mut *module.multi_segment_macro_resolutions.borrow_mut(), Vec::new()); for (mut path, path_span, kind, parent_scope, initial_def) in macro_resolutions { - // FIXME: Path resolution will ICE if segment IDs present. + // FIXME: path resolution will ICE if segment IDs present. for seg in &mut path { seg.id = None; } match self.resolve_path(&path, Some(MacroNS), &parent_scope, true, path_span, CrateLint::No) { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index b930c30c51192..bc605274d45e4 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1,15 +1,9 @@ -use ImportDirectiveSubclass::*; - -use crate::{AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; -use crate::{CrateLint, Module, ModuleOrUniformRoot, PerNS, ScopeSet, Weak}; -use crate::Namespace::{self, TypeNS, MacroNS}; -use crate::{NameBinding, NameBindingKind, ToNameBinding, PathResult, PrivacyError}; -use crate::{Resolver, Segment}; -use crate::{names_to_string, module_to_string}; -use crate::{resolve_error, ResolutionError}; -use crate::macros::ParentScope; +use std::cell::{Cell, RefCell}; +use std::{mem, ptr}; +use log::debug; use rustc_data_structures::ptr_key::PtrKey; +use rustc::{bug, span_bug}; use rustc::ty; use rustc::lint::builtin::BuiltinLintDiagnostics; use rustc::lint::builtin::{DUPLICATE_MACRO_EXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE}; @@ -17,20 +11,23 @@ use rustc::hir::def_id::{CrateNum, DefId}; use rustc::hir::def::*; use rustc::session::DiagnosticMessageId; use rustc::util::nodemap::FxHashSet; -use rustc::{bug, span_bug}; - +use syntax_pos::{MultiSpan, Span}; use syntax::ast::{self, Ident, Name, NodeId, CRATE_NODE_ID}; use syntax::ext::base::Determinacy::{self, Determined, Undetermined}; use syntax::ext::hygiene::Mark; use syntax::symbol::keywords; use syntax::util::lev_distance::find_best_match_for_name; use syntax::{struct_span_err, unwrap_or}; -use syntax_pos::{MultiSpan, Span}; - -use log::debug; -use std::cell::{Cell, RefCell}; -use std::{mem, ptr}; +use crate::{AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; +use crate::{CrateLint, Module, ModuleOrUniformRoot, PerNS, ScopeSet, Weak}; +use crate::Namespace::{self, TypeNS, MacroNS}; +use crate::{NameBinding, NameBindingKind, ToNameBinding, PathResult, PrivacyError}; +use crate::{Resolver, Segment}; +use crate::{names_to_string, module_to_string}; +use crate::{resolve_error, ResolutionError}; +use crate::macros::ParentScope; +use self::ImportDirectiveSubclass::*; /// Contains data for specific types of import directives. #[derive(Clone, Debug)] @@ -52,7 +49,7 @@ pub enum ImportDirectiveSubclass<'a> { GlobImport { is_prelude: bool, max_vis: Cell, // The visibility of the greatest re-export. - // n.b. `max_vis` is only used in `finalize_import` to check for re-export errors. + // N.B., `max_vis` is only used in `finalize_import` to check for re-export errors. }, ExternCrate { source: Option, @@ -217,7 +214,7 @@ impl<'a> Resolver<'a> { return Ok(binding); } else if ident.name == keywords::Super.name() || ident.name == keywords::SelfLower.name() { - // FIXME: Implement these with renaming requirements so that e.g. + // FIXME: implement these with renaming requirements so that e.g. // `use super;` doesn't work, but `use super as name;` does. // Fall through here to get an error from `early_resolve_...`. } @@ -935,7 +932,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { (source, target, source_bindings, target_bindings, type_ns_only), GlobImport { is_prelude, ref max_vis } => { if directive.module_path.len() <= 1 { - // HACK(eddyb) `lint_if_path_starts_with_module` needs at least + // HACK(eddyb): `lint_if_path_starts_with_module` needs at least // 2 segments, so the `resolve_path` above won't trigger it. let mut full_path = directive.module_path.clone(); full_path.push(Segment::from_ident(keywords::Invalid.ident())); @@ -1011,7 +1008,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } } Err(..) => { - // FIXME: This assert may fire if public glob is later shadowed by a private + // FIXME: this assert may fire if public glob is later shadowed by a private // single import (see test `issue-55884-2.rs`). In theory single imports should // always block globs, even if they are not yet resolved, so that this kind of // self-inconsistent resolution never happens. @@ -1077,7 +1074,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if !ident.is_path_segment_keyword() { format!("no `{}` external crate{}", ident, lev_suggestion) } else { - // HACK(eddyb) this shows up for `self` & `super`, which + // HACK(eddyb): this shows up for `self` & `super`, which // should work instead - for now keep the same error message. format!("no `{}` in the root{}", ident, lev_suggestion) } @@ -1133,7 +1130,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } if directive.module_path.len() <= 1 { - // HACK(eddyb) `lint_if_path_starts_with_module` needs at least + // HACK(eddyb): `lint_if_path_starts_with_module` needs at least // 2 segments, so the `resolve_path` above won't trigger it. let mut full_path = directive.module_path.clone(); full_path.push(Segment::from_ident(ident)); diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 187ebf0bc4304..3f293128463db 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -461,7 +461,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } } - // FIXME tuple structs should generate tuple-specific data. + // FIXME: tuple structs should generate tuple-specific data. fn process_struct( &mut self, item: &'l ast::Item, @@ -861,7 +861,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { fn process_pat(&mut self, p: &'l ast::Pat) { match p.node { PatKind::Struct(ref _path, ref fields, _) => { - // FIXME do something with _path? + // FIXME: do something with _path? let hir_id = self.tcx.hir().node_to_hir_id(p.id); let adt = match self.save_ctxt.tables.node_type_opt(hir_id) { Some(ty) => ty.ty_adt_def().unwrap(), @@ -991,7 +991,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { None => String::new(), }; - // Rust uses the id of the pattern for var lookups, so we'll use it too. + // Rust uses the ID of the pattern for var lookups, so we'll use it too. if !self.span.filter_generated(ident.span) { let qualname = format!("{}${}", ident.to_string(), id); let id = id_from_node_id(id, &self.save_ctxt); @@ -1029,7 +1029,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { /// callsite spans to record macro definition and use data, using the /// mac_uses and mac_defs sets to prevent multiples. fn process_macro_use(&mut self, _span: Span) { - // FIXME if we're not dumping the defs (see below), there is no point + // FIXME: if we're not dumping the defs (see below), there is no point // dumping refs either. // let source_span = span.source_callsite(); // if !self.macro_calls.insert(source_span) { @@ -1043,7 +1043,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // self.dumper.macro_use(data); - // FIXME write the macro def + // FIXME: write the macro def // let mut hasher = DefaultHasher::new(); // data.callee_span.hash(&mut hasher); // let hash = hasher.finish(); @@ -1057,7 +1057,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // span: sub_span, // name: data.name.clone(), // qualname: qualname.clone(), - // // FIXME where do macro docs come from? + // // FIXME: where do macro docs come from? // docs: String::new(), // }.lower(self.tcx)); // } @@ -1091,7 +1091,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { ); } ast::TraitItemKind::Type(ref bounds, ref default_ty) => { - // FIXME do something with _bounds (for type refs) + // FIXME: do something with _bounds (for type refs) let name = trait_item.ident.name.to_string(); let qualname = format!("::{}", self.tcx.node_path_str(trait_item.id)); @@ -1161,13 +1161,13 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { ); } ast::ImplItemKind::Type(ref ty) => { - // FIXME uses of the assoc type should ideally point to this + // FIXME: uses of the assoc type should ideally point to this // 'def' and the name here should be a ref to the def in the // trait. self.visit_ty(ty) } ast::ImplItemKind::Existential(ref bounds) => { - // FIXME uses of the assoc type should ideally point to this + // FIXME: uses of the assoc type should ideally point to this // 'def' and the name here should be a ref to the def in the // trait. for bound in bounds.iter() { @@ -1199,7 +1199,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // (since nested trees don't have their own visibility). let access = access_from!(self.save_ctxt, root_item.vis, id); - // The parent def id of a given use tree is always the enclosing item. + // The parent `DefId` of a given use tree is always the enclosing item. let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) .map(id_from_def_id); @@ -1419,7 +1419,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc } Existential(ref _bounds, ref ty_params) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - // FIXME do something with _bounds + // FIXME: do something with _bounds let value = String::new(); if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 8ab9a8e8dda86..072e26ad32823 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -386,7 +386,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - // FIXME would be nice to take a MethodItem here, but the ast provides both + // FIXME: would be nice to take a MethodItem here, but the ast provides both // trait and impl flavours, so the caller must do the disassembly. pub fn get_method_data(&self, id: ast::NodeId, ident: ast::Ident, span: Span) -> Option { // The qualname for a method is the trait name or name of the struct in an impl in @@ -477,7 +477,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { span: self.span_from_span(ident.span), name: ident.name.to_string(), qualname, - // FIXME you get better data here by using the visitor. + // FIXME: you get better data here by using the visitor. value: String::new(), parent: parent_scope.map(|id| id_from_def_id(id)), children: vec![], @@ -556,7 +556,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { })) } _ => { - // FIXME ty could legitimately be an enum, but then we will fail + // FIXME: ty could legitimately be an enum, but then we will fail // later if we try to look up the fields. debug!("expected struct or union, found {:?}", ty); None @@ -690,7 +690,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { path_seg: &ast::PathSegment, id: NodeId, ) -> Option { - // Returns true if the path is function type sugar, e.g., `Fn(A) -> B`. + // Returns whether the path is function type sugar, e.g., `Fn(A) -> B`. fn fn_type(seg: &ast::PathSegment) -> bool { if let Some(ref generic_args) = seg.args { if let ast::GenericArgs::Parenthesized(_) = **generic_args { @@ -1099,9 +1099,9 @@ impl<'b> SaveHandler for CallbackHandler<'b> { cratename: &str, input: &'l Input, ) { - // We're using the JsonDumper here because it has the format of the - // save-analysis results that we will pass to the callback. IOW, we are - // using the JsonDumper to collect the save-analysis results, but not + // We're using the `JsonDumper` here because it has the format of the + // save-analysis results that we will pass to the callback. I.e., we are + // using the `JsonDumper` to collect the save-analysis results, but not // actually to dump them to a file. This is all a bit convoluted and // there is certainly a simpler design here trying to get out (FIXME). let mut dumper = JsonDumper::with_callback(self.callback, save_ctxt.config.clone()); @@ -1181,7 +1181,7 @@ fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id { let def_id = scx.tcx.hir().opt_local_def_id(id); def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| { // Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId` - // out of the maximum u32 value. This will work unless you have *billions* + // from the maximum `u32` value. This will work unless you have *billions* // of definitions in a single crate (very unlikely to actually happen). rls_data::Id { krate: LOCAL_CRATE.as_u32(), @@ -1202,9 +1202,9 @@ fn lower_attributes(attrs: Vec, scx: &SaveContext<'_, '_>) -> Vec { let mut text = String::new(); if !f.generic_params.is_empty() { - // FIXME defs, bounds on lifetimes + // FIXME: defs, bounds on lifetimes text.push_str("for<"); text.push_str(&f.generic_params .iter() @@ -267,7 +267,7 @@ impl Sig for ast::Ty { let first = pprust::path_segment_to_string(&path.segments[0]); format!("<{} as {}>::", nested_ty.text, first) } else { - // FIXME handle path instead of elipses. + // FIXME: handle path instead of elipses. format!("<{} as ...>::", nested_ty.text) }; @@ -286,7 +286,7 @@ impl Sig for ast::Ty { } else { let start = offset + prefix.len() + 5; let end = start + name.len(); - // FIXME should put the proper path in there, not elipses. + // FIXME: should put the proper path in there, not elipses. Ok(Signature { text: prefix + "...::" + &name, defs: vec![], @@ -295,12 +295,12 @@ impl Sig for ast::Ty { } } ast::TyKind::TraitObject(ref bounds, ..) => { - // FIXME recurse into bounds + // FIXME: recurse into bounds let nested = pprust::bounds_to_string(bounds); Ok(text_sig(nested)) } ast::TyKind::ImplTrait(_, ref bounds) => { - // FIXME recurse into bounds + // FIXME: recurse into bounds let nested = pprust::bounds_to_string(bounds); Ok(text_sig(format!("impl {}", nested))) } @@ -395,7 +395,7 @@ impl Sig for ast::Item { sig.text.push('('); for i in &decl.inputs { - // FIXME should descend into patterns to add defs. + // FIXME: should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(offset + sig.text.len(), Some(i.id), scx)?; @@ -495,7 +495,7 @@ impl Sig for ast::Item { sig.text.push_str(": "); sig.text.push_str(&pprust::bounds_to_string(bounds)); } - // FIXME where clause + // FIXME: where-clause sig.text.push_str(" {}"); Ok(sig) @@ -514,7 +514,7 @@ impl Sig for ast::Item { sig.text.push_str(" = "); sig.text.push_str(&pprust::bounds_to_string(bounds)); } - // FIXME where clause + // FIXME: where-clause sig.text.push_str(";"); Ok(sig) @@ -561,12 +561,12 @@ impl Sig for ast::Item { Ok(merge_sigs(text, vec![generics_sig, trait_sig, ty_sig])) - // FIXME where clause + // FIXME: where-clause } ast::ItemKind::ForeignMod(_) => Err("extern mod"), ast::ItemKind::GlobalAsm(_) => Err("glboal asm"), ast::ItemKind::ExternCrate(_) => Err("extern crate"), - // FIXME should implement this (e.g., pub use). + // FIXME: should implement this (e.g., pub use). ast::ItemKind::Use(_) => Err("import"), ast::ItemKind::Mac(..) | ast::ItemKind::MacroDef(_) => Err("Macro"), } @@ -614,7 +614,7 @@ impl Sig for ast::Path { } } -// This does not cover the where clause, which must be processed separately. +// This does not cover the where-clause, which must be processed separately. impl Sig for ast::Generics { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { if self.params.is_empty() { @@ -651,11 +651,11 @@ impl Sig for ast::Generics { .collect::>() .join(" + "); param_text.push_str(&bounds); - // FIXME add lifetime bounds refs. + // FIXME: add lifetime bounds refs. } ast::GenericParamKind::Type { .. } => { param_text.push_str(&pprust::bounds_to_string(¶m.bounds)); - // FIXME descend properly into bounds. + // FIXME: descend properly into bounds. } ast::GenericParamKind::Const { .. } => { // Const generics cannot contain bounds. @@ -768,7 +768,7 @@ impl Sig for ast::ForeignItem { sig.text.push('('); for i in &decl.inputs { - // FIXME should descend into patterns to add defs. + // FIXME: should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(offset + sig.text.len(), Some(i.id), scx)?; @@ -851,7 +851,7 @@ fn name_and_generics( }; text.push_str(&name); let generics: Signature = generics.make(offset + text.len(), Some(id), scx)?; - // FIXME where clause + // FIXME: where-clause let text = format!("{}{}", text, generics.text); Ok(extend_sig(generics, text, vec![def], vec![])) } @@ -877,7 +877,7 @@ fn make_assoc_type_signature( text.push_str(&name); if let Some(bounds) = bounds { text.push_str(": "); - // FIXME should descend into bounds + // FIXME: should descend into bounds text.push_str(&pprust::bounds_to_string(bounds)); } if let Some(default) = default { @@ -931,7 +931,7 @@ fn make_method_signature( m: &ast::MethodSig, scx: &SaveContext<'_, '_>, ) -> Result { - // FIXME code dup with function signature + // FIXME: code dup with function signature let mut text = String::new(); if m.header.constness.node == ast::Constness::Const { text.push_str("const "); @@ -953,7 +953,7 @@ fn make_method_signature( sig.text.push('('); for i in &m.decl.inputs { - // FIXME should descend into patterns to add defs. + // FIXME: should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(sig.text.len(), Some(i.id), scx)?; diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index e2c93b6d33158..764ee4f5df4b3 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -11,7 +11,7 @@ use syntax_pos::*; #[derive(Clone)] pub struct SpanUtils<'a> { pub sess: &'a Session, - // FIXME given that we clone SpanUtils all over the place, this err_count is + // FIXME: given that we clone SpanUtils all over the place, this err_count is // probably useless and any logic relying on it is bogus. pub err_count: Cell, } @@ -75,14 +75,14 @@ impl<'a> SpanUtils<'a> { // loop { // let ts = toks.real_token(); // if ts.tok == token::Eof { - // return None; + // return `None`; // } // if ts.tok == token::Not { // let ts = toks.real_token(); // if ts.tok.is_ident() { // return Some(ts.sp); // } else { - // return None; + // return `None`; // } // } // } @@ -94,21 +94,21 @@ impl<'a> SpanUtils<'a> { // let mut prev = toks.real_token(); // loop { // if prev.tok == token::Eof { - // return None; + // return `None`; // } // let ts = toks.real_token(); // if ts.tok == token::Not { // if prev.tok.is_ident() { // return Some(prev.sp); // } else { - // return None; + // return `None`; // } // } // prev = ts; // } // } - /// Return true if the span is generated code, and + /// Returnss `true` if the span is generated code, and /// it is not a subspan of the root callsite. /// /// Used to filter out spans of minimal value, @@ -118,7 +118,7 @@ impl<'a> SpanUtils<'a> { return true; } - //If the span comes from a fake source_file, filter it. + // If the span comes from a fake `source_file`, filter it. !self.sess .source_map() .lookup_char_pos(span.lo()) diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index 411eb192d902b..334d5f5bb3990 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -1,7 +1,3 @@ -use crate::abi::{self, Abi, Align, FieldPlacement, Size}; -use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; -use crate::spec::{self, HasTargetSpec}; - mod aarch64; mod amdgpu; mod arm; @@ -23,6 +19,10 @@ mod x86_64; mod x86_win64; mod wasm32; +use crate::abi::{self, Abi, Align, FieldPlacement, Size}; +use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; +use crate::spec::{self, HasTargetSpec}; + #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum PassMode { /// Ignore the argument (useful for empty struct). @@ -40,14 +40,14 @@ pub enum PassMode { Indirect(ArgAttributes, Option), } -// Hack to disable non_upper_case_globals only for the bitflags! and not for the rest -// of this module +// Hack to disable `non_upper_case_globals` only for the `bitflags!` and not for the rest +// of this module. pub use attr_impl::ArgAttribute; #[allow(non_upper_case_globals)] #[allow(unused)] mod attr_impl { - // The subset of llvm::Attribute needed for arguments, packed into a bitfield. + // The subset of `llvm::Attribute` needed for arguments, packed into a bit field. bitflags::bitflags! { #[derive(Default)] pub struct ArgAttribute: u16 { @@ -329,7 +329,7 @@ impl<'a, Ty> TyLayout<'a, Ty> { match (result, field.homogeneous_aggregate(cx)) { (_, HomogeneousAggregate::NoData) => { - // Ignore fields that have no data + // Ignore fields that have no data. } (_, HomogeneousAggregate::Heterogeneous) => { // The field itself must be a homogeneous aggregate. @@ -410,8 +410,9 @@ impl<'a, Ty> ArgType<'a, Ty> { .set(ArgAttribute::NoCapture) .set(ArgAttribute::NonNull); attrs.pointee_size = self.layout.size; - // FIXME(eddyb) We should be doing this, but at least on + // FIXME(eddyb): we should be doing this, but at least on // i686-pc-windows-msvc, it results in wrong stack offsets. + // attrs.pointee_align = Some(self.layout.align.abi); let extra_attrs = if self.layout.is_unsized() { @@ -434,7 +435,7 @@ impl<'a, Ty> ArgType<'a, Ty> { } pub fn extend_integer_width_to(&mut self, bits: u64) { - // Only integers have signedness + // Only integers have signedness. if let Abi::Scalar(ref scalar) = self.layout.abi { if let abi::Int(i, signed) = scalar.value { if i.size().bits() < bits { diff --git a/src/librustc_target/abi/call/powerpc64.rs b/src/librustc_target/abi/call/powerpc64.rs index a9683104d164e..1b06d3f2a7b3e 100644 --- a/src/librustc_target/abi/call/powerpc64.rs +++ b/src/librustc_target/abi/call/powerpc64.rs @@ -1,5 +1,4 @@ -// FIXME: -// Alignment of 128 bit types is not currently handled, this will +// FIXME: alignment of 128-bit types is not currently handled -- this will // need to be fixed when PowerPC vector support is added. use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; @@ -8,8 +7,10 @@ use crate::spec::HasTargetSpec; #[derive(Debug, Clone, Copy, PartialEq)] enum ABI { - ELFv1, // original ABI used for powerpc64 (big-endian) - ELFv2, // newer ABI used for powerpc64le and musl (both endians) + // Original ABI used for `powerpc64` (big-endian). + ELFv1, + // Newer ABI used for `powerpc64le` and `musl` (both endians). + ELFv2, } use ABI::*; @@ -52,7 +53,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>, abi: ABI) return; } - // The ELFv1 ABI doesn't return aggregates in registers + // The ELFv1 ABI doesn't return aggregates in registers. if abi == ELFv1 { ret.make_indirect(); return; diff --git a/src/librustc_target/abi/call/s390x.rs b/src/librustc_target/abi/call/s390x.rs index c2717b1bcb815..c1a2dc6224fa5 100644 --- a/src/librustc_target/abi/call/s390x.rs +++ b/src/librustc_target/abi/call/s390x.rs @@ -1,5 +1,5 @@ -// FIXME: The assumes we're using the non-vector ABI, i.e., compiling -// for a pre-z13 machine or using -mno-vx. +// FIXME: the assumes we're using the non-vector ABI, i.e., compiling +// for a pre-z13 machine or using `-mno-vx`. use crate::abi::call::{FnType, ArgType, Reg}; use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; diff --git a/src/librustc_target/abi/call/sparc64.rs b/src/librustc_target/abi/call/sparc64.rs index d8930a875efbc..c8dd343402ef2 100644 --- a/src/librustc_target/abi/call/sparc64.rs +++ b/src/librustc_target/abi/call/sparc64.rs @@ -1,4 +1,4 @@ -// FIXME: This needs an audit for correctness and completeness. +// FIXME: this needs an audit for correctness and completeness. use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform}; use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; diff --git a/src/librustc_target/abi/call/x86_win64.rs b/src/librustc_target/abi/call/x86_win64.rs index ebdeb63150a46..3f0bf2b171349 100644 --- a/src/librustc_target/abi/call/x86_win64.rs +++ b/src/librustc_target/abi/call/x86_win64.rs @@ -18,7 +18,7 @@ pub fn compute_abi_info(fty: &mut FnType<'_, Ty>) { } } Abi::Vector { .. } => { - // FIXME(eddyb) there should be a size cap here + // FIXME(eddyb): there should be a size cap here // (probably what clang calls "illegal vectors"). } Abi::Scalar(_) => { diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 8b96a8c1658b2..878db03e5b431 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -510,11 +510,11 @@ impl Integer { None } - /// Find the largest integer with the given alignment or less. + /// Finds the largest integer with the given alignment or less. pub fn approximate_align(cx: &C, wanted: Align) -> Integer { let dl = cx.data_layout(); - // FIXME(eddyb) maybe include I128 in the future, when it works everywhere. + // FIXME(eddyb): maybe include `I128` in the future, when it works everywhere. for &candidate in &[I64, I32, I16] { if wanted >= candidate.align(dl).abi && wanted.bytes() >= candidate.size().bytes() { return candidate; @@ -629,7 +629,7 @@ pub struct Scalar { /// /// This is intended specifically to mirror LLVM’s `!range` metadata, /// semantics. - // FIXME(eddyb) always use the shortest range, e.g., by finding + // FIXME(eddyb): always use the shortest range, e.g., by finding // the largest space between two consecutive valid values and // taking everything else as the (shortest) valid range. pub valid_range: RangeInclusive, @@ -687,12 +687,12 @@ pub enum FieldPlacement { /// Offsets for the first byte of each field, /// ordered to match the source definition order. /// This vector does not go in increasing order. - // FIXME(eddyb) use small vector optimization for the common case. + // FIXME(eddyb): use small vector optimization for the common case. offsets: Vec, /// Maps source order field indices to memory order indices, /// depending how fields were permuted. - // FIXME(camlorn) also consider small vector optimization here. + // FIXME(camlorn): also consider small vector optimization here. memory_index: Vec } } diff --git a/src/librustc_target/spec/dragonfly_base.rs b/src/librustc_target/spec/dragonfly_base.rs index 766030e8015d0..249925d3de7cf 100644 --- a/src/librustc_target/spec/dragonfly_base.rs +++ b/src/librustc_target/spec/dragonfly_base.rs @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions { args.insert(LinkerFlavor::Gcc, vec![ // GNU-style linkers will use this to omit linking to libraries // which don't actually fulfill any relocations, but only for - // libraries which follow this flag. Thus, use it before + // libraries which follow this flag. Thus, use it before // specifying libraries to link to. "-Wl,--as-needed".to_string(), diff --git a/src/librustc_target/spec/freebsd_base.rs b/src/librustc_target/spec/freebsd_base.rs index 51f030f59084d..91ef6f8986aa2 100644 --- a/src/librustc_target/spec/freebsd_base.rs +++ b/src/librustc_target/spec/freebsd_base.rs @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions { args.insert(LinkerFlavor::Gcc, vec![ // GNU-style linkers will use this to omit linking to libraries // which don't actually fulfill any relocations, but only for - // libraries which follow this flag. Thus, use it before + // libraries which follow this flag. Thus, use it before // specifying libraries to link to. "-Wl,--as-needed".to_string(), @@ -22,7 +22,7 @@ pub fn opts() -> TargetOptions { has_rpath: true, pre_link_args: args, position_independent_executables: true, - eliminate_frame_pointer: false, // FIXME 43575 + eliminate_frame_pointer: false, // FIXME: 43575 relro_level: RelroLevel::Full, abi_return_struct_as_int: true, .. Default::default() diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs index e294e63982de4..1899117c855b6 100644 --- a/src/librustc_target/spec/linux_musl_base.rs +++ b/src/librustc_target/spec/linux_musl_base.rs @@ -11,7 +11,7 @@ pub fn opts() -> TargetOptions { // At least when this was tested, the linker would not add the // `GNU_EH_FRAME` program header to executables generated, which is required // when unwinding to locate the unwinding information. I'm not sure why this - // argument is *not* necessary for normal builds, but it can't hurt! + // argument is **not** necessary for normal builds, but it can't hurt! base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string()); // When generating a statically linked executable there's generally some diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 7cbf24402d742..afe3b13815159 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -1189,7 +1189,7 @@ impl Target { let target_path = env::var_os("RUST_TARGET_PATH").unwrap_or_default(); - // FIXME 16351: add a sane default search path? + // FIXME: 16351: add a sane default search path? for dir in env::split_paths(&target_path) { let p = dir.join(&path); diff --git a/src/librustc_target/spec/netbsd_base.rs b/src/librustc_target/spec/netbsd_base.rs index e9cd98c0e7151..eb0581058898c 100644 --- a/src/librustc_target/spec/netbsd_base.rs +++ b/src/librustc_target/spec/netbsd_base.rs @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions { args.insert(LinkerFlavor::Gcc, vec![ // GNU-style linkers will use this to omit linking to libraries // which don't actually fulfill any relocations, but only for - // libraries which follow this flag. Thus, use it before + // libraries which follow this flag. Thus, use it before // specifying libraries to link to. "-Wl,--as-needed".to_string(), diff --git a/src/librustc_target/spec/openbsd_base.rs b/src/librustc_target/spec/openbsd_base.rs index 5bcfd62d75bd4..b82fc5e90696b 100644 --- a/src/librustc_target/spec/openbsd_base.rs +++ b/src/librustc_target/spec/openbsd_base.rs @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions { args.insert(LinkerFlavor::Gcc, vec![ // GNU-style linkers will use this to omit linking to libraries // which don't actually fulfill any relocations, but only for - // libraries which follow this flag. Thus, use it before + // libraries which follow this flag. Thus, use it before // specifying libraries to link to. "-Wl,--as-needed".to_string(), @@ -23,7 +23,7 @@ pub fn opts() -> TargetOptions { abi_return_struct_as_int: true, pre_link_args: args, position_independent_executables: true, - eliminate_frame_pointer: false, // FIXME 43575 + eliminate_frame_pointer: false, // FIXME: 43575 relro_level: RelroLevel::Full, .. Default::default() } diff --git a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs index f259787e1d54d..a536e2e82830d 100644 --- a/src/librustc_target/spec/s390x_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/s390x_unknown_linux_gnu.rs @@ -4,7 +4,7 @@ pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); // z10 is the oldest CPU supported by LLVM base.cpu = "z10".to_string(); - // FIXME: The data_layout string below and the ABI implementation in + // FIXME: the data_layout string below and the ABI implementation in // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI. // Pass the -vector feature string to LLVM to respect this assumption. base.features = "-vector".to_string(); diff --git a/src/librustc_target/spec/sparcv9_sun_solaris.rs b/src/librustc_target/spec/sparcv9_sun_solaris.rs index acc03fd0d79ee..101efca1f2817 100644 --- a/src/librustc_target/spec/sparcv9_sun_solaris.rs +++ b/src/librustc_target/spec/sparcv9_sun_solaris.rs @@ -14,7 +14,7 @@ pub fn target() -> TargetResult { target_c_int_width: "32".to_string(), data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), // Use "sparc64" instead of "sparcv9" here, since the former is already - // used widely in the source base. If we ever needed ABI + // used widely in the source base. If we ever needed ABI // differentiation from the sparc64, we could, but that would probably // just be confusing. arch: "sparc64".to_string(), diff --git a/src/librustc_target/spec/thumb_base.rs b/src/librustc_target/spec/thumb_base.rs index ed0dbb766a835..7d1e4c1d8da54 100644 --- a/src/librustc_target/spec/thumb_base.rs +++ b/src/librustc_target/spec/thumb_base.rs @@ -45,9 +45,9 @@ pub fn opts() -> TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), // When this section is added a volatile load to its start address is also generated. This // volatile load is a footgun as it can end up loading an invalid memory address, depending - // on how the user set up their linker scripts. This section adds pretty printer for stuff + // on how the user set up their linker scripts. This section adds pretty-printer for stuff // like std::Vec, which is not that used in no-std context, so it's best to left it out - // until we figure a way to add the pretty printers without requiring a volatile load cf. + // until we figure a way to add the pretty-printers without requiring a volatile load cf. // rust-lang/rust#44993. emit_debug_gdb_scripts: false, .. Default::default() diff --git a/src/librustc_target/spec/wasm32_unknown_emscripten.rs b/src/librustc_target/spec/wasm32_unknown_emscripten.rs index a6e9340ce28ef..0d25e6dfac4d0 100644 --- a/src/librustc_target/spec/wasm32_unknown_emscripten.rs +++ b/src/librustc_target/spec/wasm32_unknown_emscripten.rs @@ -1,8 +1,8 @@ use super::{LinkArgs, LinkerFlavor, Target, TargetOptions}; pub fn target() -> Result { - // FIXME(nikic) BINARYEN_TRAP_MODE=clamp is needed to avoid trapping in our - // -Zsaturating-float-casts implementation. This can be dropped if/when + // FIXME(nikic): `BINARYEN_TRAP_MODE=clamp` is needed to avoid trapping in our + // `-Zsaturating-float-casts` implementation. This can be dropped if/when // we have native fpto[su]i.sat intrinsics, or the implementation otherwise // stops relying on non-trapping fpto[su]i. let mut post_link_args = LinkArgs::new(); diff --git a/src/librustc_target/spec/wasm32_unknown_unknown.rs b/src/librustc_target/spec/wasm32_unknown_unknown.rs index ee2160c472080..dc9229e3a0759 100644 --- a/src/librustc_target/spec/wasm32_unknown_unknown.rs +++ b/src/librustc_target/spec/wasm32_unknown_unknown.rs @@ -1,5 +1,5 @@ // The wasm32-unknown-unknown target is currently an experimental version of a -// wasm-based target which does *not* use the Emscripten toolchain. Instead +// wasm-based target which does **not** use the Emscripten toolchain. Instead // this toolchain is based purely on LLVM's own toolchain, using LLVM's native // WebAssembly backend as well as LLD for a native linker. // diff --git a/src/librustc_target/spec/windows_base.rs b/src/librustc_target/spec/windows_base.rs index 38db9cd356cd8..f9a4714d236fd 100644 --- a/src/librustc_target/spec/windows_base.rs +++ b/src/librustc_target/spec/windows_base.rs @@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions { // section, ".note.rustc", you'll note is over 8 characters. // // On more recent versions of gcc on mingw, apparently the section name - // is *not* truncated, but rather stored elsewhere in a separate lookup + // is **not** truncated, but rather stored elsewhere in a separate lookup // table. On older versions of gcc, they apparently always truncated th // section names (at least in some cases). Truncating the section name // actually creates "invalid" objects [1] [2], but only for some @@ -55,14 +55,14 @@ pub fn opts() -> TargetOptions { // Listing the library twice seems to fix that, and seems to also be done // by mingw's gcc (Though not sure if it's done on purpose, or by mistake). // - // See https://github.com/rust-lang/rust/pull/47483 + // See PR #47483. "-lmsvcrt".to_string(), "-luser32".to_string(), "-lkernel32".to_string(), ]); TargetOptions { - // FIXME(#13846) this should be enabled for windows + // FIXME(#13846): this should be enabled for Windows. function_sections: false, linker: Some("gcc".to_string()), dynamic_linking: true, diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index a326d84725ab4..8edfd3c270f56 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -294,21 +294,23 @@ impl context::ContextOps> for ChalkContext<'cx, 'gcx> { canon.max_universe.index() + 1 } - /// Convert a goal G *from* the canonical universes *into* our + /// Converts a goal G *from* the canonical universes *into* our /// local universes. This will yield a goal G' that is the same /// but for the universes of universally quantified names. fn map_goal_from_canonical( _map: &UniverseMap, value: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, ) -> Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { - *value // FIXME universe maps not implemented yet + // FIXME: universe maps not implemented yet + *value } fn map_subst_from_canonical( _map: &UniverseMap, value: &Canonical<'gcx, ConstrainedSubst<'gcx>>, ) -> Canonical<'gcx, ConstrainedSubst<'gcx>> { - value.clone() // FIXME universe maps not implemented yet + // FIXME: universe maps not implemented yet + value.clone() } } @@ -363,14 +365,14 @@ impl context::TruncateOps, ChalkArenas<'tcx>> &mut self, _subgoal: &InEnvironment<'tcx, Goal<'tcx>>, ) -> Option>> { - None // FIXME we should truncate at some point! + None // FIXME: we should truncate at some point! } fn truncate_answer( &mut self, _subst: &CanonicalVarValues<'tcx>, ) -> Option> { - None // FIXME we should truncate at some point! + None // FIXME: we should truncate at some point! } } diff --git a/src/librustc_traits/chalk_context/program_clauses.rs b/src/librustc_traits/chalk_context/program_clauses.rs index adfd26814db1e..7fc540e7feeea 100644 --- a/src/librustc_traits/chalk_context/program_clauses.rs +++ b/src/librustc_traits/chalk_context/program_clauses.rs @@ -281,7 +281,7 @@ fn wf_clause_for_tuple<'tcx>( None => return ty::List::empty(), }; - // If `arity == 0` (i.e. the unit type) or `arity == 1`, this list of + // If `arity == 0` (i.e., the unit type) or `arity == 1`, this list of // hypotheses is actually empty. let sized_implemented = type_list[0 .. std::cmp::max(arity, 1) - 1].iter() .map(|ty| ty::TraitRef { diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index dad45130062a4..53177b6908da5 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -73,14 +73,14 @@ fn compute_implied_outlives_bounds<'tcx>( // an annoying scenario where: // // - Some `T::Foo` gets normalized, resulting in a - // variable `_1` and a `T: Trait` constraint + // variable `_1` and a `T: Trait` constraint // (not sure why it couldn't immediately get // solved). This result of `_1` got cached. // - These obligations were dropped on the floor here, // rather than being registered. // - Then later we would get a request to normalize // `T::Foo` which would result in `_1` being used from - // the cache, but hence without the `T: Trait` + // the cache, but hence without the `T: Trait` // constraint. As a result, `_1` never gets resolved, // and we get an ICE (in dropck). // diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 908fdcfe7430f..5b878e11a782f 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -1,5 +1,7 @@ mod environment; +use std::iter; + use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::definitions::DefPathData; @@ -21,8 +23,6 @@ use rustc::ty::{self, List, TyCtxt}; use rustc::ty::subst::{Subst, Substs}; use syntax::ast; -use std::iter; - crate fn provide(p: &mut Providers<'_>) { *p = Providers { program_clauses_for, @@ -216,14 +216,14 @@ fn program_clauses_for_trait<'a, 'tcx>( // Rule Implied-Bound-From-Trait // - // For each where clause WC: + // For each where-clause WC: // ``` // forall { // FromEnv(WC) :- FromEnv(Self: Trait)`, for each where clause WC + // `FromEnv(WC) :- FromEnv(Self: Trait)`, for each where-clause WC let implied_bound_clauses = where_clauses .iter() .cloned() @@ -232,12 +232,12 @@ fn program_clauses_for_trait<'a, 'tcx>( .map(|wc| { // we move binders to the left wc.map_bound(|goal| ProgramClause { - // FIXME: As where clauses can only bind lifetimes for now, and that named - // bound regions have a def-id, it is safe to just inject `bound_vars` and + // FIXME: as where-clauses can only bind lifetimes for now, and that named + // bound regions have a `DefId`, it is safe to just inject `bound_vars` and // `hypotheses` (which contain named vars bound at index `0`) into this - // binding level. This may change if we ever allow where clauses to bind - // types (e.g. for GATs things), because bound types only use a `BoundVar` - // index (no def-id). + // binding level. This may change if we ever allow where-clauses to bind + // types (e.g., for GATs things), because bound types only use a `BoundVar` + // index (no `DefId`). goal: goal.subst(tcx, bound_vars).into_from_env_goal(), hypotheses, @@ -248,7 +248,7 @@ fn program_clauses_for_trait<'a, 'tcx>( // Rule WellFormed-TraitRef // - // Here `WC` denotes the set of all where clauses: + // Here `WC` denotes the set of all where-clauses: // ``` // forall { // WellFormed(Self: Trait) :- Implemented(Self: Trait) && WellFormed(WC) @@ -362,7 +362,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>( // Rule Implied-Bound-From-Type // - // For each where clause `WC`: + // For each where-clause `WC`: // ``` // forall { // FromEnv(WC) :- FromEnv(Ty<...>) @@ -373,7 +373,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>( let from_env_goal = tcx.mk_goal(DomainGoal::FromEnv(FromEnv::Ty(ty)).into_goal()); let hypotheses = tcx.intern_goals(&[from_env_goal]); - // For each where clause `WC`: + // For each where-clause `WC`: let from_env_clauses = where_clauses .into_iter() @@ -382,7 +382,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>( // move the binders to the left wc.map_bound(|goal| ProgramClause { // FIXME: we inject `bound_vars` and `hypotheses` into this binding - // level, which may be incorrect in the future: see the FIXME in + // level, which may be incorrect in the future; see the FIXME in // `program_clauses_for_trait`. goal: goal.subst(tcx, bound_vars).into_from_env_goal(), hypotheses, @@ -546,7 +546,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( // } // ``` // - // FIXME: For the moment, we don't account for where clauses written on the associated + // FIXME: for the moment, we don't account for where-clauses written on the associated // ty definition (i.e., in the trait def, as in `type AssocType where T: Sized`). // ``` // forall { diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index 30fbdbdeb4433..4e526173c5adc 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -120,7 +120,7 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { let ty = tcx.type_of(def_id); let ty = self.subst(ty, substs); - debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); + debug!("relate_type_and_user_type: ty of `DefId` is {:?}", ty); let ty = self.normalize(ty); self.relate(mir_ty, Variance::Invariant, ty)?; @@ -159,9 +159,9 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { // haven't been normalized. // // FIXME(nmatsakis): Well, perhaps we should normalize - // them? This would only be relevant if some input + // them? This would only be relevant if some input // type were ill-formed but did not appear in `ty`, - // which...could happen with normalization... + // which could happen with normalization. self.prove_predicate(Predicate::WellFormed(ty)); Ok(()) } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 23e9cd55cdce7..9500ddf6e6c69 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -292,8 +292,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { if !infer_lifetimes { if let Some(span_late) = def.has_late_bound_regions { let msg = "cannot specify lifetime arguments explicitly \ - if late bound lifetime parameters are present"; - let note = "the late bound lifetime parameter is introduced here"; + if late-bound lifetime parameters are present"; + let note = "the late-bound lifetime parameter is introduced here"; let span = args.args[0].span(); if position == GenericArgPosition::Value && arg_counts.lifetimes != param_counts.lifetimes { @@ -564,7 +564,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { let tcx = self.tcx(); let generic_params = tcx.generics_of(def_id); - // If a self-type was declared, one should be provided. + // If a self type was declared, one should be provided. assert_eq!(generic_params.has_self, self_ty.is_some()); let has_self = generic_params.has_self; @@ -584,7 +584,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { if is_object && has_default { if tcx.at(span).type_of(param.def_id).has_self_ty() { // There is no suitable inference default for a type parameter - // that references self, in an object type. + // that references the self type in an object type. return true; } } @@ -723,7 +723,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { let predicate: Result<_, ErrorReported> = self.ast_type_binding_to_poly_projection_predicate( trait_ref.ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings); - // okay to ignore Err because of ErrorReported (see above) + // ok to ignore Err because of ErrorReported (see above) Some((predicate.ok()?, binding.span)) })); @@ -918,6 +918,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { })) } + // `item_segment` is used to substitute the generic arguments. fn ast_path_to_ty(&self, span: Span, did: DefId, @@ -963,10 +964,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { debug!("principal: {:?}", principal); for trait_bound in trait_bounds[1..].iter() { - // sanity check for non-principal trait bounds + // Perform sanity check for non-principal trait bounds. self.instantiate_poly_trait_ref(trait_bound, dummy_self, - &mut vec![]); + &mut Vec::new()); } let (mut auto_traits, trait_bounds) = split_auto_traits(tcx, &trait_bounds[1..]); @@ -1019,11 +1020,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { // } // ``` // - // Here, the user could theoretically write `dyn MyTrait`, + // Here, the user could theoretically write `dyn MyTrait`, // but actually supporting that would "expand" to an infinitely-long type - // `fix $ τ → dyn MyTrait::MyOutput`. + // `fix $ τ → dyn MyTrait::MyOutput`. // - // Instead, we force the user to write `dyn MyTrait`, + // Instead, we force the user to write `dyn MyTrait`, // which is uglier but works. See the discussion in #56288 for alternatives. if !references_self { // Include projections defined on supertraits, @@ -1124,7 +1125,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { auto_traits.sort(); auto_traits.dedup(); - // Calling `skip_binder` is okay, because the predicates are re-bound. + // Calling `skip_binder` is ok, because the predicates are re-bound. let principal = if tcx.trait_is_auto(existential_principal.def_id()) { ty::ExistentialPredicate::AutoTrait(existential_principal.def_id()) } else { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 0e6ab5b1eb3b2..72a7dcfdb100a 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -168,7 +168,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // cases. Actually what we really want is not a subtyping // relation at all but rather that there exists a LUB (so // that they can be compared). However, in practice, - // constants are always scalars or strings. For scalars + // constants are always scalars or strings. For scalars // subtyping is irrelevant, and for strings `ty` is // type is `&'static str`, so if we say that // @@ -350,7 +350,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // below for details. // Take region, inner-type from expected type if we - // can, to avoid creating needless variables. This + // can, to avoid creating needless variables. This // also helps with the bad interactions of the given // hack detailed in (*) below. debug!("check_pat_walk: expected={:?}", expected); @@ -494,7 +494,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // int`) as a subtype of `Z`: `&'x int <: Z`. And hence we // will instantiate `Z` as a type `&'0 int` where `'0` is // a fresh region variable, with the constraint that `'x : - // '0`. So basically we're all set. + // '0`. So basically we're all set. // // Note that there are two tests to check that this remains true // (`regions-reassign-{match,let}-bound-pointer.rs`). @@ -554,7 +554,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); let tcx = self.tcx; // Not entirely obvious: if matches may create ref bindings, we want to - // use the *precise* type of the discriminant, *not* some supertype, as + // use the *precise* type of the discriminant, **not** some supertype, as // the "discriminant type" (issue #23116). // // arielb1 [writes here in this comment thread][c] that there @@ -634,12 +634,12 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); } } - // Otherwise, we have to union together the types that the - // arms produce and so forth. + // Otherwise, we have to take the union of the types that the + // arms produce, and so forth. let discrim_diverges = self.diverges.get(); self.diverges.set(Diverges::Maybe); - // rust-lang/rust#55810: Typecheck patterns first (via eager + // Issue #55810: type-check patterns first (via eager // collection into `Vec`), so we get types for all bindings. let all_arm_pats_diverge: Vec<_> = arms.iter().map(|arm| { let mut all_pats_diverge = Diverges::WarnedAlways; @@ -663,7 +663,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); } }).collect(); - // Now typecheck the blocks. + // Now type-check the blocks. // // The result of the match is the common supertype of all the // arms. Start out the value as bottom, since it's the, well, @@ -943,7 +943,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); let mut no_field_errors = true; let mut inexistent_fields = vec![]; - // Typecheck each field. + // Type-check each field. for &Spanned { node: ref field, span } in fields { let ident = tcx.adjust_ident(field.ident, variant.did, self.body_id).0; let field_ty = match used_fields.entry(ident) { diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index f863cfe1887db..0ad3577f5a5d7 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -113,7 +113,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { let tcx = self.infcx.tcx; - // + // `` let trait_ref = TraitRef { def_id: tcx.lang_items().deref_trait()?, substs: tcx.mk_substs_trait(self.cur_ty, &[]), diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 1bbb93b4e461d..b210998604075 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let output = match result { None => { - // this will report an error since original_callee_ty is not a fn + // This will report an error since `original_callee_ty` is not a fn. self.confirm_builtin_call(call_expr, original_callee_ty, arg_exprs, expected) } @@ -70,7 +70,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } }; - // we must check that return type of called functions is WF: + // We must check that return type of called functions is WF. self.register_wf_obligation(output, call_expr.span, traits::MiscObligation); output @@ -101,8 +101,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { assert_eq!(def_id.krate, LOCAL_CRATE); // Check whether this is a call to a closure where we - // haven't yet decided on whether the closure is fn vs - // fnmut vs fnonce. If so, we have to defer further processing. + // haven't yet decided on whether the closure is `fn` versus + // `FnMut` versus `FnOnce`. If so, we have to defer further processing. if self.closure_kind(def_id, substs).is_none() { let closure_ty = self.closure_sig(def_id, substs); let fn_sig = self @@ -129,8 +129,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - // Hack: we know that there are traits implementing Fn for &F - // where F:Fn and so forth. In the particular case of types + // Hack: we know that there are traits implementing `Fn` for `&F` + // where `F: Fn` and so forth. In the particular case of types // like `x: &mut FnMut()`, if there is a call `x()`, we would // normally translate to `FnMut::call_mut(&mut x, ())`, but // that winds up requiring `mut x: &mut FnMut()`. A little @@ -397,7 +397,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn_sig: ty::FnSig<'tcx>, ) -> Ty<'tcx> { // `fn_sig` is the *signature* of the cosure being called. We - // don't know the full details yet (`Fn` vs `FnMut` etc), but we + // don't know the full details yet (`Fn` versus `FnMut`, etc..), but we // do know the types expected for each argument and the return // type. @@ -458,21 +458,21 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { pub fn resolve(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { debug!("DeferredCallResolution::resolve() {:?}", self); - // we should not be invoked until the closure kind has been - // determined by upvar inference + // We should not be invoked until the closure kind has been + // determined by upvar inference. assert!(fcx .closure_kind(self.closure_def_id, self.closure_substs) .is_some()); - // We may now know enough to figure out fn vs fnmut etc. + // We may now know enough to figure out `fn` versus `FnMut`, etc. match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty, None) { Some((autoref, method_callee)) => { // One problem is that when we get here, we are going // to have a newly instantiated function signature // from the call trait. This has to be reconciled with // the older function signature we had before. In - // principle we *should* be able to fn_sigs(), but we - // can't because of the annoying need for a TypeTrace. + // principle we *should* be able to `fn_sigs()`, but we + // can't because of the annoying need for a `TypeTrace`. // (This always bites me, should find a way to // refactor it.) let method_sig = method_callee.sig; diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 317d6bbd78592..c8c91299f5fd4 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { let mut err = struct_span_err!(fcx.tcx.sess, self.span, E0641, "cannot cast {} a pointer of an unknown kind", if unknown_cast_to { "to" } else { "from" }); - err.note("The type information given here is insufficient to check whether \ + err.note("the type information given here is insufficient to check whether \ the pointer cast is valid"); if unknown_cast_to { err.span_suggestion_short( diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 722af8f0e778d..4a025929c7141 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -397,7 +397,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); } - // Create a `PolyFnSig`. Note the oddity that late bound + // Create a `PolyFnSig`. Note the oddity that late-bound // regions appearing free in `expected_sig` are now bound up // in this binder we are creating. assert!(!expected_sig.sig.has_vars_bound_above(ty::INNERMOST)); @@ -481,7 +481,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // FIXME(#45727): As discussed in [this comment][c1], naively // forcing equality here actually results in suboptimal error - // messages in some cases. For now, if there would have been + // messages in some cases. For now, if there would have been // an obvious error, we fallback to declaring the type of the // closure to be the one the user gave, which allows other // error message code to trigger. diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 90071e3f3634a..03f077b0c44e2 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -50,34 +50,36 @@ //! sort of a minor point so I've opted to leave it for later -- after all, //! we may want to adjust precisely when coercions occur. -use crate::check::{FnCtxt, Needs}; +use std::ops::Deref; + use errors::DiagnosticBuilder; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::infer::{Coercion, InferResult, InferOk}; use rustc::infer::type_variable::TypeVariableOrigin; use rustc::traits::{self, ObligationCause, ObligationCauseCode}; -use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::{self, TypeAndMut, Ty, ClosureSubsts}; -use rustc::ty::fold::TypeFoldable; +use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::error::TypeError; +use rustc::ty::fold::TypeFoldable; use rustc::ty::relate::RelateResult; use smallvec::{smallvec, SmallVec}; -use std::ops::Deref; use syntax::feature_gate; use syntax::ptr::P; use syntax_pos; +use crate::check::{FnCtxt, Needs}; + struct Coerce<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, cause: ObligationCause<'tcx>, use_lub: bool, - /// Determines whether or not allow_two_phase_borrow is set on any + /// Determines whether or not `allow_two_phase_borrow` is set on any /// autoref adjustments we create while coercing. We don't want to /// allow deref coercions to create two-phase borrows, at least initially, /// but we do need two-phase borrows for function argument reborrows. - /// See #47489 and #48598 - /// See docs on the "AllowTwoPhase" type for a more detailed discussion + /// See #47489 and #48598. + /// See docs on the `AllowTwoPhase` type for a more detailed discussion. allow_two_phase: AllowTwoPhase, } @@ -161,7 +163,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { } if a.is_never() { - // Subtle: If we are coercing from `!` to `?T`, where `?T` is an unbound + // Subtle: if we are coercing from `!` to `?T`, where `?T` is an unbound // type variable, we want `?T` to fallback to `!` if not // otherwise constrained. An example where this arises: // @@ -170,7 +172,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // here, we would coerce from `!` to `?T`. let b = self.shallow_resolve(b); return if self.shallow_resolve(b).is_ty_var() { - // micro-optimization: no need for this if `b` is + // Micro-optimization: no need for this if `b` is // already resolved in some way. let diverging_ty = self.next_diverging_ty_var( TypeVariableOrigin::AdjustmentType(self.cause.span)); @@ -249,7 +251,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // If we have a parameter of type `&M T_a` and the value // provided is `expr`, we will be adding an implicit borrow, - // meaning that we convert `f(expr)` to `f(&M *expr)`. Therefore, + // meaning that we convert `f(expr)` to `f(&M *expr)`. Therefore, // to type check, we will construct the type that `&M*expr` would // yield. @@ -276,7 +278,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { continue; } - // At this point, we have deref'd `a` to `referent_ty`. So + // At this point, we have deref'd `a` to `referent_ty`. So, // imagine we are coercing from `&'a mut Vec` to `&'b mut [T]`. // In the autoderef loop for `&'a mut Vec`, we would get // three callbacks: @@ -307,7 +309,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // - if in sub mode, that means we want to use `'b` (the // region from the target reference) for both // pointers [2]. This is because sub mode (somewhat - // arbitrarily) returns the subtype region. In the case + // arbitrarily) returns the subtype region. In the case // where we are coercing to a target type, we know we // want to use that target type region (`'b`) because -- // for the program to type-check -- it must be the @@ -319,7 +321,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // annotate the region of a borrow), and regionck has // code that adds edges from the region of a borrow // (`'b`, here) into the regions in the borrowed - // expression (`*x`, here). (Search for "link".) + // expression (`*x`, here). (Search for "link".) // - if in lub mode, things can get fairly complicated. The // easiest thing is just to make a fresh // region variable [4], which effectively means we defer @@ -394,7 +396,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { if ty == a && mt_a.mutbl == hir::MutImmutable && autoderef.step_count() == 1 { // As a special case, if we would produce `&'a *x`, that's // a total no-op. We end up with the type `&'a T` just as - // we started with. In that case, just skip it + // we started with. In that case, just skip it // altogether. This is just an optimization. // // Note that for `&mut`, we DO want to reborrow -- @@ -1096,8 +1098,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> } /// The inner coercion "engine". If `expression` is `None`, this - /// is a forced-unit case, and hence `expression_ty` must be - /// `Nil`. + /// is a forced-unit case, and hence `expression_ty` must be `Nil`. fn coerce_inner<'a>(&mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, cause: &ObligationCause<'tcx>, @@ -1153,7 +1154,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> // if let Some(x) = ... { } // // we wind up with a second match arm that is like `_ => - // ()`. That is the case we are considering here. We take + // ()`. That is the case we are considering here. We take // a different path to get the right "expected, found" // message and so forth (and because we know that // `expression_ty` will be unit). diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 05ca54df2984b..54c51e8014598 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -80,7 +80,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Result<(), ErrorReported> { let trait_to_impl_substs = impl_trait_ref.substs; - // This node-id should be used for the `body_id` field on each + // This `NodeId` should be used for the `body_id` field on each // `ObligationCause` (and the `FnCtxt`). This is what // `regionck_item` expects. let impl_m_node_id = tcx.hir().as_local_node_id(impl_m.def_id).unwrap(); @@ -145,7 +145,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // <'a> fn(t: &'i0 U0, m: &'a) -> Foo // // This type is also the same but the name of the bound region ('a - // vs 'b). However, the normal subtyping rules on fn types handle + // vs 'b). However, the normal subtyping rules on fn types handle // this kind of equivalency just fine. // // We now use these substitutions to ensure that all declared bounds are @@ -244,7 +244,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // compatible with that of the trait method. We do this by // checking that `impl_fty <: trait_fty`. // - // FIXME. Unfortunately, this doesn't quite work right now because + // FIXME: unfortunately, this doesn't quite work right now because // associated type normalization is not integrated into subtype // checks. For the comparison to be valid, we need to // normalize the associated types in the impl/trait methods @@ -253,7 +253,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // any associated types appearing in the fn arguments or return // type. - // Compute placeholder form of impl and trait method tys. + // Compute placeholder forms of impl and trait method types. let tcx = infcx.tcx; let (impl_sig, _) = infcx.replace_bound_vars_with_fresh_vars( @@ -376,7 +376,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Must have same number of early-bound lifetime parameters. // Unfortunately, if the user screws up the bounds, then this - // will change classification between early and late. E.g., + // will change classification between early and late. E.g., // if in trait we have `<'a,'b:'a>`, and in impl we just have // `<'a,'b>`, then we have 2 early-bound lifetime parameters // in trait but 0 in the impl. But if we report "expected 2 @@ -499,9 +499,9 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Result<(), ErrorReported> { // Try to give more informative error messages about self typing - // mismatches. Note that any mismatch will also be detected + // mismatches. Note that any mismatch will also be detected // below, where we construct a canonical function type that - // includes the self parameter as a normal parameter. It's just + // includes the self parameter as a normal parameter. It's just // that the error messages you get out of this code are a bit more // inscrutable, particularly for cases where one method has no // self. @@ -715,11 +715,11 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_m: &ty::AssociatedItem, trait_m: &ty::AssociatedItem) -> Result<(), ErrorReported> { - // FIXME(chrisvittal) Clean up this function, list of FIXME items: - // 1. Better messages for the span labels - // 2. Explanation as to what is going on - // If we get here, we already have the same number of generics, so the zip will - // be okay. + // FIXME(chrisvittal): clean up this function. + // 1. Better messages for the span labels. + // 2. Explanation as to what is going on. + // If we get here, we already have the same number of generics, so the `zip` will + // be ok. let mut error_found = false; let impl_m_generics = tcx.generics_of(impl_m.def_id); let trait_m_generics = tcx.generics_of(trait_m.def_id); @@ -911,7 +911,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let trait_ty = tcx.type_of(trait_c.def_id).subst(tcx, trait_to_impl_substs); let mut cause = ObligationCause::misc(impl_c_span, impl_c_hir_id); - // There is no "body" here, so just pass dummy id. + // There is no "body" here, so just pass dummy ID. let impl_ty = inh.normalize_associated_types_in(impl_c_span, impl_c_hir_id, param_env, @@ -935,7 +935,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_ty, trait_ty); - // Locate the Span containing just the type of the offending impl + // Locate the Span containing just the type of the offending impl. match tcx.hir().expect_impl_item(impl_c_node_id).node { ImplItemKind::Const(ref ty, _) => cause.span = ty.span, _ => bug!("{:?} is not a impl const", impl_c), @@ -950,7 +950,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let trait_c_node_id = tcx.hir().as_local_node_id(trait_c.def_id); let trait_c_span = trait_c_node_id.map(|trait_c_node_id| { - // Add a label to the Span containing just the type of the const + // Add a label to the `Span` containing just the type of the const. match tcx.hir().expect_trait_item(trait_c_node_id).node { TraitItemKind::Const(ref ty, _) => ty.span, _ => bug!("{:?} is not a trait const", trait_c), diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 8b80fba4d19d0..3c190e0f99ff8 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -171,7 +171,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This special internal attribute is used to whitelist // "identity-like" conversion methods to be suggested here. // - // FIXME (#46459 and #46460): ideally + // FIXME(#46459 and #46460): ideally // `std::convert::Into::into` and `std::borrow:ToOwned` would // also be `#[rustc_conversion_suggestion]`, if not for // method-probing false-positives and -negatives (respectively). diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index ad74e78fecdcd..91c12ddd775ba 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -53,7 +53,7 @@ pub fn check_drop_impl<'a, 'tcx>( ) } _ => { - // Destructors only work on nominal types. This was + // Destructors only work on nominal types. This was // already checked by coherence, but compilation may // not have been terminated. let span = tcx.def_span(drop_impl_did); @@ -72,8 +72,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>( ) -> Result<(), ErrorReported> { let drop_impl_hir_id = tcx.hir().as_local_hir_id(drop_impl_did).unwrap(); - // check that the impl type can be made to match the trait type. - + // Check that the impl type can be made to match the trait type. tcx.infer_ctxt().enter(|ref infcx| { let impl_param_env = tcx.param_env(self_type_did); let tcx = infcx.tcx; @@ -111,21 +110,21 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>( } if let Err(ref errors) = fulfillment_cx.select_all_or_error(&infcx) { - // this could be reached when we get lazy normalization + // This could be reached when we get lazy normalization. infcx.report_fulfillment_errors(errors, None, false); return Err(ErrorReported); } let region_scope_tree = region::ScopeTree::default(); - // NB. It seems a bit... suspicious to use an empty param-env - // here. The correct thing, I imagine, would be + // FIXMKE(nmatsakis): it seems a bit suspicious to use an empty + // param-env here. The correct thing, I imagine, would be // `OutlivesEnvironment::new(impl_param_env)`, which would // allow region solving to take any `a: 'b` relations on the // impl into account. But I could not create a test case where // it did the wrong thing, so I chose to preserve existing // behavior, since it ought to be simply more - // conservative. -nmatsakis + // conservative. let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty()); infcx.resolve_regions_and_report_errors( @@ -294,7 +293,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'gcx, 'tcx>( body_id: hir::HirId, scope: region::Scope, ) -> Result<(), ErrorReported> { - debug!("check_safety_of_destructor_if_necessary typ: {:?} scope: {:?}", + debug!("check_safety_of_destructor_if_necessary: typ={:?} scope={:?}", ty, scope); let parent_scope = match rcx.region_scope_tree.opt_encl_scope(scope) { @@ -307,7 +306,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'gcx, 'tcx>( let origin = || infer::SubregionOrigin::SafeDestructor(span); let cause = &ObligationCause::misc(span, body_id); let infer_ok = rcx.infcx.at(cause, rcx.fcx.param_env).dropck_outlives(ty); - debug!("dropck_outlives = {:#?}", infer_ok); + debug!("check_safety_of_destructor_if_necessary: dropck_outlives={:#?}", infer_ok); let kinds = rcx.fcx.register_infer_ok_obligations(infer_ok); for kind in kinds { match kind.unpack() { diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 7f4b0a96a15ab..ee81e9c44079d 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -108,8 +108,8 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, debug!("Types in generator {:?}, span = {:?}", type_list, body.value.span); - // Replace all regions inside the generator interior with late bound regions - // Note that each region slot in the types gets a new fresh late bound region, + // Replace all regions inside the generator interior with late-bound regions + // Note that each region slot in the types gets a new fresh late-bound region, // which means that none of the regions inside relate to any other, even if // typeck had previously found constraints that would cause them to be related. let mut counter = 0; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 34b248a106cb0..590e180bd6d50 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -94,7 +94,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { // // SUBTLE: if we want good error messages, because of "guessing" while matching // traits, no trait system method can be called before this point because they - // could alter our Self-type, except for normalizing the receiver from the + // could alter our self type, except for normalizing the receiver from the // signature (which is also done during probing). let method_sig_rcvr = self.normalize_associated_types_in(self.span, &method_sig.inputs()[0]); @@ -249,14 +249,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { // Make a trait reference `$0 : Trait<$1...$n>` // consisting entirely of type variables. Later on in - // the process we will unify the transformed-self-type + // the process we will unify the transformed-self type // of the method with the actual type in order to // unify some of these variables. self.fresh_substs_for_item(self.span, trait_def_id) } probe::WhereClausePick(ref poly_trait_ref) => { - // Where clauses can have bound regions in them. We need to instantiate + // where-clauses can have bound regions in them. We need to instantiate // those to convert from a poly-trait-ref to a trait-ref. self.replace_bound_vars_with_fresh_vars(&poly_trait_ref).substs } @@ -270,7 +270,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { -> R { // If we specified that this is an object method, then the - // self-type ought to be something that can be dereferenced to + // self type ought to be something that can be dereferenced to // yield an object-type (e.g., `&Object` or `Box` // etc). @@ -291,7 +291,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { .next() .unwrap_or_else(|| span_bug!(self.span, - "self-type `{}` for ObjectPick never dereferenced to an object", + "self type `{}` for ObjectPick never dereferenced to an object", self_ty) ) } diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 259a28645815f..0b47e6d7bbf7d 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -6,12 +6,6 @@ mod confirm; pub mod probe; mod suggest; -pub use self::MethodError::*; -pub use self::CandidateSource::*; -pub use self::suggest::{SelfSource, TraitInfo}; - -use crate::check::FnCtxt; -use crate::namespace::Namespace; use errors::{Applicability, DiagnosticBuilder}; use rustc_data_structures::sync::Lrc; use rustc::hir; @@ -27,7 +21,12 @@ use syntax::ast; use syntax_pos::Span; use crate::{check_type_alias_enum_variants_enabled}; +use crate::check::FnCtxt; +use crate::namespace::Namespace; +pub use self::MethodError::*; +pub use self::CandidateSource::*; use self::probe::{IsSuggestion, ProbeScope}; +pub use self::suggest::{SelfSource, TraitInfo}; pub fn provide(providers: &mut ty::query::Providers<'_>) { suggest::provide(providers); @@ -351,7 +350,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Register obligations for the parameters. This will include the // `Self` parameter, which in turn has a bound of the main trait, - // so this also effectively registers `obligation` as well. (We + // so this also effectively registers `obligation` as well. (We // used to register `obligation` explicitly, but that resulted in // double error messages being reported.) // diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 709177212ada7..491684165c299 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -281,8 +281,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.tcx.method_autoderef_steps(param_env_and_self_ty) } else { self.infcx.probe(|_| { - // Mode::Path - the deref steps is "trivial". This turns - // our CanonicalQuery into a "trivial" QueryResponse. This + // `Mode::Path` -- the deref steps is "trivial". This turns + // our `CanonicalQuery` into a "trivial" `QueryResponse`. This // is a bit inefficient, but I don't think that writing // special handling for this "trivial case" is a good idea. @@ -329,12 +329,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // ambiguous. if let Some(bad_ty) = &steps.opt_bad_ty { if is_suggestion.0 { - // Ambiguity was encountered during a suggestion. Just keep going. + // Ambiguity was encountered during a suggestion; just keep going. debug!("ProbeContext: encountered ambiguity in suggestion"); } else if bad_ty.reached_raw_pointer && !self.tcx.features().arbitrary_self_types { - // this case used to be allowed by the compiler, - // so we do a future-compat lint here for the 2015 edition - // (see https://github.com/rust-lang/rust/issues/46906) + // Rhis case used to be allowed by the compiler, + // so we do a future-compat lint here for the 2015 edition. + // (See issue #46906.) if self.tcx.sess.rust_2018() { span_err!(self.tcx.sess, span, E0699, "the type of this value must be known \ @@ -367,9 +367,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self_ty, steps); - - // this creates one big transaction so that all type variables etc - // that we create during the probe process are removed later + // This creates one big transaction so that all type variables, etc., + // that we create during the probe process are removed later. self.probe(|_| { let mut probe_cx = ProbeContext::new( self, span, mode, method_name, return_type, orig_values, @@ -755,7 +754,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) { - // FIXME -- Do we want to commit to this behavior for param bounds? + // FIXME: do we want to commit to this behavior for param bounds? let bounds = self.param_env .caller_bounds @@ -1190,10 +1189,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { "a method with this name may be added to the standard library in the future", ); - // FIXME: This should be a `span_suggestion` instead of `help` - // However `self.span` only - // highlights the method name, so we can't use it. Also consider reusing the code from - // `report_method_error()`. + // FIXME: this should be a `span_suggestion` instead of `help`. + // However, `self.span` only highlights the method name, so we can't use it. + // Also consider reusing the code from `report_method_error()`. diag.help(&format!( "call with fully qualified syntax `{}(...)` to keep using the current method", self.tcx.item_path_str(stable_pick.item.def_id), @@ -1259,7 +1257,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { .sup(probe.xform_self_ty, self_ty) { Ok(InferOk { obligations, value: () }) => obligations, Err(_) => { - debug!("--> cannot relate self-types"); + debug!("--> cannot relate self types"); return ProbeResult::NoMatch; } }; @@ -1466,7 +1464,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { ty::AssociatedKind::Method | ty::AssociatedKind::Const => true }, } - // FIXME -- check for types that deref to `Self`, + // FIXME: check for types that deref to `Self`, // like `Rc` and so on. // // Note also that the current code will break if this type diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 768842ef39214..4c86886d20963 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -423,7 +423,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .map(|p| format!("`{} : {}`", p.self_ty(), p)) .collect::>(); bound_list.sort(); - bound_list.dedup(); // #35677 + // Issue #35677. + bound_list.dedup(); let bound_list = bound_list.join("\n"); err.note(&format!("the method `{}` exists but the following trait bounds \ were not satisfied:\n{}", @@ -506,7 +507,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let (span, found_use) = UsePlacementFinder::check(self.tcx, krate, module_id); if let Some(span) = span { let path_strings = candidates.iter().map(|did| { - // Produce an additional newline to separate the new use statement + // Produce an additional newline to separate the new use-statement // from the directly following item. let additional_newline = if found_use { "" @@ -616,7 +617,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { candidates.sort_by(|a, b| a.cmp(b).reverse()); candidates.dedup(); - // FIXME #21673: this help message could be tuned to the case + // FIXME(#21673): this help message could be tuned to the case // of a type parameter: suggest adding a trait bound rather // than implementing. err.help("items from traits can only be used if the trait is implemented and in scope"); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 91e44a1588268..2d127463ffc4c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -9,31 +9,31 @@ function). Inference is used to supply types wherever they are unknown. By far the most complex case is checking the body of a function. This can be broken down into several distinct phases: -- gather: creates type variables to represent the type of each local +- *gather*: creates type variables to represent the type of each local variable and pattern binding. -- main: the main pass does the lion's share of the work: it +- *main*: the main pass does the lion's share of the work: it determines the types of all expressions, resolves - methods, checks for most invalid conditions, and so forth. In + methods, checks for most invalid conditions, and so forth. In some cases, where a type is unknown, it may create a type or region variable and use that as the type of an expression. In the process of checking, various constraints will be placed on these type variables through the subtyping relationships requested - through the `demand` module. The `infer` module is in charge + through the `demand` module. The `infer` module is in charge of resolving those constraints. -- regionck: after main is complete, the regionck pass goes over all +- *regionck*: after main is complete, the regionck pass goes over all types looking for regions and making sure that they did not escape - into places they are not in scope. This may also influence the + into places they are not in scope. This may also influence the final assignments of the various region variables if there is some flexibility. -- vtable: find and records the impls to use for each trait bound that +- *vtable*: find and records the impls to use for each trait bound that appears on a type parameter. -- writeback: writes the final types within a function body, replacing - type variables with their final inferred types. These final types +- *writeback*: writes the final types within a function body, replacing + type variables with their final inferred types. These final types are written into the `tcx.node_types` table, which should *never* contain any reference to a type variable. @@ -41,8 +41,8 @@ can be broken down into several distinct phases: While type checking a function, the intermediate types for the expressions, blocks, and so forth contained within the function are -stored in `fcx.node_types` and `fcx.node_substs`. These types -may contain unresolved type variables. After type checking is +stored in `fcx.node_types` and `fcx.node_substs`. These types +may contain unresolved type variables. After type checking is complete, the functions in the writeback module are used to take the types from this table, resolve them, and then write them into their permanent home in the type context `tcx`. @@ -54,12 +54,12 @@ nodes within the function. The types of top-level items, which never contain unbound type variables, are stored directly into the `tcx` tables. -N.B., a type variable is not the same thing as a type parameter. A +N.B., a type variable is not the same thing as a type parameter. A type variable is rather an "instance" of a type parameter: that is, given a generic function `fn foo(t: T)`: while checking the function `foo`, the type `ty_param(0)` refers to the type `T`, which -is treated in abstract. When `foo()` is called, however, `T` will be -substituted for a fresh type variable `N`. This variable will +is treated in abstract. When `foo()` is called, however, `T` will be +substituted for a fresh type variable `N`. This variable will eventually be resolved to some concrete type (which might itself be type parameter). @@ -207,7 +207,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { // `FnOnce` closure. In that case, we defer full resolution of the // call until upvar inference can kick in and make the // decision. We keep these deferred resolutions grouped by the - // def-id of the closure, so that once we decide, we can easily go + // `DefId` of the closure, so that once we decide, we can easily go // back and process them. deferred_call_resolutions: RefCell>>>, @@ -490,8 +490,8 @@ impl Diverges { pub struct BreakableCtxt<'gcx: 'tcx, 'tcx> { may_break: bool, - // this is `null` for loops where break with a value is illegal, - // such as `while`, `for`, and `while let` + // This is `null` for loops where break with a value is illegal, + // such as `while`, `for`, and `while let`. coerce: Option>, } @@ -923,7 +923,7 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fcx.resolve_type_vars_in_body(body) }); - // Consistency check our TypeckTables instance can hold all ItemLocalIds + // Consistency check our `TypeckTables` instance can hold all `ItemLocalId`s // it will need to hold. assert_eq!(tables.local_id_root, Some(DefId::local(tcx.hir().definitions().node_to_hir_id(id).owner))); @@ -1022,7 +1022,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> { intravisit::walk_pat(self, p); } - // Don't descend into the bodies of nested closures + // Don't descend into the bodies of nested closures. fn visit_fn(&mut self, _: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl, _: hir::BodyId, _: Span, _: ast::NodeId) { } } @@ -1060,7 +1060,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, debug!("check_fn(sig={:?}, fn_id={}, param_env={:?})", fn_sig, fn_id, param_env); - // Create the function context. This is either derived from scratch or, + // Create the function context. This is either derived from scratch or, // in the case of closures, based on the outer context. let mut fcx = FnCtxt::new(inherited, param_env, body.value.hir_id); *fcx.ps.borrow_mut() = UnsafetyState::function(fn_sig.unsafety, fn_id); @@ -1099,7 +1099,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, None, ); - // Check that argument is Sized. + // Check that argument is `Sized`. // The check for a non-trivial pattern is a hack to avoid duplicate warnings // for simple cases like `fn foo(x: Trait)`, // where we would error once on the parameter as a whole, and once on the binding `x`. @@ -1117,7 +1117,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // We insert the deferred_generator_interiors entry after visiting the body. // This ensures that all nested generators appear before the entry of this generator. - // resolve_generator_interiors relies on this property. + // `resolve_generator_interiors` relies on this property. let gen_ty = if can_be_generator.is_some() && body.is_generator { let interior = fcx.next_ty_var(TypeVariableOrigin::MiscVariable(span)); fcx.deferred_generator_interiors.borrow_mut().push((body.id(), interior)); @@ -1139,7 +1139,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // event that the `actual_return_ty` comes back as `!`, that // indicates that the fn either does not return or "returns" only // values of type `!`. In this case, if there is an expected - // return type that is *not* `!`, that should be ok. But if the + // return type that is **not** `!`, that should be ok. But if the // return type is being inferred, we want to "fallback" to `!`: // // let x = move || panic!(); @@ -1180,13 +1180,13 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } } - // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !` + // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !`. if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() { if panic_impl_did == fcx.tcx.hir().local_def_id(fn_id) { if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() { - // at this point we don't care if there are duplicate handlers or if the handler has - // the wrong signature as this value we'll be used when writing metadata and that - // only happens if compilation succeeded + // At this point we don't care if there are duplicate handlers or if the handler has + // the wrong signature, as this value will be used when writing metadata, and that + // only happens if compilation succeeded. fcx.tcx.sess.has_panic_handler.try_set_same(true); if declared_ret_ty.sty != ty::Never { @@ -1238,7 +1238,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } } - // Check that a function marked as `#[alloc_error_handler]` has signature `fn(Layout) -> !` + // Check that a function marked as `#[alloc_error_handler]` has signature `fn(Layout) -> !`. if let Some(alloc_error_handler_did) = fcx.tcx.lang_items().oom() { if alloc_error_handler_did == fcx.tcx.hir().local_def_id(fn_id) { if let Some(alloc_layout_did) = fcx.tcx.lang_items().alloc_layout() { @@ -1295,7 +1295,8 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span) { let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); - def.destructor(tcx); // force the destructor to be evaluated + // Force the destructor to be evaluated. + def.destructor(tcx); check_representable(tcx, span, def_id); if def.repr.simd() { @@ -1311,7 +1312,8 @@ fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span) { let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); - def.destructor(tcx); // force the destructor to be evaluated + // Force the destructor to be evaluated. + def.destructor(tcx); check_representable(tcx, span, def_id); check_packed(tcx, span, def_id); @@ -1441,12 +1443,12 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite } fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { - // Only restricted on wasm32 target for now + // Only restricted on wasm32 target for now. if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") { return } - // If `#[link_section]` is missing, then nothing to verify + // If `#[link_section]` is missing, then nothing to verify. let attrs = tcx.codegen_fn_attrs(id); if attrs.link_section.is_none() { return @@ -1482,7 +1484,7 @@ fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId, item: &hir::Item) { let item_def_id = tcx.hir().local_def_id(item.id); - // an error would be reported if this fails. + // An error would be reported if this fails. let _ = traits::OnUnimplementedDirective::of_item(tcx, trait_def_id, item_def_id); } @@ -1557,14 +1559,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let impl_items = || impl_item_refs.iter().map(|iiref| tcx.hir().impl_item(iiref.id)); // Check existing impl methods to see if they are both present in trait - // and compatible with trait signature + // and compatible with trait signature. for impl_item in impl_items() { let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.id)); let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id) .find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) && tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) .or_else(|| { - // Not compatible, but needed for the error message + // Not compatible, but needed for the error message. tcx.associated_items(impl_trait_ref.def_id) .find(|ac| tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) }); @@ -1587,8 +1589,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); - // We can only get the spans from local trait definition - // Same for E0324 and E0325 + // We can only get the spans from local trait definition. + // Same for E0324 and E0325. if let Some(trait_span) = tcx.hir().span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, "item in trait"); } @@ -1642,7 +1644,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - // Check for missing items from trait + // Check for missing items from the trait. let mut missing_items = Vec::new(); let mut invalidated_items = Vec::new(); let associated_type_overridden = overridden_associated_type.is_some(); @@ -1789,7 +1791,7 @@ fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if tcx.adt_def(def.did).repr.align > 0 { return true; } - // push struct def_id before checking fields + // Push `def_id` of struct before checking fields. stack.push(def_id); for field in &def.non_enum_variant().fields { let f = field.ty(tcx, substs); @@ -1799,7 +1801,7 @@ fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } } - // only need to pop if not early out + // We only need to pop if we didn't exit early. stack.pop(); } } @@ -1812,12 +1814,12 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De return; } - // For each field, figure out if it's known to be a ZST and align(1) + // For each field, figure out if it's known to be a ZST and align(1). let field_infos = adt.non_enum_variant().fields.iter().map(|field| { let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did)); let param_env = tcx.param_env(field.did); let layout = tcx.layout_of(param_env.and(ty)); - // We are currently checking the type this field came from, so it must be local + // We are currently checking the type this field came from, so it must be local. let span = tcx.hir().span_if_local(field.did).unwrap(); let zst = layout.map(|layout| layout.is_zst()).unwrap_or(false); let align1 = layout.map(|layout| layout.align.abi.bytes() == 1).unwrap_or(false); @@ -1849,7 +1851,8 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: ast::NodeId) { let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); - def.destructor(tcx); // force the destructor to be evaluated + // Force the destructor to be evaluated. + def.destructor(tcx); if vs.is_empty() { let attributes = tcx.get_attrs(def_id); @@ -1881,7 +1884,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut disr_vals: Vec> = Vec::with_capacity(vs.len()); for ((_, discr), v) in def.discriminants(tcx).zip(vs) { - // Check for duplicate discriminant values + // Check for duplicate discriminant values. if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) { let variant_did = def.variants[VariantIdx::new(i)].did; let variant_i_hir_id = tcx.hir().as_local_hir_id(variant_did).unwrap(); @@ -1934,7 +1937,7 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> { match predicate { ty::Predicate::Trait(ref data) if data.skip_binder().self_ty().is_param(index) => { - // HACK(eddyb) should get the original `Span`. + // HACK(eddyb): should get the original `Span`. let span = tcx.def_span(def_id); Some((predicate, span)) } @@ -1983,7 +1986,8 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> { fn normalize_ty(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx> { if ty.has_escaping_bound_vars() { - ty // FIXME: normalization and escaping regions + // FIXME: normalization and escaping regions + ty } else { self.normalize_associated_types_in(span, &ty) } @@ -2079,13 +2083,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Resolves type variables in `ty` if possible. Unlike the infcx - /// version (resolve_type_vars_if_possible), this version will + /// version (`resolve_type_vars_if_possible`), this version will /// also select obligations if it seems useful, in an effort /// to get more type information. fn resolve_type_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> { debug!("resolve_type_vars_with_obligations(ty={:?})", ty); - // No Infer()? Nothing needs doing. + // No `Infer()`? Nothing needs doing. if !ty.has_infer_types() { debug!("resolve_type_vars_with_obligations: ty={:?}", ty); return ty; @@ -2281,7 +2285,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { debug!(" - composing on top of {:?}", entry.get()); match (&entry.get()[..], &adj[..]) { // Applying any adjustment on top of a NeverToAny - // is a valid NeverToAny adjustment, because it can't + // is a valid `NeverToAny` adjustment, because it can't // be reached. (&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return, (&[ @@ -2294,7 +2298,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // A reborrow has no effect before a dereference. } // FIXME: currently we never try to compose autoderefs - // and ReifyFnPointer/UnsafeFnPointer, but we could. + // and `ReifyFnPointer`/`UnsafeFnPointer`, but we could. _ => bug!("while adjusting {:?}, can't compose {:?} and {:?}", expr, entry.get(), adj) @@ -2469,7 +2473,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { span: Span, code: traits::ObligationCauseCode<'tcx>) { - // WF obligations never themselves fail, so no real need to give a detailed cause: + // WF obligations never themselves fail, so no real need to give a detailed cause. let cause = traits::ObligationCause::new(span, self.body_id, code); self.register_predicate(traits::Obligation::new(cause, self.param_env, @@ -2543,11 +2547,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } // Tries to apply a fallback to `ty` if it is an unsolved variable. - // Non-numerics get replaced with ! or () (depending on whether - // feature(never_type) is enabled, unconstrained ints with i32, + // Non-numerics get replaced with `!` or `()` (depending on whether + // feature(never_type) is enabled, unconstrained ints with `i32`, // unconstrained floats with f64. // Fallback becomes very dubious if we have encountered type-checking errors. - // In that case, fallback to Error. + // In that case, fallback to `Error`. // The return value indicates whether fallback has occurred. fn fallback_if_possible(&self, ty: Ty<'tcx>) -> bool { use rustc::ty::error::UnconstrainedNumeric::Neither; @@ -2588,10 +2592,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { method: MethodCallee<'tcx>) -> ty::TypeAndMut<'tcx> { - // extract method return type, which will be &T; + // Extract method return type, which will be `&T`. let ret_ty = method.sig.output(); - // method returns &T, but the type as visible to user is T, so deref + // Method returns `&T`, but type as visible to user is `T`, so deref. ret_ty.builtin_deref(true).unwrap() } @@ -2603,7 +2607,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { needs: Needs) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> { - // FIXME(#18741) -- this is almost but not quite the same as the + // FIXME(#18741): this is almost but not quite the same as the // autoderef that normal method probing does. They could likely be // consolidated. @@ -2650,7 +2654,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If some lookup succeeds, write callee into table and extract index/element // type from the method signature. - // If some lookup succeeded, install method in table + // If some lookup succeeded, install method in table. let input_ty = self.next_ty_var(TypeVariableOrigin::AutoDeref(base_expr.span)); let method = self.try_overloaded_place_op( expr.span, self_ty, &[input_ty], needs, PlaceOp::Index); @@ -2666,7 +2670,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::MutMutable => AutoBorrowMutability::Mutable { // Indexing can be desugared to a method call, // so maybe we could use two-phase here. - // See the documentation of AllowTwoPhase for why that's + // See the documentation of `AllowTwoPhase` for why that's // not the case today. allow_two_phase_borrow: AllowTwoPhase::No, } @@ -2726,7 +2730,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { needs, op); - // Try Mut first, if needed. + // Try `Mut` first, if needed. let (mut_tr, mut_op) = self.resolve_place_op(op, true); let method = match (needs, mut_tr) { (Needs::MutPlace, Some(trait_did)) => { @@ -2775,7 +2779,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } let method = method.unwrap(); - // HACK(eddyb) ignore self in the definition (see above). + // HACK(eddyb): ignore self in the definition (see above). let expected_arg_tys = self.expected_inputs_for_expected_output( sp, expected, @@ -2868,7 +2872,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let tcx = self.tcx; // Grab the argument types, supplying fresh type variables - // if the wrong number of arguments were supplied + // if the wrong number of arguments were supplied. let supplied_arg_count = if tuple_arguments == DontTupleArguments { args.len() } else { @@ -2901,12 +2905,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } if sugg_unit { let sugg_span = tcx.sess.source_map().end_point(expr_sp); - // remove closing `)` from the span + // Remove closing `)` from the span. let sugg_span = sugg_span.shrink_to_lo(); err.span_suggestion( sugg_span, "expected the unit value `()`; create it with empty parentheses", - String::from("()"), + "()".to_owned(), Applicability::MachineApplicable); } else { err.span_label(sp, format!("expected {}{}", @@ -2953,7 +2957,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.err_args(supplied_arg_count) } } else { - // is the missing argument of type `()`? + // Is the missing argument of type `()`? let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 { self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit() } else if fn_inputs.len() == 1 && supplied_arg_count == 0 { @@ -2966,7 +2970,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected_arg_tys = &[]; self.err_args(supplied_arg_count) }; - // If there is no expectation, expect formal_tys. + // If there is no expectation, expect `formal_tys`. let expected_arg_tys = if !expected_arg_tys.is_empty() { expected_arg_tys } else { @@ -3041,8 +3045,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - // We also need to make sure we at least write the ty of the other - // arguments which we skipped above. + // We also need to make sure we at least write the type of the other + // arguments that we skipped above. if variadic { fn variadic_error<'tcx>(s: &Session, span: Span, t: Ty<'tcx>, cast_ty: &str) { use crate::structured_errors::{VariadicError, StructuredDiagnostic}; @@ -3052,8 +3056,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { for arg in args.iter().skip(expected_arg_count) { let arg_ty = self.check_expr(&arg); - // There are a few types which get autopromoted when passed via varargs - // in C but we just error out instead and require explicit casts. + // There are a few types that get auto-promoted when passed via varargs + // in C, but we just error out instead and require explicit casts. let arg_ty = self.structurally_resolved_type(arg.span, arg_ty); match arg_ty.sty { ty::Float(ast::FloatTy::F32) => { @@ -3188,7 +3192,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr: &'gcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { let ty = self.check_expr_with_hint(expr, expected); - // checks don't need two phase + // Checks don't need two phases. self.demand_coerce(expr, ty, expected, AllowTwoPhase::No) } @@ -3250,12 +3254,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let origin = self.misc(call_span); let ures = self.at(&origin, self.param_env).sup(ret_ty, &formal_ret); - // FIXME(#27336) can't use ? here, Try::from_error doesn't default - // to identity so the resulting type is not constrained. + // FIXME(#27336): can't use `?` here -- `Try::from_error` doesn't default + // to identity, so the resulting type is not constrained. match ures { Ok(ok) => { // Process any obligations locally as much as - // we can. We don't care if some things turn + // we can. We don't care if some things turn // out unconstrained or ambiguous, as we're // just trying to get hints here. self.save_and_restore_in_snapshot_flag(|_| { @@ -3291,7 +3295,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { needs: Needs) -> Ty<'tcx> { let rcvr = &args[0]; let rcvr_t = self.check_expr_with_needs(&rcvr, needs); - // no need to check for bot/err -- callee does that + // No need to check for bot/err -- callee does that. let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t); let method = match self.lookup_method(rcvr_t, @@ -3485,7 +3489,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - // Check field access expressions + // Check field access expressions. fn check_field(&self, expr: &'gcx hir::Expr, needs: Needs, @@ -3648,13 +3652,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - // Return an hint about the closest match in field names + // Return an hint about the closest match in field names. fn suggest_field_name(variant: &'tcx ty::VariantDef, field: &str, skip: Vec) -> Option { let names = variant.fields.iter().filter_map(|field| { - // ignore already set fields and private fields from non-local crates + // Ignore already-set fields and private fields from non-local crates. if skip.iter().any(|x| *x == field.ident.as_str()) || (variant.did.krate != LOCAL_CRATE && field.vis != Visibility::Public) { None @@ -3676,7 +3680,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn name_series_display(&self, names: Vec) -> String { - // dynamic limit, to never omit just one field + // Use dynamic limit, in order to never omit just one field. let limit = if names.len() == 6 { 6 } else { 5 }; let mut display = names.iter().take(limit) .map(|n| format!("`{}`", n)).collect::>().join(", "); @@ -3714,7 +3718,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } }, ty); - // prevent all specified fields from being suggested + // Prevent all specified fields from being suggested. let skip_fields = skip_fields.iter().map(|ref x| x.ident.as_str()); if let Some(field_name) = Self::suggest_field_name(variant, &field.ident.as_str(), @@ -3761,7 +3765,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let adt_ty_hint = self.expected_inputs_for_expected_output(span, expected, adt_ty, &[adt_ty]) .get(0).cloned().unwrap_or(adt_ty); - // re-link the regions that EIfEO can erase. + // Re-link the regions that EIfEO can erase. self.demand_eqtype(span, adt_ty_hint, adt_ty); let (substs, adt_kind, kind_name) = match &adt_ty.sty { @@ -3873,7 +3877,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn check_struct_path(&self, qpath: &QPath, node_id: ast::NodeId) - -> Option<(&'tcx ty::VariantDef, Ty<'tcx>)> { + -> Option<(&'tcx ty::VariantDef, Ty<'tcx>)> { let path_span = match *qpath { QPath::Resolved(_, ref path) => path.span, QPath::TypeRelative(ref qself, _) => qself.span @@ -3933,7 +3937,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fields: &'gcx [hir::Field], base_expr: &'gcx Option>) -> Ty<'tcx> { - // Find the relevant variant + // Find the relevant variant. let (variant, adt_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, expr.id) { variant_ty @@ -3958,8 +3962,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.id, path_span, variant, fields, base_expr.is_none()); if let &Some(ref base_expr) = base_expr { - // If check_expr_struct_fields hit an error, do not attempt to populate - // the fields with the base_expr. This could cause us to hit errors later + // If `check_expr_struct_fields` hit an error, do not attempt to populate + // the fields with the `base_expr`. This could cause us to hit errors later // when certain fields are assumed to exist that in fact do not. if !error_happened { self.check_expr_has_type_or_error(base_expr, adt_ty); @@ -3985,14 +3989,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { adt_ty } - /// Invariant: /// If an expression has any sub-expressions that result in a type error, /// inspecting that expression's type with `ty.references_error()` will return /// true. Likewise, if an expression is known to diverge, inspecting its - /// type with `ty::type_is_bot` will return true (n.b.: since Rust is - /// strict, _|_ can appear in the type of an expression that does not, - /// itself, diverge: for example, fn() -> _|_.) + /// type with `ty::type_is_bot` will return true (N.B., since Rust is + /// strict, `_|_` can appear in the type of an expression that does not + /// itself diverge, e.g., `fn() -> _|_`.) /// Note that inspecting a type's structure *directly* may expose the fact /// that there are actually multiple representations for `Error`, so avoid /// that when err needs to be handled differently. @@ -4006,7 +4009,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Warn for expressions after diverging siblings. self.warn_if_unreachable(expr.id, expr.span, "expression"); - // Hide the outer diverging and has_errors flags. + // Hide the outer diverging and `has_errors` flags. let old_diverges = self.diverges.get(); let old_has_errors = self.has_errors.get(); self.diverges.set(Diverges::Maybe); @@ -4023,7 +4026,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => self.warn_if_unreachable(expr.id, expr.span, "expression") } - // Any expression that produces a value of type `!` must have diverged + // Any expression that produces a value of type `!` must have diverged. if ty.is_never() { self.diverges.set(self.diverges.get() | Diverges::Always); } @@ -4033,7 +4036,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // we don't warn for the diverging expression itself. self.write_ty(expr.hir_id, ty); - // Combine the diverging and has_error flags. + // Combine the diverging and `has_error` flags. self.diverges.set(self.diverges.get() | old_diverges); self.has_errors.set(self.has_errors.get() | old_has_errors); @@ -4172,14 +4175,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.types.err } else { // Note: at this point, we cannot say what the best lifetime - // is to use for resulting pointer. We want to use the + // is to use for resulting pointer. We want to use the // shortest lifetime possible so as to avoid spurious borrowck - // errors. Moreover, the longest lifetime will depend on the + // errors. Moreover, the longest lifetime will depend on the // precise details of the value whose address is being taken // (and how long it is valid), which we don't know yet until type // inference is complete. // - // Therefore, here we simply generate a region variable. The + // Therefore, here we simply generate a region variable. The // region inferencer will then select the ultimate value. // Finally, borrowck is charged with guaranteeing that the // value whose address was taken can actually be made to live @@ -4207,11 +4210,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !tcx.features().unsized_locals { // We want to remove some Sized bounds from std functions, // but don't want to expose the removal to stable Rust. - // i.e., we don't want to allow + // I.e., we don't want to allow // - // ```rust - // drop as fn(str); - // ``` + // drop as fn(str); // // to work in stable even if the Sized bound on `drop` is relaxed. for i in 0..fn_sig.inputs().skip_binder().len() { @@ -4295,7 +4296,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } else { // If `ctxt.coerce` is `None`, we can just ignore - // the type of the expresison. This is because + // the type of the expresison. This is because // either this was a break *without* a value, in // which case it is always a legal type (`()`), or // else an error would have been flagged by the @@ -4306,7 +4307,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ctxt.may_break = true; - // the type of a `break` is always `!`, since it diverges + // The type of a `break` is always `!`, since it diverges. tcx.types.never } else { // Otherwise, we failed to find the enclosing loop; @@ -4331,7 +4332,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - // There was an error; make type-check fail. + // There was an error; make type-checking fail. tcx.types.err } @@ -4340,7 +4341,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if destination.target_id.is_ok() { tcx.types.never } else { - // There was an error; make type-check fail. + // There was an error; make type-checking fail. tcx.types.err } } @@ -4416,9 +4417,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } ExprKind::While(ref cond, ref body, _) => { let ctxt = BreakableCtxt { - // cannot use break with a value from a while loop + // Cannot use break with a value from a while loop. coerce: None, - may_break: false, // Will get updated if/when we find a `break`. + // Will get updated if/when we find a `break`. + may_break: false, }; let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || { @@ -4440,7 +4442,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } ExprKind::Loop(ref body, _, source) => { let coerce = match source { - // you can only use break with a value from a normal `loop { }` + // Can only use `break` with a value from a normal `loop { }`. hir::LoopSource::Loop => { let coerce_to = expected.coercion_target_type(self, body.span); Some(CoerceMany::new(coerce_to)) @@ -4454,7 +4456,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let ctxt = BreakableCtxt { coerce, - may_break: false, // Will get updated if/when we find a `break`. + // Will get updated if/when we find a `break`. + may_break: false, }; let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || { @@ -4588,8 +4591,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Ok(count) = count { let zero_or_one = count.assert_usize(tcx).map_or(false, |count| count <= 1); if !zero_or_one { - // For [foo, ..n] where n > 1, `foo` must have - // Copy type: + // For [foo, ..n] where n > 1, `foo` must have `Copy` type. let lang_item = self.tcx.require_lang_item(lang_items::CopyTraitLangItem); self.require_type_meets(t, expr.span, traits::RepeatVec, lang_item); } @@ -4651,7 +4653,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let base_t = self.structurally_resolved_type(base.span, base_t); match self.lookup_indexing(expr, base, base_t, idx_t, needs) { Some((index_ty, element_ty)) => { - // two-phase not needed because index_ty is never mutable + // Two-phase not needed because `index_ty` is never mutable. self.demand_coerce(idx, idx_t, index_ty, AllowTwoPhase::No); element_ty } @@ -4938,7 +4940,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.check_stmt(s); } - // check the tail expression **without** holding the + // Check the tail expression **without** holding the // `enclosing_breakables` lock below. let tail_expr_ty = tail_expr.map(|t| self.check_expr_with_expectation(t, expected)); @@ -4998,7 +5000,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if ctxt.may_break { // If we can break from the block, then the block's exit is always reachable - // (... as long as the entry is reachable) - regardless of the tail of the block. + // (as long as the entry is reachable), regardless of the tail of the block. self.diverges.set(prev_diverges); } @@ -5407,7 +5409,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); if suppress_errors { infer_args_for_err.insert(index); - self.set_tainted_by_errors(); // See issue #53251. + // See issue #53251. + self.set_tainted_by_errors(); } } @@ -5433,14 +5436,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(adt_def) = adt_def { match adt_def.adt_kind() { AdtKind::Enum => { - err.help("did you mean to use one of the enum's variants?"); + err.note("did you mean to use one of the enum's variants?"); }, AdtKind::Struct | AdtKind::Union => { err.span_suggestion( span, "use curly brackets", - String::from("Self { /* fields */ }"), + "Self { /* fields */ }".to_owned(), Applicability::HasPlaceholders, ); } @@ -5454,7 +5457,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } _ => { let def_id = def.def_id(); - // The things we are substituting into the type should not contain // escaping late-bound regions, and nor should the base type scheme. let ty = tcx.type_of(def_id); @@ -5578,7 +5580,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { node_id: ast::NodeId, span: Span) { // We're only interested in functions tagged with - // #[rustc_args_required_const], so ignore anything that's not. + // `#[rustc_args_required_const]`, so ignore anything that's not. if !self.tcx.has_attr(def_id, "rustc_args_required_const") { return } @@ -5717,12 +5719,12 @@ fn fatally_break_rust(sess: &Session) { let handler = sess.diagnostic(); handler.span_bug_no_panic( MultiSpan::new(), - "It looks like you're trying to break rust; would you like some ICE?", + "It looks like you're trying to break Rust; would you like some ICE?", ); handler.note_without_error("the compiler expectedly panicked. this is a feature."); handler.note_without_error( "we would appreciate a joke overview: \ - https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675" + " ); handler.note_without_error(&format!("rustc {} running on {}", option_env!("CFG_VERSION").unwrap_or("unknown_version"), diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 9b1a656b1bc98..dae53e7f5c9d2 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -1,4 +1,4 @@ -//! Code related to processing overloaded binary and unary operators. +//! Processing of overloaded binary and unary operators. use super::{FnCtxt, Needs}; use super::method::MethodCallee; @@ -164,7 +164,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`. let lhs_ty = self.check_expr_with_needs(lhs_expr, Needs::None); let fresh_var = self.next_ty_var(TypeVariableOrigin::MiscVariable(lhs_expr.span)); - self.demand_coerce(lhs_expr, lhs_ty, fresh_var, AllowTwoPhase::No) + self.demand_coerce(lhs_expr, lhs_ty, fresh_var, AllowTwoPhase::No) } IsAssign::Yes => { // rust-lang/rust#52126: We have to use strict @@ -224,7 +224,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[1] }; - // HACK(eddyb) Bypass checks due to reborrows being in + // HACK(eddyb): bypass checks due to reborrows being in // some cases applied on the RHS, on top of which we need // to autoref, which is not allowed by apply_adjustments. // self.apply_adjustments(rhs_expr, vec![autoref]); diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 792f8eaacd290..5dc31ace25c02 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -121,12 +121,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.param_env, ); - // There are no add'l implied bounds when checking a + // There are no additional implied bounds when checking a // standalone expr (e.g., the `E` in a type like `[u32; E]`). rcx.outlives_environment.save_implied_bounds(id); if self.err_count_since_creation() == 0 { - // regionck assumes typeck succeeded + // regionck assumes typeck succeeded. rcx.visit_body(body); rcx.visit_region_obligations(id); } @@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if self.err_count_since_creation() == 0 { let fn_hir_id = self.tcx.hir().node_to_hir_id(fn_id); - // regionck assumes typeck succeeded + // regionck assumes typeck succeeded. rcx.visit_fn_body(fn_hir_id, body, self.tcx.hir().span_by_hir_id(fn_hir_id)); } @@ -302,11 +302,12 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { /// `intravisit::Visitor` impl below.) fn visit_fn_body( &mut self, - id: hir::HirId, // the id of the fn itself + // The ID of the fn itself. + id: hir::HirId, body: &'gcx hir::Body, span: Span, ) { - // When we enter a function, we can derive + // When we enter a function, we can derive. debug!("visit_fn_body(id={:?})", id); let body_id = body.id(); @@ -321,9 +322,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { let fn_sig = { match self.tables.borrow().liberated_fn_sigs().get(id) { Some(f) => f.clone(), - None => { - bug!("No fn-sig entry for id={:?}", id); - } + None => bug!("no fn-sig entry for id={:?}", id), } }; @@ -331,7 +330,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { // For the return type, if diverging, substitute `bool` just // because it will have no effect. // - // FIXME(#27579) return types should not be implied bounds + // FIXME(#27579): return types should not be implied bounds. let fn_sig_tys: Vec<_> = fn_sig .inputs() .iter() @@ -359,7 +358,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { let call_site_scope = self.call_site_scope.unwrap(); debug!( - "visit_fn_body body.id {:?} call_site_scope: {:?}", + "visit_fn_body: body.id={:?} call_site_scope={:?}", body.id(), call_site_scope ); @@ -438,7 +437,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { } impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { - // (..) FIXME(#3238) should use visit_pat, not visit_arm/visit_local, + // (..) FIXME(#3238): should use `visit_pat`, not `visit_arm`/`visit_local`, // However, right now we run into an issue whereby some free // regions are not properly related if they appear within the // types of arguments that must be inferred. This could be @@ -467,7 +466,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { ); // Save state of current function before invoking - // `visit_fn_body`. We will restore afterwards. + // `visit_fn_body`. We will restore afterwards. let old_body_id = self.body_id; let old_call_site_scope = self.call_site_scope; let env_snapshot = self.outlives_environment.push_snapshot_pre_closure(); @@ -477,16 +476,15 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { self.visit_fn_body(hir_id, body, span); // Restore state from previous function. - self.outlives_environment - .pop_snapshot_post_closure(env_snapshot); + self.outlives_environment.pop_snapshot_post_closure(env_snapshot); self.call_site_scope = old_call_site_scope; self.body_id = old_body_id; } - //visit_pat: visit_pat, // (..) see above + // visit_pat: visit_pat, // (..) see above fn visit_arm(&mut self, arm: &'gcx hir::Arm) { - // see above + // See above. for p in &arm.pats { self.constrain_bindings_in_pat(p); } @@ -494,7 +492,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { } fn visit_local(&mut self, l: &'gcx hir::Local) { - // see above + // See above. self.constrain_bindings_in_pat(&l.pat); self.link_local(l); intravisit::walk_local(self, l); @@ -550,7 +548,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { self.check_safety_of_rvalue_destructor_if_necessary(&head_cmt, expr.span); } Err(..) => { - self.tcx.sess.delay_span_bug(expr.span, "cat_expr Errd"); + self.tcx.sess.delay_span_bug(expr.span, "cat_expr errored"); } } @@ -646,7 +644,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { hir::ExprKind::Cast(ref source, _) => { // Determine if we are casting `source` to a trait - // instance. If so, we have to be sure that the type of + // instance. If so, we have to be sure that the type of // the source obeys the trait's region bound. self.constrain_cast(expr, &source); intravisit::walk_expr(self, expr); @@ -798,7 +796,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { // `callee_region` is the scope representing the time in which the // call occurs. // - // FIXME(#6268) to support nested method calls, should be callee_id + // FIXME(#6268): to support nested method calls, should be `callee_id`. let callee_scope = region::Scope { id: call_expr.hir_id.local_id, data: region::ScopeData::Node, @@ -894,7 +892,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { &cmt, ); - // Specialized version of constrain_call. + // Specialized version of `constrain_call`. self.type_must_outlive(infer::CallRcvr(expr.span), input, expr_region); self.type_must_outlive(infer::CallReturn(expr.span), output, expr_region); } @@ -905,7 +903,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { // Require that the resulting region encompasses // the current node. // - // FIXME(#6268) remove to support nested method calls + // FIXME(#6268): remove to support nested method calls. self.type_of_node_must_outlive( infer::AutoBorrow(expr.span), expr.hir_id, @@ -997,7 +995,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { hir_id: hir::HirId, minimum_lifetime: ty::Region<'tcx>, ) { - // Try to resolve the type. If we encounter an error, then typeck + // Try to resolve the type. If we encounter an error, then typeck // is going to fail anyway, so just stop here and let typeck // report errors later on in the writeback phase. let ty0 = self.resolve_node_type(hir_id); @@ -1367,7 +1365,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { // ref_cmt ^~~ // // (Note that since we have not examined `ref_cmt.cat`, we don't - // know whether this scenario has occurred; but I wanted to show + // know whether this scenario has occurred, but I wanted to show // how all the types get adjusted.) match ref_kind { ty::ImmBorrow => { diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 1816b7454dd2d..562d113567dff 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -153,9 +153,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .upvar_capture_map .insert(upvar_id, capture_kind); } - // Add the vector of freevars to the map keyed with the closure id. + // Add the vector of freevars to the map keyed with the closure ID. // This gives us an easier access to them without having to call - // with_freevars again.. + // `with_freevars` again. if !freevar_list.is_empty() { self.tables .borrow_mut() @@ -283,7 +283,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { struct InferBorrowKind<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, - // The def-id of the closure whose kind and upvar accesses are being inferred. + // The `DefId` of the closure whose kind and upvar accesses are being inferred. closure_def_id: DefId, // The kind that we have inferred that the current closure diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 86b2e0bfe8aef..3d4945c2bb05f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -1,21 +1,19 @@ -use crate::check::{Inherited, FnCtxt}; -use crate::constrained_type_params::{identify_constrained_type_params, Parameter}; - -use crate::hir::def_id::DefId; +use errors::{DiagnosticBuilder, DiagnosticId}; +use rustc::hir; +use rustc::hir::def_id::DefId; +use rustc::hir::itemlikevisit::ItemLikeVisitor; +use rustc::infer::opaque_types::may_define_existential_type; +use rustc::middle::lang_items; use rustc::traits::{self, ObligationCauseCode}; use rustc::ty::{self, Lift, Ty, TyCtxt, TyKind, GenericParamDefKind, TypeFoldable, ToPredicate}; use rustc::ty::subst::{Subst, Substs}; use rustc::util::nodemap::{FxHashSet, FxHashMap}; -use rustc::middle::lang_items; -use rustc::infer::opaque_types::may_define_existential_type; - +use syntax_pos::Span; use syntax::ast; use syntax::feature_gate::{self, GateIssue}; -use syntax_pos::Span; -use errors::{DiagnosticBuilder, DiagnosticId}; -use rustc::hir::itemlikevisit::ItemLikeVisitor; -use rustc::hir; +use crate::check::{Inherited, FnCtxt}; +use crate::constrained_type_params::{identify_constrained_type_params, Parameter}; /// Helper type of a temporary returned by `.for_item(...)`. /// Necessary because we can't write the following bound: @@ -96,7 +94,7 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def if polarity == hir::ImplPolarity::Positive { check_impl(tcx, item, self_ty, trait_ref); } else { - // FIXME(#27579) what amount of WF checking do we need for neg impls? + // FIXME(#27579): what amount of WF checking do we need for neg impls? if trait_ref.is_some() && !is_auto { span_err!(tcx.sess, item.span, E0192, "negative impls are only allowed for \ @@ -210,7 +208,7 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } ty::AssociatedKind::Existential => { - // do nothing, existential types check themselves + // Do nothing; existential types check themselves. } } @@ -298,7 +296,8 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, check_where_clauses(tcx, fcx, item.span, def_id, None); - vec![] // no implied bounds in a struct def'n + // No implied bounds in a struct definiton. + vec![] }); } @@ -365,7 +364,8 @@ fn check_item_type<'a, 'tcx>( ); } - vec![] // no implied bounds in a const etc + // No implied bounds in a const, etc. + vec![] }); } @@ -432,7 +432,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( } }; - // Check that concrete defaults are well-formed. See test `type-check-defaults.rs`. + // Checks that concrete defaults are well-formed. See test `type-check-defaults.rs`. // For example this forbids the declaration: // struct Foo> { .. } // Here the default `Vec<[u32]>` is not WF because `[u32]: Sized` does not hold. @@ -451,10 +451,10 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( } } - // Check that trait predicates are WF when params are substituted by their defaults. + // Checks that trait predicates are WF when params are substituted by their defaults. // We don't want to overly constrain the predicates that may be written but we want to // catch cases where a default my never be applied such as `struct Foo`. - // Therefore we check if a predicate which contains a single type param + // Therefore, we check if a predicate which contains a single type param // with a concrete default is WF with that default substituted. // For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`. // @@ -568,7 +568,7 @@ fn check_fn_or_method<'a, 'fcx, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, fcx.register_wf_obligation(sig.output(), span, ObligationCauseCode::MiscObligation); - // FIXME(#25759) return types should not be implied bounds + // FIXME(#25759): return types should not be implied bounds. implied_bounds.push(sig.output()); check_where_clauses(tcx, fcx, span, def_id, Some(sig.output())); @@ -929,7 +929,7 @@ fn report_bivariance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut err = error_392(tcx, span, param_name); let suggested_marker_id = tcx.lang_items().phantom_data(); - // help is available only in presence of lang items + // Help is available only in presence of lang items. if let Some(def_id) = suggested_marker_id { err.help(&format!("consider removing `{}` or using a marker such as `{}`", param_name, @@ -947,16 +947,16 @@ fn reject_shadowing_parameters(tcx: TyCtxt, def_id: DefId) { }).collect(); for method_param in &generics.params { - // Shadowing is checked in resolve_lifetime. + // Shadowing is checked in `resolve_lifetime`. if let GenericParamDefKind::Lifetime = method_param.kind { continue } if impl_params.contains_key(&method_param.name) { - // Tighten up the span to focus on only the shadowing type + // Tighten up the span to focus on only the shadowing type. let type_span = tcx.def_span(method_param.def_id); // The expectation here is that the original trait declaration is - // local so it should be okay to just unwrap everything. + // local so it should be ok to just unwrap everything. let trait_def_id = impl_params[&method_param.name]; let trait_decl_span = tcx.def_span(trait_def_id); error_194(tcx, type_span, trait_decl_span, &method_param.name.as_str()[..]); @@ -980,7 +980,7 @@ fn check_false_global_bounds<'a, 'gcx, 'tcx>( .iter() .map(|(p, _)| *p) .collect(); - // Check elaborated bounds + // Check elaborated bounds. let implied_obligations = traits::elaborate_predicates(fcx.tcx, predicates); for pred in implied_obligations { diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index e68c50d752bd5..931479c46f81b 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -2,8 +2,10 @@ // unresolved type variables and replaces "ty_var" types with their // substitutions. -use crate::check::FnCtxt; +use std::mem; + use errors::DiagnosticBuilder; +use rustc_data_structures::sync::Lrc; use rustc::hir; use rustc::hir::def_id::{DefId, DefIndex}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; @@ -13,10 +15,10 @@ use rustc::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; use rustc::ty::subst::UnpackedKind; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::DefIdSet; -use rustc_data_structures::sync::Lrc; -use std::mem; -use syntax::ast; use syntax_pos::Span; +use syntax::ast; + +use crate::check::FnCtxt; /////////////////////////////////////////////////////////////////////////// // Entry point @@ -219,7 +221,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { // This is the master code which walks the AST. It delegates most of // the heavy lifting to the generic visit and resolve functions // below. In general, a function is made into a `visitor` if it must -// traffic in node-ids or update tables in the type context etc. +// traffic in `NodeId`s or update tables in the type context etc. impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { @@ -456,38 +458,38 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { let generics = self.tcx().generics_of(def_id); let definition_ty = if generics.parent.is_some() { - // impl trait + // `impl Trait` self.fcx.infer_opaque_definition_from_instantiation( def_id, opaque_defn, instantiated_ty, ) } else { - // prevent + // Prevent: // * `fn foo() -> Foo` // * `fn foo() -> Foo` - // from being defining + // from being defining. // Also replace all generic params with the ones from the existential type - // definition so + // definition so that // ```rust // existential type Foo: 'static; // fn foo() -> Foo { .. } // ``` - // figures out the concrete type with `U`, but the stored type is with `T` + // figures out the concrete type with `U`, but the stored type is with `T`. instantiated_ty.fold_with(&mut BottomUpFolder { tcx: self.tcx().global_tcx(), fldop: |ty| { trace!("checking type {:?}: {:#?}", ty, ty.sty); - // find a type parameter + // Find a type parameter. if let ty::Param(..) = ty.sty { - // look it up in the substitution list + // Look it up in the substitution list. assert_eq!(opaque_defn.substs.len(), generics.params.len()); for (subst, param) in opaque_defn.substs.iter().zip(&generics.params) { if let UnpackedKind::Type(subst) = subst.unpack() { if subst == ty { - // found it in the substitution list, replace with the - // parameter from the existential type + // Found it in the substitution list; replace with the + // parameter from the existential type. return self.tcx() .global_tcx() .mk_ty_param(param.index, param.name); @@ -511,15 +513,15 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { }, reg_op: |region| { match region { - // ignore static regions + // Ignore static regions. ty::ReStatic => region, _ => { trace!("checking {:?}", region); for (subst, p) in opaque_defn.substs.iter().zip(&generics.params) { if let UnpackedKind::Lifetime(subst) = subst.unpack() { if subst == region { - // found it in the substitution list, replace with the - // parameter from the existential type + // Found it in the substitution list; replace with the + // parameter from the existential type. let reg = ty::EarlyBoundRegion { def_id: p.def_id, index: p.index, @@ -558,8 +560,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { if let ty::Opaque(defin_ty_def_id, _substs) = definition_ty.sty { if def_id == defin_ty_def_id { - // Concrete type resolved to the existential type itself - // Force a cycle error + // Concrete type resolved to the existential type itself. + // Force a cycle error. self.tcx().at(span).type_of(defin_ty_def_id); } } @@ -571,8 +573,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { if old != definition_ty { span_bug!( span, - "visit_opaque_types tried to write \ - different types for the same existential type: {:?}, {:?}, {:?}", + "`visit_opaque_types` tried to write \ + different types for the same existential type: {:?}, {:?}, {:?}", def_id, definition_ty, old, @@ -605,10 +607,10 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { self.tables.type_dependent_defs_mut().insert(hir_id, def); } - // Resolve any borrowings for the node with id `node_id` + // Resolve any borrowings for the node with ID `node_id` self.visit_adjustments(span, hir_id); - // Resolve the type of the node with id `node_id` + // Resolve the type of the node with ID `node_id` let n_ty = self.fcx.node_ty(hir_id); let n_ty = self.resolve(&n_ty, &span); self.write_ty_to_tables(hir_id, n_ty); @@ -802,8 +804,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Resolver<'cx, 'gcx, 'tcx> { } } - // FIXME This should be carefully checked - // We could use `self.report_error` but it doesn't accept a ty::Region, right now. + // FIXME: this should be carefully checked. + // We could use `self.report_error`, but it doesn't accept a `ty::Region` right now. fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { self.infcx.fully_resolve(&r).unwrap_or(self.tcx.types.re_static) } diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 70f7c30f7ecb6..3f9108d026aeb 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -74,7 +74,7 @@ impl<'a, 'tcx> CheckVisitor<'a, 'tcx> { fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { let lint = lint::builtin::UNUSED_EXTERN_CRATES; - // Collect first the crates that are completely unused. These we + // Collect first the crates that are completely unused. These we // can always suggest removing (no matter which edition we are // in). let unused_extern_crates: FxHashMap = diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 0996d1ff3b998..f149b7c62a63b 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -1,21 +1,18 @@ //! Check properties that are required by built-in traits and set //! up data structures required by type-checking/codegen. +use rustc::hir::{self, ItemKind, Node}; +use rustc::hir::def_id::DefId; +use rustc::infer; use rustc::infer::SuppressRegionErrors; use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::middle::region; use rustc::middle::lang_items::UnsizeTraitLangItem; - use rustc::traits::{self, TraitEngine, ObligationCause}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::TypeFoldable; use rustc::ty::adjustment::CoerceUnsizedInfo; use rustc::ty::util::CopyImplementationError; -use rustc::infer; - -use rustc::hir::def_id::DefId; -use hir::Node; -use rustc::hir::{self, ItemKind}; pub fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId) { Checker { tcx, trait_def_id } @@ -47,7 +44,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: DefId) { if let ty::Adt(..) = tcx.type_of(impl_did).sty { - /* do nothing */ + // Do nothing. } else { // Destructors only work on nominal types. if let Some(impl_node_id) = tcx.hir().as_local_node_id(impl_did) { @@ -331,9 +328,9 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, gcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err)); }); - // this provider should only get invoked for local def-ids + // This provider should only get invoked for local `DefId`s. let impl_hir_id = gcx.hir().as_local_hir_id(impl_did).unwrap_or_else(|| { - bug!("coerce_unsized_info: invoked for non-local def-id {:?}", impl_did) + bug!("coerce_unsized_info: invoked for non-local `DefId` {:?}", impl_did) }); let source = gcx.type_of(impl_did); @@ -419,7 +416,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, // when this coercion occurs, we would be changing the // field `ptr` from a thin pointer of type `*mut [i32; // 3]` to a fat pointer of type `*mut [i32]` (with - // extra data `3`). **The purpose of this check is to + // extra data `3`). **The purpose of this check is to // make sure that we know how to do this conversion.** // // To check if this impl is legal, we would walk down @@ -467,7 +464,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, } // Collect up all fields that were significantly changed - // i.e., those that contain T in coerce_unsized T -> U + // i.e., those that contain `T` in `coerce_unsized T -> U`. Some((i, a, b)) }) .collect::>(); diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 93cc86423ace3..8a68d0ad5d2cb 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -38,9 +38,9 @@ pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Lrc> { assert!(ty_def_id.is_local()); - // NB. Until we adopt the red-green dep-tracking algorithm (see + // N.B., until we adopt the red-green dep-tracking algorithm (see // [the plan] for details on that), we do some hackery here to get - // the dependencies correct. Basically, we use a `with_ignore` to + // the dependencies correct. Basically, we use a `with_ignore` to // read the result we want. If we didn't have the `with_ignore`, // we would wind up with a dependency on the entire crate, which // we don't want. Then we go and add dependencies on all the impls @@ -286,7 +286,7 @@ impl<'a, 'tcx> InherentCollect<'a, 'tcx> { fn check_def_id(&mut self, item: &hir::Item, def_id: DefId) { if def_id.is_local() { // Add the implementation to the mapping from implementation to base - // type def ID, if there is a base type for this implementation and + // type `DefId`, if there is a base type for this implementation and // the implementation does not have any associated traits. let impl_def_id = self.tcx.hir().local_def_id(item.id); let mut rc_vec = self.impls_map.inherent_impls diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 24e5ca989c4b2..b314b830c6925 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -1,6 +1,6 @@ -// Coherence phase +// The coherence phase of type-checking. // -// The job of the coherence phase of typechecking is to ensure that +// The job of the coherence phase of type-checking is to ensure that // each trait has at most one implementation for each type. This is // done by the orphan and overlap modules. Then we build up various // mappings. That mapping code resides here. @@ -171,8 +171,8 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI // check for overlap with the automatic `impl Trait for Trait` if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().sty { - // This is something like impl Trait1 for Trait2. Illegal - // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. + // This is something like `impl Trait1 for Trait2`. Illegal + // if `Trait1` is a supertrait of `Trait2` or `Trait2` is not object safe. let component_def_ids = data.iter().flat_map(|predicate| { match predicate.skip_binder() { @@ -186,7 +186,7 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI for component_def_id in component_def_ids { if !tcx.is_object_safe(component_def_id) { - // This is an error, but it will be reported by wfcheck. Ignore it here. + // This is an error, but it will be reported by wfcheck. Ignore it here. // This is tested by `coherence-impl-trait-for-trait-object-safe.rs`. } else { let mut supertrait_def_ids = diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 4a2d526263c03..13245a87bf963 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1,6 +1,6 @@ //! "Collection" is the process of determining the type and other external //! details of each item in Rust. Collection is specifically concerned -//! with *interprocedural* things -- for example, for a function +//! with *interprocedural* things; for example, for a function //! definition, collection will figure out the type and signature of the //! function, but it will not visit the *body* of the function in any way, //! nor examine type annotations on local variables (that's the job of @@ -14,41 +14,37 @@ //! At present, however, we do run collection across all items in the //! crate as a kind of pass. This should eventually be factored away. -use crate::astconv::{AstConv, Bounds}; -use crate::constrained_type_params as ctp; -use crate::check::intrinsic::intrisic_operation_unsafety; -use crate::lint; -use crate::middle::lang_items::SizedTraitLangItem; -use crate::middle::resolve_lifetime as rl; -use crate::middle::weak_lang_items; +use std::iter; + +use rustc_data_structures::sync::Lrc; +use rustc_target::spec::abi; +use rustc::hir::{GenericParamKind, Node}; +use rustc::hir::def::{CtorKind, Def}; +use rustc::hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety}; use rustc::mir::mono::Linkage; +use rustc::ty::{self, AdtKind, ReprOptions, ToPolyTraitRef, ToPredicate, Ty, TyCtxt}; use rustc::ty::query::Providers; use rustc::ty::subst::Substs; -use rustc::ty::util::Discr; -use rustc::ty::util::IntTypeExt; -use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt}; -use rustc::ty::{ReprOptions, ToPredicate}; +use rustc::ty::util::{Discr, IntTypeExt}; use rustc::util::captures::Captures; use rustc::util::nodemap::FxHashMap; -use rustc_data_structures::sync::Lrc; -use rustc_target::spec::abi; - +use syntax_pos::{Span, DUMMY_SP}; use syntax::ast; use syntax::ast::{Ident, MetaItemKind}; use syntax::attr::{InlineAttr, OptimizeAttr, list_contains_name, mark_used}; use syntax::source_map::Spanned; use syntax::feature_gate; use syntax::symbol::{keywords, Symbol}; -use syntax_pos::{Span, DUMMY_SP}; -use rustc::hir::def::{CtorKind, Def}; -use rustc::hir::Node; -use rustc::hir::def_id::{DefId, LOCAL_CRATE}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc::hir::GenericParamKind; -use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety}; - -use std::iter; +use crate::astconv::{AstConv, Bounds}; +use crate::constrained_type_params as ctp; +use crate::check::intrinsic::intrisic_operation_unsafety; +use crate::lint; +use crate::middle::lang_items::SizedTraitLangItem; +use crate::middle::resolve_lifetime as rl; +use crate::middle::weak_lang_items; struct OnlySelfBounds(bool); @@ -226,17 +222,17 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> { } fn normalize_ty(&self, _span: Span, ty: Ty<'tcx>) -> Ty<'tcx> { - // types in item signatures are not normalized, to avoid undue + // Types in item signatures are not normalized, to avoid undue // dependencies. ty } fn set_tainted_by_errors(&self) { - // no obvious place to track this, just let it go + // No obvious place to track this; just let it go. } fn record_ty(&self, _hir_id: hir::HirId, _ty: Ty<'tcx>, _span: Span) { - // no place to record types from signatures? + // No place to record types from signatures? } } @@ -247,8 +243,8 @@ fn type_param_predicates<'a, 'tcx>( use rustc::hir::*; // In the AST, bounds can derive from two places. Either - // written inline like `` or in a where clause like - // `where T : Foo`. + // written inline like `` or in a where-clause like + // `where T: Foo`. let param_id = tcx.hir().as_local_node_id(def_id).unwrap(); let param_owner = tcx.hir().ty_param_owner(param_id); @@ -452,7 +448,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { } } - // Desugared from `impl Trait` -> visited by the function's return type + // Desugared from `impl Trait`, so visited by the function's return type. hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. @@ -644,7 +640,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad ) } ItemKind::Struct(ref def, _) => { - // Use separate constructor id for unit/tuple structs and reuse did for braced structs. + // Use separate constructor ID for unit/tuple structs and reuse did for braced structs. let ctor_id = if !def.is_struct() { Some(tcx.hir().local_def_id(def.id())) } else { @@ -703,15 +699,15 @@ fn super_predicates_of<'a, 'tcx>( let icx = ItemCtxt::new(tcx, trait_def_id); - // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo : Bar + Zed`. + // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. let self_param_ty = tcx.mk_self_type(); let superbounds1 = compute_bounds(&icx, self_param_ty, bounds, SizedByDefault::No, item.span); let superbounds1 = superbounds1.predicates(tcx, self_param_ty); - // Convert any explicit superbounds in the where clause, - // e.g., `trait Foo where Self : Bar`. - // In the case of trait aliases, however, we include all bounds in the where clause, + // Convert any explicit superbounds in the where-clause, + // e.g., `trait Foo where Self: Bar`. + // In the case of trait aliases, however, we include all bounds in the where-clause, // so e.g., `trait Foo = where u32: PartialEq` would include `u32: PartialEq` // as one of its "superpredicates". let is_trait_alias = tcx.is_trait_alias(trait_def_id); @@ -929,8 +925,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty | ItemKind::TraitAlias(ref generics, ..) => { // Add in the self type parameter. // - // Something of a hack: use the node id for the trait, also as - // the node id for the Self type parameter. + // Something of a hack: use the `NodeId` for the trait, also as + // the `NodeId` for the Self type parameter. let param_id = item.id; opt_self = Some(ty::GenericParamDef { @@ -1183,7 +1179,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { impl_trait_fn: None, .. }) => find_existential_constraints(tcx, def_id), - // existential types desugared from impl Trait + // Existential types desugared from `impl Trait`. ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(owner), .. @@ -1320,6 +1316,8 @@ fn find_existential_constraints<'a, 'tcx>( ) -> ty::Ty<'tcx> { use rustc::hir::*; + debug!("find_existential_constraints({:?})", def_id); + struct ConstraintLocator<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, @@ -1345,7 +1343,7 @@ fn find_existential_constraints<'a, 'tcx>( let span = self.tcx.def_span(def_id); if let Some((prev_span, prev_ty)) = self.found { if ty != prev_ty { - // found different concrete types for the existential type + // Found different concrete types for the existential type. let mut err = self.tcx.sess.struct_span_err( span, "defining existential type use differs from previous", @@ -1366,7 +1364,7 @@ fn find_existential_constraints<'a, 'tcx>( } fn visit_item(&mut self, it: &'tcx Item) { let def_id = self.tcx.hir().local_def_id(it.id); - // the existential type itself or its children are not within its reveal scope + // The existential type itself or its children are not within its reveal scope. if def_id != self.def_id { self.check(def_id); intravisit::walk_item(self, it); @@ -1374,7 +1372,7 @@ fn find_existential_constraints<'a, 'tcx>( } fn visit_impl_item(&mut self, it: &'tcx ImplItem) { let def_id = self.tcx.hir().local_def_id(it.id); - // the existential type itself or its children are not within its reveal scope + // The existential type itself or its children are not within its reveal scope. if def_id != self.def_id { self.check(def_id); intravisit::walk_impl_item(self, it); @@ -1529,7 +1527,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> hir::I } } -// Is it marked with ?Sized +// Returns whether the given bounds include `?Sized`. fn is_unsized<'gcx: 'tcx, 'tcx>( astconv: &dyn AstConv<'gcx, 'tcx>, ast_bounds: &[hir::GenericBound], @@ -1558,7 +1556,7 @@ fn is_unsized<'gcx: 'tcx, 'tcx>( let kind_id = tcx.lang_items().require(SizedTraitLangItem); match unbound { Some(ref tpb) => { - // FIXME(#8559) currently requires the unbound to be built-in. + // FIXME(#8559): currently requires the unbound to be built-in. if let Ok(kind_id) = kind_id { if tpb.path.def != Def::Trait(kind_id) { tcx.sess.span_warn( @@ -1646,7 +1644,7 @@ fn predicates_of<'a, 'tcx>( // is something that one must prove in order to invoke a // method or project an associated type. // - // In the chalk setup, this predicate is not part of the + // In the Chalk setup, this predicate is not part of the // "predicates" for a trait item. But it is useful in // rustc because if you directly (e.g.) invoke a trait // method like `Trait::method(...)`, you must naturally @@ -1819,7 +1817,7 @@ fn explicit_predicates_of<'a, 'tcx>( // // default impl Foo for Bar { .. } // - // we add a default where clause `Foo: Bar`. We do a similar thing for traits + // we add a default where-clause `Foo: Bar`. We do a similar thing for traits // (see below). Recall that a default impl is not itself an impl, but rather a // set of defaults that can be incorporated into another impl. if let Some(trait_ref) = is_default_impl_trait { @@ -1854,7 +1852,7 @@ fn explicit_predicates_of<'a, 'tcx>( } // Collect the predicates that were written inline by the user on each - // type parameter (e.g., ``). + // type parameter (e.g., ``). for param in &ast_generics.params { if let GenericParamKind::Type { .. } = param.kind { let name = param.name.ident().as_interned_str(); @@ -1867,7 +1865,7 @@ fn explicit_predicates_of<'a, 'tcx>( } } - // Add in the bounds that appear in the where-clause + // Add in the bounds that appear in the where-clause. let where_clause = &ast_generics.where_clause; for predicate in &where_clause.predicates { match predicate { @@ -1969,8 +1967,8 @@ fn explicit_predicates_of<'a, 'tcx>( let mut predicates = predicates.predicates; // Subtle: before we store the predicates into the tcx, we - // sort them so that predicates like `T: Foo` come - // before uses of `U`. This avoids false ambiguity errors + // sort them so that predicates like `T: Foo` come + // before uses of `U`. This avoids false ambiguity errors // in trait checking. See `setup_constraining_predicates` // for details. if let Node::Item(&Item { @@ -2136,7 +2134,7 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool match tcx.hir().get_if_local(def_id) { Some(Node::ForeignItem(..)) => true, Some(_) => false, - _ => bug!("is_foreign_item applied to non-local def-id {:?}", def_id), + _ => bug!("is_foreign_item applied to non-local `DefId` {:?}", def_id), } } @@ -2238,7 +2236,7 @@ fn linkage_by_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, name: & // may pop up in the future. // // ghost, dllimport, dllexport and linkonce_odr_autohide are not supported - // and don't have to be, LLVM treats them as no-ops. + // and don't have to be, LLVM treats them as noops. match name { "appending" => Appending, "available_externally" => AvailableExternally, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 71767fcfd4933..289f7513a2f0d 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -193,7 +193,7 @@ want to capture values of an orderable type between two end-points, you can use a guard. ```compile_fail,E0029 -let string = "salutations !"; +let string = "salutations!"; // The ordering relation for strings can't be evaluated at compile time, // so this doesn't work: @@ -565,10 +565,10 @@ fn foo(f: F) { E0059: r##" The built-in function traits are generic over a tuple of the function arguments. -If one uses angle-bracket notation (`Fn<(T,), Output=U>`) instead of parentheses -(`Fn(T) -> U`) to denote the function trait, the type parameter should be a -tuple. Otherwise function call notation cannot be used and the trait will not be -implemented by closures. +If one uses angle-bracket notation (`Fn<(T,), Output = U>`) instead of +parentheses (`Fn(T) -> U`) to denote the function trait, the type parameter +should be a tuple. Otherwise, function call notation cannot be used and the +trait will not be implemented by closures. The most likely source of this error is using angle-bracket notation without wrapping the function argument type into a tuple, for example: @@ -633,7 +633,7 @@ unsafe { // the C runtime does not contain the `printf` definition. This leads to linker // error from the doc test (issue #42830). // This can be fixed by linking to the static library -// `legacy_stdio_definitions.lib` (see https://stackoverflow.com/a/36504365/). +// `legacy_stdio_definitions.lib` (see ). // If this compatibility library is removed in the future, consider changing // `printf` in this example to another well-known variadic function. @@ -730,7 +730,7 @@ LinkedList::new() += 1; // ... fn some_func(i: &mut i32) { - i += 12; // Error : '+=' operation cannot be applied on a reference ! + i += 12; // error: '+=' operation cannot be applied on a reference! } ``` @@ -739,12 +739,12 @@ And now some working examples: ``` let mut i : i32 = 0; -i += 12; // Good ! +i += 12; // good! // ... fn some_func(i: &mut i32) { - *i += 12; // Good ! + *i += 12; // good! } ``` "##, @@ -787,10 +787,10 @@ const SOME_CONST : i32 = 12; fn some_other_func() {} fn some_function() { - SOME_CONST = 14; // error : a constant value cannot be changed! - 1 = 3; // error : 1 isn't a valid place! - some_other_func() = 4; // error : we can't assign value to a function! - SomeStruct.x = 12; // error : SomeStruct a structure name but it is used + SOME_CONST = 14; // error: a constant value cannot be changed! + 1 = 3; // error: 1 isn't a valid place! + some_other_func() = 4; // error: we can't assign value to a function! + SomeStruct.x = 12; // error: SomeStruct a structure name but it is used // like a variable! } ``` @@ -804,12 +804,12 @@ struct SomeStruct { } let mut s = SomeStruct {x: 0, y: 0}; -s.x = 3; // that's good ! +s.x = 3; // that's good! // ... fn some_func(x: &mut i32) { - *x = 12; // that's good ! + *x = 12; // that's good! } ``` "##, @@ -1432,7 +1432,7 @@ impl LiveLongAndProsper for (u8, u8) { } ``` -Alternatively, you can create a newtype. A newtype is a wrapping tuple-struct. +Alternatively, you can create a newtype. A newtype is a wrapping tuple struct. For example, `NewType` is a newtype over `Foo` in `struct NewType(Foo)`. Example: @@ -1681,7 +1681,7 @@ information see the [opt-in builtin traits RFC][RFC 19]. E0193: r##" #### Note: this error code is no longer emitted by the compiler. -`where` clauses must use generic type parameters: it does not make sense to use +where-clauses must use generic type parameters: it does not make sense to use them otherwise. An example causing this error: ``` @@ -1699,7 +1699,7 @@ impl Foo for Wrapper where Wrapper: Clone { } ``` -This use of a `where` clause is strange - a more common usage would look +This use of a where-clause is strange -- a more common usage would look something like the following: ``` @@ -1717,12 +1717,12 @@ impl Foo for Wrapper where Wrapper: Clone { ``` Here, we're saying that the implementation exists on Wrapper only when the -wrapped type `T` implements `Clone`. The `where` clause is important because +wrapped type `T` implements `Clone`. The where-clause is important because some types will not implement `Clone`, and thus will not get this method. In our erroneous example, however, we're referencing a single concrete type. Since we know for certain that `Wrapper` implements `Clone`, there's no -reason to also specify it in a `where` clause. +reason to also specify it in a where-clause. "##, E0194: r##" @@ -2377,7 +2377,7 @@ fn main() { E0229: r##" An associated type binding was done outside of the type parameter declaration -and `where` clause. Erroneous code example: +and where-clause. Erroneous code example: ```compile_fail,E0229 pub trait Foo { @@ -2392,7 +2392,7 @@ impl Foo for isize { fn boo(&self) -> usize { 42 } } -fn baz(x: &>::A) {} +fn baz(x: &>::A) {} // error: associated type bindings are not allowed here ``` @@ -2402,15 +2402,15 @@ declaration: ``` # struct Bar; # trait Foo { type A; } -fn baz>(x: &::A) {} // ok! +fn baz>(x: &::A) {} // ok! ``` -Or in the `where` clause: +Or in the where-clause: ``` # struct Bar; # trait Foo { type A; } -fn baz(x: &::A) where I: Foo {} +fn baz(x: &::A) where I: Foo {} ``` "##, @@ -3236,7 +3236,7 @@ A type parameter which references `Self` in its default value was not specified. Example of erroneous code: ```compile_fail,E0393 -trait A {} +trait A {} fn together_we_will_rule_the_galaxy(son: &A) {} // error: the type parameter `T` must be explicitly specified in an @@ -3256,7 +3256,7 @@ disallowed. Making the trait concrete by explicitly specifying the value of the defaulted parameter will fix this issue. Fixed example: ``` -trait A {} +trait A {} fn together_we_will_rule_the_galaxy(son: &A) {} // Ok! ``` @@ -3965,7 +3965,7 @@ Thin pointers are "simple" pointers: they are purely a reference to a memory address. Fat pointers are pointers referencing Dynamically Sized Types (also called DST). -DST don't have a statically known size, therefore they can only exist behind +DST don't have a statically-known size, therefore they can only exist behind some kind of pointers that contain additional information. Slices and trait objects are DSTs. In the case of slices, the additional information the fat pointer holds is their size. @@ -4419,18 +4419,18 @@ impl Foo for () { "##, E0646: r##" -It is not possible to define `main` with a where clause. +It is not possible to define `main` with a where-clause. Erroneous code example: ```compile_fail,E0646 fn main() where i32: Copy { // error: main function is not allowed to have - // a where clause + // a where-clause } ``` "##, E0647: r##" -It is not possible to define `start` with a where clause. +It is not possible to define `start` with a where-clause. Erroneous code example: ```compile_fail,E0647 @@ -4438,7 +4438,7 @@ Erroneous code example: #[start] fn start(_: isize, _: *const *const u8) -> isize where (): Copy { - //^ error: start function is not allowed to have a where clause + //^ error: start function is not allowed to have a where-clause 0 } ``` @@ -4621,7 +4621,7 @@ E0714: r##" A `#[marker]` trait contained an associated item. The items of marker traits cannot be overridden, so there's no need to have them -when they cannot be changed per-type anyway. If you wanted them for ergonomic +when they cannot be changed per-type anyway. If you wanted them for ergonomic reasons, consider making an extension trait instead. "##, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 7055218577c5c..00414ce8f2bc0 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -22,7 +22,7 @@ several major phases: 4. Finally, the check phase then checks function bodies and so forth. Within the check phase, we check each function body one at a time (bodies of function expressions are checked as part of the - containing function). Inference is used to supply types wherever + containing function). Inference is used to supply types wherever they are unknown. The actual checking of a function itself has several phases (check, regionck, writeback), as discussed in the documentation for the `check` module. @@ -43,10 +43,10 @@ independently: - outlives: outlives inference - check: walks over function bodies and type checks them, inferring types for - local variables, type parameters, etc as necessary. + local variables, type parameters, etc., as necessary. - infer: finds the types to use for each type variable such that - all subtyping and assignment constraints are met. In essence, the check + all subtyping and assignment constraints are met. In essence, the check module specifies the constraints, and the infer module solves them. ## Note @@ -77,10 +77,12 @@ This API is completely unstable and subject to change. #![allow(elided_lifetimes_in_paths)] // WIP -#[macro_use] extern crate log; -#[macro_use] extern crate syntax; - -#[macro_use] extern crate rustc; +#[macro_use] +extern crate log; +#[macro_use] +extern crate rustc; +#[macro_use] +extern crate syntax; // N.B., this module needs to be declared first so diagnostics are // registered before they are used. @@ -98,6 +100,8 @@ mod namespace; mod outlives; mod variance; +use std::iter; + use rustc_target::spec::abi::Abi; use rustc::hir::{self, Node}; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; @@ -116,8 +120,6 @@ use rustc::util::profiling::ProfileCategory; use syntax_pos::Span; use util::common::time; -use std::iter; - pub struct TypeAndSubsts<'tcx> { substs: &'tcx Substs<'tcx>, ty: Ty<'tcx>, @@ -198,8 +200,8 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, main_def_id: DefId) { } if let Some(sp) = generics.where_clause.span() { struct_span_err!(tcx.sess, sp, E0646, - "`main` function is not allowed to have a `where` clause") - .span_label(sp, "`main` cannot have a `where` clause") + "`main` function is not allowed to have a where-clause") + .span_label(sp, "`main` cannot have a where-clause") .emit(); error = true; } @@ -262,8 +264,8 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, start_def_id: DefId) } if let Some(sp) = generics.where_clause.span() { struct_span_err!(tcx.sess, sp, E0647, - "start function is not allowed to have a `where` clause") - .span_label(sp, "start function cannot have a `where` clause") + "start function is not allowed to have a where-clause") + .span_label(sp, "start function cannot have a where-clause") .emit(); error = true; } @@ -369,11 +371,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) } /// A quasi-deprecated helper used in rustdoc and save-analysis to get -/// the type from a HIR node. +/// the type from an HIR node. pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> { // In case there are any projections etc, find the "environment" - // def-id that will be used to determine the traits/predicates in - // scope. This is derived from the enclosing item-like thing. + // `DefId` that will be used to determine the traits/predicates in + // scope. This is derived from the enclosing item-like thing. let env_node_id = tcx.hir().get_parent(hir_ty.id); let env_def_id = tcx.hir().local_def_id(env_node_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id); @@ -384,8 +386,8 @@ pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait: &hir::TraitRef) -> (ty::PolyTraitRef<'tcx>, Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>) { // In case there are any projections etc, find the "environment" - // def-id that will be used to determine the traits/predicates in - // scope. This is derived from the enclosing item-like thing. + // `DefId` that will be used to determine the traits/predicates in + // scope. This is derived from the enclosing item-like thing. let env_node_id = tcx.hir().get_parent(hir_trait.ref_id); let env_def_id = tcx.hir().local_def_id(env_node_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id); diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 6c56e9991c8a8..5428125f5a270 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -36,7 +36,7 @@ pub fn infer_predicates<'tcx>( explicit_map: explicit_map, }; - // Visit all the crates and infer predicates + // Visit all the crates and infer predicates. tcx.hir().krate().visit_all_item_likes(&mut visitor); } @@ -60,7 +60,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { .tcx .hir() .as_local_node_id(item_did) - .expect("expected local def-id"); + .expect("expected local `DefId`"); let item = match self.tcx.hir().get(node_id) { Node::Item(item) => item, _ => bug!(), @@ -71,14 +71,14 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) => { let adt_def = self.tcx.adt_def(item_did); - // Iterate over all fields in item_did + // Iterate over all fields in `item_did`. for field_def in adt_def.all_fields() { // Calculating the predicate requirements necessary - // for item_did. + // for `item_did`. // - // For field of type &'a T (reference) or Adt - // (struct/enum/union) there will be outlive - // requirements for adt_def. + // For field of a reference type (i.e., `&'a T`) or ADT + // (i.e., struct/enum/union), there will be 'outlives' + // requirements for `adt_def`. let field_ty = self.tcx.type_of(field_def.did); insert_required_predicates_to_be_wf( self.tcx, @@ -96,7 +96,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { // If new predicates were added (`local_predicate_map` has more // predicates than the `global_inferred_outlives`), the new predicates // might result in implied predicates for their parent types. - // Therefore mark `predicates_added` as true and which will ensure + // Therefore, mark `predicates_added` as true and which will ensure // we walk the crates again and re-calculate predicates for all // items. let item_predicates_len: usize = self @@ -125,8 +125,8 @@ fn insert_required_predicates_to_be_wf<'tcx>( ) { for ty in field_ty.walk() { match ty.sty { - // The field is of type &'a T which means that we will have - // a predicate requirement of T: 'a (T outlives 'a). + // The field is of type `&'a T`, which means that we will have + // a predicate requirement of `T: 'a` (`T` outlives `'a`). // // We also want to calculate potential predicates for the T ty::Ref(region, rty, _) => { @@ -134,10 +134,10 @@ fn insert_required_predicates_to_be_wf<'tcx>( insert_outlives_predicate(tcx, rty.into(), region, required_predicates); } - // For each Adt (struct/enum/union) type `Foo<'a, T>`, we + // For each ADT (i.e., struct/enum/union) type `Foo<'a, T>`, we // can load the current set of inferred and explicit // predicates from `global_inferred_outlives` and filter the - // ones that are TypeOutlives. + // ones that are `TypeOutlives`. ty::Adt(def, substs) => { // First check the inferred predicates // @@ -161,7 +161,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( if let Some(unsubstituted_predicates) = global_inferred_outlives.get(&def.did) { for unsubstituted_predicate in unsubstituted_predicates { // `unsubstituted_predicate` is `U: 'b` in the - // example above. So apply the substitution to + // example above. So apply the substitution to // get `T: 'a` (or `predicate`): let predicate = unsubstituted_predicate.subst(tcx, substs); insert_outlives_predicate( @@ -198,7 +198,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( // placeholder value with the function // `with_self_ty`, since there is no concrete type // `Self` for a `dyn Trait` at this - // stage. Therefore when checking explicit + // stage. Therefore, when checking explicit // predicates in `check_explicit_predicates` we // need to ignore checking the explicit_map for // Self type. @@ -311,7 +311,7 @@ pub fn check_explicit_predicates<'tcx>( // ignore such requirements as well (cc #54467)-- though // conceivably it might be better if we could extract the `Foo // = X` binding from the object type (there must be such a - // binding) and thus infer an outlives requirement that `X: + // binding) and thus infer an 'outlives' requirement that `X: // 'b`. if ignore_self_ty.0 { if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() { diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index b3634d37cc2b8..c8a32e46d2cd2 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -27,7 +27,7 @@ fn inferred_outlives_of<'a, 'tcx>( let id = tcx .hir() .as_local_node_id(item_def_id) - .expect("expected local def-id"); + .expect("expected local `DefId`"); match tcx.hir().get(id) { Node::Item(item) => match item.node { @@ -83,7 +83,7 @@ fn inferred_outlives_crate<'tcx>( // predicate is satisfied, so they form a kind of base set of requirements // for the type. - // Compute the inferred predicates + // Compute the inferred predicates. let mut exp_map = explicit::ExplicitPredicatesMap::new(); let global_inferred_outlives = implicit_infer::infer_predicates(tcx, &mut exp_map); @@ -91,7 +91,7 @@ fn inferred_outlives_crate<'tcx>( // Convert the inferred predicates into the "collected" form the // global data structure expects. // - // FIXME -- consider correcting impedance mismatch in some way, + // FIXME: consider correcting impedance mismatch in some way, // probably by updating the global data structure. let predicates = global_inferred_outlives .iter() diff --git a/src/librustc_typeck/outlives/utils.rs b/src/librustc_typeck/outlives/utils.rs index c886c7a4ffce5..c2249e2d271be 100644 --- a/src/librustc_typeck/outlives/utils.rs +++ b/src/librustc_typeck/outlives/utils.rs @@ -45,9 +45,9 @@ pub fn insert_outlives_predicate<'tcx>( // ``` // // Here `outlived_region = 'a` and `kind = &'b - // u32`. Decomposing `&'b u32` into + // u32`. Decomposing `&'b u32` into // components would yield `'b`, and we add the - // where clause that `'b: 'a`. + // where-clause that `'b: 'a`. insert_outlives_predicate( tcx, r.into(), @@ -67,9 +67,9 @@ pub fn insert_outlives_predicate<'tcx>( // ``` // // Here `outlived_region = 'a` and `kind = - // Vec`. Decomposing `Vec` into + // Vec`. Decomposing `Vec` into // components would yield `U`, and we add the - // where clause that `U: 'a`. + // where-clause that `U: 'a`. let ty: Ty<'tcx> = param_ty.to_ty(tcx); required_predicates .insert(ty::OutlivesPredicate(ty.into(), outlived_region)); @@ -92,7 +92,7 @@ pub fn insert_outlives_predicate<'tcx>( Component::EscapingProjection(_) => { // As above, but the projection involves - // late-bound regions. Therefore, the WF + // late-bound regions. Therefore, the WF // requirement is not checked in type definition // but at fn call site, so ignore it. // @@ -153,7 +153,7 @@ fn is_free_region<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, region: Region<'_>) -> bool // } // // The type above might generate a `T: 'b` bound, but we can - // ignore it. We can't put it on the struct header anyway. + // ignore it. We can't put it on the struct header anyway. RegionKind::ReLateBound(..) => false, // These regions don't appear in types from type declarations: diff --git a/src/librustc_typeck/structured_errors.rs b/src/librustc_typeck/structured_errors.rs index 3e3eab8cf4cfb..b81f92f188677 100644 --- a/src/librustc_typeck/structured_errors.rs +++ b/src/librustc_typeck/structured_errors.rs @@ -128,7 +128,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCastError<'tcx> { memory address. Fat pointers are pointers referencing \"Dynamically Sized Types\" (also -called DST). DST don't have a statically known size, therefore they can +called DST). DST don't have a statically-known size, therefore they can only exist behind some kind of pointers that contain additional information. Slices and trait objects are DSTs. In the case of slices, the additional information the fat pointer holds is their size. diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 347422780d516..4bcb9a64db422 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -46,7 +46,7 @@ fn crate_variances<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) -> Lrc> { - let id = tcx.hir().as_local_hir_id(item_def_id).expect("expected local def-id"); + let id = tcx.hir().as_local_hir_id(item_def_id).expect("expected local `DefId`"); let unsupported = || { // Variance not relevant. span_bug!(tcx.hir().span_by_hir_id(id), "asked to compute variance for wrong kind of item") diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 550c1b1d68bd3..ee161a3074370 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -48,7 +48,7 @@ pub fn solve_constraints(constraints_cx: ConstraintContext) -> ty::CrateVariance impl<'a, 'tcx> SolveContext<'a, 'tcx> { fn solve(&mut self) { - // Propagate constraints until a fixed point is reached. Note + // Propagate constraints until a fixed point is reached. Note // that the maximum number of iterations is 2C where C is the // number of constraints (each variable can change values at most // twice). Since number of constraints is linear in size of the diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index ec0acfb63a89a..9b3b3478969bd 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -57,7 +57,7 @@ pub struct TermsContext<'a, 'tcx: 'a> { // variance. pub lang_items: Vec<(ast::NodeId, Vec)>, - // Maps from the node id of an item to the first inferred index + // Maps from the `NodeId` of an item to the first inferred index // used for its type & region parameters. pub inferred_starts: NodeMap, diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index b99181c0d4f9e..9646ebb28febe 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -129,7 +129,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { AutoTraitResult::NegativeImpl => { polarity = Some(ImplPolarity::Negative); - // For negative impls, we use the generic params, but *not* the predicates, + // For negative impls, we use the generic params, but **not** the predicates, // from the original type. Otherwise, the displayed impl appears to be a // conditional negative impl, when it's really unconditional. // @@ -402,7 +402,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { regions.into_iter().flat_map(|r| { match r { - // We only care about late bound regions, as we need to add them + // We only care about late-bound regions, as we need to add them // to the 'for<>' section &ty::ReLateBound(_, ty::BoundRegion::BrNamed(_, name)) => { Some(GenericParamDef { @@ -535,7 +535,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { ); // The `Sized` trait must be handled specially, since we only display it when - // it is *not* required (i.e., '?Sized') + // it is **not** required (i.e., '?Sized') let sized_trait = self.cx .tcx .require_lang_item(lang_items::SizedTraitLangItem); @@ -681,7 +681,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { continue; } - // FIXME: Remove this scope when NLL lands + // FIXME: remove this scope when NLL lands { let args = &mut new_trait_path.segments @@ -765,7 +765,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { for param in generic_params.iter_mut() { match param.kind { GenericParamDefKind::Type { ref mut default, ref mut bounds, .. } => { - // We never want something like `impl`. + // We never want something like `impl`. default.take(); let generic_ty = Type::Generic(param.name.clone()); if !has_sized.contains(&generic_ty) { diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index ab8656fa47c9b..529e63955ce2c 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -93,7 +93,7 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> { let eq_result = infcx.at(&cause, param_env) .eq(trait_ref.self_ty(), ty); if let Ok(InferOk { value: (), obligations }) = eq_result { - // FIXME(eddyb) ignoring `obligations` might cause false positives. + // FIXME(eddyb): ignoring `obligations` might cause false positives. drop(obligations); debug!( diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index adfac98df868b..0bf7a60907f77 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -95,7 +95,7 @@ impl Cfg { /// Checks whether the given configuration can be matched in the current session. /// /// Equivalent to `attr::cfg_matches`. - // FIXME: Actually make use of `features`. + // FIXME: actually make use of `features`. pub fn matches(&self, parse_sess: &ParseSess, features: Option<&Features>) -> bool { match *self { Cfg::False => false, diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 8c8151e1e9509..cfa9474a5e82d 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -287,10 +287,10 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { let associated_trait = tcx.impl_trait_ref(did); // Only inline impl if the implemented trait is - // reachable in rustdoc generated documentation + // reachable in rustdoc-generated documentation. if !did.is_local() { - if let Some(traitref) = associated_trait { - if !cx.renderinfo.borrow().access_levels.is_doc_reachable(traitref.def_id) { + if let Some(tr) = associated_trait { + if !cx.renderinfo.borrow().access_levels.is_doc_reachable(tr.def_id) { return } } @@ -308,7 +308,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { }; // Only inline impl if the implementing type is - // reachable in rustdoc generated documentation + // reachable in rustdoc-generated documentation. if !did.is_local() { if let Some(did) = for_.def_id() { if !cx.renderinfo.borrow().access_levels.is_doc_reachable(did) { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d12b5021ca9fa..dc1834b870477 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1,68 +1,66 @@ //! This module contains the "cleaned" pieces of the AST, and the functions //! that clean them. -pub mod inline; -pub mod cfg; -mod simplify; mod auto_trait; mod blanket_impl; +pub mod cfg; pub mod def_ctor; +pub mod inline; +mod simplify; +use std::u32; +use std::collections::hash_map::Entry; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::default::Default; +use std::{mem, slice, vec}; +use std::iter::{FromIterator, once}; +use std::rc::Rc; +use std::str::FromStr; +use std::cell::RefCell; +use std::sync::Arc; + +use parking_lot::ReentrantMutex; +use html::render::{cache, ExternalLocation}; +use html::item_type::ItemType; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; use rustc_typeck::hir_ty_to_ty; +use rustc::hir::{self, GenericArg, HirVec}; +use rustc::hir::def::{self, Def, CtorKind}; +use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::infer::region_constraints::{RegionConstraintData, Constraint}; use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::middle::stability; use rustc::mir::interpret::GlobalId; -use rustc::hir::{self, GenericArg, HirVec}; -use rustc::hir::def::{self, Def, CtorKind}; -use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::ty::subst::Substs; use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::fold::TypeFolder; use rustc::ty::layout::VariantIdx; use rustc::util::nodemap::{FxHashMap, FxHashSet}; +use syntax_pos::{self, DUMMY_SP, Pos, FileName}; use syntax::ast::{self, AttrStyle, Ident}; use syntax::attr; use syntax::ext::base::MacroKind; -use syntax::source_map::{dummy_spanned, Spanned}; use syntax::ptr::P; +use syntax::source_map::{dummy_spanned, Spanned}; use syntax::symbol::keywords::{self, Keyword}; use syntax::symbol::InternedString; -use syntax_pos::{self, DUMMY_SP, Pos, FileName}; - -use std::collections::hash_map::Entry; -use std::fmt; -use std::hash::{Hash, Hasher}; -use std::default::Default; -use std::{mem, slice, vec}; -use std::iter::{FromIterator, once}; -use std::rc::Rc; -use std::str::FromStr; -use std::cell::RefCell; -use std::sync::Arc; -use std::u32; - -use parking_lot::ReentrantMutex; - -use core::{self, DocContext}; -use doctree; -use visit_ast; -use html::render::{cache, ExternalLocation}; -use html::item_type::ItemType; +use crate::core::{self, DocContext}; +use crate::doctree; +use crate::visit_ast; use self::cfg::Cfg; use self::auto_trait::AutoTraitFinder; use self::blanket_impl::BlanketImplFinder; -pub use self::Type::*; -pub use self::Mutability::*; +pub use self::FunctionRetTy::*; pub use self::ItemEnum::*; +pub use self::Mutability::*; pub use self::SelfTy::*; -pub use self::FunctionRetTy::*; +pub use self::Type::*; pub use self::Visibility::{Public, Inherited}; thread_local!(pub static MAX_DEF_ID: RefCell> = Default::default()); @@ -583,9 +581,9 @@ impl Clean for doctree::Module { String::new() }; - // maintain a stack of mod ids, for doc comment path resolution - // but we also need to resolve the module's own docs based on whether its docs were written - // inside or outside the module, so check for that + // Maintain a stack of module IDs, for doc comment path resolution. + // However, we also need to resolve the module's own docs based on whether its docs were + // written inside or outside the module, so check for that. let attrs = self.attrs.clean(cx); let mut items: Vec = vec![]; @@ -1085,7 +1083,7 @@ fn external_generic_args(cx: &DocContext, trait_did: Option, has_self: bo let types = substs.types().skip(has_self as usize).collect::>(); match trait_did { - // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C + // Attempt to sugar an external path like `Fn<(A, B,), C>` to `Fn(A, B) -> C`. Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { assert_eq!(types.len(), 1); let inputs = match types[0].sty { @@ -1099,7 +1097,7 @@ fn external_generic_args(cx: &DocContext, trait_did: Option, has_self: bo } }; let output = None; - // FIXME(#20299) return type comes from a projection now + // FIXME(#20299): return type comes from a projection now. // match types[1].sty { // ty::Tuple(ref v) if v.is_empty() => None, // -> () // _ => Some(types[1].clean(cx)) @@ -1142,7 +1140,7 @@ impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs); - // collect any late bound regions + // Collect any late-bound regions. let mut late_bounds = vec![]; for ty_s in trait_ref.input_types().skip(1) { if let ty::Tuple(ts) = ty_s.sty { @@ -2838,7 +2836,8 @@ impl<'tcx> Clean for Ty<'tcx> { ImplTrait(bounds) } - ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton) + // FIXME(pcwalton) + ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), ty::Bound(..) => panic!("Bound"), ty::Placeholder(..) => panic!("Placeholder"), @@ -3879,7 +3878,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId { Def::ForeignTy(i) => (i, TypeKind::Foreign), Def::Const(i) => (i, TypeKind::Const), Def::Static(i, _) => (i, TypeKind::Static), - Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"), + Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent `DefId`"), TypeKind::Enum), Def::Macro(i, mac_kind) => match mac_kind { MacroKind::Bang => (i, TypeKind::Macro), diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 376cf3a2deebe..97783375837d9 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -23,7 +23,7 @@ use clean; use core::DocContext; pub fn where_clauses(cx: &DocContext, clauses: Vec) -> Vec { - // First, partition the where clause into its separate components + // First, partition the where-clause into its separate components let mut params: BTreeMap<_, Vec<_>> = BTreeMap::new(); let mut lifetimes = Vec::new(); let mut equalities = Vec::new(); diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index ec4ee2d66a599..fa87e422a98c6 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -504,7 +504,7 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &errors::Handler) if matches.opt_present(flag) { let mut err = diag.struct_warn(&format!("the '{}' flag is considered deprecated", flag)); - err.warn("please see https://github.com/rust-lang/rust/issues/44136"); + err.warn("see "); if *flag == "no-defaults" { err.help("you may want to use --document-private-items"); @@ -548,7 +548,7 @@ fn parse_extern_html_roots( /// Extracts `--extern CRATE=PATH` arguments from `matches` and /// returns a map mapping crate names to their paths or else an /// error message. -// FIXME(eddyb) This shouldn't be duplicated with `rustc::session`. +// FIXME(eddyb): this shouldn't be duplicated with `rustc::session`. fn parse_externs(matches: &getopts::Matches) -> Result { let mut externs: BTreeMap<_, BTreeSet<_>> = BTreeMap::new(); for arg in &matches.opt_strs("extern") { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index e90127ca162d2..6625f1154cb61 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -101,9 +101,9 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> { // registered after the AST is constructed would require storing the defid mapping in a // RefCell, decreasing the performance for normal compilation for very little gain. // - // Instead, we construct 'fake' def ids, which start immediately after the last DefId in + // Instead, we construct 'fake' `DefId`s, which start immediately after the last DefId in // DefIndexAddressSpace::Low. In the Debug impl for clean::Item, we explicitly check for fake - // def ids, as we'll end up with a panic if we use the DefId Debug impl for fake DefIds + // `DefId`s, as we'll end up with a panic if we use the DefId Debug impl for fake DefIds pub fn next_def_id(&self, crate_num: CrateNum) -> DefId { let start_def_id = { let next_id = if crate_num == LOCAL_CRATE { @@ -309,7 +309,7 @@ pub fn new_handler(error_format: ErrorOutputType, } pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOptions, Vec) { - // Parse, resolve, and typecheck the given crate. + // Parse, resolve, and type-check the given crate. let RustdocOptions { input, @@ -545,7 +545,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt fn report_deprecated_attr(name: &str, diag: &errors::Handler) { let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \ considered deprecated", name)); - msg.warn("please see https://github.com/rust-lang/rust/issues/44136"); + msg.warn("see "); if name == "no_default_passes" { msg.help("you may want to use `#![doc(document_private_items)]`"); diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs index 35858d8415075..438bc393de2ba 100644 --- a/src/librustdoc/html/escape.rs +++ b/src/librustdoc/html/escape.rs @@ -12,7 +12,7 @@ pub struct Escape<'a>(pub &'a str); impl<'a> fmt::Display for Escape<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { // Because the internet is always right, turns out there's not that many - // characters to escape: http://stackoverflow.com/questions/7381974 + // characters to escape: . let Escape(s) = *self; let pile_o_bits = s; let mut last = 0; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 35555f61bd150..cd7a7ca988481 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -573,7 +573,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: &[] => primitive_link(f, PrimitiveType::Unit, "()"), &[ref one] => { primitive_link(f, PrimitiveType::Tuple, "(")?; - //carry f.alternate() into this display w/o branching manually + // Carry `f.alternate()` into this display without branching manually. fmt::Display::fmt(one, f)?; primitive_link(f, PrimitiveType::Tuple, ",)") } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 66b1b5b4d7547..abdb9f896f14c 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -280,7 +280,8 @@ impl<'a> Classifier<'a> { // Case 1: #![inner_attribute] if self.lexer.peek().tok == token::Not { - self.try_next_token()?; // NOTE: consumes `!` token! + // Consume `!` token. + self.try_next_token()?; if self.lexer.peek().tok == token::OpenDelim(token::Bracket) { self.in_attribute = true; out.enter_span(Class::Attribute)?; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 386480313dc4c..9c21fd9d3e7df 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -96,27 +96,27 @@ impl<'a> Line<'a> { } } -// FIXME: There is a minor inconsistency here. For lines that start with ##, we +// FIXME: there is a minor inconsistency here. For lines that start with `##`, we // have no easy way of removing a potential single space after the hashes, which -// is done in the single # case. This inconsistency seems okay, if non-ideal. In -// order to fix it we'd have to iterate to find the first non-# character, and +// is done in the single `#` case. This inconsistency seems ok, if non-ideal. In +// order to fix it we'd have to iterate to find the first non-`#` character, and // then reallocate to remove it; which would make us return a String. fn map_line(s: &str) -> Line { let trimmed = s.trim(); if trimmed.starts_with("##") { Line::Shown(Cow::Owned(s.replacen("##", "#", 1))) } else if trimmed.starts_with("# ") { - // # text + // `# text` Line::Hidden(&trimmed[2..]) } else if trimmed == "#" { - // We cannot handle '#text' because it could be #[attr]. + // We cannot handle `#text` because it could be `#[attr]`. Line::Hidden("") } else { Line::Shown(Cow::Borrowed(s)) } } -/// Convert chars from a title for an id. +/// Converts chars from a title, for use as an ID. /// /// "Hello, world!" -> "hello-world" fn slugify(c: char) -> Option { @@ -1038,7 +1038,7 @@ impl IdMap { IdMap::default() } - pub fn populate>(&mut self, ids: I) { + pub fn populate>(&mut self, ids: I) { for id in ids { let _ = self.derive(id); } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e660d27d74b4c..4a18862a38b0a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -343,7 +343,7 @@ pub struct Cache { // in another, if the implementing module is parsed before defining module, // then the fully qualified name of the structure isn't presented in `paths` // yet when its implementation methods are being indexed. Caches such methods - // and their parent id here and indexes them at the end of crate parsing. + // and their parent ID here and indexes them at the end of crate parsing. orphan_impl_items: Vec<(DefId, clean::Item)>, // Similarly to `orphan_impl_items`, sometimes trait impls are picked up @@ -1615,7 +1615,7 @@ impl DocFolder for Cache { clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..) | clean::ProcMacroItem(..) if !self.stripped_mod => { - // Re-exported items mean that the same id can show up twice + // Re-exported items mean that the same ID can show up twice // in the rustdoc ast that we're looking at. We know, // however, that a re-exported item doesn't show up in the // `public_items` map, so we can skip inserting into the @@ -1683,7 +1683,7 @@ impl DocFolder for Cache { // implementations elsewhere. let ret = self.fold_item_recur(item).and_then(|item| { if let clean::Item { inner: clean::ImplItem(_), .. } = item { - // Figure out the id of this impl. This may map to a + // Figure out the ID of this impl. This may map to a // primitive rather than always to a struct/enum. // Note: matching twice to restrict the lifetime of the `i` borrow. let mut dids = FxHashSet::default(); @@ -2592,8 +2592,8 @@ fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::R if item.is_struct() { write!(w, "Non-exhaustive structs could have additional fields added in future. \ Therefore, non-exhaustive structs cannot be constructed in external crates \ - using the traditional Struct {{ .. }} syntax; cannot be \ - matched against without a wildcard ..; and \ + using the traditional Struct {{ .. }} syntax, cannot be \ + matched against without a wildcard .., and \ struct update syntax will not work.")?; } else if item.is_enum() { write!(w, "Non-exhaustive enums could have additional variants added in future. \ @@ -2693,7 +2693,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, // // `Double` will appear twice in the generated docs. // - // FIXME: This code is quite ugly and could be improved. Small issue: DefId + // FIXME: this code is quite ugly and could be improved. Small issue: `DefId` // can be identical even if the elements are different (mostly in imports). // So in case this is an import, we keep everything by adding a "unique id" // (which is the position in the vector). @@ -4449,7 +4449,7 @@ impl<'a> fmt::Display for Sidebar<'a> { path = relpath)?; if parentlen == 0 { // There is no sidebar-items.js beyond the crate root path - // FIXME maybe dynamic crate loading can be merged here + // FIXME: maybe dynamic crate loading can be merged here } else { write!(fmt, "", path = relpath)?; diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 00622770adafc..eaf69e9b608e6 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -475,7 +475,7 @@ crate fn source_span_for_markdown_range( break; } None => { - // Since this is a source line that doesn't include a markdown line, + // Since this is a source line that doesn't include a Markdown line, // we have to count the newline that we split from earlier. if line_no <= starting_line { start_bytes += source_line.len() + 1; diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs index c0a8fa9d0016d..0d375c2b887f0 100644 --- a/src/libserialize/collection_impls.rs +++ b/src/libserialize/collection_impls.rs @@ -30,7 +30,7 @@ impl Decodable for SmallVec fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut vec = SmallVec::with_capacity(len); - // FIXME(#48994) - could just be collected into a Result + // FIXME(#48994): could just be collected into a `Result`. for i in 0..len { vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?); } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index a4fd288451205..d1e8636dc8641 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1,10 +1,7 @@ // Rust JSON serialization library. -// Copyright (c) 2011 Google Inc. +// Original version copyright (c) 2011 Google Inc. -#![forbid(non_camel_case_types)] -#![allow(missing_docs)] - -//! JSON parsing and serialization +//! JSON parsing and serialization. //! //! # What is JSON? //! @@ -106,20 +103,20 @@ //! extern crate serialize; //! use serialize::json::{self, ToJson, Json}; //! -//! // A custom data structure +//! // A custom data structure. //! struct ComplexNum { //! a: f64, //! b: f64, //! } //! -//! // JSON value representation +//! // JSON value representation. //! impl ToJson for ComplexNum { //! fn to_json(&self) -> Json { //! Json::String(format!("{}+{}i", self.a, self.b)) //! } //! } //! -//! // Only generate `RustcEncodable` trait implementation +//! // Only generate `RustcEncodable` trait implementation. //! #[derive(Encodable)] //! pub struct ComplexNumRecord { //! uid: u8, @@ -159,7 +156,7 @@ //! impl ToJson for TestStruct { //! fn to_json(&self) -> Json { //! let mut d = BTreeMap::new(); -//! // All standard types implement `to_json()`, so use it +//! // All standard types implement `to_json()`, so use it. //! d.insert("data_int".to_string(), self.data_int.to_json()); //! d.insert("data_str".to_string(), self.data_str.to_json()); //! d.insert("data_vector".to_string(), self.data_vector.to_json()); @@ -168,7 +165,7 @@ //! } //! //! fn main() { -//! // Serialize using `ToJson` +//! // Serialize using `ToJson`. //! let input_data = TestStruct { //! data_int: 1, //! data_str: "madoka".to_string(), @@ -182,12 +179,8 @@ //! } //! ``` -use self::JsonEvent::*; -use self::ErrorCode::*; -use self::ParserError::*; -use self::DecoderError::*; -use self::ParserState::*; -use self::InternalStackElement::*; +#![forbid(non_camel_case_types)] +#![allow(missing_docs)] use std::borrow::Cow; use std::collections::{HashMap, BTreeMap}; @@ -201,8 +194,14 @@ use std::string; use std::{char, f64, fmt, str}; use crate::Encodable; +use self::JsonEvent::*; +use self::ErrorCode::*; +use self::ParserError::*; +use self::DecoderError::*; +use self::ParserState::*; +use self::InternalStackElement::*; -/// Represents a json value +/// Represents a JSON value. #[derive(Clone, PartialEq, PartialOrd, Debug)] pub enum Json { I64(i64), @@ -247,12 +246,12 @@ pub enum ErrorCode { #[derive(Clone, PartialEq, Debug)] pub enum ParserError { - /// msg, line, col + /// `(msg, line, col)` SyntaxError(ErrorCode, usize, usize), IoError(io::ErrorKind, String), } -// Builder and Parser have the same errors. +// The `Builder` and `Parser` types have the same errors. pub type BuilderError = ParserError; #[derive(Clone, PartialEq, Debug)] @@ -293,7 +292,7 @@ pub fn error_str(error: ErrorCode) -> &'static str { } } -/// Shortcut function to decode a JSON `&str` into an object +/// Shortcut function to decode a JSON `&str` into an object. pub fn decode(s: &str) -> DecodeResult { let json = match from_str(s) { Ok(x) => x, @@ -304,7 +303,7 @@ pub fn decode(s: &str) -> DecodeResult { crate::Decodable::decode(&mut decoder) } -/// Shortcut function to encode a `T` into a JSON `String` +/// Shortcut function to encode a `T` into a JSON `String`. pub fn encode(object: &T) -> Result { let mut s = String::new(); { @@ -326,14 +325,14 @@ fn io_error_to_error(io: io::Error) -> ParserError { impl fmt::Display for ParserError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME this should be a nicer error + // FIXME: this should be a nicer error. fmt::Debug::fmt(self, f) } } impl fmt::Display for DecoderError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME this should be a nicer error + // FIXME: this should be a nicer error. fmt::Debug::fmt(self, f) } } @@ -344,7 +343,7 @@ impl std::error::Error for DecoderError { impl fmt::Display for EncoderError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME this should be a nicer error + // FIXME: this should be a nicer error. fmt::Debug::fmt(self, f) } } @@ -354,7 +353,7 @@ impl std::error::Error for EncoderError { } impl From for EncoderError { - /// Converts a [`fmt::Error`] into `EncoderError` + /// Converts a [`fmt::Error`] into `EncoderError`. /// /// This conversion does not allocate memory. fn from(err: fmt::Error) -> EncoderError { EncoderError::FmtError(err) } @@ -451,15 +450,14 @@ fn fmt_number_or_null(v: f64) -> string::String { } } -/// A structure for implementing serialization to JSON. +/// Serializes values to JSON. pub struct Encoder<'a> { writer: &'a mut (dyn fmt::Write+'a), is_emitting_map_key: bool, } impl<'a> Encoder<'a> { - /// Creates a new JSON encoder whose output will be written to the writer - /// specified. + /// Creates a new JSON encoder whose output will be written to the writer specified. pub fn new(writer: &'a mut dyn fmt::Write) -> Encoder<'a> { Encoder { writer: writer, is_emitting_map_key: false, } } @@ -536,9 +534,10 @@ impl<'a> crate::Encoder for Encoder<'a> { f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { - // enums are encoded as strings or objects - // Bunny => "Bunny" - // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]} + // Enums are encoded as strings or objects. For example: + // + // `Bunny` => `"Bunny"` + // `Kangaroo(34, "William")` => `{"variant": "Kangaroo", "fields": [34,"William"]}` if cnt == 0 { escape_str(self.writer, name) } else { @@ -697,7 +696,7 @@ impl<'a> crate::Encoder for Encoder<'a> { } /// Another encoder for JSON, but prints out human-readable JSON instead of -/// compact data +/// compact data. pub struct PrettyEncoder<'a> { writer: &'a mut (dyn fmt::Write+'a), curr_indent: usize, @@ -706,7 +705,7 @@ pub struct PrettyEncoder<'a> { } impl<'a> PrettyEncoder<'a> { - /// Creates a new encoder whose output will be written to the specified writer + /// Creates a new encoder whose output will be written to the specified writer. pub fn new(writer: &'a mut dyn fmt::Write) -> PrettyEncoder<'a> { PrettyEncoder { writer, @@ -719,7 +718,7 @@ impl<'a> PrettyEncoder<'a> { /// Sets the number of spaces to indent for each level. /// This is safe to set during encoding. pub fn set_indent(&mut self, indent: usize) { - // self.indent very well could be 0 so we need to use checked division. + // `self.indent` could very well be `0`, so we need to use checked division. let level = self.curr_indent.checked_div(self.indent).unwrap_or(0); self.indent = indent; self.curr_indent = level * self.indent; @@ -1023,14 +1022,14 @@ pub fn as_pretty_json(t: &T) -> AsPrettyJson<'_, T> { } impl Json { - /// Borrow this json object as a pretty object to generate a pretty + /// Borrows this `Json` object as a pretty object to generate a pretty /// representation for it via `Display`. pub fn pretty(&self) -> PrettyJson<'_> { PrettyJson { inner: self } } - /// If the Json value is an Object, returns the value associated with the provided key. - /// Otherwise, returns None. + /// If the `Json` value is an `Object`, returns the value associated with the provided key; + /// otherwise, returns `None`. pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{ match *self { Json::Object(ref map) => map.get(key), @@ -1038,9 +1037,9 @@ impl Json { } } - /// Attempts to get a nested Json Object for each key in `keys`. + /// Attempts to get a nested `Json::Object` for each key in `keys`. /// If any key is found not to exist, `find_path` will return `None`. - /// Otherwise, it will return the Json value associated with the final key. + /// Otherwise, it will return the `Json` value associated with the final key. pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{ let mut target = self; for key in keys { @@ -1049,9 +1048,9 @@ impl Json { Some(target) } - /// If the Json value is an Object, performs a depth-first search until + /// If the `Json` value is an `Object`, performs a depth-first search until /// a value associated with the provided key is found. If no value is found - /// or the Json value is not an Object, returns `None`. + /// or the `Json` value is not an `Object`, returns `None`. pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> { match self { &Json::Object(ref map) => { @@ -1072,13 +1071,13 @@ impl Json { } } - /// Returns `true` if the Json value is an `Object`. + /// Returns `true` if the `Json` value is an `Object`. pub fn is_object(&self) -> bool { self.as_object().is_some() } - /// If the Json value is an `Object`, returns the associated `BTreeMap`; - /// returns `None` otherwise. + /// If the `Json` value is an `Object`, returns the associated `BTreeMap`; + /// otherwise, returns `None`. pub fn as_object(&self) -> Option<&Object> { match *self { Json::Object(ref map) => Some(map), @@ -1086,13 +1085,13 @@ impl Json { } } - /// Returns `true` if the Json value is an `Array`. + /// Returns `true` if the `Json` value is an `Array`. pub fn is_array(&self) -> bool { self.as_array().is_some() } - /// If the Json value is an `Array`, returns the associated vector; - /// returns `None` otherwise. + /// If the `Json` value is an `Array`, returns the associated vector; + /// otherwise, returns `None`. pub fn as_array(&self) -> Option<&Array> { match *self { Json::Array(ref array) => Some(&*array), @@ -1100,13 +1099,13 @@ impl Json { } } - /// Returns `true` if the Json value is a `String`. + /// Returns `true` if the `Json` value is a `String`. pub fn is_string(&self) -> bool { self.as_string().is_some() } - /// If the Json value is a `String`, returns the associated `str`; - /// returns `None` otherwise. + /// If the `Json` value is a `String`, returns the associated `str`; + /// otherwise, returns `None`. pub fn as_string(&self) -> Option<&str> { match *self { Json::String(ref s) => Some(&s[..]), @@ -1122,7 +1121,7 @@ impl Json { } } - /// Returns `true` if the Json value is a `i64`. + /// Returns `true` if the `Json` value is a `i64`. pub fn is_i64(&self) -> bool { match *self { Json::I64(_) => true, @@ -1130,7 +1129,7 @@ impl Json { } } - /// Returns `true` if the Json value is a `u64`. + /// Returns `true` if the `Json` value is a `u64`. pub fn is_u64(&self) -> bool { match *self { Json::U64(_) => true, @@ -1138,7 +1137,7 @@ impl Json { } } - /// Returns `true` if the Json value is a `f64`. + /// Returns `true` if the `Json` value is a `f64`. pub fn is_f64(&self) -> bool { match *self { Json::F64(_) => true, @@ -1146,8 +1145,8 @@ impl Json { } } - /// If the Json value is a number, returns or cast it to a `i64`; - /// returns `None` otherwise. + /// If the `Json` value is a number, returns or cast it to a `i64`; + /// otherwise, returns `None`. pub fn as_i64(&self) -> Option { match *self { Json::I64(n) => Some(n), @@ -1156,8 +1155,8 @@ impl Json { } } - /// If the Json value is a number, returns or cast it to a `u64`; - /// returns `None` otherwise. + /// If the `Json` value is a number, returns or cast it to a `u64`; + /// otherwise, returns `None`. pub fn as_u64(&self) -> Option { match *self { Json::I64(n) => Some(n as u64), @@ -1166,8 +1165,8 @@ impl Json { } } - /// If the Json value is a number, returns or cast it to a `f64`; - /// returns `None` otherwise. + /// If the `Json` value is a number, returns or cast it to a `f64`; + /// otherwise, returns `None`. pub fn as_f64(&self) -> Option { match *self { Json::I64(n) => Some(n as f64), @@ -1177,13 +1176,13 @@ impl Json { } } - /// Returns `true` if the Json value is a `Boolean`. + /// Returns `true` if the `Json` value is a `Boolean`. pub fn is_boolean(&self) -> bool { self.as_boolean().is_some() } - /// If the Json value is a `Boolean`, returns the associated `bool`; - /// returns `None` otherwise. + /// If the `Json` value is a `Boolean`, returns the associated `bool`; + /// otherwise, returns `None`. pub fn as_boolean(&self) -> Option { match *self { Json::Boolean(b) => Some(b), @@ -1191,13 +1190,12 @@ impl Json { } } - /// Returns `true` if the Json value is a `Null`. + /// Returns `true` if the `Json` value is a `Null`. pub fn is_null(&self) -> bool { self.as_null().is_some() } - /// If the Json value is a `Null`, returns `()`; - /// returns `None` otherwise. + /// If the `Json` value is a `Null`, returns `()`; otherwise, returns `None`. pub fn as_null(&self) -> Option<()> { match *self { Json::Null => Some(()), @@ -1259,30 +1257,30 @@ enum ParserState { ParseFinished, } -/// A Stack represents the current position of the parser in the logical -/// structure of the JSON stream. -/// For example foo.bar[3].x +/// Represents the current position of the parser in the logical structure of the JSON stream. +/// E.g., `foo.bar[3].x`. pub struct Stack { stack: Vec, str_buffer: Vec, } -/// StackElements compose a Stack. -/// For example, StackElement::Key("foo"), StackElement::Key("bar"), -/// StackElement::Index(3) and StackElement::Key("x") are the -/// StackElements compositing the stack that represents foo.bar[3].x +/// Elements that compose a `Stack`. +/// E.g., `StackElement::Key("foo")`, `StackElement::Key("bar")`, +/// `StackElement::Index(3)` and `StackElement::Key("x")` are the +/// `StackElement`s compositing the stack that represents `foo.bar[3].x`. #[derive(PartialEq, Clone, Debug)] pub enum StackElement<'l> { Index(u32), Key(&'l str), } -// Internally, Key elements are stored as indices in a buffer to avoid +// Internally, `Key` elements are stored as indices in a buffer to avoid // allocating a string for every member of an object. #[derive(PartialEq, Clone, Debug)] enum InternalStackElement { InternalIndex(u32), - InternalKey(u16, u16), // start, size + // `(start, size)` + InternalKey(u16, u16), } impl Stack { @@ -1290,15 +1288,14 @@ impl Stack { Stack { stack: Vec::new(), str_buffer: Vec::new() } } - /// Returns The number of elements in the Stack. + /// Returns the number of elements in the `Stack`. pub fn len(&self) -> usize { self.stack.len() } /// Returns `true` if the stack is empty. pub fn is_empty(&self) -> bool { self.stack.is_empty() } - /// Provides access to the StackElement at a given index. - /// lower indices are at the bottom of the stack while higher indices are - /// at the top. + /// Provides access to the `StackElement` at a given index. + /// Lower indices are at the bottom of the stack while higher indices are at the top. pub fn get(&self, idx: usize) -> StackElement<'_> { match self.stack[idx] { InternalIndex(i) => StackElement::Index(i), @@ -1310,7 +1307,7 @@ impl Stack { } } - /// Compares this stack with an array of StackElement<'_>s. + /// Compares this stack with an array of `StackElement<'_>`s. pub fn is_equal_to(&self, rhs: &[StackElement<'_>]) -> bool { if self.stack.len() != rhs.len() { return false; } for (i, r) in rhs.iter().enumerate() { @@ -1353,18 +1350,18 @@ impl Stack { } } - // Used by Parser to insert StackElement::Key elements at the top of the stack. + // Used by `Parser` to insert `StackElement::Key` elements at the top of the stack. fn push_key(&mut self, key: string::String) { self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16)); self.str_buffer.extend(key.as_bytes()); } - // Used by Parser to insert StackElement::Index elements at the top of the stack. + // Used by `Parser` to insert `StackElement::Index` elements at the top of the stack. fn push_index(&mut self, index: u32) { self.stack.push(InternalIndex(index)); } - // Used by Parser to remove the top-most element of the stack. + // Used by `Parser` to remove the top-most element of the stack. fn pop(&mut self) { assert!(!self.is_empty()); match *self.stack.last().unwrap() { @@ -1377,7 +1374,7 @@ impl Stack { self.stack.pop(); } - // Used by Parser to test whether the top-most element is an index. + // Used by `Parser` to test whether the top-most element is an index. fn last_is_index(&self) -> bool { match self.stack.last() { Some(InternalIndex(_)) => true, @@ -1385,7 +1382,7 @@ impl Stack { } } - // Used by Parser to increment the index of the top-most element. + // Used by `Parser` to increment the index of the top-most element. fn bump_index(&mut self) { let len = self.stack.len(); let idx = match *self.stack.last().unwrap() { @@ -1396,15 +1393,14 @@ impl Stack { } } -/// A streaming JSON parser implemented as an iterator of JsonEvent, consuming +/// A streaming JSON parser implemented as an iterator of `JsonEvent`, consuming /// an iterator of char. pub struct Parser { rdr: T, ch: Option, line: usize, col: usize, - // We maintain a stack representing where we are in the logical structure - // of the JSON stream. + // We maintain a stack representing where we are in the logical structure of the JSON stream. stack: Stack, // A state machine is kept to make it possible to interrupt and resume parsing. state: ParserState, @@ -1420,7 +1416,7 @@ impl> Iterator for Parser { if self.state == ParseBeforeFinish { self.parse_whitespace(); - // Make sure there is no trailing characters. + // Make sure there are no trailing characters. if self.eof() { self.state = ParseFinished; return None; @@ -1448,8 +1444,7 @@ impl> Parser { p } - /// Provides access to the current position in the logical structure of the - /// JSON stream. + /// Provides access to the current position in the logical structure of the JSON stream. pub fn stack(&self) -> &Stack { &self.stack } @@ -1537,7 +1532,8 @@ impl> Parser { fn parse_u64(&mut self) -> Result { let mut accum = 0u64; - let last_accum = 0; // necessary to detect overflow. + // Necessary to detect overflow. + let last_accum = 0; match self.ch_or_null() { '0' => { @@ -1727,17 +1723,17 @@ impl> Parser { } // Invoked at each iteration, consumes the stream until it has enough - // information to return a JsonEvent. + // information to return a `JsonEvent`. // Manages an internal state so that parsing can be interrupted and resumed. - // Also keeps track of the position in the logical structure of the json - // stream isize the form of a stack that can be queried by the user using the - // stack() method. + // Also keeps track of the position in the logical structure of the JSON + // stream `isize` in the form of a stack that can be queried by the user using + // the `stack()` method. fn parse(&mut self) -> JsonEvent { loop { // The only paths where the loop can spin a new iteration - // are in the cases ParseArrayComma and ParseObjectComma if ',' + // are in the cases `ParseArrayComma` and `ParseObjectComma` if ',' // is parsed. In these cases the state is set to (respectively) - // ParseArray(false) and ParseObject(false), which always return, + // `ParseArray(false)` and `ParseObject(false)`, which always return, // so there is no risk of getting stuck in an infinite loop. // All other paths return before the end of the loop's iteration. self.parse_whitespace(); @@ -1947,19 +1943,19 @@ impl> Parser { } } -/// A Builder consumes a json::Parser to create a generic Json structure. +/// Consumes a `json::Parser` to create a generic JSON structure. pub struct Builder { parser: Parser, token: Option, } -impl> Builder { - /// Creates a JSON Builder. +impl> Builder { + /// Creates a JSON `Builder`. pub fn new(src: T) -> Builder { Builder { parser: Parser::new(src), token: None, } } - // Decode a Json value from a Parser. + // Decodes a `Json` value from a `Parser`. pub fn build(&mut self) -> Result { self.bump(); let result = self.build_value(); @@ -2039,7 +2035,7 @@ impl> Builder { } } -/// Decodes a json value from an `&mut io::Read` +/// Decodes a JSON value from an `&mut io::Read`. pub fn from_reader(rdr: &mut dyn Read) -> Result { let mut contents = Vec::new(); match rdr.read_to_end(&mut contents) { @@ -2054,19 +2050,19 @@ pub fn from_reader(rdr: &mut dyn Read) -> Result { builder.build() } -/// Decodes a json value from a string +/// Decodes a JSON value from a string. pub fn from_str(s: &str) -> Result { let mut builder = Builder::new(s.chars()); builder.build() } -/// A structure to decode JSON to values in rust. +/// Decodes JSON into Rust values. pub struct Decoder { stack: Vec, } impl Decoder { - /// Creates a new decoder instance for decoding the specified JSON value. + /// Creates a new decoder instance for decoding the specified `Json` value. pub fn new(json: Json) -> Decoder { Decoder { stack: vec![json] } } @@ -2102,8 +2098,8 @@ macro_rules! read_primitive { Json::I64(f) => Ok(f as $ty), Json::U64(f) => Ok(f as $ty), Json::F64(f) => Err(ExpectedError("Integer".to_owned(), f.to_string())), - // re: #12967.. a type w/ numeric keys (ie HashMap etc) - // is going to have a string here, as per JSON spec. + // Issue #12967: a type with numeric keys (e.g., `HashMap`) + // is going to have a string here, as per the JSON spec. Json::String(s) => match s.parse().ok() { Some(f) => Ok(f), None => Err(ExpectedError("Number".to_owned(), s)), @@ -2142,8 +2138,8 @@ impl crate::Decoder for Decoder { Json::U64(f) => Ok(f as f64), Json::F64(f) => Ok(f), Json::String(s) => { - // re: #12967.. a type w/ numeric keys (ie HashMap etc) - // is going to have a string here, as per JSON spec. + // Issue #12967: a type with numeric keys (e.g., `HashMap`) + // is going to have a string here, as per the JSON spec. match s.parse().ok() { Some(f) => Ok(f), None => Err(ExpectedError("Number".to_owned(), s)), @@ -2163,7 +2159,7 @@ impl crate::Decoder for Decoder { { let mut it = s.chars(); match (it.next(), it.next()) { - // exactly one character + // Exactly one character. (Some(c), None) => return Ok(c), _ => () } @@ -2263,8 +2259,8 @@ impl crate::Decoder for Decoder { let value = match obj.remove(&name.to_string()) { None => { - // Add a Null and try to parse it as an Option<_> - // to get None as a default value. + // Add a `Null` and try to parse it as an `Option<_>` + // to get `None` as a default value. self.stack.push(Json::Null); match f(self) { Ok(x) => x, @@ -2370,9 +2366,9 @@ impl crate::Decoder for Decoder { } } -/// A trait for converting values to JSON +/// Converts values to JSON. pub trait ToJson { - /// Converts the value of `self` to an instance of JSON + /// Converts the value of `self` to an instance of `Json`. fn to_json(&self) -> Json; } @@ -2434,9 +2430,9 @@ impl ToJson for string::String { } macro_rules! tuple_impl { - // use variables to indicate the arity of the tuple + // Use variables to indicate the arity of the tuple. ($($tyvar:ident),* ) => { - // the trailing commas are for the 1 tuple + // The trailing commas are for the 1-tuple. impl< $( $tyvar : ToJson ),* > ToJson for ( $( $tyvar ),* , ) { @@ -2516,7 +2512,7 @@ impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> { } impl fmt::Display for Json { - /// Encodes a json value into a string + /// Encodes a `Json` value as a string. fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut shim = FormatShim { inner: f }; let mut encoder = Encoder::new(&mut shim); @@ -2528,7 +2524,7 @@ impl fmt::Display for Json { } impl<'a> fmt::Display for PrettyJson<'a> { - /// Encodes a json value into a string + /// Encodes a `PrettyJson` value as a string. fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut shim = FormatShim { inner: f }; let mut encoder = PrettyEncoder::new(&mut shim); @@ -2540,7 +2536,7 @@ impl<'a> fmt::Display for PrettyJson<'a> { } impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> { - /// Encodes a json value into a string + /// Encodes an `AsJson` value as a string. fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut shim = FormatShim { inner: f }; let mut encoder = Encoder::new(&mut shim); @@ -2552,7 +2548,7 @@ impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> { } impl<'a, T> AsPrettyJson<'a, T> { - /// Sets the indentation level for the emitted JSON + /// Sets the indentation level for the emitted JSON. pub fn indent(mut self, indent: usize) -> AsPrettyJson<'a, T> { self.indent = Some(indent); self @@ -2560,7 +2556,7 @@ impl<'a, T> AsPrettyJson<'a, T> { } impl<'a, T: Encodable> fmt::Display for AsPrettyJson<'a, T> { - /// Encodes a json value into a string + /// Encodes an `AsPrettyJson` value as a string. fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut shim = FormatShim { inner: f }; let mut encoder = PrettyEncoder::new(&mut shim); @@ -2583,7 +2579,7 @@ impl FromStr for Json { #[cfg(test)] mod tests { - // Benchmarks and tests that require private items + // Benchmarks and tests that require private items. extern crate test; use test::Bencher; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index beecfb1aa295f..12c1d5e2f6184 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -64,8 +64,8 @@ impl DefaultResizePolicy { // This doesn't have to be checked for overflow since allocation size // in bytes will overflow earlier than multiplication by 10. // - // As per https://github.com/rust-lang/rust/pull/30991 this is updated - // to be: (raw_cap * den + den - 1) / num + // As per PR #30991, this is updated + // to be `(raw_cap * den + den - 1) / num`. (raw_cap * 10 + 10 - 1) / 11 } } @@ -231,7 +231,7 @@ const DISPLACEMENT_THRESHOLD: usize = 128; /// subject to change at any point in the future. While its performance is very /// competitive for medium sized keys, other hashing algorithms will outperform /// it for small keys such as integers as well as large keys such as long -/// strings, though those algorithms will typically *not* protect against +/// strings, though those algorithms will typically **not** protect against /// attacks such as HashDoS. /// /// The hashing algorithm can be replaced on a per-`HashMap` basis using the @@ -1671,7 +1671,7 @@ pub struct Iter<'a, K: 'a, V: 'a> { inner: table::Iter<'a, K, V>, } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Clone for Iter<'a, K, V> { fn clone(&self) -> Iter<'a, K, V> { @@ -1724,7 +1724,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { inner: Iter<'a, K, V>, } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Clone for Keys<'a, K, V> { fn clone(&self) -> Keys<'a, K, V> { @@ -1753,7 +1753,7 @@ pub struct Values<'a, K: 'a, V: 'a> { inner: Iter<'a, K, V>, } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Clone for Values<'a, K, V> { fn clone(&self) -> Values<'a, K, V> { diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 92e63df7c682e..d4eff5ae1d0d9 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -10,7 +10,7 @@ use super::map::{self, HashMap, Keys, RandomState}; // Future Optimization (FIXME!) // ============================= // -// Iteration over zero sized values is a noop. There is no need +// Iteration over zero sized values is a no-op. There is no need // for `bucket.val` in the case of HashSet. I suppose we would need HKT // to get rid of it properly. diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 9446a80a55cd2..2ca85afe29163 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -655,7 +655,7 @@ fn calculate_layout(capacity: usize) -> Result<(Layout, usize), LayoutErr> // possibly due to the use of NonZeroUsize. This little hack allows it // to generate optimal code. // - // See https://github.com/rust-lang/rust/issues/51346 for more details. + // See issue #51346 for more details. ( layout, hashes.size() + hashes.padding_needed_for(mem::align_of::<(K, V)>()), @@ -823,9 +823,9 @@ impl RawTable { /// Drops buckets in reverse order. It leaves the table in an inconsistent /// state and should only be used for dropping the table's remaining - /// entries. It's used in the implementation of Drop. + /// entries. It's used in the implementation of `Drop`. unsafe fn rev_drop_buckets(&mut self) { - // initialize the raw bucket past the end of the table + // Initialize the raw bucket past the end of the table. let mut raw = self.raw_bucket_at(self.capacity()); let mut elems_left = self.size; @@ -864,7 +864,7 @@ struct RawBuckets<'a, K, V> { marker: marker::PhantomData<&'a ()>, } -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. impl<'a, K, V> Clone for RawBuckets<'a, K, V> { fn clone(&self) -> RawBuckets<'a, K, V> { RawBuckets { @@ -915,7 +915,7 @@ pub struct Iter<'a, K: 'a, V: 'a> { unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {} unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {} -// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +// FIXME(#26925): remove in favor of `#[derive(Clone)]`. impl<'a, K, V> Clone for Iter<'a, K, V> { fn clone(&self) -> Iter<'a, K, V> { Iter { @@ -932,8 +932,8 @@ pub struct IterMut<'a, K: 'a, V: 'a> { } unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {} -// Both K: Sync and K: Send are correct for IterMut's Send impl, -// but Send is the more useful bound +// Both `K: Sync` and `K: Send` are correct for `IterMut`'s `Send` impl, +// but `Send` is the more useful bound. unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {} impl<'a, K: 'a, V: 'a> IterMut<'a, K, V> { diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 1f3b264c414a2..dfa1eabf16fdb 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -479,7 +479,7 @@ pub struct JoinPathsError { /// ``` #[stable(feature = "env", since = "1.0.0")] pub fn join_paths(paths: I) -> Result - where I: IntoIterator, T: AsRef + where I: IntoIterator, T: AsRef { os_imp::join_paths(paths.into_iter()).map_err(|e| { JoinPathsError { inner: e } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 7fa7b80751938..dd99365191fde 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -990,7 +990,7 @@ mod tests { assert_eq!(Fp::Zero, neg_zero.classify()); } - #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 + #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn test_one() { let one: f64 = 1.0f64; @@ -1043,7 +1043,7 @@ mod tests { assert!((-109.2f64).is_finite()); } - #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 + #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn test_is_normal() { let nan: f64 = NAN; @@ -1061,7 +1061,7 @@ mod tests { assert!(!1e-308f64.is_normal()); } - #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630 + #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue #42630 #[test] fn test_classify() { let nan: f64 = NAN; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index caf490a02777e..04649e63106d9 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -49,7 +49,7 @@ use sys; /// /// Alternatively, you can obtain a `&[`[`u8`]`]` slice from a /// `CString` with the [`as_bytes`] method. Slices produced in this -/// way do *not* contain the trailing nul terminator. This is useful +/// way do **not** contain the trailing nul terminator. This is useful /// when you will be calling an extern function that takes a `*const /// u8` argument which is not necessarily nul-terminated, plus another /// argument with the length of the string — like C's `strndup()`. @@ -406,7 +406,7 @@ impl CString { /// /// The pointer which this function returns must be returned to Rust and reconstituted using /// [`from_raw`] to be properly deallocated. Specifically, one - /// should *not* use the standard C `free()` function to deallocate + /// should **not** use the standard C `free()` function to deallocate /// this string. /// /// Failure to call [`from_raw`] will lead to a memory leak. diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 7dbf15cdc90ab..18fe01c658e69 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -25,7 +25,7 @@ use sys_common::{AsInner, IntoInner, FromInner}; /// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust /// and platform-native string values, and in particular allowing a Rust string /// to be converted into an "OS" string with no cost if possible. A consequence -/// of this is that `OsString` instances are *not* `NUL` terminated; in order +/// of this is that `OsString` instances are **not** `NUL` terminated; in order /// to pass to e.g., Unix system call, you should create a [`CStr`]. /// /// `OsString` is to [`&OsStr`] as [`String`] is to [`&str`]: the former @@ -834,7 +834,7 @@ impl PartialOrd for OsStr { } } -// FIXME (#19470): cannot provide PartialOrd for str until we +// FIXME(#19470): cannot provide PartialOrd for str until we // have more flexible coherence rules. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index f1e8619fc8ffc..c955dd048b8f0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -214,7 +214,7 @@ pub struct DirBuilder { /// How large a buffer to pre-allocate before reading the entire file. fn initial_buffer_size(file: &File) -> usize { // Allocate one extra byte so the buffer doesn't need to grow before the - // final `read` call at the end of the file. Don't worry about `usize` + // final `read` call at the end of the file. Don't worry about `usize` // overflow because reading will fail regardless in that case. file.metadata().map(|m| m.len() as usize + 1).unwrap_or(0) } @@ -1518,7 +1518,7 @@ pub fn symlink_metadata>(path: P) -> io::Result { /// Because of this, the behavior when both `from` and `to` exist differs. On /// Unix, if `from` is a directory, `to` must also be an (empty) directory. If /// `from` is not a directory, `to` must also be not a directory. In contrast, -/// on Windows, `from` can be anything, but `to` must *not* be a directory. +/// on Windows, `from` can be anything, but `to` must **not** be a directory. /// /// Note that, this [may change in the future][changes]. /// diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index c0570ae60a19c..4247377441e00 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -607,7 +607,7 @@ pub trait Read { /// /// # Errors /// - /// If the data in this stream is *not* valid UTF-8 then an error is + /// If the data in this stream is **not** valid UTF-8 then an error is /// returned and `buf` is unchanged. /// /// See [`read_to_end`][readtoend] for other error semantics. @@ -640,7 +640,7 @@ pub trait Read { /// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html #[stable(feature = "rust1", since = "1.0.0")] fn read_to_string(&mut self, buf: &mut String) -> Result { - // Note that we do *not* call `.read_to_end()` here. We are passing + // Note that we do **not** call `.read_to_end()` here. We are passing // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` // method to fill it up. An arbitrary implementation could overwrite the // entire contents of the vector, not just append to it (which is what @@ -1514,7 +1514,7 @@ pub trait BufRead: Read { /// `byte`. /// /// The iterator returned from this function will return instances of - /// [`io::Result`]`<`[`Vec`]`>`. Each vector returned will *not* have + /// [`io::Result`]`<`[`Vec`]`>`. Each vector returned will **not** have /// the delimiter byte at the end. /// /// This function will yield errors whenever [`read_until`] would have @@ -1551,7 +1551,7 @@ pub trait BufRead: Read { /// Returns an iterator over the lines of this reader. /// /// The iterator returned from this function will yield instances of - /// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline + /// [`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 diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b9204d27f5392..5d97717846c2f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -316,7 +316,7 @@ macro_rules! eprintln { macro_rules! dbg { ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes - // of temporaries - https://stackoverflow.com/a/48732525/1063961 + // of temporaries - . match $val { tmp => { eprintln!("[{}:{}] {} = {:#?}", @@ -344,7 +344,7 @@ macro_rules! await { { break x; } - // FIXME(cramertj) prior to stabilizing await, we have to ensure that this + // FIXME(cramertj): prior to stabilizing await, we have to ensure that this // can't be used to create a generator on stable via `|| await!()`. yield } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 654ad64d97b36..1d3e83ee943de 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -787,7 +787,7 @@ pub trait ToSocketAddrs { /// Returned iterator over socket addresses which this type may correspond /// to. #[stable(feature = "rust1", since = "1.0.0")] - type Iter: Iterator; + type Iter: Iterator; /// Converts this object to an iterator of resolved `SocketAddr`s. /// diff --git a/src/libstd/num.rs b/src/libstd/num.rs index c80b9a56704a7..9eb583f7de7c4 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -21,9 +21,9 @@ pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, #[cfg(test)] pub fn test_num(ten: T, two: T) where T: PartialEq - + Add + Sub - + Mul + Div - + Rem + fmt::Debug + + Add + Sub + + Mul + Div + + Rem + fmt::Debug + Copy { assert_eq!(ten.add(two), ten + two); @@ -188,7 +188,7 @@ mod tests { #[test] fn test_pow() { - fn naive_pow + Copy>(one: T, base: T, exp: usize) -> T { + fn naive_pow + Copy>(one: T, base: T, exp: usize) -> T { (0..exp).fold(one, |acc, _| acc * base) } macro_rules! assert_pow { diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index aaffc9bad4547..b8fde41c04926 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -174,7 +174,8 @@ fn default_hook(info: &PanicInfo) { } }; - let location = info.location().unwrap(); // The current implementation always returns Some + // The current implementation always returns `Some`. + let location = info.location().unwrap(); let msg = match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, @@ -199,7 +200,7 @@ fn default_hook(info: &PanicInfo) { if let Some(format) = log_backtrace { let _ = backtrace::print(err, format); } else if FIRST_PANIC.compare_and_swap(true, false, Ordering::SeqCst) { - let _ = writeln!(err, "note: Run with `RUST_BACKTRACE=1` \ + let _ = writeln!(err, "note: run with `RUST_BACKTRACE=1` \ environment variable to display a backtrace."); } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 0f1d627fa1e85..80ab01a765e49 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -91,7 +91,7 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; // // Parsing in this module is done by directly transmuting OsStr to [u8] slices, // taking advantage of the fact that OsStr always encodes ASCII characters -// as-is. Eventually, this transmutation should be replaced by direct uses of +// as-is. Eventually, this transmutation should be replaced by direct uses of // OsStr APIs for parsing, but it will take a while for those to become // available. @@ -104,7 +104,7 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; /// Windows uses a variety of path prefix styles, including references to drive /// volumes (like `C:`), network shared folders (like `\\server\share`), and /// others. In addition, some path prefixes are "verbatim" (i.e., prefixed with -/// `\\?\`), in which case `/` is *not* treated as a separator and essentially +/// `\\?\`), in which case `/` is **not** treated as a separator and essentially /// no normalization is performed. /// /// # Examples @@ -597,19 +597,19 @@ impl<'a> AsRef for Component<'a> { #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Components<'a> { - // The path left to parse components from + // The path left to parse components from. path: &'a [u8], - // The prefix as it was originally parsed, if any + // The prefix as it was originally parsed, if any. prefix: Option>, - // true if path *physically* has a root separator; for most Windows - // prefixes, it may have a "logical" rootseparator for the purposes of - // normalization, e.g., \\server\share == \\server\share\. + // `true` if path *physically* has a root separator; for most Windows + // prefixes, it may have a "logical" root separator for the purposes of + // normalization (e.g., `\\server\share == \\server\share\`). has_physical_root: bool, // The iterator is double-ended, and these two states keep track of what has - // been produced from either end + // been produced from either end. front: State, back: State, } @@ -1202,7 +1202,7 @@ impl PathBuf { // in general, a separator is needed if the rightmost byte is not a separator let mut need_sep = self.as_mut_vec().last().map(|c| !is_sep_byte(*c)).unwrap_or(false); - // in the special case of `C:` on Windows, do *not* add a separator + // in the special case of `C:` on Windows, do **not** add a separator { let comps = self.components(); if comps.prefix_len() > 0 && comps.prefix_len() == comps.path.len() && @@ -1822,7 +1822,7 @@ impl Path { #[allow(deprecated)] pub fn is_absolute(&self) -> bool { if cfg!(target_os = "redox") { - // FIXME: Allow Redox prefixes + // FIXME: allow Redox prefixes. self.has_root() || has_redox_scheme(self.as_u8_slice()) } else { self.has_root() && (cfg!(unix) || self.prefix().is_some()) @@ -3789,7 +3789,7 @@ mod tests { tp!("\\\\?\\UNC\\server\\share", "C:\\a", "C:\\a"); tp!("\\\\?\\UNC\\server\\share", "C:a", "C:a"); - // Note: modified from old path API + // Note: modified from old path API. tp!("\\\\?\\UNC\\server", "foo", "\\\\?\\UNC\\server\\foo"); tp!("C:\\a", @@ -3797,10 +3797,11 @@ mod tests { "\\\\?\\UNC\\server\\share"); tp!("\\\\.\\foo\\bar", "baz", "\\\\.\\foo\\bar\\baz"); tp!("\\\\.\\foo\\bar", "C:a", "C:a"); - // again, not sure about the following, but I'm assuming \\.\ should be verbatim + // Again, not sure about the following, but I'm assuming `\\.\` should be verbatim. tp!("\\\\.\\foo", "..\\bar", "\\\\.\\foo\\..\\bar"); - tp!("\\\\?\\C:", "foo", "\\\\?\\C:\\foo"); // this is a weird one + // This is a weird one. + tp!("\\\\?\\C:", "foo", "\\\\?\\C:\\foo"); } } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a2ef85016d8a2..182c54ff9151b 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -507,7 +507,7 @@ impl Command { /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn args(&mut self, args: I) -> &mut Command - where I: IntoIterator, S: AsRef + where I: IntoIterator, S: AsRef { for arg in args { self.arg(arg.as_ref()); @@ -1629,7 +1629,7 @@ mod tests { use str; use super::{Command, Output, Stdio}; - // FIXME(#10380) these tests should not all be ignored on android. + // FIXME(#10380): these tests should not all be ignored on Android. #[test] #[cfg_attr(target_os = "android", ignore)] diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 5273345c6b4fd..cf6869fbe5594 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -219,7 +219,7 @@ // // The recv() method has a beginning call to pop(), and if successful, it needs // to decrement the count. It is a crucial implementation detail that this -// decrement does *not* happen to the shared counter. If this were the case, +// decrement does **not** happen to the shared counter. If this were the case, // then it would be possible for the counter to be very negative when there were // no receivers waiting, in which case the senders would have to determine when // it was actually appropriate to wake up a receiver. @@ -791,7 +791,7 @@ impl Sender { /// the channel has not hung up already. An unsuccessful send would be one /// where the corresponding receiver has already been deallocated. Note /// that a return value of [`Err`] means that the data will never be - /// received, but a return value of [`Ok`] does *not* mean that the data + /// received, but a return value of [`Ok`] does **not** mean that the data /// will be received. It is possible for the corresponding receiver to /// hang up immediately after this function returns [`Ok`]. /// @@ -933,7 +933,7 @@ impl SyncSender { /// This function will *block* until space in the internal buffer becomes /// available or a receiver is available to hand off the message to. /// - /// Note that a successful send does *not* guarantee that the receiver will + /// Note that a successful send does **not** guarantee that the receiver will /// ever see the data if there is a buffer on this channel. Items may be /// enqueued in the internal buffer for the receiver to receive at a later /// time. If the buffer size is 0, however, the channel becomes a rendezvous diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8f6f9818d5c76..10d95060b409c 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -84,8 +84,8 @@ pub struct Handle<'rx, T:Send+'rx> { added: bool, packet: &'rx (dyn Packet+'rx), - // due to our fun transmutes, we be sure to place this at the end. (nothing - // previous relies on T) + // Due to our fun transmutes, we be sure to place this at the end. (Nothing + // previous relies on `T`). rx: &'rx Receiver, } @@ -131,7 +131,7 @@ impl Select { } /// Creates a new handle into this receiver set for a new receiver. Note - /// that this does *not* add the receiver to the receiver set, for that you + /// that this does **not** add the receiver to the receiver set, for that you /// must call the `add` method on the handle itself. pub fn handle<'a, T: Send>(&'a self, rx: &'a Receiver) -> Handle<'a, T> { let id = self.next_id.get(); @@ -147,7 +147,7 @@ impl Select { } } - /// Waits for an event on this receiver set. The returned value is *not* an + /// Waits for an event on this receiver set. The returned value is **not** an /// index, but rather an ID. This ID can be queried against any active /// `Handle` structures (each one has an `id` method). The handle with /// the matching `id` will have some sort of event available on it. The @@ -180,7 +180,7 @@ impl Select { // Most notably, the iterations over all of the receivers shouldn't be // necessary. unsafe { - // Stage 1: preflight checks. Look for any packets ready to receive + // Stage 1: pre-flight checks. Look for any packets ready to receive. if do_preflight_checks { for handle in self.iter() { if (*handle).packet.can_recv() { @@ -189,7 +189,7 @@ impl Select { } } - // Stage 2: begin the blocking process + // Stage 2: begin the blocking process. // // Create a number of signal tokens, and install each one // sequentially until one fails. If one fails, then abort the @@ -199,7 +199,7 @@ impl Select { match (*handle).packet.start_selection(signal_token.clone()) { StartResult::Installed => {} StartResult::Abort => { - // Go back and abort the already-begun selections + // Go back and abort the already-begun selections. for handle in self.iter().take(i) { (*handle).packet.abort_selection(); } @@ -208,7 +208,7 @@ impl Select { } } - // Stage 3: no messages available, actually block + // Stage 3: no messages available, actually block. wait_token.wait(); // Stage 4: there *must* be message available; find it. @@ -220,13 +220,13 @@ impl Select { // woken us up (although the wakeup is guaranteed to fail). // // This situation happens in the window of where a sender invokes - // increment(), sees -1, and then decides to wake up the thread. After + // increment(), sees `-1`, and then decides to wake up the thread. After // all this is done, the sending thread will set `selecting` to // `false`. Until this is done, we cannot return. If we were to // return, then a sender could wake up a receiver which has gone // back to sleep after this call to `select`. // - // Note that it is a "fairly small window" in which an increment() + // Note that it is a "fairly small window" in which an `increment()` // views that it should wake a thread up until the `selecting` bit // is set to false. For now, the implementation currently just spins // in a yield loop. This is very distasteful, but this diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index 3da73ac0b822e..ce9da9bb07b67 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -35,20 +35,22 @@ const MAX_STEALS: isize = 1 << 20; pub struct Packet { queue: mpsc::Queue, - cnt: AtomicIsize, // How many items are on this channel - steals: UnsafeCell, // How many times has a port received without blocking? - to_wake: AtomicUsize, // SignalToken for wake up + // The number of items on this channel. + cnt: AtomicIsize, + // The number of times a port has received without blocking. + steals: UnsafeCell, + // `SignalToken` for wake up. + to_wake: AtomicUsize, // The number of channels which are currently using this packet. channels: AtomicUsize, - // See the discussion in Port::drop and the channel send methods for what - // these are used for + // See the discussion in `Port::drop` and the channel `send_*` methods for what + // these are used for. port_dropped: AtomicBool, sender_drain: AtomicIsize, - // this lock protects various portions of this implementation during - // select() + // This lock protects various portions of this implementation during `select()`. select_lock: Mutex<()>, } @@ -58,8 +60,8 @@ pub enum Failure { } impl Packet { - // Creation of a packet *must* be followed by a call to postinit_lock - // and later by inherit_blocker + // Creation of a packet *must* be followed by a call to `postinit_lock`, + // and later by `inherit_blocker`. pub fn new() -> Packet { Packet { queue: mpsc::Queue::new(), @@ -74,19 +76,19 @@ impl Packet { } // This function should be used after newly created Packet - // was wrapped with an Arc + // was wrapped with an `Arc` // In other case mutex data will be duplicated while cloning // and that could cause problems on platforms where it is - // represented by opaque data structure + // represented by opaque data structure. pub fn postinit_lock(&self) -> MutexGuard<()> { self.select_lock.lock().unwrap() } // This function is used at the creation of a shared packet to inherit a // previously blocked thread. This is done to prevent spurious wakeups of - // threads in select(). + // threads in `select()`. // - // This can only be called at channel-creation time + // This can only be called at channel-creation time. pub fn inherit_blocker(&self, token: Option, guard: MutexGuard<()>) { @@ -101,32 +103,32 @@ impl Packet { // this shared channel. In doing so, we never spuriously wake them // up and rather only wake them up at the appropriate time. This // implementation of shared channels assumes that any blocking - // recv() will undo the increment of steals performed in try_recv() - // once the recv is complete. This thread that we're inheriting, - // however, is not in the middle of recv. Hence, the first time we + // `recv()` will undo the increment of steals performed in `try_recv()` + // once the `recv` is complete. This thread that we're inheriting, + // however, is not in the middle of `recv`. Hence, the first time we // wake them up, they're going to wake up from their old port, move - // on to the upgraded port, and then call the block recv() function. + // on to the upgraded port, and then call the block `recv()` function. // // When calling this function, they'll find there's data immediately // available, counting it as a steal. This in fact wasn't a steal // because we appropriately blocked them waiting for data. // // To offset this bad increment, we initially set the steal count to - // -1. You'll find some special code in abort_selection() as well to - // ensure that this -1 steal count doesn't escape too far. + // `-1`. You'll find some special code in `abort_selection()` as well to + // ensure that this `-1` steal count doesn't escape too far. unsafe { *self.steals.get() = -1; } }); // When the shared packet is constructed, we grabbed this lock. The - // purpose of this lock is to ensure that abort_selection() doesn't + // purpose of this lock is to ensure that `abort_selection()` doesn't // interfere with this method. After we unlock this lock, we're - // signifying that we're done modifying self.cnt and self.to_wake and + // signifying that we're done modifying `self.cnt` and self.to_wake and // the port is ready for the world to continue using it. drop(guard); } pub fn send(&self, t: T) -> Result<(), T> { - // See Port::drop for what's going on + // See `Port::drop` for what's going on. if self.port_dropped.load(Ordering::SeqCst) { return Err(t) } // Note that the multiple sender case is a little trickier @@ -174,14 +176,14 @@ impl Packet { // much as possible, and then can only exit when they are the // only pusher (otherwise they must try again). n if n < DISCONNECTED + FUDGE => { - // see the comment in 'try' for a shared channel for why this + // See the comment in 'try' for a shared channel for why this // window of "not disconnected" is ok. self.cnt.store(DISCONNECTED, Ordering::SeqCst); if self.sender_drain.fetch_add(1, Ordering::SeqCst) == 0 { loop { - // drain the queue, for info on the thread yield see the - // discussion in try_recv + // Drain the queue. For info on the thread yield, see the + // discussion in `try_recv`. loop { match self.queue.pop() { mpsc::Data(..) => {} @@ -189,7 +191,7 @@ impl Packet { mpsc::Inconsistent => thread::yield_now(), } } - // maybe we're done, if we're not the last ones + // Maybe we're done. If we're not the last ones // here, then we need to go try again. if self.sender_drain.fetch_sub(1, Ordering::SeqCst) == 1 { break @@ -212,7 +214,7 @@ impl Packet { pub fn recv(&self, deadline: Option) -> Result { // This code is essentially the exact same as that found in the stream - // case (see stream.rs) + // case (see `stream.rs`). match self.try_recv() { Err(Empty) => {} data => return data, @@ -237,7 +239,7 @@ impl Packet { } // Essentially the exact same thing as the stream decrement function. - // Returns true if blocking should proceed. + // Returns `true` if blocking should proceed. fn decrement(&self, token: SignalToken) -> StartResult { unsafe { assert_eq!(self.to_wake.load(Ordering::SeqCst), 0); @@ -249,7 +251,7 @@ impl Packet { match self.cnt.fetch_sub(1 + steals, Ordering::SeqCst) { DISCONNECTED => { self.cnt.store(DISCONNECTED, Ordering::SeqCst); } // If we factor in our steals and notice that the channel has no - // data, we successfully sleep + // data, we successfully sleep. n => { assert!(n >= 0); if n - steals <= 0 { return Installed } @@ -268,8 +270,8 @@ impl Packet { mpsc::Empty => None, // This is a bit of an interesting case. The channel is reported as - // having data available, but our pop() has failed due to the queue - // being in an inconsistent state. This means that there is some + // having data available, but our `pop()` has failed due to the queue + // being in an inconsistent state. This means that there is some // pusher somewhere which has yet to complete, but we are guaranteed // that a pop will eventually succeed. In this case, we spin in a // yield loop because the remote sender should finish their enqueue @@ -333,11 +335,11 @@ impl Packet { } // Prepares this shared packet for a channel clone, essentially just bumping - // a refcount. + // a ref count. pub fn clone_chan(&self) { let old_count = self.channels.fetch_add(1, Ordering::SeqCst); - // See comments on Arc::clone() on why we do this (for `mem::forget`). + // See comments on `Arc::clone()` on why we do this (for `mem::forget`). if old_count > MAX_REFCOUNT { unsafe { abort(); @@ -345,7 +347,7 @@ impl Packet { } } - // Decrement the reference count on a channel. This is called whenever a + // Decrements the reference count on a channel. This is called whenever a // Chan is dropped and may end up waking up a receiver. It's the receiver's // responsibility on the other end to figure out that we've disconnected. pub fn drop_chan(&self) { @@ -362,7 +364,7 @@ impl Packet { } } - // See the long discussion inside of stream.rs for why the queue is drained, + // See the long discussion inside of `stream`.rs for why the queue is drained, // and why it is done in this fashion. pub fn drop_port(&self) { self.port_dropped.store(true, Ordering::SeqCst); @@ -404,7 +406,7 @@ impl Packet { cnt == DISCONNECTED || cnt - unsafe { *self.steals.get() } > 0 } - // increment the count on the channel (used for selection) + // Increments the count on the channel (used for selection). fn bump(&self, amt: isize) -> isize { match self.cnt.fetch_add(amt, Ordering::SeqCst) { DISCONNECTED => { @@ -418,7 +420,7 @@ impl Packet { // Inserts the signal token for selection on this port, returning true if // blocking should proceed. // - // The code here is the same as in stream.rs, except that it doesn't need to + // The code here is the same as in `stream.rs`, except that it doesn't need to // peek at the channel to see if an upgrade is pending. pub fn start_selection(&self, token: SignalToken) -> StartResult { match self.decrement(token) { @@ -441,14 +443,14 @@ impl Packet { // doing this is to ensure that any upgrade-in-progress is gone and // done with. Without this bounce, we can race with inherit_blocker // about looking at and dealing with to_wake. Once we have acquired the - // lock, we are guaranteed that inherit_blocker is done. + // lock, we are guaranteed that `inherit_blocker` is done. { let _guard = self.select_lock.lock().unwrap(); } // Like the stream implementation, we want to make sure that the count // on the channel goes non-negative. We don't know how negative the - // stream currently is, so instead of using a steal value of 1, we load + // stream currently is, so instead of using a steal value of `1`, we load // the channel count and figure out what we should do to make it // positive. let steals = { @@ -471,7 +473,7 @@ impl Packet { } } unsafe { - // if the number of steals is -1, it was the pre-emptive -1 steal + // if the number of steals is `-1`, it was the pre-emptive `-1` steal. // count from when we inherited a blocker. This is fine because // we're just going to overwrite it with a real value. let old = self.steals.get(); diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs index 5c68930bf4730..159523e84f302 100644 --- a/src/libstd/sync/mpsc/stream.rs +++ b/src/libstd/sync/mpsc/stream.rs @@ -1,4 +1,4 @@ -/// Stream channels +/// Stream channels. /// /// This is the flavor of channels which are optimized for one sender and one /// receiver. The sender will be upgraded to a shared channel if the channel is @@ -31,19 +31,23 @@ const MAX_STEALS: isize = 5; const MAX_STEALS: isize = 1 << 20; pub struct Packet { - // internal queue for all messages + // Internal queue for all messages. queue: spsc::Queue, ProducerAddition, ConsumerAddition>, } struct ProducerAddition { - cnt: AtomicIsize, // How many items are on this channel - to_wake: AtomicUsize, // SignalToken for the blocked thread to wake up + // The number of items on the channel. + cnt: AtomicIsize, + // `SignalToken` for the blocked thread to wake up. + to_wake: AtomicUsize, - port_dropped: AtomicBool, // flag if the channel has been destroyed. + // `true` if the channel has been destroyed. + port_dropped: AtomicBool, } struct ConsumerAddition { - steals: UnsafeCell, // How many times has a port received without blocking? + // The number of times a port received without blocking. + steals: UnsafeCell, } @@ -169,7 +173,7 @@ impl Packet { self.queue.producer_addition().cnt.store(DISCONNECTED, Ordering::SeqCst); } // If we factor in our steals and notice that the channel has no - // data, we successfully sleep + // data, we successfully sleep. n => { assert!(n >= 0); if n - steals <= 0 { return Ok(()) } @@ -187,8 +191,8 @@ impl Packet { data => return data, } - // Welp, our channel has no data. Deschedule the current thread and - // initiate the blocking protocol. + // Our channel has no data! Deschedule the current thread, + // and initiate the blocking protocol. let (wait_token, signal_token) = blocking::tokens(); if self.decrement(signal_token).is_ok() { if let Some(deadline) = deadline { @@ -292,7 +296,7 @@ impl Packet { // need to do is flag that we're disconnected and then everything else // can take over (we don't have anyone to wake up). // - // The catch for Ports is that we want to drop the entire contents of + // The catch for ports is that we want to drop the entire contents of // the queue. There are multiple reasons for having this property, the // largest of which is that if another chan is waiting in this channel // (but not received yet), then waiting on that port will cause a @@ -358,7 +362,7 @@ impl Packet { } } - // increment the count on the channel (used for selection) + // Increments the count on the channel (used for selection). fn bump(&self, amt: isize) -> isize { match self.queue.producer_addition().cnt.fetch_add(amt, Ordering::SeqCst) { DISCONNECTED => { @@ -426,23 +430,24 @@ impl Packet { // is no thread in to_wake, so just keep going let has_data = if prev == DISCONNECTED { assert_eq!(self.queue.producer_addition().to_wake.load(Ordering::SeqCst), 0); - true // there is data, that data is that we're disconnected + // There is data, that data is that we're disconnected. + true } else { let cur = prev + steals + 1; assert!(cur >= 0); // If the previous count was negative, then we just made things go - // positive, hence we passed the -1 boundary and we're responsible - // for removing the to_wake() field and trashing it. + // positive, hence we passed the `-1` boundary and we're responsible + // for removing the `to_wake()` field and trashing it. // // If the previous count was positive then we're in a tougher // situation. A possible race is that a sender just incremented - // through -1 (meaning it's going to try to wake a thread up), but it + // through `-1` (meaning it's going to try to wake a thread up), but it // hasn't yet read the to_wake. In order to prevent a future recv() // from waking up too early (this sender picking up the plastered - // over to_wake), we spin loop here waiting for to_wake to be 0. - // Note that this entire select() implementation needs an overhaul, - // and this is *not* the worst part of it, so this is not done as a + // over to_wake), we spin loop here waiting for `to_wake` to be `0`. + // Note that this entire `select()` implementation needs an overhaul, + // and this is **not** the worst part of it, so this is not done as a // final solution but rather out of necessity for now to get // something working. if prev < 0 { @@ -457,8 +462,7 @@ impl Packet { *self.queue.consumer_addition().steals.get() = steals; } - // if we were previously positive, then there's surely data to - // receive + // If we were previously positive, then there's surely data to receive. prev >= 0 }; diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index bce42bc69cda4..e2d3e0a8b6f56 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -336,17 +336,17 @@ impl Packet { }; mem::drop(guard); - // only outside of the lock do we wake up the pending threads + // Only outside of the lock do we wake up the pending threads. pending_sender1.map(|t| t.signal()); pending_sender2.map(|t| t.signal()); } // Prepares this shared packet for a channel clone, essentially just bumping - // a refcount. + // a ref count. pub fn clone_chan(&self) { let old_count = self.channels.fetch_add(1, Ordering::SeqCst); - // See comments on Arc::clone() on why we do this (for `mem::forget`). + // See comments on `Arc::clone()` on why we do this (for `mem::forget`). if old_count > MAX_REFCOUNT { unsafe { abort(); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 656389789d771..38e3ce759679d 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -154,7 +154,7 @@ impl Once { /// Performs an initialization routine once and only once. The given closure /// will be executed if this is the first time `call_once` has been called, - /// and otherwise the routine will *not* be invoked. + /// and otherwise the routine will **not** be invoked. /// /// This method will block the calling thread if another initialization /// routine is currently running. diff --git a/src/libstd/sys/cloudabi/abi/bitflags.rs b/src/libstd/sys/cloudabi/abi/bitflags.rs index f764cc1df5a5c..be76496e12e34 100644 --- a/src/libstd/sys/cloudabi/abi/bitflags.rs +++ b/src/libstd/sys/cloudabi/abi/bitflags.rs @@ -12,7 +12,7 @@ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs index 83d45b3547bc2..fe98d2fcf1742 100644 --- a/src/libstd/sys/cloudabi/abi/cloudabi.rs +++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs @@ -12,7 +12,7 @@ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index 0a56f4fad6d15..3730d52088fcb 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -76,7 +76,7 @@ cfg_if! { #[cfg(rustdoc)] cfg_if! { if #[cfg(windows)] { - // On windows we'll just be documenting what's already available + // On Windows we'll just be documenting what's already available. #[allow(missing_docs)] #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as windows_ext; @@ -84,13 +84,13 @@ cfg_if! { target_arch = "wasm32", all(target_vendor = "fortanix", target_env = "sgx")))] { // On CloudABI and wasm right now the shim below doesn't compile, so - // just omit it + // just omit it. #[unstable(issue = "0", feature = "std_internals")] #[allow(missing_docs)] pub mod windows_ext {} } else { - // On all other platforms (aka linux/osx/etc) then pull in a "minimal" - // amount of windows goop which ends up compiling + // On all other platforms (e.g. Linux, macOS, etc.), then pull in a "minimal" + // amount of Windows goop, which ends up compiling. #[macro_use] #[path = "windows/compat.rs"] mod compat; diff --git a/src/libstd/sys/redox/backtrace/tracing.rs b/src/libstd/sys/redox/backtrace/tracing.rs index 59a8c5fab3d44..93ffcf1c96b4e 100644 --- a/src/libstd/sys/redox/backtrace/tracing.rs +++ b/src/libstd/sys/redox/backtrace/tracing.rs @@ -67,18 +67,18 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context, uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void }; if !ip.is_null() && ip_before_insn == 0 { - // this is a non-signaling frame, so `ip` refers to the address + // This is a non-signaling frame, so `ip` refers to the address // after the calling instruction. account for that. ip = (ip as usize - 1) as *mut _; } - // dladdr() on osx gets whiny when we use FindEnclosingFunction, and + // `dladdr()` on macOS gets whiny when we use `FindEnclosingFunction`, and // it appears to work fine without it, so we only use - // FindEnclosingFunction on non-osx platforms. In doing so, we get a + // `FindEnclosingFunction` on non-macOS platforms. In doing so, we get a // slightly more accurate stack trace in the process. // // This is often because panic involves the last instruction of a - // function being "call std::rt::begin_unwind", with no ret + // function being "call `std::rt::begin_unwind`", with no ret // instructions after it. This means that the return instruction // pointer points *outside* of the calling function, and by // unwinding it we go back to the original function. diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 8b81273f201cf..3c3bc67ed2c48 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -194,8 +194,8 @@ pub trait MetadataExt { fn blocks(&self) -> u64; } -// Hm, why are there casts here to the returned type, shouldn't the types always -// be the same? Right you are! Turns out, however, on android at least the types +// NOTE: why are there casts here to the returned type; shouldn't the types always +// be the same? Right you are! It turns out, however, on Android at least the types // in the raw `stat` structure are not the same as the types being returned. Who // knew! // @@ -258,26 +258,26 @@ impl MetadataExt for fs::Metadata { /// [`FileType`]: ../../../../std/fs/struct.FileType.html #[stable(feature = "file_type_ext", since = "1.5.0")] pub trait FileTypeExt { - /// Returns whether this file type is a block device. + /// Returns `true` if this file type is a block device. #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_block_device(&self) -> bool; - /// Returns whether this file type is a char device. + /// Returns `true` if this file type is a char device. #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_char_device(&self) -> bool; - /// Returns whether this file type is a fifo. + /// Returns `true` if this file type is a fifo. #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_fifo(&self) -> bool; - /// Returns whether this file type is a socket. + /// Returns `true` if this file type is a socket. #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_socket(&self) -> bool; } #[stable(feature = "file_type_ext", since = "1.5.0")] impl FileTypeExt for fs::FileType { - fn is_block_device(&self) -> bool { false /*FIXME: Implement block device mode*/ } - fn is_char_device(&self) -> bool { false /*FIXME: Implement char device mode*/ } - fn is_fifo(&self) -> bool { false /*FIXME: Implement fifo mode*/ } - fn is_socket(&self) -> bool { false /*FIXME: Implement socket mode*/ } + fn is_block_device(&self) -> bool { false /* FIXME: implement block device mode */ } + fn is_char_device(&self) -> bool { false /* FIXME: implement char device mode */ } + fn is_fifo(&self) -> bool { false /* FIXME: implement fifo mode */ } + fn is_socket(&self) -> bool { false /* FIXME: implement socket mode */ } } /// Creates a new symbolic link on the filesystem. diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index f7a26c9497025..fc4a2323e68ae 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -80,7 +80,7 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths(paths: I) -> Result - where I: Iterator, T: AsRef + where I: Iterator, T: AsRef { let mut joined = Vec::new(); let sep = b';'; diff --git a/src/libstd/sys/redox/path.rs b/src/libstd/sys/redox/path.rs index a7a8b03c8b1f6..0ceb14eb4fa16 100644 --- a/src/libstd/sys/redox/path.rs +++ b/src/libstd/sys/redox/path.rs @@ -14,7 +14,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { pub fn parse_prefix(path: &OsStr) -> Option { if let Some(path_str) = path.to_str() { if let Some(_i) = path_str.find(':') { - // FIXME: Redox specific prefix + // FIXME: redox specific prefix // Some(Prefix::Verbatim(OsStr::new(&path_str[..i]))) None } else { diff --git a/src/libstd/sys/redox/pipe.rs b/src/libstd/sys/redox/pipe.rs index 9e40eadb2370e..317ece6d2a2a2 100644 --- a/src/libstd/sys/redox/pipe.rs +++ b/src/libstd/sys/redox/pipe.rs @@ -36,8 +36,8 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec, p2: AnonPipe, v2: &mut Vec) -> io::Result<()> { - //FIXME: Use event based I/O multiplexing - //unimplemented!() + // FIXME: use event based I/O multiplexing. + //unimplemented!(); p1.0.read_to_end(v1)?; p2.0.read_to_end(v2)?; diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 9e23c537f22d4..dfab275619f67 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -358,10 +358,10 @@ impl Command { interpreter.pop().unwrap(); } - // FIXME: Here we could just reassign `file` directly, if it + // FIXME: here we could just reassign `file` directly, if it // wasn't for lexical lifetimes. Remove the whole `let // interpreter = { ... };` hack once NLL lands. - // NOTE: Although DO REMEMBER to make sure the interpreter path + // NOTE: however, *do remember* to make sure the interpreter path // still lives long enough to reach fexec. Some(interpreter) } else { diff --git a/src/libstd/sys/redox/syscall/call.rs b/src/libstd/sys/redox/syscall/call.rs index b9abb48a8d368..c356a6aabffa3 100644 --- a/src/libstd/sys/redox/syscall/call.rs +++ b/src/libstd/sys/redox/syscall/call.rs @@ -5,13 +5,13 @@ use super::number::*; use core::{mem, ptr}; -// Signal restorer +// Signal restorer. extern "C" fn restorer() -> ! { sigreturn().unwrap(); unreachable!(); } -/// Set the end of the process's heap +/// Sets the end of the process's heap. /// /// When `addr` is `0`, this function will return the current break. /// diff --git a/src/libstd/sys/sgx/os.rs b/src/libstd/sys/sgx/os.rs index b1e4d371a6779..a240ebb5bf8ca 100644 --- a/src/libstd/sys/sgx/os.rs +++ b/src/libstd/sys/sgx/os.rs @@ -52,7 +52,7 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths(_paths: I) -> Result - where I: Iterator, T: AsRef + where I: Iterator, T: AsRef { Err(JoinPathsError) } diff --git a/src/libstd/sys/sgx/stdio.rs b/src/libstd/sys/sgx/stdio.rs index 6f206cd9a51d7..9d48cc9ab3398 100644 --- a/src/libstd/sys/sgx/stdio.rs +++ b/src/libstd/sys/sgx/stdio.rs @@ -62,7 +62,7 @@ impl io::Write for Stderr { pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; pub fn is_ebadf(err: &io::Error) -> bool { - // FIXME: Rust normally maps Unix EBADF to `Other` + // FIXME: rust normally maps Unix EBADF to `Other` err.raw_os_error() == Some(abi::Error::BrokenPipe as _) } diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs index aec643b3175b4..a52161ac924c1 100644 --- a/src/libstd/sys/sgx/waitqueue.rs +++ b/src/libstd/sys/sgx/waitqueue.rs @@ -402,7 +402,7 @@ mod unsafe_list { } /// Trivial spinlock-based implementation of `sync::Mutex`. -// FIXME: Perhaps use Intel TSX to avoid locking? +// FIXME: perhaps use Intel TSX to avoid locking? mod spin_mutex { use cell::UnsafeCell; use sync::atomic::{AtomicBool, Ordering, spin_loop_hint}; diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs index 72a7968c514ca..de4d1738681f5 100644 --- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs +++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs @@ -67,18 +67,18 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context, uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void }; if !ip.is_null() && ip_before_insn == 0 { - // this is a non-signaling frame, so `ip` refers to the address + // This is a non-signaling frame, so `ip` refers to the address // after the calling instruction. account for that. ip = (ip as usize - 1) as *mut _; } - // dladdr() on osx gets whiny when we use FindEnclosingFunction, and + // `dladdr()` on macOS gets whiny when we use `FindEnclosingFunction`, and // it appears to work fine without it, so we only use - // FindEnclosingFunction on non-osx platforms. In doing so, we get a + // `FindEnclosingFunction` on non-macOS platforms. In doing so, we get a // slightly more accurate stack trace in the process. // // This is often because panic involves the last instruction of a - // function being "call std::rt::begin_unwind", with no ret + // function being "call `std::rt::begin_unwind`", with no ret // instructions after it. This means that the return instruction // pointer points *outside* of the calling function, and by // unwinding it we go back to the original function. diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index 3e048d5c6e4f3..c71530f3d6f3f 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -24,7 +24,7 @@ fn saturating_cast_to_time_t(value: u64) -> libc::time_t { impl Condvar { pub const fn new() -> Condvar { // Might be moved and address is changing it is better to avoid - // initialization of potentially opaque OS data before it landed + // initialization of potentially opaque OS data before it landed. Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) } } @@ -71,7 +71,7 @@ impl Condvar { debug_assert_eq!(r, 0); } - // This implementation is used on systems that support pthread_condattr_setclock + // This implementation is used on systems that support `pthread_condattr_setclock` // where we configure condition variable to use monotonic clock (instead of // default system clock). This approach avoids all problems that result // from changes made to the system time. @@ -105,9 +105,9 @@ impl Condvar { } - // This implementation is modeled after libcxx's condition_variable - // https://github.com/llvm-mirror/libcxx/blob/release_35/src/condition_variable.cpp#L46 - // https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367 + // This implementation is modeled after libcxx's `condition_variable`. + // + // #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", target_os = "hermit"))] pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool { use ptr; @@ -117,13 +117,13 @@ impl Condvar { let max_dur = Duration::from_secs(1000 * 365 * 86400); if dur > max_dur { - // OSX implementation of `pthread_cond_timedwait` is buggy + // macOS implementation of `pthread_cond_timedwait` is buggy // with super long durations. When duration is greater than // 0x100_0000_0000_0000 seconds, `pthread_cond_timedwait` // in macOS Sierra return error 316. // // This program demonstrates the issue: - // https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c + // . // // To work around this issue, and possible bugs of other OSes, timeout // is clamped to 1000 years, which is allowable per the API of `wait_timeout` @@ -133,7 +133,7 @@ impl Condvar { } // First, figure out what time it currently is, in both system and - // stable time. pthread_cond_timedwait uses system time, but we want to + // stable time. `pthread_cond_timedwait` uses system time, but we want to // report timeout based on stable time. let mut sys_now = libc::timeval { tv_sec: 0, tv_usec: 0 }; let stable_now = Instant::now(); @@ -157,8 +157,8 @@ impl Condvar { &timeout); debug_assert!(r == libc::ETIMEDOUT || r == 0); - // ETIMEDOUT is not a totally reliable method of determining timeout due - // to clock shifts, so do the check ourselves + // `ETIMEDOUT` is not a totally reliable method of determining timeout due + // to clock shifts, so do the check ourselves. stable_now.elapsed() < dur } @@ -173,10 +173,10 @@ impl Condvar { #[cfg(target_os = "dragonfly")] pub unsafe fn destroy(&self) { let r = libc::pthread_cond_destroy(self.inner.get()); - // On DragonFly pthread_cond_destroy() returns EINVAL if called on + // On DragonFly `pthread_cond_destroy()` returns `EINVAL` if called on // a condvar that was just initialized with - // libc::PTHREAD_COND_INITIALIZER. Once it is used or - // pthread_cond_init() is called, this behaviour no longer occurs. + // `libc::PTHREAD_COND_INITIALIZER`. Once it is used or + // `pthread_cond_init()` is called, this behaviour no longer occurs. debug_assert!(r == 0 || r == libc::EINVAL); } } diff --git a/src/libstd/sys/unix/fast_thread_local.rs b/src/libstd/sys/unix/fast_thread_local.rs index 742ffd12b883d..76a2048dc089c 100644 --- a/src/libstd/sys/unix/fast_thread_local.rs +++ b/src/libstd/sys/unix/fast_thread_local.rs @@ -33,16 +33,16 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { register_dtor_fallback(t, dtor); } -// This implementation is very similar to register_dtor_fallback in -// sys_common/thread_local.rs. The main difference is that we want to hook into -// macOS's analog of the above linux function, _tlv_atexit. OSX will run the +// This implementation is very similar to `register_dtor_fallback` in +// `sys_common/thread_local.rs`. The main difference is that we want to hook into +// macOS's analog of the above linux function, `_tlv_atexit`. macOS will run the // registered dtors before any TLS slots get freed, and when the main thread // exits. // // Unfortunately, calling _tlv_atexit while tls dtors are running is UB. The -// workaround below is to register, via _tlv_atexit, a custom DTOR list once per +// workaround below is to register, via `_tlv_atexit`, a custom DTOR list once per // thread. thread_local dtors are pushed to the DTOR list without calling -// _tlv_atexit. +// `_tlv_atexit`. #[cfg(target_os = "macos")] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { use cell::Cell; diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 5183d6fadd218..c281f7cca7361 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -633,7 +633,7 @@ impl fmt::Debug for File { #[cfg(target_os = "macos")] fn get_path(fd: c_int) -> Option { - // FIXME: The use of PATH_MAX is generally not encouraged, but it + // FIXME: the use of `PATH_MAX` is generally not encouraged, but it // is inevitable in this case because macOS defines `fcntl` with // `F_GETPATH` in terms of `MAXPATHLEN`, and there are no // alternatives. If a better method is invented, it should be used diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index b36c117fd09d4..1665ede0db3d6 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -146,10 +146,10 @@ pub fn cvt_r(mut f: F) -> io::Result } } -// On Unix-like platforms, libc::abort will unregister signal handlers -// including the SIGABRT handler, preventing the abort from being blocked, and +// On Unix-like platforms, `libc::abort` will unregister signal handlers +// including the `SIGABRT` handler, preventing the abort from being blocked, and // fclose streams, with the side effect of flushing them so libc bufferred -// output will be printed. Additionally the shell will generally print a more +// output will be printed. Additionally the shell will generally print a more // understandable error message like "Abort trap" rather than "Illegal // instruction" that intrinsics::abort would cause, as intrinsics::abort is // implemented as an illegal instruction. diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index d780d71c37693..d2bea8bbc3b40 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -15,18 +15,18 @@ pub extern crate libc as netc; pub type wrlen_t = size_t; -// See below for the usage of SOCK_CLOEXEC, but this constant is only defined on +// See below for the usage of `SOCK_CLOEXEC`, but this constant is only defined on // Linux currently (e.g., support doesn't exist on other platforms). In order to // get name resolution to work and things to compile we just define a dummy -// SOCK_CLOEXEC here for other platforms. Note that the dummy constant isn't +// `SOCK_CLOEXEC` here for other platforms. Note that the dummy constant isn't // actually ever used (the blocks below are wrapped in `if cfg!` as well. #[cfg(target_os = "linux")] use libc::SOCK_CLOEXEC; #[cfg(not(target_os = "linux"))] const SOCK_CLOEXEC: c_int = 0; -// Another conditional constant for name resolution: Macos et iOS use -// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket. +// Another conditional constant for name resolution: macOS and iOS use +// `SO_NOSIGPIPE` as a setsockopt flag to disable `SIGPIPE` emission on socket. // Other platforms do otherwise. #[cfg(target_vendor = "apple")] use libc::SO_NOSIGPIPE; @@ -42,7 +42,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { return Ok(()) } - // We may need to trigger a glibc workaround. See on_resolver_failure() for details. + // We may need to trigger a glibc workaround. See `on_resolver_failure()` for details. on_resolver_failure(); if err == EAI_SYSTEM { @@ -69,10 +69,10 @@ impl Socket { pub fn new_raw(fam: c_int, ty: c_int) -> io::Result { unsafe { - // On linux we first attempt to pass the SOCK_CLOEXEC flag to - // atomically create the socket and set it as CLOEXEC. Support for + // On Linux, we first attempt to pass the `SOCK_CLOEXEC` flag to + // atomically create the socket and set it as `CLOEXEC`. Support for // this option, however, was added in 2.6.27, and we still support - // 2.6.18 as a kernel, so if the returned error is EINVAL we + // 2.6.18 as a kernel, so if the returned error is `EINVAL` we // fallthrough to the fallback. if cfg!(target_os = "linux") { match cvt(libc::socket(fam, ty | SOCK_CLOEXEC, 0)) { @@ -97,7 +97,7 @@ impl Socket { unsafe { let mut fds = [0, 0]; - // Like above, see if we can set cloexec atomically + // Like above, see if we can set `cloexec` atomically. if cfg!(target_os = "linux") { match cvt(libc::socketpair(fam, ty | SOCK_CLOEXEC, 0, fds.as_mut_ptr())) { Ok(_) => { @@ -127,7 +127,7 @@ impl Socket { match r { Ok(_) => return Ok(()), - // there's no ErrorKind for EINPROGRESS :( + // There's no `ErrorKind` for `EINPROGRESS`, unfortunately. Err(ref e) if e.raw_os_error() == Some(libc::EINPROGRESS) => {} Err(e) => return Err(e), } @@ -170,8 +170,8 @@ impl Socket { } 0 => {} _ => { - // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look - // for POLLHUP rather than read readiness + // Linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look + // for `POLLHUP` rather than read readiness. if pollfd.revents & libc::POLLHUP != 0 { let e = self.take_error()? .unwrap_or_else(|| { @@ -188,10 +188,10 @@ impl Socket { pub fn accept(&self, storage: *mut sockaddr, len: *mut socklen_t) -> io::Result { - // Unfortunately the only known way right now to accept a socket and - // atomically set the CLOEXEC flag is to use the `accept4` syscall on + // Unfortunately, the only known way right now to accept a socket and + // atomically set the `CLOEXEC` flag is to use the `accept4` syscall on // Linux. This was added in 2.6.28, however, and because we support - // 2.6.18 we must detect this support dynamically. + // 2.6.18, we must detect this support dynamically. if cfg!(target_os = "linux") { syscall! { fn accept4( @@ -359,17 +359,17 @@ impl IntoInner for Socket { } // In versions of glibc prior to 2.26, there's a bug where the DNS resolver -// will cache the contents of /etc/resolv.conf, so changes to that file on disk +// will cache the contents of `/etc/resolv.conf`, so changes to that file on disk // can be ignored by a long-running program. That can break DNS lookups on e.g. // laptops where the network comes and goes. See -// https://sourceware.org/bugzilla/show_bug.cgi?id=984. Note however that some +// . Note however that some // distros including Debian have patched glibc to fix this for a long time. // // A workaround for this bug is to call the res_init libc function, to clear // the cached configs. Unfortunately, while we believe glibc's implementation // of res_init is thread-safe, we know that other implementations are not -// (https://github.com/rust-lang/rust/issues/43592). Code here in libstd could -// try to synchronize its res_init calls with a Mutex, but that wouldn't +// (issue #43592). Code here in libstd could +// try to synchronize its `res_init` calls with a `Mutex`, but that wouldn't // protect programs that call into libc in other ways. So instead of calling // res_init unconditionally, we call it only when we detect we're linking // against glibc version < 2.26. (That is, when we both know its needed and diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 58ea190fcc004..13a8c4a9cd3cb 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -173,7 +173,7 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths(paths: I) -> Result - where I: Iterator, T: AsRef + where I: Iterator, T: AsRef { let mut joined = Vec::new(); let sep = b':'; @@ -369,7 +369,7 @@ pub fn current_exe() -> io::Result { let mut info: image_info = mem::zeroed(); let mut cookie: i32 = 0; - // the executable can be found at team id 0 + // The executable can be found at team ID `0`. let result = _get_next_image_info(0, &mut cookie, &mut info, mem::size_of::() as i32); if result != 0 { @@ -570,7 +570,7 @@ fn glibc_version_cstr() -> Option<&'static CStr> { } // Returns Some((major, minor)) if the string is a valid "x.y" version, -// ignoring any extra dot-separated parts. Otherwise return None. +// ignoring any extra dot-separated parts. Otherwise return `None`. #[cfg(target_env = "gnu")] fn parse_glibc_version(version: &str) -> Option<(usize, usize)> { let mut parsed_ints = version.split('.').map(str::parse::).fuse(); diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 2c55813c5cd39..0633544b3f703 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -488,7 +488,7 @@ mod tests { let _ = stdin_write.write(b"Hello"); drop(stdin_write); - // Either EOF or failure (EPIPE) is okay. + // Either EOF or failure (EPIPE) is ok. let mut buf = [0; 5]; if let Ok(ret) = stdout_read.read(&mut buf) { assert_eq!(ret, 0); diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 5582310adbf74..e56f9009a7c8e 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -35,7 +35,7 @@ impl Command { match self.setup_io(default, true) { Ok((_, _)) => { - // FIXME: This is tough because we don't support the exec syscalls + // FIXME: this is tough because we don't support the exec syscalls unimplemented!(); }, Err(e) => e, @@ -89,7 +89,7 @@ impl Command { &mut process_handle, ptr::null_mut(), ))?; - // FIXME: See if we want to do something with that err_msg + // FIXME: see if we want to do something with that err_msg Ok(process_handle) } diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 690c745218b64..6b3b487faabc7 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -159,7 +159,7 @@ pub const FDIO_SPAWN_ACTION_TRANSFER_FD: u32 = 0x0002; #[allow(unused)] pub const ERR_CALL_FAILED: zx_status_t = -5; // ERR_INTERRUPTED_RETRY: The system call was interrupted, but should be -// retried. This should not be seen outside of the VDSO. +// retried. This should not be seen outside of the VDSO. #[allow(unused)] pub const ERR_INTERRUPTED_RETRY: zx_status_t = -6; // ======= Parameter errors ======= diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index e29557f1ba29b..74fca656d31ec 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -55,7 +55,7 @@ impl Thread { n => { assert_eq!(n, libc::EINVAL); // EINVAL means |stack_size| is either too small or not a - // multiple of the system page size. Because it's definitely + // multiple of the system page size. Because it's definitely // >= PTHREAD_STACK_MIN, it must be an alignment issue. // Round up to the nearest page and try again. let page_size = os::page_size(); @@ -303,10 +303,10 @@ pub mod guard { if cfg!(target_os = "linux") { // Linux doesn't allocate the whole stack right away, and // the kernel has its own stack-guard mechanism to fault - // when growing too close to an existing mapping. If we map + // when growing too close to an existing mapping. If we map // our own guard, then the kernel starts enforcing a rather // large gap above that, rendering much of the possible - // stack space useless. See #43052. + // stack space useless. See #43052. // // Instead, we'll just note where we expect rlimit to start // faulting, so our handler can report "stack overflow", and @@ -376,16 +376,16 @@ pub mod guard { let stackaddr = stackaddr as usize; ret = if cfg!(target_os = "freebsd") { - // FIXME does freebsd really fault *below* the guard addr? + // FIXME: does freebsd really fault *below* the guard addr? let guardaddr = stackaddr - guardsize; Some(guardaddr - PAGE_SIZE..guardaddr) } else if cfg!(target_os = "netbsd") { Some(stackaddr - guardsize..stackaddr) } else if cfg!(all(target_os = "linux", target_env = "gnu")) { // glibc used to include the guard area within the stack, as noted in the BUGS - // section of `man pthread_attr_getguardsize`. This has been corrected starting + // section of `man pthread_attr_getguardsize`. This has been corrected starting // with glibc 2.27, and in some distro backports, so the guard is now placed at the - // end (below) the stack. There's no easy way for us to know which we have at + // end (below) the stack. There's no easy way for us to know which we have at // runtime, so we'll just match any fault in the range right above or below the // stack base to call that fault a stack overflow. Some(stackaddr - guardsize..stackaddr + guardsize) @@ -400,7 +400,7 @@ pub mod guard { // glibc >= 2.15 has a __pthread_get_minstack() function that returns // PTHREAD_STACK_MIN plus however many bytes are needed for thread-local -// storage. We need that information to avoid blowing up when a small stack +// storage. We need that information to avoid blowing up when a small stack // is created in an application with big thread-local storage requirements. // See #6233 for rationale and details. #[cfg(target_os = "linux")] diff --git a/src/libstd/sys/wasm/condvar_atomics.rs b/src/libstd/sys/wasm/condvar_atomics.rs index 099404c75d42d..0464846291ecd 100644 --- a/src/libstd/sys/wasm/condvar_atomics.rs +++ b/src/libstd/sys/wasm/condvar_atomics.rs @@ -37,7 +37,7 @@ impl Condvar { #[inline] pub unsafe fn init(&mut self) { - // nothing to do + // Nothing to do. } pub unsafe fn notify_one(&self) { @@ -83,7 +83,7 @@ impl Condvar { #[inline] pub unsafe fn destroy(&self) { - // nothing to do + // Nothing to do. } #[inline] diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs index e21455ec6da75..1e7e2a4f9d2dd 100644 --- a/src/libstd/sys/wasm/mod.rs +++ b/src/libstd/sys/wasm/mod.rs @@ -1,8 +1,8 @@ //! System bindings for the wasm/web platform //! //! This module contains the facade (aka platform-specific) implementations of -//! OS level functionality for wasm. Note that this wasm is *not* the emscripten -//! wasm, so we have no runtime here. +//! OS-level functionality for wasm. Note that this wasm is **not** the +//! emscrimpten wasm, so we have no runtime here. //! //! This is all super highly experimental and not actually intended for //! wide/production use yet, it's still all in the experimental category. This diff --git a/src/libstd/sys/wasm/mutex_atomics.rs b/src/libstd/sys/wasm/mutex_atomics.rs index da03e8fa23f18..73d98980183ed 100644 --- a/src/libstd/sys/wasm/mutex_atomics.rs +++ b/src/libstd/sys/wasm/mutex_atomics.rs @@ -9,10 +9,10 @@ pub struct Mutex { } // Mutexes have a pretty simple implementation where they contain an `i32` -// internally that is 0 when unlocked and 1 when the mutex is locked. -// Acquisition has a fast path where it attempts to cmpxchg the 0 to a 1, and -// if it fails it then waits for a notification. Releasing a lock is then done -// by swapping in 0 and then notifying any waiters, if present. +// internally that is `0` when unlocked and `1` when the mutex is locked. +// Acquisition has a fast path where it attempts to `cmpxchg` the `0` to a `1`, +// and if it fails, it then waits for a notification. Releasing a lock is then done +// by swapping in `0` and then notifying any waiters, if present. impl Mutex { pub const fn new() -> Mutex { @@ -21,18 +21,20 @@ impl Mutex { #[inline] pub unsafe fn init(&mut self) { - // nothing to do + // Nothing to do. } pub unsafe fn lock(&self) { while !self.try_lock() { let val = wasm32::i32_atomic_wait( self.ptr(), - 1, // we expect our mutex is locked - -1, // wait infinitely + // We expect our mutex is locked. + 1, + // Wait infinitely. + -1, ); - // we should have either woke up (0) or got a not-equal due to a - // race (1). We should never time out (2) + // We should have either woken up (`0`), or got a not-equal due to a + // race (`1`). We should never time out (`2`). debug_assert!(val == 0 || val == 1); } } @@ -40,7 +42,8 @@ impl Mutex { pub unsafe fn unlock(&self) { let prev = self.locked.swap(0, SeqCst); debug_assert_eq!(prev, 1); - wasm32::atomic_notify(self.ptr(), 1); // wake up one waiter, if any + // Wake up one waiter, if any. + wasm32::atomic_notify(self.ptr(), 1); } #[inline] @@ -50,7 +53,7 @@ impl Mutex { #[inline] pub unsafe fn destroy(&self) { - // nothing to do + // Nothing to do. } #[inline] @@ -69,15 +72,15 @@ unsafe impl Send for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {} // Reentrant mutexes are similarly implemented to mutexs above except that -// instead of "1" meaning unlocked we use the id of a thread to represent +// instead of `1` meaning unlocked we use the ID of a thread to represent // whether it has locked a mutex. That way we have an atomic counter which -// always holds the id of the thread that currently holds the lock (or 0 if the -// lock is unlocked). +// always holds the ID of the thread that currently holds the lock (or `0` if +// the lock is unlocked). // // Once a thread acquires a lock recursively, which it detects by looking at // the value that's already there, it will update a local `recursions` counter // in a nonatomic fashion (as we hold the lock). The lock is then fully -// released when this recursion counter reaches 0. +// released when this recursion counter reaches `0`. impl ReentrantMutex { pub unsafe fn uninitialized() -> ReentrantMutex { @@ -88,7 +91,7 @@ impl ReentrantMutex { } pub unsafe fn init(&mut self) { - // nothing to do... + // Nothing to do. } pub unsafe fn lock(&self) { @@ -106,22 +109,23 @@ impl ReentrantMutex { #[inline] unsafe fn _try_lock(&self, id: u32) -> Result<(), u32> { - let id = id.checked_add(1).unwrap(); // make sure `id` isn't 0 + // Make sure `id` isn't `0`. + let id = id.checked_add(1).unwrap(); match self.owner.compare_exchange(0, id, SeqCst, SeqCst) { - // we transitioned from unlocked to locked + // We transitioned from unlocked to locked. Ok(_) => { debug_assert_eq!(*self.recursions.get(), 0); Ok(()) } - // we currently own this lock, so let's update our count and return - // true. + // We currently own this lock, so let's update our count and return + // `true`. Err(n) if n == id => { *self.recursions.get() += 1; Ok(()) } - // Someone else owns the lock, let our caller take care of it + // Someone else owns the lock, so let our caller take care of it. Err(other) => Err(other), } } @@ -133,14 +137,15 @@ impl ReentrantMutex { match *self.recursions.get() { 0 => { self.owner.swap(0, SeqCst); - wasm32::atomic_notify(self.ptr() as *mut i32, 1); // wake up one waiter, if any + // Wake up one waiter, if any. + wasm32::atomic_notify(self.ptr() as *mut i32, 1); } ref mut n => *n -= 1, } } pub unsafe fn destroy(&self) { - // nothing to do... + // Nothing to do. } #[inline] diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs index 9b278dfb9f8b2..3f51d42c97a56 100644 --- a/src/libstd/sys/wasm/os.rs +++ b/src/libstd/sys/wasm/os.rs @@ -39,7 +39,7 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths(_paths: I) -> Result - where I: Iterator, T: AsRef + where I: Iterator, T: AsRef { Err(JoinPathsError) } diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs index c2322088e8e5a..654ccf2a07ca8 100644 --- a/src/libstd/sys/wasm/thread.rs +++ b/src/libstd/sys/wasm/thread.rs @@ -9,7 +9,7 @@ pub struct Thread(Void); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements + // Unsafe: see `thread::Builder::spawn_unchecked` for safety requirements. pub unsafe fn new(_stack: usize, _p: Box) -> io::Result { @@ -17,11 +17,11 @@ impl Thread { } pub fn yield_now() { - // do nothing + // Do nothing. } pub fn set_name(_name: &CStr) { - // nope + // Do nothing. } #[cfg(not(target_feature = "atomics"))] @@ -86,11 +86,11 @@ cfg_if! { } // FIXME: still need something for hooking exiting a thread to free - // data... + // data. } else if #[cfg(target_feature = "atomics")] { pub fn my_id() -> u32 { - panic!("thread ids not implemented on wasm with atomics yet") + panic!("thread IDs not implemented on wasm with atomics yet") } pub fn tcb_get() -> *mut u8 { @@ -101,7 +101,7 @@ cfg_if! { panic!("thread local data not implemented on wasm with atomics yet") } } else { - // stubbed out because no functions actually access these intrinsics - // unless atomics are enabled + // Stubbed out because no functions actually access these intrinsics + // unless atomics are enabled. } } diff --git a/src/libstd/sys/windows/backtrace/printing/msvc.rs b/src/libstd/sys/windows/backtrace/printing/msvc.rs index b186bb423345c..6a81b2a9ed340 100644 --- a/src/libstd/sys/windows/backtrace/printing/msvc.rs +++ b/src/libstd/sys/windows/backtrace/printing/msvc.rs @@ -105,7 +105,7 @@ where unsafe { let mut info: c::SYMBOL_INFO = mem::zeroed(); info.MaxNameLen = c::MAX_SYM_NAME as c_ulong; - // the struct size in C. the value is different to + // the struct size in C. the value is different to // `size_of::() - MAX_SYM_NAME + 1` (== 81) // due to struct alignment. info.SizeOfStruct = 88; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 28fd4df386e99..036a9ebd3744c 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -786,7 +786,7 @@ pub struct M128A { #[cfg(target_arch = "x86_64")] #[repr(C, align(16))] pub struct FLOATING_SAVE_AREA { - _Dummy: [u8; 512] // FIXME: Fill this out + _Dummy: [u8; 512] // FIXME: fill this out. } #[cfg(target_arch = "arm")] diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index e97e436efbf71..eec4744fda271 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -152,7 +152,8 @@ fn os2path(s: &[u16]) -> PathBuf { PathBuf::from(OsString::from_wide(s)) } -#[allow(dead_code)] // Only used in backtrace::gnu::get_executable_filename() +// Only used in `backtrace::gnu::get_executable_filename()`. +#[allow(dead_code)] fn wide_char_to_multi_byte(code_page: u32, flags: u32, s: &[u16], @@ -229,12 +230,12 @@ pub fn cvt(i: I) -> io::Result { } pub fn dur2timeout(dur: Duration) -> c::DWORD { - // Note that a duration is a (u64, u32) (seconds, nanoseconds) pair, and the - // timeouts in windows APIs are typically u32 milliseconds. To translate, we + // Note that a duration is a `(u64, u32)` `(seconds, nanoseconds)` pair, and the + // timeouts in Windows APIs are typically `u32` milliseconds. To translate, we // have two pieces to take care of: // // * Nanosecond precision is rounded up - // * Greater than u32::MAX milliseconds (50 days) is rounded up to INFINITE + // * Greater than `u32::MAX` milliseconds (50 days) is rounded up to `INFINITE` // (never time out). dur.as_secs().checked_mul(1000).and_then(|ms| { ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000) @@ -249,19 +250,20 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD { }).unwrap_or(c::INFINITE) } -// On Windows, use the processor-specific __fastfail mechanism. In Windows 8 +// On Windows, use the processor-specific `__fastfail` mechanism. On Windows 8 // and later, this will terminate the process immediately without running any -// in-process exception handlers. In earlier versions of Windows, this +// in-process exception handlers. In earlier versions of Windows, this // sequence of instructions will be treated as an access violation, // terminating the process but without necessarily bypassing all exception // handlers. // -// https://msdn.microsoft.com/en-us/library/dn774154.aspx +// See for details. #[allow(unreachable_code)] pub unsafe fn abort_internal() -> ! { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT + // `7` is `FAST_FAIL_FATAL_APP_EXIT`. + asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); ::intrinsics::unreachable(); } ::intrinsics::abort(); diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 7399dd41a41cf..d67e9c303101a 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -24,7 +24,7 @@ pub fn errno() -> i32 { /// Gets a detailed string description for the given error number. pub fn error_string(mut errnum: i32) -> String { // This value is calculated from the macro - // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) + // `MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)`. let langId = 0x0800 as c::DWORD; let mut buf = [0 as c::WCHAR; 2048]; @@ -33,11 +33,11 @@ pub fn error_string(mut errnum: i32) -> String { let mut module = ptr::null_mut(); let mut flags = 0; - // NTSTATUS errors may be encoded as HRESULT, which may returned from + // `NTSTATUS` errors may be encoded as `HRESULT`, which may returned from // GetLastError. For more information about Windows error codes, see // `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx if (errnum & c::FACILITY_NT_BIT as i32) != 0 { - // format according to https://support.microsoft.com/en-us/help/259693 + // Format according to . const NTDLL_DLL: &[u16] = &['N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _, 'L' as _, 0]; module = c::GetModuleHandleW(NTDLL_DLL.as_ptr()); @@ -57,7 +57,7 @@ pub fn error_string(mut errnum: i32) -> String { buf.len() as c::DWORD, ptr::null()) as usize; if res == 0 { - // Sometimes FormatMessageW can fail e.g., system doesn't like langId, + // Sometimes `FormatMessageW` can fail (e.g., system doesn't like `langId`). let fm_err = errno(); return format!("OS Error {} (FormatMessageW() returned error {})", errnum, fm_err); @@ -65,7 +65,7 @@ pub fn error_string(mut errnum: i32) -> String { match String::from_utf16(&buf[..res]) { Ok(mut msg) => { - // Trim trailing CRLF inserted by FormatMessageW + // Trim trailing CRLF inserted by `FormatMessageW`. let len = msg.trim_end().len(); msg.truncate(len); msg @@ -98,7 +98,7 @@ impl Iterator for Env { // Windows allows environment variables to start with an equals // symbol (in any other position, this is the separator between - // variable name and value). Since`s` has at least length 1 at + // variable name and value). Since `s` has at least length one at // this point (because the empty string terminates the array of // environment variables), we can safely slice. let pos = match s[1..].iter().position(|&u| u == b'=' as u16).map(|p| p + 1) { @@ -146,15 +146,15 @@ pub fn split_paths(unparsed: &OsStr) -> SplitPaths { impl<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option { - // On Windows, the PATH environment variable is semicolon separated. + // On Windows, the `PATH` environment variable is semicolon separated. // Double quotes are used as a way of introducing literal semicolons - // (since c:\some;dir is a valid Windows path). Double quotes are not + // (since `c:\some;dir` is a valid Windows path). Double quotes are not // themselves permitted in path names, so there is no way to escape a - // double quote. Quoted regions can appear in arbitrary locations, so + // double quote. Quoted regions can appear in arbitrary locations, so // - // c:\foo;c:\som"e;di"r;c:\bar + // c:\foo;c:\som"e;di"r;c:\bar // - // Should parse as [c:\foo, c:\some;dir, c:\bar]. + // Should parse as `["c:\foo", "c:\some;dir", "c:\bar"]`. // // (The above is based on testing; there is no clear reference available // for the grammar.) @@ -188,7 +188,7 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths(paths: I) -> Result - where I: Iterator, T: AsRef + where I: Iterator, T: AsRef { let mut joined = Vec::new(); let sep = b';' as u16; @@ -298,7 +298,8 @@ pub fn home_dir() -> Option { match c::GetUserProfileDirectoryW(token, buf, &mut sz) { 0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0, 0 => sz, - _ => sz - 1, // sz includes the null terminator + // `sz` includes the null terminator. + _ => sz - 1, } }, super::os2path).ok() }) @@ -317,7 +318,7 @@ mod tests { use io::Error; use sys::c; - // tests `error_string` above + // Tests `error_string` above. #[test] fn ntstatus_error() { const STATUS_UNSUCCESSFUL: u32 = 0xc000_0001; diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index d3b102268f632..b6d854246c003 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -35,7 +35,7 @@ pub struct Pipes { /// processes in the standard library, so "ours" is the one that'll stay in our /// process whereas "theirs" will be inherited to a child. /// -/// The ours/theirs pipes are *not* specifically readable or writable. Each +/// The `ours`/`theirs` pipes are **not** specifically readable or writable. Each /// one only supports a read or a write, but which is which depends on the /// boolean flag given. If `ours_readable` is true then `ours` is readable where /// `theirs` is writable. Conversely if `ours_readable` is false then `ours` is @@ -46,7 +46,7 @@ pub struct Pipes { /// with `OVERLAPPED` instances, but also works out ok if it's only ever used /// once at a time (which we do indeed guarantee). pub fn anon_pipe(ours_readable: bool) -> io::Result { - // Note that we specifically do *not* use `CreatePipe` here because + // Note that we specifically do **not** use `CreatePipe` here because // unfortunately the anonymous pipes returned do not support overlapped // operations. Instead, we create a "hopefully unique" name and create a // named pipe which has overlapped operations enabled. @@ -106,7 +106,7 @@ pub fn anon_pipe(ours_readable: bool) -> io::Result { // Proper fix would increase the number of FFI imports and introduce // significant amount of Windows XP specific code with no clean // testing strategy - // For more info, see https://github.com/rust-lang/rust/pull/37677. + // For more info, see PR #37677. if handle == c::INVALID_HANDLE_VALUE { let err = io::Error::last_os_error(); let raw_os_err = err.raw_os_error(); diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 08a166bd8c504..2c83e0d05f7c9 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -208,7 +208,7 @@ impl Command { }?; // We close the thread handle because we don't care about keeping - // the thread id valid, and we aren't keeping the thread handle + // the thread ID valid, and we aren't keeping the thread handle // around to be able to close it later. drop(Handle::new(pi.hThread)); diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 0ea19a855257b..0c1cbb74e136e 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -75,7 +75,7 @@ fn write(handle: c::DWORD, data: &[u8]) -> io::Result { ptr::null_mut()) })?; - // FIXME if this only partially writes the utf16 buffer then we need to + // FIXME: if this only partially writes the utf16 buffer then we need to // figure out how many bytes of `data` were actually written assert_eq!(written as usize, utf16.len()); Ok(utf8.len()) diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index bd7cb673a0dbe..5b601b5c810f1 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -18,17 +18,17 @@ pub struct Thread { } impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements + // Unsafe: see `thread::Builder::spawn_unchecked` for safety requirements. pub unsafe fn new(stack: usize, p: Box) -> io::Result { let p = box p; - // FIXME On UNIX, we guard against stack sizes that are too small but + // FIXME: on Unix, we guard against stack sizes that are too small but // that's because pthreads enforces that stacks are at least - // PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's + // `PTHREAD_STACK_MIN` bytes big. Windows has no such lower limit, it's // just that below a certain threshold you can't do anything useful. // That threshold is application and architecture-specific, however. - // Round up to the next 64 kB because that's what the NT kernel does, + // Round up to the next 64kB because that's what the NT kernel does, // might as well make it explicit. let stack_size = (stack + 0xfffe) & (!0xfffe); let ret = c::CreateThread(ptr::null_mut(), stack_size, @@ -39,7 +39,8 @@ impl Thread { return if ret as usize == 0 { Err(io::Error::last_os_error()) } else { - mem::forget(p); // ownership passed to CreateThread + // Ownership passed to `CreateThread`. + mem::forget(p); Ok(Thread { handle: Handle::new(ret) }) }; diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 347244b0e0d44..4d7a9977f555e 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -108,7 +108,7 @@ fn filter_frames(frames: &[Frame], let mut is_marker = false; let _ = resolve_symname(*frame, |symname| { if let Some(mangled_symbol_name) = symname { - // Use grep to find the concerned functions + // Use grep to find the concerned functions. if mangled_symbol_name.contains("__rust_begin_short_backtrace") { is_marker = true; } @@ -119,7 +119,7 @@ fn filter_frames(frames: &[Frame], }).unwrap_or(frames.len()); if skipped_before + skipped_after >= frames.len() { - // Avoid showing completely empty backtraces + // Avoid showing completely empty backtraces. return (0, 0); } @@ -211,7 +211,7 @@ fn output_fileline(w: &mut dyn Write, file: &[u8], line: u32, format: PrintFormat) -> io::Result<()> { - // prior line: " ##: {:2$} - func" + // Prior line: " ##: {:2$} - func" w.write_all(b"")?; match format { PrintFormat::Full => write!(w, @@ -240,4 +240,3 @@ fn output_fileline(w: &mut dyn Write, w.write_all(b"\n") } - diff --git a/src/libstd/sys_common/gnu/libbacktrace.rs b/src/libstd/sys_common/gnu/libbacktrace.rs index 188eb4e4b86b1..6931d94dbf654 100644 --- a/src/libstd/sys_common/gnu/libbacktrace.rs +++ b/src/libstd/sys_common/gnu/libbacktrace.rs @@ -13,9 +13,9 @@ pub fn foreach_symbol_fileline(frame: Frame, _: &BacktraceContext) -> io::Result where F: FnMut(&[u8], u32) -> io::Result<()> { - // pcinfo may return an arbitrary number of file:line pairs, + // `pcinfo` may return an arbitrary number of "file:line" pairs, // in the order of stack trace (i.e., inlined calls first). - // in order to avoid allocation, we stack-allocate a fixed size of entries. + // In order to avoid allocation, we stack-allocate a fixed size of entries. const FILELINE_SIZE: usize = 32; let mut fileline_buf = [(ptr::null(), !0); FILELINE_SIZE]; let ret; @@ -89,14 +89,14 @@ pub fn resolve_symname(frame: Frame, } //////////////////////////////////////////////////////////////////////// -// helper callbacks +// Helper callbacks //////////////////////////////////////////////////////////////////////// type FileLine = (*const libc::c_char, u32); extern fn error_cb(_data: *mut libc::c_void, _msg: *const libc::c_char, _errnum: libc::c_int) { - // do nothing for now + // Do nothing for now. } extern fn syminfo_cb(data: *mut libc::c_void, _pc: libc::uintptr_t, @@ -115,8 +115,8 @@ extern fn pcinfo_cb(data: *mut libc::c_void, let slot = data as *mut &mut [FileLine]; let buffer = unsafe {ptr::read(slot)}; - // if the buffer is not full, add file:line to the buffer - // and adjust the buffer for next possible calls to pcinfo_cb. + // If the buffer is not full, add `"file:line"` to the buffer + // and adjust the buffer for next possible calls to `pcinfo_cb`. if !buffer.is_empty() { buffer[0] = (filename, lineno as u32); unsafe { ptr::write(slot, &mut buffer[1..]); } @@ -155,9 +155,9 @@ unsafe fn init_state() -> *mut backtrace_state { let filename = match ::sys::backtrace::gnu::get_executable_filename() { Ok((filename, file)) => { - // filename is purposely leaked here since libbacktrace requires + // Filename is purposely leaked here since libbacktrace requires. // it to stay allocated permanently, file is also leaked so that - // the file stays locked + // the file stays locked. let filename_ptr = filename.as_ptr(); mem::forget(filename); mem::forget(file); diff --git a/src/libstd/sys_common/util.rs b/src/libstd/sys_common/util.rs index 7dec22be97808..9e0a0427f6ce3 100644 --- a/src/libstd/sys_common/util.rs +++ b/src/libstd/sys_common/util.rs @@ -10,8 +10,8 @@ pub fn dumb_print(args: fmt::Arguments) { } // Other platforms should use the appropriate platform-specific mechanism for -// aborting the process. If no platform-specific mechanism is available, -// ::intrinsics::abort() may be used instead. The above implementations cover +// aborting the process. If no platform-specific mechanism is available, +// `::intrinsics::abort()` may be used instead. The above implementations cover // all targets currently supported by libstd. pub fn abort(args: fmt::Arguments) -> ! { @@ -19,7 +19,8 @@ pub fn abort(args: fmt::Arguments) -> ! { unsafe { ::sys::abort_internal(); } } -#[allow(dead_code)] // stack overflow detection not enabled on all platforms +// Stack overflow detection not enabled on all platforms. +#[allow(dead_code)] pub unsafe fn report_overflow() { dumb_print(format_args!("\nthread '{}' has overflowed its stack\n", thread::current().name().unwrap_or(""))); diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 6d4594fe295ca..8417d09ac427f 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -371,7 +371,7 @@ impl Wtf8Buf { /// This replaces surrogate code point pairs with supplementary code points, /// like concatenating ill-formed UTF-16 strings effectively would. impl FromIterator for Wtf8Buf { - fn from_iter>(iter: T) -> Wtf8Buf { + fn from_iter>(iter: T) -> Wtf8Buf { let mut string = Wtf8Buf::new(); string.extend(iter); string @@ -383,7 +383,7 @@ impl FromIterator for Wtf8Buf { /// This replaces surrogate code point pairs with supplementary code points, /// like concatenating ill-formed UTF-16 strings effectively would. impl Extend for Wtf8Buf { - fn extend>(&mut self, iter: T) { + fn extend>(&mut self, iter: T) { let iterator = iter.into_iter(); let (low, _high) = iterator.size_hint(); // Lower bound of one byte per code point (ASCII only) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 438ea3aa3f6a3..97ac6ecf22c94 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -127,7 +127,7 @@ //! * Set the `RUST_MIN_STACK` environment variable to an integer representing the desired stack //! size (in bytes). Note that setting [`Builder::stack_size`] will override this. //! -//! Note that the stack size of the main thread is *not* determined by Rust. +//! Note that the stack size of the main thread is **not** determined by Rust. //! //! [channels]: ../../std/sync/mpsc/index.html //! [`Arc`]: ../../std/sync/struct.Arc.html @@ -1606,10 +1606,10 @@ mod tests { #[test] fn test_child_doesnt_ref_parent() { - // If the child refcounts the parent thread, this will stack overflow when + // If the child ref counts the parent thread, this will stack overflow when // climbing the thread tree to dereference each ancestor. (See #1789) - // (well, it would if the constant were 8000+ - I lowered it to be more - // valgrind-friendly. try this at home, instead..!) + // (Well, it would if the constant were 8000+ -- I lowered it to be more + // valgrind-friendly. Try this at home, instead!) const GENERATIONS: u32 = 16; fn child_no(x: u32) -> Box { return Box::new(move|| { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ab62dd2bc9b01..7640507c12d00 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -531,7 +531,7 @@ impl Pat { } PatKind::Tuple(pats, None) => { let mut tys = Vec::with_capacity(pats.len()); - // FIXME(#48994) - could just be collected into an Option + // FIXME(#48994): could just be collected into an `Option`. for pat in pats { tys.push(pat.to_ty()?); } diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 420f7426ad786..12f2e57bd3351 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -487,7 +487,7 @@ impl MetaItem { fn from_tokens(tokens: &mut iter::Peekable) -> Option where I: Iterator, { - // FIXME: Share code with `parse_path`. + // FIXME: share code with `parse_path`. let ident = match tokens.next() { Some(TokenTree::Token(span, token @ Token::Ident(..))) | Some(TokenTree::Token(span, token @ Token::ModSep)) => 'arm: { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 4e4432a3f334d..438a4fc2b8685 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -45,7 +45,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, edition: Edition) features = get_features(&sess.span_diagnostic, &krate.attrs, edition); - // Avoid reconfiguring malformed `cfg_attr`s + // Avoid reconfiguring malformed `cfg_attr`s. if err_count == sess.span_diagnostic.err_count() { strip_unconfigured.features = Some(&features); strip_unconfigured.configure(unconfigured_attrs); @@ -123,14 +123,14 @@ impl<'a> StripUnconfigured<'a> { // Check feature gate and lint on zero attributes in source. Even if the feature is gated, // we still compute as if it wasn't, since the emitted error will stop compilation further // along the compilation. - if expanded_attrs.len() == 0 { - // FIXME: Emit unused attribute lint here. + if expanded_attrs.is_empty() { + // FIXME: emit unused attribute lint here. } if attr::cfg_matches(&cfg_predicate, self.sess, self.features) { // We call `process_cfg_attr` recursively in case there's a - // `cfg_attr` inside of another `cfg_attr`. E.g. - // `#[cfg_attr(false, cfg_attr(true, some_attr))]`. + // `cfg_attr` inside of another `cfg_attr`. + // E.g., `#[cfg_attr(false, cfg_attr(true, some_attr))]`. expanded_attrs.into_iter() .flat_map(|(path, tokens, span)| self.process_cfg_attr(ast::Attribute { id: attr::mk_attr_id(), @@ -193,15 +193,15 @@ impl<'a> StripUnconfigured<'a> { }) } - /// Visit attributes on expression and statements (but not attributes on items in blocks). + /// Visits attributes on expression and statements (but not attributes on items in blocks). fn visit_expr_attrs(&mut self, attrs: &[ast::Attribute]) { - // flag the offending attributes + // Flag the offending attributes. for attr in attrs.iter() { self.maybe_emit_expr_attr_err(attr); } } - /// If attributes are not allowed on expressions, emit an error for `attr` + /// If attributes are not allowed on expressions, emits an error for `attr`. pub fn maybe_emit_expr_attr_err(&self, attr: &ast::Attribute) { if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) { let mut err = feature_err(self.sess, @@ -261,13 +261,13 @@ impl<'a> StripUnconfigured<'a> { pub fn configure_expr(&mut self, expr: &mut P) { self.visit_expr_attrs(expr.attrs()); - // If an expr is valid to cfg away it will have been removed by the - // outer stmt or expression folder before descending in here. - // Anything else is always required, and thus has to error out - // in case of a cfg attr. + // If an expr is valid to `cfg` away, it will have been removed by the + // outer statement or expression folder before descending into here. + // Anything else is always required, and thus has to error out in case + // of a `cfg` attr. // - // N.B., this is intentionally not part of the visit_expr() function - // in order for filter_map_expr() to be able to avoid this check + // N.B., this is intentionally not part of the `visit_expr()` function + // in order for `filter_map_expr()` to be able to avoid this check. if let Some(attr) = expr.attrs().iter().find(|a| is_cfg(a)) { let msg = "removing an expression is not supported in this position"; self.sess.span_diagnostic.span_err(attr.span, msg); diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 2c367f1f40242..a20551d7d0d02 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -358,7 +358,7 @@ The `#[unwind]` attribute should be used as follows: should be allowed to unwind. This can easily result in Undefined Behavior (UB), so be careful. -NB. The default behavior here is "allowed", but this is unspecified +N.B., the default behavior here is "allowed", but this is unspecified and likely to change in the future. "##, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 5980261593dbf..7791d7c8e05c7 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -1,4 +1,13 @@ -pub use SyntaxExtension::*; +use std::iter; +use std::path::PathBuf; +use std::rc::Rc; +use std::default::Default; + +use errors::{DiagnosticBuilder, DiagnosticId}; +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::sync::{self, Lrc}; +use smallvec::{smallvec, SmallVec}; +use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use crate::ast::{self, Attribute, Name, PatKind, MetaItem}; use crate::attr::HasAttrs; @@ -13,18 +22,7 @@ use crate::ptr::P; use crate::symbol::{keywords, Ident, Symbol}; use crate::ThinVec; use crate::tokenstream::{self, TokenStream}; - -use errors::{DiagnosticBuilder, DiagnosticId}; -use smallvec::{smallvec, SmallVec}; -use syntax_pos::{Span, MultiSpan, DUMMY_SP}; - -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::sync::{self, Lrc}; -use std::iter; -use std::path::PathBuf; -use std::rc::Rc; -use std::default::Default; - +pub use self::SyntaxExtension::*; #[derive(Debug,Clone)] pub enum Annotatable { @@ -137,7 +135,7 @@ impl Annotatable { } } -// A more flexible ItemDecorator. +// A more flexible `ItemDecorator`. pub trait MultiItemDecorator { fn expand(&self, ecx: &mut ExtCtxt<'_>, @@ -161,7 +159,7 @@ impl MultiItemDecorator for F } // `meta_item` is the annotation, and `item` is the item being modified. -// FIXME Decorators should follow the same pattern too. +// FIXME: decorators should follow the same pattern too. pub trait MultiItemModifier { fn expand(&self, ecx: &mut ExtCtxt<'_>, @@ -207,7 +205,7 @@ impl ProcMacro for F _span: Span, ts: TokenStream) -> TokenStream { - // FIXME setup implicit context in TLS before calling self. + // FIXME: set up implicit context in TLS before calling `self`. (*self)(ts) } } @@ -230,12 +228,12 @@ impl AttrProcMacro for F annotation: TokenStream, annotated: TokenStream) -> TokenStream { - // FIXME setup implicit context in TLS before calling self. + // FIXME: set up implicit context in TLS before calling self. (*self)(annotation, annotated) } } -/// Represents a thing that maps token trees to Macro Results +/// Represents a thing that maps token trees to macro results. pub trait TTMacroExpander { fn expand<'cx>( &self, @@ -313,7 +311,7 @@ impl IdentMacroExpander for F } } -// Use a macro because forwarding to a simple function has type system issues +// Use a macro because forwarding to a simple function has type system issues. macro_rules! make_stmts_default { ($me:expr) => { $me.make_expr().map(|e| smallvec![ast::Stmt { @@ -451,8 +449,7 @@ impl MacResult for MacEager { } } -/// Fill-in macro expansion result, to allow compilation to continue -/// after hitting errors. +/// Fill-in macro expansion result, to allow compilation to continue after hitting errors. #[derive(Copy, Clone)] pub struct DummyResult { expr_only: bool, @@ -463,8 +460,7 @@ pub struct DummyResult { impl DummyResult { /// Creates a default MacResult that can be anything. /// - /// Use this as a return value after hitting any errors and - /// calling `span_err`. + /// Use this as a return value after hitting any errors and calling `span_err`. pub fn any(span: Span) -> Box { Box::new(DummyResult { expr_only: false, is_error: true, span }) } @@ -522,7 +518,7 @@ impl MacResult for DummyResult { } fn make_items(self: Box) -> Option; 1]>> { - // this code needs a comment... why not always just return the Some() ? + // NOTE: this needs an explanation -- why not always just return the `Some()`? if self.expr_only { None } else { @@ -573,13 +569,13 @@ pub type BuiltinDeriveFn = /// Represents different kinds of macro invocations that can be resolved. #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum MacroKind { - /// A bang macro - foo!() + /// A bang macro (e.g., `foo!()`). Bang, - /// An attribute macro - #[foo] + /// An attribute macro (e.g., `#[foo]`). Attr, - /// A derive attribute macro - #[derive(Foo)] + /// A derive attribute macro (e.g., `#[derive(Foo)]`). Derive, - /// A view of a procedural macro from the same crate that defines it. + /// A view of a procedural macro from the same crate that defined it. ProcMacroStub, } @@ -606,19 +602,18 @@ pub enum SyntaxExtension { /// A trivial "extension" that does nothing, only keeps the attribute and marks it as known. NonMacroAttr { mark_used: bool }, - /// A syntax extension that is attached to an item and creates new items - /// based upon it. + /// A syntax extension that is attached to an item and creates new items based upon it. /// /// `#[derive(...)]` is a `MultiItemDecorator`. /// - /// Prefer ProcMacro or MultiModifier since they are more flexible. + /// Prefer `ProcMacro` or `MultiModifier` since they are more flexible. MultiDecorator(Box), /// A syntax extension that is attached to an item and modifies it /// in-place. Also allows decoration, i.e., creating new items. MultiModifier(Box), - /// A function-like procedural macro. TokenStream -> TokenStream. + /// A function-like procedural macro; `TokenStream -> TokenStream`. ProcMacro { expander: Box, /// Whitelist of unstable features that are treated as stable inside this macro @@ -626,7 +621,7 @@ pub enum SyntaxExtension { edition: Edition, }, - /// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream. + /// An attribute-like procedural macro; `TokenStream, TokenStream -> TokenStream`. /// The first TokenSteam is the attribute, the second is the annotated item. /// Allows modification of the input items and adding new items, similar to /// MultiModifier, but uses TokenStreams, rather than AST nodes. @@ -638,25 +633,23 @@ pub enum SyntaxExtension { NormalTT { expander: Box, def_info: Option<(ast::NodeId, Span)>, - /// Whether the contents of the macro can - /// directly use `#[unstable]` things. + /// Whether the contents of the macro can directly use `#[unstable]` things. /// - /// Only allows things that require a feature gate in the given whitelist + /// Only allows things that require a feature gate in the given whitelist. allow_internal_unstable: Option>, - /// Whether the contents of the macro can use `unsafe` - /// without triggering the `unsafe_code` lint. + /// `true` if the contents of the macro can use `unsafe` without triggering + /// the `unsafe_code` lint. allow_internal_unsafe: bool, - /// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) + /// `true` to enable the macro helper hack (i.e, `ident!(...)` -> `$crate::ident!(...)`) /// for a given macro. local_inner_macros: bool, /// The macro's feature name if it is unstable, and the stability feature unstable_feature: Option<(Symbol, u32)>, - /// Edition of the crate in which the macro is defined + /// The edition of the crate in which the macro is defined. edition: Edition, }, - /// A function-like syntax extension that has an extra ident before - /// the block. + /// A function-like syntax extension that has an extra ident before the block. IdentTT { expander: Box, span: Option, @@ -668,7 +661,9 @@ pub enum SyntaxExtension { /// Allows generating code to implement a Trait for a given struct /// or enum item. ProcMacroDerive(Box, - Vec /* inert attribute names */, Edition), + // Inert attribute names. + Vec, + Edition), /// An attribute-like procedural macro that derives a builtin trait. BuiltinDerive(BuiltinDeriveFn), @@ -720,7 +715,7 @@ impl SyntaxExtension { SyntaxExtension::ProcMacro { edition, .. } | SyntaxExtension::AttrProcMacro(.., edition) | SyntaxExtension::ProcMacroDerive(.., edition) => edition, - // Unstable legacy stuff + // Unstable legacy stuff. SyntaxExtension::NonMacroAttr { .. } | SyntaxExtension::IdentTT { .. } | SyntaxExtension::MultiDecorator(..) | @@ -803,9 +798,9 @@ pub struct ExpansionData { pub crate_span: Option, } -/// One of these is made during expansion and incrementally updated as we go; -/// when a macro expansion occurs, the resulting nodes have the `backtrace() -/// -> expn_info` of their expansion context stored into their span. +/// Information created during expansion and updated incrementally as we go; +/// when a macro expansion occurs, the resulting nodes have the `backtrace() -> expn_info` +/// of their expansion context stored into their span. pub struct ExtCtxt<'a> { pub parse_sess: &'a parse::ParseSess, pub ecfg: expand::ExpansionConfig<'a>, @@ -904,9 +899,9 @@ impl<'a> ExtCtxt<'a> { self.parse_sess.span_diagnostic.struct_span_fatal(sp, msg) } - /// Emit `msg` attached to `sp`, and stop compilation immediately. + /// Emits `msg` attached to `sp`, and stops compilation immediately. /// - /// `span_err` should be strongly preferred where-ever possible: + /// `span_err` should be strongly preferred whereever possible: /// this should *only* be used when: /// /// - continuing has a high risk of flow-on errors (e.g., errors in @@ -915,13 +910,12 @@ impl<'a> ExtCtxt<'a> { /// - there is literally nothing else that can be done (however, /// in most cases one can construct a dummy expression/item to /// substitute; we never hit resolve/type-checking so the dummy - /// value doesn't have to match anything) + /// value doesn't have to match anything). pub fn span_fatal>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_fatal(sp, msg).raise(); } - /// Emit `msg` attached to `sp`, without immediately stopping - /// compilation. + /// Emit `msg` attached to `sp`, without immediately stopping compilation. /// /// Compilation will be stopped in the near future (at the end of /// the macro expansion phase). @@ -952,7 +946,7 @@ impl<'a> ExtCtxt<'a> { } db.emit(); } - // Fixme: does this result in errors? + // FIXME: does this result in errors? self.expansions.clear(); } pub fn bug(&self, msg: &str) -> ! { @@ -993,7 +987,7 @@ pub fn expr_to_spanned_string<'a>( // Update `expr.span`'s ctxt now in case expr is an `include!` macro invocation. expr.span = expr.span.apply_mark(cx.current_expansion.mark); - // we want to be able to handle e.g., `concat!("foo", "bar")` + // We want to be able to handle, e.g., `concat!("foo", "bar")`. cx.expander().visit_expr(&mut expr); Err(match expr.node { ast::ExprKind::Lit(ref l) => match l.node { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 48f6e4c0c8203..7942ef20e6881 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -206,7 +206,7 @@ pub trait AstBuilder { name: Ident, attrs: Vec , node: ast::ItemKind) -> P; fn arg(&self, span: Span, name: Ident, ty: P) -> ast::Arg; - // FIXME unused self + // FIXME: unused self fn fn_decl(&self, inputs: Vec , output: ast::FunctionRetTy) -> P; fn item_fn_poly(&self, @@ -942,7 +942,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(), ast::FunctionRetTy::Default(span)); - // FIXME -- We are using `span` as the span of the `|...|` + // FIXME: we are using `span` as the span of the `|...|` // part of the lambda, but it probably (maybe?) corresponds to // the entire lambda body. Probably we should extend the API // here, but that's not entirely clear. @@ -986,7 +986,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } } - // FIXME unused self + // FIXME: unused self fn fn_decl(&self, inputs: Vec, output: ast::FunctionRetTy) -> P { P(ast::FnDecl { inputs, @@ -997,7 +997,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn item(&self, span: Span, name: Ident, attrs: Vec, node: ast::ItemKind) -> P { - // FIXME: Would be nice if our generated code didn't violate + // FIXME: would be nice if our generated code didn't violate // Rust coding conventions P(ast::Item { ident: name, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d398437d7affc..f7e753dbf7a27 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1,3 +1,16 @@ +use std::fs; +use std::io::ErrorKind; +use std::ops::DerefMut; +use std::path::PathBuf; +use std::rc::Rc; +use std::{iter, mem}; + +use errors::{Applicability, FatalError}; +use rustc_data_structures::fx::FxHashMap; +use smallvec::{smallvec, SmallVec}; +use syntax_pos::{Span, DUMMY_SP, FileName}; +use syntax_pos::hygiene::ExpnFormat; + use crate::ast::{self, Block, Ident, LitKind, NodeId, PatKind, Path}; use crate::ast::{MacStmtStyle, StmtKind, ItemKind}; use crate::attr::{self, HasAttrs}; @@ -16,27 +29,14 @@ use crate::ptr::P; use crate::symbol::Symbol; use crate::symbol::keywords; use crate::tokenstream::{TokenStream, TokenTree}; -use crate::visit::{self, Visitor}; use crate::util::map_in_place::MapInPlace; - -use errors::{Applicability, FatalError}; -use smallvec::{smallvec, SmallVec}; -use syntax_pos::{Span, DUMMY_SP, FileName}; -use syntax_pos::hygiene::ExpnFormat; - -use rustc_data_structures::fx::FxHashMap; -use std::fs; -use std::io::ErrorKind; -use std::{iter, mem}; -use std::ops::DerefMut; -use std::rc::Rc; -use std::path::PathBuf; +use crate::visit::{self, Visitor}; macro_rules! ast_fragments { ( $($Kind:ident($AstTy:ty) { $kind_name:expr; - // FIXME: HACK: this should be `$(one ...)?` and `$(many ...)?` but `?` macro + // HACK: this should be `$(one ...)?` and `$(many ...)?` but `?` macro // repetition was removed from 2015 edition in #51587 because of ambiguities. $(one fn $mut_visit_ast:ident; fn $visit_ast:ident;)* $(many fn $flat_map_ast_elt:ident; fn $visit_ast_elt:ident;)* @@ -223,7 +223,7 @@ pub enum InvocationKind { attr: Option, traits: Vec, item: Annotatable, - // We temporarily report errors for attribute macros placed after derives + // We temporarily report errors for attribute macros placed after derives. after_derive: bool, }, Derive { @@ -245,7 +245,8 @@ impl Invocation { pub struct MacroExpander<'a, 'b:'a> { pub cx: &'a mut ExtCtxt<'b>, - monotonic: bool, // cf. `cx.monotonic_expander()` + // cf. `cx.monotonic_expander()` + monotonic: bool, } impl<'a, 'b> MacroExpander<'a, 'b> { @@ -284,7 +285,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { krate.module = module; }, None => { - // Resolution failed so we return an empty expansion + // Resolution failed, so we return an empty expansion. krate.attrs = vec![]; krate.module = ast::Mod { inner: orig_mod_span, @@ -298,7 +299,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { krate } - // Fully expand all macro invocations in this AST fragment. + // Fully expands all macro invocations in this AST fragment. fn expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment { let orig_expansion_data = self.cx.current_expansion.clone(); self.cx.current_expansion.depth = 0; @@ -347,7 +348,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.cx.current_expansion = invoc.expansion_data.clone(); self.cx.current_expansion.mark = scope; - // FIXME(jseyfried): Refactor out the following logic + // FIXME(jseyfried): factor out the following logic. let (expanded_fragment, new_invocations) = if let Some(ext) = ext { if let Some(ext) = ext { let (invoc_fragment_kind, invoc_span) = (invoc.fragment_kind, invoc.span()); @@ -480,8 +481,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { sess: self.cx.parse_sess, features: self.cx.ecfg.features, }; - // Since the item itself has already been configured by the InvocationCollector, - // we know that fold result vector will contain exactly one element + // Since the item itself has already been configured by the `InvocationCollector`, + // we know that fold result `Vec` will contain exactly one element. match item { Annotatable::Item(item) => { Annotatable::Item(cfg.flat_map_item(item).pop().unwrap()) @@ -579,7 +580,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { MultiDecorator(ref mac) => { let mut items = Vec::new(); let meta = attr.parse_meta(self.cx.parse_sess) - .expect("derive meta should already have been parsed"); + .expect("`derive` meta should already have been parsed"); mac.expand(self.cx, attr.span, &meta, &item, &mut |item| items.push(item)); items.push(item); Some(invoc.fragment_kind.expect_from_annotatables(items)) @@ -602,7 +603,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { res } ProcMacroDerive(..) | BuiltinDerive(..) => { - self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path)); + self.cx.span_err(attr.span, &format!("`{}` is a `derive` macro", attr.path)); self.cx.trace_macros_diag(); invoc.fragment_kind.dummy(attr.span) } @@ -697,7 +698,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } - /// Expand a macro invocation. Returns the resulting expanded AST fragment. + /// Expands a macro invocation. Returns the resulting expanded AST fragment. fn expand_bang_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtension) @@ -710,24 +711,24 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let path = &mac.node.path; let ident = ident.unwrap_or_else(|| keywords::Invalid.ident()); - let validate_and_set_expn_info = |this: &mut Self, // arg instead of capture + let validate_and_set_expn_info = |// Arg instead of capture. + this: &mut Self, def_site_span: Option, allow_internal_unstable, allow_internal_unsafe, local_inner_macros, - // can't infer this type + // Can't infer this type. unstable_feature: Option<(Symbol, u32)>, edition| { - - // feature-gate the macro invocation + // Feature-gate the macro invocation. if let Some((feature, issue)) = unstable_feature { let crate_span = this.cx.current_expansion.crate_span.unwrap(); - // don't stability-check macros in the same crate - // (the only time this is null is for syntax extensions registered as macros) + // Don't stability-check macros in the same crate. + // (The only time this is null is for syntax extensions registered as macros.) if def_site_span.map_or(false, |def_span| !crate_span.contains(def_span)) && !span.allows_unstable(&feature.as_str()) && this.cx.ecfg.features.map_or(true, |feats| { - // macro features will count as lib features + // Macro features will count as lib features. !feats.declared_lib_features.iter().any(|&(feat, _)| feat == feature) }) { let explain = format!("macro {}! is unstable", path); @@ -823,7 +824,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } ProcMacroDerive(..) | BuiltinDerive(..) => { - self.cx.span_err(path.span, &format!("`{}` is a derive mode", path)); + self.cx.span_err(path.span, &format!("`{}` is a `derive` macro", path)); self.cx.trace_macros_diag(); kind.dummy(span) } @@ -839,11 +840,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.gate_proc_macro_expansion_kind(span, kind); invoc.expansion_data.mark.set_expn_info(ExpnInfo { call_site: span, - // FIXME procedural macros do not have proper span info - // yet, when they do, we should use it here. + // FIXME: procedural macros do not have proper span info yet -- + // when they do, we should use it here. def_site: None, format: macro_bang_format(path), - // FIXME probably want to follow macro_rules macros here. + // FIXME: probably want to follow `macro_rules` macros here. allow_internal_unstable: allow_internal_unstable.clone(), allow_internal_unsafe: false, local_inner_macros: false, @@ -893,7 +894,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { ); } - /// Expand a derive invocation. Returns the resulting expanded AST fragment. + /// Expands a `derive` invocation. Returns the resulting expanded AST fragment. fn expand_derive_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtension) @@ -911,7 +912,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let attr = ast::Attribute { path, span, tokens: TokenStream::empty(), - // irrelevant: + // Irrelevant. id: ast::AttrId(0), style: ast::AttrStyle::Outer, is_sugared_doc: false, }; @@ -929,7 +930,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { ProcMacroDerive(ref ext, ..) => { invoc.expansion_data.mark.set_expn_info(expn_info); let span = span.with_ctxt(self.cx.backtrace()); - let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this + // FIXME(jseyfried): avoid this. + let dummy = ast::MetaItem { ident: Path::from_ident(keywords::Invalid.ident()), span: DUMMY_SP, node: ast::MetaItemKind::Word, @@ -942,7 +944,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Symbol::intern("rustc_attrs"), Symbol::intern("derive_clone_copy"), Symbol::intern("derive_eq"), - Symbol::intern("libstd_sys_internals"), // RustcDeserialize and RustcSerialize + // `RustcDeserialize` and `RustcSerialize`. + Symbol::intern("libstd_sys_internals"), ].into()); invoc.expansion_data.mark.set_expn_info(expn_info); let span = span.with_ctxt(self.cx.backtrace()); @@ -951,7 +954,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Some(invoc.fragment_kind.expect_from_annotatables(items)) } _ => { - let msg = &format!("macro `{}` may not be used for derive attributes", attr.path); + let msg = &format!("macro `{}` may not be used for `derive` attributes", attr.path); self.cx.span_err(span, msg); self.cx.trace_macros_diag(); invoc.fragment_kind.dummy(span) @@ -1016,7 +1019,7 @@ impl<'a> Parser<'a> { AstFragmentKind::Stmts => { let mut stmts = SmallVec::new(); while self.token != token::Eof && - // won't make progress on a `}` + // Won't make progress on a `}`. self.token != token::CloseDelim(token::Brace) { if let Some(stmt) = self.parse_full_stmt(macro_legacy_warnings)? { stmts.push(stmt); @@ -1127,7 +1130,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { attr } - /// If `item` is an attr invocation, remove and return the macro attribute and derive traits. + /// If `item` is an attribute invocation, remove and return the macro attribute and `derive` + /// traits. fn classify_item(&mut self, item: &mut T) -> (Option, Vec, /* after_derive */ bool) where T: HasAttrs, @@ -1142,9 +1146,9 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { (attr, traits, after_derive) } - /// Alternative to `classify_item()` that ignores `#[derive]` so invocations fallthrough - /// to the unused-attributes lint (making it an error on statements and expressions - /// is a breaking change) + /// Alternative to `classify_item()` that ignores `#[derive]` so that invocations fall through + /// to the unused-attributes lint. + /// (Note, making it an error on statements and expressions is a breaking change.) fn classify_nonitem(&mut self, nonitem: &mut T) -> (Option, /* after_derive */ bool) { let (mut attr, mut after_derive) = (None, false); @@ -1160,14 +1164,14 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { self.cfg.configure(node) } - // Detect use of feature-gated or invalid attributes on macro invocations - // since they will not be detected after macro expansion. + /// Detects use of feature-gated or invalid attributes on macro invocations, + /// since they will not be detected after macro expansion. fn check_attributes(&mut self, attrs: &[ast::Attribute]) { let features = self.cx.ecfg.features.unwrap(); for attr in attrs.iter() { self.check_attribute_inner(attr, features); - // macros are expanded before any lint passes so this warning has to be hardcoded + // Macros are expanded before any lint passes, so this warning has to be hard-coded. if attr.path == "derive" { self.cx.struct_span_warn(attr.span, "`#[derive]` does nothing on macro invocations") .note("this may become a hard error in a future release") @@ -1192,15 +1196,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { visit_clobber(expr.deref_mut(), |mut expr| { self.cfg.configure_expr_kind(&mut expr.node); - // ignore derives so they remain unused + // Ignore `derive`s so that they remain unused. let (attr, after_derive) = self.classify_nonitem(&mut expr); if attr.is_some() { - // Collect the invoc regardless of whether or not attributes are permitted here - // expansion will eat the attribute so it won't error later. + // Collect the invocation regardless of whether or not attributes are permitted + // here. Expansion will eat the attribute so that it won't error later. attr.as_ref().map(|a| self.cfg.maybe_emit_expr_attr_err(a)); - // AstFragmentKind::Expr requires the macro to emit an expression. + // `AstFragmentKind::Expr` requires the macro to emit an expression. return self.collect_attr(attr, vec![], Annotatable::Expr(P(expr)), AstFragmentKind::Expr, after_derive) .make_expr() @@ -1224,7 +1228,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { expr.filter_map(|mut expr| { self.cfg.configure_expr_kind(&mut expr.node); - // Ignore derives so they remain unused. + // Ignore derives so that they remain unused. let (attr, after_derive) = self.classify_nonitem(&mut expr); if attr.is_some() { @@ -1266,13 +1270,13 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { let mut stmt = configure!(self, stmt); - // we'll expand attributes on expressions separately + // We'll expand attributes on expressions separately. if !stmt.is_expr() { let (attr, derives, after_derive) = if stmt.is_item() { self.classify_item(&mut stmt) } else { - // ignore derives on non-item statements so it falls through - // to the unused-attributes lint + // Ignore `derive`s on non-item statements, so it falls through + // to the unused-attributes lint. let (attr, after_derive) = self.classify_nonitem(&mut stmt); (attr, vec![], after_derive) }; @@ -1300,7 +1304,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { return placeholder; } - // The placeholder expander gives ids to statements, so we avoid folding the id here. + // The placeholder expander gives IDs to statements, so we avoid folding the ID here. let ast::Stmt { id, node, span } = stmt; noop_flat_map_stmt_kind(node, self).into_iter().map(|node| { ast::Stmt { id, node, span } @@ -1484,8 +1488,8 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } fn visit_attribute(&mut self, at: &mut ast::Attribute) { - // turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename", - // contents="file contents")]` attributes + // Turn `#[doc(include="filename")]` attributes into + // `#[doc(include(file="filename", contents="file contents")]` attributes. if !at.check_name("doc") { return noop_visit_attribute(at, self); } @@ -1507,7 +1511,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { let err_count = self.cx.parse_sess.span_diagnostic.err_count(); self.check_attribute(&at); if self.cx.parse_sess.span_diagnostic.err_count() > err_count { - // avoid loading the file if they haven't enabled the feature + // Avoid loading the file if user hasn't enabled the feature. return noop_visit_attribute(at, self); } @@ -1517,7 +1521,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { let src_interned = Symbol::intern(&src); // Add this input file to the code map to make it available as - // dependency information + // dependency information. self.cx.source_map().new_source_file(filename.into(), src); let include_info = vec![ @@ -1624,7 +1628,8 @@ pub struct ExpansionConfig<'feat> { pub features: Option<&'feat Features>, pub recursion_limit: usize, pub trace_mac: bool, - pub should_test: bool, // If false, strip `#[test]` nodes + // If `false`, strip `#[test]` nodes. + pub should_test: bool, pub single_step: bool, pub keep_macs: bool, } @@ -1675,7 +1680,7 @@ impl<'feat> ExpansionConfig<'feat> { } } -// A Marker adds the given mark to the syntax context. +// Adds the given mark to the syntax context. #[derive(Debug)] pub struct Marker(pub Mark); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 5de1ccec8609e..f8cb4f54189ae 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -389,7 +389,7 @@ fn nameize>( TokenTree::MetaVarDecl(sp, bind_name, _) => { match ret_val.entry(bind_name) { Vacant(spot) => { - // FIXME(simulacrum): Don't construct Rc here + // FIXME(simulacrum): don't construct `Rc` here. spot.insert(Rc::new(res.next().unwrap())); } Occupied(..) => { @@ -592,7 +592,7 @@ fn inner_parse_loop<'root, 'tt>( // We need to match a metavar with a valid ident... call out to the black-box // parser by adding an item to `bb_items`. TokenTree::MetaVarDecl(_, _, id) => { - // Built-in nonterminals never start with these tokens, + // Built-in non-terminals never start with these tokens, // so we can eliminate them from consideration. if may_begin_with(&*id.as_str(), token) { bb_items.push(item); @@ -726,12 +726,12 @@ pub fn parse( ); } } - // Performance hack: eof_items may share matchers via Rc with other things that we want - // to modify. Dropping eof_items now may drop these refcounts to 1, preventing an - // unnecessary implicit clone later in Rc::make_mut. + // Performance hack: `eof_items` may share matchers via Rc with other things that we want + // to modify. Dropping eof_items now may drop these ref counts to 1, preventing an + // unnecessary implicit clone later in `Rc::make_mut`. drop(eof_items); - // Another possibility is that we need to call out to parse some rust nonterminal + // Another possibility is that we need to call out to parse some rust non-terminal. // (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong. if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 { let nts = bb_items @@ -771,7 +771,7 @@ pub fn parse( parser.bump(); } // Finally, we have the case where we need to call the black-box parser to get some - // nonterminal. + // non-terminal. else { assert_eq!(bb_items.len(), 1); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index bd64bb010219b..abf7510e29e15 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -134,10 +134,11 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>, let mut best_fail_tok = None; let mut best_fail_text = None; - for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers + // Try each arm's matchers. + for (i, lhs) in lhses.iter().enumerate() { let lhs_tt = match *lhs { quoted::TokenTree::Delimited(_, ref delim) => &delim.tts[..], - _ => cx.span_bug(sp, "malformed macro lhs") + _ => cx.span_bug(sp, "malformed macro LHS") }; match TokenTree::parse(cx, lhs_tt, arg.clone()) { @@ -213,7 +214,8 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>, // Check whether there's a missing comma in this macro call, like `println!("{}" a);` if let Some((arg, comma_span)) = arg.add_comma() { - for lhs in lhses { // try each arm's matchers + // Try each arm's matchers. + for lhs in lhses { let lhs_tt = match *lhs { quoted::TokenTree::Delimited(_, ref delim) => &delim.tts[..], _ => continue, @@ -241,7 +243,8 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>, } // Note that macro-by-example's input is also matched against a token tree: -// $( $lhs:tt => $rhs:tt );+ +// +// $( $lhs:tt => $rhs:tt );+ // // Holy self-referential! @@ -255,17 +258,19 @@ pub fn compile( let lhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("lhs")); let rhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("rhs")); - // Parse the macro_rules! invocation + // Parse the `macro_rules!` invocation. let body = match def.node { ast::ItemKind::MacroDef(ref body) => body, _ => unreachable!(), }; - // The pattern that macro_rules matches. - // The grammar for macro_rules! is: - // $( $lhs:tt => $rhs:tt );+ - // ...quasiquoting this would be nice. - // These spans won't matter, anyways + // The pattern that `macro_rules` matches. + // The grammar for `macro_rules!` is: + // + // $( $lhs:tt => $rhs:tt );+ + // + // N.B., quasiquoting this would be nice. + // These spans won't matter, in any case. let argument_gram = vec![ quoted::TokenTree::Sequence(DelimSpan::dummy(), Lrc::new(quoted::SequenceRepetition { tts: vec![ @@ -277,7 +282,7 @@ pub fn compile( op: quoted::KleeneOp::OneOrMore, num_captures: 2, })), - // to phase into semicolon-termination instead of semicolon-separation + // To phase into semicolon-termination instead of semicolon-separation. quoted::TokenTree::Sequence(DelimSpan::dummy(), Lrc::new(quoted::SequenceRepetition { tts: vec![quoted::TokenTree::Token(DUMMY_SP, token::Semi)], separator: None, @@ -303,7 +308,7 @@ pub fn compile( let mut valid = true; - // Extract the arguments: + // Extract the arguments. let lhses = match *argument_map[&lhs_nm] { MatchedSeq(ref s, _) => { s.iter().map(|m| { @@ -324,10 +329,10 @@ pub fn compile( return tt; } } - sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") + sess.span_diagnostic.span_bug(def.span, "badly-structured LHS") }).collect::>() } - _ => sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") + _ => sess.span_diagnostic.span_bug(def.span, "badly-structured LHS") }; let rhses = match *argument_map[&rhs_nm] { @@ -347,17 +352,17 @@ pub fn compile( .unwrap(); } } - sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") + sess.span_diagnostic.span_bug(def.span, "badly-structured LHS") }).collect::>() } - _ => sess.span_diagnostic.span_bug(def.span, "wrong-structured rhs") + _ => sess.span_diagnostic.span_bug(def.span, "badly-structured RHS") }; for rhs in &rhses { valid &= check_rhs(sess, rhs); } - // don't abort iteration early, so that errors for multiple lhses can be reported + // Don't abort iteration early, so that errors for multiple LHSs can be reported. for lhs in &lhses { valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]); valid &= check_lhs_duplicate_matcher_bindings( @@ -387,9 +392,10 @@ pub fn compile( ) .unwrap_or_else(|| { sess.span_diagnostic.span_warn( - attr.span, "allow_internal_unstable expects list of feature names. In the \ - future this will become a hard error. Please use `allow_internal_unstable(\ - foo, bar)` to only allow the `foo` and `bar` features", + attr.span, + "allow_internal_unstable expects list of feature names. in the \ + future this will become a hard error. please use `allow_internal_unstable(\ + foo, bar)` to only allow the `foo` and `bar` features", ); vec![Symbol::intern("allow_internal_unstable_backcompat_hack")].into() }) @@ -436,8 +442,9 @@ fn check_lhs_nt_follows(sess: &ParseSess, features: &Features, attrs: &[ast::Attribute], lhs: "ed::TokenTree) -> bool { - // lhs is going to be like TokenTree::Delimited(...), where the - // entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens. + // LHS is going to be like `TokenTree::Delimited(...)`, where the + // entire LHS is those token trees. Otherwise, it can be a "bare sequence", + // not wrapped in parentheses. if let quoted::TokenTree::Delimited(_, ref tts) = *lhs { check_matcher(sess, features, attrs, &tts.tts) } else { @@ -445,11 +452,11 @@ fn check_lhs_nt_follows(sess: &ParseSess, sess.span_diagnostic.span_err(lhs.span(), msg); false } - // we don't abort on errors on rejection, the driver will do that for us + // We don't abort on errors on rejection; the driver will do that for us // after parsing/expansion. we can report every error in every macro this way. } -/// Checks that the lhs contains no repetition which could match an empty token +/// Checks that the LHS contains no repetition which could match an empty token /// tree, because then the matcher would hang indefinitely. fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool { use quoted::TokenTree; @@ -483,8 +490,9 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool { true } -/// Check that the LHS contains no duplicate matcher bindings. e.g. `$a:expr, $a:expr` would be -/// illegal, since it would be ambiguous which `$a` to use if we ever needed to. +/// Checks that the LHS contains no duplicate matcher bindings. +/// E.g., `$a:expr, $a:expr` would be illegal, since it would be ambiguous which `$a` to use if we +/// ever needed to. fn check_lhs_duplicate_matcher_bindings( sess: &ParseSess, tts: &[quoted::TokenTree], @@ -497,11 +505,12 @@ fn check_lhs_duplicate_matcher_bindings( match *tt { TokenTree::MetaVarDecl(span, name, _kind) => { if let Some(&prev_span) = metavar_names.get(&name) { - // FIXME(mark-i-m): in a few cycles, make this a hard error. - // sess.span_diagnostic - // .struct_span_err(span, "duplicate matcher binding") - // .span_note(prev_span, "previous declaration was here") - // .emit(); + // FIXME(mark-i-m): after a few release cycles, make this a hard error. + // + // sess.span_diagnostic + // .struct_span_err(span, "duplicate matcher binding") + // .span_note(prev_span, "previous declaration was here") + // .emit(); sess.buffer_lint( BufferedEarlyLintId::DuplicateMacroMatcherBindingName, crate::source_map::MultiSpan::from(vec![prev_span, span]), @@ -533,7 +542,7 @@ fn check_lhs_duplicate_matcher_bindings( fn check_rhs(sess: &ParseSess, rhs: "ed::TokenTree) -> bool { match *rhs { quoted::TokenTree::Delimited(..) => return true, - _ => sess.span_diagnostic.span_err(rhs.span(), "macro rhs must be delimited") + _ => sess.span_diagnostic.span_err(rhs.span(), "macro RHS must be delimited") } false } @@ -579,7 +588,7 @@ impl FirstSets { build_recur(&mut sets, tts); return sets; - // walks backward over `tts`, returning the FIRST for `tts` + // Walks backward over `tts`, returning the FIRST for `tts` // and updating `sets` at the same time for all sequence // substructure we find within `tts`. fn build_recur(sets: &mut FirstSets, tts: &[TokenTree]) -> TokenSet { @@ -601,8 +610,8 @@ impl FirstSets { vac.insert(Some(subfirst.clone())); } Entry::Occupied(mut occ) => { - // if there is already an entry, then a span must have collided. - // This should not happen with typical macro_rules macros, + // If there is already an entry, then a span must have collided. + // This should not happen with typical `macro_rules` macros, // but syntax extensions need not maintain distinct spans, // so distinct syntax trees can be assigned the same span. // In such a case, the map cannot be trusted; so mark this @@ -619,17 +628,16 @@ impl FirstSets { first.add_one_maybe(TokenTree::Token(sp.entire(), sep.clone())); } - // Reverse scan: Sequence comes before `first`. + // Reverse scan: sequence comes before `first`. if subfirst.maybe_empty || seq_rep.op == quoted::KleeneOp::ZeroOrMore || seq_rep.op == quoted::KleeneOp::ZeroOrOne { - // If sequence is potentially empty, then - // union them (preserving first emptiness). + // If sequence is potentially empty, then union them + // (preserving first emptiness). first.add_all(&TokenSet { maybe_empty: true, ..subfirst }); } else { - // Otherwise, sequence guaranteed - // non-empty; replace first. + // Otherwise, sequence guaranteed non-empty; replace first. first = subfirst; } } @@ -640,8 +648,7 @@ impl FirstSets { } } - // walks forward over `tts` until all potential FIRST tokens are - // identified. + // Walks forward over `tts` until all potential *first* tokens are identified. fn first(&self, tts: &[quoted::TokenTree]) -> TokenSet { use quoted::TokenTree; @@ -675,9 +682,8 @@ impl FirstSets { || seq_rep.op == quoted::KleeneOp::ZeroOrMore || seq_rep.op == quoted::KleeneOp::ZeroOrOne { - // continue scanning for more first - // tokens, but also make sure we - // restore empty-tracking state + // Continue scanning for more first tokens, but also make sure we + // restore empty-tracking state. first.maybe_empty = true; continue; } else { @@ -690,15 +696,15 @@ impl FirstSets { } None => { - panic!("We missed a sequence during FirstSets construction"); + panic!("we missed a sequence during `FirstSets` construction"); } } } } } - // we only exit the loop if `tts` was empty or if every - // element of `tts` matches the empty sequence. + // We only exit the loop if `tts` was empty or if every element of `tts` + // matches the empty sequence. assert!(first.maybe_empty); first } @@ -754,7 +760,7 @@ impl TokenSet { self.maybe_empty = false; } - // Adds `tok` to the set for `self`. (Leaves `maybe_empty` flag alone.) + // Adds `tok` to the set for `self`. (Leaves the `maybe_empty` flag alone.) fn add_one_maybe(&mut self, tok: quoted::TokenTree) { if !self.tokens.contains(&tok) { self.tokens.push(tok); @@ -781,8 +787,8 @@ impl TokenSet { } // Checks that `matcher` is internally consistent and that it -// can legally by followed by a token N, for all N in `follow`. -// (If `follow` is empty, then it imposes no constraint on +// can legally by followed by a token `N`, for all `N` in `FOLLOW`. +// (If `FOLLOW` is empty, then it imposes no constraint on // the `matcher`.) // // Returns the set of NT tokens that could possibly come last in @@ -801,9 +807,9 @@ fn check_matcher_core(sess: &ParseSess, let mut last = TokenSet::empty(); - // 2. For each token and suffix [T, SUFFIX] in M: - // ensure that T can be followed by SUFFIX, and if SUFFIX may be empty, - // then ensure T can also be followed by any element of FOLLOW. + // 2. For each token and suffix `[T, SUFFIX]` in `M`: + // ensure that `T` can be followed by `SUFFIX`, and if `SUFFIX` may be empty, + // then ensure `T` can also be followed by any element of `FOLLOW`. 'each_token: for i in 0..matcher.len() { let token = &matcher[i]; let suffix = &matcher[i+1..]; @@ -814,7 +820,7 @@ fn check_matcher_core(sess: &ParseSess, s }; - // (we build `suffix_first` on demand below; you can tell + // (We build `suffix_first` on demand below; you can tell // which cases are supposed to fall through by looking for the // initialization of this variable.) let suffix_first; @@ -837,10 +843,10 @@ fn check_matcher_core(sess: &ParseSess, } if can_be_followed_by_any { - // don't need to track tokens that work with any, + // Don't need to track tokens that work with any, ... last.replace_with_irrelevant(); // ... and don't need to check tokens that can be - // followed by anything against SUFFIX. + // followed by anything against `SUFFIX`. continue 'each_token; } else { last.replace_with(token.clone()); @@ -850,24 +856,23 @@ fn check_matcher_core(sess: &ParseSess, TokenTree::Delimited(span, ref d) => { let my_suffix = TokenSet::singleton(d.close_tt(span.close)); check_matcher_core(sess, features, attrs, first_sets, &d.tts, &my_suffix); - // don't track non NT tokens + // Don't track non NT tokens. last.replace_with_irrelevant(); - // also, we don't need to check delimited sequences - // against SUFFIX + // Also, we don't need to check delimited sequences against `SUFFIX`. continue 'each_token; } TokenTree::Sequence(sp, ref seq_rep) => { suffix_first = build_suffix_first(); // The trick here: when we check the interior, we want // to include the separator (if any) as a potential - // (but not guaranteed) element of FOLLOW. So in that + // (but not guaranteed) element of `FOLLOW`. So in that // case, we make a temp copy of suffix and stuff // delimiter in there. // - // FIXME: Should I first scan suffix_first to see if + // FIXME: should we first scan `suffix_first` to see if // delimiter is already in it before I go through the - // work of cloning it? But then again, this way I may + // work of cloning it? But then again, this way we may // get a "tighter" span? let mut new; let my_suffix = if let Some(ref u) = seq_rep.separator { @@ -893,16 +898,17 @@ fn check_matcher_core(sess: &ParseSess, last = next; } - // the recursive call to check_matcher_core already ran the 'each_last - // check below, so we can just keep going forward here. + // The recursive call to `check_matcher_core` already + // ran the `'each_last` check below, so we can just keep + // going forward here. continue 'each_token; } } - // (`suffix_first` guaranteed initialized once reaching here.) + // (`suffix_first` guaranteed initialized once reached here.) - // Now `last` holds the complete set of NT tokens that could - // end the sequence before SUFFIX. Check that every one works with `suffix`. + // `last` now holds the complete set of NT tokens that could + // end the sequence before `SUFFIX`. Check that every one works with `SUFFIX`. 'each_last: for token in &last.tokens { if let TokenTree::MetaVarDecl(_, ref name, ref frag_spec) = *token { for next_token in &suffix_first.tokens { @@ -910,7 +916,7 @@ fn check_matcher_core(sess: &ParseSess, IsInFollow::Invalid(msg, help) => { sess.span_diagnostic.struct_span_err(next_token.span(), &msg) .help(help).emit(); - // don't bother reporting every source of + // Don't bother reporting every source of // conflict for a particular element of `last`. continue 'each_last; } @@ -972,7 +978,7 @@ fn token_can_be_followed_by_any(tok: "ed::TokenTree) -> bool { if let quoted::TokenTree::MetaVarDecl(_, _, frag_spec) = *tok { frag_can_be_followed_by_any(&frag_spec.as_str()) } else { - // (Non NT's can always be followed by anthing in matchers.) + // Non NT's can always be followed by anthing in matchers. true } } @@ -993,7 +999,7 @@ fn frag_can_be_followed_by_any(frag: &str) -> bool { "literal" | // exactly one token tree "meta" | // exactly one token tree "lifetime" | // exactly one token tree - "tt" => // exactly one token tree + "tt" => // exactly one token tree true, _ => @@ -1014,24 +1020,25 @@ enum IsInFollow { /// we expanded `expr` to include a new binary operator, we might /// break macros that were relying on that binary operator as a /// separator. -// when changing this do not forget to update doc/book/macros.md! +// +// NOTE: when changing this, do not forget to update `doc/book/macros.md`. fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow { use quoted::TokenTree; if let TokenTree::Token(_, token::CloseDelim(_)) = *tok { - // closing a token tree can never be matched by any fragment; - // iow, we always require that `(` and `)` match, etc. + // Closing a token tree can never be matched by any fragment; + // i.e., we always require that `(` and `)` match, etc. IsInFollow::Yes } else { match frag { "item" => { - // since items *must* be followed by either a `;` or a `}`, we can - // accept anything after them + // Since items *must* be followed by either a `;` or a `}`, we can + // accept anything after them. IsInFollow::Yes }, "block" => { - // anything can follow block, the braces provide an easy boundary to - // maintain + // Anything can follow a block, since the braces provide an easy boundary + // to maintain. IsInFollow::Yes }, "stmt" | "expr" => { @@ -1074,16 +1081,15 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow { } }, "ident" | "lifetime" => { - // being a single token, idents and lifetimes are harmless + // Being a single tokens, an ident or lifetime is harmless. IsInFollow::Yes }, "literal" => { - // literals may be of a single token, or two tokens (negative numbers) + // Literals may be of a single token, or two tokens (negative numbers). IsInFollow::Yes }, "meta" | "tt" => { - // being either a single token or a delimited sequence, tt is - // harmless + // Being either a single token or a delimited sequence, a token tree is harmless. IsInFollow::Yes }, "vis" => { @@ -1105,7 +1111,8 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow { _ => IsInFollow::No(tokens), } }, - "" => IsInFollow::Yes, // keywords::Invalid + // `keywords::Invalid` + "" => IsInFollow::Yes, _ => IsInFollow::Invalid(format!("invalid fragment specifier `{}`", frag), VALID_FRAGMENT_NAMES_MSG), } @@ -1132,12 +1139,10 @@ fn is_legal_fragment_specifier(_sess: &ParseSess, _attrs: &[ast::Attribute], frag_name: &str, _frag_span: Span) -> bool { - /* - * If new fragment specifiers are invented in nightly, `_sess`, - * `_features`, `_attrs`, and `_frag_span` will be useful here - * for checking against feature gates. See past versions of - * this function. - */ + // If new fragment specifiers are invented in nightly, `_sess`, + // `_features`, `_attrs`, and `_frag_span` will be useful here + // for checking against feature gates. See past versions of + // this function. match frag_name { "item" | "block" | "stmt" | "expr" | "pat" | "lifetime" | "path" | "ty" | "ident" | "meta" | "tt" | "vis" | "literal" | @@ -1151,7 +1156,7 @@ fn quoted_tt_to_string(tt: "ed::TokenTree) -> String { quoted::TokenTree::Token(_, ref tok) => crate::print::pprust::token_to_string(tok), quoted::TokenTree::MetaVar(_, name) => format!("${}", name), quoted::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind), - _ => panic!("unexpected quoted::TokenTree::{{Sequence or Delimited}} \ + _ => panic!("unexpected `quoted::TokenTree::Sequence` or `quoted::TokenTree::Delimited` \ in follow set checker"), } } diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 255795f28c7a3..524028cf6902b 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -82,20 +82,22 @@ pub enum KleeneOp { pub enum TokenTree { Token(Span, token::Token), Delimited(DelimSpan, Lrc), - /// A kleene-style repetition sequence + /// A kleene-style repetition sequence. Sequence(DelimSpan, Lrc), - /// e.g., `$var` + /// E.g., `$var`. MetaVar(Span, ast::Ident), - /// e.g., `$var:expr`. This is only used in the left hand side of MBE macros. + /// E.g., `$var:expr`. This is only used in the left-hand side of MBE macros. MetaVarDecl( Span, - ast::Ident, /* name to bind */ - ast::Ident, /* kind of nonterminal */ + /// The name to bind. + ast::Ident, + /// The kind of non-terminal. + ast::Ident, ), } impl TokenTree { - /// Return the number of tokens in the tree. + /// Returns the number of tokens in the tree. pub fn len(&self) -> usize { match *self { TokenTree::Delimited(_, ref delimed) => match delimed.delim { @@ -271,7 +273,7 @@ where // `tree` is a `$` token. Look at the next token in `trees` tokenstream::TokenTree::Token(span, token::Dollar) => match trees.next() { // `tree` is followed by a delimited set of token trees. This indicates the beginning - // of a repetition sequence in the macro (e.g. `$(pat)*`). + // of a repetition sequence in the macro (e.g., `$(pat)*`). Some(tokenstream::TokenTree::Delimited(span, delim, tts)) => { // Must have `(` not `{` or `[` if delim != token::Paren { @@ -473,7 +475,7 @@ where if is_1_sep { // #1 is a separator and #2 should be a KleepeOp. - // (N.B. We need to advance the input iterator.) + // (N.B., we need to advance the input iterator.) match parse_kleene_op(input, span) { // #2 is `?`, which is not allowed as a Kleene op in 2015 edition. Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index b9a50cc6488dd..77c0f4a77851b 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -121,13 +121,13 @@ pub fn transcribe(cx: &ExtCtxt<'_>, variables matched as repeating at this depth"); } LockstepIterSize::Contradiction(ref msg) => { - // FIXME #2887 blame macro invoker instead + // FIXME(#2887): blame macro invoker instead cx.span_fatal(sp.entire(), &msg[..]); } LockstepIterSize::Constraint(len, _) => { if len == 0 { if seq.op == quoted::KleeneOp::OneOrMore { - // FIXME #2887 blame invoker + // FIXME(#2887): blame invoker cx.span_fatal(sp.entire(), "this must repeat at least once"); } } else { @@ -141,7 +141,7 @@ pub fn transcribe(cx: &ExtCtxt<'_>, } } } - // FIXME #2887: think about span stuff here + // FIXME(#2887): think about span stuff here quoted::TokenTree::MetaVar(mut sp, ident) => { if let Some(cur_matched) = lookup_cur_matched(ident, &interpolations, &repeats) { if let MatchedNonterminal(ref nt) = *cur_matched { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d574b410ccc06..1e5e5ef3ca873 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -405,7 +405,7 @@ declare_features! ( // `#[doc(alias = "...")]` (active, doc_alias, "1.27.0", Some(50146), None), - // inconsistent bounds in where clauses + // inconsistent bounds in where-clauses (active, trivial_bounds, "1.28.0", Some(48214), None), // `'a: { break 'a; }` @@ -781,11 +781,11 @@ impl AttributeGate { pub enum Stability { Unstable, // First argument is tracking issue link; second argument is an optional - // help message, which defaults to "remove this attribute" + // help message, which defaults to "remove this attribute". Deprecated(&'static str, Option<&'static str>), } -// fn() is not Debug +// `fn()` is not `Debug`. impl std::fmt::Debug for AttributeGate { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { @@ -818,7 +818,7 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool { BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, ..)| attr.path == builtin_name) } -// Attributes that have a special meaning to rustc or rustdoc +// Attributes that have a special meaning to rustc or rustdoc. pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, AttributeGate)] = &[ // Normal attributes @@ -1117,11 +1117,10 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu "internal implementation detail", cfg_fn!(rustc_attrs))), - // FIXME: #14408 whitelist docs since rustdoc looks at them + // FIXME: #14408 whitelist docs since rustdoc looks at them. ("doc", Whitelisted, template!(List: "hidden|inline|...", NameValueStr: "string"), Ungated), - // FIXME: #14406 these are processed in codegen, which happens after the - // lint pass + // FIXME: #14406 these are processed in codegen, which happens after the lint pass. ("cold", Whitelisted, template!(Word), Ungated), ("naked", Whitelisted, template!(Word), Gated(Stability::Unstable, "naked_functions", @@ -1171,14 +1170,14 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu cfg_fn!(unwind_attributes))), ("used", Whitelisted, template!(Word), Ungated), - // used in resolve + // Used in resolve. ("prelude_import", Whitelisted, template!(Word), Gated(Stability::Unstable, "prelude_import", "`#[prelude_import]` is for use by rustc only", cfg_fn!(prelude_import))), // FIXME: #14407 these are only looked at on-demand so we can't - // guarantee they'll have already been checked + // guarantee they'll have already been checked. ("rustc_deprecated", Whitelisted, template!(List: r#"since = "version", reason = "...""#), Ungated), ("must_use", Whitelisted, template!(Word, NameValueStr: "reason"), Ungated), @@ -1221,7 +1220,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu never be stable", cfg_fn!(rustc_attrs))), - // whitelists "identity-like" conversion methods to suggest on type mismatch + // Whitelists "identity-like" conversion methods to suggest on type mismatch. ("rustc_conversion_suggestion", Whitelisted, template!(Word), Gated(Stability::Unstable, "rustc_attrs", "this is an internal attribute that will \ @@ -1246,7 +1245,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu "#[optimize] attribute is an unstable feature", cfg_fn!(optimize_attribute))), - // Crate level attributes + // Crate level attributes. ("crate_name", CrateLevel, template!(NameValueStr: "name"), Ungated), ("crate_type", CrateLevel, template!(NameValueStr: "bin|lib|..."), Ungated), ("crate_id", CrateLevel, template!(NameValueStr: "ignored"), Ungated), @@ -1262,7 +1261,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu cfg_fn!(custom_test_frameworks))), ]; -// cfg(...)'s that are feature gated +// `cfg(...)`s that are feature gated. const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[ // (name in cfg, feature, function to check if the feature is enabled) ("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)), @@ -1387,11 +1386,11 @@ pub fn check_attribute(attr: &ast::Attribute, parse_sess: &ParseSess, features: fn find_lang_feature_issue(feature: &str) -> Option { if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.0 == feature) { let issue = info.2; - // FIXME (#28244): enforce that active features have issue numbers + // FIXME(#28244): enforce that active features have issue numbers. // assert!(issue.is_some()) issue } else { - // search in Accepted, Removed, or Stable Removed features + // Search in Accepted, Removed, or Stable Removed features. let found = ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES).chain(STABLE_REMOVED_FEATURES) .find(|t| t.0 == feature); match found { @@ -1445,7 +1444,7 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue GateStrength::Soft => diag.struct_span_warn(span, &explanation), }; - // #23973: do not suggest `#![feature(...)]` if we are in beta/stable + // #23973: do not suggest `#![feature(...)]` if we are in beta/stable. if sess.unstable_features.is_nightly_build() { err.help(&format!("add #![feature({})] to the \ crate attributes to enable", @@ -1817,7 +1816,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) { if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty { if let ast::TyKind::Never = output_ty.node { - // Do nothing + // Do nothing. } else { self.visit_ty(output_ty) } @@ -1942,7 +1941,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } if !ti.generics.where_clause.predicates.is_empty() { gate_feature_post!(&self, generic_associated_types, ti.span, - "where clauses on associated types are unstable"); + "where-clauses on associated types are unstable"); } } _ => {} @@ -1974,7 +1973,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } if !ii.generics.where_clause.predicates.is_empty() { gate_feature_post!(&self, generic_associated_types, ii.span, - "where clauses on associated types are unstable"); + "where-clauses on associated types are unstable"); } } _ => {} @@ -2063,7 +2062,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], for &(name, .., f_edition, set) in ACTIVE_FEATURES { if let Some(f_edition) = f_edition { if f_edition <= *edition { - // FIXME(Manishearth) there is currently no way to set + // FIXME(Manishearth): there is currently no way to set // lib features by edition set(&mut features, DUMMY_SP); edition_enabled_features.insert(Symbol::intern(name), *edition); @@ -2167,9 +2166,9 @@ pub enum UnstableFeatures { impl UnstableFeatures { pub fn from_environment() -> UnstableFeatures { - // Whether this is a feature-staged build, i.e., on the beta or stable channel + // Whether this is a feature-staged build, i.e., on the beta or stable channel. let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some(); - // Whether we should enable unstable features for bootstrapping + // Whether we should enable unstable features for bootstrapping. let bootstrap = env::var("RUSTC_BOOTSTRAP").is_ok(); match (disable_unstable_features, bootstrap) { (_, true) => UnstableFeatures::Cheat, diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 36488b3a69f07..bb328e23fa642 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -21,17 +21,19 @@ #![recursion_limit="256"] +// Used by deriving. #[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving +extern crate serialize as rustc_serialize; pub use errors; use rustc_data_structures::sync::Lock; use rustc_data_structures::bit_set::GrowableBitSet; pub use rustc_data_structures::thin_vec::ThinVec; -use ast::AttrId; -// A variant of 'try!' that panics on an Err. This is used as a crutch on the -// way towards a non-panic!-prone parser. It should be used for fatal parsing +use crate::ast::AttrId; + +// A variant of `try!` that panics on an `Err`. This is used as a crutch on the +// way towards a parser not prone to `panic!`. It should be used for fatal parsing // errors; eventually we plan to convert all code using panictry to just use // normal try. macro_rules! panictry { @@ -48,7 +50,8 @@ macro_rules! panictry { }) } -// A variant of 'panictry!' that works on a Vec instead of a single DiagnosticBuilder. +// A variant of `panictry!` that works on a `Vec` instead of a single +// `DiagnosticBuilder`. macro_rules! panictry_buffer { ($handler:expr, $e:expr) => ({ use std::result::Result::{Ok, Err}; diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index b36ca0574cb8d..dc76f5068a940 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -1,3 +1,5 @@ +use log::debug; + use crate::attr; use crate::ast; use crate::source_map::respan; @@ -6,8 +8,6 @@ use crate::parse::token::{self, Nonterminal, DelimToken}; use crate::parse::parser::{Parser, TokenType, PathStyle}; use crate::tokenstream::{TokenStream, TokenTree}; -use log::debug; - #[derive(Debug)] enum InnerAttributeParsePolicy<'a> { Permitted, diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index b4103440e3577..d3a66a8956c85 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -1,6 +1,6 @@ -//! Routines the parser uses to classify AST nodes +//! Routines the parser uses to classify AST nodes. -// Predicates on exprs and stmts that the pretty-printer and parser use +// Predicates on expressions and statements that the pretty-printer and parser use. use crate::ast; diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 74fff3324eacf..a732b2f3414eb 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -248,7 +248,7 @@ fn read_block_comment(rdr: &mut StringReader<'_>, let mut curr_line = String::from("/*"); - // doc-comments are not really comments, they are attributes + // Doc-comments are not really comments; they are attributes. if (rdr.ch_is('*') && !rdr.nextch_is('*')) || rdr.ch_is('!') { while !(rdr.ch_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() { curr_line.push(rdr.ch.unwrap()); @@ -373,7 +373,7 @@ pub fn gather_comments_and_literals(sess: &ParseSess, path: FileName, srdr: &mut code_to_the_left = false; anything_to_the_left = false; } - // Eat one comment group + // Eat one comment group. if rdr.peeking_at_comment() { consume_comment(&mut rdr, &mut comments, &mut code_to_the_left, &mut anything_to_the_left); @@ -384,7 +384,7 @@ pub fn gather_comments_and_literals(sess: &ParseSess, path: FileName, srdr: &mut let bstart = rdr.pos; rdr.next_token(); - // discard, and look ahead; we're working with internal state + // Discard, and look ahead; we're working with internal state. let TokenAndSpan { tok, sp } = rdr.peek(); if tok.is_lit() { rdr.with_str_from(bstart, |s| { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index babe0eef20f8c..99d05f4e49558 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -561,8 +561,8 @@ impl<'a> StringReader<'a> { .warn("this was previously accepted by the compiler but is \ being phased out; it will become a hard error in \ a future release!") - .note("for more information, see issue #42326 \ - ") + .note("for more information, see \ + ") .emit(); None } else { @@ -652,7 +652,7 @@ impl<'a> StringReader<'a> { let loc = smap.lookup_char_pos_adj(self.pos); debug!("Skipping a shebang"); if loc.line == 1 && loc.col == CharPos(0) { - // FIXME: Add shebang "token", return it + // FIXME: add shebang "token", return it let start = self.pos; while !self.ch_is('\n') && !self.is_eof() { self.bump(); @@ -1703,7 +1703,7 @@ impl<'a> StringReader<'a> { true, '\''); if !self.ch_is('\'') { - // Byte offsetting here is okay because the + // Byte offsetting here is ok because the // character before position `start` are an // ascii single quote and ascii 'b'. let pos = self.pos; @@ -1939,7 +1939,7 @@ mod tests { assert_eq!(tok1.tok, tok2.tok); assert_eq!(tok1.sp, tok2.sp); assert_eq!(string_reader.next_token().tok, token::Whitespace); - // the 'main' id is already read: + // the 'main' ID is already read: assert_eq!(string_reader.pos.clone(), BytePos(28)); // read another token: let tok3 = string_reader.next_token(); diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs index 7da4284c0e4aa..2f9b958da553d 100644 --- a/src/libsyntax/parse/lexer/unicode_chars.rs +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -1,5 +1,5 @@ -// Characters and their corresponding confusables were collected from -// http://www.unicode.org/Public/security/10.0.0/confusables.txt +// Characters and their corresponding confusables were collected from. +// See for more details. use syntax_pos::{Span, NO_EXPANSION}; use errors::{Applicability, DiagnosticBuilder}; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index b2d4d97d57d89..270240a9b375d 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -1,36 +1,34 @@ //! The main parser interface. -use crate::ast::{self, CrateConfig, NodeId}; -use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; -use crate::source_map::{SourceMap, FilePathMapping}; -use crate::feature_gate::UnstableFeatures; -use crate::parse::parser::Parser; -use crate::symbol::Symbol; -use crate::tokenstream::{TokenStream, TokenTree}; -use crate::diagnostics::plugin::ErrorMap; -use crate::print::pprust::token_to_string; - -use errors::{FatalError, Level, Handler, ColorConfig, Diagnostic, DiagnosticBuilder}; -use rustc_data_structures::sync::{Lrc, Lock}; -use syntax_pos::{Span, SourceFile, FileName, MultiSpan}; -use log::debug; +pub mod attr; +pub mod classify; +pub mod lexer; +#[macro_use] +pub mod parser; +pub mod token; -use rustc_data_structures::fx::FxHashSet; use std::borrow::Cow; use std::iter; use std::path::{Path, PathBuf}; use std::str; -pub type PResult<'a, T> = Result>; - -#[macro_use] -pub mod parser; +use errors::{FatalError, Level, Handler, ColorConfig, Diagnostic, DiagnosticBuilder}; +use log::debug; +use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::sync::{Lrc, Lock}; +use syntax_pos::{Span, SourceFile, FileName, MultiSpan}; -pub mod lexer; -pub mod token; -pub mod attr; +use crate::ast::{self, CrateConfig, NodeId}; +use crate::diagnostics::plugin::ErrorMap; +use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; +use crate::feature_gate::UnstableFeatures; +use crate::parse::parser::Parser; +use crate::print::pprust::token_to_string; +use crate::source_map::{SourceMap, FilePathMapping}; +use crate::symbol::Symbol; +use crate::tokenstream::{TokenStream, TokenTree}; -pub mod classify; +pub type PResult<'a, T> = Result>; /// Info about a parsing session. pub struct ParseSess { @@ -103,17 +101,17 @@ pub struct Directory<'a> { #[derive(Copy, Clone)] pub enum DirectoryOwnership { Owned { - // None if `mod.rs`, `Some("foo")` if we're in `foo.rs` + // None if `mod.rs`, `Some("foo")` if we're in `foo.rs`. relative: Option, }, UnownedViaBlock, UnownedViaMod(bool /* legacy warnings? */), } -// a bunch of utility functions of the form parse__from_ -// where includes crate, expr, item, stmt, tts, and one that -// uses a HOF to parse anything, and includes file and -// source_str. +// A bunch of utility functions of the form `parse__from_` +// where `` includes `crate`, `expr`, `item`, `stmt`, `tts`, and one that +// uses a HOF to parse anything, and `` includes `file` and +// `source_str`. pub fn parse_crate_from_file<'a>(input: &Path, sess: &'a ParseSess) -> PResult<'a, ast::Crate> { let mut parser = new_parser_from_file(sess, input); @@ -274,7 +272,7 @@ pub fn maybe_file_to_stream( Err(err) => { let mut buffer = Vec::with_capacity(1); err.buffer(&mut buffer); - // Not using `emit_unclosed_delims` to use `db.buffer` + // Not using `emit_unclosed_delims` to use `db.buffer`. for unmatched in srdr.unmatched_braces { let mut db = sess.span_diagnostic.struct_span_err(unmatched.found_span, &format!( "incorrect close delimiter: `{}`", @@ -398,9 +396,10 @@ pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String { } eat(&mut chars); } else { - // otherwise, a normal escape + // Otherwise, a normal escape. let (c, n) = char_lit(&lit[i..], diag); - for _ in 0..n - 1 { // we don't need to move past the first \ + // We don't need to move past the first `\`. + for _ in 0..n - 1 { chars.next(); } res.push(c); @@ -421,7 +420,8 @@ pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String { } } - res.shrink_to_fit(); // probably not going to do anything, unless there was an escape. + // Probably not going to do anything, unless there was an escape. + res.shrink_to_fit(); debug!("parse_str_lit: returning {}", res); res } @@ -449,7 +449,7 @@ fn raw_str_lit(lit: &str) -> String { res } -// check if `s` looks like i32 or u1234 etc. +// Checks if `s` looks like `i32`, `u1234`, etc. fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool { s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit()) } @@ -478,10 +478,10 @@ crate fn lit_token(lit: token::Lit, suf: Option, diag: Option<(Span, &Ha token::Float(s) => (false, float_lit(&s.as_str(), suf, diag)), token::Str_(mut sym) => { - // If there are no characters requiring special treatment we can - // reuse the symbol from the Token. Otherwise, we must generate a - // new symbol because the string in the LitKind is different to the - // string in the Token. + // If there are no characters requiring special treatment, we can + // reuse the symbol from the `Token`. Otherwise, we must generate a + // new symbol because the string in the `LitKind` is different to the + // string in the `Token`. let s = &sym.as_str(); if s.as_bytes().iter().any(|&c| c == b'\\' || c == b'\r') { sym = Symbol::intern(&str_lit(s, diag)); @@ -489,7 +489,7 @@ crate fn lit_token(lit: token::Lit, suf: Option, diag: Option<(Span, &Ha (true, Some(LitKind::Str(sym, ast::StrStyle::Cooked))) } token::StrRaw(mut sym, n) => { - // Ditto. + // Same as above. let s = &sym.as_str(); if s.contains('\r') { sym = Symbol::intern(&raw_str_lit(s)); @@ -519,7 +519,7 @@ fn filtered_float_lit(data: Symbol, suffix: Option, diag: Option<(Span, suf => { err!(diag, |span, diag| { if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) { - // if it looks like a width, lets try to be helpful. + // If it looks like a width, lets try to be helpful. let msg = format!("invalid width `{}` for float literal", &suf[1..]); diag.struct_span_err(span, &msg).help("valid widths are 32 and 64").emit() } else { @@ -535,12 +535,13 @@ fn filtered_float_lit(data: Symbol, suffix: Option, diag: Option<(Span, } }) } + fn float_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) -> Option { debug!("float_lit: {:?}, {:?}", s, suffix); - // FIXME #2252: bounds checking float literals is deferred until trans + // FIXME(#2252): bounds checking float literals is deferred until trans step. - // Strip underscores without allocating a new String unless necessary. + // Strip underscores without allocating a new `String` unless necessary. let s2; let s = if s.chars().any(|c| c == '_') { s2 = s.chars().filter(|&c| c != '_').collect::(); @@ -601,7 +602,7 @@ fn byte_str_lit(lit: &str) -> Lrc> { } } - // byte string literals *must* be ASCII, but the escapes don't have to be + // Byte string literals *must* be ASCII, but the escapes don't have to be. let mut chars = lit.bytes().enumerate().peekable(); loop { match chars.next() { @@ -616,9 +617,9 @@ fn byte_str_lit(lit: &str) -> Lrc> { eat(&mut chars); } _ => { - // otherwise, a normal escape + // Otherwise, a normal escape. let (c, n) = byte_lit(&lit[i..]); - // we don't need to move past the first \ + // We don't need to move past the first `\`. for _ in 0..n - 1 { chars.next(); } @@ -643,9 +644,9 @@ fn byte_str_lit(lit: &str) -> Lrc> { fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) -> Option { - // s can only be ascii, byte indexing is fine + // `s` can only be ASCII; byte indexing is fine. - // Strip underscores without allocating a new String unless necessary. + // Strip underscores without allocating a new `String` unless necessary. let s2; let mut s = if s.chars().any(|c| c == '_') { s2 = s.chars().filter(|&c| c != '_').collect::(); @@ -669,7 +670,7 @@ fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) } } - // 1f64 and 2f32 etc. are valid float literals. + // `1f64`, `2f32`, etc. are valid float literals. if let Some(suf) = suffix { if looks_like_width_suffix(&['f'], &suf.as_str()) { let err = match base { @@ -695,7 +696,7 @@ fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) if let Some(suf) = suffix { if suf.as_str().is_empty() { - err!(diag, |span, diag| diag.span_bug(span, "found empty literal suffix in Some")); + err!(diag, |span, diag| diag.span_bug(span, "found empty literal suffix in `Some`")); } ty = match &*suf.as_str() { "isize" => ast::LitIntType::Signed(ast::IntTy::Isize), @@ -711,8 +712,8 @@ fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) "u64" => ast::LitIntType::Unsigned(ast::UintTy::U64), "u128" => ast::LitIntType::Unsigned(ast::UintTy::U128), suf => { - // i and u look like widths, so lets - // give an error message along those lines + // `i` and `u` look like widths, so lets + // give an error message along those lines. err!(diag, |span, diag| { if looks_like_width_suffix(&['i', 'u'], suf) { let msg = format!("invalid width `{}` for integer literal", &suf[1..]); @@ -735,12 +736,12 @@ fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) } debug!("integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \ - string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix); + string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix); Some(match u128::from_str_radix(s, base) { Ok(r) => ast::LitKind::Int(r, ty), Err(_) => { - // small bases are lexed as if they were base 10, e.g, the string + // Small bases are lexed as if they were base 10, e.g, the string // might be `0b10201`. This will cause the conversion above to fail, // but these cases have errors in the lexer: we don't want to emit // two errors, and we especially don't want to emit this error since @@ -802,7 +803,7 @@ mod tests { new_parser_from_source_str(sess, name, source).parse_item() } - // produce a syntax_pos::span + // Produces a `syntax_pos::span`. fn sp(a: u32, b: u32) -> Span { Span::new(BytePos(a), BytePos(b), NO_EXPANSION) } @@ -814,7 +815,7 @@ mod tests { }) } - // check the token-tree-ization of macros + // Checks the token-tree-ization of macros. #[test] fn string_to_tts_macro () { with_globals(|| { @@ -977,7 +978,7 @@ mod tests { #[test] fn parse_exprs () { with_globals(|| { - // just make sure that they parse.... + // Just make sure that they parse. string_to_expr("3 + 4".to_string()); string_to_expr("a::z.froob(b,&(987+3))".to_string()); }) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e22047938e518..c89e0ca516257 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,3 +1,14 @@ +use std::borrow::Cow; +use std::cmp; +use std::mem; +use std::path::{self, Path, PathBuf}; +use std::slice; + +use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use log::{debug, trace}; +use rustc_target::spec::abi::{self, Abi}; +use syntax_pos::{self, Span, MultiSpan, BytePos, FileName}; + use crate::ast::{AngleBracketedArgs, ParenthesizedArgs, AttrStyle, BareFnTy}; use crate::ast::{GenericBound, TraitBoundModifier}; use crate::ast::Unsafety; @@ -46,17 +57,6 @@ use crate::ThinVec; use crate::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint}; use crate::symbol::{Symbol, keywords}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; -use rustc_target::spec::abi::{self, Abi}; -use syntax_pos::{Span, MultiSpan, BytePos, FileName}; -use log::{debug, trace}; - -use std::borrow::Cow; -use std::cmp; -use std::mem; -use std::path::{self, Path, PathBuf}; -use std::slice; - #[derive(Debug)] /// Whether the type alias or associated type is a concrete type or an existential type pub enum AliasKind { @@ -217,26 +217,26 @@ impl RecoverQPath for Expr { } } -/* ident is handled by common.rs */ +// Ident is handled by `common.rs`. #[derive(Clone)] pub struct Parser<'a> { pub sess: &'a ParseSess, - /// the current token: + /// The current token. pub token: token::Token, - /// the span of the current token: + /// The span of the current token. pub span: Span, - /// the span of the previous token: + /// The span of the previous token. meta_var_span: Option, pub prev_span: Span, - /// the previous token kind + /// The previous token kind. prev_token_kind: PrevTokenKind, restrictions: Restrictions, - /// Used to determine the path to externally loaded source files + /// Used to determine the path to externally loaded source files. crate directory: Directory<'a>, /// Whether to parse sub-modules in other files. pub recurse_into_file_modules: bool, - /// Name of the root module this parser originated from. If `None`, then the + /// The name of the root module this parser originated from. If `None`, then the /// name is not known. This does not change while the parser is descending /// into modules, and sub-parsers have new values for this name. pub root_module_name: Option, @@ -461,8 +461,8 @@ pub enum Error { impl Error { fn span_err>(self, - sp: S, - handler: &errors::Handler) -> DiagnosticBuilder<'_> { + sp: S, + handler: &errors::Handler) -> DiagnosticBuilder<'_> { match self { Error::FileNotFoundForModule { ref mod_name, ref default_path, @@ -650,7 +650,7 @@ impl<'a> Parser<'a> { } /// Expects and consumes the token `t`. Signals an error if the next token is not `t`. - pub fn expect(&mut self, t: &token::Token) -> PResult<'a, bool /* recovered */> { + pub fn expect(&mut self, t: &token::Token) -> PResult<'a, bool /* recovered */> { if self.expected_tokens.is_empty() { if self.token == *t { self.bump(); @@ -663,7 +663,7 @@ impl<'a> Parser<'a> { this_token_str)); let sp = if self.token == token::Token::Eof { - // EOF, don't want to point at the following char, but rather the last token + // EOF; don't want to point at the following char, but rather the last token. self.prev_span } else { self.sess.source_map().next_point(self.prev_span) @@ -700,7 +700,7 @@ impl<'a> Parser<'a> { mut err: DiagnosticBuilder<'a>, ) -> PResult<'a, bool> { let mut pos = None; - // we want to use the last closing delim that would apply + // We want to use the last closing delim that would apply. for (i, unmatched) in self.unclosed_delims.iter().enumerate().rev() { if tokens.contains(&token::CloseDelim(unmatched.expected_delim)) && Some(self.span) > unmatched.unclosed_span @@ -718,8 +718,8 @@ impl<'a> Parser<'a> { let unmatched = self.unclosed_delims.remove(pos); let delim = TokenType::Token(token::CloseDelim(unmatched.expected_delim)); - // We want to suggest the inclusion of the closing delimiter where it makes - // the most sense, which is immediately after the last token: + // We want to suggest the inclusion of the closing delimiter where it makes + // the most sense, which is immediately after the last token. // // {foo(bar {}} // - ^ @@ -737,16 +737,17 @@ impl<'a> Parser<'a> { Applicability::MaybeIncorrect, ); err.emit(); - self.expected_tokens.clear(); // reduce errors + // Reduce errors. + self.expected_tokens.clear(); Ok(true) } _ => Err(err), } } - /// Expect next token to be edible or inedible token. If edible, - /// then consume it; if inedible, then return without consuming - /// anything. Signal a fatal error if next token is unexpected. + /// Expects the next token to be an edible or an inedible token; if edible, + /// then consumes it; if inedible, then returns without consuming anything. + /// Signals a fatal error if next token is unexpected. pub fn expect_one_of( &mut self, edible: &[token::Token], @@ -754,7 +755,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, bool /* recovered */> { fn tokens_to_string(tokens: &[TokenType]) -> String { let mut i = tokens.iter(); - // This might be a sign we need a connect method on Iterator. + // This might be a sign we need a connect method on `Iterator`. let b = i.next() .map_or(String::new(), |t| t.to_string()); i.enumerate().fold(b, |mut b, (i, a)| { @@ -773,7 +774,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(false) } else if inedible.contains(&self.token) { - // leave it in the input + // Leave it in the input. Ok(false) } else { let mut expected = edible.iter() @@ -820,7 +821,8 @@ impl<'a> Parser<'a> { ); } let sp = if self.token == token::Token::Eof { - // This is EOF, don't want to point at the following char, but rather the last token + // This is EOF; don't want to point at the following char, but rather the + // last token. self.prev_span } else { label_sp @@ -1214,7 +1216,7 @@ impl<'a> Parser<'a> { sep: SeqSep, f: F) -> PResult<'a, Vec> where - F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, + F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, { let (val, recovered) = self.parse_seq_to_before_end(ket, sep, f)?; if !recovered { @@ -1270,14 +1272,14 @@ impl<'a> Parser<'a> { break; } Err(mut e) => { - // Attempt to keep parsing if it was a similar separator + // Attempt to keep parsing if it was a similar separator. if let Some(ref tokens) = t.similar_tokens() { if tokens.contains(&self.token) { self.bump(); } } e.emit(); - // Attempt to keep parsing if it was an omitted separator + // Attempt to keep parsing if it was an omitted separator. match f(self) { Ok(t) => { v.push(t); @@ -1328,10 +1330,10 @@ impl<'a> Parser<'a> { Ok(result) } - /// Advance the parser by one token + /// Advances the parser by a single token. pub fn bump(&mut self) { if self.prev_token_kind == PrevTokenKind::Eof { - // Bumping after EOF is a bad sign, usually an infinite loop. + // Bumping after EOF is a bad sign; usually an infinite loop. self.bug("attempted to bump the parser past EOF (may be stuck in a loop)"); } @@ -1352,17 +1354,17 @@ impl<'a> Parser<'a> { self.span = next.sp; self.token = next.tok; self.expected_tokens.clear(); - // check after each token + // Check after each token. self.process_potential_macro_variable(); } - /// Advance the parser using provided token as a next one. Use this when - /// consuming a part of a token. For example a single `<` from `<<`. + /// Advances the parser using provided token as a next one. Use this when + /// consuming a part of a token. E.g., a single `<` from `<<`. fn bump_with(&mut self, next: token::Token, span: Span) { self.prev_span = self.span.with_hi(span.lo()); // It would be incorrect to record the kind of the current token, but // fortunately for tokens currently using `bump_with`, the - // prev_token_kind will be of no use anyway. + // `prev_token_kind` will be of no use anyway. self.prev_token_kind = PrevTokenKind::Other; self.span = span; self.token = next; @@ -1527,7 +1529,7 @@ impl<'a> Parser<'a> { }; (ident, TraitItemKind::Const(ty, default), ast::Generics::default()) } else if let Some(mac) = self.parse_assoc_macro_invoc("trait", None, &mut false)? { - // trait item macro. + // Trait item macro (keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac), ast::Generics::default()) } else { let (constness, unsafety, asyncness, abi) = self.parse_fn_front_matter()?; @@ -1536,11 +1538,10 @@ impl<'a> Parser<'a> { let mut generics = self.parse_generics()?; let d = self.parse_fn_decl_with_self(|p: &mut Parser<'a>| { - // This is somewhat dubious; We don't want to allow - // argument names to be left off if there is a - // definition... + // This is somewhat dubious; we don't want to allow + // argument names to be left off if there is a definition. - // We don't allow argument names to be left off in edition 2018. + // We don't allow argument names to be left off in the 2018 edition. p.parse_arg_general(p.span.rust_2018(), true) })?; generics.where_clause = self.parse_where_clause()?; @@ -1659,7 +1660,7 @@ impl<'a> Parser<'a> { let ty = ts.into_iter().nth(0).unwrap().into_inner(); let maybe_bounds = allow_plus && self.token.is_like_plus(); match ty.node { - // `(TY_BOUND_NOPAREN) + BOUND + ...`. + // `(TY_BOUND_NOPAREN) + BOUND + ...` TyKind::Path(None, ref path) if maybe_bounds => { self.parse_remaining_bounds(Vec::new(), path.clone(), lo, true)? } @@ -1678,15 +1679,15 @@ impl<'a> Parser<'a> { TyKind::Tup(ts) } } else if self.eat(&token::Not) { - // Never type `!` + // Never type (i.e., `!`). TyKind::Never } else if self.eat(&token::BinOp(token::Star)) { // Raw pointer TyKind::Ptr(self.parse_ptr()?) } else if self.eat(&token::OpenDelim(token::Bracket)) { - // Array or slice + // Array or slice. let t = self.parse_ty()?; - // Parse optional `; EXPR` in `[TYPE; EXPR]` + // Parse optional `; EXPR` in `[TYPE; EXPR]`. let t = match self.maybe_parse_fixed_length_of_vec()? { None => TyKind::Slice(t), Some(length) => TyKind::Array(t, AnonConst { @@ -1697,7 +1698,7 @@ impl<'a> Parser<'a> { self.expect(&token::CloseDelim(token::Bracket))?; t } else if self.check(&token::BinOp(token::And)) || self.check(&token::AndAnd) { - // Reference + // Reference. self.expect_and()?; self.parse_borrowed_pointee()? } else if self.eat_keyword_noexpect(keywords::Typeof) { @@ -1711,15 +1712,16 @@ impl<'a> Parser<'a> { self.expect(&token::CloseDelim(token::Paren))?; TyKind::Typeof(e) } else if self.eat_keyword(keywords::Underscore) { - // A type to be inferred `_` + // A type to be inferred `_`. TyKind::Infer } else if self.token_is_bare_fn_keyword() { - // Function pointer type + // Function pointer type. self.parse_ty_bare_fn(Vec::new())? } else if self.check_keyword(keywords::For) { // Function pointer type or bound list (trait object type) starting with a poly-trait. - // `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T` - // `for<'lt> Trait1<'lt> + Trait2 + 'a` + // + // `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T` + // `for<'lt> Trait1<'lt> + Trait2 + 'a` let lo = self.span; let lifetime_defs = self.parse_late_bound_lifetime_defs()?; if self.token_is_bare_fn_keyword() { @@ -1738,7 +1740,8 @@ impl<'a> Parser<'a> { (self.span.rust_2018() || self.look_ahead(1, |t| t.can_begin_bound() && !can_continue_type_after_non_fn_ident(t))) { - self.bump(); // `dyn` + // `dyn` + self.bump(); // Always parse bounds greedily for better error recovery. let bounds = self.parse_generic_bounds()?; impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus; @@ -1791,7 +1794,8 @@ impl<'a> Parser<'a> { let poly_trait_ref = PolyTraitRef::new(generic_params, path, lo.to(self.prev_span)); let mut bounds = vec![GenericBound::Trait(poly_trait_ref, TraitBoundModifier::None)]; if parse_plus { - self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded + // `+`, or `+=` gets split and `+` is discarded. + self.eat_plus(); bounds.append(&mut self.parse_generic_bounds()?); } Ok(TyKind::TraitObject(bounds, TraitObjectSyntax::None)) @@ -1854,7 +1858,7 @@ impl<'a> Parser<'a> { Ok(()) } - // Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`. + // Try to recover from associated item paths like `[T]::AssocItem` / `(T, U)::AssocItem`. fn maybe_recover_from_bad_qpath(&mut self, base: T, allow_recovery: bool) -> PResult<'a, T> { // Do not add `::` to expected tokens. @@ -1866,12 +1870,14 @@ impl<'a> Parser<'a> { None => return Ok(base), }; - self.bump(); // `::` + // `::` + self.bump(); let mut segments = Vec::new(); self.parse_path_segments(&mut segments, T::PATH_STYLE, true)?; let span = ty.span.to(self.prev_span); - let path_span = span.to(span); // use an empty path since `position` == 0 + // Use an empty path, since `position == 0`. + let path_span = span.to(span); let recovered = base.to_recovered( Some(QSelf { ty, path_span, position: 0 }), ast::Path { segments, span }, @@ -1879,7 +1885,8 @@ impl<'a> Parser<'a> { self.diagnostic() .struct_span_err(span, "missing angle brackets in associated item path") - .span_suggestion( // this is a best-effort recovery + // This is a best-effort recovery. + .span_suggestion( span, "try", recovered.to_string(), Applicability::MaybeIncorrect ).emit(); @@ -2120,7 +2127,9 @@ impl<'a> Parser<'a> { token::Dot if self.look_ahead(1, |t| match t { token::Literal(parse::token::Lit::Integer(_) , _) => true, _ => false, - }) => { // recover from `let x = .4;` + }) => { + // Recover from `let x = .4;`. + let lo = self.span; self.bump(); if let token::Literal( @@ -2367,7 +2376,7 @@ impl<'a> Parser<'a> { Ok(if style == PathStyle::Type && check_args_start(self) || style != PathStyle::Mod && self.check(&token::ModSep) && self.look_ahead(1, |t| is_args_start(t)) { - // Generic arguments are found - `<`, `(`, `::<` or `::(`. + // Generic arguments are found: `<`, `(`, `::<` or `::(`. if self.eat(&token::ModSep) && style == PathStyle::Type && enable_warning { self.diagnostic().struct_span_warn(self.prev_span, "unnecessary path disambiguator") .span_label(self.prev_span, "try removing `::`").emit(); @@ -2460,12 +2469,12 @@ impl<'a> Parser<'a> { } } - /// Parse ident (COLON expr)? + /// Parses `ident (COLON expr)?`. fn parse_field(&mut self) -> PResult<'a, Field> { let attrs = self.parse_outer_attributes()?; let lo = self.span; - // Check if a colon exists one ahead. This means we're parsing a fieldname. + // Check if a colon exists one ahead. This means we're parsing a field name. let (fieldname, expr, is_shorthand) = if self.look_ahead(1, |t| { t == &token::Colon || t == &token::Eq }) { @@ -2599,8 +2608,8 @@ impl<'a> Parser<'a> { attrs.extend(self.parse_inner_attributes()?); - // (e) is parenthesized e - // (e,) is a tuple with only one field, e + // `(e)` is parenthesized `e`. + // `(e,)` is a tuple with only one field, `e`. let mut es = vec![]; let mut trailing_comma = false; let mut recovered = false; @@ -2646,7 +2655,7 @@ impl<'a> Parser<'a> { // Nonempty vector. let first_expr = self.parse_expr()?; if self.eat(&token::Semi) { - // Repeating array syntax: [ 0; 512 ] + // Repeating array syntax: `[ 0; 512 ]` let count = AnonConst { id: ast::DUMMY_NODE_ID, value: self.parse_expr()?, @@ -2679,7 +2688,8 @@ impl<'a> Parser<'a> { } if self.span.rust_2018() && self.check_keyword(keywords::Async) { - if self.is_async_block() { // check for `async {` and `async move {` + // Check for `async {` and `async move {`. + if self.is_async_block() { return self.parse_async_block(attrs); } else { return self.parse_lambda_expr(attrs); @@ -2821,13 +2831,12 @@ impl<'a> Parser<'a> { // recovery in order to keep the error count down. Fixing the // delimiters will possibly also fix the bare semicolon found in // expression context. For example, silence the following error: - // ``` - // error: expected expression, found `;` - // --> file.rs:2:13 - // | - // 2 | foo(bar(; - // | ^ expected expression - // ``` + // + // error: expected expression, found `;` + // --> file.rs:2:13 + // | + // 2 | foo(bar(; + // | ^ expected expression self.bump(); return Ok(self.mk_expr(self.span, ExprKind::Err, ThinVec::new())); } @@ -2993,7 +3002,7 @@ impl<'a> Parser<'a> { -> PResult<'a, P> { // Stitch the list of outer attributes onto the return value. // A little bit ugly, but the best way given the current code - // structure + // structure. self.parse_dot_or_call_expr_with_(e0, lo) .map(|expr| expr.map(|mut expr| { @@ -3002,7 +3011,7 @@ impl<'a> Parser<'a> { match expr.node { ExprKind::If(..) | ExprKind::IfLet(..) => { if !expr.attrs.is_empty() { - // Just point to the first attribute in there... + // Just point to the first attribute in there. let span = expr.attrs[0].span; self.span_err(span, @@ -3024,7 +3033,7 @@ impl<'a> Parser<'a> { Ok(match self.token { token::OpenDelim(token::Paren) => { - // Method call `expr.f()` + // Method call (i.e., `expr.f()`) let mut args = self.parse_unspanned_seq( &token::OpenDelim(token::Paren), &token::CloseDelim(token::Paren), @@ -3037,7 +3046,7 @@ impl<'a> Parser<'a> { self.mk_expr(span, ExprKind::MethodCall(segment, args), ThinVec::new()) } _ => { - // Field access `expr.f` + // Field access (i.e., `expr.f`). if let Some(args) = segment.args { self.span_err(args.span(), "field expressions may not have generic arguments"); @@ -3061,10 +3070,10 @@ impl<'a> Parser<'a> { // cases: // // 1. A specific token is expected after the path segment. - // eg. `x.foo(`, `x.foo::(` (parenthesis - method call), - // `Foo::`, or `Foo::::` (mod sep - continued path). + // E.g., `x.foo(`, `x.foo::(` (parenthesis - method call), + // `Foo::`, or `Foo::::` (mod sep - continued path). // 2. No specific token is expected after the path segment. - // eg. `x.foo` (field access) + // E.., `x.foo` (field access). // // This function is called after parsing `.foo` and before parsing the token `end` (if // present). This includes any angle bracket arguments, such as `.foo::` or @@ -3076,7 +3085,7 @@ impl<'a> Parser<'a> { // // `x.foo >> (3)` (where `x.foo` is a `u32` for example) // - // This case is particularly tricky as we won't notice it just looking at the tokens - + // This case is particularly tricky, as we won't notice it just looking at the tokens - // it will appear the same (in terms of upcoming tokens) as below (since the `::` will // have already been parsed): // @@ -3163,13 +3172,13 @@ impl<'a> Parser<'a> { let mut e = e0; let mut hi; loop { - // expr? + // `expr?` while self.eat(&token::Question) { let hi = self.prev_span; e = self.mk_expr(lo.to(hi), ExprKind::Try(e), ThinVec::new()); } - // expr.f + // `expr.f` if self.eat(&token::Dot) { match self.token { token::Ident(..) => { @@ -3213,7 +3222,7 @@ impl<'a> Parser<'a> { } _ => { - // FIXME Could factor this out into non_fatal_unexpected or something. + // FIXME: could factor this out into `non_fatal_unexpected` or something. let actual = self.this_token_to_string(); self.span_err(self.span, &format!("unexpected token: `{}`", actual)); } @@ -3222,7 +3231,7 @@ impl<'a> Parser<'a> { } if self.expr_is_complete(&e) { break; } match self.token { - // expr(...) + // `expr(...)` token::OpenDelim(token::Paren) => { let es = self.parse_unspanned_seq( &token::OpenDelim(token::Paren), @@ -3236,7 +3245,7 @@ impl<'a> Parser<'a> { e = self.mk_expr(lo.to(hi), nd, ThinVec::new()); } - // expr[...] + // `expr[...]` // Could be either an index expression or a slicing expression. token::OpenDelim(token::Bracket) => { self.bump(); @@ -3306,8 +3315,7 @@ impl<'a> Parser<'a> { } } - // parse a stream of tokens into a list of TokenTree's, - // up to EOF. + /// Parses a stream of tokens into a list of `TokenTree`s, up to EOF. pub fn parse_all_token_trees(&mut self) -> PResult<'a, Vec> { let mut tts = Vec::new(); while self.token != token::Eof { @@ -3327,13 +3335,13 @@ impl<'a> Parser<'a> { TokenStream::new(result) } - /// Parse a prefix-unary-operator expr + /// Parses a prefix-unary-operator expr. fn parse_prefix_expr(&mut self, already_parsed_attrs: Option>) -> PResult<'a, P> { let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?; let lo = self.span; - // Note: when adding new unary operators, don't forget to adjust Token::can_begin_expr() + // Note: when adding new unary operators, don't forget to adjust `Token::can_begin_expr()`. let (hi, ex) = match self.token { token::Not => { self.bump(); @@ -3341,7 +3349,7 @@ impl<'a> Parser<'a> { let (span, e) = self.interpolated_or_expr_span(e)?; (lo.to(span), self.mk_unary(UnOp::Not, e)) } - // Suggest `!` for bitwise negation when encountering a `~` + // Suggest `!` for bitwise negation when encountering a `~`. token::Tilde => { self.bump(); let e = self.parse_prefix_expr(None); @@ -3413,13 +3421,13 @@ impl<'a> Parser<'a> { let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr); if cannot_continue_expr { self.bump(); - // Emit the error ... + // Emit the error. let mut err = self.diagnostic() .struct_span_err(self.span, &format!("unexpected {} after identifier", self.this_token_descr())); - // span the `not` plus trailing whitespace to avoid - // trailing whitespace after the `!` in our suggestion + // Span the `not` plus trailing whitespace to avoid + // trailing whitespace after the `!` in our suggestion ... let to_replace = self.sess.source_map() .span_until_non_whitespace(lo.to(self.span)); err.span_suggestion_short( @@ -3429,8 +3437,8 @@ impl<'a> Parser<'a> { Applicability::MachineApplicable ); err.emit(); - // —and recover! (just as if we were in the block - // for the `token::Not` arm) + // ... and recover! (just as if we were in the block + // for the `token::Not` arm). let e = self.parse_prefix_expr(None); let (span, e) = self.interpolated_or_expr_span(e)?; (lo.to(span), self.mk_unary(UnOp::Not, e)) @@ -3474,7 +3482,7 @@ impl<'a> Parser<'a> { }; if self.expr_is_complete(&lhs) { - // Semi-statement forms are odd. See https://github.com/rust-lang/rust/issues/29071 + // Semi-statement forms are odd (see issue #29071). return Ok(lhs); } self.expected_tokens.push(TokenType::Operator); @@ -3701,7 +3709,7 @@ impl<'a> Parser<'a> { Ok(expr) } Err(mut path_err) => { - // Couldn't parse as a path, return original error and parser state. + // Couldn't parse as a path; return original error and parser state. path_err.cancel(); mem::replace(self, parser_snapshot_after_type); Err(type_err) @@ -3711,23 +3719,26 @@ impl<'a> Parser<'a> { } } - /// Produce an error if comparison operators are chained (RFC #558). + /// Produces an error if comparison operators are chained (RFC #558). /// We only need to check lhs, not rhs, because all comparison ops - /// have same precedence and are left-associative + /// have same precedence and are left-associative. fn check_no_chained_comparison(&mut self, lhs: &Expr, outer_op: &AssocOp) { debug_assert!(outer_op.is_comparison(), "check_no_chained_comparison: {:?} is not comparison", outer_op); match lhs.node { ExprKind::Binary(op, _, _) if op.node.is_comparison() => { - // respan to include both operators + // Respan to include both operators. let op_span = op.span.to(self.span); let mut err = self.diagnostic().struct_span_err(op_span, "chained comparison operators require parentheses"); + // Include `<` to provide this recommendation + // even in a case like the following: + // `Foo>>` if op.node == BinOpKind::Lt && - *outer_op == AssocOp::Less || // Include `<` to provide this recommendation - *outer_op == AssocOp::Greater // even in a case like the following: - { // Foo>> + *outer_op == AssocOp::Less || + *outer_op == AssocOp::Greater + { err.help( "use `::<...>` instead of `<...>` if you meant to specify type arguments"); err.help("or use `(...)` if you meant to specify fn arguments"); @@ -3738,11 +3749,11 @@ impl<'a> Parser<'a> { } } - /// Parse prefix-forms of range notation: `..expr`, `..`, `..=expr` + /// Parses prefix-forms of range notation: `..expr`, `..`, `..=expr`. fn parse_prefix_range_expr(&mut self, already_parsed_attrs: Option>) -> PResult<'a, P> { - // Check for deprecated `...` syntax + // Check for deprecated `...` syntax. if self.token == token::DotDotDot { self.err_dotdotdot_syntax(self.span); } @@ -3779,7 +3790,7 @@ impl<'a> Parser<'a> { fn is_at_start_of_range_notation_rhs(&self) -> bool { if self.token.can_begin_expr() { - // parse `for i in 1.. { }` as infinite loop, not as `for i in (1..{})`. + // Parses `for i in 1.. { }` as infinite loop, not as `for i in (1..{})`. if self.token == token::OpenDelim(token::Brace) { return !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL); } @@ -3872,8 +3883,7 @@ impl<'a> Parser<'a> { self.parse_expr_res(restrictions, None)? }, _ => { - // If an explicit return type is given, require a - // block to appear (RFC 968). + // If an explicit return type is given, require a block to appear (RFC 968). let body_lo = self.span; self.parse_block_expr(None, body_lo, BlockCheckMode::Default, ThinVec::new())? } @@ -3885,7 +3895,7 @@ impl<'a> Parser<'a> { attrs)) } - // `else` token already eaten + // `else` token already eaten. fn parse_else_expr(&mut self) -> PResult<'a, P> { if self.eat_keyword(keywords::If) { return self.parse_if_expr(ThinVec::new()); @@ -3895,11 +3905,11 @@ impl<'a> Parser<'a> { } } - /// Parse a 'for' .. 'in' expression ('for' token already eaten) + /// Parses a `for .. in` expression (`for` token already eaten). fn parse_for_expr(&mut self, opt_label: Option { fn flat_map_in_place(&mut self, mut f: F) where F: FnMut(T) -> I, - I: IntoIterator + I: IntoIterator { let mut read_i = 0; let mut write_i = 0; unsafe { let mut old_len = self.len(); - self.set_len(0); // make sure we just leak elements in case of panic + // Make sure we just leak elements in case of panic. + self.set_len(0); while read_i < old_len { - // move the read_i'th item out of the vector and map it - // to an iterator + // Move the `read_i'th item out of the vector and map it + // to an iterator. let e = ptr::read(self.get_unchecked(read_i)); let iter = f(e).into_iter(); read_i += 1; @@ -95,7 +97,7 @@ impl> MapInPlace for SmallVec { } } - // write_i tracks the number of actually written new items. + // `write_i` tracks the number of actually written new items. self.set_len(write_i); } } diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index 5f15ede7b0b6a..5e621989759f9 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -281,7 +281,7 @@ impl ExprPrecedence { ExprPrecedence::Yield => PREC_JUMP, // `Range` claims to have higher precedence than `Assign`, but `x .. x = x` fails to - // parse, instead of parsing as `(x .. x) = x`. Giving `Range` a lower precedence + // parse, instead of parsing as `(x .. x) = x`. Giving `Range` a lower precedence // ensures that `pprust` will add parentheses in the right places to get the desired // parse. ExprPrecedence::Range => PREC_RANGE, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index a002394c710fe..aae2a3a8babcd 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -102,13 +102,12 @@ pub trait Visitor<'ast>: Sized { fn visit_mac(&mut self, _mac: &'ast Mac) { panic!("visit_mac disabled by default"); // N.B., see note about macros above. - // if you really want a visitor that - // works on macros, use this + // If you really want a visitor that works on macros, use this // definition in your trait impl: - // visit::walk_mac(self, _mac) + // `visit::walk_mac(self, _mac)`. } fn visit_mac_def(&mut self, _mac: &'ast MacroDef, _id: NodeId) { - // Nothing to do + // Nothing to do. } fn visit_path(&mut self, path: &'ast Path, _id: NodeId) { walk_path(self, path) @@ -485,7 +484,7 @@ pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Generi walk_list!(visitor, visit_attribute, param.attrs.iter()); walk_list!(visitor, visit_param_bound, ¶m.bounds); match param.kind { - GenericParamKind::Lifetime => {} + GenericParamKind::Lifetime => (), GenericParamKind::Type { ref default } => walk_list!(visitor, visit_ty, default), GenericParamKind::Const { ref ty, .. } => visitor.visit_ty(ty), } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index b8f96c5bc0ea9..970378d0912e0 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -563,7 +563,7 @@ impl<'a> TraitDef<'a> { GenericParamKind::Const { .. } => param.clone(), })); - // and similarly for where clauses + // and similarly for where-clauses where_clause.predicates.extend(generics.where_clause.predicates.iter().map(|clause| { match *clause { ast::WherePredicate::BoundPredicate(ref wb) => { @@ -1266,7 +1266,7 @@ impl<'a> MethodDef<'a> { // we are in. // All of the Self args have the same variant in these - // cases. So we transpose the info in self_pats_idents + // cases. So we transpose the info in self_pats_idents // to gather the getter expressions together, in the // form that EnumMatching expects. @@ -1286,9 +1286,9 @@ impl<'a> MethodDef<'a> { fields[field_index]; // All Self args have same variant, so - // opt_idents are the same. (Assert + // opt_idents are the same. (Assert // here to make it self-evident that - // it is okay to ignore `_opt_ident`.) + // it is ok to ignore `_opt_ident`.) assert!(opt_ident == _opt_ident); other_getter_expr.clone() @@ -1345,7 +1345,7 @@ impl<'a> MethodDef<'a> { // We will usually need the catch-all after matching the // tuples `(VariantK, VariantK, ...)` for each VariantK of the - // enum. But: + // enum. But: // // * when there is only one Self arg, the arms above suffice // (and the deriving we call back into may not be prepared to @@ -1362,7 +1362,7 @@ impl<'a> MethodDef<'a> { // Build a series of let statements mapping each self_arg // to its discriminant value. If this is a C-style enum // with a specific repr type, then casts the values to - // that type. Otherwise casts to `i32` (the default repr + // that type. Otherwise casts to `i32` (the default repr // type). // // i.e., for `enum E { A, B(1), C(T, T) }`, and a deriving @@ -1454,7 +1454,7 @@ impl<'a> MethodDef<'a> { // least safely), according to the type system. // // The most expedient fix for this is to just let the - // code fall through to the catch-all. But even this is + // code fall through to the catch-all. But even this is // error-prone, since the catch-all as defined above would // generate code like this: // @@ -1466,13 +1466,13 @@ impl<'a> MethodDef<'a> { // inference cannot resolve to unique types. // // One option to the above might be to add explicit type - // annotations. But the *only* reason to go down that path + // annotations. But the *only* reason to go down that path // would be to try to make the expanded output consistent // with the case when the number of enum variants >= 1. // - // That just isn't worth it. In fact, trying to generate + // That just isn't worth it. In fact, trying to generate // sensible code for *any* deriving on a zero-variant enum - // does not make sense. But at the same time, for now, we + // does not make sense. But at the same time, for now, we // do not want to cause a compile failure just because the // user happened to attach a deriving to their // zero-variant enum. diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index ccff4aec2c8c7..30f688d941a2e 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -1,7 +1,6 @@ -// The compiler code necessary to support the env! extension. Eventually this +// The compiler code necessary to support the `env!` extension. Eventually this // should all get sucked into either the compiler syntax extension plugin // interface. -// use syntax::ast::{self, Ident, GenericArg}; use syntax::ext::base::{self, *}; diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 5efa6b36f675d..aaeee814f59bc 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -1,11 +1,10 @@ -use ArgumentType::*; -use Position::*; +use std::borrow::Cow; +use std::collections::hash_map::Entry; +use errors::{Applicability, DiagnosticBuilder}; use fmt_macros as parse; - -use errors::DiagnosticBuilder; -use errors::Applicability; - +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use syntax_pos::{MultiSpan, Span, DUMMY_SP}; use syntax::ast; use syntax::ext::base::{self, *}; use syntax::ext::build::AstBuilder; @@ -14,11 +13,9 @@ use syntax::parse::token; use syntax::ptr::P; use syntax::symbol::Symbol; use syntax::tokenstream; -use syntax_pos::{MultiSpan, Span, DUMMY_SP}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use std::borrow::Cow; -use std::collections::hash_map::Entry; +use ArgumentType::*; +use Position::*; #[derive(PartialEq)] enum ArgumentType { @@ -39,7 +36,7 @@ struct Context<'a, 'b: 'a> { /// The span of the format string literal. fmtsp: Span, - /// List of parsed argument expressions. + /// A list of parsed argument expressions. /// Named expressions are resolved early, and are appended to the end of /// argument expressions. /// @@ -52,21 +49,21 @@ struct Context<'a, 'b: 'a> { /// * `arg_unique_types` (in simplified JSON): `[["o", "x"], ["o", "x"], ["o", "x"]]` /// * `names` (in JSON): `{"foo": 2}` args: Vec>, - /// Placeholder slot numbers indexed by argument. + /// The placeholder slot numbers, indexed by argument. arg_types: Vec>, - /// Unique format specs seen for each argument. + /// The unique format specs seen for each argument. arg_unique_types: Vec>, - /// Map from named arguments to their resolved indices. + /// A map from named arguments to their resolved indices. names: FxHashMap, /// The latest consecutive literal strings, or empty if there weren't any. literal: String, - /// Collection of the compiled `rt::Argument` structures + /// The collection of the compiled `rt::Argument` structures. pieces: Vec>, - /// Collection of string literals + /// The collection of string literals. str_pieces: Vec>, - /// Stays `true` if all formatting parameters are default (as in "{}{}"). + /// Stays `true` if all formatting parameters are default (as in `{}{}`). all_pieces_simple: bool, /// Mapping between positional argument references and indices into the @@ -81,7 +78,7 @@ struct Context<'a, 'b: 'a> { /// * `arg_index_map` (in JSON): `[[0, 1, 0], [2, 3, 3], [4, 5]]` arg_index_map: Vec>, - /// Starting offset of count argument slots. + /// The starting offset of count argument slots. count_args_index_offset: usize, /// Count argument slots and tracking data structures. @@ -95,22 +92,22 @@ struct Context<'a, 'b: 'a> { /// * `count_positions` (in JSON): `{0: 0, 5: 1, 3: 2}` /// * `count_args`: `vec![Exact(0), Exact(5), Exact(3)]` count_args: Vec, - /// Relative slot numbers for count arguments. + /// The relative slot numbers for count arguments. count_positions: FxHashMap, - /// Number of count slots assigned. + /// The number of count slots assigned. count_positions_count: usize, - /// Current position of the implicit positional arg pointer, as if it + /// The current position of the implicit positional arg pointer, as if it /// still existed in this phase of processing. /// Used only for `all_pieces_simple` tracking in `build_piece`. curarg: usize, - /// Current piece being evaluated, used for error reporting. + /// The current piece being evaluated, used for error reporting. curpiece: usize, /// Keep track of invalid references to positional arguments. invalid_refs: Vec<(usize, usize)>, - /// Spans of all the formatting arguments, in order. + /// The spans of all the formatting arguments, in order. arg_spans: Vec, - /// Whether this formatting string is a literal or it comes from a macro. + /// `true` if this formatting string is a literal; `false` if it comes from a macro. is_literal: bool, } @@ -144,9 +141,11 @@ fn parse_args<'a>( if !p.eat(&token::Comma) { return Err(ecx.struct_span_err(p.span, "expected token: `,`")); } + // Accept trailing commas. if p.token == token::Eof { break; - } // accept trailing commas + } + if named || (p.token.is_ident() && p.look_ahead(1, |t| *t == token::Eq)) { named = true; let ident = if let token::Ident(i, _) = p.token { @@ -213,12 +212,12 @@ impl<'a, 'b> Context<'a, 'b> { match *p { parse::String(..) => {} parse::NextArgument(ref arg) => { - // width/precision first, if they have implicit positional - // parameters it makes more sense to consume them first. + // Width/precision first: if they have implicit positional + // parameters, it makes more sense to consume them first. self.verify_count(arg.format.width); self.verify_count(arg.format.precision); - // argument second, if it's an implicit positional parameter + // Argument second: if it's an implicit positional parameter, // it's written second, so it should come after width/precision. let pos = match arg.position { parse::ArgumentIs(i) | parse::ArgumentImplicitlyIs(i) => Exact(i), @@ -253,7 +252,7 @@ impl<'a, 'b> Context<'a, 'b> { } } - /// Handle invalid references to positional arguments. Output different + /// Handles invalid references to positional arguments. Outputs different /// errors for the case where all arguments are positional and for when /// there are named arguments or numbered positional arguments in the /// format string. @@ -314,8 +313,7 @@ impl<'a, 'b> Context<'a, 'b> { e.emit(); } - /// Actually verifies and tracks a given format placeholder - /// (a.k.a. argument). + /// Actually verifies and tracks a given format placeholder (i.e., argument). fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) { match arg { Exact(arg) => { @@ -325,7 +323,7 @@ impl<'a, 'b> Context<'a, 'b> { } match ty { Placeholder(_) => { - // record every (position, type) combination only once + // Record every `(position, type)` combination only once. let ref mut seen_ty = self.arg_unique_types[arg]; let i = seen_ty.iter().position(|x| *x == ty).unwrap_or_else(|| { let i = seen_ty.len(); @@ -368,13 +366,13 @@ impl<'a, 'b> Context<'a, 'b> { /// Builds the mapping between format placeholders and argument objects. fn build_index_map(&mut self) { - // NOTE: Keep the ordering the same as `into_expr`'s expansion would do! + // NOTE: keep the ordering the same as `into_expr`'s expansion would do! let args_len = self.args.len(); self.arg_index_map.reserve(args_len); let mut sofar = 0usize; - // Map the arguments + // Map the arguments. for i in 0..args_len { let ref arg_types = self.arg_types[i]; let arg_offsets = arg_types.iter().map(|offset| sofar + *offset).collect::>(); @@ -382,7 +380,7 @@ impl<'a, 'b> Context<'a, 'b> { sofar += self.arg_unique_types[i].len(); } - // Record starting index for counts, which appear just after arguments + // Record starting index for counts, which appear just after arguments. self.count_args_index_offset = sofar; } @@ -411,12 +409,12 @@ impl<'a, 'b> Context<'a, 'b> { count("Param", Some(self.ecx.expr_usize(sp, i))) } parse::CountImplied => count("Implied", None), - // should never be the case, names are already resolved + // Should never be the case, names are already resolved. parse::CountIsName(_) => panic!("should never happen"), } } - /// Build a literal expression from the accumulated string literals + /// Builds a literal expression from the accumulated string literals. fn build_literal_string(&mut self) -> P { let sp = self.fmtsp; let s = Symbol::intern(&self.literal); @@ -424,8 +422,7 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.expr_str(sp, s) } - /// Builds a static `rt::Argument` from a `parse::Piece` or append - /// to the `literal` string. + /// Builds a static `rt::Argument` from a `parse::Piece` or append to the `literal` string. fn build_piece(&mut self, piece: &parse::Piece<'_>, arg_index_consumed: &mut Vec) @@ -437,7 +434,7 @@ impl<'a, 'b> Context<'a, 'b> { None } parse::NextArgument(ref arg) => { - // Build the position + // Build the position. let pos = { let pos = |c, arg| { let mut path = Context::rtpath(self.ecx, "Position"); @@ -454,12 +451,13 @@ impl<'a, 'b> Context<'a, 'b> { parse::ArgumentIs(i) | parse::ArgumentImplicitlyIs(i) => { // Map to index in final generated argument array - // in case of multiple types specified + // in case of multiple types specified. let arg_idx = match arg_index_consumed.get_mut(i) { - None => 0, // error already emitted elsewhere + // Error already emitted elsewhere. + None => 0, Some(offset) => { let ref idx_map = self.arg_index_map[i]; - // unwrap_or branch: error already emitted elsewhere + // `unwrap_or` branch: error already emitted elsewhere. let arg_idx = *idx_map.get(*offset).unwrap_or(&0); *offset += 1; arg_idx @@ -468,15 +466,15 @@ impl<'a, 'b> Context<'a, 'b> { pos("At", Some(arg_idx)) } - // should never be the case, because names are already - // resolved. + // Should never be the case, because names are already + // resolved by now. parse::ArgumentNamed(_) => panic!("should never happen"), } }; let simple_arg = parse::Argument { position: { - // We don't have ArgumentNext any more, so we have to + // We don't have `ArgumentNext` any more, so we have to // track the current argument ourselves. let i = self.curarg; self.curarg += 1; @@ -501,7 +499,7 @@ impl<'a, 'b> Context<'a, 'b> { self.all_pieces_simple = false; } - // Build the format + // Build the format. let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill)); let align = |name| { let mut p = Context::rtpath(self.ecx, "Alignment"); @@ -521,7 +519,7 @@ impl<'a, 'b> Context<'a, 'b> { let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "FormatSpec")); let fmt = self.ecx.expr_struct( sp, - path, + path, vec![ self.ecx.field_imm(sp, self.ecx.ident_of("fill"), fill), self.ecx.field_imm(sp, self.ecx.ident_of("align"), align), @@ -534,7 +532,7 @@ impl<'a, 'b> Context<'a, 'b> { let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "Argument")); Some(self.ecx.expr_struct( sp, - path, + path, vec![ self.ecx.field_imm(sp, self.ecx.ident_of("position"), pos), self.ecx.field_imm(sp, self.ecx.ident_of("format"), fmt), @@ -544,8 +542,7 @@ impl<'a, 'b> Context<'a, 'b> { } } - /// Actually builds the expression which the format_args! block will be - /// expanded to. + /// Actually builds the expression which the format_args! block will be expanded to. fn into_expr(self) -> P { let mut locals = Vec::with_capacity( (0..self.args.len()).map(|i| self.arg_unique_types[i].len()).sum() @@ -559,16 +556,15 @@ impl<'a, 'b> Context<'a, 'b> { .collect(); // First, build up the static array which will become our precompiled - // format "string" + // format "string". let pieces = self.ecx.expr_vec_slice(self.fmtsp, self.str_pieces); // Before consuming the expressions, we have to remember spans for // count arguments as they are now generated separate from other - // arguments, hence have no access to the `P`'s. + // arguments, hence have no access to the `P`s. let spans_pos: Vec<_> = self.args.iter().map(|e| e.span.clone()).collect(); - // Right now there is a bug such that for the expression: - // foo(bar(&1)) + // Right now there is a bug such that for the expression `foo(bar(&1))`. // the lifetime of `1` doesn't outlast the call to `bar`, so it's not // valid for the call to `foo`. To work around this all arguments to the // format! string are shoved into locals. Furthermore, we shove the address @@ -594,7 +590,7 @@ impl<'a, 'b> Context<'a, 'b> { counts.push(Context::format_arg(self.ecx, self.macsp, span, &Count, name)); } - // Now create a vector containing all the arguments + // Now, create a vector containing all the arguments. let args = locals.into_iter().chain(counts.into_iter()); let args_array = self.ecx.expr_vec(self.fmtsp, args.collect()); @@ -633,7 +629,7 @@ impl<'a, 'b> Context<'a, 'b> { let args_slice = self.ecx.expr_addr_of(self.fmtsp, result); - // Now create the fmt::Arguments struct with all our locals we created. + // Now, create the `fmt::Arguments` struct with all our locals we created. let (fn_name, fn_args) = if self.all_pieces_simple { ("new_v1", vec![pieces, args_slice]) } else { @@ -708,12 +704,14 @@ pub fn expand_format_args_nl<'cx>( mut sp: Span, tts: &[tokenstream::TokenTree], ) -> Box { - //if !ecx.ecfg.enable_allow_internal_unstable() { - - // For some reason, the only one that actually works for `println` is the first check - if !sp.allows_unstable("format_args_nl") // the span is marked as `#[allow_insternal_unsable]` - && !ecx.ecfg.enable_allow_internal_unstable() // NOTE: when is this enabled? - && !ecx.ecfg.enable_format_args_nl() // enabled using `#[feature(format_args_nl]` + // For some reason, the only one that actually works for `println` is the first check. + if + // The span is marked as `#[allow_insternal_unsable]`. + !sp.allows_unstable("format_args_nl") + // NOTE: when is this enabled? + && !ecx.ecfg.enable_allow_internal_unstable() + // Enabled using `#[feature(format_args_nl]`. + && !ecx.ecfg.enable_format_args_nl() { feature_gate::emit_feature_err(&ecx.parse_sess, "format_args_nl", @@ -733,7 +731,7 @@ pub fn expand_format_args_nl<'cx>( } } -/// Take the various parts of `format_args!(efmt, args..., name=names...)` +/// Takes the various parts of `format_args!(efmt, args..., name=names...)` /// and construct the appropriate formatting expression. pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, sp: Span, @@ -797,7 +795,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, let mut skips = vec![]; while let Some((pos, c)) = s.next() { match (c, s.peek()) { - // skip whitespace and empty lines ending in '\\' + // Skip whitespace and empty lines ending in `\\`. ('\\', Some((next_pos, '\n'))) if !is_raw => { eat_ws = true; skips.push(pos); @@ -826,7 +824,8 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, let _ = s.next(); } ('\\', Some((_, 'x'))) if !is_raw => { - for _ in 0..3 { // consume `\xAB` literal + // Consume `\xAB` literal. + for _ in 0..3 { if let Some((pos, _)) = s.next() { skips.push(pos); } else { @@ -841,7 +840,8 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, if let Some((next_pos, next_c)) = s.next() { if next_c == '{' { skips.push(next_pos); - let mut i = 0; // consume up to 6 hexanumeric chars + closing `}` + // Consume up to 6 hexanumeric chars and closing `}`. + let mut i = 0; while let (Some((next_pos, c)), true) = (s.next(), i < 7) { if c.is_digit(16) { skips.push(next_pos); @@ -856,8 +856,9 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, } else if next_c.is_digit(16) { skips.push(next_pos); // We suggest adding `{` and `}` when appropriate, accept it here as if - // it were correct - let mut i = 0; // consume up to 6 hexanumeric chars + // it were correct. + // Consume up to 6 hexanumeric chars. + let mut i = 0; while let (Some((next_pos, c)), _) = (s.next(), i < 6) { if c.is_digit(16) { skips.push(next_pos); @@ -869,7 +870,9 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, } } } - _ if eat_ws => { // `take_while(|c| c.is_whitespace())` + _ if eat_ws => { + // `take_while(|c| c.is_whitespace())` + eat_ws = false; } _ => {} @@ -946,7 +949,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, is_literal, }; - // This needs to happen *after* the Parser has consumed all pieces to create all the spans + // This needs to happen *after* the `Parser` has consumed all pieces to create all the spans. let pieces = unverified_pieces.into_iter().map(|mut piece| { cx.verify_piece(&piece); cx.resolve_name_inplace(&mut piece); @@ -995,10 +998,10 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, .filter(|(i, ty)| ty.is_empty() && !cx.count_positions.contains_key(&i)) .map(|(i, _)| { let msg = if i >= num_pos_args { - // named argument + // Named argument. "named argument never used" } else { - // positional argument + // Positional argument. "argument never used" }; (cx.args[i].span, msg) @@ -1035,7 +1038,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, if args_used < args_unused { use super::format_foreign as foreign; - // The set of foreign substitutions we've explained. This prevents spamming the user + // The set of foreign substitutions we've explained. This prevents spamming the user // with `%d should be written as {}` over and over again. let mut explained = FxHashSet::default(); @@ -1065,7 +1068,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, } if let Some((start, end)) = pos { - // account for `"` and account for raw strings `r#` + // Account for `"` and account for raw strings `r#`. let padding = str_style.map(|i| i + 2).unwrap_or(1); let sp = fmt_sp.from_inner_byte_pos(start + padding, end + padding); suggestions.push((sp, trn)); diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 261b2f373cefd..d67c6c6451ef3 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -225,7 +225,7 @@ pub mod printf { #[derive(Copy, Clone, PartialEq, Debug)] pub enum Num { // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU - // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it + // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it // is *vanishingly* unlikely that *anyone* is going to try formatting something wider, or // with more precision, than 32 thousand positions which is so wide it couldn't possibly fit // on a screen. diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index fd82dac5ab6d8..e43fb89621134 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -303,7 +303,7 @@ pub struct Group { #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct Punct { ch: char, - // NB. not using `Spacing` here because it doesn't implement `Hash`. + // N.B., not using `Spacing` here because it doesn't implement `Hash`. joint: bool, span: Span, } @@ -356,7 +356,7 @@ impl Ident { } } -// FIXME(eddyb) `Literal` should not expose internal `Debug` impls. +// FIXME(eddyb): `Literal` should not expose internal `Debug` impls. #[derive(Clone, Debug)] pub struct Literal { lit: token::Lit, @@ -538,7 +538,7 @@ impl server::Ident for Rustc<'_> { } impl server::Literal for Rustc<'_> { - // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + // FIXME(eddyb): `Literal` should not expose internal `Debug` impls. fn debug(&mut self, literal: &Self::Literal) -> String { format!("{:?}", literal) } diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 371862465487b..b49516f0b089b 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -1,16 +1,17 @@ -/// The expansion from a test function to the appropriate test struct for libtest +/// The expansion from a test function to the appropriate test struct for libtest. /// Ideally, this code would be in libtest but for efficiency and error messages it lives here. +use std::iter; + +use syntax_pos::{DUMMY_SP, Span}; +use syntax::attr; +use syntax::ast; use syntax::ext::base::*; use syntax::ext::build::AstBuilder; use syntax::ext::hygiene::{self, Mark, SyntaxContext}; -use syntax::attr; -use syntax::ast; use syntax::print::pprust; -use syntax::symbol::Symbol; -use syntax_pos::{DUMMY_SP, Span}; use syntax::source_map::{ExpnInfo, MacroAttribute}; -use std::iter; +use syntax::symbol::Symbol; pub fn expand_test( cx: &mut ExtCtxt<'_>, @@ -36,23 +37,23 @@ pub fn expand_test_or_bench( item: Annotatable, is_bench: bool ) -> Vec { - // If we're not in test configuration, remove the annotated item + // If we're not in test configuration, remove the annotated item. if !cx.ecfg.should_test { return vec![]; } let item = if let Annotatable::Item(i) = item { i } else { cx.parse_sess.span_diagnostic.span_fatal(item.span(), - "#[test] attribute is only allowed on non associated functions").raise(); + "`#[test]` attribute is only allowed on non associated functions").raise(); }; if let ast::ItemKind::Mac(_) = item.node { cx.parse_sess.span_diagnostic.span_warn(item.span, - "#[test] attribute should not be used on macros. Use #[cfg(test)] instead."); + "`#[test]` attribute should not be used on macros. use `#[cfg(test)]` instead."); return vec![Annotatable::Item(item)]; } - // has_*_signature will report any errors in the type so compilation + // `has_*_signature` will report any errors in the type so compilation // will fail. We shouldn't try to expand in this case because the errors // would be spurious. if (!is_bench && !has_test_signature(cx, &item)) || @@ -78,119 +79,119 @@ pub fn expand_test_or_bench( attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(mark))) }; - // Gensym "test" so we can extern crate without conflicting with any local names + // Gensym "test" so we can extern crate without conflicting with any local names. let test_id = cx.ident_of("test").gensym(); - // creates test::$name + // Creates `test::$name`. let test_path = |name| { cx.path(sp, vec![test_id, cx.ident_of(name)]) }; - // creates test::$name + // Creates `test::$name`. let should_panic_path = |name| { cx.path(sp, vec![test_id, cx.ident_of("ShouldPanic"), cx.ident_of(name)]) }; - // creates $name: $expr + // Creates `$name: $expr`. let field = |name, expr| cx.field_imm(sp, cx.ident_of(name), expr); let test_fn = if is_bench { - // A simple ident for a lambda + // A simple ident for a closure. let b = cx.ident_of("b"); cx.expr_call(sp, cx.expr_path(test_path("StaticBenchFn")), vec![ - // |b| self::test::assert_test_result( + // `|b| self::test::assert_test_result(` cx.lambda1(sp, cx.expr_call(sp, cx.expr_path(test_path("assert_test_result")), vec![ - // super::$test_fn(b) + // `super::$test_fn(b)` cx.expr_call(sp, cx.expr_path(cx.path(sp, vec![item.ident])), vec![cx.expr_ident(sp, b)]) ]), b ) - // ) + // `)` ]) } else { cx.expr_call(sp, cx.expr_path(test_path("StaticTestFn")), vec![ - // || { + // `|| {` cx.lambda0(sp, - // test::assert_test_result( + // `test::assert_test_result(` cx.expr_call(sp, cx.expr_path(test_path("assert_test_result")), vec![ - // $test_fn() + // `$test_fn()` cx.expr_call(sp, cx.expr_path(cx.path(sp, vec![item.ident])), vec![]) - // ) + // `)` ]) - // } + // `}` ) - // ) + // `)` ]) }; let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name.gensymed(), sp), vec![ - // #[cfg(test)] + // `#[cfg(test)]` cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![ cx.meta_list_item_word(attr_sp, Symbol::intern("test")) ])), - // #[rustc_test_marker] + // `#[rustc_test_marker]` cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker"))), ], - // const $ident: test::TestDescAndFn = + // `const $ident: test::TestDescAndFn =` ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))), - // test::TestDescAndFn { + // `test::TestDescAndFn {` cx.expr_struct(sp, test_path("TestDescAndFn"), vec![ - // desc: test::TestDesc { + // `desc: test::TestDesc {` field("desc", cx.expr_struct(sp, test_path("TestDesc"), vec![ - // name: "path::to::test" + // `name: "path::to::test"` field("name", cx.expr_call(sp, cx.expr_path(test_path("StaticTestName")), vec![ cx.expr_str(sp, Symbol::intern(&item_path( - // skip the name of the root module + // Skip the name of the root module. &cx.current_expansion.module.mod_path[1..], &item.ident ))) ])), - // ignore: true | false + // `ignore: true | false` field("ignore", cx.expr_bool(sp, should_ignore(&item))), - // allow_fail: true | false + // `allow_fail: true | false` field("allow_fail", cx.expr_bool(sp, should_fail(&item))), - // should_panic: ... + // `should_panic: ...` field("should_panic", match should_panic(cx, &item) { - // test::ShouldPanic::No + // `test::ShouldPanic::No` ShouldPanic::No => cx.expr_path(should_panic_path("No")), - // test::ShouldPanic::Yes + // `test::ShouldPanic::Yes` ShouldPanic::Yes(None) => cx.expr_path(should_panic_path("Yes")), - // test::ShouldPanic::YesWithMessage("...") + // `test::ShouldPanic::YesWithMessage("...")` ShouldPanic::Yes(Some(sym)) => cx.expr_call(sp, cx.expr_path(should_panic_path("YesWithMessage")), vec![cx.expr_str(sp, sym)]), }), - // }, + // `},` ])), // testfn: test::StaticTestFn(...) | test::StaticBenchFn(...) field("testfn", test_fn) - // } + // `}` ]) - // } + // `}` )); test_const = test_const.map(|mut tc| { tc.vis.node = ast::VisibilityKind::Public; tc}); - // extern crate test as test_gensym + // `extern crate` test as `test_gensym`. let test_extern = cx.item(sp, test_id, vec![], ast::ItemKind::ExternCrate(Some(Symbol::intern("test"))) ); - log::debug!("Synthetic test item:\n{}\n", pprust::item_to_string(&test_const)); + log::debug!("synthetic test item:\n{}\n", pprust::item_to_string(&test_const)); vec![ - // Access to libtest under a gensymed name + // Access to libtest under a gensym-ed name. Annotatable::Item(test_extern), - // The generated test case + // The generated test case. Annotatable::Item(test_const), - // The original item + // The original item. Annotatable::Item(item) ] } @@ -219,7 +220,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { let ref sd = cx.parse_sess.span_diagnostic; match attr.meta_item_list() { - // Handle #[should_panic(expected = "foo")] + // Handle `#[should_panic(expected = "foo")]`. Some(list) => { let msg = list.iter() .find(|mi| mi.check_name("expected")) @@ -230,15 +231,15 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { attr.span(), "argument must be of the form: \ `expected = \"error message\"`" - ).note("Errors in this attribute were erroneously \ - allowed and will become a hard error in a \ + ).note("errors in this attribute were erroneously \ + allowed, and will become a hard error in a \ future release.").emit(); ShouldPanic::Yes(None) } else { ShouldPanic::Yes(msg) } }, - // Handle #[should_panic] and #[should_panic = "expected"] + // Handle `#[should_panic]` and `#[should_panic = "expected"]`. None => ShouldPanic::Yes(attr.value_str()) } } @@ -285,8 +286,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { false }, (true, false) => if !generics.params.is_empty() { - sd.span_err(i.span, - "functions used as tests must have signature fn() -> ()"); + sd.span_err(i.span, "functions used as tests must have signature `fn() -> ()`"); false } else { true @@ -301,8 +301,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.node { - // N.B., inadequate check, but we're running - // well before resolve, can't get too deep. + // N.B., inadequate check, but we're running well before resolve, so we can't get too deep. decl.inputs.len() == 1 } else { false diff --git a/src/libsyntax_pos/analyze_source_file.rs b/src/libsyntax_pos/analyze_source_file.rs index 353b4e4ab36b3..b0b0f516d9f1c 100644 --- a/src/libsyntax_pos/analyze_source_file.rs +++ b/src/libsyntax_pos/analyze_source_file.rs @@ -258,7 +258,7 @@ fn analyze_source_file_generic(src: &str, } // Assume control characters are zero width. - // FIXME: How can we decide between `width` and `width_cjk`? + // FIXME: how can we decide between `width` and `width_cjk`? let char_width = UnicodeWidthChar::width(c).unwrap_or(0); if char_width != 1 { diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 6331fe608868f..42696efe79e66 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -232,7 +232,7 @@ impl SyntaxContext { // Allocate a new SyntaxContext with the given ExpnInfo. This is used when // deserializing Spans from the incr. comp. cache. - // FIXME(mw): This method does not restore MarkData::parent or + // FIXME(mw): this method does not restore MarkData::parent or // SyntaxContextData::prev_ctxt or SyntaxContextData::opaque. These things // don't seem to be used after HIR lowering, so everything should be fine // as long as incremental compilation does not kick in before that. @@ -612,12 +612,12 @@ impl CompilerDesugaringKind { impl Encodable for SyntaxContext { fn encode(&self, _: &mut E) -> Result<(), E::Error> { - Ok(()) // FIXME(jseyfried) intercrate hygiene + Ok(()) // FIXME(jseyfried): intercrate hygiene } } impl Decodable for SyntaxContext { fn decode(_: &mut D) -> Result { - Ok(SyntaxContext::empty()) // FIXME(jseyfried) intercrate hygiene + Ok(SyntaxContext::empty()) // FIXME(jseyfried): intercrate hygiene } } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index c5301f9f174c0..424eaa1f4e176 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -356,7 +356,7 @@ macro_rules! declare_keywords {( }} // N.B., leaving holes in the ident table is bad! a different ident will get -// interned with the id from the hole, but it will be between the min and max +// interned with the ID from the hole, but it will be between the min and max // of the reserved words, and thus tagged as "reserved". // After modifying this list adjust `is_special`, `is_used_keyword`/`is_unused_keyword`, // this should be rarely necessary though if the keywords are kept in alphabetic order. diff --git a/src/libterm/terminfo/searcher.rs b/src/libterm/terminfo/searcher.rs index 0b17ed36fc8ca..799caa5ae6c13 100644 --- a/src/libterm/terminfo/searcher.rs +++ b/src/libterm/terminfo/searcher.rs @@ -6,13 +6,13 @@ use std::env; use std::fs; use std::path::PathBuf; -/// Return path to database entry for `term` +/// Returns path to database entry for `term`. #[allow(deprecated)] pub fn get_dbpath_for_term(term: &str) -> Option { let mut dirs_to_search = Vec::new(); let first_char = term.chars().next()?; - // Find search directory + // Find search directory. if let Some(dir) = env::var_os("TERMINFO") { dirs_to_search.push(PathBuf::from(dir)); } @@ -26,11 +26,11 @@ pub fn get_dbpath_for_term(term: &str) -> Option { } } } else { - // Found nothing in TERMINFO_DIRS, use the default paths: - // According to /etc/terminfo/README, after looking at - // ~/.terminfo, ncurses will search /etc/terminfo, then - // /lib/terminfo, and eventually /usr/share/terminfo. - // On Haiku the database can be found at /boot/system/data/terminfo + // Found nothing in `TERMINFO_DIRS`, so use the default paths. + // According to `/etc/terminfo/README`, after looking at + // `~/.terminfo`, ncurses will search `/etc/terminfo`, then + // `/lib/terminfo`, and eventually `/usr/share/terminfo`. + // On Haiku, the database can be found at `/boot/system/data/terminfo`. if let Some(mut homedir) = env::home_dir() { homedir.push(".terminfo"); dirs_to_search.push(homedir) @@ -42,7 +42,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option { dirs_to_search.push(PathBuf::from("/boot/system/data/terminfo")); } - // Look for the terminal in all of the search directories + // Look for the terminal in all of the search directories. for mut p in dirs_to_search { if fs::metadata(&p).is_ok() { p.push(&first_char.to_string()); @@ -53,8 +53,8 @@ pub fn get_dbpath_for_term(term: &str) -> Option { p.pop(); p.pop(); - // on some installations the dir is named after the hex of the char - // (e.g., macOS) + // On some installations, the dir is named after the hex of the char + // (e.g., macOS). p.push(&format!("{:x}", first_char as usize)); p.push(term); if fs::metadata(&p).is_ok() { @@ -68,10 +68,10 @@ pub fn get_dbpath_for_term(term: &str) -> Option { #[test] #[ignore = "buildbots don't have ncurses installed and I can't mock everything I need"] fn test_get_dbpath_for_term() { - // woefully inadequate test coverage - // note: current tests won't work with non-standard terminfo hierarchies (e.g., macOS's) + // Woefully inadequate test coverage. + // N.B., current tests won't work with non-standard terminfo hierarchies (e.g., macOS's). use std::env; - // FIXME (#9639): This needs to handle non-utf8 paths + // FIXME(#9639): this needs to handle non-UTF8 paths. fn x(t: &str) -> String { let p = get_dbpath_for_term(t).expect("no terminfo entry found"); p.to_str().unwrap().to_string() diff --git a/src/libterm/win.rs b/src/libterm/win.rs index 6d42b01337ed5..ee0a59b43d25b 100644 --- a/src/libterm/win.rs +++ b/src/libterm/win.rs @@ -1,6 +1,6 @@ -//! Windows console handling +//! Windows console handling. -// FIXME (#13400): this is only a tiny fraction of the Windows console api +// FIXME(#13400): this is only a tiny fraction of the Windows console API. extern crate libc; @@ -44,7 +44,7 @@ extern "system" { } fn color_to_bits(color: color::Color) -> u16 { - // magic numbers from mingw-w64's wincon.h + // Magic numbers from mingw-w64's `wincon.h`. let bits = match color % 8 { color::BLACK => 0, @@ -78,7 +78,8 @@ fn bits_to_color(bits: u16) -> color::Color { _ => unreachable!(), }; - color | (bits & 0x8) // copy the hi-intensity bit + // Copy the hi-intensity bit. + color | (bits & 0x8) } impl WinConsole { @@ -89,8 +90,8 @@ impl WinConsole { accum |= color_to_bits(self.background) << 4; unsafe { - // Magic -11 means stdout, from - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx + // Magic `-11` means stdout, from + // . // // You may be wondering, "but what about stderr?", and the answer // to that is that setting terminal attributes on the stdout @@ -171,8 +172,8 @@ impl Terminal for WinConsole { } fn supports_attr(&self, attr: Attr) -> bool { - // it claims support for underscore and reverse video, but I can't get - // it to do anything -cmr + // It claims support for underscore and reverse video, but I can't get + // it to do anything. -cmr match attr { Attr::ForegroundColor(_) | Attr::BackgroundColor(_) => true, _ => false, diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 5c7fb1b804461..adb6171edb191 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -510,7 +510,7 @@ Test Attributes: ); } -// FIXME: Copied from libsyntax until linkage errors are resolved. Issue #47566 +// FIXME: copied from libsyntax until linkage errors are resolved. Issue #47566 fn is_nightly() -> bool { // Whether this is a feature-staged build, i.e., on the beta or stable channel let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some(); @@ -1024,7 +1024,7 @@ fn use_color(opts: &TestOpts) -> bool { all(target_vendor = "fortanix", target_env = "sgx") ))] fn stdout_isatty() -> bool { - // FIXME: Implement isatty on Redox and SGX + // FIXME: implement isatty on Redox and SGX false } #[cfg(unix)] @@ -1249,7 +1249,7 @@ fn get_concurrency() -> usize { #[cfg(target_os = "redox")] fn num_cpus() -> usize { - // FIXME: Implement num_cpus on Redox + // FIXME: implement num_cpus on Redox 1 } diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index 5c9421d5ea4b0..024e11d38e630 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -150,7 +150,7 @@ impl Summary { } impl Stats for [f64] { - // FIXME #11059 handle NaN, inf and overflow + // FIXME(#11059): handle NaN, inf and overflow. fn sum(&self) -> f64 { let mut partials = vec![]; diff --git a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs index 8a19a7bd9f8fa..987d8fdd47187 100644 --- a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs @@ -13,7 +13,7 @@ use cgu_export_trait_method::Trait; #[start] fn start(_: isize, _: *const *const u8) -> isize { // The object code of these methods is contained in the external crate, so - // calling them should *not* introduce codegen items in the current crate. + // calling them should **not** introduce codegen items in the current crate. let _: (u32, u32) = Trait::without_default_impl(0); let _: (char, u32) = Trait::without_default_impl(0); diff --git a/src/test/codegen-units/partitioning/methods-are-with-self-type.rs b/src/test/codegen-units/partitioning/methods-are-with-self-type.rs index c2961ed9322ad..3ccabbce24618 100644 --- a/src/test/codegen-units/partitioning/methods-are-with-self-type.rs +++ b/src/test/codegen-units/partitioning/methods-are-with-self-type.rs @@ -19,7 +19,7 @@ mod mod1 { use super::{SomeType, SomeGenericType}; // Even though the impl is in `mod1`, the methods should end up in the - // parent module, since that is where their self-type is. + // parent module, since that is where their self type is. impl SomeType { //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[0]::method[0] @@ methods_are_with_self_type[External] fn method(&self) {} diff --git a/src/test/codegen/align-struct.rs b/src/test/codegen/align-struct.rs index c0d6a0c80e1cf..1151689873649 100644 --- a/src/test/codegen/align-struct.rs +++ b/src/test/codegen/align-struct.rs @@ -38,7 +38,7 @@ pub fn align64(i : i32) -> Align64 { a64 } -// For issue 54028: make sure that we are specifying the correct alignment for fields of aligned +// For issue #54028: make sure that we are specifying the correct alignment for fields of aligned // structs // CHECK-LABEL: @align64_load #[no_mangle] diff --git a/src/test/codegen/dllimports/auxiliary/dummy.rs b/src/test/codegen/dllimports/auxiliary/dummy.rs index 113a164f1457f..244bd91837f53 100644 --- a/src/test/codegen/dllimports/auxiliary/dummy.rs +++ b/src/test/codegen/dllimports/auxiliary/dummy.rs @@ -2,5 +2,5 @@ #![crate_type = "staticlib"] // Since codegen tests don't actually perform linking, this library doesn't need to export -// any symbols. It's here just to satisfy the compiler looking for a .lib file when processing +// any symbols. It's here just to satisfy the compiler looking for a .lib file when processing // #[link(...)] attributes in wrapper.rs. diff --git a/src/test/codegen/enum-debug-clike.rs b/src/test/codegen/enum-debug-clike.rs index 62cfef5a845e9..0fde8f53a2b57 100644 --- a/src/test/codegen/enum-debug-clike.rs +++ b/src/test/codegen/enum-debug-clike.rs @@ -1,5 +1,5 @@ // This test depends on a patch that was committed to upstream LLVM -// before 7.0, then backported to the Rust LLVM fork. It tests that +// before 7.0, then backported to the Rust LLVM fork. It tests that // debug info for "c-like" enums is properly emitted. // ignore-tidy-linelength diff --git a/src/test/codegen/enum-debug-niche-2.rs b/src/test/codegen/enum-debug-niche-2.rs index 369fa1fcfda7b..bb4f3a2a9ff27 100644 --- a/src/test/codegen/enum-debug-niche-2.rs +++ b/src/test/codegen/enum-debug-niche-2.rs @@ -1,5 +1,5 @@ // This test depends on a patch that was committed to upstream LLVM -// before 7.0, then backported to the Rust LLVM fork. It tests that +// before 7.0, then backported to the Rust LLVM fork. It tests that // optimized enum debug info accurately reflects the enum layout. // ignore-tidy-linelength diff --git a/src/test/codegen/enum-debug-niche.rs b/src/test/codegen/enum-debug-niche.rs index 1273a785ba42f..9a0c6b5a32db7 100644 --- a/src/test/codegen/enum-debug-niche.rs +++ b/src/test/codegen/enum-debug-niche.rs @@ -1,5 +1,5 @@ // This test depends on a patch that was committed to upstream LLVM -// before 7.0, then backported to the Rust LLVM fork. It tests that +// before 7.0, then backported to the Rust LLVM fork. It tests that // optimized enum debug info accurately reflects the enum layout. // ignore-tidy-linelength diff --git a/src/test/codegen/enum-debug-tagged.rs b/src/test/codegen/enum-debug-tagged.rs index 5c37e40c27032..9357478289ef5 100644 --- a/src/test/codegen/enum-debug-tagged.rs +++ b/src/test/codegen/enum-debug-tagged.rs @@ -1,5 +1,5 @@ // This test depends on a patch that was committed to upstream LLVM -// before 7.0, then backported to the Rust LLVM fork. It tests that +// before 7.0, then backported to the Rust LLVM fork. It tests that // debug info for tagged (ordinary) enums is properly emitted. // ignore-tidy-linelength diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index c2d697fd046bf..cc51130b32adb 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -5,51 +5,51 @@ #![feature(custom_attribute)] pub struct S { - _field: [i32; 8], + _field: [i32; 8], } pub struct UnsafeInner { - _field: std::cell::UnsafeCell, + _field: std::cell::UnsafeCell, } // CHECK: zeroext i1 @boolean(i1 zeroext %x) #[no_mangle] pub fn boolean(x: bool) -> bool { - x + x } // CHECK: @readonly_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn readonly_borrow(_: &i32) { } // CHECK: @static_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0) -// static borrow may be captured +// Static borrow may be captured. #[no_mangle] pub fn static_borrow(_: &'static i32) { } // CHECK: @named_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0) -// borrow with named lifetime may be captured +// Borrow with named lifetime may be captured. #[no_mangle] pub fn named_borrow<'r>(_: &'r i32) { } // CHECK: @unsafe_borrow(i16* align 2 dereferenceable(2) %arg0) -// unsafe interior means this isn't actually readonly and there may be aliases ... +// Unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_borrow(_: &UnsafeInner) { } // CHECK: @mutable_unsafe_borrow(i16* align 2 dereferenceable(2) %arg0) -// ... unless this is a mutable borrow, those never alias +// ... unless this is a mutable borrow, those never alias. #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } // CHECK: @mutable_borrow(i32* align 4 dereferenceable(4) %arg0) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn mutable_borrow(_: &mut i32) { } @@ -60,7 +60,7 @@ pub fn indirect_struct(_: S) { } // CHECK: @borrowed_struct(%S* noalias readonly align 4 dereferenceable(32) %arg0) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn borrowed_struct(_: &S) { } @@ -68,49 +68,49 @@ pub fn borrowed_struct(_: &S) { // CHECK: noalias align 4 dereferenceable(4) i32* @_box(i32* noalias align 4 dereferenceable(4) %x) #[no_mangle] pub fn _box(x: Box) -> Box { - x + x } // CHECK: @struct_return(%S* noalias nocapture sret dereferenceable(32)) #[no_mangle] pub fn struct_return() -> S { - S { - _field: [0, 0, 0, 0, 0, 0, 0, 0] - } + S { + _field: [0, 0, 0, 0, 0, 0, 0, 0] + } } -// Hack to get the correct size for the length part in slices +// Hack to get the correct size for the length part in slices. // CHECK: @helper([[USIZE:i[0-9]+]] %arg0) #[no_mangle] pub fn helper(_: usize) { } // CHECK: @slice([0 x i8]* noalias nonnull readonly align 1 %arg0.0, [[USIZE]] %arg0.1) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn slice(_: &[u8]) { } // CHECK: @mutable_slice([0 x i8]* nonnull align 1 %arg0.0, [[USIZE]] %arg0.1) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn mutable_slice(_: &mut [u8]) { } // CHECK: @unsafe_slice([0 x i16]* nonnull align 2 %arg0.0, [[USIZE]] %arg0.1) -// unsafe interior means this isn't actually readonly and there may be aliases ... +// Unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_slice(_: &[UnsafeInner]) { } // CHECK: @str([0 x i8]* noalias nonnull readonly align 1 %arg0.0, [[USIZE]] %arg0.1) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn str(_: &[u8]) { } // CHECK: @trait_borrow({}* nonnull align 1 %arg0.0, [3 x [[USIZE]]]* noalias readonly align {{.*}} dereferenceable({{.*}}) %arg0.1) -// FIXME #25759 This should also have `nocapture` +// FIXME(#25759): this should also have `nocapture`. #[no_mangle] pub fn trait_borrow(_: &Drop) { } @@ -123,30 +123,30 @@ pub fn trait_box(_: Box) { // CHECK: { i8*, i8* } @trait_option(i8* noalias align 1 %x.0, i8* %x.1) #[no_mangle] pub fn trait_option(x: Option>) -> Option> { - x + x } // CHECK: { [0 x i16]*, [[USIZE]] } @return_slice([0 x i16]* noalias nonnull readonly align 2 %x.0, [[USIZE]] %x.1) #[no_mangle] pub fn return_slice(x: &[u16]) -> &[u16] { - x + x } // CHECK: { i16, i16 } @enum_id_1(i16 %x.0, i16 %x.1) #[no_mangle] pub fn enum_id_1(x: Option>) -> Option> { - x + x } // CHECK: { i8, i8 } @enum_id_2(i1 zeroext %x.0, i8 %x.1) #[no_mangle] pub fn enum_id_2(x: Option) -> Option { - x + x } // CHECK: noalias i8* @allocator() #[no_mangle] #[allocator] pub fn allocator() -> *const i8 { - std::ptr::null() + std::ptr::null() } diff --git a/src/test/codegen/issue-13018.rs b/src/test/codegen/issue-13018.rs index b70ea1f48c8ce..8a9da14e9e932 100644 --- a/src/test/codegen/issue-13018.rs +++ b/src/test/codegen/issue-13018.rs @@ -1,7 +1,7 @@ // compile-flags: -O -// A drop([...].clone()) sequence on an Rc should be a no-op -// In particular, no call to __rust_dealloc should be emitted +// A `drop([...].clone())` sequence on an `Rc` should be a no-op +// In particular, no call to `__rust_dealloc` should be emitted. #![crate_type = "lib"] use std::rc::Rc; diff --git a/src/test/codegen/naked-functions.rs b/src/test/codegen/naked-functions.rs index 2050193b61b54..3e8f382f9dccf 100644 --- a/src/test/codegen/naked-functions.rs +++ b/src/test/codegen/naked-functions.rs @@ -55,7 +55,7 @@ pub fn naked_recursive() { // CHECK-NEXT: {{.+}}: // CHECK-NEXT: call void @naked_empty() - // FIXME(#39685) Avoid one block per call. + // FIXME(#39685): avoid one block per call. // CHECK-NEXT: br label %bb1 // CHECK: bb1: @@ -63,19 +63,19 @@ pub fn naked_recursive() { // CHECK-NEXT: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_return() - // FIXME(#39685) Avoid one block per call. + // FIXME(#39685): avoid one block per call. // CHECK-NEXT: br label %bb2 // CHECK: bb2: // CHECK-NEXT: %{{[0-9]+}} = call i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}} %{{[0-9]+}}) - // FIXME(#39685) Avoid one block per call. + // FIXME(#39685): avoid one block per call. // CHECK-NEXT: br label %bb3 // CHECK: bb3: // CHECK-NEXT: call void @naked_with_args(i{{[0-9]+}} %{{[0-9]+}}) - // FIXME(#39685) Avoid one block per call. + // FIXME(#39685): avoid one block per call. // CHECK-NEXT: br label %bb4 // CHECK: bb4: diff --git a/src/test/compile-fail/auxiliary/weak-lang-items.rs b/src/test/compile-fail/auxiliary/weak-lang-items.rs index 7a698cf76ae51..c5181f3b6719e 100644 --- a/src/test/compile-fail/auxiliary/weak-lang-items.rs +++ b/src/test/compile-fail/auxiliary/weak-lang-items.rs @@ -1,6 +1,6 @@ // no-prefer-dynamic -// This aux-file will require the eh_personality function to be codegen'd, but +// This aux-file will require the `eh_personality` function to be codegen'ed, but // it hasn't been defined just yet. Make sure we don't explode. #![no_std] diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs index b8a0c4846abeb..5505fcd888631 100644 --- a/src/test/compile-fail/issue-23595-1.rs +++ b/src/test/compile-fail/issue-23595-1.rs @@ -5,7 +5,7 @@ use std::ops::{Index}; trait Hierarchy { type Value; type ChildKey; - type Children = Index; + type Children = Index; //~^ ERROR: the value of the associated types `Value` (from the trait `Hierarchy`), `ChildKey` fn data(&self) -> Option<(Self::Value, Self::Children)>; diff --git a/src/test/compile-fail/meta-expected-error-wrong-rev.rs b/src/test/compile-fail/meta-expected-error-wrong-rev.rs index 7e49434142bcb..48fe3f4c5856e 100644 --- a/src/test/compile-fail/meta-expected-error-wrong-rev.rs +++ b/src/test/compile-fail/meta-expected-error-wrong-rev.rs @@ -3,7 +3,7 @@ // revisions: a // should-fail -// This is a "meta-test" of the compilertest framework itself. In +// This is a "meta-test" of the compilertest framework itself. In // particular, it includes the right error message, but the message // targets the wrong revision, so we expect the execution to fail. // See also `meta-expected-error-correct-rev.rs`. diff --git a/src/test/debuginfo/basic-types-globals-metadata.rs b/src/test/debuginfo/basic-types-globals-metadata.rs index 3934d3c7a685e..30f050a41ffc0 100644 --- a/src/test/debuginfo/basic-types-globals-metadata.rs +++ b/src/test/debuginfo/basic-types-globals-metadata.rs @@ -52,7 +52,7 @@ #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] -// N.B. These are `mut` only so they don't constant fold away. +// N.B., these are `mut` only so they don't constant fold away. static mut B: bool = false; static mut I: isize = -1; static mut C: char = 'a'; diff --git a/src/test/debuginfo/basic-types-globals.rs b/src/test/debuginfo/basic-types-globals.rs index 389b2cf015cac..6b9d899e4cbb3 100644 --- a/src/test/debuginfo/basic-types-globals.rs +++ b/src/test/debuginfo/basic-types-globals.rs @@ -58,7 +58,7 @@ #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] -// N.B. These are `mut` only so they don't constant fold away. +// N.B., these are `mut` only so they don't constant fold away. static mut B: bool = false; static mut I: isize = -1; static mut C: char = 'a'; diff --git a/src/test/debuginfo/basic-types.rs b/src/test/debuginfo/basic-types.rs index 3721b87678d55..837a75a9a101c 100644 --- a/src/test/debuginfo/basic-types.rs +++ b/src/test/debuginfo/basic-types.rs @@ -56,7 +56,7 @@ // lldbg-check:[...]$1 = -1 // lldbr-check:(isize) i = -1 -// NOTE: only rust-enabled lldb supports 32bit chars +// NOTE: only Rust-enabled LLDB supports 32-bit chars. // lldbr-command:print c // lldbr-check:(char) c = 'a' diff --git a/src/test/debuginfo/borrowed-basic.rs b/src/test/debuginfo/borrowed-basic.rs index c3868d46ba485..2ce1795cc63a5 100644 --- a/src/test/debuginfo/borrowed-basic.rs +++ b/src/test/debuginfo/borrowed-basic.rs @@ -64,7 +64,7 @@ // lldbg-check:[...]$1 = -1 // lldbr-check:(isize) *int_ref = -1 -// NOTE: only rust-enabled lldb supports 32bit chars +// NOTE: only Rust-enabled LLDB supports 32-bit chars. // lldbr-command:print *char_ref // lldbr-check:(char) *char_ref = 'a' diff --git a/src/test/debuginfo/borrowed-enum-legacy.rs b/src/test/debuginfo/borrowed-enum-legacy.rs index 9a973ed74e867..66f07e91e1ad6 100644 --- a/src/test/debuginfo/borrowed-enum-legacy.rs +++ b/src/test/debuginfo/borrowed-enum-legacy.rs @@ -2,7 +2,7 @@ // min-lldb-version: 310 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/borrowed-unique-basic.rs b/src/test/debuginfo/borrowed-unique-basic.rs index f927a54f02aa6..7e90fc61ea6e9 100644 --- a/src/test/debuginfo/borrowed-unique-basic.rs +++ b/src/test/debuginfo/borrowed-unique-basic.rs @@ -67,7 +67,7 @@ // lldbg-check:[...]$1 = -1 // lldbr-check:(isize) *int_ref = -1 -// NOTE: only rust-enabled lldb supports 32bit chars +// NOTE: only Rust-enabled LLDB supports 32-bit chars. // lldbr-command:print *char_ref // lldbr-check:(char) *char_ref = 97 diff --git a/src/test/debuginfo/drop-locations.rs b/src/test/debuginfo/drop-locations.rs index c195f46208a0c..1e7ab823424d9 100644 --- a/src/test/debuginfo/drop-locations.rs +++ b/src/test/debuginfo/drop-locations.rs @@ -37,8 +37,8 @@ // lldb-command:set set stop-line-count-before 0 // lldb-command:set set stop-line-count-after 1 -// Can't set both to zero or lldb will stop printing source at all. So it will output the current -// line and the next. We deal with this by having at least 2 lines between the #loc's +// Can't set both to zero or lldb will stop printing source at all. So it will output the current +// line and the next. We deal with this by having at least 2 lines between the #loc's // lldb-command:run // lldb-command:next diff --git a/src/test/debuginfo/generic-enum-with-different-disr-sizes-legacy.rs b/src/test/debuginfo/generic-enum-with-different-disr-sizes-legacy.rs index 4f17e48c6a437..b761f951625e2 100644 --- a/src/test/debuginfo/generic-enum-with-different-disr-sizes-legacy.rs +++ b/src/test/debuginfo/generic-enum-with-different-disr-sizes-legacy.rs @@ -3,7 +3,7 @@ // min-lldb-version: 310 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/generic-struct-style-enum-legacy.rs b/src/test/debuginfo/generic-struct-style-enum-legacy.rs index 37a875a4188c1..c2652ab4de903 100644 --- a/src/test/debuginfo/generic-struct-style-enum-legacy.rs +++ b/src/test/debuginfo/generic-struct-style-enum-legacy.rs @@ -3,7 +3,7 @@ // ignore-gdb-version: 7.11.90 - 7.12.9 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 @@ -37,7 +37,7 @@ use self::Regular::{Case1, Case2, Case3}; use self::Univariant::TheOnlyCase; -// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// NOTE: this is a copy of the non-generic test case. The `Txx` type parameters have to be // substituted with something of size `xx` bits and the same alignment as an integer type of the // same size. diff --git a/src/test/debuginfo/generic-struct-style-enum.rs b/src/test/debuginfo/generic-struct-style-enum.rs index 3e593470303ea..2d1c71e72ebf6 100644 --- a/src/test/debuginfo/generic-struct-style-enum.rs +++ b/src/test/debuginfo/generic-struct-style-enum.rs @@ -29,7 +29,7 @@ use self::Regular::{Case1, Case2, Case3}; use self::Univariant::TheOnlyCase; -// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// NOTE: this is a copy of the non-generic test case. The `Txx` type parameters have to be // substituted with something of size `xx` bits and the same alignment as an integer type of the // same size. diff --git a/src/test/debuginfo/generic-tuple-style-enum-legacy.rs b/src/test/debuginfo/generic-tuple-style-enum-legacy.rs index 452e90008ea60..f60e2c654561b 100644 --- a/src/test/debuginfo/generic-tuple-style-enum-legacy.rs +++ b/src/test/debuginfo/generic-tuple-style-enum-legacy.rs @@ -3,7 +3,7 @@ // ignore-gdb-version: 7.11.90 - 7.12.9 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 @@ -59,7 +59,7 @@ use self::Regular::{Case1, Case2, Case3}; use self::Univariant::TheOnlyCase; -// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// NOTE: this is a copy of the non-generic test case. The `Txx` type parameters have to be // substituted with something of size `xx` bits and the same alignment as an integer type of the // same size. diff --git a/src/test/debuginfo/generic-tuple-style-enum.rs b/src/test/debuginfo/generic-tuple-style-enum.rs index 3c136add07915..69176b82eb93c 100644 --- a/src/test/debuginfo/generic-tuple-style-enum.rs +++ b/src/test/debuginfo/generic-tuple-style-enum.rs @@ -48,7 +48,7 @@ use self::Regular::{Case1, Case2, Case3}; use self::Univariant::TheOnlyCase; -// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// NOTE: this is a copy of the non-generic test case. The `Txx` type parameters have to be // substituted with something of size `xx` bits and the same alignment as an integer type of the // same size. diff --git a/src/test/debuginfo/issue-12886.rs b/src/test/debuginfo/issue-12886.rs index 892f7d9485f9c..2bc96a8edbc1e 100644 --- a/src/test/debuginfo/issue-12886.rs +++ b/src/test/debuginfo/issue-12886.rs @@ -1,4 +1,4 @@ -// ignore-windows failing on 64-bit bots FIXME #17638 +// ignore-windows FIXME(#17638): failing on 64-bit bots // ignore-lldb // ignore-aarch64 @@ -15,11 +15,11 @@ // IF YOU MODIFY THIS FILE, BE CAREFUL TO ADAPT THE LINE NUMBERS IN THE DEBUGGER COMMANDS // This test makes sure that gdb does not set unwanted breakpoints in inlined functions. If a -// breakpoint existed in unwrap(), then calling `next` would (when stopped at `let s = ...`) stop -// in unwrap() instead of stepping over the function invocation. By making sure that `s` is +// breakpoint existed in `unwrap()`, then calling `next` would (when stopped at `let s = ...`) stop +// in `unwrap()` instead of stepping over the function invocation. By making sure that `s` is // contained in the output, after calling `next` just once, we can be sure that we did not stop in -// unwrap(). (The testing framework doesn't allow for checking that some text is *not* contained in -// the output, which is why we have to make the test in this kind of roundabout way) +// `unwrap()`. (The testing framework doesn't allow for checking that some text is *not* contained +// in the output, which is why we have to make the test in this kind of roundabout way.) fn bar() -> isize { let s = Some(5).unwrap(); // #break s diff --git a/src/test/debuginfo/issue-22656.rs b/src/test/debuginfo/issue-22656.rs index 86d31909a0b3b..b0a5dc96a1c49 100644 --- a/src/test/debuginfo/issue-22656.rs +++ b/src/test/debuginfo/issue-22656.rs @@ -1,4 +1,4 @@ -// This test makes sure that the LLDB pretty printer does not throw an exception +// This test makes sure that the LLDB pretty-printer does not throw an exception // when trying to handle a Vec<> or anything else that contains zero-sized // fields. diff --git a/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs b/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs index d6b947fad8e12..ec5acfc3c15e5 100644 --- a/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs +++ b/src/test/debuginfo/lexical-scope-in-parameterless-closure.rs @@ -5,7 +5,7 @@ // gdb-command:run // lldb-command:run -// Nothing to do here really, just make sure it compiles. See issue #8513. +// Nothing to do here really; just make sure it compiles (see issue #8513). fn main() { let _ = ||(); let _ = (1_usize..3).map(|_| 5); diff --git a/src/test/debuginfo/lexical-scope-with-macro.rs b/src/test/debuginfo/lexical-scope-with-macro.rs index 3dab7939265ac..ee3c8885f5904 100644 --- a/src/test/debuginfo/lexical-scope-with-macro.rs +++ b/src/test/debuginfo/lexical-scope-with-macro.rs @@ -1,5 +1,5 @@ // min-lldb-version: 310 -// ignore-lldb FIXME #48807 +// ignore-lldb FIXME(#48807) // compile-flags:-g -Zdebug-macros diff --git a/src/test/debuginfo/macro-stepping.rs b/src/test/debuginfo/macro-stepping.rs index e4b2b7b79bcb9..a3bcaee8b78c7 100644 --- a/src/test/debuginfo/macro-stepping.rs +++ b/src/test/debuginfo/macro-stepping.rs @@ -50,8 +50,8 @@ extern crate macro_stepping; // exports new_scope!() // lldb-command:set set stop-line-count-before 0 // lldb-command:set set stop-line-count-after 1 -// Can't set both to zero or lldb will stop printing source at all. So it will output the current -// line and the next. We deal with this by having at least 2 lines between the #loc's +// Can't set both to zero or lldb will stop printing source at all. So it will output the current +// line and the next. We deal with this by having at least 2 lines between the #loc's // lldb-command:run // lldb-command:next diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs index f8997fad9a53f..86df246d34f88 100644 --- a/src/test/debuginfo/pretty-std-collections.rs +++ b/src/test/debuginfo/pretty-std-collections.rs @@ -4,7 +4,7 @@ // ignore-android: FIXME(#10381) // compile-flags:-g -// The pretty printers being tested here require the patch from +// The pretty-printers being tested here require the patch from // https://sourceware.org/bugzilla/show_bug.cgi?id=21763 // min-gdb-version 8.1 diff --git a/src/test/debuginfo/recursive-struct-legacy.rs b/src/test/debuginfo/recursive-struct-legacy.rs index 99286708ae243..54d9c3763c4f2 100644 --- a/src/test/debuginfo/recursive-struct-legacy.rs +++ b/src/test/debuginfo/recursive-struct-legacy.rs @@ -2,7 +2,7 @@ // ignore-lldb // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/struct-style-enum-legacy.rs b/src/test/debuginfo/struct-style-enum-legacy.rs index 1433493fd5d0f..0a5eb8cb5d716 100644 --- a/src/test/debuginfo/struct-style-enum-legacy.rs +++ b/src/test/debuginfo/struct-style-enum-legacy.rs @@ -2,7 +2,7 @@ // min-lldb-version: 310 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/tuple-style-enum-legacy.rs b/src/test/debuginfo/tuple-style-enum-legacy.rs index ebc8e03443881..68dace7b27fdc 100644 --- a/src/test/debuginfo/tuple-style-enum-legacy.rs +++ b/src/test/debuginfo/tuple-style-enum-legacy.rs @@ -2,7 +2,7 @@ // min-lldb-version: 310 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/unique-enum-legacy.rs b/src/test/debuginfo/unique-enum-legacy.rs index e7c9357752897..6888b4bcd88e1 100644 --- a/src/test/debuginfo/unique-enum-legacy.rs +++ b/src/test/debuginfo/unique-enum-legacy.rs @@ -2,7 +2,7 @@ // min-lldb-version: 310 // As long as LLVM 5 and LLVM 6 are supported, we want to test the -// enum debuginfo fallback mode. Once those are desupported, this +// enum debuginfo fallback mode. Once those are desupported, this // test can be removed, as there is another (non-"legacy") test that // tests the new mode. // ignore-llvm-version: 7.0 - 9.9.9 diff --git a/src/test/debuginfo/vec-slices.rs b/src/test/debuginfo/vec-slices.rs index 8d9fc498882d3..93b888e296815 100644 --- a/src/test/debuginfo/vec-slices.rs +++ b/src/test/debuginfo/vec-slices.rs @@ -59,12 +59,12 @@ // gdbg-check:$15 = {64, 65} // gdbr-check:$15 = [64, 65] -//gdb-command:print mut_slice.length -//gdb-check:$16 = 5 -//gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) -//gdbr-command:print *(mut_slice.data_ptr as &[i64; 5]) -//gdbg-check:$17 = {1, 2, 3, 4, 5} -//gdbr-check:$17 = [1, 2, 3, 4, 5] +// gdb-command:print mut_slice.length +// gdb-check:$16 = 5 +// gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) +// gdbr-command:print *(mut_slice.data_ptr as &[i64; 5]) +// gdbg-check:$17 = {1, 2, 3, 4, 5} +// gdbr-check:$17 = [1, 2, 3, 4, 5] // === LLDB TESTS ================================================================================== diff --git a/src/test/incremental/change_add_field/struct_point.rs b/src/test/incremental/change_add_field/struct_point.rs index 182e6cb45be64..fe680a7bc4e07 100644 --- a/src/test/incremental/change_add_field/struct_point.rs +++ b/src/test/incremental/change_add_field/struct_point.rs @@ -1,7 +1,7 @@ -// Test where we change a type definition by adding a field. Fns with -// this type in their signature are recompiled, as are their callers. -// Fns with that type used only in their body are also recompiled, but -// their callers are not. +// Test where we change a type definition by adding a field. Functions +// with this type in their signature are recompiled, as are their callers. +// Functions with that type used only in their body are also recompiled, +// but their callers are not. // revisions:cfail1 cfail2 // compile-flags: -Z query-dep-graph diff --git a/src/test/incremental/extern_static/issue-49153.rs b/src/test/incremental/extern_static/issue-49153.rs index f1dbac288853e..c17ef275f7d5b 100644 --- a/src/test/incremental/extern_static/issue-49153.rs +++ b/src/test/incremental/extern_static/issue-49153.rs @@ -1,5 +1,3 @@ -// https://github.com/rust-lang/rust/issues/49153 - // revisions:rpass1 rpass2 extern "C" { diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index 294476258ab95..fbb8f4e443cdc 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -474,7 +474,7 @@ enum EnumAddTraitBound { -// Add a lifetime bound to a lifetime parameter in where clause --------------- +// Add a lifetime bound to a lifetime parameter in where-clause --------------- #[cfg(cfail1)] enum EnumAddLifetimeParameterBoundWhere<'a, 'b> { Variant1(&'a u32), @@ -491,7 +491,7 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a { -// Add a lifetime bound to a type parameter in where clause ------------------- +// Add a lifetime bound to a type parameter in where-clause ------------------- #[cfg(cfail1)] enum EnumAddLifetimeBoundToParameterWhere<'a, T> { Variant1(T), @@ -508,7 +508,7 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a { -// Add a trait bound to a type parameter in where clause ---------------------- +// Add a trait bound to a type parameter in where-clause ---------------------- #[cfg(cfail1)] enum EnumAddTraitBoundWhere { Variant1(S), @@ -570,7 +570,7 @@ struct ReferencedType2; -// Change field type in tuple-style variant indirectly by modifying a use statement +// Change field type in tuple-style variant indirectly by modifying a use-statement mod change_field_type_indirectly_tuple_style { #[cfg(cfail1)] use super::ReferencedType1 as FieldType; @@ -588,7 +588,7 @@ mod change_field_type_indirectly_tuple_style { -// Change field type in record-style variant indirectly by modifying a use statement +// Change field type in record-style variant indirectly by modifying a use-statement mod change_field_type_indirectly_struct_style { #[cfg(cfail1)] use super::ReferencedType1 as FieldType; @@ -611,7 +611,7 @@ trait ReferencedTrait2 {} -// Change trait bound of type parameter indirectly by modifying a use statement +// Change trait bound of type parameter indirectly by modifying a use-statement mod change_trait_bound_indirectly { #[cfg(cfail1)] use super::ReferencedTrait1 as Trait; @@ -627,7 +627,7 @@ mod change_trait_bound_indirectly { -// Change trait bound of type parameter in where clause indirectly by modifying a use statement +// Change trait bound of type parameter in where-clause indirectly by modifying a use-statement mod change_trait_bound_indirectly_where { #[cfg(cfail1)] use super::ReferencedTrait1 as Trait; diff --git a/src/test/incremental/hashes/function_interfaces.rs b/src/test/incremental/hashes/function_interfaces.rs index 4330b0025a251..0a776519aab52 100644 --- a/src/test/incremental/hashes/function_interfaces.rs +++ b/src/test/incremental/hashes/function_interfaces.rs @@ -332,7 +332,7 @@ pub mod change_trait_bound_indirectly { } -// Change Trait Bound Indirectly In Where Clause ------------------------------- +// Change Trait Bound Indirectly In where-clause ------------------------------- pub mod change_trait_bound_indirectly_in_where_clause { #[cfg(cfail1)] diff --git a/src/test/incremental/hashes/struct_defs.rs b/src/test/incremental/hashes/struct_defs.rs index 9fca1ce1c46fe..34a6b4c81dbfd 100644 --- a/src/test/incremental/hashes/struct_defs.rs +++ b/src/test/incremental/hashes/struct_defs.rs @@ -437,7 +437,7 @@ mod change_trait_bound_indirectly { struct Struct(T); } -// Change Trait Bound Indirectly In Where Clause ------------------------------- +// Change Trait Bound Indirectly In where-clause ------------------------------- mod change_trait_bound_indirectly_in_where_clause { #[cfg(cfail1)] use super::ReferencedTrait1 as Trait; diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index da57b485beb8a..7e856cb3832bc 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -134,7 +134,7 @@ trait TraitChangeMethodParameterName { #[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] trait TraitChangeMethodParameterName { - // FIXME(#38501) This should preferably always be clean. + // FIXME(#38501): this should preferably always be clean. #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] fn method(b: u32); @@ -852,7 +852,7 @@ struct ReferenceType1 {} -// Add trait bound to type parameter of trait in where clause---------------------- +// Add trait bound to type parameter of trait in where-clause---------------------- #[cfg(cfail1)] trait TraitAddTraitBoundToTypeParameterOfTraitWhere { } @@ -863,7 +863,7 @@ trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 -// Add lifetime bound to type parameter of trait in where clause------------------- +// Add lifetime bound to type parameter of trait in where-clause------------------- #[cfg(cfail1)] trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { } @@ -874,7 +874,7 @@ trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } -// Add lifetime bound to lifetime parameter of trait in where clause--------------- +// Add lifetime bound to lifetime parameter of trait in where-clause--------------- #[cfg(cfail1)] trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { } @@ -885,7 +885,7 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b -// Add builtin bound to type parameter of trait in where clause-------------------- +// Add builtin bound to type parameter of trait in where-clause-------------------- #[cfg(cfail1)] trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere { } @@ -896,7 +896,7 @@ trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } -// Add second trait bound to type parameter of trait in where clause--------------- +// Add second trait bound to type parameter of trait in where-clause--------------- #[cfg(cfail1)] trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } @@ -908,7 +908,7 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere -// Add second lifetime bound to type parameter of trait in where clause------------ +// Add second lifetime bound to type parameter of trait in where-clause------------ #[cfg(cfail1)] trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { } @@ -919,7 +919,7 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: -// Add second lifetime bound to lifetime parameter of trait in where clause-------- +// Add second lifetime bound to lifetime parameter of trait in where-clause-------- #[cfg(cfail1)] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { } @@ -930,7 +930,7 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> whe -// Add second builtin bound to type parameter of trait in where clause------------- +// Add second builtin bound to type parameter of trait in where-clause------------- #[cfg(cfail1)] trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } @@ -940,7 +940,7 @@ trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send + Sync { } -// Change return type of method indirectly by modifying a use statement------------ +// Change return type of method indirectly by modifying a use-statement------------ mod change_return_type_of_method_indirectly_use { #[cfg(cfail1)] use super::ReferenceType0 as ReturnType; @@ -958,7 +958,7 @@ mod change_return_type_of_method_indirectly_use { -// Change type of method parameter indirectly by modifying a use statement--------- +// Change type of method parameter indirectly by modifying a use-statement--------- mod change_method_parameter_type_indirectly_by_use { #[cfg(cfail1)] use super::ReferenceType0 as ArgType; @@ -976,7 +976,7 @@ mod change_method_parameter_type_indirectly_by_use { -// Change trait bound of method type parameter indirectly by modifying a use statement +// Change trait bound of method type parameter indirectly by modifying a use-statement mod change_method_parameter_type_bound_indirectly_by_use { #[cfg(cfail1)] use super::ReferencedTrait0 as Bound; @@ -994,8 +994,8 @@ mod change_method_parameter_type_bound_indirectly_by_use { -// Change trait bound of method type parameter in where clause indirectly -// by modifying a use statement +// Change trait bound of method type parameter in where-clause indirectly +// by modifying a use-statement mod change_method_parameter_type_bound_indirectly_by_use_where { #[cfg(cfail1)] use super::ReferencedTrait0 as Bound; @@ -1013,7 +1013,7 @@ mod change_method_parameter_type_bound_indirectly_by_use_where { -// Change trait bound of trait type parameter indirectly by modifying a use statement +// Change trait bound of trait type parameter indirectly by modifying a use-statement mod change_method_type_parameter_bound_indirectly { #[cfg(cfail1)] use super::ReferencedTrait0 as Bound; @@ -1029,8 +1029,8 @@ mod change_method_type_parameter_bound_indirectly { -// Change trait bound of trait type parameter in where clause indirectly -// by modifying a use statement +// Change trait bound of trait type parameter in where-clause indirectly +// by modifying a use-statement mod change_method_type_parameter_bound_indirectly_where { #[cfg(cfail1)] use super::ReferencedTrait0 as Bound; diff --git a/src/test/incremental/hashes/type_defs.rs b/src/test/incremental/hashes/type_defs.rs index 4ffa0d9bb7ba7..880dfb6c2057e 100644 --- a/src/test/incremental/hashes/type_defs.rs +++ b/src/test/incremental/hashes/type_defs.rs @@ -1,7 +1,7 @@ // This test case tests the incremental compilation hash (ICH) implementation // for `type` definitions. -// The general pattern followed here is: Change one thing between rev1 and rev2 +// The general pattern followed here is: change one thing between rev1 and rev2 // and make sure that the hash has changed, then change nothing between rev2 and // rev3 and make sure that the hash has not changed. @@ -141,7 +141,7 @@ type AddTypeParamBound = (T1, u32); -// Add type param bound in where clause ---------------------------------------- +// Add type param bound in where-clause ---------------------------------------- #[cfg(cfail1)] type AddTypeParamBoundWhereClause where T1: Clone = (T1, u32); @@ -174,7 +174,7 @@ type AddLifetimeParamBound<'a, 'b: 'a> = (&'a u32, &'b u32); -// Add lifetime param bound in where clause ------------------------------------ +// Add lifetime param bound in where-clause ------------------------------------ #[cfg(cfail1)] type AddLifetimeParamBoundWhereClause<'a, 'b, 'c> where 'b: 'a @@ -190,7 +190,7 @@ where 'b: 'a, -// Change Trait Bound Indirectly ----------------------------------------------- +// Change trait bound Indirectly ----------------------------------------------- trait ReferencedTrait1 {} trait ReferencedTrait2 {} @@ -207,7 +207,7 @@ mod change_trait_bound_indirectly { -// Change Trait Bound Indirectly In Where Clause ------------------------------- +// Change trait bound indirectly in where-clause ------------------------------- mod change_trait_bound_indirectly_in_where_clause { #[cfg(cfail1)] use super::ReferencedTrait1 as Trait; diff --git a/src/test/incremental/inlined_hir_34991/main.rs b/src/test/incremental/inlined_hir_34991/main.rs index 819b8434b0839..7e3c43c70e5d1 100644 --- a/src/test/incremental/inlined_hir_34991/main.rs +++ b/src/test/incremental/inlined_hir_34991/main.rs @@ -1,7 +1,7 @@ // Regression test for #34991: an ICE occurred here because we inline -// some of the vector routines and give them a local def-id `X`. This +// some of the vector routines and give them a local `DefId` `X`. This // got hashed after codegen (`Hir(X)`). When we load back up, we get an -// error because the `X` is remapped to the original def-id (in +// error because the `X` is remapped to the original `DefId` (in // libstd), and we can't hash a HIR node from std. // revisions:rpass1 rpass2 diff --git a/src/test/incremental/issue-38222.rs b/src/test/incremental/issue-38222.rs index df08661c1500e..42073a1adcd44 100644 --- a/src/test/incremental/issue-38222.rs +++ b/src/test/incremental/issue-38222.rs @@ -1,16 +1,13 @@ -// Test that debuginfo does not introduce a dependency edge to the Krate -// dep-node. +// Test that debuginfo does not introduce a dependency edge to the crate dep-node. // revisions:rpass1 rpass2 // compile-flags: -Z query-dep-graph - #![feature(rustc_attrs)] - #![rustc_partition_reused(module="issue_38222-mod1", cfg="rpass2")] -// If codegen had added a dependency edge to the Krate dep-node, nothing would +// If codegen had added a dependency edge to the crate dep-node, nothing would // be re-used, so checking that this module was re-used is sufficient. #![rustc_partition_reused(module="issue_38222", cfg="rpass2")] diff --git a/src/test/incremental/issue-49043.rs b/src/test/incremental/issue-49043.rs index 50d8fb8693077..337f976c289d5 100644 --- a/src/test/incremental/issue-49043.rs +++ b/src/test/incremental/issue-49043.rs @@ -1,7 +1,7 @@ -// Regression test for hashing involving canonical variables. In this -// test -- which has an intensional error -- the type of the value +// Regression test for hashing involving canonical variables. In this +// test, which has an intentional error, the type of the value // being dropped winds up including a type variable. Canonicalization -// would then produce a `?0` which -- in turn -- triggered an ICE in +// would then produce a `?0`, which in turn triggered an ICE during // hashing. // revisions:cfail1 diff --git a/src/test/incremental/krate-inlined.rs b/src/test/incremental/krate-inlined.rs index dfb18166ae950..314bbd1339e56 100644 --- a/src/test/incremental/krate-inlined.rs +++ b/src/test/incremental/krate-inlined.rs @@ -1,4 +1,4 @@ -// Regr. test that using HIR inlined from another krate does *not* add +// Regr. test that using HIR inlined from another krate does **not** add // a dependency from the local Krate node. We can't easily test that // directly anymore, so now we test that we get reuse. diff --git a/src/test/incremental/static_refering_to_other_static/issue-49081.rs b/src/test/incremental/static_refering_to_other_static/issue-49081.rs index 8e3715d1d8341..5a67d87eca873 100644 --- a/src/test/incremental/static_refering_to_other_static/issue-49081.rs +++ b/src/test/incremental/static_refering_to_other_static/issue-49081.rs @@ -1,5 +1,3 @@ -// https://github.com/rust-lang/rust/issues/49081 - // revisions:rpass1 rpass2 pub static A: i32 = 42; diff --git a/src/test/incremental/static_stable_hash/issue-49301.rs b/src/test/incremental/static_stable_hash/issue-49301.rs index fdd05c72ca3cd..d759817d006c0 100644 --- a/src/test/incremental/static_stable_hash/issue-49301.rs +++ b/src/test/incremental/static_stable_hash/issue-49301.rs @@ -1,5 +1,3 @@ -// https://github.com/rust-lang/rust/issues/49081 - // revisions:rpass1 rpass2 #[cfg(rpass1)] diff --git a/src/test/pretty/disamb-stmt-expr.rs b/src/test/pretty/disamb-stmt-expr.rs index 601ca7bb6de1c..1fdbe0a316224 100644 --- a/src/test/pretty/disamb-stmt-expr.rs +++ b/src/test/pretty/disamb-stmt-expr.rs @@ -1,7 +1,7 @@ // pp-exact // Here we check that the parentheses around the body of `wsucc()` are -// preserved. They are needed to disambiguate `{return n+1}; - 0` from +// preserved. They are needed to disambiguate `{return n+1}; - 0` from // `({return n+1}-0)`. fn id(f: F) -> isize where F: Fn() -> isize { f() } diff --git a/src/test/pretty/for-comment.rs b/src/test/pretty/for-comment.rs index 447e7f918c224..2d5cf89136df5 100644 --- a/src/test/pretty/for-comment.rs +++ b/src/test/pretty/for-comment.rs @@ -5,7 +5,7 @@ fn f(v: &[isize]) -> isize { let mut n = 0; for e in v { - n = *e; // This comment once triggered pretty printer bug + n = *e; // This comment once triggered a pretty-printer bug. } n } diff --git a/src/test/pretty/issue-25031.rs b/src/test/pretty/issue-25031.rs index d91494891d4da..1541178f496e5 100644 --- a/src/test/pretty/issue-25031.rs +++ b/src/test/pretty/issue-25031.rs @@ -1,8 +1,7 @@ -// -// Testing that type items with where clauses output correctly. - // pp-exact +// Test that type items with where-clauses output correctly. + fn main() { type Foo where T: Copy = Box; } diff --git a/src/test/pretty/issue-30731.rs b/src/test/pretty/issue-30731.rs index ee81cce864171..6fd009bb049ce 100644 --- a/src/test/pretty/issue-30731.rs +++ b/src/test/pretty/issue-30731.rs @@ -1,5 +1,5 @@ // -// Test pretty printing of macro with braces but without terminating semicolon, +// Test pretty-printing of macro with braces but without terminating semicolon, // this used to panic before fix. // pretty-compare-only diff --git a/src/test/pretty/top-level-doc-comments.rs b/src/test/pretty/top-level-doc-comments.rs index 16f95d334cbcf..828d2ef700068 100644 --- a/src/test/pretty/top-level-doc-comments.rs +++ b/src/test/pretty/top-level-doc-comments.rs @@ -3,11 +3,8 @@ struct X; // ignore-license -// http://rust-lang.org/COPYRIGHT. -// - // pp-exact -// Test that rust can properly pretty print a doc comment if it's the first line in a file. some +// Test that Rust can properly pretty-print a doc comment if it's the first line in a file. fn main() { let x = X; } diff --git a/src/test/run-make-fulldeps/crate-data-smoke/crate.rs b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs index a48a6f51c4234..1966a36de72ca 100644 --- a/src/test/run-make-fulldeps/crate-data-smoke/crate.rs +++ b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// Querying about the crate metadata should *not* parse the entire crate, it +// Querying about the crate metadata should **not** parse the entire crate, it // only needs the crate attributes (which are guaranteed to be at the top) be // sure that if we have an error like a missing module that we can still query -// about the crate id. +// about the crate ID. mod error; diff --git a/src/test/run-make-fulldeps/libtest-json/output.json b/src/test/run-make-fulldeps/libtest-json/output.json index c8b3d08186929..0caf268aa007f 100644 --- a/src/test/run-make-fulldeps/libtest-json/output.json +++ b/src/test/run-make-fulldeps/libtest-json/output.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:8:5\nnote: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:8:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } diff --git a/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs b/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs index d32fafd215c07..d3e1bfab99317 100644 --- a/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs +++ b/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs @@ -272,7 +272,7 @@ fn run() { reject_stmt_parse("#[attr] #![attr] foo![]"); reject_stmt_parse("#[attr] #![attr] foo!{}"); - // FIXME: Allow attributes in pattern constexprs? + // FIXME: allow attributes in pattern constexprs? // note: requires parens in patterns to allow disambiguation reject_expr_parse("match 0 { diff --git a/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs b/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs index 216c81ca34ce5..c1871013eb5e2 100644 --- a/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs +++ b/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs @@ -11,15 +11,16 @@ extern crate rustc_plugin; use syntax::parse::token; use syntax::tokenstream::TokenTree; use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; -use syntax::ext::build::AstBuilder; // trait for expr_usize +use syntax::ext::build::AstBuilder; // trait for `expr_usize` use syntax_pos::Span; use rustc_plugin::Registry; // WARNING WARNING WARNING WARNING WARNING // ======================================= // -// This code also appears in src/doc/unstable-book/src/language-features/plugin.md. -// Please keep the two copies in sync! FIXME: have rustdoc read this file +// This code also appears in `src/doc/unstable-book/src/language-features/plugin.md`. +// Please keep the two copies in sync! +// FIXME: have rustdoc read this file. fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box { diff --git a/src/test/run-pass-fulldeps/issue-15149.rs b/src/test/run-pass-fulldeps/issue-15149.rs index 2a62fabf53d3a..acf70faf2e435 100644 --- a/src/test/run-pass-fulldeps/issue-15149.rs +++ b/src/test/run-pass-fulldeps/issue-15149.rs @@ -12,7 +12,7 @@ fn main() { // If we're the child, make sure we were invoked correctly let args: Vec = env::args().collect(); if args.len() > 1 && args[1] == "child" { - // FIXME: This should check the whole `args[0]` instead of just + // FIXME: this should check the whole `args[0]` instead of just // checking that it ends_with the executable name. This // is needed because of Windows, which has a different behavior. // See #15149 for more info. diff --git a/src/test/run-pass-fulldeps/issue-15778-pass.rs b/src/test/run-pass-fulldeps/issue-15778-pass.rs index 50e9b14b26832..4e860d33047e8 100644 --- a/src/test/run-pass-fulldeps/issue-15778-pass.rs +++ b/src/test/run-pass-fulldeps/issue-15778-pass.rs @@ -10,4 +10,4 @@ #![rustc_crate_grey] #![rustc_crate_green] -pub fn main() { } +pub fn main() {} diff --git a/src/test/run-pass-fulldeps/issue-15924.rs b/src/test/run-pass-fulldeps/issue-15924.rs index 9d807533f429d..e42944d8cb2ce 100644 --- a/src/test/run-pass-fulldeps/issue-15924.rs +++ b/src/test/run-pass-fulldeps/issue-15924.rs @@ -1,6 +1,6 @@ #![allow(unused_imports)] #![allow(unused_must_use)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(rustc_private)] diff --git a/src/test/run-pass-fulldeps/issue-4036.rs b/src/test/run-pass-fulldeps/issue-4036.rs index 0cbd8adf977d8..5d836a4d0b989 100644 --- a/src/test/run-pass-fulldeps/issue-4036.rs +++ b/src/test/run-pass-fulldeps/issue-4036.rs @@ -1,7 +1,7 @@ // Issue #4036: Test for an issue that arose around fixing up type inference // byproducts in vtable records. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(rustc_private)] diff --git a/src/test/run-pass-fulldeps/myriad-closures.rs b/src/test/run-pass-fulldeps/myriad-closures.rs index a1ea0e685d659..bc21b354c5586 100644 --- a/src/test/run-pass-fulldeps/myriad-closures.rs +++ b/src/test/run-pass-fulldeps/myriad-closures.rs @@ -1,7 +1,7 @@ // This test case tests whether we can handle code bases that contain a high // number of closures, something that needs special handling in the MingGW // toolchain. -// See https://github.com/rust-lang/rust/issues/34793 for more information. +// See issue #34793 for more information. // Make sure we don't optimize anything away: // compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals diff --git a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs index 956bc5ad862ca..18c36cceeda67 100644 --- a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs @@ -1,23 +1,21 @@ // ignore-cross-compile - // The general idea of this test is to enumerate all "interesting" expressions and check that -// `parse(print(e)) == e` for all `e`. Here's what's interesting, for the purposes of this test: +// `parse(print(e)) == e` for all `e`. Here's what's interesting, for the purposes of this test: // // 1. The test focuses on expression nesting, because interactions between different expression // types are harder to test manually than single expression types in isolation. // -// 2. The test only considers expressions of at most two nontrivial nodes. So it will check `x + -// x` and `x + (x - x)` but not `(x * x) + (x - x)`. The assumption here is that the correct +// 2. The test only considers expressions of at most two nontrivial nodes. So it will check `x + +// x` and `x + (x - x)` but not `(x * x) + (x - x)`. The assumption here is that the correct // handling of an expression might depend on the expression's parent, but doesn't depend on its // siblings or any more distant ancestors. // -// 3. The test only checks certain expression kinds. The assumption is that similar expression -// types, such as `if` and `while` or `+` and `-`, will be handled identically in the printer -// and parser. So if all combinations of exprs involving `if` work correctly, then combinations +// 3. The test only checks certain expression kinds. The assumption is that similar expression +// types, such as `if` and `while` or `+` and `-`, will be handled identically in the printer +// and parser. So, if all combinations of exprs involving `if` work correctly, then combinations // using `while`, `if let`, and so on will likely work as well. - #![feature(rustc_private)] extern crate rustc_data_structures; @@ -155,7 +153,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P)) { } -// Folders for manipulating the placement of `Paren` nodes. See below for why this is needed. +// Folders for manipulating the placement of `Paren` nodes. See below for why this is needed. /// MutVisitor that removes all `ExprKind::Paren` nodes. struct RemoveParens; @@ -196,7 +194,7 @@ fn run() { let ps = ParseSess::new(FilePathMapping::empty()); iter_exprs(2, &mut |mut e| { - // If the pretty printer is correct, then `parse(print(e))` should be identical to `e`, + // If the pretty-printer is correct, then `parse(print(e))` should be identical to `e`, // modulo placement of `Paren` nodes. let printed = pprust::expr_to_string(&e); println!("printed: {}", printed); @@ -205,8 +203,8 @@ fn run() { // We want to know if `parsed` is structurally identical to `e`, ignoring trivial // differences like placement of `Paren`s or the exact ranges of node spans. - // Unfortunately, there is no easy way to make this comparison. Instead, we add `Paren`s - // everywhere we can, then pretty-print. This should give an unambiguous representation of + // Unfortunately, there is no easy way to make this comparison. Instead, we add `Paren`s + // everywhere we can, then pretty-print. This should give an unambiguous representation of // each `Expr`, and it bypasses nearly all of the parenthesization logic, so we aren't // relying on the correctness of the very thing we're testing. RemoveParens.visit_expr(&mut e); diff --git a/src/test/run-pass-valgrind/coerce-match-calls.rs b/src/test/run-pass-valgrind/coerce-match-calls.rs index 60943aad80dc2..9ee22146b3f5d 100644 --- a/src/test/run-pass-valgrind/coerce-match-calls.rs +++ b/src/test/run-pass-valgrind/coerce-match-calls.rs @@ -1,6 +1,6 @@ // Check that coercions are propagated through match and if expressions. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::boxed::Box; diff --git a/src/test/run-pass-valgrind/coerce-match.rs b/src/test/run-pass-valgrind/coerce-match.rs index a4ba5427d4b04..bc9ea8042de1b 100644 --- a/src/test/run-pass-valgrind/coerce-match.rs +++ b/src/test/run-pass-valgrind/coerce-match.rs @@ -1,6 +1,6 @@ // Check that coercions are propagated through match and if expressions. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass-valgrind/osx-frameworks.rs b/src/test/run-pass-valgrind/osx-frameworks.rs index 4ea804a184474..55c9181976783 100644 --- a/src/test/run-pass-valgrind/osx-frameworks.rs +++ b/src/test/run-pass-valgrind/osx-frameworks.rs @@ -1,5 +1,5 @@ // no-prefer-dynamic -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(rustc_private)] diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index c0fd09cbd40fb..03515f2bec392 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -5,7 +5,7 @@ // Regression test for issue #374 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum sty { ty_nil, } diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index 55f65806ab094..45be5c54339c9 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum option { some(T), none, } diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs index 6d7e3f3cd5c1a..d6279655b8291 100644 --- a/src/test/run-pass/anon-extern-mod.rs +++ b/src/test/run-pass/anon-extern-mod.rs @@ -1,5 +1,5 @@ -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test ffi with +// pretty-expanded FIXME(#23616) +// ignore-wasm32-bare no libc to test FFI with #![feature(rustc_private)] diff --git a/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs b/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs index 6904c29111ee3..dc653da6bfdf0 100644 --- a/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs +++ b/src/test/run-pass/arbitrary_self_types_pointers_and_wrappers.rs @@ -36,7 +36,7 @@ impl, U> DispatchFromDyn> for Wrapper {} trait Trait { // This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable // without unsized_locals), but wrappers arond `Self` currently are not. - // FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented + // FIXME(mikeyhew): uncomment this when unsized rvalues object-safety is implemented. // fn wrapper(self: Wrapper) -> i32; fn ptr_wrapper(self: Ptr>) -> i32; fn wrapper_ptr(self: Wrapper>) -> i32; diff --git a/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs b/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs index d485893281562..1beb58e860337 100644 --- a/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs +++ b/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs @@ -32,11 +32,11 @@ fn main() { assert!(g.join().is_err()); // When the panic occurs, we will be in the midst of constructing - // the input to `_b3`. Therefore, we drop the elements of the + // the input to `_b3`. Therefore, we drop the elements of the // partially filled array first, before we get around to dropping // the elements of `_b1` and _b2`. - // Issue 23222: The order in which the elements actually get + // Issue #23222: The order in which the elements actually get // dropped is a little funky. See similar notes in nested-vec-3; // in essence, I would not be surprised if we change the ordering // given in `expect` in the future. diff --git a/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs b/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs index e8a5b00a55b9c..13b98b52cab09 100644 --- a/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs +++ b/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs @@ -32,11 +32,11 @@ fn main() { assert!(g.join().is_err()); // When the panic occurs, we will be in the midst of constructing - // the input to `_b3`. Therefore, we drop the elements of the + // the input to `_b3`. Therefore, we drop the elements of the // partially filled array first, before we get around to dropping // the elements of `_b1` and _b2`. - // Issue 23222: The order in which the elements actually get + // Issue #23222: The order in which the elements actually get // dropped is a little funky. See similar notes in nested-vec-3; // in essence, I would not be surprised if we change the ordering // given in `expect` in the future. diff --git a/src/test/run-pass/array-slice-vec/cast-in-array-size.rs b/src/test/run-pass/array-slice-vec/cast-in-array-size.rs index b112dcaef3e42..ab1dc65413094 100644 --- a/src/test/run-pass/array-slice-vec/cast-in-array-size.rs +++ b/src/test/run-pass/array-slice-vec/cast-in-array-size.rs @@ -2,7 +2,7 @@ // issues #10618 and #16382 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) const SIZE: isize = 25; diff --git a/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs b/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs index 91ab280b9c7ec..1392be7456b90 100644 --- a/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs +++ b/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_mut)] diff --git a/src/test/run-pass/array-slice-vec/nested-vec-3.rs b/src/test/run-pass/array-slice-vec/nested-vec-3.rs index 52b892dbcdfaf..6d6de8c2094c9 100644 --- a/src/test/run-pass/array-slice-vec/nested-vec-3.rs +++ b/src/test/run-pass/array-slice-vec/nested-vec-3.rs @@ -33,11 +33,11 @@ fn main() { assert!(g.join().is_err()); // When the panic occurs, we will be in the midst of constructing the - // second inner vector. Therefore, we drop the elements of the + // second inner vector. Therefore, we drop the elements of the // partially filled vector first, before we get around to dropping // the elements of the filled vector. - // Issue 23222: The order in which the elements actually get + // Issue #23222: The order in which the elements actually get // dropped is a little funky: as noted above, we'll drop the 9+10 // first, but due to #23222, they get dropped in reverse // order. Likewise, again due to #23222, we will drop the second diff --git a/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs b/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs index 6c95bd50007f5..65fd2b00a9e0f 100644 --- a/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs +++ b/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) macro_rules! vec [ ($($e:expr),*) => ({ diff --git a/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs b/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs index 8179edf420cb0..02d37c20ae99d 100644 --- a/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs +++ b/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs @@ -1,5 +1,7 @@ // run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + +// FIXME(#41620) +#![allow(illegal_floating_point_literal_pattern)] pub fn main() { let x = [1, 2, 3]; diff --git a/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs b/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs index 3e0e18873ab0f..a41b1ebd290d3 100644 --- a/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs +++ b/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let _a = [0; 1 as usize]; } diff --git a/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs b/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs index dd8f402f3f6a5..c4be56ec52d39 100644 --- a/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs +++ b/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/asm-concat-src.rs b/src/test/run-pass/asm-concat-src.rs index b24586464d673..d9c1c1f40bf33 100644 --- a/src/test/run-pass/asm-concat-src.rs +++ b/src/test/run-pass/asm-concat-src.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no asm #![feature(asm)] diff --git a/src/test/run-pass/assign-assign.rs b/src/test/run-pass/assign-assign.rs index ea0337676fc5f..284068fe81164 100644 --- a/src/test/run-pass/assign-assign.rs +++ b/src/test/run-pass/assign-assign.rs @@ -1,4 +1,4 @@ -// Issue 483 - Assignment expressions result in nil +// Issue #483: assignment expressions result in nil. fn test_assign() { let mut x: isize; diff --git a/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs b/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs index c54bc3cd6230c..30ee203ec0ae3 100644 --- a/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs +++ b/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs @@ -1,7 +1,7 @@ // run-pass -// Test equality constraints on associated types in a where clause. +// pretty-expanded FIXME(#23616) -// pretty-expanded FIXME #23616 +// Test equality constraints on associated types in a where-clause. pub trait Foo { type A; @@ -21,7 +21,7 @@ impl Foo for char { fn boo(&self) -> Bar { Bar } } -fn foo_bar>(x: I) -> Bar { +fn foo_bar>(x: I) -> Bar { x.boo() } diff --git a/src/test/run-pass/associated-types/associated-types-bound.rs b/src/test/run-pass/associated-types/associated-types-bound.rs index 0e9a229a5e592..f732155f45aab 100644 --- a/src/test/run-pass/associated-types/associated-types-bound.rs +++ b/src/test/run-pass/associated-types/associated-types-bound.rs @@ -1,6 +1,6 @@ // run-pass -// Test equality constrai32s on associated types in a where clause. +// Test equality constrai32s on associated types in a where-clause. pub trait ToI32 { fn to_i32(&self) -> i32; diff --git a/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs b/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs index 70ee60517ae86..e583441543855 100644 --- a/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs +++ b/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs @@ -5,12 +5,12 @@ // `Target=[A]`, then the impl marked with `(*)` is seen to conflict // with all the others. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::PhantomData; use std::ops::Deref; -pub trait MyEq { +pub trait MyEq { fn eq(&self, u: &U) -> bool; } diff --git a/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs b/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs index 12ca100435a47..0c5aa0d5a0329 100644 --- a/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs +++ b/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs @@ -4,7 +4,7 @@ // (modulo bound lifetime names) appears in the environment // twice. Issue #21965. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(t: T) -> i32 where T : for<'a> Fn(&'a u8) -> i32, diff --git a/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs b/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs index 9ffccd3d8ff0d..c7624048874ac 100644 --- a/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs +++ b/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs @@ -3,7 +3,7 @@ // Check that we do not report ambiguities when the same predicate // appears in the environment twice. Issue #21965. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { type B; diff --git a/src/test/run-pass/associated-types/associated-types-enum-field-named.rs b/src/test/run-pass/associated-types/associated-types-enum-field-named.rs index 896d67213e9b1..95832277b514a 100644 --- a/src/test/run-pass/associated-types/associated-types-enum-field-named.rs +++ b/src/test/run-pass/associated-types/associated-types-enum-field-named.rs @@ -14,7 +14,7 @@ pub enum VarValue { Root { value: K::Value, rank: usize }, } -fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { +fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { match table[key.to_index()] { VarValue::Redirect { to: ref k } => get(table, k), VarValue::Root { value: ref v, rank: _ } => v, diff --git a/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs b/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs index 77ced3c078106..202842b649094 100644 --- a/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs +++ b/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs @@ -14,7 +14,7 @@ pub enum VarValue { Root(K::Value, usize), } -fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { +fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { match table[key.to_index()] { VarValue::Redirect(ref k) => get(table, k), VarValue::Root(ref v, _) => v, diff --git a/src/test/run-pass/associated-types/associated-types-eq-obj.rs b/src/test/run-pass/associated-types/associated-types-eq-obj.rs index 0f3dfe338a33c..c59ad537babe7 100644 --- a/src/test/run-pass/associated-types/associated-types-eq-obj.rs +++ b/src/test/run-pass/associated-types/associated-types-eq-obj.rs @@ -1,7 +1,7 @@ // run-pass // Test equality constraints on associated types inside of an object type -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Foo { type A; @@ -15,7 +15,7 @@ impl Foo for char { fn boo(&self) -> Bar { Bar } } -fn baz(x: &Foo) -> Bar { +fn baz(x: &Foo) -> Bar { x.boo() } diff --git a/src/test/run-pass/associated-types/associated-types-impl-redirect.rs b/src/test/run-pass/associated-types/associated-types-impl-redirect.rs index 8fa20cdf4b7a1..ae6be1b15b8b4 100644 --- a/src/test/run-pass/associated-types/associated-types-impl-redirect.rs +++ b/src/test/run-pass/associated-types/associated-types-impl-redirect.rs @@ -1,16 +1,18 @@ // run-pass -#![allow(dead_code)] -#![allow(unused_mut)] -#![allow(unused_imports)] -// Test how resolving a projection interacts with inference. In this + +// Test how resolving a projection interacts with inference. In this // case, we were eagerly unifying the type variable for the iterator -// type with `I` from the where clause, ignoring the in-scope `impl` +// type with `I` from the where-clause, ignoring the in-scope `impl` // for `ByRef`. The right answer was to consider the result ambiguous // until more type information was available. #![feature(lang_items)] #![no_implicit_prelude] +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_imports)] + use std::marker::Sized; use std::option::Option::{None, Some, self}; @@ -38,14 +40,14 @@ impl<'a, I: Iterator> Iterator for ByRef<'a, I> { } } -fn is_iterator_of>(_: &I) {} +fn is_iterator_of>(_: &I) {} -fn test>(mut it: I) { +fn test>(mut it: I) { is_iterator_of::(&it.by_ref()); } -fn test2, I2: Iterator>(mut it: I2) { +fn test2, I2: Iterator>(mut it: I2) { is_iterator_of::(&it) } -fn main() { } +fn main() {} diff --git a/src/test/run-pass/associated-types/associated-types-issue-20220.rs b/src/test/run-pass/associated-types/associated-types-issue-20220.rs index 19fa7a6085a56..cf280442681a1 100644 --- a/src/test/run-pass/associated-types/associated-types-issue-20220.rs +++ b/src/test/run-pass/associated-types/associated-types-issue-20220.rs @@ -6,7 +6,7 @@ use std::vec; trait IntoIteratorX { type Item; - type IntoIter: Iterator; + type IntoIter: Iterator; fn into_iter_x(self) -> Self::IntoIter; } diff --git a/src/test/run-pass/associated-types/associated-types-issue-20371.rs b/src/test/run-pass/associated-types/associated-types-issue-20371.rs index ae8a8767d2746..9d410a4c17dfa 100644 --- a/src/test/run-pass/associated-types/associated-types-issue-20371.rs +++ b/src/test/run-pass/associated-types/associated-types-issue-20371.rs @@ -2,7 +2,7 @@ // Test that we are able to have an impl that defines an associated type // before the actual trait. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) impl X for f64 { type Y = isize; } trait X { type Y; } diff --git a/src/test/run-pass/associated-types/associated-types-issue-21212.rs b/src/test/run-pass/associated-types/associated-types-issue-21212.rs index ce27eac4d0ebe..720aa2b90ab89 100644 --- a/src/test/run-pass/associated-types/associated-types-issue-21212.rs +++ b/src/test/run-pass/associated-types/associated-types-issue-21212.rs @@ -1,10 +1,11 @@ // run-pass -#![allow(unused_variables)] + // Regression test for #21212: an overflow occurred during trait // checking where normalizing `Self::Input` led to normalizing the -// where clauses in the environment which in turn required normalizing +// where-clauses in the environment which in turn required normalizing // `Self::Input`. +#![allow(unused_variables)] pub trait Parser { type Input; @@ -18,5 +19,4 @@ impl

Parser for P { type Input = (); } -fn main() { -} +fn main() {} diff --git a/src/test/run-pass/associated-types/associated-types-nested-projections.rs b/src/test/run-pass/associated-types/associated-types-nested-projections.rs index 76ba7496250cc..d6ac568888f3d 100644 --- a/src/test/run-pass/associated-types/associated-types-nested-projections.rs +++ b/src/test/run-pass/associated-types/associated-types-nested-projections.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // Test that we can resolve nested projection types. Issue #20666. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::slice; @@ -32,8 +32,8 @@ fn foo(x: X) where fn bar(x: X) where T: Bound, - I: Iterator, - X: IntoIterator, + I: Iterator, + X: IntoIterator, { } diff --git a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs index 7c54efb83c26a..ef5adcd0bb8d6 100644 --- a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs +++ b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs @@ -3,7 +3,7 @@ // Test that we normalize associated types that appear in a bound that // contains a binding. Issue #21664. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs index e09aa3663c6e5..8bafd5125be4b 100644 --- a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs +++ b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs @@ -3,7 +3,7 @@ // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::PhantomData; diff --git a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs index dcfae0f37e1da..d90fa59de350c 100644 --- a/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs +++ b/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs @@ -3,7 +3,7 @@ // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::PhantomData; diff --git a/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs b/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs index 107e6b4ce0ca0..e9c618f16ae2c 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // Test that we correctly handle projection bounds appearing in the // supertrait list (and in conjunction with overloaded operators). In -// this case, the `Result=Self` binding in the supertrait listing of +// this case, the `Result = Self` binding in the supertrait listing of // `Int` was being ignored. trait Not { @@ -11,7 +11,7 @@ trait Not { fn not(self) -> Self::Result; } -trait Int: Not + Sized { +trait Int: Not + Sized { fn count_ones(self) -> usize; fn count_zeros(self) -> usize { // neither works diff --git a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs index 0dc32f2fd94ec..295798ed06ec9 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs @@ -6,7 +6,7 @@ // appear in associated type bindings in object types, which were not // being properly flagged. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ops::{Shl, Shr}; use std::cell::RefCell; @@ -19,7 +19,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } diff --git a/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs b/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs index e9a26e53c3c7d..4367fe9165399 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs @@ -1,9 +1,9 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// Test a where clause that uses a non-normalized projection type. +// Test a where-clause that uses a non-normalized projection type. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Int { @@ -17,7 +17,7 @@ trait NonZero fn non_zero(self) -> bool; } -fn foo,J>(t: I) -> bool +fn foo,J>(t: I) -> bool where ::T : NonZero // ^~~~~~~~~~~~~ canonical form is just J { diff --git a/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs b/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs index 5f06a829600af..c019df2d63867 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs @@ -12,7 +12,7 @@ trait Get { } trait Other { - fn okay(&self, foo: U, bar: ::Value) + fn ok(&self, foo: U, bar: ::Value) where Self: Get; } @@ -25,11 +25,11 @@ impl Get for f64 { } impl Other for () { - fn okay(&self, _foo: U, _bar: ::Value) { } + fn ok(&self, _foo: U, _bar: ::Value) { } } impl Other for f64 { - fn okay(&self, _foo: U, _bar: ::Value) { } + fn ok(&self, _foo: U, _bar: ::Value) { } } fn main() { } diff --git a/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs b/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs index 3c830d37060ab..4f3a437287d0b 100644 --- a/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs +++ b/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { type Bar; diff --git a/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs b/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs index 3ccba289e4b0a..db0c02522f07e 100644 --- a/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs +++ b/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs @@ -1,7 +1,7 @@ // run-pass // Test associated type references in structure fields. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Test { type V; diff --git a/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs b/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs index b722506dbbf0e..ae7219c2b4d87 100644 --- a/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs +++ b/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs @@ -3,7 +3,7 @@ // Regression test for #20582. This test caused an ICE related to // inconsistent region erasure in codegen. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo<'a> { buf: &'a[u8] diff --git a/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs b/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs index 52f2324d72ab7..74ef7db7c7121 100644 --- a/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs +++ b/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Get { fn get(&self) -> T; diff --git a/src/test/run-pass/associated-types/associated-types-return.rs b/src/test/run-pass/associated-types/associated-types-return.rs index 997a48b0379a9..0c94e8cc3ecb3 100644 --- a/src/test/run-pass/associated-types/associated-types-return.rs +++ b/src/test/run-pass/associated-types/associated-types-return.rs @@ -1,5 +1,5 @@ // run-pass -// Test equality constraints on associated types in a where clause. +// Test equality constraints on associated types in a where-clause. pub trait Foo { @@ -25,7 +25,7 @@ impl Foo for char { fn boo(&self) -> Bar { Bar } } -fn foo1>(x: I) -> Bar { +fn foo1>(x: I) -> Bar { x.boo() } diff --git a/src/test/run-pass/associated-types/associated-types-struct-field-named.rs b/src/test/run-pass/associated-types/associated-types-struct-field-named.rs index c400bf943e182..28b0fe313e29d 100644 --- a/src/test/run-pass/associated-types/associated-types-struct-field-named.rs +++ b/src/test/run-pass/associated-types/associated-types-struct-field-named.rs @@ -14,7 +14,7 @@ pub struct Node { pub value: K::Value, } -fn foo>,V : Clone>(node: &Node) -> Option { +fn foo>,V : Clone>(node: &Node) -> Option { node.value.clone() } diff --git a/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs b/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs index fa59060629ddf..8a1b9755e977b 100644 --- a/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs +++ b/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs @@ -11,7 +11,7 @@ pub trait UnifyKey { pub struct Node(K, K::Value); -fn foo>,V : Clone>(node: &Node) -> Option { +fn foo>,V : Clone>(node: &Node) -> Option { node.1.clone() } diff --git a/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs b/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs index f2a4c6e42a93f..ef5fa2b3128ca 100644 --- a/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs +++ b/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs @@ -1,9 +1,9 @@ // run-pass #![allow(dead_code)] #![allow(unused_imports)] -// Test how resolving a projection interacts with inference. In this +// Test how resolving a projection interacts with inference. In this // case, we were eagerly unifying the type variable for the iterator -// type with `I` from the where clause, ignoring the in-scope `impl` +// type with `I` from the where-clause, ignoring the in-scope `impl` // for `ByRef`. The right answer was to consider the result ambiguous // until more type information was available. @@ -29,7 +29,7 @@ impl IteratorExt for I where I: Iterator {} struct ByRef<'a, I: 'a + Iterator>(&'a mut I); -impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator { +impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator { type Item = A; fn next(&mut self) -> Option< ::Item > { @@ -37,9 +37,9 @@ impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator { } } -fn is_iterator_of>(_: &I) {} +fn is_iterator_of>(_: &I) {} -fn test>(mut it: I) { +fn test>(mut it: I) { is_iterator_of::(&it.by_ref()); } diff --git a/src/test/run-pass/attr-before-view-item.rs b/src/test/run-pass/attr-before-view-item.rs index 14b4189684f9c..cecfe1fca7269 100644 --- a/src/test/run-pass/attr-before-view-item.rs +++ b/src/test/run-pass/attr-before-view-item.rs @@ -1,6 +1,6 @@ #![allow(unused_attributes)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(custom_attribute, test)] diff --git a/src/test/run-pass/attr-before-view-item2.rs b/src/test/run-pass/attr-before-view-item2.rs index 6fc1e35d47ac5..304f9738cc082 100644 --- a/src/test/run-pass/attr-before-view-item2.rs +++ b/src/test/run-pass/attr-before-view-item2.rs @@ -1,6 +1,6 @@ #![allow(unused_attributes)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(custom_attribute, test)] diff --git a/src/test/run-pass/attr-main.rs b/src/test/run-pass/attr-main.rs index 645baf32e0458..9e93479ad83c7 100644 --- a/src/test/run-pass/attr-main.rs +++ b/src/test/run-pass/attr-main.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(main)] diff --git a/src/test/run-pass/attr-mix-new.rs b/src/test/run-pass/attr-mix-new.rs index 223a434dbb9e7..b103989c4f4d2 100644 --- a/src/test/run-pass/attr-mix-new.rs +++ b/src/test/run-pass/attr-mix-new.rs @@ -1,7 +1,7 @@ #![allow(unused_attributes)] #![allow(unknown_lints)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_attribute)] #![feature(custom_attribute)] diff --git a/src/test/run-pass/attr-start.rs b/src/test/run-pass/attr-start.rs index 29f86c9b59e99..fe60fd4aa41f4 100644 --- a/src/test/run-pass/attr-start.rs +++ b/src/test/run-pass/attr-start.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(start)] diff --git a/src/test/run-pass/attr.rs b/src/test/run-pass/attr.rs index 645baf32e0458..9e93479ad83c7 100644 --- a/src/test/run-pass/attr.rs +++ b/src/test/run-pass/attr.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(main)] diff --git a/src/test/run-pass/augmented-assignments.rs b/src/test/run-pass/augmented-assignments.rs index c26d0ffce4469..5690627a8f401 100644 --- a/src/test/run-pass/augmented-assignments.rs +++ b/src/test/run-pass/augmented-assignments.rs @@ -62,20 +62,20 @@ fn main() { x -= Int(1); assert_eq!(x, Int(0)); - // indexed LHS + // Indexed LHS. let mut v = vec![Int(1), Int(2)]; v[0] += Int(2); assert_eq!(v[0], Int(3)); - // unsized RHS + // Unsized RHS. let mut array = [0, 1, 2]; *Slice::new(&mut array) += 1; assert_eq!(array[0], 1); assert_eq!(array[1], 2); assert_eq!(array[2], 3); - // sized indirection - // check that this does *not* trigger the unused_assignments lint + // Sized indirection. + // Check that this does **not** trigger the `unused_assignments` lint. let mut array = [0, 1, 2]; let mut view = View(&mut array); view += 1; diff --git a/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs b/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs index 874f4228277e1..8b9a6b9d3ec71 100644 --- a/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs +++ b/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo { x: isize, diff --git a/src/test/run-pass/auxiliary/foreign_lib.rs b/src/test/run-pass/auxiliary/foreign_lib.rs index de6b0e2118a58..be1a6b78cf4f5 100644 --- a/src/test/run-pass/auxiliary/foreign_lib.rs +++ b/src/test/run-pass/auxiliary/foreign_lib.rs @@ -23,7 +23,7 @@ pub mod rustrt3 { // Different type, but same ABI (on all supported platforms). // Ensures that we don't ICE or trigger LLVM asserts when // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. + // See issue #32740. extern { pub fn rust_get_test_int() -> *const u8; } diff --git a/src/test/run-pass/auxiliary/kinds_in_metadata.rs b/src/test/run-pass/auxiliary/kinds_in_metadata.rs index 2a2106ff70ac6..2469657ba41bf 100644 --- a/src/test/run-pass/auxiliary/kinds_in_metadata.rs +++ b/src/test/run-pass/auxiliary/kinds_in_metadata.rs @@ -1,6 +1,3 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - // Tests that metadata serialization works for the `Copy` kind. #![crate_type="lib"] diff --git a/src/test/run-pass/auxiliary/nested_item.rs b/src/test/run-pass/auxiliary/nested_item.rs index 9db9d19d6f610..53ae251302b74 100644 --- a/src/test/run-pass/auxiliary/nested_item.rs +++ b/src/test/run-pass/auxiliary/nested_item.rs @@ -6,7 +6,7 @@ pub fn foo() -> isize { } } -// issue 8134 +// issue #8134 struct Foo; impl Foo { pub fn foo(&self) { @@ -14,7 +14,7 @@ impl Foo { } } -// issue 8134 +// issue #8134 pub struct Parser(T); impl> Parser { fn in_doctype(&mut self) { diff --git a/src/test/run-pass/auxiliary/weak-lang-items.rs b/src/test/run-pass/auxiliary/weak-lang-items.rs index 7a698cf76ae51..c5181f3b6719e 100644 --- a/src/test/run-pass/auxiliary/weak-lang-items.rs +++ b/src/test/run-pass/auxiliary/weak-lang-items.rs @@ -1,6 +1,6 @@ // no-prefer-dynamic -// This aux-file will require the eh_personality function to be codegen'd, but +// This aux-file will require the `eh_personality` function to be codegen'ed, but // it hasn't been defined just yet. Make sure we don't explode. #![no_std] diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index da3871aba095c..99bb4efaf5baa 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -1,4 +1,4 @@ -// ignore-android FIXME #17520 +// ignore-android FIXME(#17520) // ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-openbsd no support for libbacktrace without filename @@ -42,7 +42,7 @@ fn expected(fn_name: &str) -> String { } fn runtest(me: &str) { - // Make sure that the stack trace is printed + // Make sure that the stack trace is printed. let p = template(me).arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); @@ -51,7 +51,7 @@ fn runtest(me: &str) { "bad output: {}", s); assert!(s.contains(" 0:"), "the frame number should start at 0"); - // Make sure the stack trace is *not* printed + // Make sure the stack trace is **not** printed. // (Remove RUST_BACKTRACE from our own environment, in case developer // is running `make check` with it on.) let p = template(me).arg("fail").env_remove("RUST_BACKTRACE").spawn().unwrap(); @@ -61,7 +61,7 @@ fn runtest(me: &str) { assert!(!s.contains("stack backtrace") && !s.contains(&expected("foo")), "bad output2: {}", s); - // Make sure the stack trace is *not* printed + // Make sure the stack trace is **not** printed. // (RUST_BACKTRACE=0 acts as if it were unset from our own environment, // in case developer is running `make check` with it set.) let p = template(me).arg("fail").env("RUST_BACKTRACE","0").spawn().unwrap(); @@ -71,17 +71,17 @@ fn runtest(me: &str) { assert!(!s.contains("stack backtrace") && !s.contains(" - foo"), "bad output3: {}", s); - // Make sure a stack trace is printed + // Make sure a stack trace is printed. let p = template(me).arg("double-fail").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); - // loosened the following from double::h to double:: due to - // spurious failures on mac, 32bit, optimized + // Loosened the following from `double::h` to `double::` due to + // spurious failures on macOS, 32-bit, optimized. assert!(s.contains("stack backtrace") && s.contains(&expected("double")), "bad output3: {}", s); - // Make sure a stack trace isn't printed too many times + // Make sure a stack trace isn't printed too many times. let p = template(me).arg("double-fail") .env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); diff --git a/src/test/run-pass/bench/issue-32062.rs b/src/test/run-pass/bench/issue-32062.rs index dc45061da5b50..5bdf782e3a3bc 100644 --- a/src/test/run-pass/bench/issue-32062.rs +++ b/src/test/run-pass/bench/issue-32062.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let _ = test(Some(0).into_iter()); diff --git a/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs b/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs index 87768c28cf4a1..91449f78323a4 100644 --- a/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs +++ b/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(_: &[&str]) {} diff --git a/src/test/run-pass/binding/match-bot-2.rs b/src/test/run-pass/binding/match-bot-2.rs index 95b3406f0b579..21ada9c82cc25 100644 --- a/src/test/run-pass/binding/match-bot-2.rs +++ b/src/test/run-pass/binding/match-bot-2.rs @@ -1,6 +1,8 @@ // run-pass + #![allow(unreachable_code)] -// n.b. This was only ever failing with optimization disabled. +// N.B., this was only ever failing with optimization disabled. fn a() -> isize { match return 1 { 2 => 3, _ => panic!() } } + pub fn main() { a(); } diff --git a/src/test/run-pass/binding/match-naked-record-expr.rs b/src/test/run-pass/binding/match-naked-record-expr.rs index c23ff8c949580..9b247c88700e8 100644 --- a/src/test/run-pass/binding/match-naked-record-expr.rs +++ b/src/test/run-pass/binding/match-naked-record-expr.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct X { x: isize } diff --git a/src/test/run-pass/binding/match-naked-record.rs b/src/test/run-pass/binding/match-naked-record.rs index f7479152ebcac..911754fa4b69f 100644 --- a/src/test/run-pass/binding/match-naked-record.rs +++ b/src/test/run-pass/binding/match-naked-record.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct X { x: isize } diff --git a/src/test/run-pass/binding/match-path.rs b/src/test/run-pass/binding/match-path.rs index 286214eb8ace8..0068789a5ff11 100644 --- a/src/test/run-pass/binding/match-path.rs +++ b/src/test/run-pass/binding/match-path.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m1 { pub enum foo { foo1, foo2, } diff --git a/src/test/run-pass/binding/match-pattern-simple.rs b/src/test/run-pass/binding/match-pattern-simple.rs index 3f56cd4796d87..6ea5c39e43217 100644 --- a/src/test/run-pass/binding/match-pattern-simple.rs +++ b/src/test/run-pass/binding/match-pattern-simple.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn altsimple(f: isize) { match f { _x => () } } diff --git a/src/test/run-pass/binding/match-phi.rs b/src/test/run-pass/binding/match-phi.rs index 92a3f6e0f7f60..83e43952903b4 100644 --- a/src/test/run-pass/binding/match-phi.rs +++ b/src/test/run-pass/binding/match-phi.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_assignments)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] #![allow(unused_variables)] diff --git a/src/test/run-pass/binding/match-pipe-binding.rs b/src/test/run-pass/binding/match-pipe-binding.rs index 40dbd2468950e..237b4bb4e6cf5 100644 --- a/src/test/run-pass/binding/match-pipe-binding.rs +++ b/src/test/run-pass/binding/match-pipe-binding.rs @@ -2,7 +2,7 @@ // compile-flags: -Z borrowck=compare fn test1() { - // from issue 6338 + // from issue #6338 match ((1, "a".to_string()), (2, "b".to_string())) { ((1, a), (2, b)) | ((2, b), (1, a)) => { assert_eq!(a, "a".to_string()); diff --git a/src/test/run-pass/binding/match-range-static.rs b/src/test/run-pass/binding/match-range-static.rs index f01a3505ee618..efd831dcc7a32 100644 --- a/src/test/run-pass/binding/match-range-static.rs +++ b/src/test/run-pass/binding/match-range-static.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_upper_case_globals)] const s: isize = 1; diff --git a/src/test/run-pass/binding/match-range.rs b/src/test/run-pass/binding/match-range.rs index 1dca84dfd45ff..15d54defd9366 100644 --- a/src/test/run-pass/binding/match-range.rs +++ b/src/test/run-pass/binding/match-range.rs @@ -1,7 +1,10 @@ // run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + #![feature(exclusive_range_pattern)] +// FIXME(#41620) +#![allow(illegal_floating_point_literal_pattern)] + pub fn main() { match 5_usize { 1_usize..=5_usize => {} diff --git a/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs b/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs index 4b209b20a18aa..c9cdccb5d6026 100644 --- a/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs +++ b/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/binding/nested-exhaustive-match.rs b/src/test/run-pass/binding/nested-exhaustive-match.rs index 8b2294f843272..f57af4d6582ab 100644 --- a/src/test/run-pass/binding/nested-exhaustive-match.rs +++ b/src/test/run-pass/binding/nested-exhaustive-match.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo { foo: bool, bar: Option, baz: isize } diff --git a/src/test/run-pass/binding/nil-pattern.rs b/src/test/run-pass/binding/nil-pattern.rs index 268af351d0879..246d897c86674 100644 --- a/src/test/run-pass/binding/nil-pattern.rs +++ b/src/test/run-pass/binding/nil-pattern.rs @@ -1,4 +1,4 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x = (); match x { () => { } } } diff --git a/src/test/run-pass/binding/simple-generic-match.rs b/src/test/run-pass/binding/simple-generic-match.rs index 50cfe19fef48d..0aea428007725 100644 --- a/src/test/run-pass/binding/simple-generic-match.rs +++ b/src/test/run-pass/binding/simple-generic-match.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum clam { a(T), } diff --git a/src/test/run-pass/blind-item-mixed-crate-use-item.rs b/src/test/run-pass/blind-item-mixed-crate-use-item.rs index 00d171f6e4d43..5449c04b332e6 100644 --- a/src/test/run-pass/blind-item-mixed-crate-use-item.rs +++ b/src/test/run-pass/blind-item-mixed-crate-use-item.rs @@ -1,7 +1,7 @@ // aux-build:blind-item-mixed-crate-use-item-foo.rs // aux-build:blind-item-mixed-crate-use-item-foo2.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m { pub fn f(_: T, _: (), _: ()) { } diff --git a/src/test/run-pass/blind-item-mixed-use-item.rs b/src/test/run-pass/blind-item-mixed-use-item.rs index e6008206ba8f0..e76ec37983e30 100644 --- a/src/test/run-pass/blind-item-mixed-use-item.rs +++ b/src/test/run-pass/blind-item-mixed-use-item.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m { pub fn f(_: T, _: ()) { } diff --git a/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs b/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs index 050d702b625ab..61d1b635277cd 100644 --- a/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs +++ b/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { struct A { diff --git a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs index 25ef48d0d5ce3..780395387b46c 100644 --- a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs +++ b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs @@ -1,6 +1,8 @@ +// Test taken from issue #45641. + // run-pass + #![allow(dead_code)] -// Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641) // revisions: ast mir //[mir]compile-flags: -Z borrowck=mir diff --git a/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs b/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs index 2839a9195a0e2..c25c5880ea58a 100644 --- a/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs +++ b/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs @@ -7,7 +7,7 @@ // // Example from src/librustc_borrowck/borrowck/README.md -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo<'a>(mut t0: &'a mut isize, mut t1: &'a mut isize) { diff --git a/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs b/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs index cb1ba90de891e..e900fc20ff7a8 100644 --- a/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs +++ b/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/borrowck/borrowck-lend-args.rs b/src/test/run-pass/borrowck/borrowck-lend-args.rs index d0ef2dcdd2867..aadde34759e7a 100644 --- a/src/test/run-pass/borrowck/borrowck-lend-args.rs +++ b/src/test/run-pass/borrowck/borrowck-lend-args.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn borrow(_v: &isize) {} diff --git a/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs b/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs index 7675147c8ec2a..ba529292f6b2d 100644 --- a/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs +++ b/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs @@ -1,5 +1,5 @@ // run-pass -//compile-flags: -Z borrowck=mir +// compile-flags: -Z borrowck=mir #![feature(slice_patterns)] diff --git a/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs b/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs index 5f4379325a58a..04787a366014b 100644 --- a/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs +++ b/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Regression test for issue #7740 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { static A: &'static char = &'A'; diff --git a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs index 9721b08233e39..582cbbb663563 100644 --- a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs +++ b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs @@ -3,7 +3,7 @@ // This test verifies that casting from the same lifetime on a value // to the same lifetime on a trait succeeds. See issue #10766. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs b/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs index bdf7cc57a539e..ad91a578f3086 100644 --- a/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs +++ b/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Rec { f: Box, diff --git a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs index 0487c179e3688..65753ea171173 100644 --- a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs +++ b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs @@ -1,9 +1,9 @@ +// Test taken from issue #45129. + // run-pass // revisions: ast mir //[mir]compile-flags: -Z borrowck=mir -// Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129) - struct Foo { x: [usize; 2] } static mut SFOO: Foo = Foo { x: [23, 32] }; diff --git a/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs b/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs index bcd1d3ccd8acb..39ae68cea0804 100644 --- a/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs +++ b/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/borrowck/two-phase-baseline.rs b/src/test/run-pass/borrowck/two-phase-baseline.rs index aa8d18312941a..578545ba83764 100644 --- a/src/test/run-pass/borrowck/two-phase-baseline.rs +++ b/src/test/run-pass/borrowck/two-phase-baseline.rs @@ -1,7 +1,7 @@ // run-pass // compile-flags: -Z borrowck=mir -Z two-phase-borrows -// This is the "goto example" for why we want two phase borrows. +// This is the "goto example" for why we want two-phase borrows. fn main() { let mut v = vec![0, 1, 2]; diff --git a/src/test/run-pass/box-new.rs b/src/test/run-pass/box-new.rs index 2d177bcf9276c..368a62f05fc5f 100644 --- a/src/test/run-pass/box-new.rs +++ b/src/test/run-pass/box-new.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let _a = Box::new(1); diff --git a/src/test/run-pass/bug-7295.rs b/src/test/run-pass/bug-7295.rs index b6dea6c82dc1a..98041345c0ea7 100644 --- a/src/test/run-pass/bug-7295.rs +++ b/src/test/run-pass/bug-7295.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Foo { fn func1(&self, t: U, w: T); @@ -8,6 +8,4 @@ pub trait Foo { } } -pub fn main() { - -} +pub fn main() {} diff --git a/src/test/run-pass/builtin-superkinds-phantom-typaram.rs b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs index 3899ecf6f3f7d..5e01c4cc3f107 100644 --- a/src/test/run-pass/builtin-superkinds-phantom-typaram.rs +++ b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs @@ -3,7 +3,7 @@ // super-builtin-kind of a trait, if the type parameter is never used, // the type can implement the trait anyway. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker; diff --git a/src/test/run-pass/builtin-superkinds-simple.rs b/src/test/run-pass/builtin-superkinds-simple.rs index 670b8ed0e9bc1..dcdf5d917b3af 100644 --- a/src/test/run-pass/builtin-superkinds-simple.rs +++ b/src/test/run-pass/builtin-superkinds-simple.rs @@ -1,6 +1,6 @@ // Simple test case of implementing a trait with super-builtin-kinds. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo : Send { } diff --git a/src/test/run-pass/builtin-superkinds-typaram.rs b/src/test/run-pass/builtin-superkinds-typaram.rs index c3a456318bce6..83f28b6c1d9da 100644 --- a/src/test/run-pass/builtin-superkinds-typaram.rs +++ b/src/test/run-pass/builtin-superkinds-typaram.rs @@ -1,7 +1,7 @@ // Tests correct implementation of traits with super-builtin-kinds // using a bounded type parameter. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo : Send { } diff --git a/src/test/run-pass/c-stack-as-value.rs b/src/test/run-pass/c-stack-as-value.rs index 3b997295c122a..0230b913f8370 100644 --- a/src/test/run-pass/c-stack-as-value.rs +++ b/src/test/run-pass/c-stack-as-value.rs @@ -1,5 +1,5 @@ -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test ffi with +// pretty-expanded FIXME(#23616) +// ignore-wasm32-bare no libc to test FFI with #![feature(rustc_private)] diff --git a/src/test/run-pass/can-copy-pod.rs b/src/test/run-pass/can-copy-pod.rs index bc10d236b3639..95b596ec5af6e 100644 --- a/src/test/run-pass/can-copy-pod.rs +++ b/src/test/run-pass/can-copy-pod.rs @@ -1,7 +1,4 @@ -// pretty-expanded FIXME #23616 - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ +// pretty-expanded FIXME(#23616) // Tests that type parameters with the `Copy` are implicitly copyable. diff --git a/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs b/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs index f27803677cc0e..323a495486554 100644 --- a/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs +++ b/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/cfg/cfg-attr-cfg.rs b/src/test/run-pass/cfg/cfg-attr-cfg.rs index 61794e0bfa90e..4fe3de15aa7af 100644 --- a/src/test/run-pass/cfg/cfg-attr-cfg.rs +++ b/src/test/run-pass/cfg/cfg-attr-cfg.rs @@ -2,7 +2,7 @@ // main is conditionally compiled, but the conditional compilation // is conditional too! -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[cfg_attr(foo, cfg(bar))] fn main() { } diff --git a/src/test/run-pass/cfg/cfg-attr-crate.rs b/src/test/run-pass/cfg/cfg-attr-crate.rs index 1d70f2f84f29b..8127b047259e9 100644 --- a/src/test/run-pass/cfg/cfg-attr-crate.rs +++ b/src/test/run-pass/cfg/cfg-attr-crate.rs @@ -1,7 +1,7 @@ // run-pass // https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![cfg_attr(not_used, no_core)] diff --git a/src/test/run-pass/cfg/cfg-family.rs b/src/test/run-pass/cfg/cfg-family.rs index 282ac4abcee98..29076bd371de1 100644 --- a/src/test/run-pass/cfg/cfg-family.rs +++ b/src/test/run-pass/cfg/cfg-family.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no target_family // ignore-wasm32-bare no target_family diff --git a/src/test/run-pass/cfg/cfg-match-arm.rs b/src/test/run-pass/cfg/cfg-match-arm.rs index 071008f9eb6a4..a935465417c7b 100644 --- a/src/test/run-pass/cfg/cfg-match-arm.rs +++ b/src/test/run-pass/cfg/cfg-match-arm.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Foo { Bar, diff --git a/src/test/run-pass/cfg/cfg-target-family.rs b/src/test/run-pass/cfg/cfg-target-family.rs index 2cd0ba5bf881c..cd3a5eaae8830 100644 --- a/src/test/run-pass/cfg/cfg-target-family.rs +++ b/src/test/run-pass/cfg/cfg-target-family.rs @@ -2,7 +2,7 @@ // ignore-cloudabi no target_family // ignore-wasm32-bare no target_family -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[cfg(target_family = "windows")] pub fn main() { diff --git a/src/test/run-pass/cfg/cfg_inner_static.rs b/src/test/run-pass/cfg/cfg_inner_static.rs index 45dbbcc10844b..9ee34d9803452 100644 --- a/src/test/run-pass/cfg/cfg_inner_static.rs +++ b/src/test/run-pass/cfg/cfg_inner_static.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:cfg_inner_static.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate cfg_inner_static; diff --git a/src/test/run-pass/cfg/cfg_stmt_expr.rs b/src/test/run-pass/cfg/cfg_stmt_expr.rs index e466ad69f721c..13622741a39ca 100644 --- a/src/test/run-pass/cfg/cfg_stmt_expr.rs +++ b/src/test/run-pass/cfg/cfg_stmt_expr.rs @@ -28,7 +28,7 @@ fn main() { #[cfg(unset)] undefined_macro!{}; - // pretty printer bug... + // pretty-printer bug... // #[cfg(unset)] // undefined_macro!{} diff --git a/src/test/run-pass/cfg/conditional-compile-arch.rs b/src/test/run-pass/cfg/conditional-compile-arch.rs index ea3affee4066e..28900daa501b0 100644 --- a/src/test/run-pass/cfg/conditional-compile-arch.rs +++ b/src/test/run-pass/cfg/conditional-compile-arch.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[cfg(target_arch = "x86")] pub fn main() { } diff --git a/src/test/run-pass/cfg/conditional-compile.rs b/src/test/run-pass/cfg/conditional-compile.rs index de5bd5f07dd57..8453f9b79cb59 100644 --- a/src/test/run-pass/cfg/conditional-compile.rs +++ b/src/test/run-pass/cfg/conditional-compile.rs @@ -1,10 +1,11 @@ // run-pass + #![allow(dead_code)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(improper_ctypes)] -// Crate use statements +// Crate `use` statements. #[cfg(bogus)] use flippity; @@ -18,7 +19,7 @@ mod rustrt { #[cfg(bogus)] extern { // This symbol doesn't exist and would be a link error if this - // module was codegened + // module was codegen'ed. pub fn bogus(); } @@ -60,13 +61,13 @@ fn r(i:isize) -> r { #[cfg(bogus)] mod m { // This needs to parse but would fail in typeck. Since it's not in - // the current config it should not be typechecked. + // the current config it should not be type-checked. pub fn bogus() { return 0; } } mod m { // Submodules have slightly different code paths than the top-level - // module, so let's make sure this jazz works here as well + // module, so let's make sure this jazz works here as well. #[cfg(bogus)] pub fn f() { } @@ -74,13 +75,13 @@ mod m { } // Since the bogus configuration isn't defined main will just be -// parsed, but nothing further will be done with it +// parsed, but nothing further will be done with it. #[cfg(bogus)] pub fn main() { panic!() } pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible - // if they had the bogus definition + // if they had the bogus definition. assert!((b)); let _x: t = true; let _y: tg = tg::bar; @@ -145,5 +146,6 @@ mod test_methods { } } +// Check that unconfigured non-inline modules are not loaded or parsed. #[cfg(any())] -mod nonexistent_file; // Check that unconfigured non-inline modules are not loaded or parsed. +mod nonexistent_file; diff --git a/src/test/run-pass/check-static-recursion-foreign.rs b/src/test/run-pass/check-static-recursion-foreign.rs index c423bf666e5fb..7899964db1ae8 100644 --- a/src/test/run-pass/check-static-recursion-foreign.rs +++ b/src/test/run-pass/check-static-recursion-foreign.rs @@ -4,7 +4,7 @@ // aux-build:check_static_recursion_foreign_helper.rs // ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(custom_attribute, rustc_private)] diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index 80e3c81af5281..b9c6f74afd0db 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -1,6 +1,6 @@ // Reported as issue #126, child leaks the string. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads support use std::thread; diff --git a/src/test/run-pass/cleanup-arm-conditional.rs b/src/test/run-pass/cleanup-arm-conditional.rs index b8b109905209d..5549d9189bc50 100644 --- a/src/test/run-pass/cleanup-arm-conditional.rs +++ b/src/test/run-pass/cleanup-arm-conditional.rs @@ -3,7 +3,7 @@ // Test that cleanup scope for temporaries created in a match // arm is confined to the match arm itself. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax, os)] diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index 7b4d66e7571b1..cd3479f8eaaac 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unused_variables)] // Test cleanup of rvalue temporary that occurs while `box` construction -// is in progress. This scenario revealed a rather terrible bug. The +// is in progress. This scenario revealed a rather terrible bug. The // ingredients are: // // 1. Partial cleanup of `box` is in scope, diff --git a/src/test/run-pass/cleanup-shortcircuit.rs b/src/test/run-pass/cleanup-shortcircuit.rs index 118fa0083ab47..7ad056f8320a2 100644 --- a/src/test/run-pass/cleanup-shortcircuit.rs +++ b/src/test/run-pass/cleanup-shortcircuit.rs @@ -1,6 +1,6 @@ // Test that cleanups for the RHS of shortcircuiting operators work. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no std::env support use std::env; diff --git a/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs b/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs index 3fe18103ef8c3..0a972ac5c69c1 100644 --- a/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs +++ b/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::rc::Rc; diff --git a/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs b/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs index f033e1b5d2b01..31da6e6a0e429 100644 --- a/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs +++ b/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn negate(x: &isize) -> isize { -*x diff --git a/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs index c2aaae1c73ec8..cce9361f744a2 100644 --- a/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn sum(x: &[isize]) -> isize { let mut sum = 0; diff --git a/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs b/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs index 76cd6793b3c23..9d87302493b46 100644 --- a/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs +++ b/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct SpeechMaker { speeches: usize diff --git a/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs b/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs index e6e7c3a51aa09..7c71512d67143 100644 --- a/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs +++ b/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct SpeechMaker { speeches: usize diff --git a/src/test/run-pass/coerce/coerce-unify-return.rs b/src/test/run-pass/coerce/coerce-unify-return.rs index 95a7ee8fe0f2b..0f147ceca322b 100644 --- a/src/test/run-pass/coerce/coerce-unify-return.rs +++ b/src/test/run-pass/coerce/coerce-unify-return.rs @@ -2,7 +2,7 @@ // Check that coercions unify the expected return type of a polymorphic // function call, instead of leaving the type variables as they were. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo; impl Foo { diff --git a/src/test/run-pass/coerce/coerce-unsize-subtype.rs b/src/test/run-pass/coerce/coerce-unsize-subtype.rs index 45b53300c5b4b..0357877c97125 100644 --- a/src/test/run-pass/coerce/coerce-unsize-subtype.rs +++ b/src/test/run-pass/coerce/coerce-unsize-subtype.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::rc::Rc; diff --git a/src/test/run-pass/coherence/coherence-bigint-int.rs b/src/test/run-pass/coherence/coherence-bigint-int.rs index 0c9abdc15e620..b1727c0c5855d 100644 --- a/src/test/run-pass/coherence/coherence-bigint-int.rs +++ b/src/test/run-pass/coherence/coherence-bigint-int.rs @@ -4,7 +4,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote1; diff --git a/src/test/run-pass/coherence/coherence-bigint-vecint.rs b/src/test/run-pass/coherence/coherence-bigint-vecint.rs index 38e0be0aa9ab9..4beac5d496a2e 100644 --- a/src/test/run-pass/coherence/coherence-bigint-vecint.rs +++ b/src/test/run-pass/coherence/coherence-bigint-vecint.rs @@ -4,7 +4,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote1; diff --git a/src/test/run-pass/coherence/coherence-blanket.rs b/src/test/run-pass/coherence/coherence-blanket.rs index 5d310cc2c6ac5..43f4c22f012b9 100644 --- a/src/test/run-pass/coherence/coherence-blanket.rs +++ b/src/test/run-pass/coherence/coherence-blanket.rs @@ -5,7 +5,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote1; diff --git a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs index 1cf039f0831f5..32091032a1cc1 100644 --- a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs +++ b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs @@ -5,7 +5,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote; diff --git a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs index 051cc280b2d12..3f8446cd38ca2 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] // aux-build:coherence_lib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote1; diff --git a/src/test/run-pass/coherence/coherence-iterator-vec.rs b/src/test/run-pass/coherence/coherence-iterator-vec.rs index df6e808f7dec5..4559c66023f70 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] // aux-build:coherence_lib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate coherence_lib as lib; use lib::Remote1; diff --git a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs index 6a816664c4832..864cce62eaeb0 100644 --- a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs +++ b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs @@ -3,7 +3,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::fmt::Debug; use std::default::Default; diff --git a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs index 98b04489ac4de..0beb3bb32a088 100644 --- a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs +++ b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs @@ -3,7 +3,7 @@ #![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(optin_builtin_traits)] diff --git a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs index 4da54d386fd35..377bcbd4b8239 100644 --- a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs +++ b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs @@ -12,7 +12,7 @@ trait Mirror { type Image: ?Sized; } impl Mirror for T { type Image = T; } trait Bar {} -impl, L: Mirror> Bar for V +impl, L: Mirror> Bar for V where U::Image: IsU32 {} trait Foo { fn name() -> &'static str; } diff --git a/src/test/run-pass/consts/const-binops.rs b/src/test/run-pass/consts/const-binops.rs index d038dfeb419ca..3e73aa0c0e98c 100644 --- a/src/test/run-pass/consts/const-binops.rs +++ b/src/test/run-pass/consts/const-binops.rs @@ -39,7 +39,7 @@ static U: usize = 1 ^ 3; static V: isize = 1 << 3; -// NOTE: better shr coverage +// FIXME: add better `shr` coverage. static W: isize = 1024 >> 4; static X: usize = 1024 >> 4; diff --git a/src/test/run-pass/consts/const-bound.rs b/src/test/run-pass/consts/const-bound.rs index 735056a0ab0b1..667054162c616 100644 --- a/src/test/run-pass/consts/const-bound.rs +++ b/src/test/run-pass/consts/const-bound.rs @@ -3,7 +3,7 @@ // Make sure const bounds work on things, and test that a few types // are const. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(x: T) -> T { x } diff --git a/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs b/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs index a9960b4552b6e..5ee3008cfd0d7 100644 --- a/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs +++ b/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs @@ -2,7 +2,7 @@ // Check that constant expressions can be used for declaring the // type of a fixed length vector. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { diff --git a/src/test/run-pass/consts/const-expr-in-vec-repeat.rs b/src/test/run-pass/consts/const-expr-in-vec-repeat.rs index 4eaef25059b0b..4b5faa0980e65 100644 --- a/src/test/run-pass/consts/const-expr-in-vec-repeat.rs +++ b/src/test/run-pass/consts/const-expr-in-vec-repeat.rs @@ -1,7 +1,7 @@ // run-pass // Check that constant expressions can be used in vec repeat syntax. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { diff --git a/src/test/run-pass/consts/const-struct-offsets.rs b/src/test/run-pass/consts/const-struct-offsets.rs index 26a008320797e..d9aabe107632d 100644 --- a/src/test/run-pass/consts/const-struct-offsets.rs +++ b/src/test/run-pass/consts/const-struct-offsets.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_upper_case_globals)] enum Foo { diff --git a/src/test/run-pass/consts/const-unit-struct.rs b/src/test/run-pass/consts/const-unit-struct.rs index 1c9e0e8d3c989..757f1cdbda3ec 100644 --- a/src/test/run-pass/consts/const-unit-struct.rs +++ b/src/test/run-pass/consts/const-unit-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo; diff --git a/src/test/run-pass/consts/const-vec-of-fns.rs b/src/test/run-pass/consts/const-vec-of-fns.rs index 6d90b066b74d7..fda767b42c76d 100644 --- a/src/test/run-pass/consts/const-vec-of-fns.rs +++ b/src/test/run-pass/consts/const-vec-of-fns.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_upper_case_globals)] /*! diff --git a/src/test/run-pass/consts/const-vec-syntax.rs b/src/test/run-pass/consts/const-vec-syntax.rs index 61246e44eba8d..6733fafc647f6 100644 --- a/src/test/run-pass/consts/const-vec-syntax.rs +++ b/src/test/run-pass/consts/const-vec-syntax.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(_: &[isize]) {} diff --git a/src/test/run-pass/crate-leading-sep.rs b/src/test/run-pass/crate-leading-sep.rs index 26d4df433aae1..ffb605a2b334e 100644 --- a/src/test/run-pass/crate-leading-sep.rs +++ b/src/test/run-pass/crate-leading-sep.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { use ::std::mem; diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 0d243e14b94c5..a8a88ee74c4a0 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/crate-name-attr-used.rs b/src/test/run-pass/crate-name-attr-used.rs index 666f80e566262..fafac19b76db6 100644 --- a/src/test/run-pass/crate-name-attr-used.rs +++ b/src/test/run-pass/crate-name-attr-used.rs @@ -1,6 +1,6 @@ // compile-flags:--crate-name crate_name_attr_used -F unused-attributes -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![crate_name = "crate_name_attr_used"] diff --git a/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs b/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs index 77168be5374b2..f51ae39e5c918 100644 --- a/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs +++ b/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:anon-extern-mod-cross-crate-1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-wasm32-bare no libc to test ffi with extern crate anonexternmod; diff --git a/src/test/run-pass/cross-crate/cci_capture_clause.rs b/src/test/run-pass/cross-crate/cci_capture_clause.rs index ea699b5f5ac4e..4ea909fa61750 100644 --- a/src/test/run-pass/cross-crate/cci_capture_clause.rs +++ b/src/test/run-pass/cross-crate/cci_capture_clause.rs @@ -4,7 +4,7 @@ // This test makes sure we can do cross-crate inlining on functions // that use capture clauses. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads support extern crate cci_capture_clause; diff --git a/src/test/run-pass/cross-crate/cci_no_inline_exe.rs b/src/test/run-pass/cross-crate/cci_no_inline_exe.rs index ffc701678d3b6..5125c5c3153e5 100644 --- a/src/test/run-pass/cross-crate/cci_no_inline_exe.rs +++ b/src/test/run-pass/cross-crate/cci_no_inline_exe.rs @@ -6,7 +6,7 @@ use cci_no_inline_lib::iter; pub fn main() { // Check that a cross-crate call function not marked as inline - // does not, in fact, get inlined. Also, perhaps more + // does not, in fact, get inlined. Also, perhaps more // importantly, checks that our scheme of using // sys::frame_address() to determine if we are inlining is // actually working. diff --git a/src/test/run-pass/cross-crate/cross-crate-const-pat.rs b/src/test/run-pass/cross-crate/cross-crate-const-pat.rs index e8fa8485ab2fb..51c789fbc3d04 100644 --- a/src/test/run-pass/cross-crate/cross-crate-const-pat.rs +++ b/src/test/run-pass/cross-crate/cross-crate-const-pat.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:cci_const.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate cci_const; diff --git a/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs b/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs index 3881e3352202f..e83e2d5dd8844 100644 --- a/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs +++ b/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:moves_based_on_type_lib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate moves_based_on_type_lib; use moves_based_on_type_lib::f; diff --git a/src/test/run-pass/cross-crate/xcrate-static-addresses.rs b/src/test/run-pass/cross-crate/xcrate-static-addresses.rs index 3c33976568e94..49fedc7fcf428 100644 --- a/src/test/run-pass/cross-crate/xcrate-static-addresses.rs +++ b/src/test/run-pass/cross-crate/xcrate-static-addresses.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:xcrate_static_addresses.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate xcrate_static_addresses; diff --git a/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs b/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs index 1fd7eb878d98a..0371c2f104688 100644 --- a/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs +++ b/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // aux-build:xcrate-trait-lifetime-param.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate xcrate_trait_lifetime_param as other; diff --git a/src/test/run-pass/cross-crate/xcrate-unit-struct.rs b/src/test/run-pass/cross-crate/xcrate-unit-struct.rs index 7aa3eb0d6c44a..55d7679eed38c 100644 --- a/src/test/run-pass/cross-crate/xcrate-unit-struct.rs +++ b/src/test/run-pass/cross-crate/xcrate-unit-struct.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:xcrate_unit_struct.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_upper_case_globals)] extern crate xcrate_unit_struct; diff --git a/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs b/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs index a171567c5d2fa..41eaa4befa018 100644 --- a/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs +++ b/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/34997 - pub const CST_1: u32 = 0; pub const CST_2: u32 = CST_1+1; pub const CST_3: u32 = CST_2+1; diff --git a/src/test/run-pass/ctfe/deref_in_pattern.rs b/src/test/run-pass/ctfe/deref_in_pattern.rs index cc47b5b49c0b3..6b4e3a065e517 100644 --- a/src/test/run-pass/ctfe/deref_in_pattern.rs +++ b/src/test/run-pass/ctfe/deref_in_pattern.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/25574 - const A: [u8; 4] = *b"fooo"; fn main() { diff --git a/src/test/run-pass/ctfe/ice-48279.rs b/src/test/run-pass/ctfe/ice-48279.rs index d1d90df240ca5..a806c725c6521 100644 --- a/src/test/run-pass/ctfe/ice-48279.rs +++ b/src/test/run-pass/ctfe/ice-48279.rs @@ -1,9 +1,8 @@ // run-pass + #![allow(dead_code)] #![allow(unused_unsafe)] -// https://github.com/rust-lang/rust/issues/48279 - #[derive(PartialEq, Eq)] pub struct NonZeroU32 { value: u32 @@ -15,7 +14,7 @@ impl NonZeroU32 { } } -//pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; +// pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32 { value: 7 } }; fn main() { diff --git a/src/test/run-pass/ctfe/issue-broken-mir.rs b/src/test/run-pass/ctfe/issue-broken-mir.rs index 36f0ff92104e1..d4c55345c2388 100644 --- a/src/test/run-pass/ctfe/issue-broken-mir.rs +++ b/src/test/run-pass/ctfe/issue-broken-mir.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/27918 - fn main() { match b" " { b"1234" => {}, diff --git a/src/test/run-pass/ctfe/locals-in-const-fn.rs b/src/test/run-pass/ctfe/locals-in-const-fn.rs index 95d50171a847b..05e4f99a18758 100644 --- a/src/test/run-pass/ctfe/locals-in-const-fn.rs +++ b/src/test/run-pass/ctfe/locals-in-const-fn.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/48821 - const fn foo(i: usize) -> usize { let x = i; x diff --git a/src/test/run-pass/ctfe/match-const-fn-structs.rs b/src/test/run-pass/ctfe/match-const-fn-structs.rs index 5a68048c47725..494dc6dbd2b70 100644 --- a/src/test/run-pass/ctfe/match-const-fn-structs.rs +++ b/src/test/run-pass/ctfe/match-const-fn-structs.rs @@ -1,7 +1,6 @@ // run-pass -#![allow(unused_variables)] -// https://github.com/rust-lang/rust/issues/46114 +#![allow(unused_variables)] #[derive(Eq, PartialEq)] struct A { value: u32 } diff --git a/src/test/run-pass/ctfe/non-scalar-cast.rs b/src/test/run-pass/ctfe/non-scalar-cast.rs index 671366c90ec8e..4343def1d90e3 100644 --- a/src/test/run-pass/ctfe/non-scalar-cast.rs +++ b/src/test/run-pass/ctfe/non-scalar-cast.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/37448 - fn main() { struct A; const FOO: &A = &(A as A); diff --git a/src/test/run-pass/ctfe/repeat_match.rs b/src/test/run-pass/ctfe/repeat_match.rs index 20983184a473a..895a4fa66f0ef 100644 --- a/src/test/run-pass/ctfe/repeat_match.rs +++ b/src/test/run-pass/ctfe/repeat_match.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/45044 - const X: [u8; 1] = [0; 1]; fn main() { diff --git a/src/test/run-pass/ctfe/return-in-const-fn.rs b/src/test/run-pass/ctfe/return-in-const-fn.rs index 077a33c081ba8..f12dc0e8daffb 100644 --- a/src/test/run-pass/ctfe/return-in-const-fn.rs +++ b/src/test/run-pass/ctfe/return-in-const-fn.rs @@ -1,10 +1,9 @@ // run-pass -// https://github.com/rust-lang/rust/issues/43754 - const fn foo(x: usize) -> usize { return x; } + fn main() { [0; foo(2)]; } diff --git a/src/test/run-pass/ctfe/signed_enum_discr.rs b/src/test/run-pass/ctfe/signed_enum_discr.rs index 2e4395ccf2277..026a62dd029b2 100644 --- a/src/test/run-pass/ctfe/signed_enum_discr.rs +++ b/src/test/run-pass/ctfe/signed_enum_discr.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/49181 - #[derive(Eq, PartialEq)] #[repr(i8)] pub enum A { diff --git a/src/test/run-pass/ctfe/tuple-struct-constructors.rs b/src/test/run-pass/ctfe/tuple-struct-constructors.rs index 1655f0eb85038..1564053098404 100644 --- a/src/test/run-pass/ctfe/tuple-struct-constructors.rs +++ b/src/test/run-pass/ctfe/tuple-struct-constructors.rs @@ -1,7 +1,5 @@ // run-pass -// https://github.com/rust-lang/rust/issues/41898 - use std::num::NonZeroU64; fn main() { diff --git a/src/test/run-pass/cycle-generic-bound.rs b/src/test/run-pass/cycle-generic-bound.rs index 56bfa98451f74..8607b87fccb55 100644 --- a/src/test/run-pass/cycle-generic-bound.rs +++ b/src/test/run-pass/cycle-generic-bound.rs @@ -1,6 +1,6 @@ // Regression test for #15477. This test just needs to compile. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Chromosome> { } diff --git a/src/test/run-pass/dead-code-leading-underscore.rs b/src/test/run-pass/dead-code-leading-underscore.rs index eff40111ac9d4..852b28137ee52 100644 --- a/src/test/run-pass/dead-code-leading-underscore.rs +++ b/src/test/run-pass/dead-code-leading-underscore.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![deny(dead_code)] diff --git a/src/test/run-pass/default-method-parsing.rs b/src/test/run-pass/default-method-parsing.rs index 7f66605d7c363..f2a8d7a1a2ab6 100644 --- a/src/test/run-pass/default-method-parsing.rs +++ b/src/test/run-pass/default-method-parsing.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { fn m(&self, _:isize) { } diff --git a/src/test/run-pass/defaults-well-formedness.rs b/src/test/run-pass/defaults-well-formedness.rs index cbcdb38fbebaf..c5077b60a4731 100644 --- a/src/test/run-pass/defaults-well-formedness.rs +++ b/src/test/run-pass/defaults-well-formedness.rs @@ -14,7 +14,7 @@ struct NonDefaultedInClause(TwoParams) where TwoParams: struct DefaultedLhs(U, V) where V: Trait; // Dependent defaults are not checked. struct Dependent(T, U) where U: Copy; -trait SelfBound {} +trait SelfBound {} // Not even for well-formedness. struct WellFormedProjection::Item>(A, T); diff --git a/src/test/run-pass/deref-on-ref.rs b/src/test/run-pass/deref-on-ref.rs index 651ccd5be855c..b34eb52ace310 100644 --- a/src/test/run-pass/deref-on-ref.rs +++ b/src/test/run-pass/deref-on-ref.rs @@ -3,7 +3,7 @@ use std::ops::Deref; -fn deref>(t: T) -> U { +fn deref>(t: T) -> U { *t } diff --git a/src/test/run-pass/deref.rs b/src/test/run-pass/deref.rs index 08b047f54d94b..40761ab15978a 100644 --- a/src/test/run-pass/deref.rs +++ b/src/test/run-pass/deref.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/deriving/deriving-clone-enum.rs b/src/test/run-pass/deriving/deriving-clone-enum.rs index 09e7497407254..f54b4c0c7da69 100644 --- a/src/test/run-pass/deriving/deriving-clone-enum.rs +++ b/src/test/run-pass/deriving/deriving-clone-enum.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] enum E { diff --git a/src/test/run-pass/deriving/deriving-clone-generic-enum.rs b/src/test/run-pass/deriving/deriving-clone-generic-enum.rs index a344d7fc43a2e..846cd3fdb8d48 100644 --- a/src/test/run-pass/deriving/deriving-clone-generic-enum.rs +++ b/src/test/run-pass/deriving/deriving-clone-generic-enum.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] enum E { diff --git a/src/test/run-pass/deriving/deriving-clone-generic-struct.rs b/src/test/run-pass/deriving/deriving-clone-generic-struct.rs index f6e105555fd9d..7858ca6a7f920 100644 --- a/src/test/run-pass/deriving/deriving-clone-generic-struct.rs +++ b/src/test/run-pass/deriving/deriving-clone-generic-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] struct S { diff --git a/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs b/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs index 8b9840de172da..9c0e0a3c9e15c 100644 --- a/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs +++ b/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] struct S(T, ()); diff --git a/src/test/run-pass/deriving/deriving-clone-struct.rs b/src/test/run-pass/deriving/deriving-clone-struct.rs index 7b0a1d20260d4..d797eff1af9e6 100644 --- a/src/test/run-pass/deriving/deriving-clone-struct.rs +++ b/src/test/run-pass/deriving/deriving-clone-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] struct S { diff --git a/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs b/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs index 166f1be55e02a..646f794bcbc99 100644 --- a/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs +++ b/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] struct S((), ()); diff --git a/src/test/run-pass/deriving/deriving-enum-single-variant.rs b/src/test/run-pass/deriving/deriving-enum-single-variant.rs index 1c5979c074758..4c38f4b92bdd6 100644 --- a/src/test/run-pass/deriving/deriving-enum-single-variant.rs +++ b/src/test/run-pass/deriving/deriving-enum-single-variant.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] pub type task_id = isize; diff --git a/src/test/run-pass/deriving/deriving-in-macro.rs b/src/test/run-pass/deriving/deriving-in-macro.rs index 46e8e37838dbd..15ed181b76152 100644 --- a/src/test/run-pass/deriving/deriving-in-macro.rs +++ b/src/test/run-pass/deriving/deriving-in-macro.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] macro_rules! define_vec { diff --git a/src/test/run-pass/deriving/deriving-meta-multiple.rs b/src/test/run-pass/deriving/deriving-meta-multiple.rs index ad255be8dab23..7c5c09bbc6783 100644 --- a/src/test/run-pass/deriving/deriving-meta-multiple.rs +++ b/src/test/run-pass/deriving/deriving-meta-multiple.rs @@ -1,12 +1,12 @@ // run-pass #![allow(unused_must_use)] #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(deprecated)] use std::hash::{Hash, SipHasher}; -// testing multiple separate deriving attributes +// Testing multiple separate deriving attributes. #[derive(PartialEq)] #[derive(Clone)] #[derive(Hash)] @@ -20,7 +20,10 @@ fn hash(_t: &T) {} pub fn main() { let a = Foo {bar: 4, baz: -3}; - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness + // Check for `PartialEq` impl without testing its correctness. + a == a; + // Check for `Clone` impl without testing its correctness. + a.clone(); + // Check for `Hash` impl without testing its correctness. + hash(&a); } diff --git a/src/test/run-pass/deriving/deriving-meta.rs b/src/test/run-pass/deriving/deriving-meta.rs index f2ff4f535576f..6a7bd82094c0f 100644 --- a/src/test/run-pass/deriving/deriving-meta.rs +++ b/src/test/run-pass/deriving/deriving-meta.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_must_use)] #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(deprecated)] use std::hash::{Hash, SipHasher}; @@ -17,7 +17,10 @@ fn hash(_t: &T) {} pub fn main() { let a = Foo {bar: 4, baz: -3}; - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness + // Check for `PartialEq` impl without testing its correctness. + a == a; + // Check for `Clone` impl without testing its correctness. + a.clone(); + // Check for `Hash` impl without testing its correctness. + hash(&a); } diff --git a/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs b/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs index c4037dc2714db..9129f6d36aa3c 100644 --- a/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs +++ b/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Hash)] struct Foo { diff --git a/src/test/run-pass/diverging-fallback-control-flow.rs b/src/test/run-pass/diverging-fallback-control-flow.rs index c88ab42d5a89a..73cbc443f46fc 100644 --- a/src/test/run-pass/diverging-fallback-control-flow.rs +++ b/src/test/run-pass/diverging-fallback-control-flow.rs @@ -5,7 +5,7 @@ // Test various cases where we permit an unconstrained variable // to fallback based on control-flow. // -// These represent current behavior, but are pretty dubious. I would +// These represent current behavior, but are pretty dubious. I would // like to revisit these and potentially change them. --nmatsakis #![feature(never_type)] diff --git a/src/test/run-pass/double-ref.rs b/src/test/run-pass/double-ref.rs index 16c98da94565e..ee562452286e6 100644 --- a/src/test/run-pass/double-ref.rs +++ b/src/test/run-pass/double-ref.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn check_expr() { let _: & usize = &1; diff --git a/src/test/run-pass/drop/drop-on-empty-block-exit.rs b/src/test/run-pass/drop/drop-on-empty-block-exit.rs index 1747bf029aa33..65b204584a9f9 100644 --- a/src/test/run-pass/drop/drop-on-empty-block-exit.rs +++ b/src/test/run-pass/drop/drop-on-empty-block-exit.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] #![feature(box_syntax)] diff --git a/src/test/run-pass/drop/drop-on-ret.rs b/src/test/run-pass/drop/drop-on-ret.rs index 290e274f30541..97df6e4ad584b 100644 --- a/src/test/run-pass/drop/drop-on-ret.rs +++ b/src/test/run-pass/drop/drop-on-ret.rs @@ -2,7 +2,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f() -> isize { if true { diff --git a/src/test/run-pass/drop/drop-uninhabited-enum.rs b/src/test/run-pass/drop/drop-uninhabited-enum.rs index b3566f68533bd..211e17e39f65a 100644 --- a/src/test/run-pass/drop/drop-uninhabited-enum.rs +++ b/src/test/run-pass/drop/drop-uninhabited-enum.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Foo { } diff --git a/src/test/run-pass/drop/nondrop-cycle.rs b/src/test/run-pass/drop/nondrop-cycle.rs index 29070f917e432..cd49da3349b88 100644 --- a/src/test/run-pass/drop/nondrop-cycle.rs +++ b/src/test/run-pass/drop/nondrop-cycle.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::cell::Cell; diff --git a/src/test/run-pass/duplicated-external-mods.rs b/src/test/run-pass/duplicated-external-mods.rs index f2c1e1f654016..a9d506d07d39d 100644 --- a/src/test/run-pass/duplicated-external-mods.rs +++ b/src/test/run-pass/duplicated-external-mods.rs @@ -1,6 +1,6 @@ // aux-build:anon-extern-mod-cross-crate-1.rs // aux-build:anon-extern-mod-cross-crate-1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-wasm32-bare no libc to test ffi with extern crate anonexternmod; diff --git a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs index 06c2892b69ea2..46c9d687209a4 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // Test coercions involving DST and/or raw pointers -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S; trait T { fn dummy(&self) { } } diff --git a/src/test/run-pass/early-ret-binop-add.rs b/src/test/run-pass/early-ret-binop-add.rs index 158468c572c6d..abb4dce9604a0 100644 --- a/src/test/run-pass/early-ret-binop-add.rs +++ b/src/test/run-pass/early-ret-binop-add.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] #![allow(unreachable_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ops::Add; -fn wsucc + Copy>(n: T) -> T { n + { return n } } +fn wsucc + Copy>(n: T) -> T { n + { return n } } pub fn main() { } diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 812771c29b3ab..1d36d138e5ea2 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait thing { fn foo(&self) -> Option; diff --git a/src/test/run-pass/empty-allocation-rvalue-non-null.rs b/src/test/run-pass/empty-allocation-rvalue-non-null.rs index ac597bcb20870..a7cb04682c257 100644 --- a/src/test/run-pass/empty-allocation-rvalue-non-null.rs +++ b/src/test/run-pass/empty-allocation-rvalue-non-null.rs @@ -1,5 +1,5 @@ #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x = *Box::new(()); diff --git a/src/test/run-pass/explicit-i-suffix.rs b/src/test/run-pass/explicit-i-suffix.rs index 119cce3087e84..4867519d16fd4 100644 --- a/src/test/run-pass/explicit-i-suffix.rs +++ b/src/test/run-pass/explicit-i-suffix.rs @@ -1,5 +1,5 @@ #![allow(unused_must_use)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x: isize = 8; diff --git a/src/test/run-pass/export-glob-imports-target.rs b/src/test/run-pass/export-glob-imports-target.rs index 0ac80e657982d..316503ed26164 100644 --- a/src/test/run-pass/export-glob-imports-target.rs +++ b/src/test/run-pass/export-glob-imports-target.rs @@ -5,7 +5,7 @@ // Modified to not use export since it's going away. --pcw -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { use foo::bar::*; diff --git a/src/test/run-pass/export-multi.rs b/src/test/run-pass/export-multi.rs index bfa2765d25457..acd100abe286b 100644 --- a/src/test/run-pass/export-multi.rs +++ b/src/test/run-pass/export-multi.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use m::f; use m::g; diff --git a/src/test/run-pass/expr-empty-ret.rs b/src/test/run-pass/expr-empty-ret.rs index 6bdf4350a9907..b3ea9179d55d0 100644 --- a/src/test/run-pass/expr-empty-ret.rs +++ b/src/test/run-pass/expr-empty-ret.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // Issue #521 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f() { let _x = match true { diff --git a/src/test/run-pass/expr-scope.rs b/src/test/run-pass/expr-scope.rs index 15bb4a2eb0b44..5124776f9645b 100644 --- a/src/test/run-pass/expr-scope.rs +++ b/src/test/run-pass/expr-scope.rs @@ -1,6 +1,6 @@ // Regression test for issue #762 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn f() { } pub fn main() { return ::f(); } diff --git a/src/test/run-pass/extern/extern-1.rs b/src/test/run-pass/extern/extern-1.rs index eb9aabc87bc8b..2ef5d5acd7c52 100644 --- a/src/test/run-pass/extern/extern-1.rs +++ b/src/test/run-pass/extern/extern-1.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern fn f() { } diff --git a/src/test/run-pass/extern/extern-calling-convention-test.rs b/src/test/run-pass/extern/extern-calling-convention-test.rs index 7231a7cde85e0..9570b7d35c4ef 100644 --- a/src/test/run-pass/extern/extern-calling-convention-test.rs +++ b/src/test/run-pass/extern/extern-calling-convention-test.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:extern_calling_convention.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate extern_calling_convention; diff --git a/src/test/run-pass/extern/extern-foreign-crate.rs b/src/test/run-pass/extern/extern-foreign-crate.rs index 7f774c44277f3..fca883ee3b056 100644 --- a/src/test/run-pass/extern/extern-foreign-crate.rs +++ b/src/test/run-pass/extern/extern-foreign-crate.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate std as mystd; diff --git a/src/test/run-pass/extern/extern-mod-abi.rs b/src/test/run-pass/extern/extern-mod-abi.rs index c543394cca05f..3ab3c1728e4dc 100644 --- a/src/test/run-pass/extern/extern-mod-abi.rs +++ b/src/test/run-pass/extern/extern-mod-abi.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern "C" { fn pow(x: f64, y: f64) -> f64; diff --git a/src/test/run-pass/extern/extern-mod-ordering-exe.rs b/src/test/run-pass/extern/extern-mod-ordering-exe.rs index d7cc4dffb440a..70207b955b1e7 100644 --- a/src/test/run-pass/extern/extern-mod-ordering-exe.rs +++ b/src/test/run-pass/extern/extern-mod-ordering-exe.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:extern_mod_ordering_lib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate extern_mod_ordering_lib; diff --git a/src/test/run-pass/extern/extern-pass-empty.rs b/src/test/run-pass/extern/extern-pass-empty.rs index 07099a2420483..aaa50367ea87c 100644 --- a/src/test/run-pass/extern/extern-pass-empty.rs +++ b/src/test/run-pass/extern/extern-pass-empty.rs @@ -3,7 +3,7 @@ // Test a foreign function that accepts empty struct. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-msvc // ignore-emscripten emcc asserts on an empty struct as an argument diff --git a/src/test/run-pass/extern/extern-pub.rs b/src/test/run-pass/extern/extern-pub.rs index c97e04b0755ee..d6df868ce649d 100644 --- a/src/test/run-pass/extern/extern-pub.rs +++ b/src/test/run-pass/extern/extern-pub.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern { pub fn free(p: *const u8); diff --git a/src/test/run-pass/extern/extern-rust.rs b/src/test/run-pass/extern/extern-rust.rs index 0cb190257be89..8ea225210a3cb 100644 --- a/src/test/run-pass/extern/extern-rust.rs +++ b/src/test/run-pass/extern/extern-rust.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[repr(C)] pub struct Foo(u32); diff --git a/src/test/run-pass/filter-block-view-items.rs b/src/test/run-pass/filter-block-view-items.rs index d2b9866504a98..d116639c96709 100644 --- a/src/test/run-pass/filter-block-view-items.rs +++ b/src/test/run-pass/filter-block-view-items.rs @@ -1,7 +1,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { // Make sure that this view item is filtered out because otherwise it would - // trigger a compilation error + // trigger a compilation error. #[cfg(not_present)] use bar as foo; } diff --git a/src/test/run-pass/fixup-deref-mut.rs b/src/test/run-pass/fixup-deref-mut.rs index a35412fea3fec..a63bff01caf02 100644 --- a/src/test/run-pass/fixup-deref-mut.rs +++ b/src/test/run-pass/fixup-deref-mut.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ops::{Deref, DerefMut}; diff --git a/src/test/run-pass/for-loop-while/break-value.rs b/src/test/run-pass/for-loop-while/break-value.rs index 9fc49fa8181b1..1bf27f9d289a8 100644 --- a/src/test/run-pass/for-loop-while/break-value.rs +++ b/src/test/run-pass/for-loop-while/break-value.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unreachable_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn int_id(x: isize) -> isize { return x; } diff --git a/src/test/run-pass/for-loop-while/labeled-break.rs b/src/test/run-pass/for-loop-while/labeled-break.rs index 4dacc57574f17..cd83b5a569cc7 100644 --- a/src/test/run-pass/for-loop-while/labeled-break.rs +++ b/src/test/run-pass/for-loop-while/labeled-break.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { 'foo: loop { diff --git a/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs index 11b6971656f08..567009d7e3263 100644 --- a/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs +++ b/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_assignments)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unreachable_code)] #![allow(unused_variables)] diff --git a/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs b/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs index ce73d6335cb21..1819e9f6abc02 100644 --- a/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs +++ b/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn take(x: isize) -> isize {x} diff --git a/src/test/run-pass/for-loop-while/loop-diverges.rs b/src/test/run-pass/for-loop-while/loop-diverges.rs index f657bf9e0b3bc..51809c2115bf7 100644 --- a/src/test/run-pass/for-loop-while/loop-diverges.rs +++ b/src/test/run-pass/for-loop-while/loop-diverges.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_parens)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* Make sure a loop{} can be the tailexpr in the body of a diverging function */ diff --git a/src/test/run-pass/for-loop-while/loop-label-shadowing.rs b/src/test/run-pass/for-loop-while/loop-label-shadowing.rs index acb53e254bb78..181e8cd8b2511 100644 --- a/src/test/run-pass/for-loop-while/loop-label-shadowing.rs +++ b/src/test/run-pass/for-loop-while/loop-label-shadowing.rs @@ -1,7 +1,7 @@ // run-pass // Issue #12512. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let mut foo = Vec::new(); diff --git a/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs b/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs index cc8f826983b6a..15be08c1fd65f 100644 --- a/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs +++ b/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { 'outer: loop { diff --git a/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs b/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs index 1b5db20129d8b..e2c18f1ac18c5 100644 --- a/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs +++ b/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S; // Ensure S is moved, not copied, on assignment. diff --git a/src/test/run-pass/for-loop-while/while-flow-graph.rs b/src/test/run-pass/for-loop-while/while-flow-graph.rs index 1748964a7b2a0..e9f374b05f06a 100644 --- a/src/test/run-pass/for-loop-while/while-flow-graph.rs +++ b/src/test/run-pass/for-loop-while/while-flow-graph.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x: isize = 10; while x == 10 && x == 11 { let _y = 0xf00_usize; } } diff --git a/src/test/run-pass/foreign/auxiliary/foreign_lib.rs b/src/test/run-pass/foreign/auxiliary/foreign_lib.rs index de6b0e2118a58..be1a6b78cf4f5 100644 --- a/src/test/run-pass/foreign/auxiliary/foreign_lib.rs +++ b/src/test/run-pass/foreign/auxiliary/foreign_lib.rs @@ -23,7 +23,7 @@ pub mod rustrt3 { // Different type, but same ABI (on all supported platforms). // Ensures that we don't ICE or trigger LLVM asserts when // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. + // See issue #32740. extern { pub fn rust_get_test_int() -> *const u8; } diff --git a/src/test/run-pass/foreign/foreign-mod-unused-const.rs b/src/test/run-pass/foreign/foreign-mod-unused-const.rs index d9efbe00e525d..7891c6cc64de7 100644 --- a/src/test/run-pass/foreign/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign/foreign-mod-unused-const.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { extern { diff --git a/src/test/run-pass/foreign/foreign-no-abi.rs b/src/test/run-pass/foreign/foreign-no-abi.rs index 2f33fb4765690..2183018597976 100644 --- a/src/test/run-pass/foreign/foreign-no-abi.rs +++ b/src/test/run-pass/foreign/foreign-no-abi.rs @@ -2,7 +2,7 @@ // ABI is cdecl by default // ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(rustc_private)] diff --git a/src/test/run-pass/foreign/foreign-truncated-arguments.rs b/src/test/run-pass/foreign/foreign-truncated-arguments.rs index c61c2b587b652..e5a3f1f5f606a 100644 --- a/src/test/run-pass/foreign/foreign-truncated-arguments.rs +++ b/src/test/run-pass/foreign/foreign-truncated-arguments.rs @@ -1,6 +1,5 @@ // run-pass // compile-flags: -O -// Regression test for https://github.com/rust-lang/rust/issues/33868 #[repr(C)] pub struct S { diff --git a/src/test/run-pass/foreign/foreign2.rs b/src/test/run-pass/foreign/foreign2.rs index c1ab57776f6dc..7b6fd31c4664c 100644 --- a/src/test/run-pass/foreign/foreign2.rs +++ b/src/test/run-pass/foreign/foreign2.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] // ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(rustc_private)] diff --git a/src/test/run-pass/format-ref-cell.rs b/src/test/run-pass/format-ref-cell.rs index 0e7925af78f24..8f1358ea5a365 100644 --- a/src/test/run-pass/format-ref-cell.rs +++ b/src/test/run-pass/format-ref-cell.rs @@ -3,6 +3,6 @@ use std::cell::RefCell; pub fn main() { let name = RefCell::new("rust"); let what = RefCell::new("rocks"); - let msg = format!("{name} {}", &*what.borrow(), name=&*name.borrow()); + let msg = format!("{name} {}", &*what.borrow(), name = &*name.borrow()); assert_eq!(msg, "rust rocks".to_string()); } diff --git a/src/test/run-pass/fsu-moves-and-copies.rs b/src/test/run-pass/fsu-moves-and-copies.rs index f9544ec39a0c7..8098ce2c02708 100644 --- a/src/test/run-pass/fsu-moves-and-copies.rs +++ b/src/test/run-pass/fsu-moves-and-copies.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] #![allow(stable_features)] -// Issue 4691: Ensure that functional-struct-updates operates +// Issue #4691: Ensure that functional-struct-updates operates // correctly and moves rather than copy when appropriate. #![feature(box_syntax, core)] @@ -33,7 +33,7 @@ impl Drop for DropMoveFoo { fn drop(&mut self) { } } fn test0() { // just copy implicitly copyable fields from `f`, no moves - // (and thus it is okay that these are Drop; compare against + // (and thus it is ok that these are Drop; compare against // compile-fail test: borrowck-struct-update-with-dtor.rs). // Case 1: Nocopyable diff --git a/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs b/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs index ccb2e201d7d12..83add2eb8b5f2 100644 --- a/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs +++ b/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync::mpsc::channel; diff --git a/src/test/run-pass/functions-closures/closure-reform.rs b/src/test/run-pass/functions-closures/closure-reform.rs index 0bb6159ff4aa1..1af371f3bbd25 100644 --- a/src/test/run-pass/functions-closures/closure-reform.rs +++ b/src/test/run-pass/functions-closures/closure-reform.rs @@ -1,7 +1,6 @@ // run-pass + #![allow(unused_variables)] -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ fn call_it(f: F) where F : FnOnce(String) -> String diff --git a/src/test/run-pass/functions-closures/fn-abi.rs b/src/test/run-pass/functions-closures/fn-abi.rs index 900af9c1f66b7..a0f7273ff27e3 100644 --- a/src/test/run-pass/functions-closures/fn-abi.rs +++ b/src/test/run-pass/functions-closures/fn-abi.rs @@ -2,7 +2,7 @@ // Ensure that declarations and types which use `extern fn` both have the same // ABI (#9309). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // aux-build:fn-abi.rs extern crate fn_abi; diff --git a/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs b/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs index 922e016ddc808..bfd749b54da19 100644 --- a/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn bare() {} diff --git a/src/test/run-pass/functions-closures/fn-coerce-field.rs b/src/test/run-pass/functions-closures/fn-coerce-field.rs index 38bde7b9e8fbc..80bd74b0dd9ee 100644 --- a/src/test/run-pass/functions-closures/fn-coerce-field.rs +++ b/src/test/run-pass/functions-closures/fn-coerce-field.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] struct r where F: FnOnce() { diff --git a/src/test/run-pass/functions-closures/fn-item-type-coerce.rs b/src/test/run-pass/functions-closures/fn-item-type-coerce.rs index 7a096764e45fe..218bf002ae00c 100644 --- a/src/test/run-pass/functions-closures/fn-item-type-coerce.rs +++ b/src/test/run-pass/functions-closures/fn-item-type-coerce.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // Test implicit coercions from a fn item type to a fn pointer type. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(x: isize) -> isize { x * 2 } fn bar(x: isize) -> isize { x * 4 } diff --git a/src/test/run-pass/functions-closures/fn-lval.rs b/src/test/run-pass/functions-closures/fn-lval.rs index 01079eea457c3..da0a639210f7a 100644 --- a/src/test/run-pass/functions-closures/fn-lval.rs +++ b/src/test/run-pass/functions-closures/fn-lval.rs @@ -2,7 +2,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(_f: fn(isize) -> isize) { } diff --git a/src/test/run-pass/functions-closures/fn-type-infer.rs b/src/test/run-pass/functions-closures/fn-type-infer.rs index fe6567f22b504..32fe8ddea3075 100644 --- a/src/test/run-pass/functions-closures/fn-type-infer.rs +++ b/src/test/run-pass/functions-closures/fn-type-infer.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] diff --git a/src/test/run-pass/generator/yield-in-initializer.rs b/src/test/run-pass/generator/yield-in-initializer.rs index 8ff35d8ddf10f..c338638b7f854 100644 --- a/src/test/run-pass/generator/yield-in-initializer.rs +++ b/src/test/run-pass/generator/yield-in-initializer.rs @@ -5,8 +5,8 @@ fn main() { static || { loop { - // Test that `opt` is not live across the yield, even when borrowed in a loop - // See https://github.com/rust-lang/rust/issues/52792 + // Test that `opt` is not live across the yield, even when borrowed in a loop. + // See issue #52792. let opt = { yield; true diff --git a/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs b/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs index 9e5eaa72c152f..17ccec9c59662 100644 --- a/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs +++ b/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:default_type_params_xc.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate default_type_params_xc; diff --git a/src/test/run-pass/generics/generic-fn-twice.rs b/src/test/run-pass/generics/generic-fn-twice.rs index 2f25fc24ced0b..2f9964ab20fe5 100644 --- a/src/test/run-pass/generics/generic-fn-twice.rs +++ b/src/test/run-pass/generics/generic-fn-twice.rs @@ -2,7 +2,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foomod { pub fn foo() { } diff --git a/src/test/run-pass/generics/generic-newtype-struct.rs b/src/test/run-pass/generics/generic-newtype-struct.rs index 570c982cc8700..82d20ff041e02 100644 --- a/src/test/run-pass/generics/generic-newtype-struct.rs +++ b/src/test/run-pass/generics/generic-newtype-struct.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S(T); diff --git a/src/test/run-pass/generics/generic-tag-corruption.rs b/src/test/run-pass/generics/generic-tag-corruption.rs index aa26183a0d491..b62afe56f46f6 100644 --- a/src/test/run-pass/generics/generic-tag-corruption.rs +++ b/src/test/run-pass/generics/generic-tag-corruption.rs @@ -3,7 +3,7 @@ // This used to cause memory corruption in stage 0. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum thing { some(K), } diff --git a/src/test/run-pass/generics/generic-tag-local.rs b/src/test/run-pass/generics/generic-tag-local.rs index cc85e6e0f0a8d..8a0f71f984b09 100644 --- a/src/test/run-pass/generics/generic-tag-local.rs +++ b/src/test/run-pass/generics/generic-tag-local.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum clam { a(T), } diff --git a/src/test/run-pass/generics/generic-tag.rs b/src/test/run-pass/generics/generic-tag.rs index 74ef4eeba8ab7..d7ba616b5a5ca 100644 --- a/src/test/run-pass/generics/generic-tag.rs +++ b/src/test/run-pass/generics/generic-tag.rs @@ -2,7 +2,7 @@ #![allow(unused_assignments)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] #![feature(box_syntax)] diff --git a/src/test/run-pass/generics/generic-type-synonym.rs b/src/test/run-pass/generics/generic-type-synonym.rs index 4f181fbcc7e38..39999c9f19491 100644 --- a/src/test/run-pass/generics/generic-type-synonym.rs +++ b/src/test/run-pass/generics/generic-type-synonym.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo { a: T diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs index 1591d616cac78..1f93fefbc7531 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs @@ -6,7 +6,7 @@ // `&Typer<'tcx>` was getting an incorrect binder level, yielding // weird compilation ICEs and so forth. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Typer<'tcx> { fn method(&self, data: &'tcx isize) -> &'tcx isize { data } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs index 09152970fdcd2..cab8fb156eea8 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Typer<'tcx> { fn method(&self, data: &'tcx isize) -> &'tcx isize { data } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs index 3fb0b3290eb02..b691b71f76939 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs @@ -2,7 +2,7 @@ // Test that we can parse all the various places that a `for` keyword // can appear representing universal quantification. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] #![allow(dead_code)] diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs index 42247798f661b..163bc38334e28 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // Test that `F : Fn(isize) -> isize + Send` is interpreted as two // distinct bounds on `F`. diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs index 5fda4b826e00c..62c73969e9ee3 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // Test that `Fn(isize) -> isize + 'static` parses as `(Fn(isize) -> isize) + // 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs index 917f6f9611844..39424fcad1b8a 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // A basic test of using a higher-ranked trait bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait FnLike { fn call(&self, arg: A) -> R; diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs index 4cb9242f0ed80..3827573a45016 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs @@ -4,7 +4,7 @@ // PrinterSupport<'b>`, gets properly expanded when it appears in a // closure type. This used to result in messed up De Bruijn indices. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait PrinterSupport<'ast> { fn ast_map(&self) -> Option<&'ast usize> { None } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs index a8f38180cc29d..b867bd95c9a65 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs @@ -1,10 +1,12 @@ // run-pass -#![allow(dead_code)] -#![allow(unused_variables)] + // Test what happens when a HR obligation is applied to an impl with // "outlives" bounds. Currently we're pretty conservative here; this // will probably improve in time. +#![allow(dead_code)] +#![allow(unused_variables)] + trait Foo { fn foo(&self, x: X) { } } @@ -15,7 +17,7 @@ fn want_foo() } /////////////////////////////////////////////////////////////////////////// -// Expressed as a where clause +// Expressed as a where-clause struct SomeStruct { x: X diff --git a/src/test/run-pass/hygiene/hygiene-dodging-1.rs b/src/test/run-pass/hygiene/hygiene-dodging-1.rs index 69e47e82ba5e6..94795a7aa24e6 100644 --- a/src/test/run-pass/hygiene/hygiene-dodging-1.rs +++ b/src/test/run-pass/hygiene/hygiene-dodging-1.rs @@ -1,4 +1,5 @@ // run-pass + #![allow(unused_must_use)] mod x { @@ -6,9 +7,9 @@ mod x { } pub fn main(){ - // should *not* shadow the module x: + // Should **not** shadow the module `x`. let x = 9; - // use it to avoid warnings: - x+3; - assert_eq!(x::g(),14); + // Use it to avoid warnings. + x + 3; + assert_eq!(x::g(), 14); } diff --git a/src/test/run-pass/hygiene/hygienic-labels-in-let.rs b/src/test/run-pass/hygiene/hygienic-labels-in-let.rs index fb9523b547d2e..b078d64cf5863 100644 --- a/src/test/run-pass/hygiene/hygienic-labels-in-let.rs +++ b/src/test/run-pass/hygiene/hygienic-labels-in-let.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unreachable_code)] -// Test that labels injected by macros do not break hygiene. This +// Test that labels injected by macros do not break hygiene. This // checks cases where the macros invocations are under the rhs of a // let statement. diff --git a/src/test/run-pass/if-ret.rs b/src/test/run-pass/if-ret.rs index 3c2377466a150..b930f3ac14b85 100644 --- a/src/test/run-pass/if-ret.rs +++ b/src/test/run-pass/if-ret.rs @@ -1,5 +1,5 @@ #![allow(unused_parens)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo() { if (return) { } } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 56222fa46f7c9..fc2ea7b333c6a 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -183,9 +183,9 @@ pub fn main() { // Ergonomic format_args! t!(format!("{0:x} {0:X}", 15), "f F"); t!(format!("{0:x} {0:X} {}", 15), "f F 15"); - // NOTE: For now the longer test cases must not be followed immediately by - // >1 empty lines, or the pretty printer will break. Since no one wants to - // touch the current pretty printer (#751), we have no choice but to work + // NOTE: for now, the longer test cases must not be followed immediately by + // >1 empty lines, or the pretty-printer will break. Since no one wants to + // touch the current pretty-printer (#751), we have no choice but to work // around it. Some of the following test cases are also affected. t!(format!("{:x}{0:X}{a:x}{:X}{1:x}{a:X}", 13, 14, a=15), "dDfEeF"); t!(format!("{a:x} {a:X}", a=15), "f F"); diff --git a/src/test/run-pass/ignore-all-the-things.rs b/src/test/run-pass/ignore-all-the-things.rs index 6916a199a1003..5edd3c2b0eba4 100644 --- a/src/test/run-pass/ignore-all-the-things.rs +++ b/src/test/run-pass/ignore-all-the-things.rs @@ -1,7 +1,7 @@ #![allow(non_shorthand_field_patterns)] #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(slice_patterns)] diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs index 42e149eacb543..f67c73a31903d 100644 --- a/src/test/run-pass/impl-privacy-xc-1.rs +++ b/src/test/run-pass/impl-privacy-xc-1.rs @@ -1,6 +1,6 @@ // aux-build:impl_privacy_xc_1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate impl_privacy_xc_1; diff --git a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs index ac016258b7f92..7a265ab1a4c8e 100644 --- a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs +++ b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs @@ -1,7 +1,9 @@ -// NOTE commented out due to issue #45994 -//pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 { -// move |b| move |c| move |d| a + b + c + d -//} +// NOTE: commented out due to issue #45994. +/* +pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 { + move |b| move |c| move |d| a + b + c + d +} +*/ fn some_internal_fn() -> u32 { 1 diff --git a/src/test/run-pass/impl-trait/example-calendar.rs b/src/test/run-pass/impl-trait/example-calendar.rs index cd3d48f1a03b2..30699ec57f765 100644 --- a/src/test/run-pass/impl-trait/example-calendar.rs +++ b/src/test/run-pass/impl-trait/example-calendar.rs @@ -330,7 +330,7 @@ fn test_spaces() { } /// Returns an iterator of dates in a given year. -fn dates_in_year(year: i32) -> impl Iterator+Clone { +fn dates_in_year(year: i32) -> impl Iterator+Clone { InGroup { it: NaiveDate::from_ymd(year, 1, 1).., f: |d: &NaiveDate| d.year(), @@ -376,8 +376,8 @@ fn test_dates_in_year() { /// Convenience trait for verifying that a given type iterates over /// `NaiveDate`s. -trait DateIterator: Iterator + Clone {} -impl DateIterator for It where It: Iterator + Clone {} +trait DateIterator: Iterator + Clone {} +impl DateIterator for It where It: Iterator + Clone {} fn test_group_by() { let input = [ @@ -412,8 +412,8 @@ fn test_group_by() { } /// Groups an iterator of dates by month. -fn by_month(it: impl Iterator + Clone) - -> impl Iterator + Clone)> + Clone +fn by_month(it: impl Iterator + Clone) + -> impl Iterator + Clone)> + Clone { it.group_by(|d| d.month()) } @@ -499,7 +499,7 @@ const COLS_PER_DAY: u32 = 3; const COLS_PER_WEEK: u32 = 7 * COLS_PER_DAY; /// Formats an iterator of weeks into an iterator of strings. -fn format_weeks(it: impl Iterator) -> impl Iterator { +fn format_weeks(it: impl Iterator) -> impl Iterator { it.map(|week| { let mut buf = String::with_capacity((COLS_PER_DAY * COLS_PER_WEEK + 2) as usize); @@ -527,8 +527,9 @@ fn format_weeks(it: impl Iterator) -> impl Iterator`. + // Pick January 2013 for testing purposes. + .__(by_month).next() + // NOTE: this `map` is because `next` returns an `Option<_>`. .map(|(_, month)| month.__(by_week) .map(|(_, weeks)| weeks) @@ -573,7 +574,7 @@ fn test_month_title() { } /// Formats a month. -fn format_month(it: impl DateIterator) -> impl Iterator { +fn format_month(it: impl DateIterator) -> impl Iterator { let mut month_days = it.peekable(); let title = month_title(month_days.peek().unwrap().month()); @@ -603,7 +604,7 @@ fn test_format_month() { /// Formats an iterator of months. fn format_months(it: impl Iterator) - -> impl Iterator> + -> impl Iterator> { it.map(format_month) } @@ -622,10 +623,10 @@ where Self::Item: Iterator { } } -impl PasteBlocks for It where It: Iterator, It::Item: Iterator {} +impl PasteBlocks for It where It: Iterator, It::Item: Iterator {} struct PasteBlocksIter -where StrIt: Iterator { +where StrIt: Iterator { iters: Vec, cache: Vec>, col_widths: Option>, @@ -633,7 +634,7 @@ where StrIt: Iterator { } impl Iterator for PasteBlocksIter -where StrIt: Iterator { +where StrIt: Iterator { type Item = String; fn next(&mut self) -> Option { diff --git a/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs b/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs index 64a4deca8c359..e49247a3a4864 100644 --- a/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs +++ b/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:crate_with_invalid_spans.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate crate_with_invalid_spans; diff --git a/src/test/run-pass/imports/import-from.rs b/src/test/run-pass/imports/import-from.rs index 2817977b39394..11e8b7092b3b1 100644 --- a/src/test/run-pass/imports/import-from.rs +++ b/src/test/run-pass/imports/import-from.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use spam::{ham, eggs}; diff --git a/src/test/run-pass/imports/import-in-block.rs b/src/test/run-pass/imports/import-in-block.rs index c0ba6220b5443..259cd7a61465b 100644 --- a/src/test/run-pass/imports/import-in-block.rs +++ b/src/test/run-pass/imports/import-in-block.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { use std::mem::replace; diff --git a/src/test/run-pass/imports/import-trailing-comma.rs b/src/test/run-pass/imports/import-trailing-comma.rs index f65c5c866a3b8..b45cc177e5994 100644 --- a/src/test/run-pass/imports/import-trailing-comma.rs +++ b/src/test/run-pass/imports/import-trailing-comma.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use foo::bar::{baz, quux,}; diff --git a/src/test/run-pass/imports/imports.rs b/src/test/run-pass/imports/imports.rs index acb2b32b59d5f..cda4377e6f7db 100644 --- a/src/test/run-pass/imports/imports.rs +++ b/src/test/run-pass/imports/imports.rs @@ -1,4 +1,5 @@ // run-pass + #![allow(unused)] // Like other items, private imports can be imported and used non-lexically in paths. @@ -33,9 +34,12 @@ fn h() { // Here, there appears to be shadowing but isn't because of namespaces. mod b { - use foo::*; // This imports `f` in the value namespace. - use super::b as f; // This imports `f` only in the type namespace, - fn test() { self::f(); } // so the glob isn't shadowed. + // This imports `f` in the value namespace. + use foo::*; + // This imports `f` only in the type namespace, + use super::b as f; + // so the glob isn't shadowed. + fn test() { self::f(); } } // Here, there is shadowing in one namespace, but not the other. @@ -44,23 +48,30 @@ mod c { pub fn f() {} pub mod f {} } - use self::test::*; // This glob-imports `f` in both namespaces. - mod f { pub fn f() {} } // This shadows the glob only in the value namespace. + // This glob-imports `f` in both namespaces. + use self::test::*; + // This shadows the glob only in the value namespace. + mod f { pub fn f() {} } fn test() { - self::f(); // Check that the glob-imported value isn't shadowed. - self::f::f(); // Check that the glob-imported module is shadowed. + // Check that the glob-imported value isn't shadowed. + self::f(); + // Check that the glob-imported module is shadowed. + self::f::f(); } } // Unused names can be ambiguous. mod d { - pub use foo::*; // This imports `f` in the value namespace. - pub use bar::*; // This also imports `f` in the value namespace. + // This imports `f` in the value namespace. + pub use foo::*; + // This also imports `f` in the value namespace. + pub use bar::*; } mod e { - pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. + // N.B., since `e::f` is not used, this is not considered to be a use of `d::f`. + pub use d::*; } fn main() {} diff --git a/src/test/run-pass/infer-fn-tail-expr.rs b/src/test/run-pass/infer-fn-tail-expr.rs index ab0210baa96ed..5dbdfa619cd4d 100644 --- a/src/test/run-pass/infer-fn-tail-expr.rs +++ b/src/test/run-pass/infer-fn-tail-expr.rs @@ -2,7 +2,7 @@ // issue #680 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f() -> Vec { Vec::new() } diff --git a/src/test/run-pass/init-large-type.rs b/src/test/run-pass/init-large-type.rs index cb64cd0b0f3a8..4c0cf2aae8970 100644 --- a/src/test/run-pass/init-large-type.rs +++ b/src/test/run-pass/init-large-type.rs @@ -3,7 +3,7 @@ // Doing it incorrectly causes massive slowdown in LLVM during // optimisation. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads support #![feature(intrinsics)] diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs index fe8d9f9714915..82ca0a7d6a2c7 100644 --- a/src/test/run-pass/instantiable.rs +++ b/src/test/run-pass/instantiable.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ptr; diff --git a/src/test/run-pass/intrinsics/intrinsic-uninit.rs b/src/test/run-pass/intrinsics/intrinsic-uninit.rs index 9555efb639b50..b9c599b7a6092 100644 --- a/src/test/run-pass/intrinsics/intrinsic-uninit.rs +++ b/src/test/run-pass/intrinsics/intrinsic-uninit.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(intrinsics)] diff --git a/src/test/run-pass/invoke-external-foreign.rs b/src/test/run-pass/invoke-external-foreign.rs index d34933cde4246..4365db14daf61 100644 --- a/src/test/run-pass/invoke-external-foreign.rs +++ b/src/test/run-pass/invoke-external-foreign.rs @@ -5,7 +5,7 @@ // successfully (and safely) invoke external, cdecl // functions from outside the crate. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate foreign_lib; diff --git a/src/test/run-pass/irrefutable-unit.rs b/src/test/run-pass/irrefutable-unit.rs index f588ae3a55742..922b9a50444c1 100644 --- a/src/test/run-pass/irrefutable-unit.rs +++ b/src/test/run-pass/irrefutable-unit.rs @@ -1,5 +1,5 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { - let ((),()) = ((),()); + let ((), ()) = ((), ()); } diff --git a/src/test/run-pass/issue-53843.rs b/src/test/run-pass/issue-53843.rs index 53728ec4d9fa5..03657da697c4b 100644 --- a/src/test/run-pass/issue-53843.rs +++ b/src/test/run-pass/issue-53843.rs @@ -4,7 +4,7 @@ pub struct Pin

(P); impl Deref for Pin

where - P: Deref, + P: Deref, { type Target = T; diff --git a/src/test/run-pass/issues/auxiliary/issue34796aux.rs b/src/test/run-pass/issues/auxiliary/issue34796aux.rs index 09c69b90329ff..68a9704f0e590 100644 --- a/src/test/run-pass/issues/auxiliary/issue34796aux.rs +++ b/src/test/run-pass/issues/auxiliary/issue34796aux.rs @@ -9,7 +9,7 @@ impl Future for u32 { type Error = Box<()>; } -fn foo() -> Box>> { +fn foo() -> Box>> { Box::new(0u32) } diff --git a/src/test/run-pass/issues/issue-10025.rs b/src/test/run-pass/issues/issue-10025.rs index 193d7ee891f07..e05dd29e94487 100644 --- a/src/test/run-pass/issues/issue-10025.rs +++ b/src/test/run-pass/issues/issue-10025.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) unsafe extern fn foo() {} unsafe extern "C" fn bar() {} diff --git a/src/test/run-pass/issues/issue-10028.rs b/src/test/run-pass/issues/issue-10028.rs index 1692470e8d1a8..b8e9818070a21 100644 --- a/src/test/run-pass/issues/issue-10028.rs +++ b/src/test/run-pass/issues/issue-10028.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // aux-build:issue-10028.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_10028 as issue10028; diff --git a/src/test/run-pass/issues/issue-10031.rs b/src/test/run-pass/issues/issue-10031.rs index ba1fbac48453a..8ee821d61bdf0 100644 --- a/src/test/run-pass/issues/issue-10031.rs +++ b/src/test/run-pass/issues/issue-10031.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:issue_10031_aux.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_10031_aux; diff --git a/src/test/run-pass/issues/issue-10228.rs b/src/test/run-pass/issues/issue-10228.rs index ebf8b436f132f..b9cdf85005293 100644 --- a/src/test/run-pass/issues/issue-10228.rs +++ b/src/test/run-pass/issues/issue-10228.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum StdioContainer { CreatePipe(bool) diff --git a/src/test/run-pass/issues/issue-10638.rs b/src/test/run-pass/issues/issue-10638.rs index e359669c00dad..1969e4948c78d 100644 --- a/src/test/run-pass/issues/issue-10638.rs +++ b/src/test/run-pass/issues/issue-10638.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { //// I am not a doc comment! diff --git a/src/test/run-pass/issues/issue-10682.rs b/src/test/run-pass/issues/issue-10682.rs index afaa90f05caa1..aea81396e665d 100644 --- a/src/test/run-pass/issues/issue-10682.rs +++ b/src/test/run-pass/issues/issue-10682.rs @@ -2,7 +2,7 @@ // Regression test for issue #10682 // Nested `proc` usage can't use outer owned data -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-10683.rs b/src/test/run-pass/issues/issue-10683.rs index dcb221f8c5776..26c326d76d019 100644 --- a/src/test/run-pass/issues/issue-10683.rs +++ b/src/test/run-pass/issues/issue-10683.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) static NAME: &'static str = "hello world"; diff --git a/src/test/run-pass/issues/issue-10718.rs b/src/test/run-pass/issues/issue-10718.rs index a1de0cfe6ca6a..9a4844bf9b140 100644 --- a/src/test/run-pass/issues/issue-10718.rs +++ b/src/test/run-pass/issues/issue-10718.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(p: F) { p(); diff --git a/src/test/run-pass/issues/issue-10764.rs b/src/test/run-pass/issues/issue-10764.rs index 42ed1ae93b551..2d31f32dcab19 100644 --- a/src/test/run-pass/issues/issue-10764.rs +++ b/src/test/run-pass/issues/issue-10764.rs @@ -1,4 +1,4 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern "Rust" fn main() {} diff --git a/src/test/run-pass/issues/issue-10767.rs b/src/test/run-pass/issues/issue-10767.rs index fa10f073b4576..66db71ba26013 100644 --- a/src/test/run-pass/issues/issue-10767.rs +++ b/src/test/run-pass/issues/issue-10767.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-10806.rs b/src/test/run-pass/issues/issue-10806.rs index 2f1d7bb5aaf3d..9cc1e387509ca 100644 --- a/src/test/run-pass/issues/issue-10806.rs +++ b/src/test/run-pass/issues/issue-10806.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn foo() -> isize { 3 diff --git a/src/test/run-pass/issues/issue-11085.rs b/src/test/run-pass/issues/issue-11085.rs index 47c03238b55f0..da9411ccf36db 100644 --- a/src/test/run-pass/issues/issue-11085.rs +++ b/src/test/run-pass/issues/issue-11085.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // compile-flags: --cfg foo -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo { #[cfg(fail)] diff --git a/src/test/run-pass/issues/issue-11205.rs b/src/test/run-pass/issues/issue-11205.rs index b628bf601968d..c87bf905baedb 100644 --- a/src/test/run-pass/issues/issue-11205.rs +++ b/src/test/run-pass/issues/issue-11205.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/issues/issue-11224.rs b/src/test/run-pass/issues/issue-11224.rs index e1c1df99aca9e..e3b87ab84c3fe 100644 --- a/src/test/run-pass/issues/issue-11224.rs +++ b/src/test/run-pass/issues/issue-11224.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-11224.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_11224 as unused; diff --git a/src/test/run-pass/issues/issue-11225-1.rs b/src/test/run-pass/issues/issue-11225-1.rs index d1f2ea5e7de28..ad8eab532c3f6 100644 --- a/src/test/run-pass/issues/issue-11225-1.rs +++ b/src/test/run-pass/issues/issue-11225-1.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-11225-1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_11225_1 as foo; diff --git a/src/test/run-pass/issues/issue-11225-2.rs b/src/test/run-pass/issues/issue-11225-2.rs index d41c75443f1a6..38fa9cc21ab97 100644 --- a/src/test/run-pass/issues/issue-11225-2.rs +++ b/src/test/run-pass/issues/issue-11225-2.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-11225-2.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_11225_2 as foo; diff --git a/src/test/run-pass/issues/issue-11225-3.rs b/src/test/run-pass/issues/issue-11225-3.rs index e69496baa2669..753aada1e558a 100644 --- a/src/test/run-pass/issues/issue-11225-3.rs +++ b/src/test/run-pass/issues/issue-11225-3.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-11225-3.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_11225_3; diff --git a/src/test/run-pass/issues/issue-11529.rs b/src/test/run-pass/issues/issue-11529.rs index 9a6cc8e9fe881..587607b026816 100644 --- a/src/test/run-pass/issues/issue-11529.rs +++ b/src/test/run-pass/issues/issue-11529.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-11529.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_11529 as a; diff --git a/src/test/run-pass/issues/issue-11820.rs b/src/test/run-pass/issues/issue-11820.rs index 7ffe9652797cf..a9316ede6af1d 100644 --- a/src/test/run-pass/issues/issue-11820.rs +++ b/src/test/run-pass/issues/issue-11820.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct NoClone; diff --git a/src/test/run-pass/issues/issue-12133-1.rs b/src/test/run-pass/issues/issue-12133-1.rs index 96ad5abd5483e..d2e8ef777ed30 100644 --- a/src/test/run-pass/issues/issue-12133-1.rs +++ b/src/test/run-pass/issues/issue-12133-1.rs @@ -2,7 +2,7 @@ // aux-build:issue-12133-rlib.rs // aux-build:issue-12133-dylib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_12133_rlib as a; extern crate issue_12133_dylib as b; diff --git a/src/test/run-pass/issues/issue-12133-2.rs b/src/test/run-pass/issues/issue-12133-2.rs index 02fec65c2ed54..5b65d32c71e29 100644 --- a/src/test/run-pass/issues/issue-12133-2.rs +++ b/src/test/run-pass/issues/issue-12133-2.rs @@ -3,7 +3,7 @@ // aux-build:issue-12133-dylib.rs // no-prefer-dynamic -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_12133_rlib as a; extern crate issue_12133_dylib as b; diff --git a/src/test/run-pass/issues/issue-12133-3.rs b/src/test/run-pass/issues/issue-12133-3.rs index c87a37ab6b787..0151a6026e276 100644 --- a/src/test/run-pass/issues/issue-12133-3.rs +++ b/src/test/run-pass/issues/issue-12133-3.rs @@ -6,7 +6,7 @@ // ignore-emscripten no dylib support // ignore-musl -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_12133_dylib2 as other; diff --git a/src/test/run-pass/issues/issue-1257.rs b/src/test/run-pass/issues/issue-1257.rs index de5a6d3592586..9515a0fc2aef4 100644 --- a/src/test/run-pass/issues/issue-1257.rs +++ b/src/test/run-pass/issues/issue-1257.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main () { let mut line = "".to_string(); diff --git a/src/test/run-pass/issues/issue-12612.rs b/src/test/run-pass/issues/issue-12612.rs index 158c2aed13724..2fe920ec64ec8 100644 --- a/src/test/run-pass/issues/issue-12612.rs +++ b/src/test/run-pass/issues/issue-12612.rs @@ -3,7 +3,7 @@ // aux-build:issue_12612_1.rs // aux-build:issue_12612_2.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_12612_1 as foo; extern crate issue_12612_2 as bar; diff --git a/src/test/run-pass/issues/issue-12660.rs b/src/test/run-pass/issues/issue-12660.rs index 44c492b43f0a8..c04c472eef0c2 100644 --- a/src/test/run-pass/issues/issue-12660.rs +++ b/src/test/run-pass/issues/issue-12660.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-12660-aux.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue12660aux; diff --git a/src/test/run-pass/issues/issue-12909.rs b/src/test/run-pass/issues/issue-12909.rs index a68d73a004f5d..aac7d47df753b 100644 --- a/src/test/run-pass/issues/issue-12909.rs +++ b/src/test/run-pass/issues/issue-12909.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::collections::HashMap; diff --git a/src/test/run-pass/issues/issue-13204.rs b/src/test/run-pass/issues/issue-13204.rs index 3d6aba8455a94..b0218931d19f7 100644 --- a/src/test/run-pass/issues/issue-13204.rs +++ b/src/test/run-pass/issues/issue-13204.rs @@ -5,7 +5,7 @@ pub trait Foo { - fn bar<'a, I: Iterator>(&self, it: I) -> usize { + fn bar<'a, I: Iterator>(&self, it: I) -> usize { let mut xs = it.filter(|_| true); xs.count() } diff --git a/src/test/run-pass/issues/issue-13620.rs b/src/test/run-pass/issues/issue-13620.rs index 3c3c19df75d63..c023df710fd5d 100644 --- a/src/test/run-pass/issues/issue-13620.rs +++ b/src/test/run-pass/issues/issue-13620.rs @@ -2,7 +2,7 @@ // aux-build:issue-13620-1.rs // aux-build:issue-13620-2.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_13620_2 as crate2; diff --git a/src/test/run-pass/issues/issue-13665.rs b/src/test/run-pass/issues/issue-13665.rs index a3843c65034bc..890982735a7a4 100644 --- a/src/test/run-pass/issues/issue-13665.rs +++ b/src/test/run-pass/issues/issue-13665.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo<'r>() { let maybe_value_ref: Option<&'r u8> = None; diff --git a/src/test/run-pass/issues/issue-13763.rs b/src/test/run-pass/issues/issue-13763.rs index dd5f6dbc9dcbb..d49a84dfeb97d 100644 --- a/src/test/run-pass/issues/issue-13763.rs +++ b/src/test/run-pass/issues/issue-13763.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod u8 { pub const BITS: usize = 8; diff --git a/src/test/run-pass/issues/issue-13808.rs b/src/test/run-pass/issues/issue-13808.rs index d1b94c7186462..0bf781d5ca742 100644 --- a/src/test/run-pass/issues/issue-13808.rs +++ b/src/test/run-pass/issues/issue-13808.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo<'a> { listener: Box, diff --git a/src/test/run-pass/issues/issue-13872.rs b/src/test/run-pass/issues/issue-13872.rs index aade6b8367c0b..e5c774d66f96e 100644 --- a/src/test/run-pass/issues/issue-13872.rs +++ b/src/test/run-pass/issues/issue-13872.rs @@ -3,7 +3,7 @@ // aux-build:issue-13872-2.rs // aux-build:issue-13872-3.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_13872_3 as other; diff --git a/src/test/run-pass/issues/issue-14393.rs b/src/test/run-pass/issues/issue-14393.rs index df635407af6ee..9b5768d933bdb 100644 --- a/src/test/run-pass/issues/issue-14393.rs +++ b/src/test/run-pass/issues/issue-14393.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { match ("", 1_usize) { diff --git a/src/test/run-pass/issues/issue-14399.rs b/src/test/run-pass/issues/issue-14399.rs index 1b57856e95566..b210771cced17 100644 --- a/src/test/run-pass/issues/issue-14399.rs +++ b/src/test/run-pass/issues/issue-14399.rs @@ -4,7 +4,7 @@ // value was coerced to a trait object. (v.clone() returns Box // which is coerced to Box). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-14421.rs b/src/test/run-pass/issues/issue-14421.rs index c59bd87065f25..f861e0a029ee8 100644 --- a/src/test/run-pass/issues/issue-14421.rs +++ b/src/test/run-pass/issues/issue-14421.rs @@ -3,7 +3,7 @@ // aux-build:issue-14421.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_14421 as bug_lib; diff --git a/src/test/run-pass/issues/issue-14422.rs b/src/test/run-pass/issues/issue-14422.rs index b9e2065d01468..7dfbcaebf1974 100644 --- a/src/test/run-pass/issues/issue-14422.rs +++ b/src/test/run-pass/issues/issue-14422.rs @@ -3,7 +3,7 @@ // aux-build:issue-14422.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_14422 as bug_lib; diff --git a/src/test/run-pass/issues/issue-1451.rs b/src/test/run-pass/issues/issue-1451.rs index ad8928b2043ac..9200ae0fc5bc1 100644 --- a/src/test/run-pass/issues/issue-1451.rs +++ b/src/test/run-pass/issues/issue-1451.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_snake_case)] #![allow(unused_variables)] diff --git a/src/test/run-pass/issues/issue-14589.rs b/src/test/run-pass/issues/issue-14589.rs index d495602dff7e7..987dbd8dbd09f 100644 --- a/src/test/run-pass/issues/issue-14589.rs +++ b/src/test/run-pass/issues/issue-14589.rs @@ -2,7 +2,7 @@ // All 3 expressions should work in that the argument gets // coerced to a trait object -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { send::>(Box::new(Output(0))); diff --git a/src/test/run-pass/issues/issue-1460.rs b/src/test/run-pass/issues/issue-1460.rs index 143a0387e218f..19a3ee75e04a1 100644 --- a/src/test/run-pass/issues/issue-1460.rs +++ b/src/test/run-pass/issues/issue-1460.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { {|i: u32| if 1 == i { }}; diff --git a/src/test/run-pass/issues/issue-14919.rs b/src/test/run-pass/issues/issue-14919.rs index c6ccb7575bb83..c47c1919994ae 100644 --- a/src/test/run-pass/issues/issue-14919.rs +++ b/src/test/run-pass/issues/issue-14919.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_must_use)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Matcher { fn next_match(&mut self) -> Option<(usize, usize)>; diff --git a/src/test/run-pass/issues/issue-14958.rs b/src/test/run-pass/issues/issue-14958.rs index 17f7f159fd2db..8555ee0c7bf23 100644 --- a/src/test/run-pass/issues/issue-14958.rs +++ b/src/test/run-pass/issues/issue-14958.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(fn_traits, unboxed_closures)] diff --git a/src/test/run-pass/issues/issue-15043.rs b/src/test/run-pass/issues/issue-15043.rs index 53748be8a02f7..66716303e194b 100644 --- a/src/test/run-pass/issues/issue-15043.rs +++ b/src/test/run-pass/issues/issue-15043.rs @@ -1,12 +1,12 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(warnings)] struct S(T); -static s1: S>=S(S(0)); -static s2: S=S(0); +static s1: S> = S(S(0)); +static s2: S = S(0); fn main() { let foo: S>=S(S(0)); diff --git a/src/test/run-pass/issues/issue-15221.rs b/src/test/run-pass/issues/issue-15221.rs index 4b8319a8304ff..828e7e39fcd32 100644 --- a/src/test/run-pass/issues/issue-15221.rs +++ b/src/test/run-pass/issues/issue-15221.rs @@ -1,6 +1,6 @@ // run-pass #![allow(path_statements)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) macro_rules! inner { ($e:pat ) => ($e) diff --git a/src/test/run-pass/issues/issue-15444.rs b/src/test/run-pass/issues/issue-15444.rs index e94afee963419..9d1b6dd63e989 100644 --- a/src/test/run-pass/issues/issue-15444.rs +++ b/src/test/run-pass/issues/issue-15444.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait MyTrait { fn foo(&self); diff --git a/src/test/run-pass/issues/issue-15523-big.rs b/src/test/run-pass/issues/issue-15523-big.rs index 05414f1db72be..50bcdb69ee400 100644 --- a/src/test/run-pass/issues/issue-15523-big.rs +++ b/src/test/run-pass/issues/issue-15523-big.rs @@ -1,5 +1,5 @@ // run-pass -// Issue 15523: derive(PartialOrd) should use the provided +// Issue #15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. // // This test is checking corner cases that arise when you have diff --git a/src/test/run-pass/issues/issue-15523.rs b/src/test/run-pass/issues/issue-15523.rs index 220a34b9b0f3f..430fbb82b0f83 100644 --- a/src/test/run-pass/issues/issue-15523.rs +++ b/src/test/run-pass/issues/issue-15523.rs @@ -1,5 +1,5 @@ // run-pass -// Issue 15523: derive(PartialOrd) should use the provided +// Issue #15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. // // This is checking the basic functionality. diff --git a/src/test/run-pass/issues/issue-15562.rs b/src/test/run-pass/issues/issue-15562.rs index b37ba81e291e6..067c837e87b4e 100644 --- a/src/test/run-pass/issues/issue-15562.rs +++ b/src/test/run-pass/issues/issue-15562.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-15562.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_15562 as i; diff --git a/src/test/run-pass/issues/issue-15730.rs b/src/test/run-pass/issues/issue-15730.rs index dacffd154fc29..6478d87f3a67d 100644 --- a/src/test/run-pass/issues/issue-15730.rs +++ b/src/test/run-pass/issues/issue-15730.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let mut array = [1, 2, 3]; diff --git a/src/test/run-pass/issues/issue-15734.rs b/src/test/run-pass/issues/issue-15734.rs index be582060601e7..ee5ce4e240946 100644 --- a/src/test/run-pass/issues/issue-15734.rs +++ b/src/test/run-pass/issues/issue-15734.rs @@ -33,7 +33,7 @@ impl<'a, T> Index<(usize, usize)> for &'a Mat { struct Row { mat: M, row: usize, } -impl> Index for Row { +impl> Index for Row { type Output = T; fn index<'a>(&'a self, col: usize) -> &'a T { diff --git a/src/test/run-pass/issues/issue-15774.rs b/src/test/run-pass/issues/issue-15774.rs index ed2235758b9d9..ec329209ebece 100644 --- a/src/test/run-pass/issues/issue-15774.rs +++ b/src/test/run-pass/issues/issue-15774.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![deny(warnings)] #![allow(unused_imports)] diff --git a/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs b/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs index 2470e37e1820b..39e1f79ab3249 100644 --- a/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs +++ b/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs @@ -1,8 +1,9 @@ // run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 -// regression test for the model lexer handling the DOTDOTDOT syntax (#15877) +// FIXME(#41620) +#![allow(illegal_floating_point_literal_pattern)] +// Regression test for the model lexer handling the DOTDOTDOT syntax (#15877). pub fn main() { match 5_usize { diff --git a/src/test/run-pass/issues/issue-16256.rs b/src/test/run-pass/issues/issue-16256.rs index e566eede8d227..bac88d6472c0c 100644 --- a/src/test/run-pass/issues/issue-16256.rs +++ b/src/test/run-pass/issues/issue-16256.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let mut buf = Vec::new(); diff --git a/src/test/run-pass/issues/issue-16441.rs b/src/test/run-pass/issues/issue-16441.rs index bae3813f9da95..b39a65b2fdf7a 100644 --- a/src/test/run-pass/issues/issue-16441.rs +++ b/src/test/run-pass/issues/issue-16441.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Empty; diff --git a/src/test/run-pass/issues/issue-16452.rs b/src/test/run-pass/issues/issue-16452.rs index faf9edd3b2640..53eac3557f140 100644 --- a/src/test/run-pass/issues/issue-16452.rs +++ b/src/test/run-pass/issues/issue-16452.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { if true { return } diff --git a/src/test/run-pass/issues/issue-1660.rs b/src/test/run-pass/issues/issue-1660.rs index aa60a8d8a9693..5c224aafb3d82 100644 --- a/src/test/run-pass/issues/issue-1660.rs +++ b/src/test/run-pass/issues/issue-1660.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { static _x: isize = 1<<2; diff --git a/src/test/run-pass/issues/issue-16643.rs b/src/test/run-pass/issues/issue-16643.rs index c74a554af2e42..4f429c0a98490 100644 --- a/src/test/run-pass/issues/issue-16643.rs +++ b/src/test/run-pass/issues/issue-16643.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-16643.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_16643 as i; diff --git a/src/test/run-pass/issues/issue-16671.rs b/src/test/run-pass/issues/issue-16671.rs index 81a6b669b70ef..e5572609ff8eb 100644 --- a/src/test/run-pass/issues/issue-16671.rs +++ b/src/test/run-pass/issues/issue-16671.rs @@ -1,5 +1,5 @@ // run-pass -//compile-flags: -Z borrowck=compare +// compile-flags: -Z borrowck=compare #![deny(warnings)] diff --git a/src/test/run-pass/issues/issue-16783.rs b/src/test/run-pass/issues/issue-16783.rs index 4af4031d278b8..5b100812e6345 100644 --- a/src/test/run-pass/issues/issue-16783.rs +++ b/src/test/run-pass/issues/issue-16783.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x = [1, 2, 3]; diff --git a/src/test/run-pass/issues/issue-16922.rs b/src/test/run-pass/issues/issue-16922.rs index 82a3943e9efa5..f8b07f1269110 100644 --- a/src/test/run-pass/issues/issue-16922.rs +++ b/src/test/run-pass/issues/issue-16922.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::any::Any; diff --git a/src/test/run-pass/issues/issue-17322.rs b/src/test/run-pass/issues/issue-17322.rs index 79b6a5ae5337c..b933d01d59563 100644 --- a/src/test/run-pass/issues/issue-17322.rs +++ b/src/test/run-pass/issues/issue-17322.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-17351.rs b/src/test/run-pass/issues/issue-17351.rs index f51f0b3ca0171..e478a79244a39 100644 --- a/src/test/run-pass/issues/issue-17351.rs +++ b/src/test/run-pass/issues/issue-17351.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Str { fn foo(&self) {} } impl Str for str {} diff --git a/src/test/run-pass/issues/issue-17361.rs b/src/test/run-pass/issues/issue-17361.rs index e97fc3afd1ccc..2258ee6895696 100644 --- a/src/test/run-pass/issues/issue-17361.rs +++ b/src/test/run-pass/issues/issue-17361.rs @@ -1,7 +1,7 @@ // run-pass // Test that astconv doesn't forget about mutability of &mut str -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { fn foo(_: &mut T) {} diff --git a/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs b/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs index 65a8713ba056e..f30932615da1b 100644 --- a/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs +++ b/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker; use std::cell::UnsafeCell; diff --git a/src/test/run-pass/issues/issue-17771.rs b/src/test/run-pass/issues/issue-17771.rs index 7eea5ce6589b5..f2225f66e7886 100644 --- a/src/test/run-pass/issues/issue-17771.rs +++ b/src/test/run-pass/issues/issue-17771.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Aaa { fn dummy(&self) { } } diff --git a/src/test/run-pass/issues/issue-18110.rs b/src/test/run-pass/issues/issue-18110.rs index 41c29e77da5c5..2869225709229 100644 --- a/src/test/run-pass/issues/issue-18110.rs +++ b/src/test/run-pass/issues/issue-18110.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unreachable_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { ({return},); diff --git a/src/test/run-pass/issues/issue-18232.rs b/src/test/run-pass/issues/issue-18232.rs index 7e6f6ef0f3904..027df96974381 100644 --- a/src/test/run-pass/issues/issue-18232.rs +++ b/src/test/run-pass/issues/issue-18232.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Cursor<'a>(::std::marker::PhantomData<&'a ()>); diff --git a/src/test/run-pass/issues/issue-18353.rs b/src/test/run-pass/issues/issue-18353.rs index aaa896b66c5d4..c306cd05ceda1 100644 --- a/src/test/run-pass/issues/issue-18353.rs +++ b/src/test/run-pass/issues/issue-18353.rs @@ -3,7 +3,7 @@ // Test that wrapping an unsized struct in an enum which gets optimised does // not ICE. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Str { f: [u8] diff --git a/src/test/run-pass/issues/issue-18425.rs b/src/test/run-pass/issues/issue-18425.rs index 354c14a756aaf..2f3b0fbe7f970 100644 --- a/src/test/run-pass/issues/issue-18425.rs +++ b/src/test/run-pass/issues/issue-18425.rs @@ -2,7 +2,7 @@ // Check that codegen doesn't ICE when codegenning an array repeat // expression with a count of 1 and a non-Copy element type. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let _ = [Box::new(1_usize); 1]; diff --git a/src/test/run-pass/issues/issue-18501.rs b/src/test/run-pass/issues/issue-18501.rs index 0ca23074c5520..562ac5c266397 100644 --- a/src/test/run-pass/issues/issue-18501.rs +++ b/src/test/run-pass/issues/issue-18501.rs @@ -1,10 +1,10 @@ // run-pass // Test that we don't ICE when inlining a function from another // crate that uses a trait method as a value due to incorrectly -// translating the def ID of the trait during AST decoding. +// translating the `DefId` of the trait during AST decoding. // aux-build:issue-18501.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_18501 as issue; diff --git a/src/test/run-pass/issues/issue-18539.rs b/src/test/run-pass/issues/issue-18539.rs index 745df26e3209c..8f71de55e2604 100644 --- a/src/test/run-pass/issues/issue-18539.rs +++ b/src/test/run-pass/issues/issue-18539.rs @@ -2,7 +2,7 @@ // Test that coercing bare fn's that return a zero sized type to // a closure doesn't cause an LLVM ERROR -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo; diff --git a/src/test/run-pass/issues/issue-18652.rs b/src/test/run-pass/issues/issue-18652.rs index 59aa01568429a..31798a6aadd86 100644 --- a/src/test/run-pass/issues/issue-18652.rs +++ b/src/test/run-pass/issues/issue-18652.rs @@ -1,6 +1,6 @@ // run-pass // Tests multiple free variables being passed by value into an unboxed -// once closure as an optimization by codegen. This used to hit an +// once closure as an optimization by codegen. This used to hit an // incorrect assert. fn main() { diff --git a/src/test/run-pass/issues/issue-18661.rs b/src/test/run-pass/issues/issue-18661.rs index e242724323505..d73d48a40bc1a 100644 --- a/src/test/run-pass/issues/issue-18661.rs +++ b/src/test/run-pass/issues/issue-18661.rs @@ -2,7 +2,7 @@ // Test that param substitutions from the correct environment are // used when codegenning unboxed closure calls. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn inside(c: F) { c(); diff --git a/src/test/run-pass/issues/issue-18685.rs b/src/test/run-pass/issues/issue-18685.rs index bfe24b663f60f..dd25bbd86cadc 100644 --- a/src/test/run-pass/issues/issue-18685.rs +++ b/src/test/run-pass/issues/issue-18685.rs @@ -2,7 +2,7 @@ // Test that the self param space is not used in a conflicting // manner by unboxed closures within a default method on a trait -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Tr { fn foo(&self); diff --git a/src/test/run-pass/issues/issue-18711.rs b/src/test/run-pass/issues/issue-18711.rs index 4358418775250..a90021d4dcaea 100644 --- a/src/test/run-pass/issues/issue-18711.rs +++ b/src/test/run-pass/issues/issue-18711.rs @@ -2,7 +2,7 @@ // Test that we don't panic on a RefCell borrow conflict in certain // code paths involving unboxed closures. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // aux-build:issue-18711.rs extern crate issue_18711 as issue; diff --git a/src/test/run-pass/issues/issue-19127.rs b/src/test/run-pass/issues/issue-19127.rs index c847ac9e43597..9576c5e4f7c41 100644 --- a/src/test/run-pass/issues/issue-19127.rs +++ b/src/test/run-pass/issues/issue-19127.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo T>(f: F) {} fn id<'a>(input: &'a u8) -> &'a u8 { input } diff --git a/src/test/run-pass/issues/issue-19293.rs b/src/test/run-pass/issues/issue-19293.rs index 90f96566f382b..43177d07078c3 100644 --- a/src/test/run-pass/issues/issue-19293.rs +++ b/src/test/run-pass/issues/issue-19293.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:issue_19293.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_19293; use issue_19293::{Foo, MyEnum}; diff --git a/src/test/run-pass/issues/issue-19340-1.rs b/src/test/run-pass/issues/issue-19340-1.rs index e3cc2daae9b9e..951d5b1a38641 100644 --- a/src/test/run-pass/issues/issue-19340-1.rs +++ b/src/test/run-pass/issues/issue-19340-1.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // aux-build:issue-19340-1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_19340_1 as lib; diff --git a/src/test/run-pass/issues/issue-19340-2.rs b/src/test/run-pass/issues/issue-19340-2.rs index a222e9e462104..020d96f2e17d8 100644 --- a/src/test/run-pass/issues/issue-19340-2.rs +++ b/src/test/run-pass/issues/issue-19340-2.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Homura { Madoka { diff --git a/src/test/run-pass/issues/issue-19499.rs b/src/test/run-pass/issues/issue-19499.rs index d09056ce3de4f..3b945c232be9b 100644 --- a/src/test/run-pass/issues/issue-19499.rs +++ b/src/test/run-pass/issues/issue-19499.rs @@ -7,7 +7,7 @@ // reasonable examples) let to ambiguity errors about not being able // to infer sufficient type information. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let n = 0; diff --git a/src/test/run-pass/issues/issue-1974.rs b/src/test/run-pass/issues/issue-1974.rs index 74a54a6029e1c..9091cb97ebd8c 100644 --- a/src/test/run-pass/issues/issue-1974.rs +++ b/src/test/run-pass/issues/issue-1974.rs @@ -1,7 +1,7 @@ // run-pass -// Issue 1974 +// Issue #1974 // Don't double free the condition allocation -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let s = "hej".to_string(); diff --git a/src/test/run-pass/issues/issue-20313.rs b/src/test/run-pass/issues/issue-20313.rs index 09352044b0161..f1e641c4a8da8 100644 --- a/src/test/run-pass/issues/issue-20313.rs +++ b/src/test/run-pass/issues/issue-20313.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(link_llvm_intrinsics)] diff --git a/src/test/run-pass/issues/issue-20343.rs b/src/test/run-pass/issues/issue-20343.rs index 000b6398442a3..ad538786d3833 100644 --- a/src/test/run-pass/issues/issue-20343.rs +++ b/src/test/run-pass/issues/issue-20343.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // Regression test for Issue #20343. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![deny(dead_code)] diff --git a/src/test/run-pass/issues/issue-20389.rs b/src/test/run-pass/issues/issue-20389.rs index 9c5a1844e293b..a1733e651c300 100644 --- a/src/test/run-pass/issues/issue-20389.rs +++ b/src/test/run-pass/issues/issue-20389.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // aux-build:issue_20389.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_20389; diff --git a/src/test/run-pass/issues/issue-20575.rs b/src/test/run-pass/issues/issue-20575.rs index 95273edcf7e82..8c85f27a64e65 100644 --- a/src/test/run-pass/issues/issue-20575.rs +++ b/src/test/run-pass/issues/issue-20575.rs @@ -1,7 +1,7 @@ // run-pass // Test that overloaded calls work with zero arity closures -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; diff --git a/src/test/run-pass/issues/issue-2063.rs b/src/test/run-pass/issues/issue-2063.rs index 9dbac6ccee1d1..96278997cc07e 100644 --- a/src/test/run-pass/issues/issue-2063.rs +++ b/src/test/run-pass/issues/issue-2063.rs @@ -1,6 +1,6 @@ // run-pass // test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances +// cause compiler to loop. Note that no instances // of such a type could ever be constructed. struct T(Box); diff --git a/src/test/run-pass/issues/issue-2074.rs b/src/test/run-pass/issues/issue-2074.rs index bd5f015cca0dc..2f6cc1b7ad27b 100644 --- a/src/test/run-pass/issues/issue-2074.rs +++ b/src/test/run-pass/issues/issue-2074.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] diff --git a/src/test/run-pass/issues/issue-21033.rs b/src/test/run-pass/issues/issue-21033.rs index 86cc7707e50f9..a2ccdf0ba9954 100644 --- a/src/test/run-pass/issues/issue-21033.rs +++ b/src/test/run-pass/issues/issue-21033.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-21400.rs b/src/test/run-pass/issues/issue-21400.rs index 0f297e9b8f290..6bb647cb13b27 100644 --- a/src/test/run-pass/issues/issue-21400.rs +++ b/src/test/run-pass/issues/issue-21400.rs @@ -1,6 +1,7 @@ // run-pass + // Regression test for #21400 which itself was extracted from -// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580 +// . fn main() { let mut t = Test; diff --git a/src/test/run-pass/issues/issue-21475.rs b/src/test/run-pass/issues/issue-21475.rs index 16d003aba7cab..ca42c0611c4a6 100644 --- a/src/test/run-pass/issues/issue-21475.rs +++ b/src/test/run-pass/issues/issue-21475.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use m::{START, END}; diff --git a/src/test/run-pass/issues/issue-2190-1.rs b/src/test/run-pass/issues/issue-2190-1.rs index 34a80ab00516b..4b5ae007bffd6 100644 --- a/src/test/run-pass/issues/issue-2190-1.rs +++ b/src/test/run-pass/issues/issue-2190-1.rs @@ -2,7 +2,7 @@ #![allow(unused_must_use)] #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads use std::thread::Builder; diff --git a/src/test/run-pass/issues/issue-21909.rs b/src/test/run-pass/issues/issue-21909.rs index 7cb558d9a4fa6..9df767bcc31bc 100644 --- a/src/test/run-pass/issues/issue-21909.rs +++ b/src/test/run-pass/issues/issue-21909.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn dummy(&self, arg: X); diff --git a/src/test/run-pass/issues/issue-22346.rs b/src/test/run-pass/issues/issue-22346.rs index b728911e54170..f6f62259d5437 100644 --- a/src/test/run-pass/issues/issue-22346.rs +++ b/src/test/run-pass/issues/issue-22346.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // This used to cause an ICE because the retslot for the "return" had the wrong type fn testcase<'a>() -> Box + 'a> { diff --git a/src/test/run-pass/issues/issue-22426.rs b/src/test/run-pass/issues/issue-22426.rs index adf060a8292be..6d56125304dca 100644 --- a/src/test/run-pass/issues/issue-22426.rs +++ b/src/test/run-pass/issues/issue-22426.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { match 42 { diff --git a/src/test/run-pass/issues/issue-22577.rs b/src/test/run-pass/issues/issue-22577.rs index 24f4f60aa2f4e..89398f94f1c2c 100644 --- a/src/test/run-pass/issues/issue-22577.rs +++ b/src/test/run-pass/issues/issue-22577.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no std::fs use std::{fs, net}; diff --git a/src/test/run-pass/issues/issue-22629.rs b/src/test/run-pass/issues/issue-22629.rs index 7beeb126ee45c..ffbec83afa004 100644 --- a/src/test/run-pass/issues/issue-22629.rs +++ b/src/test/run-pass/issues/issue-22629.rs @@ -3,7 +3,7 @@ // Test transitive analysis for associated types. Collected types // should be normalized and new obligations generated. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::borrow::{ToOwned, Cow}; diff --git a/src/test/run-pass/issues/issue-22828.rs b/src/test/run-pass/issues/issue-22828.rs index adf4dd6ce75a0..cdb8d0abce75a 100644 --- a/src/test/run-pass/issues/issue-22828.rs +++ b/src/test/run-pass/issues/issue-22828.rs @@ -3,7 +3,7 @@ // Test transitive analysis for associated types. Collected types // should be normalized and new obligations generated. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { type A; diff --git a/src/test/run-pass/issues/issue-2284.rs b/src/test/run-pass/issues/issue-2284.rs index 6f2c958341b5e..839bdaf4647d0 100644 --- a/src/test/run-pass/issues/issue-2284.rs +++ b/src/test/run-pass/issues/issue-2284.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Send { fn f(&self); diff --git a/src/test/run-pass/issues/issue-2316-c.rs b/src/test/run-pass/issues/issue-2316-c.rs index 6783f3fcfc691..4b312cde3c886 100644 --- a/src/test/run-pass/issues/issue-2316-c.rs +++ b/src/test/run-pass/issues/issue-2316-c.rs @@ -2,7 +2,7 @@ // aux-build:issue_2316_a.rs // aux-build:issue_2316_b.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_2316_b; use issue_2316_b::cloth; diff --git a/src/test/run-pass/issues/issue-23485.rs b/src/test/run-pass/issues/issue-23485.rs index a55846f40dfbd..26544bfc5b9af 100644 --- a/src/test/run-pass/issues/issue-23485.rs +++ b/src/test/run-pass/issues/issue-23485.rs @@ -45,6 +45,6 @@ impl Iterator for Counter { } fn main() { - let mut x: Box> = Box::new(Counter { value: 22 }); + let mut x: Box> = Box::new(Counter { value: 22 }); assert_eq!(x.next().unwrap().value, 22); } diff --git a/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs b/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs index 6ef7fd42ec6d0..bc8d8b50744f4 100644 --- a/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs +++ b/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_upper_case_globals)] -// Issue 23611: this test is ensuring that, for an instance `X` of the +// Issue #23611: this test is ensuring that, for an instance `X` of the // enum `E`, if you swap in a different variant during the execution // of the `::drop`, then the appropriate substructure will // be torn down after the `::drop` method returns. diff --git a/src/test/run-pass/issues/issue-2380-b.rs b/src/test/run-pass/issues/issue-2380-b.rs index d708c7b4213b2..04ecb12826b54 100644 --- a/src/test/run-pass/issues/issue-2380-b.rs +++ b/src/test/run-pass/issues/issue-2380-b.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-2380.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate a; diff --git a/src/test/run-pass/issues/issue-2383.rs b/src/test/run-pass/issues/issue-2383.rs index 06e61ce680b38..e23b381142b4a 100644 --- a/src/test/run-pass/issues/issue-2383.rs +++ b/src/test/run-pass/issues/issue-2383.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::collections::VecDeque; diff --git a/src/test/run-pass/issues/issue-2414-c.rs b/src/test/run-pass/issues/issue-2414-c.rs index f6fe9798067a8..fccc4a43db2c5 100644 --- a/src/test/run-pass/issues/issue-2414-c.rs +++ b/src/test/run-pass/issues/issue-2414-c.rs @@ -2,7 +2,7 @@ // aux-build:issue-2414-a.rs // aux-build:issue-2414-b.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate b; diff --git a/src/test/run-pass/issues/issue-2445-b.rs b/src/test/run-pass/issues/issue-2445-b.rs index f369eae3af348..7f0bce1b0b317 100644 --- a/src/test/run-pass/issues/issue-2445-b.rs +++ b/src/test/run-pass/issues/issue-2445-b.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct c1 { x: T, diff --git a/src/test/run-pass/issues/issue-2445.rs b/src/test/run-pass/issues/issue-2445.rs index 5730ce165748e..6be49558521b7 100644 --- a/src/test/run-pass/issues/issue-2445.rs +++ b/src/test/run-pass/issues/issue-2445.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct c1 { x: T, diff --git a/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs b/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs index 68f7dfd38f4f4..4e242c59e089c 100644 --- a/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs +++ b/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs @@ -38,7 +38,7 @@ fn rfcs_issue_1006_1() { fn rfcs_issue_1006_2() { #[inline(always)] - fn check<'a, I: Iterator>(mut i: I) -> bool { + fn check<'a, I: Iterator>(mut i: I) -> bool { i.any(|&x| x == 2) } diff --git a/src/test/run-pass/issues/issue-2463.rs b/src/test/run-pass/issues/issue-2463.rs index d24a47c53d9ee..36bc0a146db10 100644 --- a/src/test/run-pass/issues/issue-2463.rs +++ b/src/test/run-pass/issues/issue-2463.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Pair { f: isize, g: isize } diff --git a/src/test/run-pass/issues/issue-2472.rs b/src/test/run-pass/issues/issue-2472.rs index cadd0151b4e81..67b510d012282 100644 --- a/src/test/run-pass/issues/issue-2472.rs +++ b/src/test/run-pass/issues/issue-2472.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue_2472_b.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_2472_b; diff --git a/src/test/run-pass/issues/issue-24805-dropck-itemless.rs b/src/test/run-pass/issues/issue-24805-dropck-itemless.rs index db427ed3d3194..77e2bd2d61748 100644 --- a/src/test/run-pass/issues/issue-24805-dropck-itemless.rs +++ b/src/test/run-pass/issues/issue-24805-dropck-itemless.rs @@ -55,7 +55,7 @@ fn f_send() { body!(D_Send) } fn f_sized() { body!(D_Sized) } fn f_sync() { body!(D_Sync) } -// Issue 24895: Copy: Clone implies `impl Drop for ...` can +// Issue #24895: Copy: Clone implies `impl Drop for ...` can // access a user-defined clone() method, which causes this test case // to fail. // diff --git a/src/test/run-pass/issues/issue-2526-a.rs b/src/test/run-pass/issues/issue-2526-a.rs index f3fdc0bd377f3..652d781f977a3 100644 --- a/src/test/run-pass/issues/issue-2526-a.rs +++ b/src/test/run-pass/issues/issue-2526-a.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-2526.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_imports)] diff --git a/src/test/run-pass/issues/issue-25339.rs b/src/test/run-pass/issues/issue-25339.rs index 602f458e4cf54..3deaa19bb3282 100644 --- a/src/test/run-pass/issues/issue-25339.rs +++ b/src/test/run-pass/issues/issue-25339.rs @@ -22,7 +22,7 @@ pub struct Mount> { } impl> Mount { - pub fn create>(mount: &str, input: T) { + pub fn create>(mount: &str, input: T) { input.to_routing(); } } diff --git a/src/test/run-pass/issues/issue-25343.rs b/src/test/run-pass/issues/issue-25343.rs index 95a0bd9155d96..0addc81e5db53 100644 --- a/src/test/run-pass/issues/issue-25343.rs +++ b/src/test/run-pass/issues/issue-25343.rs @@ -6,7 +6,7 @@ fn main() { } }; - // More cases added from issue 31754 + // More cases added from issue #31754 'label2: loop { break; diff --git a/src/test/run-pass/issues/issue-2550.rs b/src/test/run-pass/issues/issue-2550.rs index 04ec66b80d7bb..c466f09486a76 100644 --- a/src/test/run-pass/issues/issue-2550.rs +++ b/src/test/run-pass/issues/issue-2550.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_snake_case)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct C { x: usize, diff --git a/src/test/run-pass/issues/issue-25700-1.rs b/src/test/run-pass/issues/issue-25700-1.rs index 7bc9673a5be36..e6fbeb4c87d35 100644 --- a/src/test/run-pass/issues/issue-25700-1.rs +++ b/src/test/run-pass/issues/issue-25700-1.rs @@ -4,8 +4,8 @@ struct S(Option<&'static T>); trait Tr { type Out; } impl Tr for T { type Out = T; } -impl Copy for S where S: Tr {} -impl Clone for S where S: Tr { +impl Copy for S where S: Tr {} +impl Clone for S where S: Tr { fn clone(&self) -> Self { *self } } fn main() { diff --git a/src/test/run-pass/issues/issue-2633-2.rs b/src/test/run-pass/issues/issue-2633-2.rs index 02c1a166301eb..d683d6524d397 100644 --- a/src/test/run-pass/issues/issue-2633-2.rs +++ b/src/test/run-pass/issues/issue-2633-2.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-2642.rs b/src/test/run-pass/issues/issue-2642.rs index 95c5632258eaa..fba226a00c45e 100644 --- a/src/test/run-pass/issues/issue-2642.rs +++ b/src/test/run-pass/issues/issue-2642.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f() { let _x: usize = loop { loop { break; } }; diff --git a/src/test/run-pass/issues/issue-26905.rs b/src/test/run-pass/issues/issue-26905.rs index 309e2f7e5719b..7c01302db73c6 100644 --- a/src/test/run-pass/issues/issue-26905.rs +++ b/src/test/run-pass/issues/issue-26905.rs @@ -17,6 +17,6 @@ fn main() { let data = [1, 2, 3]; let iter = data.iter(); let x = MyRc { _ptr: &iter, _boo: PhantomData }; - let _y: MyRc> = x; + let _y: MyRc> = x; } diff --git a/src/test/run-pass/issues/issue-26996.rs b/src/test/run-pass/issues/issue-26996.rs index 8c5d2441780a1..d31cf23af1d81 100644 --- a/src/test/run-pass/issues/issue-26996.rs +++ b/src/test/run-pass/issues/issue-26996.rs @@ -1,7 +1,7 @@ // run-pass // This test is bogus (i.e., should be compile-fail) during the period -// where #54986 is implemented and #54987 is *not* implemented. For +// where #54986 is implemented and #54987 is **not** implemented. For // now: just ignore it under nll // // ignore-compare-mode-nll diff --git a/src/test/run-pass/issues/issue-27021.rs b/src/test/run-pass/issues/issue-27021.rs index ecb065b196400..cef7cd42f4e13 100644 --- a/src/test/run-pass/issues/issue-27021.rs +++ b/src/test/run-pass/issues/issue-27021.rs @@ -1,7 +1,7 @@ // run-pass // This test is bogus (i.e., should be compile-fail) during the period -// where #54986 is implemented and #54987 is *not* implemented. For +// where #54986 is implemented and #54987 is **not** implemented. For // now: just ignore it under nll // // ignore-compare-mode-nll diff --git a/src/test/run-pass/issues/issue-2708.rs b/src/test/run-pass/issues/issue-2708.rs index abd5e9507f8ee..a105b6963d817 100644 --- a/src/test/run-pass/issues/issue-2708.rs +++ b/src/test/run-pass/issues/issue-2708.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_snake_case)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-2734.rs b/src/test/run-pass/issues/issue-2734.rs index fcb224e2d043d..c148a18a98205 100644 --- a/src/test/run-pass/issues/issue-2734.rs +++ b/src/test/run-pass/issues/issue-2734.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-2735.rs b/src/test/run-pass/issues/issue-2735.rs index c48bedf14f7b7..3eda2b3179018 100644 --- a/src/test/run-pass/issues/issue-2735.rs +++ b/src/test/run-pass/issues/issue-2735.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-27859.rs b/src/test/run-pass/issues/issue-27859.rs index 259d706fa2a17..c310bc000815f 100644 --- a/src/test/run-pass/issues/issue-27859.rs +++ b/src/test/run-pass/issues/issue-27859.rs @@ -1,6 +1,6 @@ // run-pass // ignore-cloudabi no std::env -// ignore-wasm32 issue 42629 +// ignore-wasm32 issue #42629 #[inline(never)] fn foo(a: f32, b: f32) -> f32 { diff --git a/src/test/run-pass/issues/issue-28950.rs b/src/test/run-pass/issues/issue-28950.rs index 8b55f42f3f41b..a21c813e06ed8 100644 --- a/src/test/run-pass/issues/issue-28950.rs +++ b/src/test/run-pass/issues/issue-28950.rs @@ -5,8 +5,8 @@ // Tests that the `vec!` macro does not overflow the stack when it is // given data larger than the stack. -// FIXME(eddyb) Improve unoptimized codegen to avoid the temporary, -// and thus run successfully even when compiled at -C opt-level=0. +// FIXME(eddyb): improve unoptimized codegen to avoid the temporary, +// and thus run successfully even when compiled at `-C opt-level=0`. const LEN: usize = 1 << 15; @@ -14,8 +14,8 @@ use std::thread::Builder; fn main() { assert!(Builder::new().stack_size(LEN / 2).spawn(|| { - // FIXME(eddyb) this can be vec![[0: LEN]] pending - // https://llvm.org/bugs/show_bug.cgi?id=28987 + // FIXME(eddyb): this can be `vec![[0: LEN]]` pending + // . let vec = vec![unsafe { std::mem::zeroed::<[u8; LEN]>() }]; assert_eq!(vec.len(), 1); }).unwrap().join().is_ok()); diff --git a/src/test/run-pass/issues/issue-2935.rs b/src/test/run-pass/issues/issue-2935.rs index 58ade32b2502c..c76875791cd08 100644 --- a/src/test/run-pass/issues/issue-2935.rs +++ b/src/test/run-pass/issues/issue-2935.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] #![feature(box_syntax)] -//type t = { a: isize }; +// type t = { a: isize }; // type t = { a: bool }; type t = bool; diff --git a/src/test/run-pass/issues/issue-3012-2.rs b/src/test/run-pass/issues/issue-3012-2.rs index 7d32c51f5699c..a193d84e09e07 100644 --- a/src/test/run-pass/issues/issue-3012-2.rs +++ b/src/test/run-pass/issues/issue-3012-2.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-3012-1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate socketlib; diff --git a/src/test/run-pass/issues/issue-3026.rs b/src/test/run-pass/issues/issue-3026.rs index 1dea8134fba2f..55cc2171c3977 100644 --- a/src/test/run-pass/issues/issue-3026.rs +++ b/src/test/run-pass/issues/issue-3026.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-3037.rs b/src/test/run-pass/issues/issue-3037.rs index ff4d32c284073..2a7cb7f94f18d 100644 --- a/src/test/run-pass/issues/issue-3037.rs +++ b/src/test/run-pass/issues/issue-3037.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] enum what { } diff --git a/src/test/run-pass/issues/issue-3052.rs b/src/test/run-pass/issues/issue-3052.rs index 927102981e7f9..2f633e36ee19c 100644 --- a/src/test/run-pass/issues/issue-3052.rs +++ b/src/test/run-pass/issues/issue-3052.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) type Connection = Box) + 'static>; diff --git a/src/test/run-pass/issues/issue-3220.rs b/src/test/run-pass/issues/issue-3220.rs index 7dc672edb54bb..f02a886992631 100644 --- a/src/test/run-pass/issues/issue-3220.rs +++ b/src/test/run-pass/issues/issue-3220.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct thing { x: isize, } diff --git a/src/test/run-pass/issues/issue-3429.rs b/src/test/run-pass/issues/issue-3429.rs index 9d94c3ff61c48..e3d0407e05a1b 100644 --- a/src/test/run-pass/issues/issue-3429.rs +++ b/src/test/run-pass/issues/issue-3429.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x = 1_usize; diff --git a/src/test/run-pass/issues/issue-34569.rs b/src/test/run-pass/issues/issue-34569.rs index 1f68560509e8c..73876ce935706 100644 --- a/src/test/run-pass/issues/issue-34569.rs +++ b/src/test/run-pass/issues/issue-34569.rs @@ -5,8 +5,6 @@ // a debuginfo verification assertion during compilation. This was caused by the // closure in the guard being codegened twice due to how match expressions are // handled. -// -// See https://github.com/rust-lang/rust/issues/34569 for details. fn main() { match 0 { diff --git a/src/test/run-pass/issues/issue-3500.rs b/src/test/run-pass/issues/issue-3500.rs index 7b39cc16cab4a..b919a7afb2a4a 100644 --- a/src/test/run-pass/issues/issue-3500.rs +++ b/src/test/run-pass/issues/issue-3500.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let x = &Some(1); diff --git a/src/test/run-pass/issues/issue-3563-3.rs b/src/test/run-pass/issues/issue-3563-3.rs index bedfdab97d58b..afed22b1187ff 100644 --- a/src/test/run-pass/issues/issue-3563-3.rs +++ b/src/test/run-pass/issues/issue-3563-3.rs @@ -2,12 +2,12 @@ #![allow(unused_imports)] #![allow(non_snake_case)] -// ASCII art shape renderer. Demonstrates traits, impls, operator overloading, -// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs && +// ASCII art shape renderer. Demonstrates traits, impls, operator overloading, +// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs && // ./shapes // Rust's std library is tightly bound to the language itself so it is -// automatically linked in. However the extra library is designed to be +// automatically linked in. However the extra library is designed to be // optional (for code that must run on constrained environments like embedded // devices or special environments like kernel code) so it must be explicitly // linked in. @@ -99,7 +99,7 @@ impl fmt::Display for AsciiArt { .map(|line| line.iter().cloned().collect()) .collect::>(); - // Concatenate the lines together using a new-line. + // Concatenate the lines together using a newline. write!(f, "{}", lines.join("\n")) } } diff --git a/src/test/run-pass/issues/issue-36036-associated-type-layout.rs b/src/test/run-pass/issues/issue-36036-associated-type-layout.rs index 022f9a5d556f1..28d800590c9a9 100644 --- a/src/test/run-pass/issues/issue-36036-associated-type-layout.rs +++ b/src/test/run-pass/issues/issue-36036-associated-type-layout.rs @@ -1,5 +1,5 @@ // run-pass -// Issue 36036: computing the layout of a type composed from another +// Issue #36036: computing the layout of a type composed from another // trait's associated type caused compiler to ICE when the associated // type was allowed to be unsized, even though the known instantiated // type is itself sized. diff --git a/src/test/run-pass/issues/issue-36278-prefix-nesting.rs b/src/test/run-pass/issues/issue-36278-prefix-nesting.rs index 62d1f5f825886..7fd48bb652074 100644 --- a/src/test/run-pass/issues/issue-36278-prefix-nesting.rs +++ b/src/test/run-pass/issues/issue-36278-prefix-nesting.rs @@ -1,5 +1,5 @@ // run-pass -// Issue 36278: On an unsized struct with >1 level of nontrivial +// Issue #36278: On an unsized struct with >1 level of nontrivial // nesting, ensure we are computing dynamic size of prefix correctly. use std::mem; diff --git a/src/test/run-pass/issues/issue-36401.rs b/src/test/run-pass/issues/issue-36401.rs index f51197b01c7ed..a10a12c134b3c 100644 --- a/src/test/run-pass/issues/issue-36401.rs +++ b/src/test/run-pass/issues/issue-36401.rs @@ -1,4 +1,5 @@ // run-pass + #[derive(Debug)] pub enum Event { Key(u8), @@ -6,7 +7,7 @@ pub enum Event { Unknown(u16), } -static XTERM_SINGLE_BYTES : [(u8, Event); 1] = [(1, Event::Resize)]; +static XTERM_SINGLE_BYTES : [(u8, Event); 1] = [(1, Event::Resize)]; fn main() { match XTERM_SINGLE_BYTES[0] { diff --git a/src/test/run-pass/issues/issue-3656.rs b/src/test/run-pass/issues/issue-3656.rs index d55a22a72b6ff..40fba1a19ac5c 100644 --- a/src/test/run-pass/issues/issue-3656.rs +++ b/src/test/run-pass/issues/issue-3656.rs @@ -6,7 +6,7 @@ // Incorrect struct size computation in the FFI, because of not taking // the alignment of elements into account. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-wasm32-bare no libc to test with #![feature(rustc_private)] diff --git a/src/test/run-pass/issues/issue-3743.rs b/src/test/run-pass/issues/issue-3743.rs index 07741914f802c..5e6e63f1a01ac 100644 --- a/src/test/run-pass/issues/issue-3743.rs +++ b/src/test/run-pass/issues/issue-3743.rs @@ -26,7 +26,7 @@ trait RhsOfVec2Mul { } // Vec2's implementation of Mul "from the other side" using the above trait -impl> Mul for Vec2 { +impl> Mul for Vec2 { type Output = Res; fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) } diff --git a/src/test/run-pass/issues/issue-38033.rs b/src/test/run-pass/issues/issue-38033.rs index 16b867ec88f17..707de03100817 100644 --- a/src/test/run-pass/issues/issue-38033.rs +++ b/src/test/run-pass/issues/issue-38033.rs @@ -15,7 +15,7 @@ trait Future { } trait IntoFuture { - type Future: Future; + type Future: Future; type Item; type Error; diff --git a/src/test/run-pass/issues/issue-3878.rs b/src/test/run-pass/issues/issue-3878.rs index a121f0ba878ef..48d4e07b83923 100644 --- a/src/test/run-pass/issues/issue-3878.rs +++ b/src/test/run-pass/issues/issue-3878.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(path_statements)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-38942.rs b/src/test/run-pass/issues/issue-38942.rs index 308bdd6e28cc4..f1859efd06523 100644 --- a/src/test/run-pass/issues/issue-38942.rs +++ b/src/test/run-pass/issues/issue-38942.rs @@ -1,5 +1,4 @@ // run-pass -// See https://github.com/rust-lang/rust/issues/38942 #[repr(u64)] pub enum NSEventType { diff --git a/src/test/run-pass/issues/issue-3979-generics.rs b/src/test/run-pass/issues/issue-3979-generics.rs index 519de1cad6ef9..8be103646de96 100644 --- a/src/test/run-pass/issues/issue-3979-generics.rs +++ b/src/test/run-pass/issues/issue-3979-generics.rs @@ -9,7 +9,7 @@ trait Positioned { fn X(&self) -> S; } -trait Movable>: Positioned { +trait Movable>: Positioned { fn translate(&mut self, dx: S) { let x = self.X() + dx; self.SetX(x); diff --git a/src/test/run-pass/issues/issue-40003.rs b/src/test/run-pass/issues/issue-40003.rs index 642de6b8fe352..24cf70bbe258c 100644 --- a/src/test/run-pass/issues/issue-40003.rs +++ b/src/test/run-pass/issues/issue-40003.rs @@ -31,7 +31,7 @@ mod future { } fn flatten_stream(self) -> FlattenStream - where ::Item: stream::Stream, + where ::Item: stream::Stream, Self: Sized { panic!() @@ -39,7 +39,7 @@ mod future { } pub trait IntoFuture { - type Future: Future; + type Future: Future; type Item; type Error; fn into_future(self) -> Self::Future; @@ -83,7 +83,7 @@ mod future { impl Stream for FlattenStream where F: Future, - ::Item: Stream, + ::Item: Stream, { type Item = ::Item; type Error = ::Error; @@ -125,13 +125,13 @@ mod stream { } pub fn iter(_: J) -> IterStream - where J: IntoIterator>, + where J: IntoIterator>, { panic!() } impl Stream for IterStream - where I: Iterator>, + where I: Iterator>, { type Item = T; type Error = E; diff --git a/src/test/run-pass/issues/issue-41677.rs b/src/test/run-pass/issues/issue-41677.rs index afddbc799b773..5d4e979bc83da 100644 --- a/src/test/run-pass/issues/issue-41677.rs +++ b/src/test/run-pass/issues/issue-41677.rs @@ -17,7 +17,7 @@ impl Handle for ResizingHandle { type Inner = H; } -struct Receiver>(PhantomData); +struct Receiver>(PhantomData); fn channel(size: usize) -> Receiver> { let rx = Receiver(PhantomData); diff --git a/src/test/run-pass/issues/issue-4208.rs b/src/test/run-pass/issues/issue-4208.rs index 3b01811a9e80e..3bb41ff0d6554 100644 --- a/src/test/run-pass/issues/issue-4208.rs +++ b/src/test/run-pass/issues/issue-4208.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // aux-build:issue-4208-cc.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate numeric; use numeric::{sin, Angle}; diff --git a/src/test/run-pass/issues/issue-4228.rs b/src/test/run-pass/issues/issue-4228.rs index 491000b6510a8..1db7113d05b4a 100644 --- a/src/test/run-pass/issues/issue-4228.rs +++ b/src/test/run-pass/issues/issue-4228.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo; diff --git a/src/test/run-pass/issues/issue-4333.rs b/src/test/run-pass/issues/issue-4333.rs index ae9f4c8bdb523..c2d6a73528c0c 100644 --- a/src/test/run-pass/issues/issue-4333.rs +++ b/src/test/run-pass/issues/issue-4333.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_must_use)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::io; diff --git a/src/test/run-pass/issues/issue-4387.rs b/src/test/run-pass/issues/issue-4387.rs index 84592f16a4ca9..2d76f7a5aa946 100644 --- a/src/test/run-pass/issues/issue-4387.rs +++ b/src/test/run-pass/issues/issue-4387.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let _foo = [0; 2*4]; diff --git a/src/test/run-pass/issues/issue-4542.rs b/src/test/run-pass/issues/issue-4542.rs index 24752114e9f5c..d354d34105d53 100644 --- a/src/test/run-pass/issues/issue-4542.rs +++ b/src/test/run-pass/issues/issue-4542.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no std::env use std::env; diff --git a/src/test/run-pass/issues/issue-4545.rs b/src/test/run-pass/issues/issue-4545.rs index 86fcf9af21fc5..dc11784a0a312 100644 --- a/src/test/run-pass/issues/issue-4545.rs +++ b/src/test/run-pass/issues/issue-4545.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-4545.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_4545 as somelib; pub fn main() { somelib::mk::(); } diff --git a/src/test/run-pass/issues/issue-46095.rs b/src/test/run-pass/issues/issue-46095.rs index 59ddb60c9f239..b246192bb7ba1 100644 --- a/src/test/run-pass/issues/issue-46095.rs +++ b/src/test/run-pass/issues/issue-46095.rs @@ -9,7 +9,7 @@ fn identity(t: T) -> T { t } -// Issue 46095 +// Issue #46095 // Built-in indexing should be used even when the index is not // trivially an integer // Overloaded indexing would cause wrapped to be borrowed mutably diff --git a/src/test/run-pass/issues/issue-4735.rs b/src/test/run-pass/issues/issue-4735.rs index 3ea4b01cd2bbe..e03c4156e51f9 100644 --- a/src/test/run-pass/issues/issue-4735.rs +++ b/src/test/run-pass/issues/issue-4735.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::mem::transmute; diff --git a/src/test/run-pass/issues/issue-4759.rs b/src/test/run-pass/issues/issue-4759.rs index 53785af09626a..b12f5747c6a47 100644 --- a/src/test/run-pass/issues/issue-4759.rs +++ b/src/test/run-pass/issues/issue-4759.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_shorthand_field_patterns)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-4875.rs b/src/test/run-pass/issues/issue-4875.rs index 8d361314f73a0..aaa26c0e44bd2 100644 --- a/src/test/run-pass/issues/issue-4875.rs +++ b/src/test/run-pass/issues/issue-4875.rs @@ -1,8 +1,8 @@ // run-pass #![allow(dead_code)] -// regression test for issue 4875 +// regression test for issue #4875 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Foo { data: T, diff --git a/src/test/run-pass/issues/issue-49298.rs b/src/test/run-pass/issues/issue-49298.rs index 56443f410205e..dfb3312636476 100644 --- a/src/test/run-pass/issues/issue-49298.rs +++ b/src/test/run-pass/issues/issue-49298.rs @@ -3,7 +3,7 @@ #![allow(unused_mut)] // under NLL we get warning about `x` below: rust-lang/rust#54499 // This test is bogus (i.e., should be compile-fail) during the period -// where #54986 is implemented and #54987 is *not* implemented. For +// where #54986 is implemented and #54987 is **not** implemented. For // now: just ignore it under nll // // ignore-compare-mode-nll diff --git a/src/test/run-pass/issues/issue-5192.rs b/src/test/run-pass/issues/issue-5192.rs index 74d8d861a7d05..25be89bbe7aff 100644 --- a/src/test/run-pass/issues/issue-5192.rs +++ b/src/test/run-pass/issues/issue-5192.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-5243.rs b/src/test/run-pass/issues/issue-5243.rs index c511d45f02de4..83729233fa0e8 100644 --- a/src/test/run-pass/issues/issue-5243.rs +++ b/src/test/run-pass/issues/issue-5243.rs @@ -4,7 +4,7 @@ // enough for codegen to consider this as non-monomorphic, // which led to various assertions and failures in turn. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S<'a> { v: &'a isize diff --git a/src/test/run-pass/issues/issue-5315.rs b/src/test/run-pass/issues/issue-5315.rs index 38c98254b9350..759549cc3e54f 100644 --- a/src/test/run-pass/issues/issue-5315.rs +++ b/src/test/run-pass/issues/issue-5315.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct A(bool); diff --git a/src/test/run-pass/issues/issue-5518.rs b/src/test/run-pass/issues/issue-5518.rs index 97ed9ef309d5a..5130eacaee41e 100644 --- a/src/test/run-pass/issues/issue-5518.rs +++ b/src/test/run-pass/issues/issue-5518.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-5518.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_5518 as other; diff --git a/src/test/run-pass/issues/issue-5550.rs b/src/test/run-pass/issues/issue-5550.rs index 6ea24747b3965..b574d483b2613 100644 --- a/src/test/run-pass/issues/issue-5550.rs +++ b/src/test/run-pass/issues/issue-5550.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_assignments)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let s: String = "foobar".to_string(); diff --git a/src/test/run-pass/issues/issue-5554.rs b/src/test/run-pass/issues/issue-5554.rs index 7737536f43dfe..7ca226c421439 100644 --- a/src/test/run-pass/issues/issue-5554.rs +++ b/src/test/run-pass/issues/issue-5554.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::default::Default; diff --git a/src/test/run-pass/issues/issue-5688.rs b/src/test/run-pass/issues/issue-5688.rs index b6e364c2f4095..eb0d12f849f4d 100644 --- a/src/test/run-pass/issues/issue-5688.rs +++ b/src/test/run-pass/issues/issue-5688.rs @@ -1,12 +1,11 @@ // run-pass -/* -# Corrupted initialization in the static struct -...should print &[1, 2, 3] but instead prints something like -&[4492532864, 24]. It is pretty evident that the compiler messed up -with the representation of [isize; n] and [isize] somehow, or at least -failed to typecheck correctly. -*/ +// Corrupted initialization in the static struct. +// +// This hould print `&[1, 2, 3]` but instead prints something like +// `&[4492532864, 24]`. It is pretty evident that the compiler messed up +// with the representation of `[isize; n]` and `[isize]` somehow, or at least +// failed to type-check correctly. #[derive(Copy, Clone)] struct X { vec: &'static [isize] } diff --git a/src/test/run-pass/issues/issue-5718.rs b/src/test/run-pass/issues/issue-5718.rs index 63efec953118a..d8787c2491188 100644 --- a/src/test/run-pass/issues/issue-5718.rs +++ b/src/test/run-pass/issues/issue-5718.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-5741.rs b/src/test/run-pass/issues/issue-5741.rs index b9eaf0be7fb3a..1da134a6e3e62 100644 --- a/src/test/run-pass/issues/issue-5741.rs +++ b/src/test/run-pass/issues/issue-5741.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(while_true)] #![allow(unreachable_code)] diff --git a/src/test/run-pass/issues/issue-5791.rs b/src/test/run-pass/issues/issue-5791.rs index 2f8bf1e936905..abf93ebaf54ff 100644 --- a/src/test/run-pass/issues/issue-5791.rs +++ b/src/test/run-pass/issues/issue-5791.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern { #[link_name = "malloc"] diff --git a/src/test/run-pass/issues/issue-5988.rs b/src/test/run-pass/issues/issue-5988.rs index db77ca4375fc3..d063cc79f9987 100644 --- a/src/test/run-pass/issues/issue-5988.rs +++ b/src/test/run-pass/issues/issue-5988.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait B { fn f(&self); diff --git a/src/test/run-pass/issues/issue-6117.rs b/src/test/run-pass/issues/issue-6117.rs index 5235d53d84a14..2b17c71538298 100644 --- a/src/test/run-pass/issues/issue-6117.rs +++ b/src/test/run-pass/issues/issue-6117.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Either { Left(T), Right(U) } diff --git a/src/test/run-pass/issues/issue-6157.rs b/src/test/run-pass/issues/issue-6157.rs index 354797cb2a784..f84d50bccc872 100644 --- a/src/test/run-pass/issues/issue-6157.rs +++ b/src/test/run-pass/issues/issue-6157.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } diff --git a/src/test/run-pass/issues/issue-6318.rs b/src/test/run-pass/issues/issue-6318.rs index d416048265fa5..6b6cbac7632dc 100644 --- a/src/test/run-pass/issues/issue-6318.rs +++ b/src/test/run-pass/issues/issue-6318.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/issues/issue-6919.rs b/src/test/run-pass/issues/issue-6919.rs index 11aed12087313..f626cc97349ab 100644 --- a/src/test/run-pass/issues/issue-6919.rs +++ b/src/test/run-pass/issues/issue-6919.rs @@ -2,7 +2,7 @@ #![allow(unused_attributes)] // aux-build:iss.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![crate_id="issue-6919"] extern crate issue6919_3; diff --git a/src/test/run-pass/issues/issue-7012.rs b/src/test/run-pass/issues/issue-7012.rs index 90eba1706956d..6bb74025f3468 100644 --- a/src/test/run-pass/issues/issue-7012.rs +++ b/src/test/run-pass/issues/issue-7012.rs @@ -12,11 +12,11 @@ would be printed, however the below prints false. struct signature<'a> { pattern : &'a [u32] } static test1: signature<'static> = signature { - pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] + pattern: &[0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0] }; pub fn main() { - let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, - 0x03707344,0xa4093822,0x299f31d0]; - println!("{}",test==test1.pattern); + let test: &[u32] = &[0x243f6a88, 0x85a308d3, 0x13198a2e, + 0x03707344, 0xa4093822, 0x299f31d0]; + println!("{}",test == test1.pattern); } diff --git a/src/test/run-pass/issues/issue-7178.rs b/src/test/run-pass/issues/issue-7178.rs index 30aa736cdc619..11d151d51adcd 100644 --- a/src/test/run-pass/issues/issue-7178.rs +++ b/src/test/run-pass/issues/issue-7178.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-7178.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_7178 as cross_crate_self; diff --git a/src/test/run-pass/issues/issue-7222.rs b/src/test/run-pass/issues/issue-7222.rs index 6490731662664..77752a037320a 100644 --- a/src/test/run-pass/issues/issue-7222.rs +++ b/src/test/run-pass/issues/issue-7222.rs @@ -1,6 +1,8 @@ // run-pass -// pretty-expanded FIXME #23616 -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 +// pretty-expanded FIXME(#23616) + +// FIXME(#41620) +#![allow(illegal_floating_point_literal_pattern)] pub fn main() { const FOO: f64 = 10.0; diff --git a/src/test/run-pass/issues/issue-7344.rs b/src/test/run-pass/issues/issue-7344.rs index f1727d0c1aef1..a76dfaa1283cf 100644 --- a/src/test/run-pass/issues/issue-7344.rs +++ b/src/test/run-pass/issues/issue-7344.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_must_use)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unreachable_code)] diff --git a/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs b/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs index 7d838cbb09b76..4ea66f397af3b 100644 --- a/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs +++ b/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* #7519 ICE pattern matching unit in function argument diff --git a/src/test/run-pass/issues/issue-7660.rs b/src/test/run-pass/issues/issue-7660.rs index ad0b8ecff39e9..0d821709931d1 100644 --- a/src/test/run-pass/issues/issue-7660.rs +++ b/src/test/run-pass/issues/issue-7660.rs @@ -1,9 +1,9 @@ // run-pass #![allow(unused_variables)] -// Regression test for issue 7660 +// Regression test for issue #7660 // rvalue lifetime too short when equivalent `match` works -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::collections::HashMap; diff --git a/src/test/run-pass/issues/issue-7784.rs b/src/test/run-pass/issues/issue-7784.rs index b75e547079ef5..7fcf31fb07efa 100644 --- a/src/test/run-pass/issues/issue-7784.rs +++ b/src/test/run-pass/issues/issue-7784.rs @@ -3,7 +3,7 @@ use std::ops::Add; -fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { +fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { (x.clone(), x.clone() + y.clone(), x + y + z) } fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { diff --git a/src/test/run-pass/issues/issue-7899.rs b/src/test/run-pass/issues/issue-7899.rs index fb631f83697ed..384ce036c16fd 100644 --- a/src/test/run-pass/issues/issue-7899.rs +++ b/src/test/run-pass/issues/issue-7899.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] // aux-build:issue-7899.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_7899 as testcrate; diff --git a/src/test/run-pass/issues/issue-8044.rs b/src/test/run-pass/issues/issue-8044.rs index 858f98b654d31..3dfddd567787a 100644 --- a/src/test/run-pass/issues/issue-8044.rs +++ b/src/test/run-pass/issues/issue-8044.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-8044.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_8044 as minimal; use minimal::{BTree, leaf}; diff --git a/src/test/run-pass/issues/issue-8248.rs b/src/test/run-pass/issues/issue-8248.rs index 239c432e457bf..3232c0a49c19a 100644 --- a/src/test/run-pass/issues/issue-8248.rs +++ b/src/test/run-pass/issues/issue-8248.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn dummy(&self) { } diff --git a/src/test/run-pass/issues/issue-8249.rs b/src/test/run-pass/issues/issue-8249.rs index db49f354a3929..c1d903df8040a 100644 --- a/src/test/run-pass/issues/issue-8249.rs +++ b/src/test/run-pass/issues/issue-8249.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn dummy(&self) { } diff --git a/src/test/run-pass/issues/issue-8259.rs b/src/test/run-pass/issues/issue-8259.rs index 2802bea7fe028..350c6f150c7e8 100644 --- a/src/test/run-pass/issues/issue-8259.rs +++ b/src/test/run-pass/issues/issue-8259.rs @@ -4,7 +4,7 @@ // aux-build:issue-8259.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_8259 as other; static a: other::Foo<'static> = other::Foo::A; diff --git a/src/test/run-pass/issues/issue-8401.rs b/src/test/run-pass/issues/issue-8401.rs index 97d66c5e40f04..8913c5c4478dd 100644 --- a/src/test/run-pass/issues/issue-8401.rs +++ b/src/test/run-pass/issues/issue-8401.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue_8401.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_8401; diff --git a/src/test/run-pass/issues/issue-8506.rs b/src/test/run-pass/issues/issue-8506.rs index cc32b89234f21..2c9051a450b45 100644 --- a/src/test/run-pass/issues/issue-8506.rs +++ b/src/test/run-pass/issues/issue-8506.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_upper_case_globals)] #![allow(dead_code)] diff --git a/src/test/run-pass/issues/issue-868.rs b/src/test/run-pass/issues/issue-868.rs index ce0a3c7ca526c..886c9d0098c87 100644 --- a/src/test/run-pass/issues/issue-868.rs +++ b/src/test/run-pass/issues/issue-868.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_parens)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(g: F) -> T where F: FnOnce() -> T { g() } diff --git a/src/test/run-pass/issues/issue-8783.rs b/src/test/run-pass/issues/issue-8783.rs index 4eb49c8216184..767caad148376 100644 --- a/src/test/run-pass/issues/issue-8783.rs +++ b/src/test/run-pass/issues/issue-8783.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::default::Default; diff --git a/src/test/run-pass/issues/issue-8851.rs b/src/test/run-pass/issues/issue-8851.rs index faacfe5f8952d..527d412d20ebf 100644 --- a/src/test/run-pass/issues/issue-8851.rs +++ b/src/test/run-pass/issues/issue-8851.rs @@ -5,7 +5,7 @@ // doesn't cause capture. Making this macro hygienic (as I've done) // could very well make this test case completely pointless.... -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum T { A(isize), diff --git a/src/test/run-pass/issues/issue-9123.rs b/src/test/run-pass/issues/issue-9123.rs index 5072ca6ba5374..c44ad131321d7 100644 --- a/src/test/run-pass/issues/issue-9123.rs +++ b/src/test/run-pass/issues/issue-9123.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue_9123.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_9123; diff --git a/src/test/run-pass/issues/issue-9382.rs b/src/test/run-pass/issues/issue-9382.rs index dbb0fa524ef51..8b24ccc8eb711 100644 --- a/src/test/run-pass/issues/issue-9382.rs +++ b/src/test/run-pass/issues/issue-9382.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // run-pass diff --git a/src/test/run-pass/issues/issue-9906.rs b/src/test/run-pass/issues/issue-9906.rs index a2870cf0f6eb7..b42784d1ec14f 100644 --- a/src/test/run-pass/issues/issue-9906.rs +++ b/src/test/run-pass/issues/issue-9906.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-9906.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_9906 as testmod; diff --git a/src/test/run-pass/issues/issue-9942.rs b/src/test/run-pass/issues/issue-9942.rs index f4880446526e7..d0445afce2741 100644 --- a/src/test/run-pass/issues/issue-9942.rs +++ b/src/test/run-pass/issues/issue-9942.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { const S: usize = 23 as usize; [0; S]; () diff --git a/src/test/run-pass/issues/issue-9951.rs b/src/test/run-pass/issues/issue-9951.rs index 4e14bdbd73429..3fcc2a3fe9a58 100644 --- a/src/test/run-pass/issues/issue-9951.rs +++ b/src/test/run-pass/issues/issue-9951.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] diff --git a/src/test/run-pass/issues/issue-9968.rs b/src/test/run-pass/issues/issue-9968.rs index 3ab90d99af9cc..0b1605d30d3e8 100644 --- a/src/test/run-pass/issues/issue-9968.rs +++ b/src/test/run-pass/issues/issue-9968.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue-9968.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_9968 as lib; diff --git a/src/test/run-pass/issues/issue2170exe.rs b/src/test/run-pass/issues/issue2170exe.rs index 4169ddf9bb7f7..f114328a4101c 100644 --- a/src/test/run-pass/issues/issue2170exe.rs +++ b/src/test/run-pass/issues/issue2170exe.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:issue2170lib.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue2170lib; diff --git a/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs b/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs index 215145a64b177..1d75fe26ca2d2 100644 --- a/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs +++ b/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs @@ -1,7 +1,7 @@ use std::fmt; // This ia file with many multi-byte characters, to try to encourage -// the compiler to trip on them. The Drop implementation below will +// the compiler to trip on them. The Drop implementation below will // need to have its source location embedded into the debug info for // the output file. diff --git a/src/test/run-pass/issues/issue_3136_b.rs b/src/test/run-pass/issues/issue_3136_b.rs index f0bdd2b5ec050..237da58865687 100644 --- a/src/test/run-pass/issues/issue_3136_b.rs +++ b/src/test/run-pass/issues/issue_3136_b.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue_3136_a.rc -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_3136_a; pub fn main() {} diff --git a/src/test/run-pass/issues/issue_9155.rs b/src/test/run-pass/issues/issue_9155.rs index 87c453be1420b..acbcac1202857 100644 --- a/src/test/run-pass/issues/issue_9155.rs +++ b/src/test/run-pass/issues/issue_9155.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:issue_9155.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate issue_9155; diff --git a/src/test/run-pass/item-name-overload.rs b/src/test/run-pass/item-name-overload.rs index 58ef977919cdd..ebacf538d5746 100644 --- a/src/test/run-pass/item-name-overload.rs +++ b/src/test/run-pass/item-name-overload.rs @@ -2,7 +2,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub fn baz() { } diff --git a/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs b/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs index 9151172fd15ed..9f922001cb25d 100644 --- a/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs +++ b/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs @@ -8,7 +8,7 @@ // propagation yet, and so we just saw a type variable, yielding an // error. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait IntoIterator { type Iter: Iterator; diff --git a/src/test/run-pass/keyword-changes-2012-07-31.rs b/src/test/run-pass/keyword-changes-2012-07-31.rs index 73b0d07090b24..5a9b85027cd85 100644 --- a/src/test/run-pass/keyword-changes-2012-07-31.rs +++ b/src/test/run-pass/keyword-changes-2012-07-31.rs @@ -3,7 +3,7 @@ // mod -> module // match -> match -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { } diff --git a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs index 3b2991ede9962..d25cc6b492625 100644 --- a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs +++ b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs @@ -6,7 +6,7 @@ fn user(_i: isize) {} fn foo() { // Here, i is *copied* into the proc (heap closure). - // Requires allocation. The proc's copy is not mutable. + // Requires allocation. The proc's copy is not mutable. let mut i = 0; let t = thread::spawn(move|| { user(i); diff --git a/src/test/run-pass/kinds-in-metadata.rs b/src/test/run-pass/kinds-in-metadata.rs index 7cfc28b12b98a..9fa99d4cec6ce 100644 --- a/src/test/run-pass/kinds-in-metadata.rs +++ b/src/test/run-pass/kinds-in-metadata.rs @@ -1,9 +1,6 @@ // aux-build:kinds_in_metadata.rs -// pretty-expanded FIXME #23616 - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ +// pretty-expanded FIXME(#23616) // Tests that metadata serialization works for the `Copy` kind. diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 751801e7c217b..2236be45163c9 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -1,7 +1,7 @@ #![allow(unused_mut)] -// This should typecheck even though the type of e is not fully -// resolved when we finish typechecking the ||. +// This should type-check even though the type of `e` is not fully +// resolved when we finish type-checking the `||`. struct Refs { refs: Vec , n: isize } diff --git a/src/test/run-pass/large-records.rs b/src/test/run-pass/large-records.rs index 9786ea7978090..f4ac06517bf90 100644 --- a/src/test/run-pass/large-records.rs +++ b/src/test/run-pass/large-records.rs @@ -3,7 +3,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Large {a: isize, b: isize, diff --git a/src/test/run-pass/leak-unique-as-tydesc.rs b/src/test/run-pass/leak-unique-as-tydesc.rs index 2293e3c823f8c..76c4439a0dc80 100644 --- a/src/test/run-pass/leak-unique-as-tydesc.rs +++ b/src/test/run-pass/leak-unique-as-tydesc.rs @@ -1,7 +1,10 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] -fn leaky(_t: T) { } +fn leaky(_t: T) {} -pub fn main() { let x = box 10; leaky::>(x); } +pub fn main() { + let x = box 10; + leaky::>(x); +} diff --git a/src/test/run-pass/list.rs b/src/test/run-pass/list.rs index 62c04bcac757b..cc9fa6548dad7 100644 --- a/src/test/run-pass/list.rs +++ b/src/test/run-pass/list.rs @@ -1,5 +1,5 @@ #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs index 3dc27dde52b32..f1ef9ccd0d2dc 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs @@ -1,5 +1,5 @@ #![allow(unreachable_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/logging_before_rt_started.rs b/src/test/run-pass/logging_before_rt_started.rs index 0cba1080de265..aadc3f04692ef 100644 --- a/src/test/run-pass/logging_before_rt_started.rs +++ b/src/test/run-pass/logging_before_rt_started.rs @@ -6,6 +6,6 @@ // this test will trigger "output during runtime initialization" to make sure // that the bug isn't re-introduced. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() {} diff --git a/src/test/run-pass/long-while.rs b/src/test/run-pass/long-while.rs index 4a3ee6f971387..9a12ee5f2353e 100644 --- a/src/test/run-pass/long-while.rs +++ b/src/test/run-pass/long-while.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] diff --git a/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs b/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs index 2d78ae6f90833..578e87e196673 100644 --- a/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs +++ b/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(trace_macros, log_syntax)] diff --git a/src/test/run-pass/macros/macro-export-inner-module.rs b/src/test/run-pass/macros/macro-export-inner-module.rs index 1f23e90b65cd5..fbe7419e19d77 100644 --- a/src/test/run-pass/macros/macro-export-inner-module.rs +++ b/src/test/run-pass/macros/macro-export-inner-module.rs @@ -1,5 +1,5 @@ // run-pass -//aux-build:macro_export_inner_module.rs +// aux-build:macro_export_inner_module.rs #[macro_use] #[no_link] extern crate macro_export_inner_module; diff --git a/src/test/run-pass/macros/macro-first-set.rs b/src/test/run-pass/macros/macro-first-set.rs index 8b09e72ed2951..8504194edf4d0 100644 --- a/src/test/run-pass/macros/macro-first-set.rs +++ b/src/test/run-pass/macros/macro-first-set.rs @@ -1,6 +1,6 @@ // run-pass -//{{{ issue 40569 ============================================================== +//{{{ issue #40569 ============================================================== macro_rules! my_struct { ($(#[$meta:meta])* $ident:ident) => { @@ -16,7 +16,7 @@ fn test_40569() { //}}} -//{{{ issue 26444 ============================================================== +//{{{ issue #26444 ============================================================== macro_rules! foo_26444 { ($($beginning:ident),*; $middle:ident; $($end:ident),*) => { @@ -38,7 +38,7 @@ pat_26444!(bar Some(ref x) Ok(ref mut y) &(w, z) =); //}}} -//{{{ issue 40984 ============================================================== +//{{{ issue #40984 ============================================================== macro_rules! thread_local_40984 { () => {}; @@ -62,7 +62,7 @@ thread_local_40984! { //}}} -//{{{ issue 35650 ============================================================== +//{{{ issue #35650 ============================================================== macro_rules! size { ($ty:ty) => { @@ -80,7 +80,7 @@ fn test_35650() { //}}} -//{{{ issue 27832 ============================================================== +//{{{ issue #27832 ============================================================== macro_rules! m { ( $i:ident ) => (); @@ -105,7 +105,7 @@ m2!(enum Foo); //}}} -//{{{ issue 39964 ============================================================== +//{{{ issue #39964 ============================================================== macro_rules! foo_39964 { ($a:ident) => {}; @@ -116,7 +116,7 @@ foo_39964!(_); //}}} -//{{{ issue 34030 ============================================================== +//{{{ issue #34030 ============================================================== macro_rules! foo_34030 { ($($t:ident),* /) => {}; @@ -128,7 +128,7 @@ foo_34030!(/); //}}} -//{{{ issue 24189 ============================================================== +//{{{ issue #24189 ============================================================== macro_rules! foo_24189 { ( @@ -189,7 +189,7 @@ fn test_24189() { //}}} -//{{{ issue 50903 ============================================================== +//{{{ issue #50903 ============================================================== macro_rules! foo_50903 { ($($lif:lifetime ,)* #) => {}; @@ -201,7 +201,7 @@ foo_50903!(#); //}}} -//{{{ issue 51477 ============================================================== +//{{{ issue #51477 ============================================================== macro_rules! foo_51477 { ($lifetime:lifetime) => { @@ -250,7 +250,7 @@ test_path!(); test_path!(,); test_path!(::std); test_path!(std::u8,); -test_path!(any, super, super::super::self::path, X::Z<'a, T=U>); +test_path!(any, super, super::super::self::path, X::Z<'a, T = U>); macro_rules! test_meta_block { ($($m:meta)* $b:block) => {}; diff --git a/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs b/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs index 8f9dcb94794b6..d7a3c161e280f 100644 --- a/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs +++ b/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) macro_rules! four { () => (4) diff --git a/src/test/run-pass/macros/macro-nt-list.rs b/src/test/run-pass/macros/macro-nt-list.rs index 36aa74f082530..30239cb92e065 100644 --- a/src/test/run-pass/macros/macro-nt-list.rs +++ b/src/test/run-pass/macros/macro-nt-list.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) macro_rules! list { ( ($($id:ident),*) ) => (()); diff --git a/src/test/run-pass/macros/macro-seq-followed-by-seq.rs b/src/test/run-pass/macros/macro-seq-followed-by-seq.rs index 8f0f4fd4a0d44..0704c06a59a3f 100644 --- a/src/test/run-pass/macros/macro-seq-followed-by-seq.rs +++ b/src/test/run-pass/macros/macro-seq-followed-by-seq.rs @@ -1,7 +1,6 @@ // run-pass // Test of allowing two sequences repetitions in a row, -// functionality added as byproduct of RFC amendment #1384 -// https://github.com/rust-lang/rfcs/pull/1384 +// functionality added as by-product of RFC amendment #1384. // Old version of Rust would reject this macro definition, even though // there are no local ambiguities (the initial `banana` and `orange` diff --git a/src/test/run-pass/macros/macro_with_super_2.rs b/src/test/run-pass/macros/macro_with_super_2.rs index 2901a74f612b4..89d93d21484ba 100644 --- a/src/test/run-pass/macros/macro_with_super_2.rs +++ b/src/test/run-pass/macros/macro_with_super_2.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:macro_with_super_1.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[macro_use] extern crate macro_with_super_1; diff --git a/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs b/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs index 8fef9b0ed877b..77539ea93740b 100644 --- a/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs +++ b/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs @@ -7,7 +7,7 @@ // Test parsing binary operators after macro invocations. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(macro_rules)] diff --git a/src/test/run-pass/macros/pub-item-inside-macro.rs b/src/test/run-pass/macros/pub-item-inside-macro.rs index d07681453a23a..9496efa2f91d9 100644 --- a/src/test/run-pass/macros/pub-item-inside-macro.rs +++ b/src/test/run-pass/macros/pub-item-inside-macro.rs @@ -1,7 +1,7 @@ // run-pass // Issue #14660 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod bleh { macro_rules! foo { diff --git a/src/test/run-pass/macros/pub-method-inside-macro.rs b/src/test/run-pass/macros/pub-method-inside-macro.rs index bc918c7a4dc22..c5cbd753155f9 100644 --- a/src/test/run-pass/macros/pub-method-inside-macro.rs +++ b/src/test/run-pass/macros/pub-method-inside-macro.rs @@ -1,7 +1,7 @@ // run-pass // Issue #17436 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod bleh { macro_rules! foo { diff --git a/src/test/run-pass/methods/method-attributes.rs b/src/test/run-pass/methods/method-attributes.rs index c7d8b3b1403ab..3deaa5d417b7a 100644 --- a/src/test/run-pass/methods/method-attributes.rs +++ b/src/test/run-pass/methods/method-attributes.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] // pp-exact - Make sure we print all the attributes -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(custom_attribute)] diff --git a/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs b/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs index f2ace32c6b636..7157094c1c232 100644 --- a/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs +++ b/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs @@ -2,7 +2,7 @@ // Check that we successfully handle methods where the `self` type has // an early-bound lifetime. Issue #18208. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs b/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs index 9c0b952849eab..d1e17e0a42d74 100644 --- a/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs +++ b/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs @@ -9,7 +9,7 @@ // winnowing stage of method resolution failed to handle an associated // type projection. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(associated_types)] diff --git a/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs b/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs index 8c8165a100449..2dc96e9dd6fd6 100644 --- a/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs +++ b/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs @@ -1,12 +1,12 @@ // Check that method matching does not make "guesses" depending on -// Deref impls that don't eventually end up being picked. +// `Deref` impls that don't eventually end up being picked. use std::ops::Deref; // An impl with less derefs will get called over an impl with more derefs, // so `(t: Foo<_>).my_fn()` will use ` as MyTrait1>::my_fn(t)`, -// and does *not* force the `_` to equal `()`, because the Deref impl -// was *not* used. +// and does **not** force the `_` to equal `()`, because the `Deref` impl +// was **not** used. trait MyTrait1 { fn my_fn(&self) {} @@ -23,9 +23,9 @@ impl Deref for Foo<()> { } } -// ...but if there is no impl with less derefs, the "guess" will be +// ... but if there is no impl with less derefs, the "guess" will be // forced, so `(t: Bar<_>).my_fn2()` is `::my_fn2(*t)`, -// and because the deref impl is used, the `_` is forced to equal `u8`. +// and because the `Deref` impl is used, the `_` is forced to equal `u8`. trait MyTrait2 { fn my_fn2(&self) {} @@ -40,7 +40,7 @@ impl Deref for Bar { } } -// actually invoke things +// Actually invoke things. fn main() { let mut foo: Option> = None; diff --git a/src/test/run-pass/methods/method-recursive-blanket-impl.rs b/src/test/run-pass/methods/method-recursive-blanket-impl.rs index a2db75b4e85d8..55e8eeab9ca30 100644 --- a/src/test/run-pass/methods/method-recursive-blanket-impl.rs +++ b/src/test/run-pass/methods/method-recursive-blanket-impl.rs @@ -2,11 +2,11 @@ #![allow(unused_variables)] #![allow(unused_imports)] // Test that we don't trigger on the blanket impl for all `&'a T` but -// rather keep autoderefing and trigger on the underlying impl. To +// rather keep autoderefing and trigger on the underlying impl. To // know not to stop at the blanket, we have to recursively evaluate // the `T:Foo` bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::Sized; diff --git a/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs b/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs index 8af3dcf5c3db0..d2c50ba4e379e 100644 --- a/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs +++ b/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs @@ -4,7 +4,7 @@ // this case, we know that `x: Vec<_1>`, but we don't know what type // `_1` is (because the call to `push` comes later). To pick between // the impls, we would have to know `_1`, since we have to know -// whether `_1: MyCopy` or `_1 == Box`. However (and this is the +// whether `_1: MyCopy` or `_1 == Box`. However (and this is the // point of the test), we don't have to pick between the two impls -- // it is enough to know that `foo` comes from the `Foo` trait. We can // codegen the call as `Foo::foo(&x)` and let the specific impl get diff --git a/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs b/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs index d820d2ad08ae8..16c99f88ebdcb 100644 --- a/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs +++ b/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs @@ -2,7 +2,7 @@ // Test that we select between traits A and B. To do that, we must // consider the `Sized` bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn foo(self); diff --git a/src/test/run-pass/methods/method-where-clause.rs b/src/test/run-pass/methods/method-where-clause.rs index 01692abf9b6f2..0e2152a6d7ea4 100644 --- a/src/test/run-pass/methods/method-where-clause.rs +++ b/src/test/run-pass/methods/method-where-clause.rs @@ -1,7 +1,7 @@ // run-pass -// Test that we can use method notation to call methods based on a -// where clause type, and not only type parameters. +// Test that we can use method notation to call methods based on a +// where-clause type, and not only type parameters. trait Foo { fn foo(&self) -> i32; diff --git a/src/test/run-pass/mid-path-type-params.rs b/src/test/run-pass/mid-path-type-params.rs index e8ed0424e4aca..7b26187ad271b 100644 --- a/src/test/run-pass/mid-path-type-params.rs +++ b/src/test/run-pass/mid-path-type-params.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S { contents: T, diff --git a/src/test/run-pass/mir/mir_codegen_critical_edge.rs b/src/test/run-pass/mir/mir_codegen_critical_edge.rs index 03b111e93dd25..20f74b09e442b 100644 --- a/src/test/run-pass/mir/mir_codegen_critical_edge.rs +++ b/src/test/run-pass/mir/mir_codegen_critical_edge.rs @@ -18,7 +18,7 @@ pub struct Foo { } impl Foo -where A: Iterator, B: Iterator +where A: Iterator, B: Iterator { // This is the function we care about fn next(&mut self) -> Option { diff --git a/src/test/run-pass/mir/mir_early_return_scope.rs b/src/test/run-pass/mir/mir_early_return_scope.rs index a696471c36150..bed10fc59e1f0 100644 --- a/src/test/run-pass/mir/mir_early_return_scope.rs +++ b/src/test/run-pass/mir/mir_early_return_scope.rs @@ -4,7 +4,7 @@ static mut DROP: bool = false; struct ConnWrap(Conn); impl ::std::ops::Deref for ConnWrap { - type Target=Conn; + type Target = Conn; fn deref(&self) -> &Conn { &self.0 } } diff --git a/src/test/run-pass/modules/mod-view-items.rs b/src/test/run-pass/modules/mod-view-items.rs index db2b303668b7e..71cf265a2468a 100644 --- a/src/test/run-pass/modules/mod-view-items.rs +++ b/src/test/run-pass/modules/mod-view-items.rs @@ -5,7 +5,7 @@ // pretty-print such view items. If that happens again, this should // begin failing. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m { pub fn f() -> Vec { Vec::new() } diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index ec7ff2d8a5174..6249f7db775f8 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Serializer { } diff --git a/src/test/run-pass/moves/move-nullary-fn.rs b/src/test/run-pass/moves/move-nullary-fn.rs index 14c9262c74d18..905e0d5b39d1e 100644 --- a/src/test/run-pass/moves/move-nullary-fn.rs +++ b/src/test/run-pass/moves/move-nullary-fn.rs @@ -1,6 +1,6 @@ // run-pass // Issue #922 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f2(_thing: F) where F: FnOnce() { } diff --git a/src/test/run-pass/mpsc_stress.rs b/src/test/run-pass/mpsc_stress.rs index cd30dd62bc4ce..930480dd09632 100644 --- a/src/test/run-pass/mpsc_stress.rs +++ b/src/test/run-pass/mpsc_stress.rs @@ -67,7 +67,7 @@ fn shared_close_sender_does_not_lose_messages() { } -// https://github.com/rust-lang/rust/issues/39364 +// See issue #39364. fn concurrent_recv_timeout_and_upgrade_iter() { // 1 us let sleep = Duration::new(0, 1_000); diff --git a/src/test/run-pass/multi-panic.rs b/src/test/run-pass/multi-panic.rs index 3f24d989c8c3f..9f026551cae49 100644 --- a/src/test/run-pass/multi-panic.rs +++ b/src/test/run-pass/multi-panic.rs @@ -7,7 +7,7 @@ fn check_for_no_backtrace(test: std::process::Output) { let mut it = err.lines(); assert_eq!(it.next().map(|l| l.starts_with("thread '' panicked at")), Some(true)); - assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` \ + assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \ environment variable to display a backtrace.")); assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true)); assert_eq!(it.next(), None); diff --git a/src/test/run-pass/multiline-comment.rs b/src/test/run-pass/multiline-comment.rs index 76f9284eb3eb1..590d3fd49781f 100644 --- a/src/test/run-pass/multiline-comment.rs +++ b/src/test/run-pass/multiline-comment.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* * This is a multi-line oldcomment. diff --git a/src/test/run-pass/mut-vstore-expr.rs b/src/test/run-pass/mut-vstore-expr.rs index d598e3b88db91..27bac4a417489 100644 --- a/src/test/run-pass/mut-vstore-expr.rs +++ b/src/test/run-pass/mut-vstore-expr.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let _x: &mut [isize] = &mut [ 1, 2, 3 ]; diff --git a/src/test/run-pass/mutual-recursion-group.rs b/src/test/run-pass/mutual-recursion-group.rs index 3be87b5a49051..5dfbfb1dd6fc2 100644 --- a/src/test/run-pass/mutual-recursion-group.rs +++ b/src/test/run-pass/mutual-recursion-group.rs @@ -1,7 +1,7 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum colour { red, green, blue, } diff --git a/src/test/run-pass/nested-block-comment.rs b/src/test/run-pass/nested-block-comment.rs index 62d038024a276..864f3bc8c6496 100644 --- a/src/test/run-pass/nested-block-comment.rs +++ b/src/test/run-pass/nested-block-comment.rs @@ -1,11 +1,10 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) -/* This test checks that nested comments are supported +/* This test checks that nested comments are supported. /* This should not panic */ */ -pub fn main() { -} +pub fn main() {} diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index a39803c2eb84b..896fc8d925731 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -1,7 +1,4 @@ -// pretty-expanded FIXME #23616 - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ +// pretty-expanded FIXME(#23616) #![allow(dead_code, unused_variables)] #![feature(box_syntax)] diff --git a/src/test/run-pass/new-unsafe-pointers.rs b/src/test/run-pass/new-unsafe-pointers.rs index a80ef1410876c..fe02cecd26527 100644 --- a/src/test/run-pass/new-unsafe-pointers.rs +++ b/src/test/run-pass/new-unsafe-pointers.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let _a: *const isize = 3 as *const isize; diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 969868486e6eb..98576064981bf 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -2,7 +2,7 @@ // Test that the lambda kind is inferred correctly as a return // expression -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn unique() -> Box { return Box::new(|| ()); } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 676b3507c5740..65de92472b96d 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -2,7 +2,7 @@ // Test that the lambda kind is inferred correctly as a return // expression -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn unique() -> Box { Box::new(|| ()) } diff --git a/src/test/run-pass/nil-decl-in-foreign.rs b/src/test/run-pass/nil-decl-in-foreign.rs index faff6b48730cf..b4bec15b8468f 100644 --- a/src/test/run-pass/nil-decl-in-foreign.rs +++ b/src/test/run-pass/nil-decl-in-foreign.rs @@ -1,7 +1,7 @@ #![allow(improper_ctypes)] #![allow(dead_code)] // Issue #901 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod libc { extern { diff --git a/src/test/run-pass/nll/rc-loop.rs b/src/test/run-pass/nll/rc-loop.rs index 2c54ee8693902..1ecd6498ed4f0 100644 --- a/src/test/run-pass/nll/rc-loop.rs +++ b/src/test/run-pass/nll/rc-loop.rs @@ -3,7 +3,7 @@ // A test for something that NLL enables. It sometimes happens that // the `while let` pattern makes some borrows from a variable (in this // case, `x`) that you need in order to compute the next value for -// `x`. The lexical checker makes this very painful. The NLL checker +// `x`. The lexical checker makes this very painful. The NLL checker // does not. #![feature(nll)] diff --git a/src/test/run-pass/non-built-in-quote.rs b/src/test/run-pass/non-built-in-quote.rs index 75df2788d7918..fc842c0227cd0 100644 --- a/src/test/run-pass/non-built-in-quote.rs +++ b/src/test/run-pass/non-built-in-quote.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) macro_rules! quote_tokens { () => (()) } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 42aad550c1a7f..75a1ff75f7ca9 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -2,7 +2,7 @@ // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions, // which "says that a destructor applied to an object built from a constructor -// behaves as expected". -- http://coq.inria.fr/doc/Reference-Manual006.html +// behaves as expected". (See .) // // It's a little more complicated here, because of pointers and regions and // trying to get assert failure messages that at least identify which case diff --git a/src/test/run-pass/numbers-arithmetic/i128.rs b/src/test/run-pass/numbers-arithmetic/i128.rs index f3b5506ae32a6..6d71060ecf840 100644 --- a/src/test/run-pass/numbers-arithmetic/i128.rs +++ b/src/test/run-pass/numbers-arithmetic/i128.rs @@ -100,7 +100,7 @@ fn main() { assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); assert_eq!(o.checked_shl(b(128)), None); - // https://github.com/rust-lang/rust/issues/41228 + // See issue #41228. assert_eq!(b(-87559967289969187895646876466835277875_i128) / b(84285771033834995895337664386045050880_i128), -1i128); diff --git a/src/test/run-pass/numbers-arithmetic/int.rs b/src/test/run-pass/numbers-arithmetic/int.rs index b496a70a6feae..69762c0f6ea34 100644 --- a/src/test/run-pass/numbers-arithmetic/int.rs +++ b/src/test/run-pass/numbers-arithmetic/int.rs @@ -2,6 +2,6 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let _x: isize = 10; } diff --git a/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs b/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs index 80248dc223dcc..2e1ea50bdc8fb 100644 --- a/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs +++ b/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(_: *const ()) {} diff --git a/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs b/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs index d177ced1a6966..fedadbf285e18 100644 --- a/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs +++ b/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { fn id_i8(n: i8) -> i8 { n } diff --git a/src/test/run-pass/numbers-arithmetic/num-wrapping.rs b/src/test/run-pass/numbers-arithmetic/num-wrapping.rs index 9a01549ecd24e..cc1aa4f8ebf4c 100644 --- a/src/test/run-pass/numbers-arithmetic/num-wrapping.rs +++ b/src/test/run-pass/numbers-arithmetic/num-wrapping.rs @@ -285,7 +285,7 @@ fn test_sh_ops() { assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans)); } } - // NOTE: This will break for i8 if we ever get i/u128 + // NOTE: this will break for `i8` if we ever get `i128`/`u128`. macro_rules! sh_test_all { ($t:ty) => { sh_test!(shl(i8::MAX, (i8::BITS + 1) as $t) == -2); diff --git a/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs b/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs index f13964fb38665..f2d7e390693e4 100644 --- a/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs +++ b/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs @@ -51,7 +51,7 @@ macro_rules! common_fptoi_tests { test!($fty::INFINITY, $fty -> $ity, $ity::MAX); test!($fty::NEG_INFINITY, $fty -> $ity, $ity::MIN); // These two tests are not solely float->int tests, in particular the latter relies on - // `u128::MAX as f32` not being UB. But that's okay, since this file tests int->float + // `u128::MAX as f32` not being UB. But that's ok, since this file tests int->float // as well, the test is just slightly misplaced. test!($ity::MIN as $fty, $fty -> $ity, $ity::MIN); test!($ity::MAX as $fty, $fty -> $ity, $ity::MAX); @@ -88,7 +88,7 @@ macro_rules! fptoui_tests { pub fn main() { common_fptoi_tests!(f* -> i8 i16 i32 i64 u8 u16 u32 u64); fptoui_tests!(f* -> u8 u16 u32 u64); - // FIXME emscripten does not support i128 + // FIXME: emscripten does not support i128 #[cfg(not(target_os="emscripten"))] { common_fptoi_tests!(f* -> i128 u128); fptoui_tests!(f* -> u128); diff --git a/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs b/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs index 939eb9746121f..2c3c3ccc9e41f 100644 --- a/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs +++ b/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs @@ -1,7 +1,7 @@ // run-pass // compile-flags: -C debug-assertions -// Check that we do *not* overflow on a number of edge cases. +// Check that we do **not** overflow on a number of edge cases. // (compare with test/run-fail/overflowing-{lsh,rsh}*.rs) fn main() { @@ -22,7 +22,7 @@ fn id(x: T) -> T { } fn test_left_shift() { - // negative rhs can panic, but values in [0,N-1] are okay for iN + // negative rhs can panic, but values in [0,N-1] are ok for iN macro_rules! tests { ($iN:ty, $uN:ty, $max_rhs:expr, $expect_i:expr, $expect_u:expr) => { { @@ -65,7 +65,7 @@ fn test_left_shift() { } fn test_right_shift() { - // negative rhs can panic, but values in [0,N-1] are okay for iN + // negative rhs can panic, but values in [0,N-1] are ok for iN macro_rules! tests { ($iN:ty, $uN:ty, $max_rhs:expr, diff --git a/src/test/run-pass/numbers-arithmetic/u128.rs b/src/test/run-pass/numbers-arithmetic/u128.rs index 56d1f221d844c..21a2bf5d72ba7 100644 --- a/src/test/run-pass/numbers-arithmetic/u128.rs +++ b/src/test/run-pass/numbers-arithmetic/u128.rs @@ -88,7 +88,7 @@ fn main() { assert_eq!(b(0xa9008fb6c9d81e42_0e25730562a601c8_u128) / b(1u128 << 120), 169u128); - // case "KK/K0" with N >= D (https://github.com/rust-lang/rust/issues/41228). + // case "KK/K0" with N >= D (issue #41228). assert_eq!(b(0xe4d26e59f0640328_06da5b06efe83a41_u128) / b(0x330fcb030ea4447c_u128 << 64), 4u128); diff --git a/src/test/run-pass/numbers-arithmetic/uint.rs b/src/test/run-pass/numbers-arithmetic/uint.rs index d219eae8f333e..39b394e7b7605 100644 --- a/src/test/run-pass/numbers-arithmetic/uint.rs +++ b/src/test/run-pass/numbers-arithmetic/uint.rs @@ -2,6 +2,6 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { let _x: usize = 10 as usize; } diff --git a/src/test/run-pass/object-lifetime-default-default-to-static.rs b/src/test/run-pass/object-lifetime-default-default-to-static.rs index cf836c1a7deda..617fea9c1d571 100644 --- a/src/test/run-pass/object-lifetime-default-default-to-static.rs +++ b/src/test/run-pass/object-lifetime-default-default-to-static.rs @@ -1,7 +1,7 @@ // Test that `Box` is equivalent to `Box`, both in // fields and fn arguments. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs index 3f69c9274889c..9cca95aad97aa 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs @@ -1,7 +1,7 @@ // Test that the lifetime from the enclosing `&` is "inherited" // through the `Box` struct. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs index dc9e292f0de38..7846dc9151661 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs @@ -1,7 +1,7 @@ // Test that the lifetime of the enclosing `&` is used for the object // lifetime bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/object-lifetime-default-from-rptr.rs b/src/test/run-pass/object-lifetime-default-from-rptr.rs index 061f71b9ae6bf..6e7288e15d845 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr.rs @@ -1,7 +1,7 @@ // Test that the lifetime of the enclosing `&` is used for the object // lifetime bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 72d6d6806229e..7a3a7973bc776 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -1,6 +1,6 @@ #![allow(unused_must_use)] #![allow(unconditional_recursion)] -// ignore-android: FIXME (#20004) +// ignore-android: FIXME(#20004) // ignore-musl // ignore-cloudabi no processes // ignore-emscripten no processes diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index f3cc2e99e0ff4..8a5d141f85359 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unknown_lints)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_assignment)] #![allow(unused_variables)] diff --git a/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs index fde1ad20f7d9c..38c15733b118a 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs @@ -1,7 +1,7 @@ // run-pass // Tests that nested vtables work with overloaded calls. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(unboxed_closures, fn_traits)] diff --git a/src/test/run-pass/overloaded/overloaded-deref-count.rs b/src/test/run-pass/overloaded/overloaded-deref-count.rs index e2f1e10b5c8ae..8e935be30c61d 100644 --- a/src/test/run-pass/overloaded/overloaded-deref-count.rs +++ b/src/test/run-pass/overloaded/overloaded-deref-count.rs @@ -44,30 +44,30 @@ pub fn main() { let mut n = DerefCounter::new(0); let mut v = DerefCounter::new(Vec::new()); - let _ = *n; // Immutable deref + copy a POD. + let _ = *n; // Immutable deref and copy a POD. assert_eq!(n.counts(), (1, 0)); - let _ = (&*n, &*v); // Immutable deref + borrow. + let _ = (&*n, &*v); // Immutable deref and borrow. assert_eq!(n.counts(), (2, 0)); assert_eq!(v.counts(), (1, 0)); - let _ = (&mut *n, &mut *v); // Mutable deref + mutable borrow. + let _ = (&mut *n, &mut *v); // Mutable deref and mutable borrow. assert_eq!(n.counts(), (2, 1)); assert_eq!(v.counts(), (1, 1)); let mut v2 = Vec::new(); v2.push(1); - *n = 5; *v = v2; // Mutable deref + assignment. + *n = 5; *v = v2; // Mutable deref and assignment. assert_eq!(n.counts(), (2, 2)); assert_eq!(v.counts(), (1, 2)); - *n -= 3; // Mutable deref + assignment with binary operation. + *n -= 3; // Mutable deref and assignment with binary operation. assert_eq!(n.counts(), (2, 3)); - // Immutable deref used for calling a method taking &self. (The - // typechecker is smarter now about doing this.) + // Immutable deref used for calling a method taking `&self`. (The + // type-checker is smarter now about doing this.) (*n).to_string(); assert_eq!(n.counts(), (3, 3)); - // Mutable deref used for calling a method taking &mut self. + // Mutable deref used for calling a method taking `&mut self`. (*v).push(2); assert_eq!(v.counts(), (1, 3)); diff --git a/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs b/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs index eb027afeacde9..6e3d5f4905389 100644 --- a/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs +++ b/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs @@ -1,5 +1,5 @@ // run-pass -// Test overloading of the `[]` operator. In particular test that it +// Test overloading of the `[]` operator. In particular test that it // takes its argument *by reference*. use std::ops::Index; diff --git a/src/test/run-pass/owned-implies-static.rs b/src/test/run-pass/owned-implies-static.rs index 7101726ab6a60..fbd7687c1cabc 100644 --- a/src/test/run-pass/owned-implies-static.rs +++ b/src/test/run-pass/owned-implies-static.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(_x: T) {} diff --git a/src/test/run-pass/panic-uninitialized-zeroed.rs b/src/test/run-pass/panic-uninitialized-zeroed.rs index 31c0d2994d415..85666b1ba9440 100644 --- a/src/test/run-pass/panic-uninitialized-zeroed.rs +++ b/src/test/run-pass/panic-uninitialized-zeroed.rs @@ -20,7 +20,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type !" + s == "attempted to instantiate uninhabited type `!`" })), Some(true) ); @@ -29,7 +29,7 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type !" + s == "attempted to instantiate uninhabited type `!`" })), Some(true) ); @@ -38,7 +38,7 @@ fn main() { panic::catch_unwind(|| { mem::MaybeUninit::::uninitialized().into_initialized() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type !" + s == "attempted to instantiate uninhabited type `!`" })), Some(true) ); @@ -47,7 +47,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo" + s == "attempted to instantiate uninhabited type `Foo`" })), Some(true) ); @@ -56,7 +56,7 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo" + s == "attempted to instantiate uninhabited type `Foo`" })), Some(true) ); @@ -65,7 +65,7 @@ fn main() { panic::catch_unwind(|| { mem::MaybeUninit::::uninitialized().into_initialized() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo" + s == "attempted to instantiate uninhabited type `Foo`" })), Some(true) ); @@ -74,7 +74,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar" + s == "attempted to instantiate uninhabited type `Bar`" })), Some(true) ); @@ -83,7 +83,7 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar" + s == "attempted to instantiate uninhabited type `Bar`" })), Some(true) ); @@ -92,7 +92,7 @@ fn main() { panic::catch_unwind(|| { mem::MaybeUninit::::uninitialized().into_initialized() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar" + s == "attempted to instantiate uninhabited type `Bar`" })), Some(true) ); diff --git a/src/test/run-pass/parse-assoc-type-lt.rs b/src/test/run-pass/parse-assoc-type-lt.rs index e6b07c583fb09..e9bf273c95d39 100644 --- a/src/test/run-pass/parse-assoc-type-lt.rs +++ b/src/test/run-pass/parse-assoc-type-lt.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { type T; diff --git a/src/test/run-pass/path.rs b/src/test/run-pass/path.rs index 7a9b04c070465..6d30f0e884ea2 100644 --- a/src/test/run-pass/path.rs +++ b/src/test/run-pass/path.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub fn bar(_offset: usize) { } diff --git a/src/test/run-pass/privacy/priv-impl-prim-ty.rs b/src/test/run-pass/privacy/priv-impl-prim-ty.rs index 5d6a6b64ed36a..81af934806c45 100644 --- a/src/test/run-pass/privacy/priv-impl-prim-ty.rs +++ b/src/test/run-pass/privacy/priv-impl-prim-ty.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:priv-impl-prim-ty.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate priv_impl_prim_ty as bar; diff --git a/src/test/run-pass/privacy/privacy-ns.rs b/src/test/run-pass/privacy/privacy-ns.rs index b1b03eae5db5f..5af3c19953819 100644 --- a/src/test/run-pass/privacy/privacy-ns.rs +++ b/src/test/run-pass/privacy/privacy-ns.rs @@ -5,7 +5,7 @@ // Check we do the correct privacy checks when we import a name and there is an // item with that name in both the value and type namespaces. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/run-pass/privacy/privacy-reexport.rs b/src/test/run-pass/privacy/privacy-reexport.rs index b3ec3af04ace8..2236c058f67c3 100644 --- a/src/test/run-pass/privacy/privacy-reexport.rs +++ b/src/test/run-pass/privacy/privacy-reexport.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:privacy_reexport.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate privacy_reexport; diff --git a/src/test/run-pass/privacy/privacy1.rs b/src/test/run-pass/privacy/privacy1.rs index 4e54780dad2bb..8b98a85139780 100644 --- a/src/test/run-pass/privacy/privacy1.rs +++ b/src/test/run-pass/privacy/privacy1.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod test2 { // This used to generate an ICE (make sure that default functions are diff --git a/src/test/run-pass/privacy/private-method.rs b/src/test/run-pass/privacy/private-method.rs index 726944fb25122..8b499fe47b8cc 100644 --- a/src/test/run-pass/privacy/private-method.rs +++ b/src/test/run-pass/privacy/private-method.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct cat { meows : usize, diff --git a/src/test/run-pass/privacy/pub-extern-privacy.rs b/src/test/run-pass/privacy/pub-extern-privacy.rs index 832acfbadcbd4..9911c17a2f8c6 100644 --- a/src/test/run-pass/privacy/pub-extern-privacy.rs +++ b/src/test/run-pass/privacy/pub-extern-privacy.rs @@ -1,7 +1,7 @@ // run-pass // ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::mem::transmute; diff --git a/src/test/run-pass/privacy/pub-use-xcrate.rs b/src/test/run-pass/privacy/pub-use-xcrate.rs index e8a6e8cf182d4..cde155d4c53a2 100644 --- a/src/test/run-pass/privacy/pub-use-xcrate.rs +++ b/src/test/run-pass/privacy/pub-use-xcrate.rs @@ -2,7 +2,7 @@ // aux-build:pub_use_xcrate1.rs // aux-build:pub_use_xcrate2.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate pub_use_xcrate2; diff --git a/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs b/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs index f163619e7cb5f..84f18e41b5b4e 100644 --- a/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs +++ b/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:pub_use_mods_xcrate.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_imports)] diff --git a/src/test/run-pass/proc-macro/auxiliary/double.rs b/src/test/run-pass/proc-macro/auxiliary/double.rs index 3a2e8d04c36b5..aaad7bd04a3f6 100644 --- a/src/test/run-pass/proc-macro/auxiliary/double.rs +++ b/src/test/run-pass/proc-macro/auxiliary/double.rs @@ -7,7 +7,7 @@ extern crate proc_macro; use proc_macro::TokenStream; -// Outputs another copy of the struct. Useful for testing the tokens +// Outputs another copy of the struct. Useful for testing the tokens // seen by the proc_macro. #[proc_macro_derive(Double)] pub fn derive(input: TokenStream) -> TokenStream { diff --git a/src/test/run-pass/process/process-spawn-with-unicode-params.rs b/src/test/run-pass/process/process-spawn-with-unicode-params.rs index e3508cb4e8fc9..5434490e54cc7 100644 --- a/src/test/run-pass/process/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process/process-spawn-with-unicode-params.rs @@ -2,9 +2,9 @@ // no-prefer-dynamic // The test copies itself into a subdirectory with a non-ASCII name and then -// runs it as a child process within the subdirectory. The parent process +// runs it as a child process within the subdirectory. The parent process // also adds an environment variable and an argument, both containing -// non-ASCII characters. The child process ensures all the strings are +// non-ASCII characters. The child process ensures all the strings are // intact. // ignore-cloudabi no processes diff --git a/src/test/run-pass/project-cache-issue-37154.rs b/src/test/run-pass/project-cache-issue-37154.rs index 8b07b9c98ad8e..27b1c7070d95f 100644 --- a/src/test/run-pass/project-cache-issue-37154.rs +++ b/src/test/run-pass/project-cache-issue-37154.rs @@ -9,7 +9,7 @@ trait Foo { struct Wrapper(T); -impl Foo for Wrapper where for<'a> &'a T: IntoIterator {} +impl Foo for Wrapper where for<'a> &'a T: IntoIterator {} fn f(x: Wrapper>) { x.method(); // This works. diff --git a/src/test/run-pass/ptr-coercion.rs b/src/test/run-pass/ptr-coercion.rs index 0dd2b5467d9a9..3a0350bfd7b37 100644 --- a/src/test/run-pass/ptr-coercion.rs +++ b/src/test/run-pass/ptr-coercion.rs @@ -1,7 +1,7 @@ #![allow(unused_variables)] // Test coercions between pointers which don't do anything fancy like unsizing. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { // &mut -> & diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index d000c8488a686..38d04e4b77114 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // Check that functions can modify local state. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index e283d5b6de1db..786c22b4c93ba 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -76,7 +76,7 @@ unsafe fn test_triangle() -> bool { fn idx_to_size(i: usize) -> usize { (i+1) * 10 } - // Allocate pairs of rows that form a triangle shape. (Hope is + // Allocate pairs of rows that form a triangle shape. (Hope is // that at least two rows will be allocated near each other, so // that we trigger the bug (a buffer overrun) in an observable // way.) diff --git a/src/test/run-pass/reexport-should-still-link.rs b/src/test/run-pass/reexport-should-still-link.rs index 733f8f9c1f37d..b2c2f62f15c8d 100644 --- a/src/test/run-pass/reexport-should-still-link.rs +++ b/src/test/run-pass/reexport-should-still-link.rs @@ -1,6 +1,6 @@ // aux-build:reexport-should-still-link.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate reexport_should_still_link as foo; diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs index ae48f97a9ddb5..a4097bd9d919f 100644 --- a/src/test/run-pass/reexport-star.rs +++ b/src/test/run-pass/reexport-star.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod a { pub fn f() {} diff --git a/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs index 4221ebfdffb2b..de9f6671d455d 100644 --- a/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Point { x: isize, diff --git a/src/test/run-pass/regions/regions-assoc-type-region-bound.rs b/src/test/run-pass/regions/regions-assoc-type-region-bound.rs index cbb7d1726d9e1..762b9fcd005d8 100644 --- a/src/test/run-pass/regions/regions-assoc-type-region-bound.rs +++ b/src/test/run-pass/regions/regions-assoc-type-region-bound.rs @@ -3,7 +3,7 @@ // Test that the compiler considers the 'a bound declared in the // trait. Issue #20890. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo<'a> { type Value: 'a; diff --git a/src/test/run-pass/regions/regions-assoc-type-static-bound.rs b/src/test/run-pass/regions/regions-assoc-type-static-bound.rs index 1458787ea65a3..9846bc5beba36 100644 --- a/src/test/run-pass/regions/regions-assoc-type-static-bound.rs +++ b/src/test/run-pass/regions/regions-assoc-type-static-bound.rs @@ -3,7 +3,7 @@ // Test that the compiler considers the 'static bound declared in the // trait. Issue #20890. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { type Value: 'static; diff --git a/src/test/run-pass/regions/regions-creating-enums2.rs b/src/test/run-pass/regions/regions-creating-enums2.rs index 7b16fb1a8e081..4ea5861598e2b 100644 --- a/src/test/run-pass/regions/regions-creating-enums2.rs +++ b/src/test/run-pass/regions/regions-creating-enums2.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum ast<'a> { num(usize), diff --git a/src/test/run-pass/regions/regions-creating-enums5.rs b/src/test/run-pass/regions/regions-creating-enums5.rs index ad3d9748bf0a6..df301f1d6473b 100644 --- a/src/test/run-pass/regions/regions-creating-enums5.rs +++ b/src/test/run-pass/regions/regions-creating-enums5.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum ast<'a> { num(usize), diff --git a/src/test/run-pass/regions/regions-debruijn-of-object.rs b/src/test/run-pass/regions/regions-debruijn-of-object.rs index 24c0cf53317e0..30313140bd3b0 100644 --- a/src/test/run-pass/regions/regions-debruijn-of-object.rs +++ b/src/test/run-pass/regions/regions-debruijn-of-object.rs @@ -3,7 +3,7 @@ #![allow(unused_variables)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct ctxt<'tcx> { x: &'tcx i32 diff --git a/src/test/run-pass/regions/regions-dependent-autofn.rs b/src/test/run-pass/regions/regions-dependent-autofn.rs index 246dbb5563c1c..c252458a381c1 100644 --- a/src/test/run-pass/regions/regions-dependent-autofn.rs +++ b/src/test/run-pass/regions/regions-dependent-autofn.rs @@ -2,7 +2,7 @@ // Test lifetimes are linked properly when we autoslice a vector. // Issue #3148. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn subslice(v: F) -> F where F: FnOnce() { v } diff --git a/src/test/run-pass/regions/regions-dependent-let-ref.rs b/src/test/run-pass/regions/regions-dependent-let-ref.rs index 94e3df4b3f1e8..aa57ee089e98e 100644 --- a/src/test/run-pass/regions/regions-dependent-let-ref.rs +++ b/src/test/run-pass/regions/regions-dependent-let-ref.rs @@ -2,7 +2,7 @@ // Test lifetimes are linked properly when we take reference // to interior. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo(isize); pub fn main() { diff --git a/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs b/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs index fe50a7dd1be33..c5efcd5503188 100644 --- a/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs +++ b/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs @@ -1,12 +1,14 @@ // run-pass -#![allow(unused_imports)] + // Test that we are able to compile calls to associated fns like // `decode()` where the bound on the `Self` parameter references a // lifetime parameter of the trait. This example indicates why trait -// lifetime parameters must be early bound in the type of the +// lifetime parameters must be early-bound in the type of the // associated item. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) + +#![allow(unused_imports)] use std::marker; @@ -32,4 +34,4 @@ impl<'v, D: Decoder<'v>> Decodable<'v, D> for () { } } -pub fn main() { } +pub fn main() {} diff --git a/src/test/run-pass/regions/regions-early-bound-trait-param.rs b/src/test/run-pass/regions/regions-early-bound-trait-param.rs index c71e47db22d41..dc9820bf2a720 100644 --- a/src/test/run-pass/regions/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions/regions-early-bound-trait-param.rs @@ -115,14 +115,15 @@ pub fn main() { assert_eq!(field_invoke2(&s2), 3); let m : Box = make_val(); - // assert_eq!(object_invoke1(&*m), (4,5)); - // ~~~~~~~~~~~~~~~~~~~ - // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs + // assert_eq!(object_invoke1(&*m), (4,5)); + // ~~~~~~~~~~~~~~~~~~~ + // + // This call yields a compilation error; see `compile-fail/dropck-object-cycle.rs` // for details. assert_eq!(object_invoke2(&*m), 5); // The RefMakerTrait above is pretty strange (i.e., it is strange - // to consume a value of type T and return a &T). Easiest thing + // to consume a value of type `T` and return a `&T`). Easiest thing // that came to my mind: consume a cell of a linked list and // return a reference to the list it points to. let l0 = List::Null; diff --git a/src/test/run-pass/regions/regions-expl-self.rs b/src/test/run-pass/regions/regions-expl-self.rs index f7315d628a57e..c894f680a2171 100644 --- a/src/test/run-pass/regions/regions-expl-self.rs +++ b/src/test/run-pass/regions/regions-expl-self.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Test that you can insert an explicit lifetime in explicit self. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo { f: usize diff --git a/src/test/run-pass/regions/regions-fn-subtyping-2.rs b/src/test/run-pass/regions/regions-fn-subtyping-2.rs index cbd88ebde0d1e..40bad58d4b37d 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping-2.rs @@ -5,7 +5,7 @@ // Here, `f` is a function that takes a pointer `x` and a function // `g`, where `g` requires its argument `y` to be in the same region // that `x` is in. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn has_same_region(f: Box FnMut(&'a isize, Box)>) { // `f` should be the type that `wants_same_region` wants, but diff --git a/src/test/run-pass/regions/regions-fn-subtyping.rs b/src/test/run-pass/regions/regions-fn-subtyping.rs index a1da966659a21..521648d93c2eb 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping.rs @@ -3,7 +3,7 @@ #![allow(unused_assignments)] // Issue #2263. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] @@ -11,9 +11,9 @@ fn ok(f: Box) { // Here, g is a function that can accept a usize pointer with // lifetime r, and f is a function that can accept a usize pointer - // with any lifetime. The assignment g = f should be OK (i.e., + // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be - // used in any context that expects g's type. But this currently + // used in any context that expects g's type. But this currently // fails. let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); g = f; diff --git a/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs index 5d8ad932ed61c..627b51885ebb0 100644 --- a/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs @@ -8,7 +8,7 @@ pub fn main() { for i in 0_usize..3 { // ensure that the borrow in this alt // does not interfere with the swap - // below. note that it would it you + // below. note that it would it you // naively borrowed &x for the lifetime // of the variable x, as we once did match i { diff --git a/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs b/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs index 31a48b4adcfaf..003b31c28754a 100644 --- a/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs +++ b/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs @@ -3,7 +3,7 @@ // Test an edge case in region inference: the lifetime of the borrow // of `*x` must be extended to at least 'a. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo<'a,'b>(x: &'a &'b mut isize) -> &'a isize { let y = &*x; // should be inferred to have type &'a &'b mut isize... diff --git a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs index dff36e6d183b9..d64555bfb089b 100644 --- a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs @@ -6,7 +6,7 @@ // check that the &isize here does not cause us to think that `foo` // contains region pointers -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct foo(Box); diff --git a/src/test/run-pass/regions/regions-infer-static-from-proc.rs b/src/test/run-pass/regions/regions-infer-static-from-proc.rs index 39501e2d697a3..ee707151c1e1b 100644 --- a/src/test/run-pass/regions/regions-infer-static-from-proc.rs +++ b/src/test/run-pass/regions/regions-infer-static-from-proc.rs @@ -5,7 +5,7 @@ // region variables contained within (otherwise, region inference will // give `x` a very short lifetime). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) static i: usize = 3; fn foo(_: F) {} diff --git a/src/test/run-pass/regions/regions-issue-21422.rs b/src/test/run-pass/regions/regions-issue-21422.rs index 198b714664789..9198f9644cb41 100644 --- a/src/test/run-pass/regions/regions-issue-21422.rs +++ b/src/test/run-pass/regions/regions-issue-21422.rs @@ -3,7 +3,7 @@ // add inference constraints that the operands of a binary operator // should outlive the binary operation itself. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct P<'a> { _ptr: *const &'a u8, diff --git a/src/test/run-pass/regions/regions-issue-22246.rs b/src/test/run-pass/regions/regions-issue-22246.rs index 0858833678bfa..946c95dc1ab69 100644 --- a/src/test/run-pass/regions/regions-issue-22246.rs +++ b/src/test/run-pass/regions/regions-issue-22246.rs @@ -3,7 +3,7 @@ // Regression test for issue #22246 -- we should be able to deduce // that `&'a B::Owned` implies that `B::Owned : 'a`. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs index 189f617202968..4d7bfe2938026 100644 --- a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs +++ b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs @@ -8,12 +8,12 @@ // // However, those encounters were occurring within the lexical scope // of the binding for the late-bound lifetime; that is, the late-bound -// lifetimes were perfectly valid. The core problem was that the type +// lifetimes were perfectly valid. The core problem was that the type // folding code was over-zealously passing back all lifetimes when // doing region-folding, when really all clients of the region-folding // case only want to see FREE lifetime variables, not bound ones. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/regions/regions-link-fn-args.rs b/src/test/run-pass/regions/regions-link-fn-args.rs index 231407b226ee9..afdf16a956a51 100644 --- a/src/test/run-pass/regions/regions-link-fn-args.rs +++ b/src/test/run-pass/regions/regions-link-fn-args.rs @@ -2,7 +2,7 @@ // Test that region inference correctly links up the regions when a // `ref` borrow occurs inside a fn argument. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs b/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs index cd095f6f3a4a3..6bd655cfe06f5 100644 --- a/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs +++ b/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs @@ -3,7 +3,7 @@ // Test a corner case of LUB coercion. In this case, one arm of the // match requires a deref coercion and the other doesn't, and there // is an extra `&` on the `rc`. We want to be sure that the lifetime -// assigned to this `&rc` value is not `'a` but something smaller. In +// assigned to this `&rc` value is not `'a` but something smaller. In // other words, the type from `rc` is `&'a Rc` and the type // from `&rc` should be `&'x &'a Rc`, where `'x` is something // small. diff --git a/src/test/run-pass/regions/regions-mock-codegen.rs b/src/test/run-pass/regions/regions-mock-codegen.rs index 521ef3f6a4b52..0c37bf8aa170d 100644 --- a/src/test/run-pass/regions/regions-mock-codegen.rs +++ b/src/test/run-pass/regions/regions-mock-codegen.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(allocator_api)] diff --git a/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs b/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs index aafab5d86b865..1fa6dc5e139dd 100644 --- a/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs +++ b/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker; diff --git a/src/test/run-pass/regions/regions-nullary-variant.rs b/src/test/run-pass/regions/regions-nullary-variant.rs index 82470af82faf3..d76bc07f513e4 100644 --- a/src/test/run-pass/regions/regions-nullary-variant.rs +++ b/src/test/run-pass/regions/regions-nullary-variant.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum roption<'a> { a, b(&'a usize) diff --git a/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs b/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs index 948b11e0f3023..f3dce09818231 100644 --- a/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs +++ b/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs @@ -5,7 +5,7 @@ // started out with a longer lifetime and was reassigned to a shorter // one (it should infer to be the intersection). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(x: &isize) { let a = 1; diff --git a/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs b/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs index ca52659c4db14..008f9f5bc6298 100644 --- a/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs +++ b/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs @@ -5,7 +5,7 @@ // started out with a longer lifetime and was reassigned to a shorter // one (it should infer to be the intersection). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(x: &isize) { let a = 1; diff --git a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs index f26ef85ef7234..8436e2a1e0605 100644 --- a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs @@ -1,10 +1,11 @@ // run-pass + #![allow(dead_code)] // Test that this fairly specialized, but also reasonable, pattern -// typechecks. The pattern involves regions bound in closures that +// type-checks. The pattern involves regions bound in closures that // wind up related to inference variables. // -// NB. Changes to the region implementations have broken this pattern +// N.B., changes to the region implementations have broken this pattern // a few times, but it happens to be used in the compiler so those // changes were caught. However, those uses in the compiler could // easily get changed or refactored away in the future. diff --git a/src/test/run-pass/regions/regions-scope-chain-example.rs b/src/test/run-pass/regions/regions-scope-chain-example.rs index 2beb20add32e0..e993e4ec5a2ff 100644 --- a/src/test/run-pass/regions/regions-scope-chain-example.rs +++ b/src/test/run-pass/regions/regions-scope-chain-example.rs @@ -1,4 +1,5 @@ // run-pass + #![allow(dead_code)] #![allow(unused_variables)] // This is an example where the older inference algorithm failed. The @@ -7,9 +8,9 @@ // mutual supertype of both sides of the `if` it would be faced with a // choice of tightening bounds or unifying variables and it took the // wrong path. The new algorithm avoids this problem and hence this -// example typechecks correctly. +// example type-checks correctly. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum ScopeChain<'a> { Link(Scope<'a>), diff --git a/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs b/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs index f10d5a25f1628..a5a02d0de6610 100644 --- a/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs +++ b/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs @@ -7,7 +7,7 @@ // Note: see compile-fail/variance-regions-*.rs for the tests that check that the // variance inference works in the first place. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Contravariant<'a> { f: &'a isize diff --git a/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs b/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs index 9316aa15d32a3..41124195f7bd6 100644 --- a/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs +++ b/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs @@ -9,7 +9,7 @@ // This is covariant with respect to 'a, meaning that // Covariant<'foo> <: Covariant<'static> because // 'foo <= 'static -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Covariant<'a> { f: extern "Rust" fn(&'a isize) diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index eb69ee6f886e8..35b6236621915 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -1,6 +1,6 @@ fn my_err(s: String) -> ! { println!("{}", s); panic!(); } -fn okay(i: usize) -> isize { +fn ok(i: usize) -> isize { if i == 3 { my_err("I don't like three".to_string()); } else { @@ -8,4 +8,4 @@ fn okay(i: usize) -> isize { } } -pub fn main() { okay(4); } +pub fn main() { ok(4); } diff --git a/src/test/run-pass/ret-none.rs b/src/test/run-pass/ret-none.rs index f23461faaf444..b57ffd50ae849 100644 --- a/src/test/run-pass/ret-none.rs +++ b/src/test/run-pass/ret-none.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum option { none, some(T), } diff --git a/src/test/run-pass/return-nil.rs b/src/test/run-pass/return-nil.rs index f24df197234f8..ee6dc26e2d658 100644 --- a/src/test/run-pass/return-nil.rs +++ b/src/test/run-pass/return-nil.rs @@ -1,5 +1,10 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) -fn f() { let x: () = (); return x; } +fn f() { + let x: () = (); + return x; +} -pub fn main() { let _x = f(); } +pub fn main() { + let _x = f(); +} diff --git a/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs b/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs index 3cd7234269e1d..7869414084701 100644 --- a/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs +++ b/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs @@ -7,7 +7,7 @@ extern crate structs; use structs::{NormalStruct, UnitStruct, TupleStruct}; // We only test matching here as we cannot create non-exhaustive -// structs from another crate. ie. they'll never pass in run-pass tests. +// structs from another crate; i.e., they'll never pass in run-pass tests. fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) { let NormalStruct { first_field, second_field, .. } = ns; diff --git a/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs b/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs index 251406e7604f7..2b8788b548d44 100644 --- a/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs +++ b/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs @@ -4,7 +4,7 @@ // Tests that `core` and `std` are always available. use core::iter; use std::io; -// FIXME(eddyb) Add a `meta` crate to the distribution. +// FIXME(eddyb): add a `meta` crate to the distribution. // use meta; fn main() { diff --git a/src/test/run-pass/rfcs/rfc1857-drop-order.rs b/src/test/run-pass/rfcs/rfc1857-drop-order.rs index 7923aa7c0e22f..afe1ec93384f2 100644 --- a/src/test/run-pass/rfcs/rfc1857-drop-order.rs +++ b/src/test/run-pass/rfcs/rfc1857-drop-order.rs @@ -52,7 +52,7 @@ fn test_drop_tuple() { assert_eq!(*dropped_fields.borrow(), &[1, 2]); // Panic during construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization + // Therefore, they are dropped in reverse order of initialization let dropped_fields = Rc::new(RefCell::new(Vec::new())); let cloned = AssertUnwindSafe(dropped_fields.clone()); panic::catch_unwind(|| { @@ -83,7 +83,7 @@ fn test_drop_struct() { assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); // Panic during struct construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization + // Therefore, they are dropped in reverse order of initialization let dropped_fields = Rc::new(RefCell::new(Vec::new())); let cloned = AssertUnwindSafe(dropped_fields.clone()); panic::catch_unwind(|| { @@ -138,7 +138,7 @@ fn test_drop_enum() { assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); // Panic during enum construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization + // Therefore, they are dropped in reverse order of initialization let dropped_fields = Rc::new(RefCell::new(Vec::new())); let cloned = AssertUnwindSafe(dropped_fields.clone()); panic::catch_unwind(|| { @@ -191,7 +191,7 @@ fn test_drop_list() { assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); // Panic during vec construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization + // Therefore, they are dropped in reverse order of initialization let dropped_fields = Rc::new(RefCell::new(Vec::new())); let cloned = AssertUnwindSafe(dropped_fields.clone()); panic::catch_unwind(|| { diff --git a/src/test/run-pass/self/explicit-self-closures.rs b/src/test/run-pass/self/explicit-self-closures.rs index 61be98fe3d3cd..c0fff47747dde 100644 --- a/src/test/run-pass/self/explicit-self-closures.rs +++ b/src/test/run-pass/self/explicit-self-closures.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Test to make sure that explicit self params work inside closures -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Box { x: usize diff --git a/src/test/run-pass/self/explicit_self_xcrate_exe.rs b/src/test/run-pass/self/explicit_self_xcrate_exe.rs index c3796f73ab5f7..7148d927eb308 100644 --- a/src/test/run-pass/self/explicit_self_xcrate_exe.rs +++ b/src/test/run-pass/self/explicit_self_xcrate_exe.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:explicit_self_xcrate.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate explicit_self_xcrate; use explicit_self_xcrate::{Foo, Bar}; diff --git a/src/test/run-pass/self/self-impl.rs b/src/test/run-pass/self/self-impl.rs index 23d513e3fac07..694680ab3730f 100644 --- a/src/test/run-pass/self/self-impl.rs +++ b/src/test/run-pass/self/self-impl.rs @@ -3,7 +3,7 @@ #![allow(unused_variables)] // Test that we can use `Self` types in impls in the expected way. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/self/self-type-param.rs b/src/test/run-pass/self/self-type-param.rs index 6deae5f2d12f4..23a53a3d4bdf8 100644 --- a/src/test/run-pass/self/self-type-param.rs +++ b/src/test/run-pass/self/self-type-param.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait MyTrait { fn f(&self) -> Self; diff --git a/src/test/run-pass/self/where-for-self.rs b/src/test/run-pass/self/where-for-self.rs index 76c592dc49b72..6dc7c3163cf3a 100644 --- a/src/test/run-pass/self/where-for-self.rs +++ b/src/test/run-pass/self/where-for-self.rs @@ -1,7 +1,7 @@ // run-pass -// Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. +// Test that we can quantify lifetimes outside a constraint (i.e., including +// the self type) in a where-clause. static mut COUNT: u32 = 1; diff --git a/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs b/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs index 96bcc260bdf5c..cf31685ca7443 100644 --- a/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs +++ b/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs @@ -6,7 +6,7 @@ // Test references to items that haven't been codegened yet. // Generate some code in the first compilation unit before declaring any -// modules. This ensures that the first module doesn't go into the same +// modules. This ensures that the first module doesn't go into the same // compilation unit as the top-level module. fn pad() -> usize { 0 } diff --git a/src/test/run-pass/sepcomp/sepcomp-fns.rs b/src/test/run-pass/sepcomp/sepcomp-fns.rs index c4ea17225b44e..c2cdee36a78ab 100644 --- a/src/test/run-pass/sepcomp/sepcomp-fns.rs +++ b/src/test/run-pass/sepcomp/sepcomp-fns.rs @@ -2,12 +2,12 @@ // ignore-bitrig // compile-flags: -C codegen-units=3 -// Test basic separate compilation functionality. The functions should be able +// Test basic separate compilation functionality. The functions should be able // to call each other even though they will be placed in different compilation // units. // Generate some code in the first compilation unit before declaring any -// modules. This ensures that the first module doesn't go into the same +// modules. This ensures that the first module doesn't go into the same // compilation unit as the top-level module. fn one() -> usize { 1 } diff --git a/src/test/run-pass/sepcomp/sepcomp-statics.rs b/src/test/run-pass/sepcomp/sepcomp-statics.rs index e0c6b268b177c..38130c695549e 100644 --- a/src/test/run-pass/sepcomp/sepcomp-statics.rs +++ b/src/test/run-pass/sepcomp/sepcomp-statics.rs @@ -12,7 +12,7 @@ const ONE: usize = 1; mod b { // Separate compilation always switches to the LLVM module with the fewest - // instructions. Make sure we have some instructions in this module so + // instructions. Make sure we have some instructions in this module so // that `a` and `b` don't go into the same compilation unit. fn pad() -> usize { 0 } diff --git a/src/test/run-pass/sepcomp/sepcomp-unwind.rs b/src/test/run-pass/sepcomp/sepcomp-unwind.rs index 01dbea08098bd..dc1d69c6f3a83 100644 --- a/src/test/run-pass/sepcomp/sepcomp-unwind.rs +++ b/src/test/run-pass/sepcomp/sepcomp-unwind.rs @@ -8,7 +8,7 @@ // According to acrichto, in the distant past `ld -r` (which is used during // linking when codegen-units > 1) was known to produce object files with -// damaged unwinding tables. This may be related to GNU binutils bug #6893 +// damaged unwinding tables. This may be related to GNU binutils bug #6893 // ("Partial linking results in corrupt .eh_frame_hdr"), but I'm not certain. // In any case, this test should let us know if enabling parallel codegen ever // breaks unwinding. diff --git a/src/test/run-pass/simd/simd-generics.rs b/src/test/run-pass/simd/simd-generics.rs index ab6caee9d7bce..7369ef2999d1f 100644 --- a/src/test/run-pass/simd/simd-generics.rs +++ b/src/test/run-pass/simd/simd-generics.rs @@ -15,7 +15,7 @@ extern "platform-intrinsic" { fn simd_add(x: T, y: T) -> T; } -fn add>(lhs: T, rhs: T) -> T { +fn add>(lhs: T, rhs: T) -> T { lhs + rhs } diff --git a/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs b/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs index 350bc434935b3..4a8eb1793bf85 100644 --- a/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs +++ b/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs @@ -24,7 +24,7 @@ fn main() { #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] let nan = ::std::f32::NAN; // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit. - // See https://github.com/rust-lang/rust/issues/52746. + // See issue #52746. #[cfg(any(target_arch = "mips", target_arch = "mips64"))] let nan = f32::from_bits(::std::f32::NAN.to_bits() - 1); diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs b/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs index b67c0ad1eb2f1..e8a87359f0b39 100644 --- a/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs +++ b/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs @@ -1,10 +1,10 @@ // run-pass -#![allow(non_camel_case_types)] - -// ignore-emscripten FIXME(#45351) hits an LLVM assert +// ignore-emscripten FIXME(#45351): hits an LLVM assert. #![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + #[repr(simd)] #[derive(Copy, Clone)] struct i32x4(pub i32, pub i32, pub i32, pub i32); diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs b/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs index 15f232e2c0f70..185060aa18729 100644 --- a/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs +++ b/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_must_use)] -// ignore-emscripten FIXME(#45351) hits an LLVM assert +// ignore-emscripten FIXME(#45351): hits an LLVM assert. #![feature(repr_simd, platform_intrinsics, concat_idents, test)] #![allow(non_camel_case_types)] diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs b/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs index 2b593e1c9b804..b180fe228c084 100644 --- a/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs +++ b/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten FIXME(#45351) hits an LLVM assert +// ignore-emscripten FIXME(#45351): hits an LLVM assert #![feature(repr_simd, platform_intrinsics, concat_idents)] #![allow(non_camel_case_types)] @@ -30,7 +30,7 @@ macro_rules! cmp { let lhs = $lhs; let rhs = $rhs; let e: u32x4 = concat_idents!(simd_, $method)($lhs, $rhs); - // assume the scalar version is correct/the behaviour we want. + // Assume the scalar version is correct/the behaviour we want. assert!((e.0 != 0) == lhs.0 .$method(&rhs.0)); assert!((e.1 != 0) == lhs.1 .$method(&rhs.1)); assert!((e.2 != 0) == lhs.2 .$method(&rhs.2)); @@ -44,7 +44,7 @@ macro_rules! tests { cmp!(eq($lhs, $rhs)); cmp!(ne($lhs, $rhs)); - // test both directions + // Test both directions. cmp!(lt($lhs, $rhs)); cmp!(lt($rhs, $lhs)); @@ -61,8 +61,8 @@ macro_rules! tests { }} } fn main() { - // 13 vs. -100 tests that we get signed vs. unsigned comparisons - // correct (i32: 13 > -100, u32: 13 < -100). let i1 = i32x4(10, -11, 12, 13); + // 13 vs. -100 tests that we get signed vs. unsigned comparisons. + // Correct: (`i32: 13 > -100`, `u32: 13 < -100`). let i1 = i32x4(10, -11, 12, 13); let i2 = i32x4(5, -5, 20, -100); let i3 = i32x4(10, -11, 20, -100); diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs b/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs index ea3d4b1894416..74d64756252f4 100644 --- a/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs +++ b/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten FIXME(#45351) hits an LLVM assert +// ignore-emscripten FIXME(#45351): hits an LLVM assert. #![feature(repr_simd, platform_intrinsics)] diff --git a/src/test/run-pass/simd/simd-type.rs b/src/test/run-pass/simd/simd-type.rs index e7b9bfe32f8df..ebfc7b7ec36ef 100644 --- a/src/test/run-pass/simd/simd-type.rs +++ b/src/test/run-pass/simd/simd-type.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(repr_simd)] diff --git a/src/test/run-pass/sized-borrowed-pointer.rs b/src/test/run-pass/sized-borrowed-pointer.rs index e5d55761539a4..b8b7c146c0c2e 100644 --- a/src/test/run-pass/sized-borrowed-pointer.rs +++ b/src/test/run-pass/sized-borrowed-pointer.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // Possibly-dynamic size of typaram should be cleared at pointer boundary. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn bar() { } fn foo() { bar::<&T>() } diff --git a/src/test/run-pass/sized-owned-pointer.rs b/src/test/run-pass/sized-owned-pointer.rs index 8dd3227ba8875..331dbb6819b32 100644 --- a/src/test/run-pass/sized-owned-pointer.rs +++ b/src/test/run-pass/sized-owned-pointer.rs @@ -2,7 +2,7 @@ // Possibly-dynamic size of typaram should be cleared at pointer boundary. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn bar() { } fn foo() { bar::>() } diff --git a/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs b/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs index 2e32e3ff02d3e..e165711beacbc 100644 --- a/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs +++ b/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs @@ -17,13 +17,13 @@ impl<'a> WithAssoc for &'a () { struct Cloned(I); impl<'a, I, T: 'a> Iterator for Cloned - where I: WithAssoc, T: Clone + where I: WithAssoc, T: Clone { fn next(&self) {} } impl<'a, I, T: 'a> Iterator for Cloned - where I: WithAssoc, T: Copy + where I: WithAssoc, T: Copy { } diff --git a/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs b/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs index bdc6501df44b8..96fc5e85991f4 100644 --- a/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs +++ b/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs @@ -14,7 +14,7 @@ trait WithAssoc { fn as_item(&self) -> &Self::Item; } -impl Trait for T where T: WithAssoc, U: Clone { +impl Trait for T where T: WithAssoc, U: Clone { fn convert(&self) -> U { self.as_item().clone() } diff --git a/src/test/run-pass/specialization/specialization-translate-projections.rs b/src/test/run-pass/specialization/specialization-translate-projections.rs index fcccb67902e58..a4049b36f894d 100644 --- a/src/test/run-pass/specialization/specialization-translate-projections.rs +++ b/src/test/run-pass/specialization/specialization-translate-projections.rs @@ -15,7 +15,7 @@ trait WithAssoc { fn to_item(&self) -> Self::Item; } -impl Trait for T where T: WithAssoc, U: Into { +impl Trait for T where T: WithAssoc, U: Into { fn to_u8(&self) -> u8 { self.to_item().into() } diff --git a/src/test/run-pass/stack-probes-lto.rs b/src/test/run-pass/stack-probes-lto.rs index 2705950b01424..5f9262b6df9b0 100644 --- a/src/test/run-pass/stack-probes-lto.rs +++ b/src/test/run-pass/stack-probes-lto.rs @@ -9,7 +9,7 @@ // ignore-wasm // ignore-cloudabi no processes // ignore-emscripten no processes -// ignore-musl FIXME #31506 +// ignore-musl FIXME(#31506) // ignore-pretty // compile-flags: -C lto // no-prefer-dynamic diff --git a/src/test/run-pass/stack-probes.rs b/src/test/run-pass/stack-probes.rs index ff264421cfbcf..1bb6d8dd1612f 100644 --- a/src/test/run-pass/stack-probes.rs +++ b/src/test/run-pass/stack-probes.rs @@ -9,7 +9,7 @@ // ignore-wasm // ignore-cloudabi no processes // ignore-emscripten no processes -// ignore-musl FIXME #31506 +// ignore-musl FIXME(#31506) use std::mem; use std::process::Command; diff --git a/src/test/run-pass/statics/static-fn-inline-xc.rs b/src/test/run-pass/statics/static-fn-inline-xc.rs index a400b9c8d5662..242929db9b35f 100644 --- a/src/test/run-pass/statics/static-fn-inline-xc.rs +++ b/src/test/run-pass/statics/static-fn-inline-xc.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:static_fn_inline_xc_aux.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate static_fn_inline_xc_aux as mycore; diff --git a/src/test/run-pass/statics/static-fn-trait-xc.rs b/src/test/run-pass/statics/static-fn-trait-xc.rs index 1d3126128c92b..b93105ad3261d 100644 --- a/src/test/run-pass/statics/static-fn-trait-xc.rs +++ b/src/test/run-pass/statics/static-fn-trait-xc.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:static_fn_trait_xc_aux.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate static_fn_trait_xc_aux as mycore; diff --git a/src/test/run-pass/statics/static-methods-in-traits2.rs b/src/test/run-pass/statics/static-methods-in-traits2.rs index 2c43ff6a788cc..f735ad9a753be 100644 --- a/src/test/run-pass/statics/static-methods-in-traits2.rs +++ b/src/test/run-pass/statics/static-methods-in-traits2.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Number: NumConv { fn from(n: T) -> Self; diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait.rs b/src/test/run-pass/structs-enums/class-cast-to-trait.rs index 7fa60da6e5762..2f22ecee0bbc1 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait.rs @@ -3,7 +3,7 @@ #![allow(unused_mut)] #![allow(non_camel_case_types)] -// ignore-freebsd FIXME fails on BSD +// ignore-freebsd FIXME: fails on BSD trait noisy { diff --git a/src/test/run-pass/structs-enums/class-dtor.rs b/src/test/run-pass/structs-enums/class-dtor.rs index ee1cac03c81e8..93f2584fdfe38 100644 --- a/src/test/run-pass/structs-enums/class-dtor.rs +++ b/src/test/run-pass/structs-enums/class-dtor.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct cat { done : extern fn(usize), diff --git a/src/test/run-pass/structs-enums/class-str-field.rs b/src/test/run-pass/structs-enums/class-str-field.rs index a3dc66aab129f..b4e0b16fa85fd 100644 --- a/src/test/run-pass/structs-enums/class-str-field.rs +++ b/src/test/run-pass/structs-enums/class-str-field.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct cat { diff --git a/src/test/run-pass/structs-enums/class-typarams.rs b/src/test/run-pass/structs-enums/class-typarams.rs index 4b2d4b12ec9cd..434db33dd7574 100644 --- a/src/test/run-pass/structs-enums/class-typarams.rs +++ b/src/test/run-pass/structs-enums/class-typarams.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::PhantomData; diff --git a/src/test/run-pass/structs-enums/classes-self-referential.rs b/src/test/run-pass/structs-enums/classes-self-referential.rs index 27d6ebf2c2a39..3391157a7ede3 100644 --- a/src/test/run-pass/structs-enums/classes-self-referential.rs +++ b/src/test/run-pass/structs-enums/classes-self-referential.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct kitten { cat: Option, diff --git a/src/test/run-pass/structs-enums/discrim-explicit-23030.rs b/src/test/run-pass/structs-enums/discrim-explicit-23030.rs index 211ca7e4e8feb..cab5782182e31 100644 --- a/src/test/run-pass/structs-enums/discrim-explicit-23030.rs +++ b/src/test/run-pass/structs-enums/discrim-explicit-23030.rs @@ -1,5 +1,5 @@ // run-pass -// Issue 23030: Workaround overflowing discriminant +// Issue #23030: Workaround overflowing discriminant // with explicit assignments. // See also compile-fail/overflow-discrim.rs, which shows what diff --git a/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs b/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs index 9c4c61e684b9c..496154bb125cb 100644 --- a/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs +++ b/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs @@ -1,7 +1,7 @@ // run-pass #![allow(overflowing_literals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub enum E64 { H64 = 0x7FFF_FFFF_FFFF_FFFF, diff --git a/src/test/run-pass/structs-enums/enum-export-inheritance.rs b/src/test/run-pass/structs-enums/enum-export-inheritance.rs index 6a36a004a7c94..703a92417c057 100644 --- a/src/test/run-pass/structs-enums/enum-export-inheritance.rs +++ b/src/test/run-pass/structs-enums/enum-export-inheritance.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod a { pub enum Foo { diff --git a/src/test/run-pass/structs-enums/enum-layout-optimization.rs b/src/test/run-pass/structs-enums/enum-layout-optimization.rs index 05d297906c317..1904d794bf107 100644 --- a/src/test/run-pass/structs-enums/enum-layout-optimization.rs +++ b/src/test/run-pass/structs-enums/enum-layout-optimization.rs @@ -1,6 +1,6 @@ // run-pass // Test that we will do various size optimizations to enum layout, but -// *not* if `#[repr(u8)]` or `#[repr(C)]` is passed. See also #40029. +// **not** if `#[repr(u8)]` or `#[repr(C)]` is passed. See also #40029. #![allow(dead_code)] diff --git a/src/test/run-pass/structs-enums/enum-variants.rs b/src/test/run-pass/structs-enums/enum-variants.rs index 9ac5aae726a00..4e2a92afb624e 100644 --- a/src/test/run-pass/structs-enums/enum-variants.rs +++ b/src/test/run-pass/structs-enums/enum-variants.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_assignments)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] diff --git a/src/test/run-pass/structs-enums/enum-vec-initializer.rs b/src/test/run-pass/structs-enums/enum-vec-initializer.rs index 42ee8ba971ebd..b52aa7d58f09b 100644 --- a/src/test/run-pass/structs-enums/enum-vec-initializer.rs +++ b/src/test/run-pass/structs-enums/enum-vec-initializer.rs @@ -1,5 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 + +// pretty-expanded FIXME(#23616) enum Flopsy { Bunny = 2 @@ -9,9 +10,9 @@ const BAR:usize = Flopsy::Bunny as usize; const BAR2:usize = BAR; pub fn main() { - let _v = [0; Flopsy::Bunny as usize]; - let _v = [0; BAR]; - let _v = [0; BAR2]; - const BAR3:usize = BAR2; - let _v = [0; BAR3]; + let _v = [0; Flopsy::Bunny as usize]; + let _v = [0; BAR]; + let _v = [0; BAR2]; + const BAR3: usize = BAR2; + let _v = [0; BAR3]; } diff --git a/src/test/run-pass/structs-enums/export-abstract-tag.rs b/src/test/run-pass/structs-enums/export-abstract-tag.rs index 76ac73321d3cb..303cf55439bc3 100644 --- a/src/test/run-pass/structs-enums/export-abstract-tag.rs +++ b/src/test/run-pass/structs-enums/export-abstract-tag.rs @@ -4,7 +4,7 @@ // We can export tags without exporting the variants to create a simple // sort of ADT. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub enum t { t1, } diff --git a/src/test/run-pass/structs-enums/export-tag-variant.rs b/src/test/run-pass/structs-enums/export-tag-variant.rs index 52e0aba0979a6..925efe784bbaa 100644 --- a/src/test/run-pass/structs-enums/export-tag-variant.rs +++ b/src/test/run-pass/structs-enums/export-tag-variant.rs @@ -1,6 +1,6 @@ // run-pass #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub enum t { t1, } diff --git a/src/test/run-pass/structs-enums/foreign-struct.rs b/src/test/run-pass/structs-enums/foreign-struct.rs index ce02c8fb5c3a5..65413a14de3b1 100644 --- a/src/test/run-pass/structs-enums/foreign-struct.rs +++ b/src/test/run-pass/structs-enums/foreign-struct.rs @@ -4,7 +4,7 @@ // Passing enums by value -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub enum void { } diff --git a/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs b/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs index 57be37cdf2bbc..f1b56aab94c56 100644 --- a/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs +++ b/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m { pub struct S { diff --git a/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs b/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs index 30cf645821d20..519e5df8310fa 100644 --- a/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs +++ b/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs @@ -3,7 +3,7 @@ // aux-build:namespaced_enum_emulate_flat.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate namespaced_enum_emulate_flat; diff --git a/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs b/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs index f6c395059ede5..6406952d36d68 100644 --- a/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs +++ b/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub use Foo::*; use nest::{Bar, D, E, F}; diff --git a/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs b/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs index d2ccadea00778..73c077ed5975c 100644 --- a/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs +++ b/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:namespaced_enums.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate namespaced_enums; diff --git a/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs b/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs index f36ac69dc0886..f7631e7c1a117 100644 --- a/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs +++ b/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod m2 { pub enum Foo { diff --git a/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs b/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs index 5e10c3ec1d0f8..8749bb0e98431 100644 --- a/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs +++ b/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:namespaced_enums.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate namespaced_enums; diff --git a/src/test/run-pass/structs-enums/namespaced-enums.rs b/src/test/run-pass/structs-enums/namespaced-enums.rs index 6a2602501a541..bb87eaffb1cf0 100644 --- a/src/test/run-pass/structs-enums/namespaced-enums.rs +++ b/src/test/run-pass/structs-enums/namespaced-enums.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Foo { A, diff --git a/src/test/run-pass/structs-enums/nested-enum-same-names.rs b/src/test/run-pass/structs-enums/nested-enum-same-names.rs index dece3dcd54b2f..b70c500af4dff 100644 --- a/src/test/run-pass/structs-enums/nested-enum-same-names.rs +++ b/src/test/run-pass/structs-enums/nested-enum-same-names.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* diff --git a/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs b/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs index f73b492dfcfc1..8c51e375b5383 100644 --- a/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs +++ b/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_unsafe)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Fd(u32); diff --git a/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs b/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs index 40837321be2c3..7b25b6c53b9fa 100644 --- a/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs +++ b/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:newtype_struct_xc.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate newtype_struct_xc; use newtype_struct_xc::Au; diff --git a/src/test/run-pass/structs-enums/newtype-struct-xc.rs b/src/test/run-pass/structs-enums/newtype-struct-xc.rs index 0c6466d97fc94..80b5739fc7d45 100644 --- a/src/test/run-pass/structs-enums/newtype-struct-xc.rs +++ b/src/test/run-pass/structs-enums/newtype-struct-xc.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:newtype_struct_xc.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate newtype_struct_xc; diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs index 0a48725cbe44a..5cbeaba863b65 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs @@ -2,7 +2,7 @@ // Test that the lifetime of the enclosing `&` is used for the object // lifetime bound. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs index 48ee5a2ed5450..c18b1a6a004f5 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs @@ -2,7 +2,7 @@ // Test that the lifetime from the enclosing `&` is "inherited" // through the `MyBox` struct. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/structs-enums/simple-generic-tag.rs b/src/test/run-pass/structs-enums/simple-generic-tag.rs index dbd2834d46857..a34316684ce12 100644 --- a/src/test/run-pass/structs-enums/simple-generic-tag.rs +++ b/src/test/run-pass/structs-enums/simple-generic-tag.rs @@ -4,7 +4,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum clam { a(T), } diff --git a/src/test/run-pass/structs-enums/struct-like-variant-construct.rs b/src/test/run-pass/structs-enums/struct-like-variant-construct.rs index 60fc7ce394c05..62b9d5f24dbfd 100644 --- a/src/test/run-pass/structs-enums/struct-like-variant-construct.rs +++ b/src/test/run-pass/structs-enums/struct-like-variant-construct.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Foo { Bar { diff --git a/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs b/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs index 7896c829a6e1f..f482b91e02244 100644 --- a/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs +++ b/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub enum Foo { diff --git a/src/test/run-pass/structs-enums/struct_variant_xc.rs b/src/test/run-pass/structs-enums/struct_variant_xc.rs index 9c8d1a69a3e9e..4e9c4eb715334 100644 --- a/src/test/run-pass/structs-enums/struct_variant_xc.rs +++ b/src/test/run-pass/structs-enums/struct_variant_xc.rs @@ -1,6 +1,6 @@ // run-pass // aux-build:struct_variant_xc_aux.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate struct_variant_xc_aux; diff --git a/src/test/run-pass/structs-enums/tag-exports.rs b/src/test/run-pass/structs-enums/tag-exports.rs index 1bcb7d35da38a..491534cfbb801 100644 --- a/src/test/run-pass/structs-enums/tag-exports.rs +++ b/src/test/run-pass/structs-enums/tag-exports.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use alder::*; diff --git a/src/test/run-pass/structs-enums/tag-in-block.rs b/src/test/run-pass/structs-enums/tag-in-block.rs index 03d4dd9b0abcd..18dfb7003b5a4 100644 --- a/src/test/run-pass/structs-enums/tag-in-block.rs +++ b/src/test/run-pass/structs-enums/tag-in-block.rs @@ -4,7 +4,7 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo() { fn zed(_z: bar) { } diff --git a/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs b/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs index 3f59db383107d..228709b3d1729 100644 --- a/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs +++ b/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum color { red = 1, diff --git a/src/test/run-pass/structs-enums/tuple-struct-trivial.rs b/src/test/run-pass/structs-enums/tuple-struct-trivial.rs index c8651fd29dedf..d7f48a04a1ac2 100644 --- a/src/test/run-pass/structs-enums/tuple-struct-trivial.rs +++ b/src/test/run-pass/structs-enums/tuple-struct-trivial.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo(isize, isize, isize); diff --git a/src/test/run-pass/structs-enums/variant-structs-trivial.rs b/src/test/run-pass/structs-enums/variant-structs-trivial.rs index 31fa610a69d95..01db47950c4c1 100644 --- a/src/test/run-pass/structs-enums/variant-structs-trivial.rs +++ b/src/test/run-pass/structs-enums/variant-structs-trivial.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum Foo { Bar { x: isize }, diff --git a/src/test/run-pass/super-fast-paren-parsing.rs b/src/test/run-pass/super-fast-paren-parsing.rs index c86f2b8f9c3b8..04353c62f5252 100644 --- a/src/test/run-pass/super-fast-paren-parsing.rs +++ b/src/test/run-pass/super-fast-paren-parsing.rs @@ -3,7 +3,7 @@ // exec-env:RUST_MIN_STACK=16000000 // rustc-env:RUST_MIN_STACK=16000000 // -// Big stack is needed for pretty printing, a little sad... +// Big stack is needed for pretty-printing, a little sad... static a: isize = ((((((((((((((((((((((((((((((((((((((((((((((((((( diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs index e378aac8be413..9a2bb6efa813f 100644 --- a/src/test/run-pass/super.rs +++ b/src/test/run-pass/super.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod a { pub fn f() {} diff --git a/src/test/run-pass/svh-add-nothing.rs b/src/test/run-pass/svh-add-nothing.rs index b673fa55e3817..594f9d877c02c 100644 --- a/src/test/run-pass/svh-add-nothing.rs +++ b/src/test/run-pass/svh-add-nothing.rs @@ -3,7 +3,7 @@ // aux-build:svh-b.rs // aux-build:svh-a-base.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate a; extern crate b; diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs index 31fd9ce7d1a49..80c382808cbd8 100644 --- a/src/test/run-pass/swap-overlapping.rs +++ b/src/test/run-pass/swap-overlapping.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ptr; diff --git a/src/test/run-pass/tail-call-arg-leak.rs b/src/test/run-pass/tail-call-arg-leak.rs index 53ec5ea7ff7ba..fb75cecf370e2 100644 --- a/src/test/run-pass/tail-call-arg-leak.rs +++ b/src/test/run-pass/tail-call-arg-leak.rs @@ -1,5 +1,5 @@ // use of tail calls causes arg slot leaks, issue #160. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn inner(dummy: String, b: bool) { if b { return inner(dummy, false); } } diff --git a/src/test/run-pass/threads-sendsync/send-resource.rs b/src/test/run-pass/threads-sendsync/send-resource.rs index 023a84d6b6ec0..fac05ead974c3 100644 --- a/src/test/run-pass/threads-sendsync/send-resource.rs +++ b/src/test/run-pass/threads-sendsync/send-resource.rs @@ -3,7 +3,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads support use std::thread; diff --git a/src/test/run-pass/threads-sendsync/send-type-inference.rs b/src/test/run-pass/threads-sendsync/send-type-inference.rs index 0d9af7512b466..385a61bbaa4be 100644 --- a/src/test/run-pass/threads-sendsync/send-type-inference.rs +++ b/src/test/run-pass/threads-sendsync/send-type-inference.rs @@ -2,7 +2,7 @@ #![allow(unused_must_use)] #![allow(dead_code)] #![allow(unused_mut)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync::mpsc::{channel, Sender}; diff --git a/src/test/run-pass/threads-sendsync/sendable-class.rs b/src/test/run-pass/threads-sendsync/sendable-class.rs index 7facf245bde42..c60a227ae0aa4 100644 --- a/src/test/run-pass/threads-sendsync/sendable-class.rs +++ b/src/test/run-pass/threads-sendsync/sendable-class.rs @@ -6,7 +6,7 @@ // Test that a class with only sendable fields can be sent -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync::mpsc::channel; diff --git a/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs b/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs index bc64c8162433b..a5285bc06e25a 100644 --- a/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs +++ b/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync; diff --git a/src/test/run-pass/threads-sendsync/sync-send-atomics.rs b/src/test/run-pass/threads-sendsync/sync-send-atomics.rs index 0466f4f0e9ddc..47c6cb0e19534 100644 --- a/src/test/run-pass/threads-sendsync/sync-send-atomics.rs +++ b/src/test/run-pass/threads-sendsync/sync-send-atomics.rs @@ -1,6 +1,6 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync::atomic::*; diff --git a/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs b/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs index 44beb9dc1e534..28a15a03fb844 100644 --- a/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs +++ b/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(warnings)] diff --git a/src/test/run-pass/threads-sendsync/task-comm-11.rs b/src/test/run-pass/threads-sendsync/task-comm-11.rs index 8541e143fb976..cc16a0c6f673d 100644 --- a/src/test/run-pass/threads-sendsync/task-comm-11.rs +++ b/src/test/run-pass/threads-sendsync/task-comm-11.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_must_use)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-emscripten no threads support use std::sync::mpsc::{channel, Sender}; diff --git a/src/test/run-pass/threads-sendsync/task-comm-15.rs b/src/test/run-pass/threads-sendsync/task-comm-15.rs index adb14abdce9df..d187c8658dd33 100644 --- a/src/test/run-pass/threads-sendsync/task-comm-15.rs +++ b/src/test/run-pass/threads-sendsync/task-comm-15.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_must_use)] // ignore-emscripten no threads support -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::sync::mpsc::{channel, Sender}; use std::thread; diff --git a/src/test/run-pass/threads-sendsync/task-comm-17.rs b/src/test/run-pass/threads-sendsync/task-comm-17.rs index 7224978709371..fbccea0940994 100644 --- a/src/test/run-pass/threads-sendsync/task-comm-17.rs +++ b/src/test/run-pass/threads-sendsync/task-comm-17.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_must_use)] // ignore-emscripten no threads support -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // Issue #922 diff --git a/src/test/run-pass/threads-sendsync/task-life-0.rs b/src/test/run-pass/threads-sendsync/task-life-0.rs index 785cff9a0f304..2b9e78411cd13 100644 --- a/src/test/run-pass/threads-sendsync/task-life-0.rs +++ b/src/test/run-pass/threads-sendsync/task-life-0.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_must_use)] // ignore-emscripten no threads support -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::thread; diff --git a/src/test/run-pass/trailing-comma.rs b/src/test/run-pass/trailing-comma.rs index 197af295a42c7..30705334a585e 100644 --- a/src/test/run-pass/trailing-comma.rs +++ b/src/test/run-pass/trailing-comma.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(slice_patterns)] diff --git a/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs b/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs index cc8f9dc519084..f868d3be0ebcd 100644 --- a/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs +++ b/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs @@ -4,7 +4,7 @@ // carries a predicate that references the trait (`u32 : Trait1`, // substituted). -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs index a25704412262d..311036dac0d25 100644 --- a/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs @@ -1,7 +1,7 @@ use std::cmp::PartialEq; use std::ops::{Add, Sub, Mul}; -pub trait MyNum : Add + Sub + Mul + PartialEq + Clone { +pub trait MyNum : Add + Sub + Mul + PartialEq + Clone { } #[derive(Clone, Debug)] diff --git a/src/test/run-pass/traits/cycle-trait-type-trait.rs b/src/test/run-pass/traits/cycle-trait-type-trait.rs index c62d01403c7f8..4dcba3c4c0e98 100644 --- a/src/test/run-pass/traits/cycle-trait-type-trait.rs +++ b/src/test/run-pass/traits/cycle-trait-type-trait.rs @@ -3,7 +3,7 @@ // Test a case where a supertrait references a type that references // the original trait. This poses no problem at the moment. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Chromosome: Get> { } diff --git a/src/test/run-pass/traits/impl-implicit-trait.rs b/src/test/run-pass/traits/impl-implicit-trait.rs index fac2bcce2481b..d2bb3ba9e1122 100644 --- a/src/test/run-pass/traits/impl-implicit-trait.rs +++ b/src/test/run-pass/traits/impl-implicit-trait.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum option_ { none_, diff --git a/src/test/run-pass/traits/multiple-trait-bounds.rs b/src/test/run-pass/traits/multiple-trait-bounds.rs index 868b334070bdd..9d43d1857a99d 100644 --- a/src/test/run-pass/traits/multiple-trait-bounds.rs +++ b/src/test/run-pass/traits/multiple-trait-bounds.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(_: T) { } diff --git a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs index b1339b207ebae..840fecb6a17ce 100644 --- a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/traits/supertrait-default-generics.rs b/src/test/run-pass/traits/supertrait-default-generics.rs index e862c0e976b31..9760d0c154f25 100644 --- a/src/test/run-pass/traits/supertrait-default-generics.rs +++ b/src/test/run-pass/traits/supertrait-default-generics.rs @@ -12,7 +12,7 @@ trait Positioned { fn X(&self) -> S; } -trait Movable>: Positioned { +trait Movable>: Positioned { fn translate(&mut self, dx: S) { let x = self.X() + dx; self.SetX(x); @@ -30,7 +30,7 @@ impl Positioned for Point { } } -impl> Movable for Point {} +impl> Movable for Point {} pub fn main() { let mut p = Point{ x: 1, y: 2}; diff --git a/src/test/run-pass/traits/syntax-trait-polarity.rs b/src/test/run-pass/traits/syntax-trait-polarity.rs index c6524f5c8e782..1fd5bdd6d222e 100644 --- a/src/test/run-pass/traits/syntax-trait-polarity.rs +++ b/src/test/run-pass/traits/syntax-trait-polarity.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(optin_builtin_traits)] diff --git a/src/test/run-pass/traits/trait-bounds-basic.rs b/src/test/run-pass/traits/trait-bounds-basic.rs index af6392e565859..a3a3afa5a9d13 100644 --- a/src/test/run-pass/traits/trait-bounds-basic.rs +++ b/src/test/run-pass/traits/trait-bounds-basic.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unconditional_recursion)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { } diff --git a/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs b/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs index de6c2afa2bbe1..802f582783f86 100644 --- a/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs +++ b/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs @@ -3,7 +3,7 @@ // trait exactly, as long as the implementation doesn't demand *more* bounds // than the trait. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn foo(&self); diff --git a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs index 18b25b852d173..d0ef597812086 100644 --- a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs +++ b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait U {} trait T { fn get(self) -> X; } diff --git a/src/test/run-pass/traits/trait-bounds-recursion.rs b/src/test/run-pass/traits/trait-bounds-recursion.rs index 0023ff654e84c..bc9ebdaf02e24 100644 --- a/src/test/run-pass/traits/trait-bounds-recursion.rs +++ b/src/test/run-pass/traits/trait-bounds-recursion.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait I { fn i(&self) -> Self; } diff --git a/src/test/run-pass/traits/trait-cache-issue-18209.rs b/src/test/run-pass/traits/trait-cache-issue-18209.rs index 15676e4554aeb..a4a869aef7618 100644 --- a/src/test/run-pass/traits/trait-cache-issue-18209.rs +++ b/src/test/run-pass/traits/trait-cache-issue-18209.rs @@ -4,7 +4,7 @@ // // See issue #18209. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Foo { fn load_from() -> Box; diff --git a/src/test/run-pass/traits/trait-composition-trivial.rs b/src/test/run-pass/traits/trait-composition-trivial.rs index 90e5dcd68e8c4..45dfe7791264a 100644 --- a/src/test/run-pass/traits/trait-composition-trivial.rs +++ b/src/test/run-pass/traits/trait-composition-trivial.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { fn foo(&self); diff --git a/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs b/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs index 3413db6a6845b..55b35807a4eed 100644 --- a/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs +++ b/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs @@ -1,10 +1,10 @@ // run-pass +// pretty-expanded FIXME(#23616) + // Test that we do not error out because of a (False) ambiguity -// between the builtin rules for Sized and the where clause. Issue +// between the builtin rules for Sized and the where-clause. Issue // #20959. -// pretty-expanded FIXME #23616 - fn foo(x: Option) where Option : Sized { diff --git a/src/test/run-pass/traits/trait-impl-2.rs b/src/test/run-pass/traits/trait-impl-2.rs index b28d74a7b35b1..6e72ee5553a7d 100644 --- a/src/test/run-pass/traits/trait-impl-2.rs +++ b/src/test/run-pass/traits/trait-impl-2.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_snake_case)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod Foo { pub trait Trait { diff --git a/src/test/run-pass/traits/trait-inheritance-num.rs b/src/test/run-pass/traits/trait-inheritance-num.rs index 3d63d78cabb45..7808e40d1832e 100644 --- a/src/test/run-pass/traits/trait-inheritance-num.rs +++ b/src/test/run-pass/traits/trait-inheritance-num.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait NumExt: PartialEq + PartialOrd {} diff --git a/src/test/run-pass/traits/trait-inheritance-num0.rs b/src/test/run-pass/traits/trait-inheritance-num0.rs index cee52542d38d2..30dbe0179c062 100644 --- a/src/test/run-pass/traits/trait-inheritance-num0.rs +++ b/src/test/run-pass/traits/trait-inheritance-num0.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Extending Num and using inherited static methods -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::cmp::PartialOrd; diff --git a/src/test/run-pass/traits/trait-inheritance-num1.rs b/src/test/run-pass/traits/trait-inheritance-num1.rs index 663dd3a5eafdb..58c58b4a5ad96 100644 --- a/src/test/run-pass/traits/trait-inheritance-num1.rs +++ b/src/test/run-pass/traits/trait-inheritance-num1.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait NumCast: Sized { fn from(i: i32) -> Option; diff --git a/src/test/run-pass/traits/trait-inheritance-num5.rs b/src/test/run-pass/traits/trait-inheritance-num5.rs index f478618f7b593..b9c10442f4d6e 100644 --- a/src/test/run-pass/traits/trait-inheritance-num5.rs +++ b/src/test/run-pass/traits/trait-inheritance-num5.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait NumCast: Sized { fn from(i: i32) -> Option; diff --git a/src/test/run-pass/traits/trait-inheritance-overloading.rs b/src/test/run-pass/traits/trait-inheritance-overloading.rs index 083643e821f4b..fa834faf925d7 100644 --- a/src/test/run-pass/traits/trait-inheritance-overloading.rs +++ b/src/test/run-pass/traits/trait-inheritance-overloading.rs @@ -2,7 +2,7 @@ use std::cmp::PartialEq; use std::ops::{Add, Sub, Mul}; -trait MyNum : Add + Sub + Mul + PartialEq + Clone { } +trait MyNum : Add + Sub + Mul + PartialEq + Clone { } #[derive(Clone, Debug)] struct MyInt { val: isize } diff --git a/src/test/run-pass/traits/trait-object-auto-dedup.rs b/src/test/run-pass/traits/trait-object-auto-dedup.rs index 98a386e4c6e1d..7bfe1da950bc4 100644 --- a/src/test/run-pass/traits/trait-object-auto-dedup.rs +++ b/src/test/run-pass/traits/trait-object-auto-dedup.rs @@ -1,14 +1,16 @@ // run-pass -#![allow(unused_assignments)] + // Test that duplicate auto trait bounds in trait objects don't create new types. -#[allow(unused_assignments)] +#![allow(unused_assignments)] + +#[allow(unused_assignments)] use std::marker::Send as SendAlias; // A dummy trait for the non-auto trait. trait Trait {} -// A dummy struct to implement Trait, Send, and . +// A dummy struct to implement `Trait` and `Send`. struct Struct; impl Trait for Struct {} @@ -23,12 +25,12 @@ impl dyn Trait + Send + Send { } fn main() { - // 1. Moving into a variable with more Sends and back. + // 1. Moving into a variable with more `Send`s and back. let mut dyn_trait_send = Box::new(Struct) as Box; let dyn_trait_send_send: Box = dyn_trait_send; dyn_trait_send = dyn_trait_send_send; - // 2. Calling methods with different number of Sends. + // 2. Calling methods with different number of `Send`s. let dyn_trait_send = Box::new(Struct) as Box; takes_dyn_trait_send_send(dyn_trait_send); diff --git a/src/test/run-pass/traits/trait-where-clause-vs-impl.rs b/src/test/run-pass/traits/trait-where-clause-vs-impl.rs index 7cfee27efb32a..c9e0beddf56ab 100644 --- a/src/test/run-pass/traits/trait-where-clause-vs-impl.rs +++ b/src/test/run-pass/traits/trait-where-clause-vs-impl.rs @@ -1,12 +1,13 @@ // run-pass -#![allow(dead_code)] -#![allow(unused_variables)] +// pretty-expanded FIXME(#23616) + // Test that when there is a conditional (but blanket) impl and a -// where clause, we don't get confused in trait resolution. +// where-clause, we don't get confused in trait resolution. // // Issue #18453. -// pretty-expanded FIXME #23616 +#![allow(dead_code)] +#![allow(unused_variables)] use std::rc::Rc; diff --git a/src/test/run-pass/traits/traits-conditional-dispatch.rs b/src/test/run-pass/traits/traits-conditional-dispatch.rs index a9c194486fecb..863bfd15a4cfa 100644 --- a/src/test/run-pass/traits/traits-conditional-dispatch.rs +++ b/src/test/run-pass/traits/traits-conditional-dispatch.rs @@ -1,5 +1,5 @@ // run-pass -// Test that we are able to resolve conditional dispatch. Here, the +// Test that we are able to resolve conditional dispatch. Here, the // blanket impl for T:Copy coexists with an impl for Box, because // Box does not impl Copy. diff --git a/src/test/run-pass/traits/traits-default-method-mut.rs b/src/test/run-pass/traits/traits-default-method-mut.rs index 5f8e983b09cfb..929b03091f565 100644 --- a/src/test/run-pass/traits/traits-default-method-mut.rs +++ b/src/test/run-pass/traits/traits-default-method-mut.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_assignments)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] diff --git a/src/test/run-pass/traits/traits-issue-22019.rs b/src/test/run-pass/traits/traits-issue-22019.rs index 1a887f0f39f6b..b6758c9bd6abd 100644 --- a/src/test/run-pass/traits/traits-issue-22019.rs +++ b/src/test/run-pass/traits/traits-issue-22019.rs @@ -3,7 +3,7 @@ // distinct scopes to be compared (`'g` and `'h`). The only important // thing is that compilation succeeds here. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(missing_copy_implementations)] #![allow(unused_variables)] @@ -16,18 +16,18 @@ pub type Node<'a> = &'a CFGNode; pub trait GraphWalk<'c, N> { /// Returns all the nodes in this graph. - fn nodes(&'c self) where [N]:ToOwned>; + fn nodes(&'c self) where [N]:ToOwned>; } impl<'g> GraphWalk<'g, Node<'g>> for u32 { - fn nodes(&'g self) where [Node<'g>]:ToOwned>> + fn nodes(&'g self) where [Node<'g>]:ToOwned>> { loop { } } } impl<'h> GraphWalk<'h, Node<'h>> for u64 { - fn nodes(&'h self) where [Node<'h>]:ToOwned>> + fn nodes(&'h self) where [Node<'h>]:ToOwned>> { loop { } } } diff --git a/src/test/run-pass/traits/traits-issue-22110.rs b/src/test/run-pass/traits/traits-issue-22110.rs index bdbfee799f176..5fd02ee3caf47 100644 --- a/src/test/run-pass/traits/traits-issue-22110.rs +++ b/src/test/run-pass/traits/traits-issue-22110.rs @@ -3,7 +3,7 @@ // and the blanket impl. The only important thing is that compilation // succeeds here. Issue #22110. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/run-pass/traits/traits-issue-22655.rs b/src/test/run-pass/traits/traits-issue-22655.rs index bc08ca0a2ba64..49a6973febbb5 100644 --- a/src/test/run-pass/traits/traits-issue-22655.rs +++ b/src/test/run-pass/traits/traits-issue-22655.rs @@ -3,7 +3,7 @@ // Regression test for issue #22655: This test should not lead to // infinite recursion. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) unsafe impl Send for Unique { } diff --git a/src/test/run-pass/traits/traits-issue-23003.rs b/src/test/run-pass/traits/traits-issue-23003.rs index 24c2b2ad66074..38f078e795b0c 100644 --- a/src/test/run-pass/traits/traits-issue-23003.rs +++ b/src/test/run-pass/traits/traits-issue-23003.rs @@ -4,7 +4,7 @@ // Async>::Cancel` be WF. This normalizes to `Receipt` // again, leading to an infinite cycle. Issue #23003. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] #![allow(unused_variables)] diff --git a/src/test/run-pass/traits/use-trait-before-def.rs b/src/test/run-pass/traits/use-trait-before-def.rs index 1ee2b941909f4..aa6a6faf37bf2 100644 --- a/src/test/run-pass/traits/use-trait-before-def.rs +++ b/src/test/run-pass/traits/use-trait-before-def.rs @@ -3,7 +3,7 @@ // Issue #1761 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) impl foo for isize { fn foo(&self) -> isize { 10 } } trait foo { fn foo(&self) -> isize; } diff --git a/src/test/run-pass/transmute-non-immediate-to-immediate.rs b/src/test/run-pass/transmute-non-immediate-to-immediate.rs index 2119c8336f4c0..9e610f38dc854 100644 --- a/src/test/run-pass/transmute-non-immediate-to-immediate.rs +++ b/src/test/run-pass/transmute-non-immediate-to-immediate.rs @@ -1,7 +1,7 @@ // Issue #7988 // Transmuting non-immediate type to immediate type -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub fn main() { unsafe { diff --git a/src/test/run-pass/type-in-nested-module.rs b/src/test/run-pass/type-in-nested-module.rs index 077a28436df3b..1f25cfb2d7986 100644 --- a/src/test/run-pass/type-in-nested-module.rs +++ b/src/test/run-pass/type-in-nested-module.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod a { pub mod b { diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 8194562899667..30a9802bfdf40 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/type-param.rs b/src/test/run-pass/type-param.rs index bfce3f3287912..54bbb52b1a18d 100644 --- a/src/test/run-pass/type-param.rs +++ b/src/test/run-pass/type-param.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) type lteq = extern fn(T) -> bool; diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index 509843c6b9281..d8ecea198f7f3 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct S { a: T, diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs index 57c229a21758f..2354d22923d99 100644 --- a/src/test/run-pass/type-ptr.rs +++ b/src/test/run-pass/type-ptr.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(a: *const isize) -> *const isize { return a; } diff --git a/src/test/run-pass/type-use-i1-versus-i8.rs b/src/test/run-pass/type-use-i1-versus-i8.rs index dc029e4569ef5..84c7dae095efc 100644 --- a/src/test/run-pass/type-use-i1-versus-i8.rs +++ b/src/test/run-pass/type-use-i1-versus-i8.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ptr; diff --git a/src/test/run-pass/typestate-cfg-nesting.rs b/src/test/run-pass/typestate-cfg-nesting.rs index 994c7d516926c..525602238397f 100644 --- a/src/test/run-pass/typestate-cfg-nesting.rs +++ b/src/test/run-pass/typestate-cfg-nesting.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unknown_lints)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_assignment)] #![allow(unused_variables)] diff --git a/src/test/run-pass/ufcs-type-params.rs b/src/test/run-pass/ufcs-type-params.rs index 2bb15b91760fa..d3670a64e9cca 100644 --- a/src/test/run-pass/ufcs-type-params.rs +++ b/src/test/run-pass/ufcs-type-params.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { fn get(&self) -> T; diff --git a/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs b/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs index ac0a74eebd5e5..47d41b6458abe 100644 --- a/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs +++ b/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs @@ -9,7 +9,7 @@ pub fn has_closures() -> usize { f() + g() } -pub fn has_generic_closures + Copy>(x: T, y: T) -> T { +pub fn has_generic_closures + Copy>(x: T, y: T) -> T { let mut f = move || x; let g = || y; f() + g() diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs index 1c5e74e593cb9..8b0b45212adf3 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_mut)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let mut unboxed = || {}; diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs index e0c9105760d24..0c947572c81ca 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs @@ -2,7 +2,7 @@ // Test that we are able to infer that the type of `x` is `isize` based // on the expected type from the object. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait ToPrimitive { fn to_int(&self) {} diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs index 4f23f85b649e4..e3a2770e9e014 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs @@ -2,7 +2,7 @@ // Test that we are able to infer that the type of `x` is `isize` based // on the expected type from the object. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait ToPrimitive { fn to_int(&self) {} diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs index c3abdd8aab09e..8f496c56ed416 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs @@ -2,7 +2,7 @@ // Test that we are able to infer that the type of `x` is `isize` based // on the expected type from the object. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait ToPrimitive { fn to_int(&self) {} diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs index 72d658f393bd9..abe9b988483e6 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; // Test that we are able to infer a suitable kind for a "recursive" -// closure. As far as I can tell, coding up a recursive closure +// closure. As far as I can tell, coding up a recursive closure // requires the good ol' [Y Combinator]. // // [Y Combinator]: http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs index 9b519e63a95cc..dd8760f74e910 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![deny(unused_mut)] diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs index 7e53c4d9eb613..496a6f4a9514f 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs @@ -1,7 +1,7 @@ // run-pass // Tests that the re-exports of `FnOnce` et al from the prelude work. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let task: Box isize> = Box::new(|x| x); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs index 054f284ea2a54..778c1fd24c94b 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let onetime = |x| x; diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs index 6f41c35584e83..5760ae5135a46 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_mut)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { let mut zero = || {}; diff --git a/src/test/run-pass/unify-return-ty.rs b/src/test/run-pass/unify-return-ty.rs index 3f743a7da4066..37b86c967a328 100644 --- a/src/test/run-pass/unify-return-ty.rs +++ b/src/test/run-pass/unify-return-ty.rs @@ -2,7 +2,7 @@ // unified with the type *T, and so the type variable // in that type gets resolved. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::mem; diff --git a/src/test/run-pass/uninit-empty-types.rs b/src/test/run-pass/uninit-empty-types.rs index b59971b349802..9e821d4be3685 100644 --- a/src/test/run-pass/uninit-empty-types.rs +++ b/src/test/run-pass/uninit-empty-types.rs @@ -1,6 +1,6 @@ // Test the uninit() construct returning various empty types. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::mem; diff --git a/src/test/run-pass/unique/unique-containing-tag.rs b/src/test/run-pass/unique/unique-containing-tag.rs index f24b3a8645f29..9966912fb2180 100644 --- a/src/test/run-pass/unique/unique-containing-tag.rs +++ b/src/test/run-pass/unique/unique-containing-tag.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unique/unique-create.rs b/src/test/run-pass/unique/unique-create.rs index 3df0f7d55fd58..10b9cf24caa99 100644 --- a/src/test/run-pass/unique/unique-create.rs +++ b/src/test/run-pass/unique/unique-create.rs @@ -1,6 +1,6 @@ // run-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unique/unique-drop-complex.rs b/src/test/run-pass/unique/unique-drop-complex.rs index 0b7bda83b3fa1..dfe0b5f8bf267 100644 --- a/src/test/run-pass/unique/unique-drop-complex.rs +++ b/src/test/run-pass/unique/unique-drop-complex.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unique/unique-generic-assign.rs b/src/test/run-pass/unique/unique-generic-assign.rs index 9c4405aa8ac2a..d053643444c99 100644 --- a/src/test/run-pass/unique/unique-generic-assign.rs +++ b/src/test/run-pass/unique/unique-generic-assign.rs @@ -3,7 +3,7 @@ // Issue #976 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn f(x: Box) { let _x2 = x; diff --git a/src/test/run-pass/unique/unique-init.rs b/src/test/run-pass/unique/unique-init.rs index c8a150522fd2e..872407c592671 100644 --- a/src/test/run-pass/unique/unique-init.rs +++ b/src/test/run-pass/unique/unique-init.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unique/unique-match-discrim.rs b/src/test/run-pass/unique/unique-match-discrim.rs index 6e6d7432277d9..4f38eabe2fba5 100644 --- a/src/test/run-pass/unique/unique-match-discrim.rs +++ b/src/test/run-pass/unique/unique-match-discrim.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Issue #961 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn altsimple() { match Box::new(true) { diff --git a/src/test/run-pass/unique/unique-object-move.rs b/src/test/run-pass/unique/unique-object-move.rs index 4bd3764fa15a7..57dc79f6a9050 100644 --- a/src/test/run-pass/unique/unique-object-move.rs +++ b/src/test/run-pass/unique/unique-object-move.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // Issue #5192 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unit.rs b/src/test/run-pass/unit.rs index e10b2408cb79e..3f0536a3117d5 100644 --- a/src/test/run-pass/unit.rs +++ b/src/test/run-pass/unit.rs @@ -1,6 +1,6 @@ #![allow(unused_assignments)] #![allow(unknown_lints)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_variables)] #![allow(dead_assignment)] diff --git a/src/test/run-pass/unnamed_argument_mode.rs b/src/test/run-pass/unnamed_argument_mode.rs index fa817be270496..9e63013ae0aa8 100644 --- a/src/test/run-pass/unnamed_argument_mode.rs +++ b/src/test/run-pass/unnamed_argument_mode.rs @@ -1,10 +1,9 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn good(_a: &isize) { } -// unnamed argument &isize is now parse x: &isize - +// Unnamed argument `&isize` is parsed like `x: &isize`. fn called(_f: F) where F: FnOnce(&isize) { } diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs index e49b372981bf7..e07bc6594d9b0 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs @@ -2,7 +2,7 @@ // // See also: compile-fail/unsafe-fn-called-from-safe.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) unsafe fn f() { return; } diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs index f9414bee2987e..d737872d60cbe 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs @@ -2,7 +2,7 @@ // // See also: compile-fail/unsafe-fn-called-from-safe.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) unsafe fn f() { return; } diff --git a/src/test/run-pass/unsized-locals/by-value-trait-object-safety-withdefault.rs b/src/test/run-pass/unsized-locals/by-value-trait-object-safety-withdefault.rs index e6e363f55a1a6..81e703b786fa5 100644 --- a/src/test/run-pass/unsized-locals/by-value-trait-object-safety-withdefault.rs +++ b/src/test/run-pass/unsized-locals/by-value-trait-object-safety-withdefault.rs @@ -10,12 +10,11 @@ struct A; impl Foo for A {} - fn main() { let x = *(Box::new(A) as Box); assert_eq!(x.foo(), format!("hello")); - // I'm not sure whether we want this to work + // I'm not sure whether we want this to work. let x = Box::new(A) as Box; assert_eq!(x.foo(), format!("hello")); } diff --git a/src/test/run-pass/unsized-locals/by-value-trait-object-safety.rs b/src/test/run-pass/unsized-locals/by-value-trait-object-safety.rs index f19ff5b8de462..45ee718c95106 100644 --- a/src/test/run-pass/unsized-locals/by-value-trait-object-safety.rs +++ b/src/test/run-pass/unsized-locals/by-value-trait-object-safety.rs @@ -12,12 +12,11 @@ impl Foo for A { } } - fn main() { let x = *(Box::new(A) as Box); assert_eq!(x.foo(), format!("hello")); - // I'm not sure whether we want this to work + // I'm not sure whether we want this to work. let x = Box::new(A) as Box; assert_eq!(x.foo(), format!("hello")); } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index c3eae299b86c8..29140da795742 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -54,7 +54,7 @@ impl T3 for S { } fn f7(x: &X) { // This is valid, but the unsized bound on X is irrelevant because any type - // which implements T3 must have statically known size. + // which implements T3 must have statically-known size. let _: Box = T3::f(); } diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index baba19c08cd55..1c9c7cfd291a0 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs index 74632dbc797fa..60106c7b3fdd7 100644 --- a/src/test/run-pass/unused-move.rs +++ b/src/test/run-pass/unused-move.rs @@ -2,7 +2,7 @@ // Issue Name: Unused move causes a crash // Abstract: zero-fill to block after drop -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(path_statements)] #![feature(box_syntax)] diff --git a/src/test/run-pass/use-crate-name-alias.rs b/src/test/run-pass/use-crate-name-alias.rs index 520e72676b097..7d0d6bb829aa2 100644 --- a/src/test/run-pass/use-crate-name-alias.rs +++ b/src/test/run-pass/use-crate-name-alias.rs @@ -1,5 +1,5 @@ // Issue #1706 -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate std as stdlib; diff --git a/src/test/run-pass/use-import-export.rs b/src/test/run-pass/use-import-export.rs index bb6a8ee55bfc8..243381c49c8b1 100644 --- a/src/test/run-pass/use-import-export.rs +++ b/src/test/run-pass/use-import-export.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod foo { pub fn x() -> isize { return 1; } @@ -8,4 +8,7 @@ mod bar { pub fn y() -> isize { return 1; } } -pub fn main() { foo::x(); bar::y(); } +pub fn main() { + foo::x(); + bar::y(); +} diff --git a/src/test/run-pass/use-mod.rs b/src/test/run-pass/use-mod.rs index 9af56b71de00d..e9d2da5e53e85 100644 --- a/src/test/run-pass/use-mod.rs +++ b/src/test/run-pass/use-mod.rs @@ -1,5 +1,5 @@ #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub use foo::bar::{self, First}; use self::bar::Second; diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index df37a60e35608..dea7cd66d4550 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -1,5 +1,5 @@ #![allow(stable_features)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_imports)] #![feature(start, no_core, core)] diff --git a/src/test/run-pass/use_inline_dtor.rs b/src/test/run-pass/use_inline_dtor.rs index 0873d185575b1..ec926ac04e8fe 100644 --- a/src/test/run-pass/use_inline_dtor.rs +++ b/src/test/run-pass/use_inline_dtor.rs @@ -1,6 +1,6 @@ // aux-build:inline_dtor.rs -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate inline_dtor; diff --git a/src/test/run-pass/variant-attributes.rs b/src/test/run-pass/variant-attributes.rs index 19de3ff2f63f3..71344b65b6ee3 100644 --- a/src/test/run-pass/variant-attributes.rs +++ b/src/test/run-pass/variant-attributes.rs @@ -2,7 +2,7 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] // pp-exact - Make sure we actually print the attributes -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(custom_attribute)] diff --git a/src/test/run-pass/warn-ctypes-inhibit.rs b/src/test/run-pass/warn-ctypes-inhibit.rs index 76b36a12c200c..b16937319c9ce 100644 --- a/src/test/run-pass/warn-ctypes-inhibit.rs +++ b/src/test/run-pass/warn-ctypes-inhibit.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // compile-flags:-D improper-ctypes -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(improper_ctypes)] diff --git a/src/test/run-pass/weak-lang-item.rs b/src/test/run-pass/weak-lang-item.rs index 9a36606a46509..14a0443e10af7 100644 --- a/src/test/run-pass/weak-lang-item.rs +++ b/src/test/run-pass/weak-lang-item.rs @@ -1,7 +1,7 @@ // aux-build:weak-lang-items.rs // ignore-emscripten no threads support -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern crate weak_lang_items as other; diff --git a/src/test/run-pass/wf-bound-region-in-object-type.rs b/src/test/run-pass/wf-bound-region-in-object-type.rs index d81059ca6a844..ff45efbb73eb9 100644 --- a/src/test/run-pass/wf-bound-region-in-object-type.rs +++ b/src/test/run-pass/wf-bound-region-in-object-type.rs @@ -3,7 +3,7 @@ // Test that the `wf` checker properly handles bound regions in object // types. Compiling this code used to trigger an ICE. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Context<'tcx> { vec: &'tcx Vec diff --git a/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs b/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs index cf7d06b6179b0..ddb1af8eb11f3 100644 --- a/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs +++ b/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs @@ -1,5 +1,5 @@ // run-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Bound { fn dummy(&self) { } diff --git a/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs b/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs index 6fc570b9b5b9b..a151ca8756684 100644 --- a/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs +++ b/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait TheTrait { fn dummy(&self) { } } diff --git a/src/test/run-pass/where-clauses/where-clause-method-substituion.rs b/src/test/run-pass/where-clauses/where-clause-method-substituion.rs index daa3c8dd8e367..d5ce8134855dc 100644 --- a/src/test/run-pass/where-clauses/where-clause-method-substituion.rs +++ b/src/test/run-pass/where-clauses/where-clause-method-substituion.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { fn dummy(&self, arg: T) { } } diff --git a/src/test/run-pass/where-clauses/where-clause-region-outlives.rs b/src/test/run-pass/where-clauses/where-clause-region-outlives.rs index 84925345de14e..435f26771ca99 100644 --- a/src/test/run-pass/where-clauses/where-clause-region-outlives.rs +++ b/src/test/run-pass/where-clauses/where-clause-region-outlives.rs @@ -1,7 +1,7 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct A<'a, 'b> where 'a : 'b { x: &'a isize, y: &'b isize } diff --git a/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs b/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs index 4bfd9e6590fba..18b215ec0e388 100644 --- a/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs +++ b/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs @@ -1,9 +1,9 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) -fn foo<'a, I>(mut it: I) where I: Iterator {} +fn foo<'a, I>(mut it: I) where I: Iterator {} fn main() { foo([1, 2].iter()); diff --git a/src/test/run-pass/where-clauses/where-clauses-method.rs b/src/test/run-pass/where-clauses/where-clauses-method.rs index feecff4356527..61715cc20d57f 100644 --- a/src/test/run-pass/where-clauses/where-clauses-method.rs +++ b/src/test/run-pass/where-clauses/where-clauses-method.rs @@ -1,5 +1,5 @@ // run-pass -// Test that a where clause attached to a method allows us to add +// Test that a where-clause attached to a method allows us to add // additional constraints to a parameter out of scope. struct Foo { diff --git a/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs b/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs index 6964cfa2eb044..eee9bf82e7558 100644 --- a/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs +++ b/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs @@ -1,6 +1,6 @@ // run-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Bencher; diff --git a/src/test/rustdoc-ui/deprecated-attrs.stderr b/src/test/rustdoc-ui/deprecated-attrs.stderr index 5bd62d60b48f3..7782b118085d4 100644 --- a/src/test/rustdoc-ui/deprecated-attrs.stderr +++ b/src/test/rustdoc-ui/deprecated-attrs.stderr @@ -1,9 +1,9 @@ warning: the `#![doc(no_default_passes)]` attribute is considered deprecated | - = warning: please see https://github.com/rust-lang/rust/issues/44136 + = warning: see = help: you may want to use `#![doc(document_private_items)]` warning: the `#![doc(passes = "...")]` attribute is considered deprecated | - = warning: please see https://github.com/rust-lang/rust/issues/44136 + = warning: see diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 8af05e9ca97b1..f3075829683d7 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -13,13 +13,13 @@ error[E0425]: cannot find value `no` in this scope | ^^ not found in this scope thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:354:13 -note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ---- thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test executable failed: thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 -note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ', src/librustdoc/test.rs:389:17 diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs index 5891a553e3255..b8e612e628858 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs @@ -3,8 +3,7 @@ #![deny(intra_doc_link_resolution_failure)] // An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to -// attempt to slice in the middle of a multibyte character. See -// https://github.com/rust-lang/rust/issues/55723 +// attempt to slice in the middle of a multibyte character. /// ## For example: /// diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index 4eb1861062872..8c23a3e1b9170 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -1,5 +1,5 @@ error: `[i]` cannot be resolved, ignoring it... - --> $DIR/intra-link-span-ice-55723.rs:11:10 + --> $DIR/intra-link-span-ice-55723.rs:10:10 | LL | /// (arr[i]) | ^ cannot be resolved, ignoring diff --git a/src/test/rustdoc/auto-impl-for-trait.rs b/src/test/rustdoc/auto-impl-for-trait.rs index bc658fbfc8cce..0ff04e59eb5d1 100644 --- a/src/test/rustdoc/auto-impl-for-trait.rs +++ b/src/test/rustdoc/auto-impl-for-trait.rs @@ -1,4 +1,4 @@ -// Test for https://github.com/rust-lang/rust/issues/48463 issue. +// Test for issue #48463. use std::any::Any; use std::ops::Deref; diff --git a/src/test/rustdoc/comment-in-doctest.rs b/src/test/rustdoc/comment-in-doctest.rs index e4e41bc7ce308..d60d7d98655c5 100644 --- a/src/test/rustdoc/comment-in-doctest.rs +++ b/src/test/rustdoc/comment-in-doctest.rs @@ -1,11 +1,11 @@ // compile-flags:--test -// comments, both doc comments and regular ones, used to trick rustdoc's doctest parser into -// thinking that everything after it was part of the regular program. combined with the libsyntax +// Comments, both doc comments and regular ones, used to trick rustdoc's doctest parser into +// thinking that everything after it was part of the regular program. Combined with the libsyntax // parser loop failing to detect the manual main function, it would wrap everything in `fn main`, // which would cause the doctest to fail as the "extern crate" declaration was no longer valid. -// oddly enough, it would pass in 2018 if a crate was in the extern prelude. see -// https://github.com/rust-lang/rust/issues/56727 +// Oddly enough, it would pass in 2018 if a crate was in the extern prelude. See +// issue #56727. //! ``` //! // crate: proc-macro-test diff --git a/src/test/rustdoc/impl-parts-crosscrate.rs b/src/test/rustdoc/impl-parts-crosscrate.rs index f9583d1a72296..1cc0027dc1969 100644 --- a/src/test/rustdoc/impl-parts-crosscrate.rs +++ b/src/test/rustdoc/impl-parts-crosscrate.rs @@ -9,7 +9,7 @@ pub struct Bar { t: T } // The output file is html embedded in javascript, so the html tags // aren't stripped by the processing script and we can't check for the -// full impl string. Instead, just make sure something from each part +// full impl string. Instead, just make sure something from each part // is mentioned. // @has implementors/rustdoc_impl_parts_crosscrate/trait.AnOibit.js Bar diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs index 55d8ee394385b..d11375328fbed 100644 --- a/src/test/rustdoc/issue-25001.rs +++ b/src/test/rustdoc/issue-25001.rs @@ -25,21 +25,21 @@ impl Foo { impl Bar for Foo { // @has - '//*[@id="associatedtype.Item"]//code' 'type Item = T' - type Item=T; + type Item = T; // @has - '//*[@id="method.quux"]//code' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a Foo { // @has - '//*[@id="associatedtype.Item-1"]//code' "type Item = &'a T" - type Item=&'a T; + type Item = &'a T; // @has - '//*[@id="method.quux-1"]//code' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a mut Foo { // @has - '//*[@id="associatedtype.Item-2"]//code' "type Item = &'a mut T" - type Item=&'a mut T; + type Item = &'a mut T; // @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)' fn quux(self) {} diff --git a/src/test/rustdoc/issue-43869.rs b/src/test/rustdoc/issue-43869.rs index 44356848fbfad..bc9fd5fd2de1c 100644 --- a/src/test/rustdoc/issue-43869.rs +++ b/src/test/rustdoc/issue-43869.rs @@ -43,17 +43,19 @@ pub fn test_44731_1() -> Result, ()> { Ok(Box::new(j())) } -// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 -// -//pub fn test_44731_2() -> Box { -// Box::new(|_: u32| {}) -//} -// -//pub fn test_44731_3() -> Box impl Clone> { -// Box::new(|| 0u32) -//} +// NOTE: these involve `Fn` sugar, where `impl Trait` is disallowed for now (see issue #45994). -pub fn test_44731_4() -> Box> { +/* +pub fn test_44731_2() -> Box { + Box::new(|_: u32| {}) +} + +pub fn test_44731_3() -> Box impl Clone> { + Box::new(|| 0u32) +} +*/ + +pub fn test_44731_4() -> Box> { Box::new(g()) } diff --git a/src/test/rustdoc/traits-in-bodies.rs b/src/test/rustdoc/traits-in-bodies.rs index 1c3727a5748e6..8cfd50b24b835 100644 --- a/src/test/rustdoc/traits-in-bodies.rs +++ b/src/test/rustdoc/traits-in-bodies.rs @@ -1,5 +1,5 @@ -//prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it -//didn't see that `SomeStruct` implemented `Clone` +// prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it +// didn't see that `SomeStruct` implemented `Clone` pub struct Bounded(T); diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs index c85d41c7f5195..1abdc97db307b 100644 --- a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs +++ b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs @@ -1,4 +1,4 @@ -// Test equality constraints in a where clause where the type being +// Test equality constraints in a where-clause where the type being // equated appears in a supertrait. pub trait Vehicle { diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs index df9143d685ff3..8421dfa707f3c 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs @@ -1,4 +1,4 @@ -// Test equality constraints in a where clause where the type being +// Test equality constraints in a where-clause where the type being // equated appears in a supertrait. pub trait Vehicle { @@ -20,7 +20,7 @@ fn dent(c: C, color: C::Color) { //~^ ERROR ambiguous associated type `Color` in bounds of `C` } -fn dent_object(c: BoxCar) { +fn dent_object(c: BoxCar) { //~^ ERROR ambiguous associated type //~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index 0994dc87c994b..42f557ac0ab81 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -19,8 +19,8 @@ LL | type Color; LL | type Color; | ----------- ambiguous `Color` from `Box` ... -LL | fn dent_object(c: BoxCar) { - | ^^^^^^^^^^^ ambiguous associated type `Color` +LL | fn dent_object(c: BoxCar) { + | ^^^^^^^^^^^^^ ambiguous associated type `Color` error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:26 @@ -28,8 +28,8 @@ error[E0191]: the value of the associated type `Color` (from the trait `Vehicle` LL | type Color; | ----------- `Color` defined here ... -LL | fn dent_object(c: BoxCar) { - | ^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified +LL | fn dent_object(c: BoxCar) { + | ^^^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29 diff --git a/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs b/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs index 06dfe490b8bd3..fc3b826b6014f 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs +++ b/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs @@ -1,4 +1,4 @@ -// Test equality constraints in a where clause where the type being +// Test equality constraints in a where-clause where the type being // equated appears in a supertrait. pub trait Vehicle { diff --git a/src/test/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs b/src/test/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs index 707bcac78bf92..2ddbc7a6a5a65 100644 --- a/src/test/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs +++ b/src/test/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs @@ -12,7 +12,7 @@ pub trait Sized { } #[lang = "add"] -trait Add { +trait Add { type Output; fn add(self, _: RHS) -> Self::Output; diff --git a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs index 653130843c8de..9070588fc9036 100644 --- a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs +++ b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs @@ -1,4 +1,4 @@ -// Test equality constraints in a where clause where the type being +// Test equality constraints in a where-clause where the type being // equated appears in a supertrait. pub trait Vehicle { @@ -27,10 +27,10 @@ impl Car for ModelU { } /////////////////////////////////////////////////////////////////////////// -fn black_car>(c: C) { +fn black_car>(c: C) { } -fn blue_car>(c: C) { +fn blue_car>(c: C) { } fn a() { black_car(ModelT); } diff --git a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr index 126fb572d992a..0cf364787be30 100644 --- a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr +++ b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr @@ -9,8 +9,8 @@ LL | fn b() { blue_car(ModelT); } //~ ERROR type mismatch note: required by `blue_car` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:33:1 | -LL | fn blue_car>(c: C) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn blue_car>(c: C) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `::Color == Black` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:38:10 @@ -23,8 +23,8 @@ LL | fn c() { black_car(ModelU); } //~ ERROR type mismatch note: required by `black_car` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:30:1 | -LL | fn black_car>(c: C) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn black_car>(c: C) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/associated-types-bound-failure.rs b/src/test/ui/associated-types/associated-types-bound-failure.rs index 883ac363b44e5..73fa173603ed4 100644 --- a/src/test/ui/associated-types/associated-types-bound-failure.rs +++ b/src/test/ui/associated-types/associated-types-bound-failure.rs @@ -1,4 +1,4 @@ -// Test equality constraints on associated types in a where clause. +// Test equality constraints on associated types in a where-clause. pub trait ToInt { fn to_int(&self) -> isize; diff --git a/src/test/ui/associated-types/associated-types-eq-2.rs b/src/test/ui/associated-types/associated-types-eq-2.rs index 18e38d4466702..c4bf894a22559 100644 --- a/src/test/ui/associated-types/associated-types-eq-2.rs +++ b/src/test/ui/associated-types/associated-types-eq-2.rs @@ -13,7 +13,7 @@ impl Foo for isize { fn boo(&self) -> usize { 42 } } -fn baz(x: &>::A) {} +fn baz(x: &>::A) {} //~^ ERROR associated type bindings are not allowed here pub fn main() {} diff --git a/src/test/ui/associated-types/associated-types-eq-2.stderr b/src/test/ui/associated-types/associated-types-eq-2.stderr index 23ee8cd23b5c3..c8e89839d429c 100644 --- a/src/test/ui/associated-types/associated-types-eq-2.stderr +++ b/src/test/ui/associated-types/associated-types-eq-2.stderr @@ -1,8 +1,8 @@ error[E0229]: associated type bindings are not allowed here --> $DIR/associated-types-eq-2.rs:16:30 | -LL | fn baz(x: &>::A) {} - | ^^^^^ associated type not allowed here +LL | fn baz(x: &>::A) {} + | ^^^^^^^ associated type not allowed here error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-eq-3.rs b/src/test/ui/associated-types/associated-types-eq-3.rs index 1a58dcca9e249..eae75791d0024 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.rs +++ b/src/test/ui/associated-types/associated-types-eq-3.rs @@ -15,7 +15,7 @@ impl Foo for isize { } } -fn foo1>(x: I) { +fn foo1>(x: I) { let _: Bar = x.boo(); } @@ -28,7 +28,7 @@ fn foo2(x: I) { } -pub fn baz(x: &Foo) { +pub fn baz(x: &Foo) { let _: Bar = x.boo(); } diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index c1a8e2002be61..1fe248f0cb10b 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -18,8 +18,8 @@ LL | foo1(a); note: required by `foo1` --> $DIR/associated-types-eq-3.rs:18:1 | -LL | fn foo1>(x: I) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo1>(x: I) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `::A == Bar` --> $DIR/associated-types-eq-3.rs:41:9 diff --git a/src/test/ui/associated-types/associated-types-issue-20346.rs b/src/test/ui/associated-types/associated-types-issue-20346.rs index 0cce847e1be54..4741988b5c7b4 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.rs +++ b/src/test/ui/associated-types/associated-types-issue-20346.rs @@ -12,14 +12,14 @@ trait Iterator { fn next(&mut self) -> Option; } -fn is_iterator_of>(_: &I) {} +fn is_iterator_of>(_: &I) {} struct Adapter { iter: I, found_none: bool, } -impl Iterator for Adapter where I: Iterator> { +impl Iterator for Adapter where I: Iterator> { type Item = T; fn next(&mut self) -> Option { @@ -27,7 +27,7 @@ impl Iterator for Adapter where I: Iterator> { } } -fn test_adapter>>(it: I) { +fn test_adapter>>(it: I) { is_iterator_of::, _>(&it); // Sanity check let adapter = Adapter { iter: it, found_none: false }; is_iterator_of::(&adapter); // OK diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index 27b5b1e00f9ec..63f3a13ff7ab6 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -9,8 +9,8 @@ LL | is_iterator_of::, _>(&adapter); //~ ERROR type mismatch note: required by `is_iterator_of` --> $DIR/associated-types-issue-20346.rs:15:1 | -LL | fn is_iterator_of>(_: &I) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn is_iterator_of>(_: &I) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.rs b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.rs index 20f11ecf63823..ba9c612557453 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.rs +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.rs @@ -12,7 +12,7 @@ struct SomeStruct Foo<&'x isize>> { //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context } -// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax. +// FIXME(eddyb): this one doesn't even compile because of the unsupported syntax. // struct AnotherStruct Foo<&'x isize>> { // field: Foo<&'y isize>>::A diff --git a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs index fc38b26f50b62..3f6df65f7b70e 100644 --- a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs +++ b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.rs @@ -6,7 +6,7 @@ trait Get { } trait Other { - fn okay(&self, foo: U, bar: ::Value); + fn ok(&self, foo: U, bar: ::Value); //~^ ERROR E0277 } @@ -19,11 +19,11 @@ impl Get for f64 { } impl Other for () { - fn okay(&self, _foo: U, _bar: ::Value) { } + fn ok(&self, _foo: U, _bar: ::Value) { } } impl Other for f64 { - fn okay(&self, _foo: U, _bar: ::Value) { } + fn ok(&self, _foo: U, _bar: ::Value) { } } fn main() { } diff --git a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr index a260e37918254..f629cd83961ff 100644 --- a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr +++ b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Self: Get` is not satisfied --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:9:5 | -LL | fn okay(&self, foo: U, bar: ::Value); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` +LL | fn ok(&self, foo: U, bar: ::Value); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` | = help: consider adding a `where Self: Get` bound diff --git a/src/test/ui/associated-types/associated-types-unsized.stderr b/src/test/ui/associated-types/associated-types-unsized.stderr index c83b14374f712..0fba85210b5b9 100644 --- a/src/test/ui/associated-types/associated-types-unsized.stderr +++ b/src/test/ui/associated-types/associated-types-unsized.stderr @@ -7,7 +7,7 @@ LL | let x = t.get(); //~ ERROR the size for values of type = help: the trait `std::marker::Sized` is not implemented for `::Value` = note: to learn more, visit = help: consider adding a `where ::Value: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr index fee64c0f663b7..36fe42362ae6b 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr @@ -1,26 +1,26 @@ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types --> $DIR/bound-lifetime-in-binding-only.rs:12:25 | -LL | fn angle Foo>() { - | ^^^^^^^^^^^^ +LL | fn angle Foo>() { + | ^^^^^^^^^^^^^^ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types --> $DIR/bound-lifetime-in-binding-only.rs:17:37 | -LL | fn angle1() where T: for<'a> Foo { - | ^^^^^^^^^^^^ +LL | fn angle1() where T: for<'a> Foo { + | ^^^^^^^^^^^^^^ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types --> $DIR/bound-lifetime-in-binding-only.rs:22:37 | -LL | fn angle2() where for<'a> T: Foo { - | ^^^^^^^^^^^^ +LL | fn angle2() where for<'a> T: Foo { + | ^^^^^^^^^^^^^^ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types --> $DIR/bound-lifetime-in-binding-only.rs:27:27 | -LL | fn angle3(_: &for<'a> Foo) { - | ^^^^^^^^^^^^ +LL | fn angle3(_: &for<'a> Foo) { + | ^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs index e1989d35bbb8c..a8d68ee4c7641 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs @@ -9,22 +9,22 @@ trait Foo { } #[cfg(angle)] -fn angle Foo>() { +fn angle Foo>() { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } #[cfg(angle)] -fn angle1() where T: for<'a> Foo { +fn angle1() where T: for<'a> Foo { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } #[cfg(angle)] -fn angle2() where for<'a> T: Foo { +fn angle2() where for<'a> T: Foo { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } #[cfg(angle)] -fn angle3(_: &for<'a> Foo) { +fn angle3(_: &for<'a> Foo) { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } @@ -60,11 +60,11 @@ fn ok1 Fn(&Parameterized<'a>) -> &'a i32>() { } #[cfg(ok)] -fn ok2 Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() { +fn ok2 Fn<(&'b Parameterized<'a>,), Output = &'a i32>>() { } #[cfg(ok)] -fn ok3() where for<'a> Parameterized<'a>: Foo { +fn ok3() where for<'a> Parameterized<'a>: Foo { } #[rustc_error] diff --git a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs index 5a7e086fd476c..7e7a1c76f5838 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs @@ -42,7 +42,7 @@ fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) { } #[cfg(ok)] -fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { +fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output = &'a i32>) { } #[rustc_error] diff --git a/src/test/ui/associated-types/cache/chrono-scan.rs b/src/test/ui/associated-types/cache/chrono-scan.rs index 00d47c92a374c..efbd5ac4cc64b 100644 --- a/src/test/ui/associated-types/cache/chrono-scan.rs +++ b/src/test/ui/associated-types/cache/chrono-scan.rs @@ -16,7 +16,7 @@ pub fn timezone_offset_zulu(s: &str, colon: F) -> ParseResult<(&str, i32)> } pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()> - where I: Iterator> { + where I: Iterator> { macro_rules! try_consume { ($e:expr) => ({ let (s_, v) = try!($e); s = s_; v }) } diff --git a/src/test/ui/associated-types/higher-ranked-projection.rs b/src/test/ui/associated-types/higher-ranked-projection.rs index 1280c8cb4cb09..2c113c9a0cfe8 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.rs +++ b/src/test/ui/associated-types/higher-ranked-projection.rs @@ -12,12 +12,12 @@ impl Mirror for T { #[cfg(bad)] fn foo(_t: T) - where for<'a> &'a T: Mirror + where for<'a> &'a T: Mirror {} #[cfg(good)] fn foo(_t: T) - where for<'a> &'a T: Mirror + where for<'a> &'a T: Mirror {} #[rustc_error] diff --git a/src/test/ui/auxiliary/weak-lang-items.rs b/src/test/ui/auxiliary/weak-lang-items.rs index 7a698cf76ae51..c5181f3b6719e 100644 --- a/src/test/ui/auxiliary/weak-lang-items.rs +++ b/src/test/ui/auxiliary/weak-lang-items.rs @@ -1,6 +1,6 @@ // no-prefer-dynamic -// This aux-file will require the eh_personality function to be codegen'd, but +// This aux-file will require the `eh_personality` function to be codegen'ed, but // it hasn't been defined just yet. Make sure we don't explode. #![no_std] diff --git a/src/test/ui/bastion-of-the-turbofish.rs b/src/test/ui/bastion-of-the-turbofish.rs index 0716fcf7f26a8..be8c99d429fb1 100644 --- a/src/test/ui/bastion-of-the-turbofish.rs +++ b/src/test/ui/bastion-of-the-turbofish.rs @@ -26,9 +26,7 @@ // My heart aches in sorrow, for I know I am defeated. Let this be a warning // to all those who come after. Here stands the bastion of the Turbofish. -// See https://github.com/rust-lang/rust/pull/53562 -// and https://github.com/rust-lang/rfcs/pull/2527 -// for context. +// See PR #53562 and RFC #2527 for context. fn main() { let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated"); diff --git a/src/test/ui/borrowck/borrowck-access-permissions.rs b/src/test/ui/borrowck/borrowck-access-permissions.rs index 993742f427e03..1a239a5416c22 100644 --- a/src/test/ui/borrowck/borrowck-access-permissions.rs +++ b/src/test/ui/borrowck/borrowck-access-permissions.rs @@ -55,6 +55,6 @@ fn main() { let foo_ref = &foo; let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] //[mir]~^ ERROR [E0596] - // FIXME: Wrong error in MIR + // FIXME: wrong error in MIR } } diff --git a/src/test/ui/borrowck/borrowck-assign-comp.rs b/src/test/ui/borrowck/borrowck-assign-comp.rs index 0cacc3882d800..42607c71e79fe 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp.rs +++ b/src/test/ui/borrowck/borrowck-assign-comp.rs @@ -9,14 +9,14 @@ fn a() { // This assignment is illegal because the field x is not // inherently mutable; since `p` was made immutable, `p.x` is now - // immutable. Otherwise the type of &_q.x (&isize) would be wrong. + // immutable. Otherwise the type of &_q.x (&isize) would be wrong. p.x = 5; //[ast]~ ERROR cannot assign to `p.x` //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed q.x; } fn c() { - // this is sort of the opposite. We take a loan to the interior of `p` + // this is sort of the opposite. We take a loan to the interior of `p` // and then try to overwrite `p` as a whole. let mut p = Point {x: 3, y: 4}; diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs index 88bd106d6f35e..05d951dd4c9d8 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs @@ -1,4 +1,4 @@ -//buggy.rs +// buggy.rs #![feature(box_syntax)] diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/borrowck/borrowck-describe-lvalue.rs index eb622ac10addf..b756b17a9a280 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.rs @@ -36,7 +36,7 @@ impl Baz { } fn main() { - // Local and field from struct + // Local and field from struct. { let mut f = Foo { x: 22 }; let x = f.x(); @@ -44,7 +44,7 @@ fn main() { //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } - // Local and field from tuple-struct + // Local and field from tuple struct. { let mut g = Bar(22); let x = g.x(); @@ -52,7 +52,7 @@ fn main() { //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } - // Local and field from tuple + // Local and field from tuple. { let mut h = (22, 23); let x = &mut h.0; @@ -60,7 +60,7 @@ fn main() { //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } - // Local and field from enum + // Local and field from enum. { let mut e = Baz::X(2); let x = e.x(); @@ -71,7 +71,7 @@ fn main() { }; drop(x); } - // Local and field from union + // Local and field from union. unsafe { let mut u = U { b: 0 }; let x = &mut u.a; @@ -79,7 +79,7 @@ fn main() { //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } - // Deref and field from struct + // Deref and field from struct. { let mut f = Box::new(Foo { x: 22 }); let x = f.x(); @@ -87,7 +87,7 @@ fn main() { //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } - // Deref and field from tuple-struct + // Deref and field from tuple struct. { let mut g = Box::new(Bar(22)); let x = g.x(); @@ -95,7 +95,7 @@ fn main() { //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } - // Deref and field from tuple + // Deref and field from tuple. { let mut h = Box::new((22, 23)); let x = &mut h.0; @@ -103,7 +103,7 @@ fn main() { //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } - // Deref and field from enum + // Deref and field from enum. { let mut e = Box::new(Baz::X(3)); let x = e.x(); @@ -114,7 +114,7 @@ fn main() { }; drop(x); } - // Deref and field from union + // Deref and field from union. unsafe { let mut u = Box::new(U { b: 0 }); let x = &mut u.a; @@ -122,7 +122,7 @@ fn main() { //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } - // Constant index + // Constant index. { let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let x = &mut v; @@ -152,7 +152,7 @@ fn main() { } drop(x); } - // Subslices + // Subslices. { let mut v = &[1, 2, 3, 4, 5]; let x = &mut v; @@ -182,7 +182,7 @@ fn main() { } drop(x); } - // Downcasted field + // Downcast field. { enum E { A(X), B { x: X } } @@ -201,7 +201,7 @@ fn main() { } drop(x); } - // Field in field + // Field in field. { struct F { x: u32, y: u32 }; struct S { x: F, y: (u32, u32), }; @@ -223,7 +223,7 @@ fn main() { } drop(x); } - // Field of ref + // Field of ref. { struct Block<'a> { current: &'a u8, @@ -238,7 +238,7 @@ fn main() { drop(x); } } - // Field of ptr + // Field of ptr. { struct Block2 { current: *const u8, @@ -253,7 +253,7 @@ fn main() { drop(x); } } - // Field of index + // Field of index. { struct F {x: u32, y: u32}; let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; @@ -264,7 +264,7 @@ fn main() { //[mir]~| ERROR cannot use `*v` because it was mutably borrowed drop(x); } - // Field of constant index + // Field of constant index. { struct F {x: u32, y: u32}; let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; @@ -277,7 +277,7 @@ fn main() { } drop(x); } - // Field from upvar + // Field from upvar. { let mut x = 0; || { @@ -287,7 +287,7 @@ fn main() { *y = 1; }; } - // Field from upvar nested + // Field from upvar, nested. { let mut x = 0; || { diff --git a/src/test/ui/borrowck/borrowck-drop-from-guard.rs b/src/test/ui/borrowck/borrowck-drop-from-guard.rs index 67a2275dcf74f..901b3d0d268c7 100644 --- a/src/test/ui/borrowck/borrowck-drop-from-guard.rs +++ b/src/test/ui/borrowck/borrowck-drop-from-guard.rs @@ -1,4 +1,4 @@ -//compile-flags: -Z borrowck=mir +// compile-flags: -Z borrowck=mir fn foo(_:String) {} diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.rs b/src/test/ui/borrowck/borrowck-lend-flow-if.rs index 1150346f752fa..9e36a8f46e048 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-if.rs @@ -1,7 +1,7 @@ // Note: the borrowck analysis is currently flow-insensitive. // Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter +// corrected by a simple change to the analysis. The others are +// either genuine or would require more advanced changes. The latter // cases are noted. #![feature(box_syntax)] diff --git a/src/test/ui/borrowck/borrowck-lend-flow.rs b/src/test/ui/borrowck/borrowck-lend-flow.rs index 0eb62ede5d65a..e32eaa8a9f19d 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow.rs @@ -1,7 +1,7 @@ // Note: the borrowck analysis is currently flow-insensitive. // Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter +// corrected by a simple change to the analysis. The others are +// either genuine or would require more advanced changes. The latter // cases are noted. #![feature(box_syntax)] diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs index bb0b26ecf0663..88c081aa4dcf0 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs @@ -1,5 +1,5 @@ // Test to ensure we only report an error for the first issued loan that -// conflicts with a new loan, as opposed to every issued loan. This keeps us +// conflicts with a new loan, as opposed to every issued loan. This keeps us // down to O(n) errors (for n problem lines), instead of O(n^2) errors. // revisions: ast mir diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs index 5de8dd3305e37..50c5ae12e9f2e 100644 --- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs +++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs @@ -1,4 +1,4 @@ -//compile-flags: -Z borrowck=mir +// compile-flags: -Z borrowck=mir #![feature(slice_patterns)] diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs index da5bb6366314a..a2547d2a372f1 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs @@ -1,7 +1,7 @@ // revisions: ast mir //[mir]compile-flags: -Z borrowck=mir -// Issue 4691: Ensure that functional-struct-update can only copy, not +// Issue #4691: Ensure that functional-struct-update can only copy, not // move, when the struct implements Drop. struct B; diff --git a/src/test/ui/borrowck/immutable-arg.rs b/src/test/ui/borrowck/immutable-arg.rs index 5a5e619ef31f2..4959b4992bf7b 100644 --- a/src/test/ui/borrowck/immutable-arg.rs +++ b/src/test/ui/borrowck/immutable-arg.rs @@ -1,4 +1,4 @@ -//compile-flags: -Z borrowck=compare +// compile-flags: -Z borrowck=compare fn foo(_x: u32) { _x = 4; diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs index da918ba92b863..fd2686b7f6545 100644 --- a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs +++ b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs @@ -28,9 +28,9 @@ impl<'a, 't> Foo<'a, 't> for &'a isize { //~^ ERROR method not compatible with trait // // Note: This is a terrible error message. It is caused - // because, in the trait, 'b is early bound, and in the impl, - // 'c is early bound, so -- after substitution -- the - // lifetimes themselves look isomorphic. We fail because the + // because, in the trait, 'b is early-bound, and in the impl, + // 'c is early-bound, so -- after substitution -- the + // lifetimes themselves look isomorphic. We fail because the // lifetimes that appear in the types are in the wrong // order. This should really be fixed by keeping more // information about the lifetime declarations in the trait so diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs index 5754220e824f5..314c62422190b 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs @@ -53,7 +53,7 @@ fn should_be_ok_with_nll() { read(z); *y += 1; //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) + // (ok with (generalized) nll today) } fn should_also_eventually_be_ok_with_nll() { @@ -63,7 +63,7 @@ fn should_also_eventually_be_ok_with_nll() { //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) + // (ok with (generalized) nll today) } fn main() { } diff --git a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs index e428964939aff..bb34bd1bdc272 100644 --- a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs +++ b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs @@ -11,7 +11,7 @@ // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ // // It is "artificial". It is meant to illustrate directly that we -// should allow an aliasing access during reservation, but *not* while +// should allow an aliasing access during reservation, but **not** while // the mutable borrow is active. // // The convention for the listed revisions: "lxl" means lexical diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index 1a14cb90f38ef..9078908c7e1af 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -125,13 +125,13 @@ fn double_access(m: &mut [X], s: &[X]) { fn coerce_unsized() { let mut a = [1, 2, 3]; - // This is not okay. + // This is not ok. double_access(&mut a, &a); //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] //[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - // But this is okay. + // But this is ok. a.m(a.i(10)); //[ast]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // Above error is an expected limitation of AST borrowck diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs index 13c1df7db2bc7..ab6f7773ef95a 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs @@ -6,7 +6,7 @@ // Currently, this test fails with lexical lifetimes, but succeeds // with non-lexical lifetimes. (The reason is because the activation // of the mutable borrow ends up overlapping with a lexically-scoped -// shared borrow; but a non-lexical shared borrow can end before the +// shared borrow, but a non-lexical shared borrow can end before the // activation occurs.) // // So this test is just making a note of the current behavior. diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs index f097defa2240e..6c5b3e63f7789 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs @@ -40,7 +40,7 @@ impl <'a> SpanlessHash<'a> { // Accepted by AST-borrowck for erroneous reasons // (rust-lang/rust#38899). // - // Not okay without two-phase borrows: the implicit + // Not ok without two-phase borrows: the implicit // `&mut self` of the receiver is evaluated first, and // that conflicts with the `self.cx`` access during // argument evaluation, as demonstrated in `fn demo` @@ -61,7 +61,7 @@ impl <'a> SpanlessHash<'a> { fn hash_expr_mut(&mut self, e: &Expr) { match *e { Expr::Closure(eid) => { - // Not okay: the call to `self.cx_mut.body(eid)` might + // Not ok: the call to `self.cx_mut.body(eid)` might // hold on to some mutably borrowed state in // `self.cx_mut`, which would then interfere with the // eventual activation of the `self` mutable borrow @@ -110,7 +110,7 @@ impl<'a> Registry<'a> { } fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { - // Not okay without two-phase borrows: The implicit `&mut reg` of + // Not ok without two-phase borrows: The implicit `&mut reg` of // the receiver is evaluaated first, and that conflicts with the // `reg.sess_mut` access during argument evaluation. // @@ -134,7 +134,7 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { //[ast]~^ ERROR cannot borrow `reg.sess_mut` //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - // These are not okay: the inner mutable borrows immediately + // These are not ok: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support // for two-phase borrows. let reg = mk_reg(); @@ -158,7 +158,7 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` - // These are not okay: the inner borrows may reach the actual + // These are not ok: the inner borrows may reach the actual // method invocation, because `CapturePass::new` might (according // to its type) keep them alive. // @@ -180,7 +180,7 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` //[nll]~^^^ ERROR cannot borrow `*reg` as mutable - // These are not okay: the inner mutable borrows immediately + // These are not ok: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support // for two-phase borrows. // diff --git a/src/test/ui/changing-crates.rs b/src/test/ui/changing-crates.rs index 60c043bc43f88..74ade67ebca69 100644 --- a/src/test/ui/changing-crates.rs +++ b/src/test/ui/changing-crates.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:changing-crates-a1.rs // aux-build:changing-crates-b.rs // aux-build:changing-crates-a2.rs diff --git a/src/test/ui/closures/closure-reform-bad.rs b/src/test/ui/closures/closure-reform-bad.rs index 0ba48ab518442..71072e5b77ce3 100644 --- a/src/test/ui/closures/closure-reform-bad.rs +++ b/src/test/ui/closures/closure-reform-bad.rs @@ -1,6 +1,3 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - fn call_bare(f: fn(&str)) { f("Hello "); } @@ -8,5 +5,5 @@ fn call_bare(f: fn(&str)) { fn main() { let string = "world!"; let f = |s: &str| println!("{}{}", s, string); - call_bare(f) //~ ERROR mismatched types + call_bare(f) //~ ERROR mismatched types } diff --git a/src/test/ui/closures/closure-reform-bad.stderr b/src/test/ui/closures/closure-reform-bad.stderr index 76f88d0490745..7948f2d72b71e 100644 --- a/src/test/ui/closures/closure-reform-bad.stderr +++ b/src/test/ui/closures/closure-reform-bad.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/closure-reform-bad.rs:11:15 + --> $DIR/closure-reform-bad.rs:8:15 | -LL | call_bare(f) //~ ERROR mismatched types +LL | call_bare(f) //~ ERROR mismatched types | ^ expected fn pointer, found closure | = note: expected type `for<'r> fn(&'r str)` - found type `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50 string:_]` + found type `[closure@$DIR/closure-reform-bad.rs:7:13: 7:50 string:_]` error: aborting due to previous error diff --git a/src/test/ui/closures/closure-wrong-kind.rs b/src/test/ui/closures/closure-wrong-kind.rs index 9bf38bfb66b62..3e159103436ca 100644 --- a/src/test/ui/closures/closure-wrong-kind.rs +++ b/src/test/ui/closures/closure-wrong-kind.rs @@ -1,12 +1,10 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - struct X; + fn foo(_: T) {} fn bar(_: T) {} fn main() { let x = X; - let closure = |_| foo(x); //~ ERROR E0525 + let closure = |_| foo(x); //~ ERROR E0525 bar(closure); } diff --git a/src/test/ui/closures/closure-wrong-kind.stderr b/src/test/ui/closures/closure-wrong-kind.stderr index b289ea2964426..06f0d93ee7d29 100644 --- a/src/test/ui/closures/closure-wrong-kind.stderr +++ b/src/test/ui/closures/closure-wrong-kind.stderr @@ -1,7 +1,7 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` - --> $DIR/closure-wrong-kind.rs:10:19 + --> $DIR/closure-wrong-kind.rs:8:19 | -LL | let closure = |_| foo(x); //~ ERROR E0525 +LL | let closure = |_| foo(x); //~ ERROR E0525 | ^^^^^^^^-^ | | | | | closure is `FnOnce` because it moves the variable `x` out of its environment diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs index 098a13e54bfb4..fbe174da8c86c 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; use std::default::Default; // Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd +// bounds). After all, some other crate could implement `Even` or `Odd` // for the same type (though this crate doesn't). trait MyTrait { diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs index 5b76fc0174b30..6b83e6663bd0e 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; use std::default::Default; // Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd +// bounds). After all, some other crate could implement `Even` or `Odd` // for the same type (though this crate doesn't implement them at all). trait MyTrait { diff --git a/src/test/ui/compare-method/region-extra-2.rs b/src/test/ui/compare-method/region-extra-2.rs index 3d57b544e16af..11457e4580f2d 100644 --- a/src/test/ui/compare-method/region-extra-2.rs +++ b/src/test/ui/compare-method/region-extra-2.rs @@ -1,4 +1,4 @@ -// Regression test for issue #22779. An extra where clause was +// Regression test for issue #22779. An extra where-clause was // permitted on the impl that is not present on the trait. trait Tr<'a, T> { diff --git a/src/test/ui/compare-method/region-extra.rs b/src/test/ui/compare-method/region-extra.rs index 1070cb84512ec..93eb3ed1b35fd 100644 --- a/src/test/ui/compare-method/region-extra.rs +++ b/src/test/ui/compare-method/region-extra.rs @@ -1,4 +1,4 @@ -// Test that you cannot add an extra where clause in the impl relating +// Test that you cannot add an extra where-clause in the impl relating // two regions. trait Master<'a, 'b> { diff --git a/src/test/ui/compare-method/reordered-type-param.rs b/src/test/ui/compare-method/reordered-type-param.rs index a858b66d760ea..68a0b630a6076 100644 --- a/src/test/ui/compare-method/reordered-type-param.rs +++ b/src/test/ui/compare-method/reordered-type-param.rs @@ -1,19 +1,20 @@ -// Tests that ty params get matched correctly when comparing -// an impl against a trait +// Tests that type params get matched correctly when comparing +// an impl against a trait. // -// cc #26111 +// See issue #26111. trait A { - fn b(&self, x: C) -> C; + fn b(&self, x: C) -> C; } struct E { - f: isize + f: isize } impl A for E { - // n.b. The error message is awful -- see #3404 - fn b(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type + // N.B., this error message is awful (see issue #3404). + fn b(&self, _x: G) -> G { panic!() } + //~^ ERROR method `b` has an incompatible type } fn main() {} diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr index c162c720a48b2..4beebbd4856be 100644 --- a/src/test/ui/compare-method/reordered-type-param.stderr +++ b/src/test/ui/compare-method/reordered-type-param.stderr @@ -1,11 +1,11 @@ error[E0053]: method `b` has an incompatible type for trait - --> $DIR/reordered-type-param.rs:16:30 + --> $DIR/reordered-type-param.rs:16:34 | -LL | fn b(&self, x: C) -> C; - | - type in trait +LL | fn b(&self, x: C) -> C; + | - type in trait ... -LL | fn b(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type - | ^ expected type parameter, found a different type parameter +LL | fn b(&self, _x: G) -> G { panic!() } + | ^ expected type parameter, found a different type parameter | = note: expected type `fn(&E, F) -> F` found type `fn(&E, G) -> G` diff --git a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs index 0dceba28b6ec3..5720639bdafed 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs @@ -1,4 +1,4 @@ -// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 +// See . // compile-flags: --cfg broken diff --git a/src/test/ui/conservative_impl_trait.stderr b/src/test/ui/conservative_impl_trait.stderr index 58223d9d3bf3f..2dba517873508 100644 --- a/src/test/ui/conservative_impl_trait.stderr +++ b/src/test/ui/conservative_impl_trait.stderr @@ -5,7 +5,7 @@ LL | fn will_ice(something: &u32) -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to previous error diff --git a/src/test/ui/constructor-lifetime-args.rs b/src/test/ui/constructor-lifetime-args.rs index 6af5f6d56e7f6..fb218005d34e0 100644 --- a/src/test/ui/constructor-lifetime-args.rs +++ b/src/test/ui/constructor-lifetime-args.rs @@ -1,10 +1,10 @@ -// All lifetime parameters in struct constructors are currently considered early bound, +// All lifetime parameters in struct constructors are currently considered early-bound, // i.e., `S::` is interpreted kinda like an associated item `S::::ctor`. // This behavior is a bit weird, because if equivalent constructor were written manually -// it would get late bound lifetime parameters. +// it would get late-bound lifetime parameters. // Variant constructors behave in the same way, lifetime parameters are considered -// belonging to the enum and being early bound. -// https://github.com/rust-lang/rust/issues/30904 +// belonging to the enum and being early-bound. +// See issue #30904. struct S<'a, 'b>(&'a u8, &'b u8); enum E<'a, 'b> { diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs index 95deb04fb01d5..fdadd47700719 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs @@ -3,7 +3,7 @@ // // This test is checking the count in an array expression. -// FIXME (#23926): the error output is not consistent between a +// FIXME(#23926): the error output is not consistent between a // self-hosted and a cross-compiled setup; therefore resorting to // error-pattern for now. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs index 5a6be0c9bd38b..60d676ce59c35 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs @@ -7,7 +7,7 @@ // types for the left- and right-hand sides of the addition do not // match (as well as overflow). -// FIXME (#23926): the error output is not consistent between a +// FIXME(#23926): the error output is not consistent between a // self-hosted and a cross-compiled setup; therefore resorting to // error-pattern for now. diff --git a/src/test/ui/consts/const-eval/issue-51300.rs b/src/test/ui/consts/const-eval/issue-51300.rs index 72a6072e4b7b4..e7b96e3c524d4 100644 --- a/src/test/ui/consts/const-eval/issue-51300.rs +++ b/src/test/ui/consts/const-eval/issue-51300.rs @@ -1,5 +1,4 @@ // compile-pass -// https://github.com/rust-lang/rust/issues/51300 #[derive(PartialEq, Eq, Clone, Copy)] pub struct Stat { diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs index 13489c50a1223..29585907012f9 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs @@ -113,10 +113,10 @@ const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; // good MySliceBool const I1: &MySliceBool = &MySlice(true, [false]); -// bad: sized field is not okay +// bad: sized field is not ok const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]); //~^ ERROR it is undefined behavior to use this value -// bad: unsized part is not okay +// bad: unsized part is not ok const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]); //~^ ERROR it is undefined behavior to use this value diff --git a/src/test/ui/consts/const-validation-fail-55455.rs b/src/test/ui/consts/const-validation-fail-55455.rs index def4062339f96..2e0ec726a8804 100644 --- a/src/test/ui/consts/const-validation-fail-55455.rs +++ b/src/test/ui/consts/const-validation-fail-55455.rs @@ -1,9 +1,7 @@ -// https://github.com/rust-lang/rust/issues/55454 // compile-pass struct This(T); const C: This> = This(Some(&1)); -fn main() { -} +fn main() {} diff --git a/src/test/ui/consts/const_short_circuit.stderr b/src/test/ui/consts/const_short_circuit.stderr index a67bb0b1b6d98..cd67aede721a4 100644 --- a/src/test/ui/consts/const_short_circuit.stderr +++ b/src/test/ui/consts/const_short_circuit.stderr @@ -4,7 +4,7 @@ error: new features like let bindings are not permitted in constants which also LL | let mut x = true && false; | ^^^^^ | -note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See https://github.com/rust-lang/rust/issues/49146 for more information. +note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See for more information. --> $DIR/const_short_circuit.rs:6:22 | LL | let mut x = true && false; @@ -16,7 +16,7 @@ error: new features like let bindings are not permitted in constants which also LL | let x = true && false; | ^ | -note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See https://github.com/rust-lang/rust/issues/49146 for more information. +note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See for more information. --> $DIR/const_short_circuit.rs:11:18 | LL | let x = true && false; diff --git a/src/test/ui/consts/dangling-alloc-id-ice.rs b/src/test/ui/consts/dangling-alloc-id-ice.rs index dbc50f1fbd4b4..cafb82f65eb95 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.rs +++ b/src/test/ui/consts/dangling-alloc-id-ice.rs @@ -1,4 +1,4 @@ -// https://github.com/rust-lang/rust/issues/55223 +// See issue #55223. union Foo<'a> { y: &'a (), diff --git a/src/test/ui/consts/promoted-validation-55454.rs b/src/test/ui/consts/promoted-validation-55454.rs index 5e193b1b7de0b..f6f4f466ffcaa 100644 --- a/src/test/ui/consts/promoted-validation-55454.rs +++ b/src/test/ui/consts/promoted-validation-55454.rs @@ -1,4 +1,5 @@ -// https://github.com/rust-lang/rust/issues/55454 +// See issue #55454. + // compile-pass #[derive(PartialEq)] diff --git a/src/test/ui/cross/cross-fn-cache-hole.rs b/src/test/ui/cross/cross-fn-cache-hole.rs index 249c6474c9420..d9a7eca4f0857 100644 --- a/src/test/ui/cross/cross-fn-cache-hole.rs +++ b/src/test/ui/cross/cross-fn-cache-hole.rs @@ -10,13 +10,13 @@ trait Foo: Bar { trait Bar { } -// We don't always check where clauses for sanity, but in this case +// We don't always check where-clauses for sanity, but in this case // wfcheck does report an error here: fn vacuous() //~ ERROR the trait bound `i32: Bar` is not satisfied where i32: Foo { // ... the original intention was to check that we don't use that - // vacuous where clause (which could never be satisfied) to accept + // vacuous where-clause (which could never be satisfied) to accept // the following line and then mess up calls elsewhere. require::(); } diff --git a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs index f3df57e6ff911..d8ed3535ed1eb 100644 --- a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs +++ b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs @@ -29,7 +29,7 @@ mod y { pub fn use_char_assoc() { // Careful here: in the representation, ::T gets // normalized away, so at a certain point we had no edge to - // codegen. (But now codegen just depends on typeck.) + // codegen. (But now codegen just depends on typeck.) let x: ::T = 'a'; } diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.rs b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs index 957e839013ec7..43ff98e15530f 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape-inner.rs +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs @@ -1,7 +1,7 @@ // run-pass mod foo { - #![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use + #![macro_escape] //~ WARNING `macro_escape` is a deprecated synonym for `macro_use` } fn main() { diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr index 94229386e5f59..fb45b25bd5ff1 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr @@ -1,8 +1,8 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `macro_escape` is a deprecated synonym for `macro_use` --> $DIR/deprecated-macro_escape-inner.rs:4:5 | -LL | #![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use +LL | #![macro_escape] //~ WARNING `macro_escape` is a deprecated synonym for `macro_use` | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, #[macro_use] mod ... + = help: consider an outer attribute, `#[macro_use] mod ...` diff --git a/src/test/ui/deprecation/deprecated-macro_escape.rs b/src/test/ui/deprecation/deprecated-macro_escape.rs index 1b82a99f42eab..ccbedc8522805 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape.rs +++ b/src/test/ui/deprecation/deprecated-macro_escape.rs @@ -1,6 +1,6 @@ // run-pass -#[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use +#[macro_escape] //~ WARNING `macro_escape` is a deprecated synonym for `macro_use` mod foo { } diff --git a/src/test/ui/deprecation/deprecated-macro_escape.stderr b/src/test/ui/deprecation/deprecated-macro_escape.stderr index f0edd838874e9..c816811fc8675 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape.stderr +++ b/src/test/ui/deprecation/deprecated-macro_escape.stderr @@ -1,6 +1,6 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `macro_escape` is a deprecated synonym for `macro_use` --> $DIR/deprecated-macro_escape.rs:3:1 | -LL | #[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use +LL | #[macro_escape] //~ WARNING `macro_escape` is a deprecated synonym for `macro_use` | ^^^^^^^^^^^^^^^ diff --git a/src/test/ui/derives/deriving-copyclone.rs b/src/test/ui/derives/deriving-copyclone.rs index afe619690711f..7660102794b69 100644 --- a/src/test/ui/derives/deriving-copyclone.rs +++ b/src/test/ui/derives/deriving-copyclone.rs @@ -1,38 +1,40 @@ -// this will get a no-op Clone impl +// This will get a no-op `Clone` impl. #[derive(Copy, Clone)] struct A { a: i32, b: i64 } -// this will get a deep Clone impl +// This will get a no-op `Clone` impl. #[derive(Copy, Clone)] struct B { a: i32, b: T } -struct C; // not Copy or Clone -#[derive(Clone)] struct D; // Clone but not Copy +// Not `Copy` or `Clone`. +struct C; +// `Clone` but not `Copy`. +#[derive(Clone)] +struct D; fn is_copy(_: T) {} fn is_clone(_: T) {} fn main() { - // A can be copied and cloned + // `A` can be copied and cloned. is_copy(A { a: 1, b: 2 }); is_clone(A { a: 1, b: 2 }); - // B can be copied and cloned + // `B` can be copied and cloned. is_copy(B { a: 1, b: 2 }); is_clone(B { a: 1, b: 2 }); - // B cannot be copied or cloned + // `B` cannot be copied or cloned. is_copy(B { a: 1, b: C }); //~ERROR Copy is_clone(B { a: 1, b: C }); //~ERROR Clone - // B can be cloned but not copied + // `B` can be cloned but not copied. is_copy(B { a: 1, b: D }); //~ERROR Copy is_clone(B { a: 1, b: D }); } - diff --git a/src/test/ui/derives/deriving-copyclone.stderr b/src/test/ui/derives/deriving-copyclone.stderr index 0a9fdd34fe2e0..371994dbcd7ef 100644 --- a/src/test/ui/derives/deriving-copyclone.stderr +++ b/src/test/ui/derives/deriving-copyclone.stderr @@ -1,38 +1,38 @@ error[E0277]: the trait bound `C: std::marker::Copy` is not satisfied - --> $DIR/deriving-copyclone.rs:31:5 + --> $DIR/deriving-copyclone.rs:34:5 | LL | is_copy(B { a: 1, b: C }); //~ERROR Copy | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `C` | = note: required because of the requirements on the impl of `std::marker::Copy` for `B` note: required by `is_copy` - --> $DIR/deriving-copyclone.rs:18:1 + --> $DIR/deriving-copyclone.rs:21:1 | LL | fn is_copy(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `C: std::clone::Clone` is not satisfied - --> $DIR/deriving-copyclone.rs:32:5 + --> $DIR/deriving-copyclone.rs:35:5 | LL | is_clone(B { a: 1, b: C }); //~ERROR Clone | ^^^^^^^^ the trait `std::clone::Clone` is not implemented for `C` | = note: required because of the requirements on the impl of `std::clone::Clone` for `B` note: required by `is_clone` - --> $DIR/deriving-copyclone.rs:19:1 + --> $DIR/deriving-copyclone.rs:22:1 | LL | fn is_clone(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `D: std::marker::Copy` is not satisfied - --> $DIR/deriving-copyclone.rs:35:5 + --> $DIR/deriving-copyclone.rs:38:5 | LL | is_copy(B { a: 1, b: D }); //~ERROR Copy | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `D` | = note: required because of the requirements on the impl of `std::marker::Copy` for `B` note: required by `is_copy` - --> $DIR/deriving-copyclone.rs:18:1 + --> $DIR/deriving-copyclone.rs:21:1 | LL | fn is_copy(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/discrim/discrim-overflow-2.rs b/src/test/ui/discrim/discrim-overflow-2.rs index 9ff39cd048454..3feb15f0ec995 100644 --- a/src/test/ui/discrim/discrim-overflow-2.rs +++ b/src/test/ui/discrim/discrim-overflow-2.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -// Issue 23030: Detect overflowing discriminant +// Issue #23030: Detect overflowing discriminant // // Check that we detect the overflow even if enum is not used. diff --git a/src/test/ui/discrim/discrim-overflow.rs b/src/test/ui/discrim/discrim-overflow.rs index c612661178cf6..dbedfa5bec2ee 100644 --- a/src/test/ui/discrim/discrim-overflow.rs +++ b/src/test/ui/discrim/discrim-overflow.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -// Issue 23030: Detect overflowing discriminant +// Issue #23030: Detect overflowing discriminant // See also run-pass/discrim-explicit-23030.rs where the suggested // workaround is tested. diff --git a/src/test/ui/diverging-tuple-parts-39485.rs b/src/test/ui/diverging-tuple-parts-39485.rs index 0cde6119308e5..35bee7339659c 100644 --- a/src/test/ui/diverging-tuple-parts-39485.rs +++ b/src/test/ui/diverging-tuple-parts-39485.rs @@ -1,7 +1,7 @@ // After #39485, this test used to pass, but that change was reverted // due to numerous inference failures like #39808, so it now fails // again. #39485 made it so that diverging types never propagate -// upward; but we now do propagate such types upward in many more +// upward, but we now do propagate such types upward in many more // cases. fn g() { diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.rs b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.rs index 6ca5f5e3c5fcf..1f1e6f49e11f8 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.rs +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.rs @@ -1,4 +1,4 @@ -// Issue 22443: Reject code using non-regular types that would +// Issue #22443: reject code using non-regular types that would // otherwise cause dropck to loop infinitely. use std::marker::PhantomData; @@ -9,19 +9,18 @@ struct Digit { struct Node { m: PhantomData<&'static T> } - enum FingerTree { Single(T), - // Bug report said Digit after Box would stack overflow (versus - // Digit before Box; see dropck_no_diverge_on_nonregular_2). + // Bug report indicated `Digit` after `Box` would stack-overflow (versus + // `Digit` before `Box`; see `dropck_no_diverge_on_nonregular_2`). Deep( Box>>, Digit, - ) + ) } fn main() { - let ft = //~ ERROR overflow while adding drop-check rules for FingerTree - FingerTree::Single(1); - //~^ ERROR overflow while adding drop-check rules for FingerTree + let ft = FingerTree::Single(1); + //~^ ERROR overflow while adding drop-check rules for `FingerTree` [E0320] + //~^^ ERROR overflow while adding drop-check rules for `FingerTree` [E0320] } diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr index 317ac7674311a..a44a849dd31db 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr @@ -1,16 +1,16 @@ -error[E0320]: overflow while adding drop-check rules for FingerTree - --> $DIR/dropck_no_diverge_on_nonregular_1.rs:24:9 +error[E0320]: overflow while adding drop-check rules for `FingerTree` + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:23:9 | -LL | let ft = //~ ERROR overflow while adding drop-check rules for FingerTree +LL | let ft = FingerTree::Single(1); | ^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -error[E0320]: overflow while adding drop-check rules for FingerTree - --> $DIR/dropck_no_diverge_on_nonregular_1.rs:25:9 +error[E0320]: overflow while adding drop-check rules for `FingerTree` + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:23:14 | -LL | FingerTree::Single(1); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | let ft = FingerTree::Single(1); + | ^^^^^^^^^^^^^^^^^^^^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.rs b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.rs index d34f7e326d15f..294794d43153c 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.rs +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.rs @@ -1,4 +1,4 @@ -// Issue 22443: Reject code using non-regular types that would +// Issue #22443: reject code using non-regular types that would // otherwise cause dropck to loop infinitely. use std::marker::PhantomData; @@ -11,16 +11,16 @@ struct Node { m: PhantomData<&'static T> } enum FingerTree { Single(T), - // Bug report said Digit before Box would infinite loop (versus - // Digit after Box; see dropck_no_diverge_on_nonregular_1). + // Bug report indicated `Digit` before `Box` would loop infinitely (versus + // `Digit` before `Box`; see `dropck_no_diverge_on_nonregular_1`). Deep( Digit, Box>>, - ) + ) } fn main() { - let ft = //~ ERROR overflow while adding drop-check rules for FingerTree - FingerTree::Single(1); - //~^ ERROR overflow while adding drop-check rules for FingerTree + let ft = FingerTree::Single(1); + //~^ ERROR overflow while adding drop-check rules for `FingerTree` [E0320] + //~^^ ERROR overflow while adding drop-check rules for `FingerTree` [E0320] } diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.stderr b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.stderr index b87e7a111493e..8a72adfa4026d 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.stderr +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_2.stderr @@ -1,16 +1,16 @@ -error[E0320]: overflow while adding drop-check rules for FingerTree +error[E0320]: overflow while adding drop-check rules for `FingerTree` --> $DIR/dropck_no_diverge_on_nonregular_2.rs:23:9 | -LL | let ft = //~ ERROR overflow while adding drop-check rules for FingerTree +LL | let ft = FingerTree::Single(1); | ^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -error[E0320]: overflow while adding drop-check rules for FingerTree - --> $DIR/dropck_no_diverge_on_nonregular_2.rs:24:9 +error[E0320]: overflow while adding drop-check rules for `FingerTree` + --> $DIR/dropck_no_diverge_on_nonregular_2.rs:23:14 | -LL | FingerTree::Single(1); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | let ft = FingerTree::Single(1); + | ^^^^^^^^^^^^^^^^^^^^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.rs b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.rs index e2e600b17f21e..492ba719ea0e6 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.rs +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.rs @@ -1,4 +1,4 @@ -// Issue 22443: Reject code using non-regular types that would +// Issue #22443: reject code using non-regular types that would // otherwise cause dropck to loop infinitely. // // This version is just checking that we still sanely handle a trivial @@ -6,6 +6,8 @@ // error messages will report different types depending on which type // dropck is analyzing.) +// ignore-tidy-linelength + use std::marker::PhantomData; struct Digit { @@ -16,11 +18,11 @@ struct Node { m: PhantomData<&'static T> } enum FingerTree { Single(T), - // According to the bug report, Digit before Box would infinite loop. + // Bug report indicated `Digit` before `Box` would loop infinitely. Deep( Digit, Box>>, - ) + ) } enum Wrapper { @@ -29,8 +31,8 @@ enum Wrapper { } fn main() { - let w = //~ ERROR overflow while adding drop-check rules for std::option - Some(Wrapper::Simple::); - //~^ ERROR overflow while adding drop-check rules for std::option::Option - //~| ERROR overflow while adding drop-check rules for Wrapper + let w = Some(Wrapper::Simple::); + //~^ ERROR overflow while adding drop-check rules for `std::option::Option>` [E0320] + //~^^ ERROR overflow while adding drop-check rules for `std::option::Option>` [E0320] + //~| ERROR overflow while adding drop-check rules for `Wrapper` [E0320] } diff --git a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.stderr b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.stderr index 799ee45a2022d..9ba629df2b8de 100644 --- a/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.stderr +++ b/src/test/ui/dropck/dropck_no_diverge_on_nonregular_3.stderr @@ -1,24 +1,24 @@ -error[E0320]: overflow while adding drop-check rules for std::option::Option> - --> $DIR/dropck_no_diverge_on_nonregular_3.rs:32:9 +error[E0320]: overflow while adding drop-check rules for `std::option::Option>` + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:34:9 | -LL | let w = //~ ERROR overflow while adding drop-check rules for std::option +LL | let w = Some(Wrapper::Simple::); | ^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -error[E0320]: overflow while adding drop-check rules for std::option::Option> - --> $DIR/dropck_no_diverge_on_nonregular_3.rs:33:9 +error[E0320]: overflow while adding drop-check rules for `std::option::Option>` + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:34:13 | -LL | Some(Wrapper::Simple::); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let w = Some(Wrapper::Simple::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -error[E0320]: overflow while adding drop-check rules for Wrapper - --> $DIR/dropck_no_diverge_on_nonregular_3.rs:33:14 +error[E0320]: overflow while adding drop-check rules for `Wrapper` + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:34:18 | -LL | Some(Wrapper::Simple::); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | let w = Some(Wrapper::Simple::); + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/src/test/ui/dst/dst-bad-assign-2.stderr b/src/test/ui/dst/dst-bad-assign-2.stderr index 4e1e67c7f4809..322fa6b3d6434 100644 --- a/src/test/ui/dst/dst-bad-assign-2.stderr +++ b/src/test/ui/dst/dst-bad-assign-2.stderr @@ -6,7 +6,7 @@ LL | f5.ptr = *z; | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` = note: to learn more, visit - = note: the left-hand-side of an assignment must have a statically known size + = note: the left-hand-side of an assignment must have a statically-known size error: aborting due to previous error diff --git a/src/test/ui/dst/dst-bad-assign-3.stderr b/src/test/ui/dst/dst-bad-assign-3.stderr index 0c4f86613196d..fa581fdad0fc4 100644 --- a/src/test/ui/dst/dst-bad-assign-3.stderr +++ b/src/test/ui/dst/dst-bad-assign-3.stderr @@ -15,7 +15,7 @@ LL | f5.2 = Bar1 {f: 36}; | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` = note: to learn more, visit - = note: the left-hand-side of an assignment must have a statically known size + = note: the left-hand-side of an assignment must have a statically-known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-assign.stderr b/src/test/ui/dst/dst-bad-assign.stderr index a60d9d66f39e6..63f04d7e06038 100644 --- a/src/test/ui/dst/dst-bad-assign.stderr +++ b/src/test/ui/dst/dst-bad-assign.stderr @@ -15,7 +15,7 @@ LL | f5.ptr = Bar1 {f: 36}; | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` = note: to learn more, visit - = note: the left-hand-side of an assignment must have a statically known size + = note: the left-hand-side of an assignment must have a statically-known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-deep-2.stderr b/src/test/ui/dst/dst-bad-deep-2.stderr index cb2735147a35b..a52bc303a115b 100644 --- a/src/test/ui/dst/dst-bad-deep-2.stderr +++ b/src/test/ui/dst/dst-bad-deep-2.stderr @@ -8,7 +8,7 @@ LL | let h: &(([isize],),) = &(*g,); = note: to learn more, visit = note: required because it appears within the type `([isize],)` = note: required because it appears within the type `(([isize],),)` - = note: tuples must have a statically known size to be initialized + = note: tuples must have a statically-known size to be initialized error: aborting due to previous error diff --git a/src/test/ui/dst/dst-bad-deep.stderr b/src/test/ui/dst/dst-bad-deep.stderr index 521adf601cc70..1ecef346479a5 100644 --- a/src/test/ui/dst/dst-bad-deep.stderr +++ b/src/test/ui/dst/dst-bad-deep.stderr @@ -8,7 +8,7 @@ LL | let h: &Fat> = &Fat { ptr: *g }; = note: to learn more, visit = note: required because it appears within the type `Fat<[isize]>` = note: required because it appears within the type `Fat>` - = note: structs must have a statically known size to be initialized + = note: structs must have a statically-known size to be initialized error: aborting due to previous error diff --git a/src/test/ui/e0119/auxiliary/complex_impl_support.rs b/src/test/ui/e0119/auxiliary/complex_impl_support.rs index ad5bb107fc6e7..ad0d9e23814e4 100644 --- a/src/test/ui/e0119/auxiliary/complex_impl_support.rs +++ b/src/test/ui/e0119/auxiliary/complex_impl_support.rs @@ -16,7 +16,7 @@ where 'b: 'a, T: 'a, U: (FnOnce(T) -> V) + 'static, - V: Iterator + Clone, + V: Iterator + Clone, W: std::ops::Add, W::Output: Copy, {} diff --git a/src/test/ui/e0119/auxiliary/issue_23563_a.rs b/src/test/ui/e0119/auxiliary/issue_23563_a.rs index 4e85bcc4ba623..860ae65fd5272 100644 --- a/src/test/ui/e0119/auxiliary/issue_23563_a.rs +++ b/src/test/ui/e0119/auxiliary/issue_23563_a.rs @@ -1,4 +1,4 @@ -// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672 +// See . pub trait LolTo { fn convert_to(&self) -> T; diff --git a/src/test/ui/e0119/issue-23563.rs b/src/test/ui/e0119/issue-23563.rs index a2804fcf1cc55..c312184946025 100644 --- a/src/test/ui/e0119/issue-23563.rs +++ b/src/test/ui/e0119/issue-23563.rs @@ -1,6 +1,6 @@ // aux-build:issue_23563_a.rs -// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672 +// See . extern crate issue_23563_a as a; diff --git a/src/test/ui/e0119/so-37347311.rs b/src/test/ui/e0119/so-37347311.rs index d5f624bc4d972..256fb37c85bf4 100644 --- a/src/test/ui/e0119/so-37347311.rs +++ b/src/test/ui/e0119/so-37347311.rs @@ -1,4 +1,4 @@ -// Ref: https://stackoverflow.com/q/37347311 +// See . trait Storage { type Error; diff --git a/src/test/ui/enum/enum-discrim-too-small.rs b/src/test/ui/enum/enum-discrim-too-small.rs index e498414020b41..40df007225434 100644 --- a/src/test/ui/enum/enum-discrim-too-small.rs +++ b/src/test/ui/enum/enum-discrim-too-small.rs @@ -30,9 +30,9 @@ enum Eu64 { //~^ ERROR cannot apply unary operator `-` to type `u64` } -// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a -// little counterintuitive, but since the discriminant can store all the bits, and extracting it +// `u64` currently allows negative numbers, and `i64` allows numbers greater than `1 << 63`. This is +// a little counter-intuitive, but since the discriminant can store all the bits, and extracting it // with a cast requires specifying the signedness, there is no loss of information in those cases. // This also applies to isize and usize on 64-bit targets. -pub fn main() { } +pub fn main() {} diff --git a/src/test/ui/enum/enum-discrim-too-small2.rs b/src/test/ui/enum/enum-discrim-too-small2.rs index af60564302599..788bcca7f37e5 100644 --- a/src/test/ui/enum/enum-discrim-too-small2.rs +++ b/src/test/ui/enum/enum-discrim-too-small2.rs @@ -29,8 +29,8 @@ enum Ei64 { Ci64 = 9223372036854775809, //~ ERROR literal out of range for i64 } -// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a -// little counterintuitive, but since the discriminant can store all the bits, and extracting it +// `u64` currently allows negative numbers, and `i64` allows numbers greater than `1 << 63`. This is +// a little counter-intuitive, but since the discriminant can store all the bits, and extracting it // with a cast requires specifying the signedness, there is no loss of information in those cases. // This also applies to isize and usize on 64-bit targets. diff --git a/src/test/ui/error-codes/E0128.rs b/src/test/ui/error-codes/E0128.rs index f42c32b91cc06..1e47340888af6 100644 --- a/src/test/ui/error-codes/E0128.rs +++ b/src/test/ui/error-codes/E0128.rs @@ -1,7 +1,6 @@ -struct Foo { //~ ERROR E0128 +struct Foo { //~ ERROR E0128 field1: T, field2: U, } -fn main() { -} +fn main() {} diff --git a/src/test/ui/error-codes/E0128.stderr b/src/test/ui/error-codes/E0128.stderr index 9ea3c09e63f53..a8d27e22788ae 100644 --- a/src/test/ui/error-codes/E0128.stderr +++ b/src/test/ui/error-codes/E0128.stderr @@ -1,8 +1,8 @@ error[E0128]: type parameters with a default cannot use forward declared identifiers - --> $DIR/E0128.rs:1:14 + --> $DIR/E0128.rs:1:16 | -LL | struct Foo { //~ ERROR E0128 - | ^ defaulted type parameters cannot be forward declared +LL | struct Foo { //~ ERROR E0128 + | ^ defaulted type parameters cannot be forward declared error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0229.rs b/src/test/ui/error-codes/E0229.rs index 4c1934107a6d6..20b08399cafef 100644 --- a/src/test/ui/error-codes/E0229.rs +++ b/src/test/ui/error-codes/E0229.rs @@ -10,7 +10,7 @@ impl Foo for isize { fn boo(&self) -> usize { 42 } } -fn baz(x: &>::A) {} +fn baz(x: &>::A) {} //~^ ERROR associated type bindings are not allowed here [E0229] fn main() { diff --git a/src/test/ui/error-codes/E0229.stderr b/src/test/ui/error-codes/E0229.stderr index 46793314bf9f9..6a64110bc8c12 100644 --- a/src/test/ui/error-codes/E0229.stderr +++ b/src/test/ui/error-codes/E0229.stderr @@ -1,8 +1,8 @@ error[E0229]: associated type bindings are not allowed here --> $DIR/E0229.rs:13:25 | -LL | fn baz(x: &>::A) {} - | ^^^^^ associated type not allowed here +LL | fn baz(x: &>::A) {} + | ^^^^^^^ associated type not allowed here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index e5e416da883de..76619d9baa728 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -7,7 +7,7 @@ LL | fn f(p: Path) { } = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `std::path::Path` - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the trait bound `i32: Foo` is not satisfied diff --git a/src/test/ui/error-codes/E0393.rs b/src/test/ui/error-codes/E0393.rs index bdd4deafc838e..55104419155c2 100644 --- a/src/test/ui/error-codes/E0393.rs +++ b/src/test/ui/error-codes/E0393.rs @@ -1,7 +1,6 @@ -trait A {} +trait A {} fn together_we_will_rule_the_galaxy(son: &A) {} //~^ ERROR E0393 -fn main() { -} +fn main() {} diff --git a/src/test/ui/error-codes/E0582.rs b/src/test/ui/error-codes/E0582.rs index ff25012d0f925..265bdb8f4b288 100644 --- a/src/test/ui/error-codes/E0582.rs +++ b/src/test/ui/error-codes/E0582.rs @@ -1,4 +1,4 @@ -// This test was derived from the wasm and parsell crates. They +// This test was derived from the wasm and parsell crates. They // stopped compiling when #32330 is fixed. #![allow(dead_code, unused_variables)] @@ -33,10 +33,9 @@ fn bar(t: F) fn baz(t: F) // No type can satisfy this requirement, since `'a` does not // appear in any of the input types: - where F: for<'a> Iterator + where F: for<'a> Iterator //~^ ERROR E0582 { } -fn main() { -} +fn main() {} diff --git a/src/test/ui/error-codes/E0582.stderr b/src/test/ui/error-codes/E0582.stderr index 81a2f004653d2..bdd6a223319ac 100644 --- a/src/test/ui/error-codes/E0582.stderr +++ b/src/test/ui/error-codes/E0582.stderr @@ -7,8 +7,8 @@ LL | where F: for<'a> Fn() -> Option<&'a i32> error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types --> $DIR/E0582.rs:36:31 | -LL | where F: for<'a> Iterator - | ^^^^^^^^^^^^ +LL | where F: for<'a> Iterator + | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs index c58744d386ca5..43992daa5961f 100644 --- a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs +++ b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs @@ -2,7 +2,7 @@ // bound in a closure (rather than suggesting a change to the signature // of the closure, which is not specified in `foo` but rather in `invoke`). -// FIXME - This might be better as a UI test, but the finer details +// FIXME: - This might be better as a UI test, but the finer details // of the error seem to vary on different machines. fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32 where F: FnOnce(&'a i32, &i32) -> &'a i32 diff --git a/src/test/ui/error-codes/E0646.stderr b/src/test/ui/error-codes/E0646.stderr index 502200c1d008e..9eec49544fd66 100644 --- a/src/test/ui/error-codes/E0646.stderr +++ b/src/test/ui/error-codes/E0646.stderr @@ -1,8 +1,8 @@ -error[E0646]: `main` function is not allowed to have a `where` clause +error[E0646]: `main` function is not allowed to have a where-clause --> $DIR/E0646.rs:1:17 | LL | fn main() where (): Copy {} //~ ERROR [E0646] - | ^^^^^^^^ `main` cannot have a `where` clause + | ^^^^^^^^ `main` cannot have a where-clause error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0647.stderr b/src/test/ui/error-codes/E0647.stderr index da9ba5bf34bcf..6b8137a2f660e 100644 --- a/src/test/ui/error-codes/E0647.stderr +++ b/src/test/ui/error-codes/E0647.stderr @@ -1,8 +1,8 @@ -error[E0647]: start function is not allowed to have a `where` clause +error[E0647]: start function is not allowed to have a where-clause --> $DIR/E0647.rs:7:56 | LL | fn start(_: isize, _: *const *const u8) -> isize where (): Copy { //~ ERROR [E0647] - | ^^^^^^^^ start function cannot have a `where` clause + | ^^^^^^^^ start function cannot have a where-clause error: aborting due to previous error diff --git a/src/test/ui/existential_types/generic_underconstrained.stderr b/src/test/ui/existential_types/generic_underconstrained.stderr index 57924e0ce2131..48a07e8fd94cf 100644 --- a/src/test/ui/existential_types/generic_underconstrained.stderr +++ b/src/test/ui/existential_types/generic_underconstrained.stderr @@ -5,7 +5,7 @@ LL | existential type Underconstrained: 'static; //~ ERROR the trait b | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | = help: consider adding a `where T: Trait` bound - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to previous error diff --git a/src/test/ui/existential_types/generic_underconstrained2.stderr b/src/test/ui/existential_types/generic_underconstrained2.stderr index c7b6d6ade557c..028369cb23ebe 100644 --- a/src/test/ui/existential_types/generic_underconstrained2.stderr +++ b/src/test/ui/existential_types/generic_underconstrained2.stderr @@ -6,7 +6,7 @@ LL | existential type Underconstrained: 'static; | = help: the trait `std::fmt::Debug` is not implemented for `U` = help: consider adding a `where U: std::fmt::Debug` bound - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error[E0277]: `V` doesn't implement `std::fmt::Debug` --> $DIR/generic_underconstrained2.rs:13:1 @@ -16,7 +16,7 @@ LL | existential type Underconstrained2: 'static; | = help: the trait `std::fmt::Debug` is not implemented for `V` = help: consider adding a `where V: std::fmt::Debug` bound - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to 2 previous errors diff --git a/src/test/ui/existential_types/no_inferrable_concrete_type.rs b/src/test/ui/existential_types/no_inferrable_concrete_type.rs index 6bbe8bdc0cd6d..585eebce228ea 100644 --- a/src/test/ui/existential_types/no_inferrable_concrete_type.rs +++ b/src/test/ui/existential_types/no_inferrable_concrete_type.rs @@ -1,11 +1,11 @@ -// Issue 52985: Cause cycle error if user code provides no use case that allows an existential type +// Issue #52985: Cause cycle error if user code provides no use case that allows an existential type // to be inferred to a concrete type. This results in an infinite cycle during type normalization. #![feature(existential_type)] existential type Foo: Copy; //~ cycle detected -// make compiler happy about using 'Foo' +// Make compiler happy about using `Foo`. fn bar(x: Foo) -> Foo { x } fn main() { diff --git a/src/test/ui/explore-issue-38412.rs b/src/test/ui/explore-issue-38412.rs index cd0a69b0d8b8e..07a8b2520ea61 100644 --- a/src/test/ui/explore-issue-38412.rs +++ b/src/test/ui/explore-issue-38412.rs @@ -3,7 +3,7 @@ #![feature(unused_feature)] // A big point of this test is that we *declare* `unstable_declared`, -// but do *not* declare `unstable_undeclared`. This way we can check +// but do **not** declare `unstable_undeclared`. This way we can check // that the compiler is letting in uses of declared feature-gated // stuff but still rejecting uses of undeclared feature-gated stuff. #![feature(unstable_declared)] diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs index b1a8cba1676bd..0ab512adc8a22 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs @@ -12,7 +12,7 @@ // the change when it happens. // // At the time of authoring, the attributes here are listed in the -// order that they occur in libsyntax/feature_gate.rs. +// order that they occur in `libsyntax/feature_gate.rs`. // // Any builtin attributes that: // @@ -20,7 +20,7 @@ // // - could not be included here covering the same cases as the other // attributes without raising an *error* from rustc (note though -// that warnings are of course expected) +// that warnings are of course expected), // // have their own test case referenced by filename in an inline // comment. @@ -39,44 +39,45 @@ #![allow(x5300)] //~ WARN unknown lint: `x5300` #![forbid(x5200)] //~ WARN unknown lint: `x5200` #![deny(x5100)] //~ WARN unknown lint: `x5100` -#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs) +#![macro_use] // (allowed if no argument; see `issue-43160-gating-of-macro_use.rs`) #![macro_export] //~ WARN unused attribute #![plugin_registrar] //~ WARN unused attribute -// skipping testing of cfg -// skipping testing of cfg_attr +// Skipping testing of `cfg`. +// Skipping testing of `cfg_attr`. #![main] //~ WARN unused attribute #![start] //~ WARN unused attribute -// see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200" -// see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100" +// See `issue-43106-gating-of-test.rs for crate-level, but non crate-level is below at "4200". +// See `issue-43106-gating-of-bench.rs` for crate-level, but non crate-level is below at "4100". #![repr()] //~^ WARN unused attribute #![path = "3800"] //~ WARN unused attribute #![automatically_derived] //~ WARN unused attribute #![no_mangle] #![no_link] //~ WARN unused attribute -// see issue-43106-gating-of-derive.rs +// See `issue-43106-gating-of-derive.rs`. #![should_panic] //~ WARN unused attribute #![ignore] //~ WARN unused attribute #![no_implicit_prelude] #![reexport_test_harness_main = "2900"] -// see gated-link-args.rs -// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700" -// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600") +// See `gated-link-args.rs`. +// See `issue-43106-gating-of-macro_escape.rs` for crate-level, but non crate-level is below at +// "2700". +// (Cannot easily test gating of crate-level `#[no_std]`, but non crate-level is below at "2600".) #![proc_macro_derive()] //~ WARN unused attribute #![doc = "2400"] #![cold] #![export_name = "2200"] -// see issue-43106-gating-of-inline.rs +// See `issue-43106-gating-of-inline.rs`. #![link()] #![link_name = "1900"] #![link_section = "1800"] -#![no_builtins] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "0300") -#![no_mangle] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "3500") +#![no_builtins] // Yikes, dupe'd on `BUILTIN_ATTRIBUTES` list (see "0300") +#![no_mangle] // Yikes, dupe'd on `BUILTIN_ATTRIBUTES` list (see "3500") // see issue-43106-gating-of-rustc_deprecated.rs #![must_use] -// see issue-43106-gating-of-stable.rs -// see issue-43106-gating-of-unstable.rs -// see issue-43106-gating-of-deprecated.rs +// See `issue-43106-gating-of-stable.rs`. +// See `issue-43106-gating-of-unstable.rs. +// See issue-43106-gating-of-deprecated.rs`. #![windows_subsystem = "1000"] // UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES @@ -84,14 +85,14 @@ #![crate_name = "0900"] #![crate_type = "bin"] // cannot pass "0800" here -// For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test) +// For `#![crate_id]`, see issue #43142. (I cannot bear to enshrine current behavior in a test.) -// FIXME(#44232) we should warn that this isn't used. +// FIXME(#44232): we should warn that this isn't used. #![feature(rust1)] -// For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test) +// For `#![no_start]`, see issue #43144. (I cannot bear to enshrine current behavior in a test.) -// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400") +// (Cannot easily gate state of crate-level `#[no_main]`, but non crate-level is below at "0400") #![no_builtins] #![recursion_limit = "0200"] #![type_length_limit = "0100"] @@ -216,7 +217,7 @@ mod plugin_registrar { mod inner { #![plugin_registrar] } //~^ WARN unused attribute - // for `fn f()` case, see gated-plugin_registrar.rs + // For `fn f()` case, see `gated-plugin_registrar.rs`. #[plugin_registrar] struct S; //~^ WARN unused attribute @@ -234,7 +235,7 @@ mod main { mod inner { #![main] } //~^ WARN unused attribute - // for `fn f()` case, see feature-gate-main.rs + // For `fn f()` case, see `feature-gate-main.rs`. #[main] struct S; //~^ WARN unused attribute @@ -252,7 +253,7 @@ mod start { mod inner { #![start] } //~^ WARN unused attribute - // for `fn f()` case, see feature-gate-start.rs + // For `fn f()` case, see `feature-gate-start.rs`. #[start] struct S; //~^ WARN unused attribute @@ -265,7 +266,7 @@ mod start { } // At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[test] attributes seem to be ignored. +// non-crate-level `#[test]` attributes seem to be ignored. #[test] mod test { mod inner { #![test] } @@ -280,7 +281,7 @@ mod test { mod inner { #![test] } } // At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[bench] attributes seem to be ignored. +// non-crate-level `#[bench]` attributes seem to be ignored. #[bench] mod bench { @@ -455,10 +456,10 @@ mod reexport_test_harness_main { // Cannot feed "2700" to `#[macro_escape]` without signaling an error. #[macro_escape] -//~^ WARN macro_escape is a deprecated synonym for macro_use +//~^ WARN `macro_escape` is a deprecated synonym for `macro_use` mod macro_escape { mod inner { #![macro_escape] } - //~^ WARN macro_escape is a deprecated synonym for macro_use + //~^ WARN `macro_escape` is a deprecated synonym for `macro_use` #[macro_escape] fn f() { } //~^ WARN unused attribute @@ -498,9 +499,9 @@ mod no_std { //~| WARN crate-level attribute should be an inner attribute } -// At time of authorship, #[proc_macro_derive = "2500"] signals error -// when it occurs on a mod (apart from crate-level). Therefore it goes -// into its own file; see issue-43106-gating-of-proc_macro_derive.rs +// At time of authorship, `#[proc_macro_derive = "2500"]` signals error +// when it occurs on a mod (apart from crate-level). Therefore, it goes +// into its own file; see `issue-43106-gating-of-proc_macro_derive.rs`. #[doc = "2400"] mod doc { diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr index 4d15ccb300a87..6a873bb5ae7bd 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr @@ -29,165 +29,165 @@ LL | #![deny(x5100)] //~ WARN unknown lint: `x5100` | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:101:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:102:8 | LL | #[warn(x5400)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:104:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:105:25 | LL | mod inner { #![warn(x5400)] } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:107:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:108:12 | LL | #[warn(x5400)] fn f() { } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:110:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:111:12 | LL | #[warn(x5400)] struct S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:113:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:114:12 | LL | #[warn(x5400)] type T = S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:116:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:117:12 | LL | #[warn(x5400)] impl S { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:120:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:121:9 | LL | #[allow(x5300)] | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:123:26 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:124:26 | LL | mod inner { #![allow(x5300)] } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:126:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:127:13 | LL | #[allow(x5300)] fn f() { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:129:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:130:13 | LL | #[allow(x5300)] struct S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:132:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:133:13 | LL | #[allow(x5300)] type T = S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:135:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:136:13 | LL | #[allow(x5300)] impl S { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:139:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:140:10 | LL | #[forbid(x5200)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:142:27 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:143:27 | LL | mod inner { #![forbid(x5200)] } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:145:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:146:14 | LL | #[forbid(x5200)] fn f() { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:148:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:149:14 | LL | #[forbid(x5200)] struct S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:151:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:152:14 | LL | #[forbid(x5200)] type T = S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:154:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:155:14 | LL | #[forbid(x5200)] impl S { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:158:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:159:8 | LL | #[deny(x5100)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:161:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:162:25 | LL | mod inner { #![deny(x5100)] } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:164:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:165:12 | LL | #[deny(x5100)] fn f() { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:167:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:168:12 | LL | #[deny(x5100)] struct S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:170:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:171:12 | LL | #[deny(x5100)] type T = S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:173:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:174:12 | LL | #[deny(x5100)] impl S { } | ^^^^^ -warning: macro_escape is a deprecated synonym for macro_use - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:457:1 +warning: `macro_escape` is a deprecated synonym for `macro_use` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:458:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ -warning: macro_escape is a deprecated synonym for macro_use - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:460:17 +warning: `macro_escape` is a deprecated synonym for `macro_use` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:461:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, #[macro_use] mod ... + = help: consider an outer attribute, `#[macro_use] mod ...` warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:181:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:182:5 | LL | #[macro_use] fn f() { } | ^^^^^^^^^^^^ @@ -199,913 +199,913 @@ LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:184:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:185:5 | LL | #[macro_use] struct S; | ^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:187:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:188:5 | LL | #[macro_use] type T = S; | ^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:190:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:191:5 | LL | #[macro_use] impl S { } | ^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:197:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:17 | LL | mod inner { #![macro_export] } | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:200:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:201:5 | LL | #[macro_export] fn f() { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:203:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:204:5 | LL | #[macro_export] struct S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:206:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:207:5 | LL | #[macro_export] type T = S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:209:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:210:5 | LL | #[macro_export] impl S { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:194:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:195:1 | LL | #[macro_export] | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:217:17 | LL | mod inner { #![plugin_registrar] } | ^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:221:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:222:5 | LL | #[plugin_registrar] struct S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:224:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:225:5 | LL | #[plugin_registrar] type T = S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:227:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:228:5 | LL | #[plugin_registrar] impl S { } | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:213:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:214:1 | LL | #[plugin_registrar] | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:234:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:235:17 | LL | mod inner { #![main] } | ^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:239:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:240:5 | LL | #[main] struct S; | ^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:242:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:243:5 | LL | #[main] type T = S; | ^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:245:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:246:5 | LL | #[main] impl S { } | ^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:231:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:232:1 | LL | #[main] | ^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:252:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:253:17 | LL | mod inner { #![start] } | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:257:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:258:5 | LL | #[start] struct S; | ^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:260:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:261:5 | LL | #[start] type T = S; | ^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:263:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:264:5 | LL | #[start] impl S { } | ^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:249:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:250:1 | LL | #[start] | ^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:316:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:317:5 | LL | #[path = "3800"] fn f() { } | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:319:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:320:5 | LL | #[path = "3800"] struct S; | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:322:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:323:5 | LL | #[path = "3800"] type T = S; | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:325:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:5 | LL | #[path = "3800"] impl S { } | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:333:17 | LL | mod inner { #![automatically_derived] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:335:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:336:5 | LL | #[automatically_derived] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:338:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:339:5 | LL | #[automatically_derived] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:341:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:342:5 | LL | #[automatically_derived] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:345:5 | LL | #[automatically_derived] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:329:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:330:1 | LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:364:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:17 | LL | mod inner { #![no_link] } | ^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:367:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:368:5 | LL | #[no_link] fn f() { } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:370:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:371:5 | LL | #[no_link] struct S; | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:374:5 | LL | #[no_link]type T = S; | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:376:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:377:5 | LL | #[no_link] impl S { } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:361:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:362:1 | LL | #[no_link] | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:383:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:384:17 | LL | mod inner { #![should_panic] } | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:386:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:387:5 | LL | #[should_panic] fn f() { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:389:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:390:5 | LL | #[should_panic] struct S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:393:5 | LL | #[should_panic] type T = S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:395:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:396:5 | LL | #[should_panic] impl S { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:381:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:402:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:403:17 | LL | mod inner { #![ignore] } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:405:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:5 | LL | #[ignore] fn f() { } | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:408:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:409:5 | LL | #[ignore] struct S; | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:411:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:5 | LL | #[ignore] type T = S; | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:414:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:415:5 | LL | #[ignore] impl S { } | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:399:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:400:1 | LL | #[ignore] | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:421:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:422:17 | LL | mod inner { #![no_implicit_prelude] } | ^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:424:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:425:5 | LL | #[no_implicit_prelude] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:428:5 | LL | #[no_implicit_prelude] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:430:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:431:5 | LL | #[no_implicit_prelude] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:434:5 | LL | #[no_implicit_prelude] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:418:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:419:1 | LL | #[no_implicit_prelude] | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:440:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:441:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:443:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:444:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:446:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:447:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:449:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:450:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:452:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:453:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:437:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:463:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:464:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:466:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:467:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:470:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:472:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:485:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:485:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:489:5 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:489:5 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:492:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:492:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:477:1 | LL | #[no_std] | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:477:1 | LL | #[no_std] | ^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:640:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:640:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:643:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:643:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:647:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:648:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:647:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:648:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:660:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:661:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:660:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:661:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:668:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:668:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:672:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:672:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:656:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:657:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:656:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:657:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:686:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:686:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:689:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:690:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:689:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:690:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:693:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:693:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:698:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:698:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:702:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:702:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:719:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:719:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:1 | LL | #[no_main] | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:1 | LL | #[no_main] | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:749:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:749:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:761:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:761:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:766:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:766:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:774:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:775:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:774:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:775:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:778:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:778:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:787:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:787:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:791:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:791:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1171,7 +1171,7 @@ LL | #![ignore] //~ WARN unused attribute | ^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:65:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 | LL | #![proc_macro_derive()] //~ WARN unused attribute | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs b/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs index 360d570b65061..d88b79305c4dd 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs @@ -3,7 +3,7 @@ // crate-level `#![deprecated]` causes all that crate's item // definitions to be deprecated, which is a pain to work with.) // -// (For non-crate-level cases, see issue-43106-gating-of-builtin-attrs.rs) +// For non-crate-level cases, see `issue-43106-gating-of-builtin-attrs.rs`. // compile-pass // skip-codegen diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs index 98ca3444c91bd..5dcb666a1e241 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs @@ -1,11 +1,11 @@ // Testing that crate-level `#![macro_escape]` is not gated beyond a -// depecation warning. This file sits on its own, because crate-level +// depecation warning. This file sits on its own, because crate-level // `#![macro_escape]` is incompatible with crate-level `#![macro_use]` // already present in issue-43106-gating-of-builtin-attrs. // compile-pass #![macro_escape] -//~^ WARN macro_escape is a deprecated synonym for macro_use +//~^ WARN `macro_escape` is a deprecated synonym for `macro_use` fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr index 9fb9633d9a86a..9156081c7bf4f 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr @@ -1,8 +1,8 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `macro_escape` is a deprecated synonym for `macro_use` --> $DIR/issue-43106-gating-of-macro_escape.rs:8:1 | LL | #![macro_escape] | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, #[macro_use] mod ... + = help: consider an outer attribute, `#[macro_use] mod ...` diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs index 725f2e0b9d008..87f1bd2daac0e 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs @@ -4,13 +4,13 @@ // get that warning; see issue-43106-gating-of-builtin-attrs.rs #![macro_use(my_macro)] -//~^ ERROR arguments to macro_use are not allowed here +//~^ ERROR arguments to `macro_use` are not allowed here #[macro_use(my_macro)] -//~^ ERROR arguments to macro_use are not allowed here +//~^ ERROR arguments to `macro_use` are not allowed here mod macro_escape { mod inner { #![macro_use(my_macro)] } - //~^ ERROR arguments to macro_use are not allowed here + //~^ ERROR arguments to `macro_use` are not allowed here #[macro_use = "2700"] struct S; //~^ ERROR attribute must be of the form diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr index 8074528c0e060..c7170670804e5 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr @@ -1,16 +1,16 @@ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:6:1 | LL | #![macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^^ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:9:1 | LL | #[macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:12:17 | LL | mod inner { #![macro_use(my_macro)] } diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs index 17548d7b9e88c..4da9a2c9908dd 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs @@ -5,7 +5,7 @@ trait PointerFamily { //~^ ERROR generic associated types are unstable type Pointer2: Deref where T: Clone, U: Clone; //~^ ERROR generic associated types are unstable - //~| ERROR where clauses on associated types are unstable + //~| ERROR where-clauses on associated types are unstable } struct Foo; @@ -19,12 +19,12 @@ impl PointerFamily for Foo { trait Bar { type Assoc where Self: Sized; - //~^ ERROR where clauses on associated types are unstable + //~^ ERROR where-clauses on associated types are unstable } impl Bar for Foo { type Assoc where Self: Sized = Foo; - //~^ ERROR where clauses on associated types are unstable + //~^ ERROR where-clauses on associated types are unstable } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr index 8a207c966cdab..733731d351a87 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr @@ -14,7 +14,7 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error[E0658]: where clauses on associated types are unstable (see issue #44265) +error[E0658]: where-clauses on associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:6:5 | LL | type Pointer2: Deref where T: Clone, U: Clone; @@ -38,7 +38,7 @@ LL | type Pointer2 = Box; | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error[E0658]: where clauses on associated types are unstable (see issue #44265) +error[E0658]: where-clauses on associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:21:5 | LL | type Assoc where Self: Sized; @@ -46,7 +46,7 @@ LL | type Assoc where Self: Sized; | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error[E0658]: where clauses on associated types are unstable (see issue #44265) +error[E0658]: where-clauses on associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:26:5 | LL | type Assoc where Self: Sized = Foo; diff --git a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs index 65792a74ea4d5..06389ec834b2c 100644 --- a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs +++ b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs @@ -1,4 +1,4 @@ -// Needs an explicit where clause stating outlives condition. (RFC 2093) +// Needs an explicit where-clause stating outlives condition. (RFC 2093) // Type T needs to outlive lifetime 'static. struct Foo { diff --git a/src/test/ui/feature-gates/feature-gate-negate-unsigned.rs b/src/test/ui/feature-gates/feature-gate-negate-unsigned.rs index 05e04f3e2b48c..06e98ab936e17 100644 --- a/src/test/ui/feature-gates/feature-gate-negate-unsigned.rs +++ b/src/test/ui/feature-gates/feature-gate-negate-unsigned.rs @@ -14,5 +14,5 @@ fn main() { let _y = -x; //~^ ERROR cannot apply unary operator `-` to type `u8` - -S; // should not trigger the gate; issue 26840 + -S; // should not trigger the gate; issue #26840 } diff --git a/src/test/ui/feature-gates/feature-gate-plugin_registrar.rs b/src/test/ui/feature-gates/feature-gate-plugin_registrar.rs index 0e357f89d14a6..232522309f59c 100644 --- a/src/test/ui/feature-gates/feature-gate-plugin_registrar.rs +++ b/src/test/ui/feature-gates/feature-gate-plugin_registrar.rs @@ -1,8 +1,9 @@ // Test that `#[plugin_registrar]` attribute is gated by `plugin_registrar` // feature gate. -// the registration function isn't typechecked yet +// The registration function isn't type-checked yet. #[plugin_registrar] pub fn registrar() {} //~^ ERROR compiler plugins are experimental + fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-simd.rs b/src/test/ui/feature-gates/feature-gate-simd.rs index d01d33de28988..5fbe2c81368fd 100644 --- a/src/test/ui/feature-gates/feature-gate-simd.rs +++ b/src/test/ui/feature-gates/feature-gate-simd.rs @@ -1,4 +1,4 @@ -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[repr(simd)] //~ ERROR SIMD types are experimental struct RGBA { diff --git a/src/test/ui/feature-gates/feature-gate-thread_local.rs b/src/test/ui/feature-gates/feature-gate-thread_local.rs index 0efae1f6bc356..01dcdb19e2712 100644 --- a/src/test/ui/feature-gates/feature-gate-thread_local.rs +++ b/src/test/ui/feature-gates/feature-gate-thread_local.rs @@ -1,7 +1,7 @@ // Test that `#[thread_local]` attribute is gated by `thread_local` // feature gate. // -// (Note that the `thread_local!` macro is explicitly *not* gated; it +// (Note that the `thread_local!` macro is explicitly **not** gated; it // is given permission to expand into this unstable attribute even // when the surrounding context does not have permission to use it.) diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs index e5028f2f8aa78..87c4c295abab2 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -33,7 +33,7 @@ fn f() where i32: Foo //~ ERROR generic_function(5i32); } -fn use_op(s: String) -> String where String: ::std::ops::Neg { //~ ERROR +fn use_op(s: String) -> String where String: ::std::ops::Neg { //~ ERROR -s } diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index 1f35efa59b690..12006096c7197 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -67,7 +67,7 @@ LL | | } error[E0277]: the trait bound `std::string::String: std::ops::Neg` is not satisfied --> $DIR/feature-gate-trivial_bounds.rs:36:1 | -LL | / fn use_op(s: String) -> String where String: ::std::ops::Neg { //~ ERROR +LL | / fn use_op(s: String) -> String where String: ::std::ops::Neg { //~ ERROR LL | | -s LL | | } | |_^ the trait `std::ops::Neg` is not implemented for `std::string::String` diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index bde39cbeaeb28..844c07b756a77 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -6,7 +6,7 @@ LL | fn f(f: FnOnce()) {} | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.rs b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.rs index a9d7d9c8aa903..f985c88a0c09b 100644 --- a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.rs +++ b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.rs @@ -1,4 +1,4 @@ -// issue 7327 +// Test for issue #7327. use std::sync::Arc; diff --git a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs index 7ae53020fe011..e189ebc2088b3 100644 --- a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs +++ b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs @@ -1,7 +1,7 @@ -// RFC 736 (and Issue 21407): functional struct update should respect privacy. +// RFC #736 (and issue #21407): functional struct update should respect privacy. // The `foo` module attempts to maintains an invariant that each `S` -// has a unique `u64` id. +// has a unique `u64` ID. use self::foo::S; mod foo { use std::cell::{UnsafeCell}; @@ -28,5 +28,5 @@ fn main() { let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... //~^ ERROR field `secret_uid` of struct `foo::S` is private println!("main forged an S named: {}", s_2.b); - // at end of scope, ... both s_1 *and* s_2 get dropped. Boom! + // At end of scope, ... both `s_1` *and* `s_2` get dropped. Boom! } diff --git a/src/test/ui/generator-yielding-or-returning-itself.stderr b/src/test/ui/generator-yielding-or-returning-itself.stderr index 5834aed2450b1..190cbf4b57d83 100644 --- a/src/test/ui/generator-yielding-or-returning-itself.stderr +++ b/src/test/ui/generator-yielding-or-returning-itself.stderr @@ -6,7 +6,8 @@ LL | want_cyclic_generator_return(|| { | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, - see https://github.com/rust-lang/rust/issues/46062 for more details + see for more + details note: required by `want_cyclic_generator_return` --> $DIR/generator-yielding-or-returning-itself.rs:9:1 | @@ -24,7 +25,8 @@ LL | want_cyclic_generator_yield(|| { | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, - see https://github.com/rust-lang/rust/issues/46062 for more details + see for more + details note: required by `want_cyclic_generator_yield` --> $DIR/generator-yielding-or-returning-itself.rs:22:1 | diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index c98f42e62168e..96c2eadb27260 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -10,7 +10,7 @@ LL | | }; | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: the yield type of a generator must have a statically known size + = note: the yield type of a generator must have a statically-known size error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/sized-yield.rs:12:23 diff --git a/src/test/ui/generator/yield-while-iterating.rs b/src/test/ui/generator/yield-while-iterating.rs index e42781d1279e7..b109d8a62ebcc 100644 --- a/src/test/ui/generator/yield-while-iterating.rs +++ b/src/test/ui/generator/yield-while-iterating.rs @@ -6,7 +6,7 @@ use std::pin::Pin; fn yield_during_iter_owned_data(x: Vec) { // The generator owns `x`, so we error out when yielding with a - // reference to it. This winds up becoming a rather confusing + // reference to it. This winds up becoming a rather confusing // regionck error -- in particular, we would freeze with the // reference in scope, and it doesn't live long enough. let _b = move || { diff --git a/src/test/ui/generic/generic-lifetime-trait-impl.rs b/src/test/ui/generic/generic-lifetime-trait-impl.rs index 6ffaba19d78b8..d3deca3fba732 100644 --- a/src/test/ui/generic/generic-lifetime-trait-impl.rs +++ b/src/test/ui/generic/generic-lifetime-trait-impl.rs @@ -1,8 +1,8 @@ -// This code used to produce an ICE on the definition of trait Bar +// This code used to produce an ICE on the definition of `trait Bar` // with the following message: // -// Type parameter out of range when substituting in region 'a (root -// type=fn(Self) -> 'astr) (space=FnSpace, index=0) +// Type parameter out of range when substituting in region `'a` (root +// type `fn(Self) -> &'a str`) (space = `FnSpace`, index = `0`). // // Regression test for issue #16218. @@ -19,5 +19,4 @@ impl<'a> Foo<'a> for &'a str { fn bar>(self) -> &'a str { panic!() } //~ ERROR lifetime } -fn main() { -} +fn main() {} diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.rs b/src/test/ui/hrtb/hrtb-conflate-regions.rs index 391303676d784..ff5de28640a2c 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.rs +++ b/src/test/ui/hrtb/hrtb-conflate-regions.rs @@ -16,7 +16,7 @@ fn want_foo1() } /////////////////////////////////////////////////////////////////////////// -// Expressed as a where clause +// Expressed as a where-clause struct SomeStruct; diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs index 35b39a9a69dd0..9d8f0c0bc74c8 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs +++ b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs @@ -1,4 +1,4 @@ -// Test that the `'a` in the where clause correctly links the region +// Test that the `'a` in the where-clause correctly links the region // of the output to the region of the input. // revisions: ast mir diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs index 0094091c6bd76..b586596e0b634 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs @@ -1,5 +1,5 @@ // Test a case where you have an impl of `Foo` for all `X` that -// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. +// is being applied to `for<'a> Foo<&'a mut X>`. See issue #19730. trait Foo { fn foo(&mut self, x: X) { } @@ -10,46 +10,46 @@ trait Bar { } impl<'a,X,F> Foo for &'a mut F - where F : Foo + Bar + where F: Foo + Bar { } impl<'a,X,F> Bar for &'a mut F - where F : Bar + where F: Bar { } fn no_hrtb<'b,T>(mut t: T) - where T : Bar<&'b isize> + where T: Bar<&'b isize> { - // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that - // `&mut T : Bar<&'b isize>`. + // OK -- `T: Bar<&'b isize>`, and thus the impl above ensures that + // `&mut T: Bar<&'b isize>`. no_hrtb(&mut t); } fn bar_hrtb(mut t: T) - where T : for<'b> Bar<&'b isize> + where T: for<'b> Bar<&'b isize> { - // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above - // ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an + // OK -- `T: for<'b> Bar<&'b isize>`, and thus the impl above + // ensures that `&mut T: for<'b> Bar<&'b isize>`. This is an // example of a "perfect forwarding" impl. bar_hrtb(&mut t); } fn foo_hrtb_bar_not<'b,T>(mut t: T) - where T : for<'a> Foo<&'a isize> + Bar<&'b isize> + where T: for<'a> Foo<&'a isize> + Bar<&'b isize> { // Not OK -- The forwarding impl for `Foo` requires that `Bar` also - // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a - // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where - // clause only specifies `T : Bar<&'b isize>`. + // be implemented. Thus to satisfy `&mut T: for<'a> Foo<&'a + // isize>`, we require `T: for<'a> Bar<&'a isize>`, but the where + // clause only specifies `T: Bar<&'b isize>`. foo_hrtb_bar_not(&mut t); //~ ERROR not general enough } fn foo_hrtb_bar_hrtb(mut t: T) - where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize> + where T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize> { - // OK -- now we have `T : for<'b> Bar&'b isize>`. + // OK -- now we have `T: for<'b> Bar&'b isize>`. foo_hrtb_bar_hrtb(&mut t); } diff --git a/src/test/ui/huge-array-simple.rs b/src/test/ui/huge-array-simple.rs index 5fa874c1fa0d3..c140ee4ed2a10 100644 --- a/src/test/ui/huge-array-simple.rs +++ b/src/test/ui/huge-array-simple.rs @@ -1,11 +1,11 @@ -// FIXME (#23926): the error output is not consistent between a -// self-hosted and a cross-compiled setup. Skipping for now. +// FIXME(#23926): the error output is not consistent between a +// self-hosted and a cross-compiled setup; skipping for now. // ignore-test FIXME(#23926) #![allow(exceeding_bitshifts)] fn main() { - let _fat : [u8; (1<<61)+(1<<31)] = - [0; (1u64<<61) as usize +(1u64<<31) as usize]; + let _fat : [u8; (1 << 61) + (1 << 31)] = + [0; (1u64 << 61) as usize + (1u64 << 31) as usize]; } diff --git a/src/test/ui/hygiene/expansion-info-reset.rs b/src/test/ui/hygiene/expansion-info-reset.rs index 5c384c4ada9fc..ede2c0343f786 100644 --- a/src/test/ui/hygiene/expansion-info-reset.rs +++ b/src/test/ui/hygiene/expansion-info-reset.rs @@ -1,4 +1,4 @@ -// FIXME: Investigate why expansion info for a single expansion id is reset from +// FIXME: investigate why expansion info for a single expansion ID is reset from // `MacroBang(format_args)` to `MacroAttribute(derive(Clone))` (issue #52363). fn main() { diff --git a/src/test/ui/impl-trait/closure-calling-parent-fn.rs b/src/test/ui/impl-trait/closure-calling-parent-fn.rs index cb5f78bd6fc0f..20ef264cbf7b5 100644 --- a/src/test/ui/impl-trait/closure-calling-parent-fn.rs +++ b/src/test/ui/impl-trait/closure-calling-parent-fn.rs @@ -4,7 +4,7 @@ // when a closure returns the `impl Copy` from its parent fn. It was // (incorrectly) replacing the `impl Copy` in its return type with the // hidden type (`()`) but that type resulted from a recursive call to -// `foo` and hence is treated opaquely within the closure body. This +// `foo` and hence is treated opaquely within the closure body. This // resulted in a failed subtype relationship. // // run-pass diff --git a/src/test/ui/impl-trait/issue-49376.rs b/src/test/ui/impl-trait/issue-49376.rs index 13671b8dbf448..1c38b03c03f3b 100644 --- a/src/test/ui/impl-trait/issue-49376.rs +++ b/src/test/ui/impl-trait/issue-49376.rs @@ -1,6 +1,6 @@ // compile-pass -// Tests for nested self-reference which caused a stack overflow. +// Tests for nested self-reference that caused a stack overflow. use std::fmt::Debug; use std::ops::*; diff --git a/src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.rs b/src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.rs index cb40d90ae551a..3325014b78371 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.rs +++ b/src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.rs @@ -3,7 +3,7 @@ // appear in the bounds. This is because `&` is contravariant, and so // we are *actually* returning a `&'y u32`. // -// See https://github.com/rust-lang/rust/issues/46541 for more details. +// See for more details. // run-pass diff --git a/src/test/ui/impl-trait/region-escape-via-bound-contravariant.rs b/src/test/ui/impl-trait/region-escape-via-bound-contravariant.rs index e2310a3907f7e..80c5de501ef42 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound-contravariant.rs +++ b/src/test/ui/impl-trait/region-escape-via-bound-contravariant.rs @@ -3,7 +3,7 @@ // appear in the bounds. This is because `&` is contravariant, and so // we are *actually* returning a `&'y u32`. // -// See https://github.com/rust-lang/rust/issues/46541 for more details. +// See issue #46541 for more details. // run-pass diff --git a/src/test/ui/impl-trait/region-escape-via-bound.rs b/src/test/ui/impl-trait/region-escape-via-bound.rs index d62aec800e8ce..547e1ea4cde26 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound.rs +++ b/src/test/ui/impl-trait/region-escape-via-bound.rs @@ -1,7 +1,7 @@ // Test that we do not allow the region `'x` to escape in the impl // trait **even though** `'y` escapes, which outlives `'x`. // -// See https://github.com/rust-lang/rust/issues/46541 for more details. +// See issue #46541 for more details. #![allow(dead_code)] #![feature(in_band_lifetimes)] diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index 31bc9f449a0f1..1585377e5b40e 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -181,14 +181,14 @@ impl InInherentImplAdt { //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types } -// Disallowed in where clauses +// Disallowed in where-clauses fn in_fn_where_clause() where impl Debug: Debug //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types { } -// Disallowed in where clauses +// Disallowed in where-clauses fn in_adt_in_fn_where_clause() where Vec: Debug //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types diff --git a/src/test/ui/impl-unused-tps-inherent.rs b/src/test/ui/impl-unused-tps-inherent.rs index 83a228e551aa6..791a95a914e1d 100644 --- a/src/test/ui/impl-unused-tps-inherent.rs +++ b/src/test/ui/impl-unused-tps-inherent.rs @@ -18,7 +18,7 @@ impl MyType1 { //~^ ERROR the type parameter `U` is not constrained } -impl MyType1 where T: Bar { +impl MyType1 where T: Bar { // OK, T is used in `Foo`. } diff --git a/src/test/ui/impl-unused-tps.rs b/src/test/ui/impl-unused-tps.rs index 7cc1ae613bc3f..a85b296eeb1ea 100644 --- a/src/test/ui/impl-unused-tps.rs +++ b/src/test/ui/impl-unused-tps.rs @@ -14,11 +14,11 @@ impl Foo for [isize;1] { //~^ ERROR the type parameter `U` is not constrained } -impl Foo for [isize;2] where T : Bar { +impl Foo for [isize;2] where T : Bar { // OK, `U` is now constrained by the output type parameter. } -impl,U> Foo for [isize;3] { +impl,U> Foo for [isize;3] { // OK, same as above but written differently. } @@ -36,7 +36,7 @@ impl Bar for T { } impl Bar for T - where T : Bar + where T : Bar { //~^^^ ERROR the type parameter `U` is not constrained @@ -44,7 +44,7 @@ impl Bar for T } impl Foo for T - where (T,U): Bar + where (T,U): Bar { //~^^^ ERROR the type parameter `U` is not constrained //~| ERROR the type parameter `V` is not constrained @@ -54,7 +54,7 @@ impl Foo for T } impl Foo<(T,U)> for T - where (T,U): Bar + where (T,U): Bar { // As above, but both T and U ARE constrained. } diff --git a/src/test/ui/infinite/infinite-instantiation.rs b/src/test/ui/infinite/infinite-instantiation.rs index 4220c8837d298..3a34a1ed3117e 100644 --- a/src/test/ui/infinite/infinite-instantiation.rs +++ b/src/test/ui/infinite/infinite-instantiation.rs @@ -24,7 +24,7 @@ fn function(counter: usize, t: T) { //~^ ERROR reached the recursion limit while instantiating `function:: 0 { function(counter - 1, t.to_option()); - // FIXME(#4287) Error message should be here. It should be + // FIXME(#4287): error message should be here. It should be // a type error to instantiate `test` at a type other than T. } } diff --git a/src/test/ui/infinite/infinite-recursion-const-fn.rs b/src/test/ui/infinite/infinite-recursion-const-fn.rs index 020c417bf61ad..f8ca686eaaa81 100644 --- a/src/test/ui/infinite/infinite-recursion-const-fn.rs +++ b/src/test/ui/infinite/infinite-recursion-const-fn.rs @@ -1,4 +1,4 @@ -//https://github.com/rust-lang/rust/issues/31364 +// Test for issue #31364. const fn a() -> usize { b() } //~ ERROR evaluation of constant value failed const fn b() -> usize { a() } diff --git a/src/test/ui/invalid/invalid-crate-type.rs b/src/test/ui/invalid/invalid-crate-type.rs index 6c44c3b4f2b13..1ef061052598d 100644 --- a/src/test/ui/invalid/invalid-crate-type.rs +++ b/src/test/ui/invalid/invalid-crate-type.rs @@ -1,5 +1,6 @@ -// regression test for issue 11256 -#![crate_type="foo"] //~ ERROR invalid `crate_type` value +// Regression test for issue #11256. + +#![crate_type="foo"] //~ ERROR invalid `crate_type` value // Tests for suggestions (#53958) diff --git a/src/test/ui/invalid/invalid-crate-type.stderr b/src/test/ui/invalid/invalid-crate-type.stderr index 63edd04650b21..4d87b58f24460 100644 --- a/src/test/ui/invalid/invalid-crate-type.stderr +++ b/src/test/ui/invalid/invalid-crate-type.stderr @@ -1,55 +1,55 @@ error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:2:15 + --> $DIR/invalid-crate-type.rs:3:15 | -LL | #![crate_type="foo"] //~ ERROR invalid `crate_type` value +LL | #![crate_type="foo"] //~ ERROR invalid `crate_type` value | ^^^^^ | = note: #[deny(unknown_crate_types)] on by default error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:6:15 + --> $DIR/invalid-crate-type.rs:7:15 | LL | #![crate_type="statoclib"] | ^^^^^^^^^^^ help: did you mean: `"staticlib"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:11:15 + --> $DIR/invalid-crate-type.rs:12:15 | LL | #![crate_type="procmacro"] | ^^^^^^^^^^^ help: did you mean: `"proc-macro"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:16:15 + --> $DIR/invalid-crate-type.rs:17:15 | LL | #![crate_type="static-lib"] | ^^^^^^^^^^^^ help: did you mean: `"staticlib"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:21:15 + --> $DIR/invalid-crate-type.rs:22:15 | LL | #![crate_type="drylib"] | ^^^^^^^^ help: did you mean: `"dylib"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:26:15 + --> $DIR/invalid-crate-type.rs:27:15 | LL | #![crate_type="dlib"] | ^^^^^^ help: did you mean: `"rlib"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:31:15 + --> $DIR/invalid-crate-type.rs:32:15 | LL | #![crate_type="lob"] | ^^^^^ help: did you mean: `"lib"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:36:15 + --> $DIR/invalid-crate-type.rs:37:15 | LL | #![crate_type="bon"] | ^^^^^ help: did you mean: `"bin"` error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:41:15 + --> $DIR/invalid-crate-type.rs:42:15 | LL | #![crate_type="cdalib"] | ^^^^^^^^ help: did you mean: `"cdylib"` diff --git a/src/test/ui/invalid_crate_type_syntax.rs b/src/test/ui/invalid_crate_type_syntax.rs index 8157ccdcbf0b9..645144ed46bb2 100644 --- a/src/test/ui/invalid_crate_type_syntax.rs +++ b/src/test/ui/invalid_crate_type_syntax.rs @@ -1,5 +1,6 @@ -// regression test for issue 16974 -#![crate_type(lib)] //~ ERROR attribute must be of the form +// Regression test for issue #16974. + +#![crate_type(lib)] //~ ERROR attribute must be of the form fn my_lib_fn() {} diff --git a/src/test/ui/invalid_crate_type_syntax.stderr b/src/test/ui/invalid_crate_type_syntax.stderr index 8d6948b583c51..b39acd1d50a92 100644 --- a/src/test/ui/invalid_crate_type_syntax.stderr +++ b/src/test/ui/invalid_crate_type_syntax.stderr @@ -1,7 +1,7 @@ error: attribute must be of the form `#[crate_type = "bin|lib|..."]` - --> $DIR/invalid_crate_type_syntax.rs:2:1 + --> $DIR/invalid_crate_type_syntax.rs:3:1 | -LL | #![crate_type(lib)] //~ ERROR attribute must be of the form +LL | #![crate_type(lib)] //~ ERROR attribute must be of the form | ^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/auxiliary/use_from_trait_xc.rs b/src/test/ui/issues/auxiliary/use-from-trait-xc.rs similarity index 100% rename from src/test/ui/auxiliary/use_from_trait_xc.rs rename to src/test/ui/issues/auxiliary/use-from-trait-xc.rs diff --git a/src/test/ui/issues/issue-10456.rs b/src/test/ui/issues/issue-10456.rs index 4b548362f4aff..35ca247852a92 100644 --- a/src/test/ui/issues/issue-10456.rs +++ b/src/test/ui/issues/issue-10456.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Foo; diff --git a/src/test/ui/issues/issue-10763.rs b/src/test/ui/issues/issue-10763.rs index f2d4c5b47d782..93421703fe71a 100644 --- a/src/test/ui/issues/issue-10763.rs +++ b/src/test/ui/issues/issue-10763.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) extern "Rust" fn foo() {} diff --git a/src/test/ui/issues/issue-10853.rs b/src/test/ui/issues/issue-10853.rs index 0b74eaddcdd3a..fc97dabd4bdb2 100644 --- a/src/test/ui/issues/issue-10853.rs +++ b/src/test/ui/issues/issue-10853.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![deny(missing_docs)] #![doc="module"] diff --git a/src/test/ui/issues/issue-10902.rs b/src/test/ui/issues/issue-10902.rs index 672386bc8a6c2..29ffa9a608c49 100644 --- a/src/test/ui/issues/issue-10902.rs +++ b/src/test/ui/issues/issue-10902.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod two_tuple { pub trait T { fn dummy(&self) { } } diff --git a/src/test/ui/issues/issue-11004.rs b/src/test/ui/issues/issue-11004.rs index 10ef1f5e3b5cd..4736c41a61535 100644 --- a/src/test/ui/issues/issue-11004.rs +++ b/src/test/ui/issues/issue-11004.rs @@ -4,21 +4,21 @@ struct A { x: i32, y: f64 } #[cfg(not(works))] unsafe fn access(n:*mut A) -> (i32, f64) { - let x : i32 = n.x; //~ no field `x` on type `*mut A` - let y : f64 = n.y; //~ no field `y` on type `*mut A` + let x: i32 = n.x; //~ no field `x` on type `*mut A` + let y: f64 = n.y; //~ no field `y` on type `*mut A` (x, y) } #[cfg(works)] unsafe fn access(n:*mut A) -> (i32, f64) { - let x : i32 = (*n).x; - let y : f64 = (*n).y; + let x: i32 = (*n).x; + let y: f64 = (*n).y; (x, y) } fn main() { - let a : A = A { x: 3, y: 3.14 }; - let p : &A = &a; + let a: A = A { x: 3, y: 3.14 }; + let p: &A = &a; let (x,y) = unsafe { let n : *mut A = mem::transmute(p); access(n) diff --git a/src/test/ui/issues/issue-11004.stderr b/src/test/ui/issues/issue-11004.stderr index a5c63e9c31d41..ff7261a6be196 100644 --- a/src/test/ui/issues/issue-11004.stderr +++ b/src/test/ui/issues/issue-11004.stderr @@ -1,18 +1,18 @@ error[E0609]: no field `x` on type `*mut A` - --> $DIR/issue-11004.rs:7:21 + --> $DIR/issue-11004.rs:7:20 | -LL | let x : i32 = n.x; //~ no field `x` on type `*mut A` - | --^ - | | - | help: `n` is a raw pointer; try dereferencing it: `(*n).x` +LL | let x: i32 = n.x; //~ no field `x` on type `*mut A` + | --^ + | | + | help: `n` is a raw pointer; try dereferencing it: `(*n).x` error[E0609]: no field `y` on type `*mut A` - --> $DIR/issue-11004.rs:8:21 + --> $DIR/issue-11004.rs:8:20 | -LL | let y : f64 = n.y; //~ no field `y` on type `*mut A` - | --^ - | | - | help: `n` is a raw pointer; try dereferencing it: `(*n).y` +LL | let y: f64 = n.y; //~ no field `y` on type `*mut A` + | --^ + | | + | help: `n` is a raw pointer; try dereferencing it: `(*n).y` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-11384.rs b/src/test/ui/issues/issue-11384.rs index 59d85b175cf69..6d1a0e369e43d 100644 --- a/src/test/ui/issues/issue-11384.rs +++ b/src/test/ui/issues/issue-11384.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Common { fn dummy(&self) { } } diff --git a/src/test/ui/issues/issue-11612.rs b/src/test/ui/issues/issue-11612.rs index 4d6f4656d589d..941e4c038cad8 100644 --- a/src/test/ui/issues/issue-11612.rs +++ b/src/test/ui/issues/issue-11612.rs @@ -4,7 +4,7 @@ // We weren't updating the auto adjustments with all the resolved // type information after type check. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn dummy(&self) { } } diff --git a/src/test/ui/issues/issue-11869.rs b/src/test/ui/issues/issue-11869.rs index e62879f1f29ea..9c9f32b1b3090 100644 --- a/src/test/ui/issues/issue-11869.rs +++ b/src/test/ui/issues/issue-11869.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct A { a: String diff --git a/src/test/ui/issues/issue-12028.rs b/src/test/ui/issues/issue-12028.rs index d55354529a9b4..542843acc8032 100644 --- a/src/test/ui/issues/issue-12028.rs +++ b/src/test/ui/issues/issue-12028.rs @@ -1,6 +1,6 @@ // Test an example where we fail to infer the type parameter H. This // is because there is really nothing constraining it. At one time, we -// would infer based on the where clauses in scope, but that no longer +// would infer based on the where-clauses in scope, but that no longer // works. trait Hash { diff --git a/src/test/ui/issues/issue-1251.rs b/src/test/ui/issues/issue-1251.rs index 84a14a8c09be6..7efe07be0bdc2 100644 --- a/src/test/ui/issues/issue-1251.rs +++ b/src/test/ui/issues/issue-1251.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(unused_attributes)] #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-wasm32-bare no libc to test ffi with #![feature(rustc_private)] diff --git a/src/test/ui/issues/issue-12729.rs b/src/test/ui/issues/issue-12729.rs index c2572c78280eb..825142d88297f 100644 --- a/src/test/ui/issues/issue-12729.rs +++ b/src/test/ui/issues/issue-12729.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Foo; diff --git a/src/test/ui/issues/issue-13058.rs b/src/test/ui/issues/issue-13058.rs index a5806feb720d6..b9c5b3a0aaf41 100644 --- a/src/test/ui/issues/issue-13058.rs +++ b/src/test/ui/issues/issue-13058.rs @@ -1,6 +1,6 @@ use std::ops::Range; -trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } +trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } impl<'r> Itble<'r, usize, Range> for (usize, usize) { fn iter(&'r self) -> Range { diff --git a/src/test/ui/issues/issue-13105.rs b/src/test/ui/issues/issue-13105.rs index 0e118043d5564..40cf1fd76221d 100644 --- a/src/test/ui/issues/issue-13105.rs +++ b/src/test/ui/issues/issue-13105.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { #[allow(anonymous_parameters)] diff --git a/src/test/ui/issues/issue-13167.rs b/src/test/ui/issues/issue-13167.rs index dcc25a446fad6..db53418b6395a 100644 --- a/src/test/ui/issues/issue-13167.rs +++ b/src/test/ui/issues/issue-13167.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::slice; diff --git a/src/test/ui/issues/issue-13214.rs b/src/test/ui/issues/issue-13214.rs index af2d95c5e4286..f8650403c39a3 100644 --- a/src/test/ui/issues/issue-13214.rs +++ b/src/test/ui/issues/issue-13214.rs @@ -3,7 +3,7 @@ // defining static with struct that contains enum // with &'static str variant used to cause ICE -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub enum Foo { Bar, diff --git a/src/test/ui/issues/issue-13405.rs b/src/test/ui/issues/issue-13405.rs index 32965cb0c6d8c..b20521af1eb85 100644 --- a/src/test/ui/issues/issue-13405.rs +++ b/src/test/ui/issues/issue-13405.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Foo<'a> { i: &'a bool, diff --git a/src/test/ui/issues/issue-1362.rs b/src/test/ui/issues/issue-1362.rs index 6fd43f50e4dc8..85026577e5560 100644 --- a/src/test/ui/issues/issue-1362.rs +++ b/src/test/ui/issues/issue-1362.rs @@ -1,8 +1,10 @@ -// Regression test for issue #1362 - without that fix the span will be bogus +// Regression test for issue #1362 -- without that fix the span will be bogus. // no-reformat + fn main() { - let x: u32 = 20i32; //~ ERROR mismatched types + let x: u32 = 20i32; //~ ERROR mismatched types } -// NOTE: Do not add any extra lines as the line number the error is + +// NOTE: do not add any extra lines as the line number the error is // on is significant; an error later in the source file might not // trigger the bug. diff --git a/src/test/ui/issues/issue-1362.stderr b/src/test/ui/issues/issue-1362.stderr index dd97e0cf04a99..2f546eaaf452e 100644 --- a/src/test/ui/issues/issue-1362.stderr +++ b/src/test/ui/issues/issue-1362.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/issue-1362.rs:4:16 + --> $DIR/issue-1362.rs:5:18 | -LL | let x: u32 = 20i32; //~ ERROR mismatched types - | ^^^^^ expected u32, found i32 +LL | let x: u32 = 20i32; //~ ERROR mismatched types + | ^^^^^ expected u32, found i32 error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13703.rs b/src/test/ui/issues/issue-13703.rs index 212fff7bcecd7..c5ae376e4c858 100644 --- a/src/test/ui/issues/issue-13703.rs +++ b/src/test/ui/issues/issue-13703.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Foo<'a, 'b: 'a> { foo: &'a &'b isize } pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; } diff --git a/src/test/ui/issues/issue-13775.rs b/src/test/ui/issues/issue-13775.rs index 39e42dc2c0d5a..5d3e3754429ce 100644 --- a/src/test/ui/issues/issue-13775.rs +++ b/src/test/ui/issues/issue-13775.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo { #[allow(anonymous_parameters)] diff --git a/src/test/ui/issues/issue-13837.rs b/src/test/ui/issues/issue-13837.rs index d475ce1d83319..d5c4bc9fde90d 100644 --- a/src/test/ui/issues/issue-13837.rs +++ b/src/test/ui/issues/issue-13837.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct TestStruct { x: *const [isize; 2] diff --git a/src/test/ui/issues/issue-13853.rs b/src/test/ui/issues/issue-13853.rs index ac9886d2e7249..f9cf33332c56f 100644 --- a/src/test/ui/issues/issue-13853.rs +++ b/src/test/ui/issues/issue-13853.rs @@ -3,12 +3,12 @@ trait Node { } trait Graph { - fn nodes<'a, I: Iterator>(&'a self) -> I + fn nodes<'a, I: Iterator>(&'a self) -> I where N: 'a; } impl Graph for Vec { - fn nodes<'a, I: Iterator>(&self) -> I + fn nodes<'a, I: Iterator>(&self) -> I where N: 'a { self.iter() //~ ERROR mismatched types diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index 6da5da04fb165..1b889b0b760f3 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/issue-13853.rs:14:9 | -LL | fn nodes<'a, I: Iterator>(&self) -> I - | - expected `I` because of return type +LL | fn nodes<'a, I: Iterator>(&self) -> I + | - expected `I` because of return type ... LL | self.iter() //~ ERROR mismatched types | ^^^^^^^^^^^ expected type parameter, found struct `std::slice::Iter` diff --git a/src/test/ui/issues/issue-14082.rs b/src/test/ui/issues/issue-14082.rs index 4849077c144e1..fbe6922097239 100644 --- a/src/test/ui/issues/issue-14082.rs +++ b/src/test/ui/issues/issue-14082.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(unused_imports, dead_code)] diff --git a/src/test/ui/issues/issue-14254.rs b/src/test/ui/issues/issue-14254.rs index 3ad388dc2d790..a08856eac7c7e 100644 --- a/src/test/ui/issues/issue-14254.rs +++ b/src/test/ui/issues/issue-14254.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Foo: Sized { fn bar(&self); diff --git a/src/test/ui/issues/issue-14330.rs b/src/test/ui/issues/issue-14330.rs index d8f225eb07c24..839ddfade3392 100644 --- a/src/test/ui/issues/issue-14330.rs +++ b/src/test/ui/issues/issue-14330.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(unused_imports)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[macro_use] extern crate std as std2; diff --git a/src/test/ui/issues/issue-14837.rs b/src/test/ui/issues/issue-14837.rs index 54387804affeb..d4a8dba945a79 100644 --- a/src/test/ui/issues/issue-14837.rs +++ b/src/test/ui/issues/issue-14837.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[deny(dead_code)] pub enum Foo { diff --git a/src/test/ui/issues/issue-14933.rs b/src/test/ui/issues/issue-14933.rs index 9249ba3d6466e..270160ab4f82a 100644 --- a/src/test/ui/issues/issue-14933.rs +++ b/src/test/ui/issues/issue-14933.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub type BigRat = T; diff --git a/src/test/ui/issues/issue-14959.rs b/src/test/ui/issues/issue-14959.rs index 78ae21e2837af..5266ec943792a 100644 --- a/src/test/ui/issues/issue-14959.rs +++ b/src/test/ui/issues/issue-14959.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(fn_traits, unboxed_closures)] diff --git a/src/test/ui/issues/issue-15108.rs b/src/test/ui/issues/issue-15108.rs index d2b56c0949d63..d25f6ba76b5b2 100644 --- a/src/test/ui/issues/issue-15108.rs +++ b/src/test/ui/issues/issue-15108.rs @@ -1,4 +1,4 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() {} diff --git a/src/test/ui/issues/issue-15261.rs b/src/test/ui/issues/issue-15261.rs index 4119cb055c590..2ca03760176a5 100644 --- a/src/test/ui/issues/issue-15261.rs +++ b/src/test/ui/issues/issue-15261.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) static mut n_mut: usize = 0; diff --git a/src/test/ui/issues/issue-15689-2.rs b/src/test/ui/issues/issue-15689-2.rs index 4a1326113910e..6cb6c016e0aef 100644 --- a/src/test/ui/issues/issue-15689-2.rs +++ b/src/test/ui/issues/issue-15689-2.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Clone)] enum Test<'a> { diff --git a/src/test/ui/issues/issue-15756.stderr b/src/test/ui/issues/issue-15756.stderr index 987bc512163d6..06f38f3702e56 100644 --- a/src/test/ui/issues/issue-15756.stderr +++ b/src/test/ui/issues/issue-15756.stderr @@ -6,7 +6,7 @@ LL | &mut something | = help: the trait `std::marker::Sized` is not implemented for `[T]` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17121.rs b/src/test/ui/issues/issue-17121.rs index 706350fc1e205..773267edf8c4e 100644 --- a/src/test/ui/issues/issue-17121.rs +++ b/src/test/ui/issues/issue-17121.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no std::fs use std::fs::File; diff --git a/src/test/ui/issues/issue-17263.rs b/src/test/ui/issues/issue-17263.rs index 754f3b90aacf1..8a10fd081658f 100644 --- a/src/test/ui/issues/issue-17263.rs +++ b/src/test/ui/issues/issue-17263.rs @@ -6,12 +6,12 @@ //[ast]compile-flags: -Z borrowck=ast //[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -// don't worry about the --compare-mode=nll on this test. +// Don't worry about the `--compare-mode=nll` on this test. // ignore-compare-mode-nll #![feature(box_syntax, rustc_attrs)] struct Foo { a: isize, b: isize } -#[rustc_error] // rust-lang/rust#49855 +#[rustc_error] // Issue #49855 fn main() { //[nll]~ ERROR compilation successful let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); @@ -22,7 +22,7 @@ fn main() { //[nll]~ ERROR compilation successful //[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable // We explicitly use the references created above to illustrate - // that NLL is accepting this code *not* because of artificially + // that NLL is accepting this code **not** because of artificially // short lifetimes, but rather because it understands that all the // references are of disjoint parts of memory. use_imm(d); diff --git a/src/test/ui/issues/issue-17732.rs b/src/test/ui/issues/issue-17732.rs index 7993bbb38bb4a..04bd9ff372171 100644 --- a/src/test/ui/issues/issue-17732.rs +++ b/src/test/ui/issues/issue-17732.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Person { type string; diff --git a/src/test/ui/issues/issue-17904-2.rs b/src/test/ui/issues/issue-17904-2.rs index 9603da097b1cf..0923aef70700b 100644 --- a/src/test/ui/issues/issue-17904-2.rs +++ b/src/test/ui/issues/issue-17904-2.rs @@ -1,4 +1,4 @@ -// Test that we can parse a unit struct with a where clause, even if +// Test that we can parse a unit struct with a where-clause, even if // it leads to an error later on since `T` is unused. struct Foo where T: Copy; //~ ERROR parameter `T` is never used diff --git a/src/test/ui/issues/issue-17904.rs b/src/test/ui/issues/issue-17904.rs index 2fe54957b3c08..01962b7321da4 100644 --- a/src/test/ui/issues/issue-17904.rs +++ b/src/test/ui/issues/issue-17904.rs @@ -1,9 +1,9 @@ // compile-pass #![allow(dead_code)] -// Test that we can parse where clauses on various forms of tuple +// Test that we can parse where-clauses on various forms of tuple // structs. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Bar(T) where T: Copy; struct Bleh(T, U) where T: Copy, U: Sized; diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr index 23b58c3f6df3d..622c5fc192366 100644 --- a/src/test/ui/issues/issue-18107.stderr +++ b/src/test/ui/issues/issue-18107.stderr @@ -6,7 +6,7 @@ LL | AbstractRenderer | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` = note: to learn more, visit - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18183.rs b/src/test/ui/issues/issue-18183.rs index 64476d1c10999..086c59df057ef 100644 --- a/src/test/ui/issues/issue-18183.rs +++ b/src/test/ui/issues/issue-18183.rs @@ -1,3 +1,4 @@ -pub struct Foo(Bar); //~ ERROR E0128 +pub struct Foo(Bar); //~ ERROR E0128 pub struct Baz(Foo); + fn main() {} diff --git a/src/test/ui/issues/issue-18183.stderr b/src/test/ui/issues/issue-18183.stderr index cf33124bc950a..60a63f9fc51e6 100644 --- a/src/test/ui/issues/issue-18183.stderr +++ b/src/test/ui/issues/issue-18183.stderr @@ -1,8 +1,8 @@ error[E0128]: type parameters with a default cannot use forward declared identifiers - --> $DIR/issue-18183.rs:1:20 + --> $DIR/issue-18183.rs:1:22 | -LL | pub struct Foo(Bar); //~ ERROR E0128 - | ^^^ defaulted type parameters cannot be forward declared +LL | pub struct Foo(Bar); //~ ERROR E0128 + | ^^^ defaulted type parameters cannot be forward declared error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18188.rs b/src/test/ui/issues/issue-18188.rs index 8e39dc15597e7..dfe6c1921a43e 100644 --- a/src/test/ui/issues/issue-18188.rs +++ b/src/test/ui/issues/issue-18188.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Promisable: Send + Sync {} impl Promisable for T {} diff --git a/src/test/ui/issues/issue-1821.rs b/src/test/ui/issues/issue-1821.rs index 0177b70a69885..4a1b8dc885092 100644 --- a/src/test/ui/issues/issue-1821.rs +++ b/src/test/ui/issues/issue-1821.rs @@ -1,13 +1,13 @@ // compile-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -// Issue #1821 - Don't recurse trying to typecheck this +// pretty-expanded FIXME(#23616) +// Issue #1821: don't recurse trying to type-check this. -// pretty-expanded FIXME #23616 +#![allow(dead_code)] +#![allow(non_camel_case_types)] enum t { foo(Vec) } + pub fn main() {} diff --git a/src/test/ui/issues/issue-1866.rs b/src/test/ui/issues/issue-1866.rs index 3de547bfe6fce..469b5b81e26e0 100644 --- a/src/test/ui/issues/issue-1866.rs +++ b/src/test/ui/issues/issue-1866.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod a { pub type rust_task = usize; diff --git a/src/test/ui/issues/issue-18906.rs b/src/test/ui/issues/issue-18906.rs index 0b9625b1868ef..c35476209cf91 100644 --- a/src/test/ui/issues/issue-18906.rs +++ b/src/test/ui/issues/issue-18906.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Borrow { fn borrow(&self) -> &Borrowed; diff --git a/src/test/ui/issue-18986.rs b/src/test/ui/issues/issue-18986.rs similarity index 85% rename from src/test/ui/issue-18986.rs rename to src/test/ui/issues/issue-18986.rs index 1c431a45ab23e..f0b292f2911c0 100644 --- a/src/test/ui/issue-18986.rs +++ b/src/test/ui/issues/issue-18986.rs @@ -1,4 +1,4 @@ -// aux-build:use_from_trait_xc.rs +// aux-build:use-from-trait-xc.rs extern crate use_from_trait_xc; pub use use_from_trait_xc::Trait; diff --git a/src/test/ui/issue-18986.stderr b/src/test/ui/issues/issue-18986.stderr similarity index 100% rename from src/test/ui/issue-18986.stderr rename to src/test/ui/issues/issue-18986.stderr diff --git a/src/test/ui/issues/issue-19037.rs b/src/test/ui/issues/issue-19037.rs index 4efc0719ffbb2..6f63af91f29fe 100644 --- a/src/test/ui/issues/issue-19037.rs +++ b/src/test/ui/issues/issue-19037.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct Str([u8]); diff --git a/src/test/ui/issues/issue-19129-1.rs b/src/test/ui/issues/issue-19129-1.rs index 4be2cc6d1797b..22396922d2344 100644 --- a/src/test/ui/issues/issue-19129-1.rs +++ b/src/test/ui/issues/issue-19129-1.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Trait { type Output; diff --git a/src/test/ui/issues/issue-19129-2.rs b/src/test/ui/issues/issue-19129-2.rs index d11ef8af709ef..331dd3d908b83 100644 --- a/src/test/ui/issues/issue-19129-2.rs +++ b/src/test/ui/issues/issue-19129-2.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(unused_variables)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Trait { type Output; diff --git a/src/test/ui/issues/issue-19398.rs b/src/test/ui/issues/issue-19398.rs index 5daa14b7cb7bb..bdcf89dc49ed2 100644 --- a/src/test/ui/issues/issue-19398.rs +++ b/src/test/ui/issues/issue-19398.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait T { unsafe extern "Rust" fn foo(&self); diff --git a/src/test/ui/issues/issue-19479.rs b/src/test/ui/issues/issue-19479.rs index 8b78952a6e2b1..9825697e20f10 100644 --- a/src/test/ui/issues/issue-19479.rs +++ b/src/test/ui/issues/issue-19479.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Base { fn dummy(&self) { } diff --git a/src/test/ui/issues/issue-19631.rs b/src/test/ui/issues/issue-19631.rs index 8c58331e581b7..76ff02d4dfa97 100644 --- a/src/test/ui/issues/issue-19631.rs +++ b/src/test/ui/issues/issue-19631.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait PoolManager { type C; diff --git a/src/test/ui/issues/issue-19632.rs b/src/test/ui/issues/issue-19632.rs index b032b67c1ebd1..0010732048fe7 100644 --- a/src/test/ui/issues/issue-19632.rs +++ b/src/test/ui/issues/issue-19632.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait PoolManager { type C; diff --git a/src/test/ui/issues/issue-19850.rs b/src/test/ui/issues/issue-19850.rs index fb64ef8940557..777c13ed2376a 100644 --- a/src/test/ui/issues/issue-19850.rs +++ b/src/test/ui/issues/issue-19850.rs @@ -3,7 +3,7 @@ // Test that `::Output` and `Self::Output` are accepted as type annotations in let // bindings -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Int { fn one() -> Self; diff --git a/src/test/ui/issues/issue-20009.rs b/src/test/ui/issues/issue-20009.rs index 6228d044ad11a..4e65782bbc467 100644 --- a/src/test/ui/issues/issue-20009.rs +++ b/src/test/ui/issues/issue-20009.rs @@ -1,7 +1,7 @@ // compile-pass // Check that associated types are `Sized` -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Trait { type Output; diff --git a/src/test/ui/issues/issue-20261.rs b/src/test/ui/issues/issue-20261.rs index 528393606f380..004173e05f1f9 100644 --- a/src/test/ui/issues/issue-20261.rs +++ b/src/test/ui/issues/issue-20261.rs @@ -1,5 +1,5 @@ fn main() { - // N.B., this (almost) typechecks when default binding modes are enabled. + // N.B., this (almost) type-checks when default binding modes are enabled. for (ref i,) in [].iter() { i.clone(); //~^ ERROR type annotations needed diff --git a/src/test/ui/issues/issue-20396.rs b/src/test/ui/issues/issue-20396.rs index b6dfffbd69ebb..41392a225ebd6 100644 --- a/src/test/ui/issues/issue-20396.rs +++ b/src/test/ui/issues/issue-20396.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(dead_code)] diff --git a/src/test/ui/issues/issue-20414.rs b/src/test/ui/issues/issue-20414.rs index 1653a9da0045a..50fd873e6ed5f 100644 --- a/src/test/ui/issues/issue-20414.rs +++ b/src/test/ui/issues/issue-20414.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Trait { fn method(self) -> isize; diff --git a/src/test/ui/issues/issue-20605.rs b/src/test/ui/issues/issue-20605.rs index 11a2a573ea677..983a02370e89f 100644 --- a/src/test/ui/issues/issue-20605.rs +++ b/src/test/ui/issues/issue-20605.rs @@ -1,4 +1,4 @@ -fn changer<'a>(mut things: Box>) { +fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-20616-1.rs b/src/test/ui/issues/issue-20616-1.rs index 49e9cb310c144..b4dd68de86044 100644 --- a/src/test/ui/issues/issue-20616-1.rs +++ b/src/test/ui/issues/issue-20616-1.rs @@ -9,28 +9,28 @@ type Type_1_<'a, T> = &'a T; type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-2.rs b/src/test/ui/issues/issue-20616-2.rs index 2f2c6903a9f4c..01e036200b504 100644 --- a/src/test/ui/issues/issue-20616-2.rs +++ b/src/test/ui/issues/issue-20616-2.rs @@ -6,31 +6,31 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-3.rs b/src/test/ui/issues/issue-20616-3.rs index 9bfd5bf231302..f87b3afcfb2d3 100644 --- a/src/test/ui/issues/issue-20616-3.rs +++ b/src/test/ui/issues/issue-20616-3.rs @@ -4,32 +4,32 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` type Type_3 = Box; //~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-4.rs b/src/test/ui/issues/issue-20616-4.rs index e9a34a04667b0..3fb83fdf3258c 100644 --- a/src/test/ui/issues/issue-20616-4.rs +++ b/src/test/ui/issues/issue-20616-4.rs @@ -4,13 +4,13 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` type Type_4 = Type_1_<'static,, T>; @@ -20,16 +20,16 @@ type Type_4 = Type_1_<'static,, T>; type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-5.rs b/src/test/ui/issues/issue-20616-5.rs index 23862516d2cbf..86c6051b7fffd 100644 --- a/src/test/ui/issues/issue-20616-5.rs +++ b/src/test/ui/issues/issue-20616-5.rs @@ -4,16 +4,16 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; @@ -23,13 +23,13 @@ type Type_5<'a> = Type_1_<'a, (),,>; //~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-6.rs b/src/test/ui/issues/issue-20616-6.rs index dc327f3f78824..46adba1e99ec7 100644 --- a/src/test/ui/issues/issue-20616-6.rs +++ b/src/test/ui/issues/issue-20616-6.rs @@ -4,32 +4,32 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` type Type_6 = Type_5_<'a,,>; //~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-7.rs b/src/test/ui/issues/issue-20616-7.rs index ffd1620c1d306..293273c12ceb5 100644 --- a/src/test/ui/issues/issue-20616-7.rs +++ b/src/test/ui/issues/issue-20616-7.rs @@ -4,32 +4,32 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` type Type_7 = Box<(),,>; //~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` +// type Type_8<'a,,> = &'a (); // error: expected ident, found `,` -//type Type_9 = Box; // error: expected ident, found `,` +// type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-8.rs b/src/test/ui/issues/issue-20616-8.rs index c9e8b61e50b52..77b8033decf0a 100644 --- a/src/test/ui/issues/issue-20616-8.rs +++ b/src/test/ui/issues/issue-20616-8.rs @@ -4,32 +4,32 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` type Type_8<'a,,> = &'a (); //~^ error: expected one of `>`, `const`, identifier, or lifetime, found `,` -//type Type_9 = Box; // error: expected identifier, found `,` +// type Type_9 = Box; // error: expected identifier, found `,` diff --git a/src/test/ui/issues/issue-20616-9.rs b/src/test/ui/issues/issue-20616-9.rs index 1c509f26fd63a..907f22ff4a349 100644 --- a/src/test/ui/issues/issue-20616-9.rs +++ b/src/test/ui/issues/issue-20616-9.rs @@ -4,31 +4,31 @@ type Type_1_<'a, T> = &'a T; -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` +// type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` +// type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -//type Type_3 = Box; // error: expected type, found `,` +// type Type_3 = Box; // error: expected type, found `,` -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` +// type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` +// type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` +// type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -//type Type_7 = Box<(),,>; // error: expected type, found `,` +// type Type_7 = Box<(),,>; // error: expected type, found `,` -//type Type_8<'a,,> = &'a (); // error: expected identifier, found `,` +// type Type_8<'a,,> = &'a (); // error: expected identifier, found `,` type Type_9 = Box; diff --git a/src/test/ui/issues/issue-2063-resource.rs b/src/test/ui/issues/issue-2063-resource.rs index 6ed3e027ffa48..d8150939da5e7 100644 --- a/src/test/ui/issues/issue-2063-resource.rs +++ b/src/test/ui/issues/issue-2063-resource.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] // test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances +// cause compiler to loop. Note that no instances // of such a type could ever be constructed. struct S { diff --git a/src/test/ui/issues/issue-20644.rs b/src/test/ui/issues/issue-20644.rs index db32344864c46..811f60a57c049 100644 --- a/src/test/ui/issues/issue-20644.rs +++ b/src/test/ui/issues/issue-20644.rs @@ -6,7 +6,7 @@ // A reduced version of the rustbook ice. The problem this encountered // had to do with codegen ignoring binders. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) // ignore-cloudabi no std::fs #![feature(os)] diff --git a/src/test/ui/issues/issue-20763-1.rs b/src/test/ui/issues/issue-20763-1.rs index c5b2852094591..e795da64c47f0 100644 --- a/src/test/ui/issues/issue-20763-1.rs +++ b/src/test/ui/issues/issue-20763-1.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait T0 { type O; @@ -11,7 +11,7 @@ struct S(A); impl T0 for S { type O = A; } trait T1: T0 { - // this looks okay but as we see below, `f` is unusable + // this looks ok but as we see below, `f` is unusable fn m0::O) -> bool>(self, f: F) -> bool; } diff --git a/src/test/ui/issues/issue-20763-2.rs b/src/test/ui/issues/issue-20763-2.rs index cfa252b095e47..2ea64252f7f07 100644 --- a/src/test/ui/issues/issue-20763-2.rs +++ b/src/test/ui/issues/issue-20763-2.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait T0 { type O; @@ -11,7 +11,7 @@ struct S(A); impl T0 for S { type O = A; } trait T1: T0 { - // this looks okay but as we see below, `f` is unusable + // this looks ok but as we see below, `f` is unusable fn m0::O) -> bool>(self, f: F) -> bool; } diff --git a/src/test/ui/issues/issue-20772.rs b/src/test/ui/issues/issue-20772.rs index 36551e7014f10..b75891123de58 100644 --- a/src/test/ui/issues/issue-20772.rs +++ b/src/test/ui/issues/issue-20772.rs @@ -1,6 +1,6 @@ -trait T : Iterator +trait T: Iterator { //~^ ERROR cycle detected //~| ERROR associated type `Item` not found for `Self` -{} +} fn main() {} diff --git a/src/test/ui/issues/issue-20772.stderr b/src/test/ui/issues/issue-20772.stderr index 7dc4e43fd573d..3e245cd49b901 100644 --- a/src/test/ui/issues/issue-20772.stderr +++ b/src/test/ui/issues/issue-20772.stderr @@ -1,27 +1,21 @@ error[E0391]: cycle detected when computing the supertraits of `T` --> $DIR/issue-20772.rs:1:1 | -LL | / trait T : Iterator -LL | | //~^ ERROR cycle detected -LL | | //~| ERROR associated type `Item` not found for `Self` -LL | | {} - | |__^ +LL | trait T: Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which again requires computing the supertraits of `T`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/issue-20772.rs:1:1 | -LL | / trait T : Iterator -LL | | //~^ ERROR cycle detected -LL | | //~| ERROR associated type `Item` not found for `Self` -LL | | {} - | |__^ +LL | trait T: Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0220]: associated type `Item` not found for `Self` - --> $DIR/issue-20772.rs:1:25 + --> $DIR/issue-20772.rs:1:26 | -LL | trait T : Iterator - | ^^^^^^^^^^ associated type `Item` not found +LL | trait T: Iterator { + | ^^^^^^^^^^ associated type `Item` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-20831-debruijn.rs b/src/test/ui/issues/issue-20831-debruijn.rs index 6d3c7331a4579..508ecf6f31480 100644 --- a/src/test/ui/issues/issue-20831-debruijn.rs +++ b/src/test/ui/issues/issue-20831-debruijn.rs @@ -1,4 +1,4 @@ -// Regression test for #20831: debruijn index account was thrown off +// Regression test for #20831: De Bruijn index account was thrown off // by the (anonymous) lifetime in `::Output` // below. Note that changing to a named lifetime made the problem go // away. @@ -12,7 +12,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } diff --git a/src/test/ui/issues/issue-21245.rs b/src/test/ui/issues/issue-21245.rs index edf482afc53d4..9ca7508c6c565 100644 --- a/src/test/ui/issues/issue-21245.rs +++ b/src/test/ui/issues/issue-21245.rs @@ -5,7 +5,7 @@ // insufficient type propagation caused the type of the iterator to be // incorrectly unified with the `*const` type to which it is coerced. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::ptr; diff --git a/src/test/ui/issues/issue-21363.rs b/src/test/ui/issues/issue-21363.rs index 5e30db17c6d18..5aeae0d4b1bf9 100644 --- a/src/test/ui/issues/issue-21363.rs +++ b/src/test/ui/issues/issue-21363.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![no_implicit_prelude] @@ -8,7 +8,7 @@ trait Iterator { fn dummy(&self) { } } -impl<'a, T> Iterator for &'a mut (Iterator + 'a) { +impl<'a, T> Iterator for &'a mut (Iterator + 'a) { type Item = T; } diff --git a/src/test/ui/issues/issue-21402.rs b/src/test/ui/issues/issue-21402.rs index 518d3cfe5a660..418bf4b190e44 100644 --- a/src/test/ui/issues/issue-21402.rs +++ b/src/test/ui/issues/issue-21402.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(Hash)] struct Foo { diff --git a/src/test/ui/issues/issue-21520.rs b/src/test/ui/issues/issue-21520.rs index 450448f1a1185..5a30eaa82bcd1 100644 --- a/src/test/ui/issues/issue-21520.rs +++ b/src/test/ui/issues/issue-21520.rs @@ -3,7 +3,7 @@ // Test that the requirement (in `Bar`) that `T::Bar : 'static` does // not wind up propagating to `T`. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Foo { type Bar; diff --git a/src/test/ui/issues/issue-21726.rs b/src/test/ui/issues/issue-21726.rs index f2065976b35d0..89675a2c07051 100644 --- a/src/test/ui/issues/issue-21726.rs +++ b/src/test/ui/issues/issue-21726.rs @@ -4,7 +4,7 @@ // subtyping of projection types that resulted in an unconstrained // region, yielding region inference failures. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn main() { } diff --git a/src/test/ui/issues/issue-21891.rs b/src/test/ui/issues/issue-21891.rs index 9b1e44c181759..22f382e27452b 100644 --- a/src/test/ui/issues/issue-21891.rs +++ b/src/test/ui/issues/issue-21891.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) static foo: [usize; 3] = [1, 2, 3]; diff --git a/src/test/ui/issues/issue-22066.rs b/src/test/ui/issues/issue-22066.rs index 8c0b664d78ad5..aac9596c8f356 100644 --- a/src/test/ui/issues/issue-22066.rs +++ b/src/test/ui/issues/issue-22066.rs @@ -1,6 +1,6 @@ // compile-pass pub trait LineFormatter<'a> { - type Iter: Iterator + 'a; + type Iter: Iterator + 'a; fn iter(&'a self, line: &'a str) -> Self::Iter; fn dimensions(&'a self, line: &'a str) { diff --git a/src/test/ui/issues/issue-22356.rs b/src/test/ui/issues/issue-22356.rs index 3f3b1d3e5f1d9..f1e2bec754b6a 100644 --- a/src/test/ui/issues/issue-22356.rs +++ b/src/test/ui/issues/issue-22356.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(type_alias_bounds)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::marker::PhantomData; diff --git a/src/test/ui/issues/issue-22370.rs b/src/test/ui/issues/issue-22370.rs index 44eef2da83ce3..b80ef4f035ec1 100644 --- a/src/test/ui/issues/issue-22370.rs +++ b/src/test/ui/issues/issue-22370.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -trait A {} +trait A {} fn f(a: &A) {} //~^ ERROR E0393 diff --git a/src/test/ui/issues/issue-22777.rs b/src/test/ui/issues/issue-22777.rs index f9b264623d6bb..4db2f8cf45819 100644 --- a/src/test/ui/issues/issue-22777.rs +++ b/src/test/ui/issues/issue-22777.rs @@ -1,9 +1,9 @@ // compile-pass -// This test is reduced from libsyntax. It is just checking that we +// This test is reduced from libsyntax. It is just checking that we // can successfully deal with a "deep" structure, which the drop-check // was hitting a recursion limit on at one point. -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_camel_case_types)] diff --git a/src/test/ui/issues/issue-2311.rs b/src/test/ui/issues/issue-2311.rs index 07b9951e68d39..3dc0e59199434 100644 --- a/src/test/ui/issues/issue-2311.rs +++ b/src/test/ui/issues/issue-2311.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait clam { fn get(self) -> A; } trait foo { diff --git a/src/test/ui/issues/issue-2487-a.rs b/src/test/ui/issues/issue-2487-a.rs index 36e121ddb7ad9..5493b7492ea14 100644 --- a/src/test/ui/issues/issue-2487-a.rs +++ b/src/test/ui/issues/issue-2487-a.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct socket { sock: isize, diff --git a/src/test/ui/issues/issue-2502.rs b/src/test/ui/issues/issue-2502.rs index 29b68c94c2e7c..1e65880252285 100644 --- a/src/test/ui/issues/issue-2502.rs +++ b/src/test/ui/issues/issue-2502.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct font<'a> { fontbuf: &'a Vec , diff --git a/src/test/ui/issues/issue-25076.rs b/src/test/ui/issues/issue-25076.rs index 6c5a553924561..488ce44d9970f 100644 --- a/src/test/ui/issues/issue-25076.rs +++ b/src/test/ui/issues/issue-25076.rs @@ -2,7 +2,7 @@ struct S; trait InOut { type Out; } -fn do_fold>(init: B, f: F) {} +fn do_fold>(init: B, f: F) {} fn bot() -> T { loop {} } diff --git a/src/test/ui/issues/issue-25076.stderr b/src/test/ui/issues/issue-25076.stderr index 8793475e6d4ed..7a94fe5cbbe7a 100644 --- a/src/test/ui/issues/issue-25076.stderr +++ b/src/test/ui/issues/issue-25076.stderr @@ -7,8 +7,8 @@ LL | do_fold(bot(), ()); //~ ERROR `(): InOut<_>` is not satisfied note: required by `do_fold` --> $DIR/issue-25076.rs:5:1 | -LL | fn do_fold>(init: B, f: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn do_fold>(init: B, f: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25439.stderr b/src/test/ui/issues/issue-25439.stderr index 9e9ab4e39d34c..acd0d3c5cd7ce 100644 --- a/src/test/ui/issues/issue-25439.stderr +++ b/src/test/ui/issues/issue-25439.stderr @@ -6,7 +6,8 @@ LL | fix(|_, x| x); //~ ERROR closure/generator type that references itself | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, - see https://github.com/rust-lang/rust/issues/46062 for more details + see for more + details error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25700.rs b/src/test/ui/issues/issue-25700.rs index 45c452d618d84..5a7436fa9cc7e 100644 --- a/src/test/ui/issues/issue-25700.rs +++ b/src/test/ui/issues/issue-25700.rs @@ -3,8 +3,8 @@ struct S(Option<&'static T>); trait Tr { type Out; } impl Tr for T { type Out = T; } -impl Copy for S where S: Tr {} -impl Clone for S where S: Tr { +impl Copy for S where S: Tr {} +impl Clone for S where S: Tr { fn clone(&self) -> Self { *self } } fn main() { diff --git a/src/test/ui/issues/issue-25793.rs b/src/test/ui/issues/issue-25793.rs index 6c8dacc224892..f0c67e0d7eb47 100644 --- a/src/test/ui/issues/issue-25793.rs +++ b/src/test/ui/issues/issue-25793.rs @@ -20,7 +20,7 @@ impl HasInfo { r.get_size(width!(self)) } // Above is like `self.get_size(width!(self))`, but it - // deliberately avoids NLL's two phase borrow feature. + // deliberately avoids NLL's two-phase borrow feature. } -fn main() { } +fn main() {} diff --git a/src/test/ui/issues/issue-26638.rs b/src/test/ui/issues/issue-26638.rs index 0f5ed5caa74cb..a806c4b4a45dc 100644 --- a/src/test/ui/issues/issue-26638.rs +++ b/src/test/ui/issues/issue-26638.rs @@ -1,10 +1,16 @@ -fn parse_type(iter: Box+'static>) -> &str { iter.next() } +fn parse_type(iter: Box + 'static>) -> &str { //~^ ERROR missing lifetime specifier [E0106] + iter.next() +} -fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } +fn parse_type_2(iter: fn(&u8) -> &u8) -> &str { //~^ ERROR missing lifetime specifier [E0106] + iter() +} -fn parse_type_3() -> &str { unimplemented!() } +fn parse_type_3() -> &str { //~^ ERROR missing lifetime specifier [E0106] + unimplemented!() +} fn main() {} diff --git a/src/test/ui/issues/issue-26638.stderr b/src/test/ui/issues/issue-26638.stderr index 64c2cd43264d0..c1fd3fbb395f0 100644 --- a/src/test/ui/issues/issue-26638.stderr +++ b/src/test/ui/issues/issue-26638.stderr @@ -1,23 +1,23 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:1:58 + --> $DIR/issue-26638.rs:1:62 | -LL | fn parse_type(iter: Box+'static>) -> &str { iter.next() } - | ^ expected lifetime parameter +LL | fn parse_type(iter: Box + 'static>) -> &str { + | ^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say which one of `iter`'s 2 lifetimes it is borrowed from error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:4:40 + --> $DIR/issue-26638.rs:6:42 | -LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } - | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` +LL | fn parse_type_2(iter: fn(&u8) -> &u8) -> &str { + | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:7:22 + --> $DIR/issue-26638.rs:11:22 | -LL | fn parse_type_3() -> &str { unimplemented!() } +LL | fn parse_type_3() -> &str { | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/issues/issue-26812.rs b/src/test/ui/issues/issue-26812.rs index b2494a91a3f8a..6a2548409d924 100644 --- a/src/test/ui/issues/issue-26812.rs +++ b/src/test/ui/issues/issue-26812.rs @@ -1,6 +1,6 @@ #![feature(default_type_parameter_fallback)] -fn avg(_: T) {} +fn avg(_: T) {} //~^ ERROR type parameters with a default cannot use forward declared identifiers fn main() {} diff --git a/src/test/ui/issues/issue-26812.stderr b/src/test/ui/issues/issue-26812.stderr index 8d507a7ea0144..226053e5b6bfc 100644 --- a/src/test/ui/issues/issue-26812.stderr +++ b/src/test/ui/issues/issue-26812.stderr @@ -1,8 +1,8 @@ error[E0128]: type parameters with a default cannot use forward declared identifiers - --> $DIR/issue-26812.rs:3:10 + --> $DIR/issue-26812.rs:3:12 | -LL | fn avg(_: T) {} - | ^^^^^^^ defaulted type parameters cannot be forward declared +LL | fn avg(_: T) {} + | ^^^^^^^ defaulted type parameters cannot be forward declared error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26905.rs b/src/test/ui/issues/issue-26905.rs index 0cd166f4ac694..c6a2327e6d776 100644 --- a/src/test/ui/issues/issue-26905.rs +++ b/src/test/ui/issues/issue-26905.rs @@ -19,6 +19,6 @@ fn main() { let data = [1, 2, 3]; let iter = data.iter(); let x = MyRc { _ptr: &iter, _boo: NotPhantomData(PhantomData) }; - let _y: MyRc> = x; + let _y: MyRc> = x; } diff --git a/src/test/ui/issues/issue-27078.stderr b/src/test/ui/issues/issue-27078.stderr index 76cc3e7b0a36e..611c099e28856 100644 --- a/src/test/ui/issues/issue-27078.stderr +++ b/src/test/ui/issues/issue-27078.stderr @@ -7,7 +7,7 @@ LL | fn foo(self) -> &'static i32 { = help: the trait `std::marker::Sized` is not implemented for `Self` = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs b/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs index 0721b051bcbd8..6126b4713bd8c 100644 --- a/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs +++ b/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs @@ -1,4 +1,4 @@ -// Issue 27282: Example 2: This sidesteps the AST checks disallowing +// Issue #27282: Example 2: this sidesteps the AST checks disallowing // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the mutably borrowed match input) within a // closure. diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs index 1312aff30fecf..5e68bf227aa95 100644 --- a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs +++ b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs @@ -1,4 +1,4 @@ -// Issue 27282: Example 1: This sidesteps the AST checks disallowing +// Issue #27282: Example 1: this sidesteps the AST checks disallowing // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the ref mut pattern id) within a closure. // diff --git a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs index c79b1873241c8..4d739af89f72a 100644 --- a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs +++ b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs @@ -1,11 +1,10 @@ -// Issue 27282: This is a variation on issue-27282-move-ref-mut-into-guard.rs +// Issue #27282: this is a variation on `issue-27282-move-ref-mut-into-guard.rs`. // // It reborrows instead of moving the `ref mut` pattern borrow. This // means that our conservative check for mutation in guards will // reject it. But I want to make sure that we continue to reject it // (under NLL) even when that conservaive check goes away. - #![feature(bind_by_move_pattern_guards)] #![feature(nll)] diff --git a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr index 3a10928981c8b..77b3592d86d7e 100644 --- a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr +++ b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard - --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:16:25 + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:15:25 | LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); | ^^ - mutable borrow occurs due to use of `r` in closure diff --git a/src/test/ui/issues/issue-2748-a.rs b/src/test/ui/issues/issue-2748-a.rs index 683a931cc3d5b..8129e3cd346a2 100644 --- a/src/test/ui/issues/issue-2748-a.rs +++ b/src/test/ui/issues/issue-2748-a.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_snake_case)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct CMap<'a> { buf: &'a [u8], diff --git a/src/test/ui/issues/issue-2804-2.rs b/src/test/ui/issues/issue-2804-2.rs index d5157420617d7..f475b7467fea0 100644 --- a/src/test/ui/issues/issue-2804-2.rs +++ b/src/test/ui/issues/issue-2804-2.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] // Minimized version of issue-2804.rs. Both check that callee IDs don't -// clobber the previous node ID in a macro expr +// clobber the previous `NodeId` in a macro expr use std::collections::HashMap; diff --git a/src/test/ui/issues/issue-28576.rs b/src/test/ui/issues/issue-28576.rs index de665d5aa1680..784d203a681c1 100644 --- a/src/test/ui/issues/issue-28576.rs +++ b/src/test/ui/issues/issue-28576.rs @@ -1,11 +1,11 @@ -pub trait Foo { +pub trait Foo { type Assoc; } -pub trait Bar: Foo { +pub trait Bar: Foo { fn new(&self, b: & - Bar //~ ERROR the trait `Bar` cannot be made into an object - + Bar + //~^ ERROR the trait `Bar` cannot be made into an object ); } diff --git a/src/test/ui/issues/issue-28576.stderr b/src/test/ui/issues/issue-28576.stderr index b04715f23f49e..cc48db14354ad 100644 --- a/src/test/ui/issues/issue-28576.stderr +++ b/src/test/ui/issues/issue-28576.stderr @@ -1,9 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-28576.rs:7:12 | -LL | / Bar //~ ERROR the trait `Bar` cannot be made into an object -LL | | - | |________________________^ the trait `Bar` cannot be made into an object +LL | Bar + | ^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-28871.rs b/src/test/ui/issues/issue-28871.rs index b7e02b85878f2..4b0402537fc23 100644 --- a/src/test/ui/issues/issue-28871.rs +++ b/src/test/ui/issues/issue-28871.rs @@ -1,9 +1,9 @@ // compile-pass // Regression test for #28871. The problem is that rustc encountered -// two ways to project, one from a where clause and one from the where +// two ways to project, one from a where-clause and one from the where // clauses on the trait definition. (In fact, in this case, the where // clauses originated from the trait definition as well.) The true -// cause of the error is that the trait definition where clauses are +// cause of the error is that the trait definition where-clauses are // not being normalized, and hence the two sources are considered in // conflict, and not a duplicate. Hacky solution is to prefer where // clauses over the data found in the trait definition. diff --git a/src/test/ui/issues/issue-29723.rs b/src/test/ui/issues/issue-29723.rs index 41db52a1fadac..51601b9f1df07 100644 --- a/src/test/ui/issues/issue-29723.rs +++ b/src/test/ui/issues/issue-29723.rs @@ -1,7 +1,5 @@ #![feature(nll)] -// test for https://github.com/rust-lang/rust/issues/29723 - fn main() { let s = String::new(); let _s = match 0 { diff --git a/src/test/ui/issues/issue-29723.stderr b/src/test/ui/issues/issue-29723.stderr index 7928af5d5a5cd..04915ab5f9510 100644 --- a/src/test/ui/issues/issue-29723.stderr +++ b/src/test/ui/issues/issue-29723.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `s` - --> $DIR/issue-29723.rs:12:13 + --> $DIR/issue-29723.rs:10:13 | LL | let s = String::new(); | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait diff --git a/src/test/ui/issues/issue-30355.stderr b/src/test/ui/issues/issue-30355.stderr index 48b151c73c956..5499827761a19 100644 --- a/src/test/ui/issues/issue-30355.stderr +++ b/src/test/ui/issues/issue-30355.stderr @@ -6,7 +6,7 @@ LL | &X(*Y) | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-31109.rs b/src/test/ui/issues/issue-31109.rs index 37c2390581973..b4b9b562a20ce 100644 --- a/src/test/ui/issues/issue-31109.rs +++ b/src/test/ui/issues/issue-31109.rs @@ -1,5 +1,5 @@ fn main() { - // FIXME(#31407) this error should go away, but in the meantime we test that it + // FIXME(#31407): this error should go away, but in the meantime we test that it // is accompanied by a somewhat useful error message. let _: f64 = 1234567890123456789012345678901234567890e-340; //~^ ERROR could not evaluate float literal (see issue #31407) diff --git a/src/test/ui/issues/issue-3149.rs b/src/test/ui/issues/issue-3149.rs index c9a6f537757d0..013cbad889598 100644 --- a/src/test/ui/issues/issue-3149.rs +++ b/src/test/ui/issues/issue-3149.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] #![allow(non_snake_case)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn Matrix4(m11: T, m12: T, m13: T, m14: T, m21: T, m22: T, m23: T, m24: T, diff --git a/src/test/ui/issues/issue-33903.rs b/src/test/ui/issues/issue-33903.rs index 98544aca5f9da..366fbe746395d 100644 --- a/src/test/ui/issues/issue-33903.rs +++ b/src/test/ui/issues/issue-33903.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// Issue 33903: +// Issue #33903: // Built-in indexing should be used even when the index is not // trivially an integer // Only built-in indexing can be used in constant expressions diff --git a/src/test/ui/issues/issue-3563-2.rs b/src/test/ui/issues/issue-3563-2.rs index 48f7c845d5e84..52a2474fc2115 100644 --- a/src/test/ui/issues/issue-3563-2.rs +++ b/src/test/ui/issues/issue-3563-2.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait Canvas { fn add_point(&self, point: &isize); diff --git a/src/test/ui/issues/issue-35668.rs b/src/test/ui/issues/issue-35668.rs index 1b8ada57ed69c..663ea385080a9 100644 --- a/src/test/ui/issues/issue-35668.rs +++ b/src/test/ui/issues/issue-35668.rs @@ -1,4 +1,4 @@ -fn func<'a, T>(a: &'a [T]) -> impl Iterator { +fn func<'a, T>(a: &'a [T]) -> impl Iterator { a.iter().map(|a| a*a) //~^ ERROR binary operation `*` cannot be applied to type `&T` } diff --git a/src/test/ui/issues/issue-35976.rs b/src/test/ui/issues/issue-35976.rs index 95c0cc95bb2ba..6cf684f087339 100644 --- a/src/test/ui/issues/issue-35976.rs +++ b/src/test/ui/issues/issue-35976.rs @@ -8,7 +8,7 @@ mod private { } } -//use private::Future; +// use private::Future; fn bar(arg: Box) { arg.wait(); diff --git a/src/test/ui/issues/issue-3601.rs b/src/test/ui/issues/issue-3601.rs index e33359beccdef..cb8d9a6e510a1 100644 --- a/src/test/ui/issues/issue-3601.rs +++ b/src/test/ui/issues/issue-3601.rs @@ -25,7 +25,7 @@ fn main() { let mut id = HTMLImageData { image: None }; let ed = ElementData { kind: box ElementKind::HTMLImageElement(id) }; let n = NodeData {kind : box NodeKind::Element(ed)}; - // n.b. span could be better + // N.B., span could be better. match n.kind { box NodeKind::Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true } diff --git a/src/test/ui/issues/issue-3874.rs b/src/test/ui/issues/issue-3874.rs index 8a7eaf29539cb..7f3094185ad03 100644 --- a/src/test/ui/issues/issue-3874.rs +++ b/src/test/ui/issues/issue-3874.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) enum PureCounter { PureCounterVariant(usize) } diff --git a/src/test/ui/issues/issue-3888-2.rs b/src/test/ui/issues/issue-3888-2.rs index 27d05b470becf..34d72a3a5bfbe 100644 --- a/src/test/ui/issues/issue-3888-2.rs +++ b/src/test/ui/issues/issue-3888-2.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] { &v[1..5] diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index a74d6353c31f4..a2d7b0d3c4d71 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -6,7 +6,7 @@ LL | fn _test(ref _p: str) {} | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3979-2.rs b/src/test/ui/issues/issue-3979-2.rs index eec8c85f276c7..766397fb89026 100644 --- a/src/test/ui/issues/issue-3979-2.rs +++ b/src/test/ui/issues/issue-3979-2.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) trait A { fn a_method(&self); diff --git a/src/test/ui/issues/issue-3991.rs b/src/test/ui/issues/issue-3991.rs index bc63aae0b9eac..9d1bc64cb99af 100644 --- a/src/test/ui/issues/issue-3991.rs +++ b/src/test/ui/issues/issue-3991.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct HasNested { nest: Vec > , diff --git a/src/test/ui/issues/issue-39970.rs b/src/test/ui/issues/issue-39970.rs index f51e3b522e1c5..c374e9be5d4e0 100644 --- a/src/test/ui/issues/issue-39970.rs +++ b/src/test/ui/issues/issue-39970.rs @@ -11,7 +11,7 @@ impl<'a> Array<'a> for () { } impl Visit for () where - //(): for<'a> Array<'a, Element=&'a ()>, // No ICE + //(): for<'a> Array<'a, Element = &'a ()>, // No ICE (): for<'a> Array<'a, Element=()>, // ICE {} diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index bcca911c5a5c8..ac932545c6b73 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -6,7 +6,7 @@ LL | pub fn example(ref s: str) {} | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 20c8d085cbc62..4dba62c3a3639 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -7,7 +7,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} = help: the trait `std::marker::Sized` is not implemented for `::Target` = note: to learn more, visit = help: consider adding a `where ::Target: std::marker::Sized` bound - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time @@ -18,7 +18,7 @@ LL | pub fn f(_: ToString) {} | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-43189.rs b/src/test/ui/issues/issue-43189.rs index f4f4dce7682fa..1177dad618a81 100644 --- a/src/test/ui/issues/issue-43189.rs +++ b/src/test/ui/issues/issue-43189.rs @@ -1,4 +1,4 @@ -// Issue 46112: An extern crate pub re-exporting libcore was causing +// Issue #46112: an extern crate pub re-exporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. // ignore-windows diff --git a/src/test/ui/issues/issue-4366.rs b/src/test/ui/issues/issue-4366.rs index 9ec2e58ecadcb..775795cc50a0d 100644 --- a/src/test/ui/issues/issue-4366.rs +++ b/src/test/ui/issues/issue-4366.rs @@ -1,7 +1,7 @@ -// regression test for issue 4366 +// Regression test for issue #4366. -// ensures that 'use foo:*' doesn't import non-public 'use' statements in the -// module 'foo' +// Ensures that `use foo:*` doesn't import non-public `use` statements in the +// module `foo`. use m1::*; diff --git a/src/test/ui/issues/issue-4464.rs b/src/test/ui/issues/issue-4464.rs index c20c1cad66909..17e14e9171547 100644 --- a/src/test/ui/issues/issue-4464.rs +++ b/src/test/ui/issues/issue-4464.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn broken(v: &[u8], i: usize, j: usize) -> &[u8] { &v[i..j] } diff --git a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs index 9f86caeaea9e9..ccce2588820f2 100644 --- a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs +++ b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs @@ -74,18 +74,18 @@ struct Scribble<'a>(&'a mut u32); impl<'a> Drop for Scribble<'a> { fn drop(&mut self) { *self.0 = 42; } } -// this is okay, in both AST-borrowck and NLL: The `Scribble` here *has* +// this is ok, in both AST-borrowck and NLL: The `Scribble` here *has* // to strictly outlive `'a` fn borrowed_scribble<'a>(s: &'a mut Scribble) -> &'a mut u32 { &mut *s.0 } -// this, by analogy to previous case, is also okay. +// this, by analogy to previous case, is also ok. fn boxed_borrowed_scribble<'a>(s: Box<&'a mut Scribble>) -> &'a mut u32 { &mut *(*s).0 } -// this, by analogy to previous case, is also okay. +// this, by analogy to previous case, is also ok. fn boxed_boxed_borrowed_scribble<'a>(s: Box>) -> &'a mut u32 { &mut *(**s).0 } diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs index fc56a2a8b70ad..874f0b33ecc76 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs @@ -22,23 +22,23 @@ struct Scribble<'a>(&'a mut u32); impl<'a> Drop for Scribble<'a> { fn drop(&mut self) { *self.0 = 42; } } -// this is okay, in both AST-borrowck and NLL: The `Scribble` here *has* +// this is ok, in both AST-borrowck and NLL: The `Scribble` here *has* // to strictly outlive `'a` fn borrowed_scribble<'a>(s: &'a mut Scribble) -> &'a mut u32 { &mut *s.0 } -// this, by analogy to previous case, is also okay. +// this, by analogy to previous case, is also ok. fn boxed_borrowed_scribble<'a>(s: Box<&'a mut Scribble>) -> &'a mut u32 { &mut *(*s).0 } -// this, by analogy to previous case, is also okay. +// this, by analogy to previous case, is also ok. fn boxed_boxed_borrowed_scribble<'a>(s: Box>) -> &'a mut u32 { &mut *(**s).0 } -// this is not okay: in between the time that we take the mutable +// this is not ok: in between the time that we take the mutable // borrow and the caller receives it as a return value, the drop of // `s` will scribble on it, violating our aliasing guarantees. // @@ -56,7 +56,7 @@ fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { //[migrate]~| WARNING this represents potential undefined behavior in your code } -// This, by analogy to previous case, is *also* not okay. +// This, by analogy to previous case, is *also* not ok. // // (But again, AST-borrowck was not smart enogh to know that this // should be an error.) @@ -67,7 +67,7 @@ fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { //[migrate]~| WARNING this represents potential undefined behavior in your code } -// This, by analogy to previous case, is *also* not okay. +// This, by analogy to previous case, is *also* not ok. // // (But again, AST-borrowck was not smart enogh to know that this // should be an error.) diff --git a/src/test/ui/issues/issue-46036.rs b/src/test/ui/issues/issue-46036.rs index c517bbe57e82b..ff87660975114 100644 --- a/src/test/ui/issues/issue-46036.rs +++ b/src/test/ui/issues/issue-46036.rs @@ -1,5 +1,6 @@ -// Issue 46036: [NLL] false edges on infinite loops +// Issue #46036: [NLL] false edges on infinite loops. // Infinite loops should create false edges to the cleanup block. + #![feature(nll)] struct Foo { x: &'static u32 } @@ -7,7 +8,7 @@ struct Foo { x: &'static u32 } fn foo() { let a = 3; let foo = Foo { x: &a }; //~ ERROR E0597 - loop { } + loop {} } -fn main() { } +fn main() {} diff --git a/src/test/ui/issues/issue-46036.stderr b/src/test/ui/issues/issue-46036.stderr index 40a77f925b94e..4be7296d28b60 100644 --- a/src/test/ui/issues/issue-46036.stderr +++ b/src/test/ui/issues/issue-46036.stderr @@ -1,12 +1,12 @@ error[E0597]: `a` does not live long enough - --> $DIR/issue-46036.rs:9:24 + --> $DIR/issue-46036.rs:10:24 | LL | let foo = Foo { x: &a }; //~ ERROR E0597 | ^^ | | | borrowed value does not live long enough | requires that `a` is borrowed for `'static` -LL | loop { } +LL | loop {} LL | } | - `a` dropped here while still borrowed diff --git a/src/test/ui/issues/issue-46112.rs b/src/test/ui/issues/issue-46112.rs index 0cdd2c27ff73e..f50484a094614 100644 --- a/src/test/ui/issues/issue-46112.rs +++ b/src/test/ui/issues/issue-46112.rs @@ -1,4 +1,4 @@ -// Issue 46112: An extern crate pub re-exporting libcore was causing +// Issue #46112: an extern crate pub re-exporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. // ignore-windows diff --git a/src/test/ui/issues/issue-47309.rs b/src/test/ui/issues/issue-47309.rs index a9aeecb61b6a5..869f01f20c01f 100644 --- a/src/test/ui/issues/issue-47309.rs +++ b/src/test/ui/issues/issue-47309.rs @@ -1,6 +1,5 @@ // Make sure that the mono-item collector does not crash when trying to // instantiate a default impl of a method with lifetime parameters. -// See https://github.com/rust-lang/rust/issues/47309 // compile-flags:-Clink-dead-code // compile-pass diff --git a/src/test/ui/issues/issue-4830.rs b/src/test/ui/issues/issue-4830.rs index cf94094a7985f..3202fc4529fab 100644 --- a/src/test/ui/issues/issue-4830.rs +++ b/src/test/ui/issues/issue-4830.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct Scheduler { /// The event loop used to drive the scheduler and perform I/O diff --git a/src/test/ui/issues/issue-50714-1.rs b/src/test/ui/issues/issue-50714-1.rs index 31de3f3c0a1b8..bdebc3a176e72 100644 --- a/src/test/ui/issues/issue-50714-1.rs +++ b/src/test/ui/issues/issue-50714-1.rs @@ -1,4 +1,4 @@ -// Regression test for issue 50714, make sure that this isn't a linker error. +// Regression test for issue #50714: make sure that this isn't a linker error. #![no_std] #![feature(start)] @@ -6,7 +6,8 @@ extern crate std; #[start] -fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { //~ ERROR [E0647] +fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { +//~^ ERROR [E0647] 0 } diff --git a/src/test/ui/issues/issue-50714-1.stderr b/src/test/ui/issues/issue-50714-1.stderr index e5fdd18d3328e..7df74d05aef9d 100644 --- a/src/test/ui/issues/issue-50714-1.stderr +++ b/src/test/ui/issues/issue-50714-1.stderr @@ -1,8 +1,8 @@ -error[E0647]: start function is not allowed to have a `where` clause +error[E0647]: start function is not allowed to have a where-clause --> $DIR/issue-50714-1.rs:9:56 | -LL | fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { //~ ERROR [E0647] - | ^^^^^^^^^^^ start function cannot have a `where` clause +LL | fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { + | ^^^^^^^^^^^ start function cannot have a where-clause error: aborting due to previous error diff --git a/src/test/ui/issues/issue-50714.rs b/src/test/ui/issues/issue-50714.rs index 3683d4bdaccd5..e665b02d6b4e2 100644 --- a/src/test/ui/issues/issue-50714.rs +++ b/src/test/ui/issues/issue-50714.rs @@ -1,4 +1,5 @@ -// Regression test for issue 50714, make sure that this isn't a linker error. - -fn main() where fn(&()): Eq {} //~ ERROR [E0646] +// Regression test for issue #50714: make sure that this isn't a linker error. +fn main() where fn(&()): Eq { +//~^ ERROR [E0646] +} diff --git a/src/test/ui/issues/issue-50714.stderr b/src/test/ui/issues/issue-50714.stderr index d7631adc7b26f..dfb29e969688f 100644 --- a/src/test/ui/issues/issue-50714.stderr +++ b/src/test/ui/issues/issue-50714.stderr @@ -1,8 +1,8 @@ -error[E0646]: `main` function is not allowed to have a `where` clause +error[E0646]: `main` function is not allowed to have a where-clause --> $DIR/issue-50714.rs:3:17 | -LL | fn main() where fn(&()): Eq {} //~ ERROR [E0646] - | ^^^^^^^^^^^ `main` cannot have a `where` clause +LL | fn main() where fn(&()): Eq { + | ^^^^^^^^^^^ `main` cannot have a where-clause error: aborting due to previous error diff --git a/src/test/ui/issues/issue-50781.stderr b/src/test/ui/issues/issue-50781.stderr index 11de59f9f0095..d25a54e67378e 100644 --- a/src/test/ui/issues/issue-50781.stderr +++ b/src/test/ui/issues/issue-50781.stderr @@ -11,7 +11,7 @@ LL | #![deny(where_clauses_object_safety)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #51443 - = note: method `foo` references the `Self` type in where clauses + = note: method `foo` references the `Self` type in where-clauses error: aborting due to previous error diff --git a/src/test/ui/issues/issue-50825-1.rs b/src/test/ui/issues/issue-50825-1.rs index ee4316029a829..eb02fc5be38cd 100644 --- a/src/test/ui/issues/issue-50825-1.rs +++ b/src/test/ui/issues/issue-50825-1.rs @@ -1,7 +1,7 @@ // run-pass // regression test for issue #50825 // Make sure that the `impl` bound (): X is preferred over -// the (): X bound in the where clause. +// the (): X bound in the where-clause. trait X { type T; diff --git a/src/test/ui/issues/issue-50825.rs b/src/test/ui/issues/issue-50825.rs index 1ece2e9fc8475..3433a9ae93834 100644 --- a/src/test/ui/issues/issue-50825.rs +++ b/src/test/ui/issues/issue-50825.rs @@ -1,7 +1,7 @@ // run-pass // regression test for issue #50825 // Make sure that the built-in bound {integer}: Sized is preferred over -// the u64: Sized bound in the where clause. +// the u64: Sized bound in the where-clause. fn foo(y: &[()]) where diff --git a/src/test/ui/issues/issue-52060.rs b/src/test/ui/issues/issue-52060.rs index 54eff228934e3..ca79e1134963c 100644 --- a/src/test/ui/issues/issue-52060.rs +++ b/src/test/ui/issues/issue-52060.rs @@ -1,5 +1,4 @@ -// Regression test for https://github.com/rust-lang/rust/issues/52060 -// The compiler shouldn't ICE in this case +// The compiler shouldn't ICE in this case. static A: &'static [u32] = &[1]; static B: [u32; 1] = [0; A.len()]; //~^ ERROR [E0013] diff --git a/src/test/ui/issues/issue-52060.stderr b/src/test/ui/issues/issue-52060.stderr index 7c3f7695549f0..a70322574a8ae 100644 --- a/src/test/ui/issues/issue-52060.stderr +++ b/src/test/ui/issues/issue-52060.stderr @@ -1,11 +1,11 @@ error[E0013]: constants cannot refer to statics, use a constant instead - --> $DIR/issue-52060.rs:4:26 + --> $DIR/issue-52060.rs:3:26 | LL | static B: [u32; 1] = [0; A.len()]; | ^ error: `core::slice::::len` is not yet stable as a const fn - --> $DIR/issue-52060.rs:4:26 + --> $DIR/issue-52060.rs:3:26 | LL | static B: [u32; 1] = [0; A.len()]; | ^^^^^^^ diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.rs b/src/test/ui/issues/issue-52126-assign-op-invariance.rs index c96cfdf3cd164..0c214a8ba6430 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.rs +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.rs @@ -1,8 +1,8 @@ -// Issue 52126: With respect to variance, the assign-op's like += were +// Issue #52126: with respect to variance, the assign-op's like `+=` were // accidentally lumped together with other binary op's. In both cases // we were coercing the LHS of the op to the expected supertype. // -// The problem is that since the LHS of += is modified, we need the +// The problem is that since the LHS of `+=` is modified, we need the // parameter to be invariant with respect to the overall type, not // covariant. diff --git a/src/test/ui/issues/issue-53300.rs b/src/test/ui/issues/issue-53300.rs index 09f0fe9d93553..a55485f0ad08a 100644 --- a/src/test/ui/issues/issue-53300.rs +++ b/src/test/ui/issues/issue-53300.rs @@ -1,4 +1,4 @@ -// issue 53300 +// Test for issue #53300. pub trait A { fn add(&self, b: i32) -> i32; diff --git a/src/test/ui/issues/issue-53419.rs b/src/test/ui/issues/issue-53419.rs index fc2a926f90ff6..73dcbe62d2927 100644 --- a/src/test/ui/issues/issue-53419.rs +++ b/src/test/ui/issues/issue-53419.rs @@ -1,4 +1,4 @@ -//compile-pass +// compile-pass struct Foo { bar: for<'r> Fn(usize, &'r FnMut()) diff --git a/src/test/ui/issues/issue-5353.rs b/src/test/ui/issues/issue-5353.rs index 808b73ec72f75..ebaf0e146af71 100644 --- a/src/test/ui/issues/issue-5353.rs +++ b/src/test/ui/issues/issue-5353.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) const INVALID_ENUM : u32 = 0; const INVALID_VALUE : u32 = 1; diff --git a/src/test/ui/issue-53787-inline-assembler-macro.rs b/src/test/ui/issues/issue-53787-inline-assembler-macro.rs similarity index 100% rename from src/test/ui/issue-53787-inline-assembler-macro.rs rename to src/test/ui/issues/issue-53787-inline-assembler-macro.rs diff --git a/src/test/ui/issue-53787-inline-assembler-macro.stderr b/src/test/ui/issues/issue-53787-inline-assembler-macro.stderr similarity index 100% rename from src/test/ui/issue-53787-inline-assembler-macro.stderr rename to src/test/ui/issues/issue-53787-inline-assembler-macro.stderr diff --git a/src/test/ui/issues/issue-54302-cases.rs b/src/test/ui/issues/issue-54302-cases.rs index faa116269ee96..541576e7600de 100644 --- a/src/test/ui/issues/issue-54302-cases.rs +++ b/src/test/ui/issues/issue-54302-cases.rs @@ -34,14 +34,14 @@ impl<'x, 'a: 'x> Foo2<'x, i32> for &'a i32 // example 3 - fails due to issue #XYZ + Leak-check impl<'x, T> Foo2<'x, u64> for T - where T: Mirror + where T: Mirror { fn foo2(self) -> &'x u64 { self.coerce() } } // example 4 - fails due to issue #XYZ impl<'x, 'a: 'x, T> Foo2<'x, i64> for T - where T: Mirror + where T: Mirror { fn foo2(self) -> &'x i64 { self.coerce() } } diff --git a/src/test/ui/issue-54943-1.rs b/src/test/ui/issues/issue-54943-1.rs similarity index 100% rename from src/test/ui/issue-54943-1.rs rename to src/test/ui/issues/issue-54943-1.rs diff --git a/src/test/ui/issue-54943-2.rs b/src/test/ui/issues/issue-54943-2.rs similarity index 100% rename from src/test/ui/issue-54943-2.rs rename to src/test/ui/issues/issue-54943-2.rs diff --git a/src/test/ui/issue-54943-3.rs b/src/test/ui/issues/issue-54943-3.rs similarity index 86% rename from src/test/ui/issue-54943-3.rs rename to src/test/ui/issues/issue-54943-3.rs index 185077bd684a8..1180cac78121a 100644 --- a/src/test/ui/issue-54943-3.rs +++ b/src/test/ui/issues/issue-54943-3.rs @@ -1,5 +1,6 @@ // compile-pass -// FIXME(#54943) This test targets the scenario where proving the WF requirements requires + +// FIXME(#54943): this test targets the scenario where proving the WF requirements requires // knowing the value of the `_` type present in the user type annotation - unfortunately, figuring // out the value of that `_` requires type-checking the surrounding code, but that code is dead, // so our NLL region checker doesn't have access to it. This test should actually fail to compile. diff --git a/src/test/ui/issue-54943.rs b/src/test/ui/issues/issue-54943.rs similarity index 100% rename from src/test/ui/issue-54943.rs rename to src/test/ui/issues/issue-54943.rs diff --git a/src/test/ui/issue-54943.stderr b/src/test/ui/issues/issue-54943.stderr similarity index 100% rename from src/test/ui/issue-54943.stderr rename to src/test/ui/issues/issue-54943.stderr diff --git a/src/test/ui/issue-55511.nll.stderr b/src/test/ui/issues/issue-55511.nll.stderr similarity index 100% rename from src/test/ui/issue-55511.nll.stderr rename to src/test/ui/issues/issue-55511.nll.stderr diff --git a/src/test/ui/issue-55511.rs b/src/test/ui/issues/issue-55511.rs similarity index 100% rename from src/test/ui/issue-55511.rs rename to src/test/ui/issues/issue-55511.rs diff --git a/src/test/ui/issue-55511.stderr b/src/test/ui/issues/issue-55511.stderr similarity index 100% rename from src/test/ui/issue-55511.stderr rename to src/test/ui/issues/issue-55511.stderr diff --git a/src/test/ui/issues/issue-5572.rs b/src/test/ui/issues/issue-5572.rs index e5963a7c435f0..93e955ab9ff25 100644 --- a/src/test/ui/issues/issue-5572.rs +++ b/src/test/ui/issues/issue-5572.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(_t: T) { } diff --git a/src/test/ui/issue-55846.rs b/src/test/ui/issues/issue-55846.rs similarity index 100% rename from src/test/ui/issue-55846.rs rename to src/test/ui/issues/issue-55846.rs diff --git a/src/test/ui/issues/issue-56128.rs b/src/test/ui/issues/issue-56128.rs index 3a3eccdc33ce8..a2b24f98f22a2 100644 --- a/src/test/ui/issues/issue-56128.rs +++ b/src/test/ui/issues/issue-56128.rs @@ -1,5 +1,5 @@ // Regression test for #56128. When this `pub(super) use...` gets -// exploded in the HIR, we were not handling ids correctly. +// exploded in the HIR, we were not handling IDs correctly. // // compile-pass diff --git a/src/test/ui/issues/issue-56199.stderr b/src/test/ui/issues/issue-56199.stderr index 7aaf8e4ac2f14..e60159a273081 100644 --- a/src/test/ui/issues/issue-56199.stderr +++ b/src/test/ui/issues/issue-56199.stderr @@ -4,7 +4,7 @@ error: the `Self` constructor can only be used with tuple or unit structs LL | let _ = Self; | ^^^^ | - = help: did you mean to use one of the enum's variants? + = note: did you mean to use one of the enum's variants? error: the `Self` constructor can only be used with tuple or unit structs --> $DIR/issue-56199.rs:8:17 @@ -12,7 +12,7 @@ error: the `Self` constructor can only be used with tuple or unit structs LL | let _ = Self(); | ^^^^ | - = help: did you mean to use one of the enum's variants? + = note: did you mean to use one of the enum's variants? error: the `Self` constructor can only be used with tuple or unit structs --> $DIR/issue-56199.rs:15:17 diff --git a/src/test/ui/issues/issue-5754.rs b/src/test/ui/issues/issue-5754.rs index 78e8701335905..44db8ddcd7f0b 100644 --- a/src/test/ui/issues/issue-5754.rs +++ b/src/test/ui/issues/issue-5754.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(improper_ctypes)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) struct TwoDoubles { r: f64, diff --git a/src/test/ui/issues/issue-5844.rs b/src/test/ui/issues/issue-5844.rs index b855e87e3f559..00c5686163919 100644 --- a/src/test/ui/issues/issue-5844.rs +++ b/src/test/ui/issues/issue-5844.rs @@ -1,4 +1,4 @@ -//aux-build:issue-5844-aux.rs +// aux-build:issue-5844-aux.rs extern crate issue_5844_aux; diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index ad463d4c478ca..9c746df3a8d6f 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -6,7 +6,7 @@ LL | fn new_struct(r: A+'static) | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time @@ -18,7 +18,7 @@ LL | -> Struct { //~^ ERROR the size for values of type = help: within `Struct`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` = note: to learn more, visit = note: required because it appears within the type `Struct` - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-5884.rs b/src/test/ui/issues/issue-5884.rs index ad7067bb9b162..c325917c69427 100644 --- a/src/test/ui/issues/issue-5884.rs +++ b/src/test/ui/issues/issue-5884.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_syntax)] diff --git a/src/test/ui/issues/issue-5900.rs b/src/test/ui/issues/issue-5900.rs index 5ac7acc8e3980..d3767d9cc54b0 100644 --- a/src/test/ui/issues/issue-5900.rs +++ b/src/test/ui/issues/issue-5900.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod foo { use super::Bar; diff --git a/src/test/ui/issues/issue-5950.rs b/src/test/ui/issues/issue-5950.rs index 19e0cfc7f2703..607f43bf2d342 100644 --- a/src/test/ui/issues/issue-5950.rs +++ b/src/test/ui/issues/issue-5950.rs @@ -1,6 +1,6 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub use local as local_alias; diff --git a/src/test/ui/issues/issue-6341.rs b/src/test/ui/issues/issue-6341.rs index 2b23ccd258643..47523d8952685 100644 --- a/src/test/ui/issues/issue-6341.rs +++ b/src/test/ui/issues/issue-6341.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[derive(PartialEq)] struct A { x: usize } diff --git a/src/test/ui/issues/issue-6470.rs b/src/test/ui/issues/issue-6470.rs index 49a313f90de09..a2ee9e2c406b4 100644 --- a/src/test/ui/issues/issue-6470.rs +++ b/src/test/ui/issues/issue-6470.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(improper_ctypes)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_snake_case)] pub mod Bar { diff --git a/src/test/ui/issues/issue-6557.rs b/src/test/ui/issues/issue-6557.rs index aa091ca594aab..dffc4b886f236 100644 --- a/src/test/ui/issues/issue-6557.rs +++ b/src/test/ui/issues/issue-6557.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/test/ui/issues/issue-6898.rs b/src/test/ui/issues/issue-6898.rs index 608c0c80716a6..b10caa5061109 100644 --- a/src/test/ui/issues/issue-6898.rs +++ b/src/test/ui/issues/issue-6898.rs @@ -1,5 +1,5 @@ // compile-pass -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) use std::mem; diff --git a/src/test/ui/issues/issue-7268.rs b/src/test/ui/issues/issue-7268.rs index 0b94fabf385df..87e267f7954b9 100644 --- a/src/test/ui/issues/issue-7268.rs +++ b/src/test/ui/issues/issue-7268.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) fn foo(_: T) {} diff --git a/src/test/ui/issues/issue-7364.rs b/src/test/ui/issues/issue-7364.rs index 52ec9e42be782..3bf70bcbcb720 100644 --- a/src/test/ui/issues/issue-7364.rs +++ b/src/test/ui/issues/issue-7364.rs @@ -2,7 +2,6 @@ use std::cell::RefCell; -// Regression test for issue 7364 static boxed: Box> = box RefCell::new(0); //~^ ERROR allocations are not allowed in statics //~| ERROR `std::cell::RefCell` cannot be shared between threads safely [E0277] diff --git a/src/test/ui/issues/issue-7364.stderr b/src/test/ui/issues/issue-7364.stderr index 52a99ce36b870..ceaa4c6383155 100644 --- a/src/test/ui/issues/issue-7364.stderr +++ b/src/test/ui/issues/issue-7364.stderr @@ -1,17 +1,17 @@ error[E0010]: allocations are not allowed in statics - --> $DIR/issue-7364.rs:6:37 + --> $DIR/issue-7364.rs:5:37 | LL | static boxed: Box> = box RefCell::new(0); | ^^^^^^^^^^^^^^^^^^^ allocation not allowed in statics error[E0019]: static contains unimplemented expression type - --> $DIR/issue-7364.rs:6:41 + --> $DIR/issue-7364.rs:5:41 | LL | static boxed: Box> = box RefCell::new(0); | ^^^^^^^^^^^^^^^ error[E0277]: `std::cell::RefCell` cannot be shared between threads safely - --> $DIR/issue-7364.rs:6:1 + --> $DIR/issue-7364.rs:5:1 | LL | static boxed: Box> = box RefCell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::RefCell` cannot be shared between threads safely diff --git a/src/test/ui/issues/issue-7607-2.rs b/src/test/ui/issues/issue-7607-2.rs index 8b5c8505d3ad7..e1093c303b6bb 100644 --- a/src/test/ui/issues/issue-7607-2.rs +++ b/src/test/ui/issues/issue-7607-2.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub mod a { pub struct Foo { a: usize } diff --git a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs index 7dd6b07177f93..0d47c6a2d1e39 100644 --- a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* diff --git a/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs b/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs index e4dafc073ab3b..512f2121f14db 100644 --- a/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs +++ b/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) /* diff --git a/src/test/ui/issues/issue-8398.rs b/src/test/ui/issues/issue-8398.rs index bd37b8582b204..dc6af360e991a 100644 --- a/src/test/ui/issues/issue-8398.rs +++ b/src/test/ui/issues/issue-8398.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub trait Writer { fn write(&mut self, b: &[u8]) -> Result<(), ()>; diff --git a/src/test/ui/issues/issue-8578.rs b/src/test/ui/issues/issue-8578.rs index 4cc21234796ae..00f6e1f47be41 100644 --- a/src/test/ui/issues/issue-8578.rs +++ b/src/test/ui/issues/issue-8578.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) pub struct UninterpretedOption_NamePart { name_part: Option, diff --git a/src/test/ui/issues/issue-9110.rs b/src/test/ui/issues/issue-9110.rs index 30acd61a34a09..ecd42685399e1 100644 --- a/src/test/ui/issues/issue-9110.rs +++ b/src/test/ui/issues/issue-9110.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![allow(non_snake_case)] macro_rules! silly_macro { diff --git a/src/test/ui/issues/issue-9243.rs b/src/test/ui/issues/issue-9243.rs index e877dd6492214..558938936aa4f 100644 --- a/src/test/ui/issues/issue-9243.rs +++ b/src/test/ui/issues/issue-9243.rs @@ -1,13 +1,13 @@ // compile-pass + #![allow(dead_code)] -// Regression test for issue 9243 #![allow(non_upper_case_globals)] pub struct Test { mem: isize, } -pub static g_test: Test = Test {mem: 0}; +pub static g_test: Test = Test { mem: 0 }; impl Drop for Test { fn drop(&mut self) {} diff --git a/src/test/ui/issues/issue-9249.rs b/src/test/ui/issues/issue-9249.rs index e4e9c4597192e..92b62702a5030 100644 --- a/src/test/ui/issues/issue-9249.rs +++ b/src/test/ui/issues/issue-9249.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) static DATA:&'static [&'static str] = &["my string"]; fn main() { } diff --git a/src/test/ui/issues/issue-9719.rs b/src/test/ui/issues/issue-9719.rs index 96865344e7464..8e6e0a5375c6e 100644 --- a/src/test/ui/issues/issue-9719.rs +++ b/src/test/ui/issues/issue-9719.rs @@ -1,6 +1,6 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) mod a { pub enum Enum { diff --git a/src/test/ui/layout/homogeneous-aggr-zero-sized-c-struct.rs b/src/test/ui/layout/homogeneous-aggr-zero-sized-c-struct.rs index 622709e7de584..e3be7fb11932e 100644 --- a/src/test/ui/layout/homogeneous-aggr-zero-sized-c-struct.rs +++ b/src/test/ui/layout/homogeneous-aggr-zero-sized-c-struct.rs @@ -1,7 +1,7 @@ #![feature(rustc_attrs)] // Show that `homogeneous_aggregate` code ignores zero-length C -// arrays. This matches the recent C standard, though not the +// arrays. This matches the recent C standard, though not the // behavior of all older compilers, which somtimes consider `T[0]` to // be a "flexible array member" (see discussion on #56877 for // details). diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs index 1c288a7e44f37..14e3d9fbc1268 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs @@ -5,7 +5,7 @@ trait Future { use std::error::Error; -fn foo() -> impl Future> { +fn foo() -> impl Future> { //~^ ERROR missing lifetime Ok(()) } diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index b2a3d9a94361f..dd037bb1ee50b 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier - --> $DIR/lifetime-elision-return-type-trait.rs:8:44 + --> $DIR/lifetime-elision-return-type-trait.rs:8:46 | -LL | fn foo() -> impl Future> { - | ^^^^^ help: consider giving it a 'static lifetime: `Error + 'static` +LL | fn foo() -> impl Future> { + | ^^^^^ help: consider giving it a 'static lifetime: `Error + 'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs index 99949e17b6f4a..98a195835123b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs @@ -1,4 +1,4 @@ -// FIXME: Change to UI Test +// FIXME: change to UI test. // Check notes are placed on an assignment that can actually precede the current assignment // Don't emit a first assignment for assignment in a loop. diff --git a/src/test/ui/lint/lint-missing-copy-implementations.rs b/src/test/ui/lint/lint-missing-copy-implementations.rs index 918f40de15378..354b6615426ac 100644 --- a/src/test/ui/lint/lint-missing-copy-implementations.rs +++ b/src/test/ui/lint/lint-missing-copy-implementations.rs @@ -1,4 +1,4 @@ -// See issue 19712 +// Test for issue #19712. #![deny(missing_copy_implementations)] diff --git a/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs b/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs index c2fdfb4fe421a..f06e245a7dc95 100644 --- a/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs +++ b/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs @@ -3,7 +3,7 @@ #![allow(dead_code)] // This is ok because we often use the trailing underscore to mean 'prime' -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #[forbid(non_camel_case_types)] type Foo_ = isize; diff --git a/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs b/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs index 9a6487d254239..9f00dd94bcf1b 100644 --- a/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs +++ b/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] -// pretty-expanded FIXME #23616 +// pretty-expanded FIXME(#23616) #![feature(non_ascii_idents)] #![deny(non_snake_case)] diff --git a/src/test/ui/lint/lint-unconditional-recursion.rs b/src/test/ui/lint/lint-unconditional-recursion.rs index 44af1179097ed..1f54300baa317 100644 --- a/src/test/ui/lint/lint-unconditional-recursion.rs +++ b/src/test/ui/lint/lint-unconditional-recursion.rs @@ -124,7 +124,7 @@ fn all_fine() { let _f = all_fine; } -// issue 26333 +// issue #26333 trait Bar { fn method(&self, x: &T) { x.method(x) diff --git a/src/test/ui/lint/lint-unknown-feature-default.rs b/src/test/ui/lint/lint-unknown-feature-default.rs index e04363faf4b60..689dbff160d6f 100644 --- a/src/test/ui/lint/lint-unknown-feature-default.rs +++ b/src/test/ui/lint/lint-unknown-feature-default.rs @@ -1,7 +1,7 @@ // Tests the default for the unused_features lint #![allow(stable_features)] -// FIXME(#44232) we should warn that this isn't used. +// FIXME(#44232): we should warn that this isn't used. #![feature(rust1)] // compile-pass diff --git a/src/test/ui/lint/lint-unknown-feature.rs b/src/test/ui/lint/lint-unknown-feature.rs index c372a980bed5e..18f595bc83153 100644 --- a/src/test/ui/lint/lint-unknown-feature.rs +++ b/src/test/ui/lint/lint-unknown-feature.rs @@ -1,10 +1,9 @@ -#![warn(unused_features)] +// compile-pass -#![allow(stable_features)] -// FIXME(#44232) we should warn that this isn't used. +// FIXME(#44232): we should warn that this isn't used. #![feature(rust1)] -// compile-pass - +#![allow(stable_features)] +#![warn(unused_features)] fn main() {} diff --git a/src/test/ui/loops/loops-reject-duplicate-labels.rs b/src/test/ui/loops/loops-reject-duplicate-labels.rs index 27f9862f70da5..b5046a606fcc2 100644 --- a/src/test/ui/loops/loops-reject-duplicate-labels.rs +++ b/src/test/ui/loops/loops-reject-duplicate-labels.rs @@ -27,13 +27,13 @@ fn foo() { //~^ WARN label name `'lt` shadows a label name that is already in scope } -// Note however that it is okay for the same label to be reused in +// Note however that it is ok for the same label to be reused in // different methods of one impl, as illustrated here. struct S; impl S { - fn m1(&self) { 'okay: loop { break 'okay; } } - fn m2(&self) { 'okay: loop { break 'okay; } } + fn m1(&self) { 'ok: loop { break 'ok; } } + fn m2(&self) { 'ok: loop { break 'ok; } } } diff --git a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs index f48e984845665..5bc681bb2a212 100644 --- a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs +++ b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs @@ -7,7 +7,7 @@ // Test rejection of lifetimes in *expressions* that shadow loop labels. fn foo() { - // Reusing lifetime `'a` in function item is okay. + // Reusing lifetime `'a` in function item is ok. fn foo<'a>(x: &'a i8) -> i8 { *x } // So is reusing `'a` in struct item diff --git a/src/test/ui/macros/format-foreign.rs b/src/test/ui/macros/format-foreign.rs index ac65838f21d85..2543ee073995f 100644 --- a/src/test/ui/macros/format-foreign.rs +++ b/src/test/ui/macros/format-foreign.rs @@ -5,10 +5,10 @@ fn main() { %s!\n "###, "Hello,", "World", 4); //~^ ERROR multiple unused formatting arguments - // correctly account for raw strings in inline suggestions + // Correctly account for raw strings in inline suggestions. // This should *not* produce hints, on the basis that there's equally as - // many "correct" format specifiers. It's *probably* just an actual typo. + // many "correct" format specifiers. It's *probably* just an actual typo. println!("{} %f", "one", 2.0); //~ ERROR never used println!("Hi there, $NAME.", NAME="Tim"); //~ ERROR never used diff --git a/src/test/ui/macros/nonterminal-matching.rs b/src/test/ui/macros/nonterminal-matching.rs index 0ccdf6e5f2e74..a3a97e9ce5398 100644 --- a/src/test/ui/macros/nonterminal-matching.rs +++ b/src/test/ui/macros/nonterminal-matching.rs @@ -1,4 +1,4 @@ -// Check that we are refusing to match on complex nonterminals for which tokens are +// Check that we are refusing to match on complex non-terminals for which tokens are // unavailable and we'd have to go through AST comparisons. #![feature(decl_macro)] diff --git a/src/test/ui/match/match-range-fail-dominate.rs b/src/test/ui/match/match-range-fail-dominate.rs index 99069183e4eda..ae7135905a155 100644 --- a/src/test/ui/match/match-range-fail-dominate.rs +++ b/src/test/ui/match/match-range-fail-dominate.rs @@ -1,8 +1,8 @@ -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable +// error-pattern: unreachable +// error-pattern: unreachable +// error-pattern: unreachable +// error-pattern: unreachable +// error-pattern: unreachable #![deny(unreachable_patterns)] diff --git a/src/test/ui/methods/method-call-lifetime-args-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-fail.stderr index 74dab5f440064..ec00bc88513be 100644 --- a/src/test/ui/methods/method-call-lifetime-args-fail.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-fail.stderr @@ -10,169 +10,169 @@ error[E0107]: wrong number of lifetime arguments: expected 2, found 3 LL | S.early::<'static, 'static, 'static>(); | ^^^^^^^ unexpected lifetime argument -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:27:15 | LL | S::late::<'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:29:15 | LL | S::late::<'static, 'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:31:15 | LL | S::late::<'static, 'static, 'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:34:21 | LL | S::late_early::<'static, 'static>(S, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:7:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:36:21 | LL | S::late_early::<'static, 'static, 'static>(S, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:7:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:40:24 | LL | S::late_implicit::<'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:42:24 | LL | S::late_implicit::<'static, 'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:44:24 | LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:47:30 | LL | S::late_implicit_early::<'static, 'static>(S, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:8:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:49:30 | LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:8:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:52:35 | LL | S::late_implicit_self_early::<'static, 'static>(&S); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:9:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:54:35 | LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:9:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:57:28 | LL | S::late_unused_early::<'static, 'static>(S); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:10:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:59:28 | LL | S::late_unused_early::<'static, 'static, 'static>(S); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:10:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr index b510a08ae3775..423bcfa6dbcf8 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr @@ -1,8 +1,8 @@ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:23:14 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late::<'static>(&0, &0); | ^^^^^^^ @@ -15,11 +15,11 @@ LL | #![deny(late_bound_lifetime_arguments)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:26:14 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late::<'static, 'static>(&0, &0); | ^^^^^^^ @@ -27,11 +27,11 @@ LL | S.late::<'static, 'static>(&0, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:29:14 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late::<'static, 'static, 'static>(&0, &0); | ^^^^^^^ @@ -39,11 +39,11 @@ LL | S.late::<'static, 'static, 'static>(&0, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:33:20 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late_early::<'static>(&0); | ^^^^^^^ @@ -51,11 +51,11 @@ LL | S.late_early::<'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:36:20 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late_early::<'static, 'static>(&0); | ^^^^^^^ @@ -63,11 +63,11 @@ LL | S.late_early::<'static, 'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:39:20 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late_early::<'static, 'static, 'static>(&0); | ^^^^^^^ @@ -75,11 +75,11 @@ LL | S.late_early::<'static, 'static, 'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:44:23 | LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ @@ -87,11 +87,11 @@ LL | S.late_implicit::<'static>(&0, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:47:23 | LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit::<'static, 'static>(&0, &0); | ^^^^^^^ @@ -99,11 +99,11 @@ LL | S.late_implicit::<'static, 'static>(&0, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:50:23 | LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); | ^^^^^^^ @@ -111,11 +111,11 @@ LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:54:29 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit_early::<'static>(&0); | ^^^^^^^ @@ -123,11 +123,11 @@ LL | S.late_implicit_early::<'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:57:29 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit_early::<'static, 'static>(&0); | ^^^^^^^ @@ -135,11 +135,11 @@ LL | S.late_implicit_early::<'static, 'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:60:29 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit_early::<'static, 'static, 'static>(&0); | ^^^^^^^ @@ -147,11 +147,11 @@ LL | S.late_implicit_early::<'static, 'static, 'static>(&0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:69:21 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S::late_early::<'static>(S, &0); | ^^^^^^^ @@ -159,11 +159,11 @@ LL | S::late_early::<'static>(S, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:73:30 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S::late_implicit_early::<'static>(S, &0); | ^^^^^^^ @@ -171,11 +171,11 @@ LL | S::late_implicit_early::<'static>(S, &0); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint-fail.rs:82:9 | LL | fn f<'early, 'late, T: 'early>() {} - | ----- the late bound lifetime parameter is introduced here + | ----- the late-bound lifetime parameter is introduced here ... LL | f::<'static, u8>; | ^^^^^^^ diff --git a/src/test/ui/methods/method-call-lifetime-args-lint.stderr b/src/test/ui/methods/method-call-lifetime-args-lint.stderr index eb1d4fe2e504e..835aa498ffbad 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-lint.stderr @@ -1,8 +1,8 @@ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint.rs:12:14 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here + | -- the late-bound lifetime parameter is introduced here ... LL | S.late::<'static>(&0, &0); | ^^^^^^^ @@ -15,11 +15,11 @@ LL | #![deny(late_bound_lifetime_arguments)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args-lint.rs:16:23 | LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here + | - the late-bound lifetime parameter is introduced here ... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ diff --git a/src/test/ui/methods/method-call-lifetime-args.stderr b/src/test/ui/methods/method-call-lifetime-args.stderr index 64ae79e9bb2b7..00fc1da749d4b 100644 --- a/src/test/ui/methods/method-call-lifetime-args.stderr +++ b/src/test/ui/methods/method-call-lifetime-args.stderr @@ -1,22 +1,22 @@ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:9:15 | LL | S::late::<'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late-bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:11:24 | LL | S::late_implicit::<'static>(S, &0, &0); | ^^^^^^^ | -note: the late bound lifetime parameter is introduced here +note: the late-bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} diff --git a/src/test/ui/module-macro_use-arguments.rs b/src/test/ui/module-macro_use-arguments.rs index 6627b48eb6a2c..121b492e25437 100644 --- a/src/test/ui/module-macro_use-arguments.rs +++ b/src/test/ui/module-macro_use-arguments.rs @@ -1,4 +1,4 @@ -#[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here +#[macro_use(foo, bar)] //~ ERROR arguments to `macro_use` are not allowed here mod foo { } diff --git a/src/test/ui/module-macro_use-arguments.stderr b/src/test/ui/module-macro_use-arguments.stderr index 4dc6df39a4797..bf7a1408ca2a7 100644 --- a/src/test/ui/module-macro_use-arguments.stderr +++ b/src/test/ui/module-macro_use-arguments.stderr @@ -1,7 +1,7 @@ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/module-macro_use-arguments.rs:1:1 | -LL | #[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here +LL | #[macro_use(foo, bar)] //~ ERROR arguments to `macro_use` are not allowed here | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/moves/move-guard-same-consts.rs b/src/test/ui/moves/move-guard-same-consts.rs index a2beb368b6e60..d035599b8c681 100644 --- a/src/test/ui/moves/move-guard-same-consts.rs +++ b/src/test/ui/moves/move-guard-same-consts.rs @@ -4,7 +4,7 @@ // // THis was broken for various reasons. In particular, that hack was // originally authored under the assunption that other checks -// elsewhere would ensure that the two patterns did not overlap. But +// elsewhere would ensure that the two patterns did not overlap. But // that assumption did not hold, at least not in the long run (namely, // overlapping patterns were turned into warnings rather than errors). diff --git a/src/test/ui/multiple-plugin-registrars.rs b/src/test/ui/multiple-plugin-registrars.rs index d211204b134be..1547224084200 100644 --- a/src/test/ui/multiple-plugin-registrars.rs +++ b/src/test/ui/multiple-plugin-registrars.rs @@ -2,7 +2,7 @@ #![feature(plugin_registrar)] -// the registration function isn't typechecked yet +// The registration function isn't type-checked yet. #[plugin_registrar] pub fn one() {} diff --git a/src/test/ui/nested_impl_trait.rs b/src/test/ui/nested_impl_trait.rs index be2c21a7743ce..efa51e46426d7 100644 --- a/src/test/ui/nested_impl_trait.rs +++ b/src/test/ui/nested_impl_trait.rs @@ -18,7 +18,7 @@ impl X { //~^ ERROR nested `impl Trait` is not allowed } -fn allowed_in_assoc_type() -> impl Iterator { +fn allowed_in_assoc_type() -> impl Iterator { vec![|| println!("woot")].into_iter() } diff --git a/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs b/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs index 59936a8092534..c5fa38ace9488 100644 --- a/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs +++ b/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs @@ -1,7 +1,7 @@ -// // run-pass -// -// FIXME(#54366) - We probably shouldn't allow #[thread_local] static mut to get a 'static lifetime. + +// FIXME(#54366): we probably shouldn't allow `#[thread_local]` static mut to get a `'static` +// lifetime. #![feature(nll)] #![feature(thread_local)] diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.rs b/src/test/ui/nll/closure-requirements/escape-argument-callee.rs index 9b3a49b7b7e0a..dc7ca3f4203fc 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.rs +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.rs @@ -8,7 +8,7 @@ // error is reported by the closure itself and is not propagated to // its creator: this is because `'a` and `'b` are higher-ranked // (late-bound) regions and the closure is not allowed to propagate -// additional where clauses between higher-ranked regions, only those +// additional where-clauses between higher-ranked regions, only those // that appear free in its type (hence, we see it before the closure's // "external requirements" report). diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs b/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs index a916ccd6c21a2..63618ce3049b9 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs @@ -6,7 +6,7 @@ // Both of these are upvars of reference type (the capture of `y` is // of type `&'a i32`, the capture of `p` is of type `&mut &'b // i32`). The closure thus computes a relationship between `'a` and -// `'b`. This relationship is propagated to the closure creator, +// `'b`. This relationship is propagated to the closure creator, // which reports an error. // compile-flags:-Zborrowck=mir -Zverbose diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.rs b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.rs index d1945f4864c9a..d53412ff340a2 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.rs +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.rs @@ -1,6 +1,6 @@ // Test where we might in theory be able to see that the relationship // between two bound regions is true within closure and hence have no -// need to propagate; but in fact we do because identity of free +// need to propagate, but in fact we do because identity of free // regions is erased. // compile-flags:-Zborrowck=mir -Zverbose diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs index c1467fcc9b6cf..0fc4ed8c1942c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs @@ -19,7 +19,7 @@ use std::cell::Cell; // 'b: 'y // // but this doesn't really help us in proving that `'x: 'y`, so -// closure gets an error. In particular, we would need to know that +// closure gets an error. In particular, we would need to know that // `'x: 'a`, so that we could approximate `'x` "downwards" to `'a`. fn establish_relationships<'a, 'b, F>(_cell_a: &Cell<&'a u32>, _cell_b: &Cell<&'b u32>, _closure: F) where diff --git a/src/test/ui/nll/issue-21232-partial-init-and-use.rs b/src/test/ui/nll/issue-21232-partial-init-and-use.rs index 633cbdba2d40e..cab6190fdb4c8 100644 --- a/src/test/ui/nll/issue-21232-partial-init-and-use.rs +++ b/src/test/ui/nll/issue-21232-partial-init-and-use.rs @@ -164,8 +164,8 @@ fn test_0201_local_void_init_and_use_tuple() { use_part!(tuple t); } -// NOTE: uniform structure of tests here makes n21n (aka combining -// Void with Reinit) an (even more) senseless case, as we cannot +// NOTE: uniform structure of tests here makes n21n (i.e., combining +// `Void` with `Reinit`) an (even more) senseless case, as we cannot // safely create initial instance containing Void to move out of and // then reinitialize. While I was tempted to sidestep this via some // unsafe code (eek), lets just instead not encode such tests. diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs index ec4eed6797600..36e3fbf75e58a 100644 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ b/src/test/ui/nll/match-guards-always-borrow.rs @@ -1,4 +1,4 @@ -//revisions: ast mir +// revisions: ast mir //[mir] compile-flags: -Z borrowck=mir #![feature(rustc_attrs)] diff --git a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs index 5b609820a237f..644a7b7236df7 100644 --- a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs +++ b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs @@ -18,5 +18,5 @@ fn main() { let foo = Foo { a: s, b: wrap }; std::mem::drop(foo.b); x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] - // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones + // FIXME: ^ Should not error in the future with implicit dtors, only manually implemented ones } diff --git a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr index 3ff778675bcf4..4ad07fc6b411d 100644 --- a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr +++ b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr @@ -6,7 +6,7 @@ LL | let wrap = Wrap { p: &mut x }; ... LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] | ^^^^^ assignment to borrowed `x` occurs here -LL | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones +LL | // FIXME: ^ Should not error in the future with implicit dtors, only manually implemented ones LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs b/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs index d6cea55c1e07d..f3c47c7c51a22 100644 --- a/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs +++ b/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs @@ -1,4 +1,4 @@ -//compile-flags: -Zborrowck=mir +// compile-flags: -Zborrowck=mir #![allow(warnings)] diff --git a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs index d2d1b98c41c14..0693047ff14af 100644 --- a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs +++ b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs @@ -1,4 +1,4 @@ -//compile-flags: -Zborrowck=mir +// compile-flags: -Zborrowck=mir #![allow(warnings)] @@ -20,5 +20,5 @@ fn main() { std::mem::drop(foo.a); std::mem::drop(foo.b); x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] - // FIXME ^ This currently errors and it should not. + // FIXME: ^ This currently errors and it should not. } diff --git a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr index aa9544927f899..b8a40f6355f94 100644 --- a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr +++ b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr @@ -6,7 +6,7 @@ LL | let wrap = Wrap { p: &mut x }; ... LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] | ^^^^^ assignment to borrowed `x` occurs here -LL | // FIXME ^ This currently errors and it should not. +LL | // FIXME: ^ This currently errors and it should not. LL | } | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` diff --git a/src/test/ui/nll/maybe-initialized-drop.rs b/src/test/ui/nll/maybe-initialized-drop.rs index cd12e93d555ff..71a8b3fcdba1d 100644 --- a/src/test/ui/nll/maybe-initialized-drop.rs +++ b/src/test/ui/nll/maybe-initialized-drop.rs @@ -1,4 +1,4 @@ -//compile-flags: -Zborrowck=mir +// compile-flags: -Zborrowck=mir #![allow(warnings)] diff --git a/src/test/ui/nll/mir_check_cast_reify.rs b/src/test/ui/nll/mir_check_cast_reify.rs index be12e313b42e6..13e8cda0ce1ee 100644 --- a/src/test/ui/nll/mir_check_cast_reify.rs +++ b/src/test/ui/nll/mir_check_cast_reify.rs @@ -8,7 +8,7 @@ // This test is a bit tortured, let me explain: // -// The `where 'a: 'a` clause here ensures that `'a` is early bound, +// The `where 'a: 'a` clause here ensures that `'a` is early-bound, // which is needed below to ensure that this test hits the path we are // concerned with. fn foo<'a>(x: &'a u32) -> &'a u32 diff --git a/src/test/ui/nll/normalization-bounds.rs b/src/test/ui/nll/normalization-bounds.rs index ebc19d7cc8350..df5064be666bb 100644 --- a/src/test/ui/nll/normalization-bounds.rs +++ b/src/test/ui/nll/normalization-bounds.rs @@ -1,6 +1,6 @@ // Check that lifetime bounds get checked the right way around with NLL enabled. -//run-pass +// run-pass #![feature(nll)] trait Visitor<'d> { diff --git a/src/test/ui/nll/reference-carried-through-struct-field.rs b/src/test/ui/nll/reference-carried-through-struct-field.rs index f7903cba6a22c..9b745a366e810 100644 --- a/src/test/ui/nll/reference-carried-through-struct-field.rs +++ b/src/test/ui/nll/reference-carried-through-struct-field.rs @@ -1,4 +1,4 @@ -//revisions: ast mir +// revisions: ast mir //[mir] compile-flags: -Z borrowck=mir #![allow(unused_assignments)] diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs index 17d5f2e1aeab8..6ec9469aefe7d 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs @@ -4,9 +4,9 @@ // ways: // // - by ensuring that `T: 'a` and `'b: 'a`, or -// - by something in the where clauses. +// - by something in the where-clauses. // -// As of this writing, the where clause option does not work because +// As of this writing, the where-clause option does not work because // of limitations in our region inferencing system (this is true both // with and without NLL). See `projection_outlives`. // diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs b/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs index c6935badf54b2..485c3dd0d5cab 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs @@ -1,7 +1,7 @@ #![feature(nll)] // Test that when we have a `>::Output: 'a` -// relationship in the environment we take advantage of it. In this +// relationship in the environment we take advantage of it. In this // case, that means we **don't** have to prove that `T: 'a`. // // Regression test for #53121. diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs index 7fce771fc8b6e..0ee322d7eb7b2 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs @@ -17,7 +17,7 @@ where T: Debug, { // Here, the closure winds up being required to prove that `T: - // 'a`. In principle, it could know that, except that it is + // 'a`. In principle, it could know that, except that it is // type-checked in a fully generic way, and hence it winds up with // a propagated requirement that `T: '_#2`, where `'_#2` appears // in the return type. The caller makes the mapping from `'_#2` to diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs index c93172885bfcc..bedf5fba5bc3a 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs @@ -1,4 +1,4 @@ -// Test that we can propagate `T: 'a` obligations to our caller. See +// Test that we can propagate `T: 'a` obligations to our caller. See // `correct_region` for an explanation of how this test is setup; it's // somewhat intricate. @@ -28,7 +28,7 @@ fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { //~^ ERROR the parameter type `T` may not live long enough // // See `correct_region`, which explains the point of this - // test. The only difference is that, in the case of this + // test. The only difference is that, in the case of this // function, there is no where clause *anywhere*, and hence we // get an error (but reported by the closure creator). require(&x, &y) @@ -63,7 +63,7 @@ where { with_signature(a, b, |x, y| { //~^ ERROR the parameter type `T` may not live long enough - // See `correct_region` + // See `correct_region`. require(&x, &y) }) } @@ -75,7 +75,7 @@ where 'b: 'a, { with_signature(a, b, |x, y| { - // See `correct_region` + // See `correct_region`. require(&x, &y) }) } diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index a76a9463cc801..6ada2e361f55a 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -96,7 +96,7 @@ note: External requirements LL | with_signature(a, b, |x, y| { | __________________________^ LL | | //~^ ERROR the parameter type `T` may not live long enough -LL | | // See `correct_region` +LL | | // See `correct_region`. LL | | require(&x, &y) LL | | }) | |_____^ @@ -134,7 +134,7 @@ error[E0309]: the parameter type `T` may not live long enough LL | with_signature(a, b, |x, y| { | __________________________^ LL | | //~^ ERROR the parameter type `T` may not live long enough -LL | | // See `correct_region` +LL | | // See `correct_region`. LL | | require(&x, &y) LL | | }) | |_____^ @@ -146,7 +146,7 @@ note: External requirements | LL | with_signature(a, b, |x, y| { | __________________________^ -LL | | // See `correct_region` +LL | | // See `correct_region`. LL | | require(&x, &y) LL | | }) | |_____^ diff --git a/src/test/ui/nll/user-annotations/issue-55219.rs b/src/test/ui/nll/user-annotations/issue-55219.rs index 7daa5a59b9977..99d8a6ac5cc09 100644 --- a/src/test/ui/nll/user-annotations/issue-55219.rs +++ b/src/test/ui/nll/user-annotations/issue-55219.rs @@ -1,8 +1,6 @@ -// Regression test for #55219: -// -// The `Self::HASH_LEN` here expands to a "self-type" where `T` is not +// The `Self::HASH_LEN` here expands to a self type where `T` is not // known. This unbound inference variable was causing an ICE. -// + // run-pass #![feature(nll)] diff --git a/src/test/ui/no-warn-on-field-replace-issue-34101.rs b/src/test/ui/no-warn-on-field-replace-issue-34101.rs index af6ccf35d538c..57a6dfa92f778 100644 --- a/src/test/ui/no-warn-on-field-replace-issue-34101.rs +++ b/src/test/ui/no-warn-on-field-replace-issue-34101.rs @@ -1,9 +1,9 @@ -// Issue 34101: Circa 2016-06-05, `fn inline` below issued an +// Issue #34101: circa 2016-06-05, `fn inline` below issued an // erroneous warning from the elaborate_drops pass about moving out of // a field in `Foo`, which has a destructor (and thus cannot have // content moved out of it). The reason that the warning is erroneous // in this case is that we are doing a *replace*, not a move, of the -// content in question, and it is okay to replace fields within `Foo`. +// content in question, and it is ok to replace fields within `Foo`. // // Another more subtle problem was that the elaborate_drops was // creating a separate drop flag for that internally replaced content, @@ -11,13 +11,6 @@ // flag for such subcontent of `Foo` will always have the same value // as the drop flag for `Foo` itself. - - - - - - - // compile-pass struct Foo(String); @@ -27,7 +20,7 @@ impl Drop for Foo { } fn inline() { - // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) + // Dummy variable so `f` gets assigned `var1` in MIR for both fn's. let _s = (); let mut f = Foo(String::from("foo")); f.0 = String::from("bar"); diff --git a/src/test/ui/no_crate_type.rs b/src/test/ui/no_crate_type.rs index 392c6fd0dfa13..8c42c88314bcc 100644 --- a/src/test/ui/no_crate_type.rs +++ b/src/test/ui/no_crate_type.rs @@ -1,5 +1,5 @@ -// regression test for issue 11256 -#![crate_type] //~ ERROR attribute must be of the form +// Regression test for issue #11256. +#![crate_type] //~ ERROR attribute must be of the form fn main() { return diff --git a/src/test/ui/no_crate_type.stderr b/src/test/ui/no_crate_type.stderr index 6b76ab68658cd..a627e2dfd683b 100644 --- a/src/test/ui/no_crate_type.stderr +++ b/src/test/ui/no_crate_type.stderr @@ -1,7 +1,7 @@ error: attribute must be of the form `#[crate_type = "bin|lib|..."]` --> $DIR/no_crate_type.rs:2:1 | -LL | #![crate_type] //~ ERROR attribute must be of the form +LL | #![crate_type] //~ ERROR attribute must be of the form | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/object-safety/object-safety-by-value-self.rs b/src/test/ui/object-safety/object-safety-by-value-self.rs index dee31f6e370f9..8d0e1db320376 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self.rs @@ -13,7 +13,7 @@ trait Baz { } trait Quux { - // Legal because of the where clause: + // Legal because of the where-clause: fn baz(self: Self) where Self : Sized; } diff --git a/src/test/ui/on-unimplemented/bad-annotation.rs b/src/test/ui/on-unimplemented/bad-annotation.rs index 846db63024cfb..c562c219ee67c 100644 --- a/src/test/ui/on-unimplemented/bad-annotation.rs +++ b/src/test/ui/on-unimplemented/bad-annotation.rs @@ -11,7 +11,7 @@ trait Foo #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] trait MyFromIterator { /// Builds a container with elements from an external iterator. - fn my_from_iter>(iterator: T) -> Self; + fn my_from_iter>(iterator: T) -> Self; } #[rustc_on_unimplemented] diff --git a/src/test/ui/on-unimplemented/on-trait.rs b/src/test/ui/on-unimplemented/on-trait.rs index 109cb5ba96942..4a2e37db0387c 100644 --- a/src/test/ui/on-unimplemented/on-trait.rs +++ b/src/test/ui/on-unimplemented/on-trait.rs @@ -16,10 +16,10 @@ fn foobar>() -> T { #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] trait MyFromIterator { /// Builds a container with elements from an external iterator. - fn my_from_iter>(iterator: T) -> Self; + fn my_from_iter>(iterator: T) -> Self; } -fn collect, B: MyFromIterator>(it: I) -> B { +fn collect, B: MyFromIterator>(it: I) -> B { MyFromIterator::my_from_iter(it) } diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index 939c2725cc472..581de87154946 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -8,8 +8,8 @@ LL | let y: Option> = collect(x.iter()); // this should give approxi note: required by `collect` --> $DIR/on-trait.rs:22:1 | -LL | fn collect, B: MyFromIterator>(it: I) -> B { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn collect, B: MyFromIterator>(it: I) -> B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:31:21 diff --git a/src/test/ui/osx-frameworks.rs b/src/test/ui/osx-frameworks.rs index 227e07de9a81e..10ae2544c72fb 100644 --- a/src/test/ui/osx-frameworks.rs +++ b/src/test/ui/osx-frameworks.rs @@ -1,4 +1,4 @@ -// ignore-macos this is supposed to succeed on osx +// ignore-macos this is supposed to succeed on macOS #[link(name = "foo", kind = "framework")] extern {} diff --git a/src/test/ui/overlap-marker-trait.rs b/src/test/ui/overlap-marker-trait.rs index bf39d9c903f80..4b2ec7a6064f6 100644 --- a/src/test/ui/overlap-marker-trait.rs +++ b/src/test/ui/overlap-marker-trait.rs @@ -1,7 +1,7 @@ // Test for RFC 1268: we allow overlapping impls of marker traits, // that is, traits without items. In this case, a type `T` is // `MyMarker` if it is either `Debug` or `Display`. This test just -// checks that we don't consider **all** types to be `MyMarker`. See +// checks that we don't consider **all** types to be `MyMarker`. See // also the companion test in // `run-pass/overlap-permitted-for-marker-traits.rs`. diff --git a/src/test/ui/parser/fn-arg-doc-comment.rs b/src/test/ui/parser/fn-arg-doc-comment.rs index 22af94b628452..14cce418f4033 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.rs +++ b/src/test/ui/parser/fn-arg-doc-comment.rs @@ -18,7 +18,7 @@ fn bar(id: #[allow(dead_code)] i32) {} //~| NOTE attributes are not allowed here fn main() { - // verify that the parser recovered and properly typechecked the args + // Verify that the parser recovered and properly type-checked the args. f("", ""); //~^ ERROR mismatched types //~| NOTE expected u8, found reference diff --git a/src/test/ui/parser/issue-10636-2.rs b/src/test/ui/parser/issue-10636-2.rs index 6fb63639d5f60..44154688a9b10 100644 --- a/src/test/ui/parser/issue-10636-2.rs +++ b/src/test/ui/parser/issue-10636-2.rs @@ -1,4 +1,4 @@ -// FIXME(31528) we emit a bunch of silly errors here due to continuing past the +// FIXME(31528): we emit a bunch of silly errors here due to continuing past the // first one. This would be easy-ish to address by better recovery in tokenisation. pub fn trace_option(option: Option) { diff --git a/src/test/ui/parser/underscore-suffix-for-string.stderr b/src/test/ui/parser/underscore-suffix-for-string.stderr index 80d0d1bc83b61..4112c1f69f412 100644 --- a/src/test/ui/parser/underscore-suffix-for-string.stderr +++ b/src/test/ui/parser/underscore-suffix-for-string.stderr @@ -5,5 +5,5 @@ LL | let _ = "Foo"_; | ^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42326 + = note: for more information, see diff --git a/src/test/ui/parser/where_with_bound.rs b/src/test/ui/parser/where_with_bound.rs index 3ca45f1889c9c..cb089ed3a402a 100644 --- a/src/test/ui/parser/where_with_bound.rs +++ b/src/test/ui/parser/where_with_bound.rs @@ -1,5 +1,5 @@ fn foo() where ::Item: ToString, T: Iterator { } -//~^ ERROR generic parameters on `where` clauses are reserved for future use +//~^ ERROR generic parameters on where-clauses are reserved for future use //~| ERROR cannot find type `Item` in the crate root fn main() {} diff --git a/src/test/ui/parser/where_with_bound.stderr b/src/test/ui/parser/where_with_bound.stderr index ff98b3f5fed61..908710eb4a14c 100644 --- a/src/test/ui/parser/where_with_bound.stderr +++ b/src/test/ui/parser/where_with_bound.stderr @@ -1,4 +1,4 @@ -error: generic parameters on `where` clauses are reserved for future use +error: generic parameters on where-clauses are reserved for future use --> $DIR/where_with_bound.rs:1:19 | LL | fn foo() where ::Item: ToString, T: Iterator { } diff --git a/src/test/ui/print_type_sizes/repr_int_c.rs b/src/test/ui/print_type_sizes/repr_int_c.rs index 6816bb71a0012..1b630dbeb6086 100644 --- a/src/test/ui/print_type_sizes/repr_int_c.rs +++ b/src/test/ui/print_type_sizes/repr_int_c.rs @@ -2,7 +2,7 @@ // compile-pass // This test makes sure that the tag is not grown for `repr(C)` or `repr(u8)` -// variants (see https://github.com/rust-lang/rust/issues/50098 for the original bug). +// variants (see issue #50098 for the original bug). #![feature(start)] #![allow(dead_code)] diff --git a/src/test/ui/privacy/private-in-public-warn.rs b/src/test/ui/privacy/private-in-public-warn.rs index 467b83746702b..737ba64ff1326 100644 --- a/src/test/ui/privacy/private-in-public-warn.rs +++ b/src/test/ui/privacy/private-in-public-warn.rs @@ -75,7 +75,7 @@ mod traits_where { pub type Alias where T: PrivTr = T; //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error - //~| WARNING where clauses are not enforced in type aliases + //~| WARNING where-clauses are not enforced in type aliases pub trait Tr2 where T: PrivTr {} //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr index 621d9a57fa076..12e68e21e9b1b 100644 --- a/src/test/ui/privacy/private-in-public-warn.stderr +++ b/src/test/ui/privacy/private-in-public-warn.stderr @@ -342,7 +342,7 @@ LL | pub type Alias = T; //~ ERROR private trait `traits::PrivTr` = note: #[warn(type_alias_bounds)] on by default = help: the bound will not be checked when the type alias is used, and should be removed -warning: where clauses are not enforced in type aliases +warning: where-clauses are not enforced in type aliases --> $DIR/private-in-public-warn.rs:75:29 | LL | pub type Alias where T: PrivTr = T; diff --git a/src/test/ui/proc-macro/issue-41211.rs b/src/test/ui/proc-macro/issue-41211.rs index 0b082f4818f1b..51217e164fdcc 100644 --- a/src/test/ui/proc-macro/issue-41211.rs +++ b/src/test/ui/proc-macro/issue-41211.rs @@ -1,7 +1,7 @@ // aux-build:issue-41211.rs -// FIXME: https://github.com/rust-lang/rust/issues/41430 -// This is a temporary regression test for the ICE reported in #41211 +// FIXME: issue #41430. +// This is a temporary regression test for the ICE reported in issue #41211. #![feature(custom_inner_attributes)] diff --git a/src/test/ui/proc-macro/proc-macro-gates2.rs b/src/test/ui/proc-macro/proc-macro-gates2.rs index 46b543a397cc7..daeba70cd53d7 100644 --- a/src/test/ui/proc-macro/proc-macro-gates2.rs +++ b/src/test/ui/proc-macro/proc-macro-gates2.rs @@ -6,7 +6,7 @@ extern crate proc_macro_gates as foo; use foo::*; -// NB. these errors aren't the best errors right now, but they're definitely +// N.B., these errors aren't the best errors right now, but they're definitely // intended to be errors. Somehow using a custom attribute in these positions // should either require a feature gate or not be allowed on stable. diff --git a/src/test/ui/proc-macro/span-preservation.rs b/src/test/ui/proc-macro/span-preservation.rs index 64f675ecc1c4d..9b8bc64898e97 100644 --- a/src/test/ui/proc-macro/span-preservation.rs +++ b/src/test/ui/proc-macro/span-preservation.rs @@ -36,7 +36,7 @@ fn c() { let y = Foo { a: 10, b: 10isize }; //~ ERROR has no field named `b` } -// FIXME: This doesn't work at the moment. See the one below. The pretty-printer +// FIXME: this doesn't work at the moment. See the one below. The pretty-printer // injects a "C" between `extern` and `fn` which causes a "probably_eq" // `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST. #[foo] diff --git a/src/test/ui/proc-macro/three-equals.rs b/src/test/ui/proc-macro/three-equals.rs index 50a144f7960b7..c21162a286054 100644 --- a/src/test/ui/proc-macro/three-equals.rs +++ b/src/test/ui/proc-macro/three-equals.rs @@ -8,7 +8,7 @@ extern crate three_equals; use three_equals::three_equals; fn main() { - // This one is okay. + // This one is ok. three_equals!(===); // Need exactly three equals. diff --git a/src/test/ui/recursion/recursion.rs b/src/test/ui/recursion/recursion.rs index ba3cc33dc30f9..10f6ca8a1ae52 100644 --- a/src/test/ui/recursion/recursion.rs +++ b/src/test/ui/recursion/recursion.rs @@ -1,22 +1,39 @@ -enum Nil {NilValue} -struct Cons {head:isize, tail:T} -trait Dot {fn dot(&self, other:Self) -> isize;} +enum Nil { + NilValue, +} + +struct Cons { + head: isize, + tail: T, +} + +trait Dot { + fn dot(&self, other: Self) -> isize; +} + impl Dot for Nil { - fn dot(&self, _:Nil) -> isize {0} + fn dot(&self, _: Nil) -> isize { + 0 + } } + impl Dot for Cons { - fn dot(&self, other:Cons) -> isize { - self.head * other.head + self.tail.dot(other.tail) - } + fn dot(&self, other: Cons) -> isize { + self.head * other.head + self.tail.dot(other.tail) + } } -fn test (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit - match n { 0 => {first.dot(second)} - // FIXME(#4287) Error message should be here. It should be - // a type error to instantiate `test` at a type other than T. - _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} - } + +fn test(n: isize, i: isize, first: T, second: T) -> isize { +//~^ ERROR recursion limit + match n { + 0 => {first.dot(second)} + // FIXME(#4287): error message should be here. It should be + // a type error to instantiate `test` at a type other than `T`. + _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + } } + pub fn main() { - let n = test(1, 0, Nil::NilValue, Nil::NilValue); - println!("{}", n); + let n = test(1, 0, Nil::NilValue, Nil::NilValue); + println!("{}", n); } diff --git a/src/test/ui/recursion/recursion.stderr b/src/test/ui/recursion/recursion.stderr index 1bef37ad58883..f2cc7d0e0c73c 100644 --- a/src/test/ui/recursion/recursion.stderr +++ b/src/test/ui/recursion/recursion.stderr @@ -1,12 +1,12 @@ error: reached the recursion limit while instantiating `test::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/recursion.rs:12:1 + --> $DIR/recursion.rs:26:1 | -LL | / fn test (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit -LL | | match n { 0 => {first.dot(second)} -LL | | // FIXME(#4287) Error message should be here. It should be -LL | | // a type error to instantiate `test` at a type other than T. -LL | | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} -LL | | } +LL | / fn test(n: isize, i: isize, first: T, second: T) -> isize { +LL | | //~^ ERROR recursion limit +LL | | match n { +LL | | 0 => {first.dot(second)} +... | +LL | | } LL | | } | |_^ diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs index ab4c6d9cf9198..01d9013f69946 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs @@ -1,10 +1,10 @@ fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { - // Note: this is legal because of the `'b:'a` declaration. + // Note: this is legal because of the `'b: 'a` declaration. *x = *y; } fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Illegal now because there is no `'b:'a` declaration. + // Illegal now because there is no `'b: 'a` declaration. *x = *y; //~ ERROR E0623 } @@ -15,15 +15,15 @@ fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { } fn d() { - // 'a and 'b are early bound in the function `a` because they appear + // `'a` and `'b` are early-bound in the function `a` because they appear // inconstraints: let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types } fn e() { - // 'a and 'b are late bound in the function `b` because there are + // `'a` and `'b` are late-bound in the function `b` because there are // no constraints: let _: fn(&mut &isize, &mut &isize) = b; } -fn main() { } +fn main() {} diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr index 47e1d0efdc77b..362233b2527da 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr @@ -3,7 +3,7 @@ error[E0623]: lifetime mismatch | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. +LL | // Illegal now because there is no `'b: 'a` declaration. LL | *x = *y; //~ ERROR E0623 | ^^ ...but data from `y` flows into `x` here diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs index 066522548ad45..4e440ed3eb2e6 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs @@ -1,11 +1,11 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c { - // Note: this is legal because of the `'b:'a` declaration. + // Note: this is legal because of the `'b: 'a` declaration. *x = *y; *z = *y; } fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - // Illegal now because there is no `'b:'a` declaration. + // Illegal now because there is no `'b: 'a` declaration. *x = *y; //~ ERROR E0623 *z = *y; //~ ERROR E0623 } @@ -17,15 +17,15 @@ fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { } fn d() { - // 'a and 'b are early bound in the function `a` because they appear + // `'a` and `'b` are early-bound in the function `a` because they appear // inconstraints: let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308 } fn e() { - // 'a and 'b are late bound in the function `b` because there are + // `'a` and `'b` are late-bound in the function `b` because there are // no constraints: let _: fn(&mut &isize, &mut &isize, &mut &isize) = b; } -fn main() { } +fn main() {} diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr index 1e7b99053f77f..18a020924a86c 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -3,7 +3,7 @@ error[E0623]: lifetime mismatch | LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. +LL | // Illegal now because there is no `'b: 'a` declaration. LL | *x = *y; //~ ERROR E0623 | ^^ ...but data from `y` flows into `x` here diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs index 1d53492199230..c94fcb95b8d05 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs @@ -1,5 +1,5 @@ // Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must +// type of a bound that appears in the where-clause on a struct must // outlive the location in which the type appears, even when the // associted type is in a supertype. Issue #22246. @@ -40,7 +40,7 @@ fn with_assoc<'a,'b>() { // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if + // FIXME(#54943): NLL doesn't enforce WF condition in unreachable code if // `_x` is changed to `_` let _x: &'a WithAssoc> = loop { }; //[ast]~^ ERROR reference has a longer lifetime diff --git a/src/test/ui/regions/regions-free-region-ordering-callee-4.rs b/src/test/ui/regions/regions-free-region-ordering-callee-4.rs index de58dd0b10f24..5af3487533533 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee-4.rs +++ b/src/test/ui/regions/regions-free-region-ordering-callee-4.rs @@ -1,5 +1,5 @@ // Tests that callees correctly infer an ordering between free regions -// that appear in their parameter list. See also +// that appear in their parameter list. See also // regions-free-region-ordering-caller.rs fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.rs b/src/test/ui/regions/regions-free-region-ordering-callee.rs index ee9a977a74f2d..f8328898a9960 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.rs +++ b/src/test/ui/regions/regions-free-region-ordering-callee.rs @@ -1,5 +1,5 @@ // Tests that callees correctly infer an ordering between free regions -// that appear in their parameter list. See also +// that appear in their parameter list. See also // regions-free-region-ordering-caller.rs fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index 7e04b6782eba1..cdd80f4faa717 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -1,5 +1,5 @@ // The "projection gap" is particularly "fun" around higher-ranked -// projections. This is because the current code is hard-coded to say +// projections. This is because the current code is hard-coded to say // that a projection that contains escaping regions, like `>::Foo` where `'z` is bound, can only be found to // outlive a region if all components that appear free (`'y`, where) diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs index 84161388a6e61..d26643c829c4f 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs @@ -1,14 +1,14 @@ // Test that a type which is contravariant with respect to its region // parameter yields an error when used in a covariant way. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: see `variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. use std::marker; -// This is contravariant with respect to 'a, meaning that -// Contravariant<'foo> <: Contravariant<'static> because -// 'foo <= 'static +// This is contravariant with respect to `'a`, meaning that +// `Contravariant<'foo> <: Contravariant<'static>` because +// `'foo <= 'static`. struct Contravariant<'a> { marker: marker::PhantomData<&'a()> } @@ -18,9 +18,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, l: &'long isize, _where:Option<&'short &'long ()>) { - // Test whether Contravariant<'short> <: Contravariant<'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. + // Test whether `Contravariant<'short> <: Contravariant<'long>`. Since + // `'short <= 'long`, this would be true if the `Contravariant` type were + // covariant with respect to its parameter `'a`. let _: Contravariant<'long> = c; //~ ERROR E0623 } diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs index b5079206578dc..f6c3b8884355c 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs @@ -1,7 +1,7 @@ // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: see `variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. use std::marker; @@ -15,9 +15,9 @@ fn use_<'short,'long>(c: Covariant<'long>, l: &'long isize, _where:Option<&'short &'long ()>) { - // Test whether Covariant<'long> <: Covariant<'short>. Since - // 'short <= 'long, this would be true if the Covariant type were - // contravariant with respect to its parameter 'a. + // Test whether `Covariant<'long> <: Covariant<'short>`. Since + // `'short <= 'long`, this would be true if the `Covariant` type were + // contravariant with respect to its parameter `'a`. let _: Covariant<'short> = c; //~ ERROR E0623 } diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs index 7d7f62e19792f..4d50c3485dc02 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs @@ -1,10 +1,10 @@ fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { - // Note: this is legal because of the `'b:'a` declaration. + // Note: this is legal because of the `'b: 'a` declaration. *x = *y; } fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Illegal now because there is no `'b:'a` declaration. + // Illegal now because there is no `'b: 'a` declaration. *x = *y; //~ ERROR E0623 } @@ -15,15 +15,15 @@ fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { } fn d() { - // 'a and 'b are early bound in the function `a` because they appear + // `'a` and `'b` are early-bound in the function `a` because they appear // inconstraints: let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR E0308 } fn e() { - // 'a and 'b are late bound in the function `b` because there are + // `'a` and `'b` are late-bound in the function `b` because there are // no constraints: let _: fn(&mut &isize, &mut &isize) = b; } -fn main() { } +fn main() {} diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr index a43ee7ec3ace0..b45b1a53886c2 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr @@ -3,7 +3,7 @@ error[E0623]: lifetime mismatch | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. +LL | // Illegal now because there is no `'b: 'a` declaration. LL | *x = *y; //~ ERROR E0623 | ^^ ...but data from `y` flows into `x` here diff --git a/src/test/ui/regions/regions-normalize-in-where-clause-list.rs b/src/test/ui/regions/regions-normalize-in-where-clause-list.rs index e94e8b25d6529..55c18f2ae7f97 100644 --- a/src/test/ui/regions/regions-normalize-in-where-clause-list.rs +++ b/src/test/ui/regions/regions-normalize-in-where-clause-list.rs @@ -12,16 +12,12 @@ impl<'a, 'b> Project<'a, 'b> for () } // No error here, we have 'a: 'b. We used to report an error here -// though, see https://github.com/rust-lang/rust/issues/45937. +// though, see issue #45937. fn foo<'a: 'b, 'b>() - where <() as Project<'a, 'b>>::Item : Eq -{ -} + where <() as Project<'a, 'b>>::Item: Eq {} // Here we get an error: we need `'a: 'b`. fn bar<'a, 'b>() //~ ERROR cannot infer - where <() as Project<'a, 'b>>::Item : Eq -{ -} + where <() as Project<'a, 'b>>::Item: Eq {} -fn main() { } +fn main() {} diff --git a/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr index a4197eed22524..3e8e2cf75ebaa 100644 --- a/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr +++ b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr @@ -1,19 +1,17 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-normalize-in-where-clause-list.rs:22:1 + --> $DIR/regions-normalize-in-where-clause-list.rs:20:1 | LL | / fn bar<'a, 'b>() //~ ERROR cannot infer -LL | | where <() as Project<'a, 'b>>::Item : Eq -LL | | { -LL | | } - | |_^ +LL | | where <() as Project<'a, 'b>>::Item: Eq {} + | |______________________________________________^ | -note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 22:8... - --> $DIR/regions-normalize-in-where-clause-list.rs:22:8 +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 20:8... + --> $DIR/regions-normalize-in-where-clause-list.rs:20:8 | LL | fn bar<'a, 'b>() //~ ERROR cannot infer | ^^ -note: ...but the lifetime must also be valid for the lifetime 'b as defined on the function body at 22:12... - --> $DIR/regions-normalize-in-where-clause-list.rs:22:12 +note: ...but the lifetime must also be valid for the lifetime 'b as defined on the function body at 20:12... + --> $DIR/regions-normalize-in-where-clause-list.rs:20:12 | LL | fn bar<'a, 'b>() //~ ERROR cannot infer | ^^ diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs index 20b391c263c26..d50354c86969b 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs @@ -3,7 +3,7 @@ // // Rule OutlivesNominalType from RFC 1214. -//compile-pass +// compile-pass #![feature(rustc_attrs)] #![allow(dead_code)] diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs index 2871d962c42c9..a54860a3bb276 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs @@ -1,4 +1,4 @@ -// Test that structs with higher-ranked where clauses don't generate +// Test that structs with higher-ranked where-clauses don't generate // "outlives" requirements. Issue #22246. // revisions: ast mir diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.rs b/src/test/ui/regions/regions-outlives-projection-container-wc.rs index 37622211327c0..8557e405ad14a 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.rs @@ -1,7 +1,7 @@ // Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must +// type of a bound that appears in the where-clause on a struct must // outlive the location in which the type appears, even when the -// constraint is in a where clause not a bound. Issue #22246. +// constraint is in a where-clause not a bound. Issue #22246. // revisions: ast mir //[mir]compile-flags: -Z borrowck=mir @@ -39,5 +39,4 @@ fn with_assoc<'a,'b>() { //[mir]~^^ ERROR lifetime may not live long enough } -fn main() { -} +fn main() {} diff --git a/src/test/ui/regions/regions-outlives-projection-container.rs b/src/test/ui/regions/regions-outlives-projection-container.rs index 78305c0693905..d46497d999943 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.rs +++ b/src/test/ui/regions/regions-outlives-projection-container.rs @@ -1,5 +1,5 @@ // Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must +// type of a bound that appears in the where-clause on a struct must // outlive the location in which the type appears. Issue #22246. #![allow(dead_code)] @@ -35,7 +35,7 @@ fn with_assoc<'a,'b>() { // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if + // FIXME(#54943): NLL doesn't enforce WF condition in unreachable code if // `_x` is changed to `_` let _x: &'a WithAssoc> = loop { }; //~^ ERROR reference has a longer lifetime @@ -46,7 +46,7 @@ fn with_assoc1<'a,'b>() where 'b : 'a { // associated types of traits that appear in `WithAssoc` must // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a, so 'b : 'a must hold, and - // that is in the where clauses, so we're fine. + // that is in the where-clauses, so we're fine. let _x: &'a WithAssoc> = loop { }; } diff --git a/src/test/ui/regions/regions-outlives-projection-trait-def.rs b/src/test/ui/regions/regions-outlives-projection-trait-def.rs index bad476d27794e..dfb2d3db1bf67 100644 --- a/src/test/ui/regions/regions-outlives-projection-trait-def.rs +++ b/src/test/ui/regions/regions-outlives-projection-trait-def.rs @@ -12,10 +12,9 @@ impl<'a: 'c, 'c, T> SomeTrait<'a> for &'c T where T: SomeTrait<'a> { type Type = >::Type; // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // | - // Note that this type must outlive 'a, due to the trait - // definition. If we fall back to OutlivesProjectionComponents + // Note that this type must outlive `'a`, due to the trait + // definition. If we fall back to `OutlivesProjectionComponents` // here, then we would require that `T:'a`, which is too strong. } - -fn main() { } +fn main() {} diff --git a/src/test/ui/regions/regions-ret-borrowed-1.rs b/src/test/ui/regions/regions-ret-borrowed-1.rs index 1be5edee599c4..0e6a3b138d562 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.rs +++ b/src/test/ui/regions/regions-ret-borrowed-1.rs @@ -1,5 +1,5 @@ -// Similar to regions-ret-borrowed.rs, but using a named lifetime. At -// some point regions-ret-borrowed reported an error but this file did +// Similar to `regions-ret-borrowed.rs`, but using a named lifetime. At +// some point, `regions-ret-borrowed` reported an error but this file did // not, due to special hardcoding around the anonymous region. fn with(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R { diff --git a/src/test/ui/regions/regions-ret-borrowed.rs b/src/test/ui/regions/regions-ret-borrowed.rs index 5fca92d68b65c..657f3f5dfd593 100644 --- a/src/test/ui/regions/regions-ret-borrowed.rs +++ b/src/test/ui/regions/regions-ret-borrowed.rs @@ -1,9 +1,9 @@ // Ensure that you cannot use generic types to return a region outside -// of its bound. Here, in the `return_it()` fn, we call with() but -// with R bound to &isize from the return_it. Meanwhile, with() +// of its bound. Here, in the `return_it()` fn, we call `with()` but +// with `R` bound to `&isize` from the `return_it`. Meanwhile, `with()` // provides a value that is only good within its own stack frame. This // used to successfully compile because we failed to account for the -// fact that fn(x: &isize) rebound the region &. +// fact that `fn(x: &isize)` rebound the region `&`. fn with(f: F) -> R where F: FnOnce(&isize) -> R { f(&3) diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs index 8ddd041d45731..136f9cea96a03 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs @@ -1,7 +1,7 @@ // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: `see variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. // `S` is contravariant with respect to both parameters. @@ -18,9 +18,9 @@ fn use_<'short,'long>(c: S<'long, 'short>, let _: S<'long, 'short> = c; // OK let _: S<'short, 'short> = c; // OK - // Test whether S<_,'short> <: S<_,'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. + // Test whether `S<_,'short> <: S<_,'long>`. Since + // `'short <= 'long`, this would be true if the `Contravariant` type were + // covariant with respect to its parameter `'a`. let _: S<'long, 'long> = c; //~ ERROR E0623 } diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs index cbdf62ecb613f..b0f1cb713ff35 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs @@ -1,12 +1,12 @@ // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: see `variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. // This is contravariant with respect to 'a, meaning that -// Contravariant<'long> <: Contravariant<'short> iff -// 'short <= 'long +// `Contravariant<'long> <: Contravariant<'short>` iff +// `'short <= 'long`. struct Contravariant<'a> { f: &'a isize } @@ -16,9 +16,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, l: &'long isize, _where:Option<&'short &'long ()>) { - // Test whether Contravariant<'short> <: Contravariant<'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. + // Test whether `Contravariant<'short> <: Contravariant<'long>`. Since + // `'short <= 'long`, this would be true if the `Contravariant` type were + // covariant with respect to its parameter `'a`. let _: Contravariant<'long> = c; //~ ERROR E0623 } diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs index 9aa0c81927197..b56eb588fd637 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs @@ -1,12 +1,12 @@ // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: `see variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. -// This is covariant with respect to 'a, meaning that -// Covariant<'foo> <: Covariant<'static> because -// 'foo <= 'static +// This is covariant with respect to `'a`, meaning that +// `Covariant<'foo> <: Covariant<'static>` because +// `'foo <= 'static`. struct Covariant<'a> { f: extern "Rust" fn(&'a isize) } @@ -16,9 +16,9 @@ fn use_<'short,'long>(c: Covariant<'long>, l: &'long isize, _where:Option<&'short &'long ()>) { - // Test whether Covariant<'long> <: Covariant<'short>. Since - // 'short <= 'long, this would be true if the Covariant type were - // contravariant with respect to its parameter 'a. + // Test whether `Covariant<'long> <: Covariant<'short>`. Since + // `'short <= 'long`, this would be true if the `Covariant` type were + // contravariant with respect to its parameter `'a`. let _: Covariant<'short> = c; //~ ERROR E0623 } diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs index 663b23b37d46a..cf3c27a37d368 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs @@ -1,7 +1,7 @@ // Test that an invariant region parameter used in a contravariant way // yields an error. // -// Note: see variance-regions-*.rs for the tests that check that the +// Note: see `variance-regions-*.rs` for the tests that check that the // variance inference works in the first place. struct Invariant<'a> { @@ -13,9 +13,9 @@ fn use_<'short,'long>(c: Invariant<'long>, l: &'long isize, _where:Option<&'short &'long ()>) { - // Test whether Invariant<'long> <: Invariant<'short>. Since - // 'short <= 'long, this would be true if the Invariant type were - // contravariant with respect to its parameter 'a. + // Test whether `Invariant<'long> <: Invariant<'short>`. Since + // `'short <= 'long`, this would be true if the `Invariant` type were + // contravariant with respect to its parameter `'a`. let _: Invariant<'short> = c; //~ ERROR E0623 } diff --git a/src/test/ui/reject-specialized-drops-8142.rs b/src/test/ui/reject-specialized-drops-8142.rs index f047e16bc0b94..5c95a531eae44 100644 --- a/src/test/ui/reject-specialized-drops-8142.rs +++ b/src/test/ui/reject-specialized-drops-8142.rs @@ -1,4 +1,4 @@ -// Issue 8142: Test that Drop impls cannot be specialized beyond the +// Issue #8142: test that `Drop` impls cannot be specialized beyond the // predicates attached to the struct/enum definition itself. trait Bound { fn foo(&self) { } } @@ -54,4 +54,4 @@ impl Drop for V { fn drop(&mut self) { } } // REJECT impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT //~^ ERROR cannot infer an appropriate lifetime -pub fn main() { } +pub fn main() {} diff --git a/src/test/ui/resolve/issue-21221-1.rs b/src/test/ui/resolve/issue-21221-1.rs index b180624d2f491..746e6e84d28be 100644 --- a/src/test/ui/resolve/issue-21221-1.rs +++ b/src/test/ui/resolve/issue-21221-1.rs @@ -28,7 +28,7 @@ mod mul5 { struct Foo; // When we comment the next line: -//use mul1::Mul; +// use mul1::Mul; // BEFORE, we got the following error for the `impl` below: // error: use of undeclared trait name `Mul` [E0405] diff --git a/src/test/ui/resolve/issue-21221-3.rs b/src/test/ui/resolve/issue-21221-3.rs index f0c0a9fd61a12..36e6fdf379dd4 100644 --- a/src/test/ui/resolve/issue-21221-3.rs +++ b/src/test/ui/resolve/issue-21221-3.rs @@ -1,5 +1,5 @@ -// testing whether the lookup mechanism picks up types -// defined in the outside crate +// Testing whether the lookup mechanism picks up types +// defined in the outside crate. // aux-build:issue-21221-3.rs @@ -7,10 +7,10 @@ extern crate issue_21221_3; struct Foo; -// NOTE: This shows only traits accessible from the current +// NOTE: this shows only traits accessible from the current // crate, thus the two private entities: -// `issue_21221_3::outer::private_module::OuterTrait` and -// `issue_21221_3::outer::public_module::OuterTrait` +// `issue_21221_3::outer::private_module::OuterTrait` and +// `issue_21221_3::outer::public_module::OuterTrait` // are hidden from the view. impl OuterTrait for Foo {} //~^ ERROR cannot find trait `OuterTrait` diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 89eb3d97ce0a5..4aa643897beda 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -6,7 +6,7 @@ LL | fn foo(_x: K) {} | = help: the trait `std::marker::Sized` is not implemented for `(dyn I + 'static)` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/retslot-cast.rs b/src/test/ui/retslot-cast.rs index ae500cb15dfdd..f61b82f536906 100644 --- a/src/test/ui/retslot-cast.rs +++ b/src/test/ui/retslot-cast.rs @@ -5,8 +5,8 @@ pub fn fail(x: Option<&(Iterator+Send)>) // This call used to trigger an LLVM assertion because the return // slot had type "Option<&Iterator>"* instead of // "Option<&(Iterator+Send)>"* -- but this now yields a - // compilation error and I'm not sure how to create a comparable - // test. To ensure that this PARTICULAR failure doesn't occur + // compilation error, and I'm not sure how to create a comparable + // test. To ensure that this _particular_ failure doesn't occur // again, though, I've left this test here, so if this ever starts // to compile again, we can adjust the test appropriately (clearly // it should never ICE...). -nmatsakis diff --git a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs index aa013d4bf3528..c90b9cb7e6c31 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs @@ -1,4 +1,4 @@ -// FIXME(tschottdorf): This should compile. See #44912. +// FIXME(tschottdorf): this should compile. See #44912. pub fn main() { let x = &Some((3, 3)); diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.rs b/src/test/ui/rfc-2093-infer-outlives/enum.rs index 622794ea9ac3b..11dc642839942 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/enum.rs @@ -2,7 +2,7 @@ #![feature(rustc_attrs)] -// Needs an explicit where clause stating outlives condition. (RFC 2093) +// Needs an explicit where-clause stating outlives condition. (RFC 2093) // Type T needs to outlive lifetime 'a. #[rustc_outlives] diff --git a/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs b/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs index 438923e29246c..2c2bcf07c4334 100644 --- a/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs +++ b/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs @@ -1,7 +1,7 @@ // Regression test for #54467: // // Here, the trait object has an "inferred outlives" requirement that -// `>::Item: 'a`; but since we don't know what +// `>::Item: 'a`, but since we don't know what // `Self` is, we were (incorrectly) messing things up, leading to // strange errors. This test ensures that we do not give compilation // errors. diff --git a/src/test/ui/rfc-2093-infer-outlives/privacy.rs b/src/test/ui/rfc-2093-infer-outlives/privacy.rs index 180f5ac6cdc46..ea3980c33e114 100644 --- a/src/test/ui/rfc-2093-infer-outlives/privacy.rs +++ b/src/test/ui/rfc-2093-infer-outlives/privacy.rs @@ -1,4 +1,4 @@ -// Test that we do not get a privacy error here. Initially, we did, +// Test that we do not get a privacy error here. Initially, we did, // because we inferred an outlives predciate of ` as // Private>::Out: 'a`, but the private trait is -- well -- private, // and hence it was not something that a pub trait could refer to. diff --git a/src/test/ui/rfc1598-generic-associated-types/collections.rs b/src/test/ui/rfc1598-generic-associated-types/collections.rs index 5414bb4a6d20e..22a1ac4bd416a 100644 --- a/src/test/ui/rfc1598-generic-associated-types/collections.rs +++ b/src/test/ui/rfc1598-generic-associated-types/collections.rs @@ -10,7 +10,7 @@ // associated-type-constructors-part-2-family-traits/ trait Collection { - type Iter<'iter>: Iterator; + type Iter<'iter>: Iterator; type Family: CollectionFamily; // Test associated type defaults with parameters type Sibling: Collection = diff --git a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs index b0d1fa1a74fb5..4e88f5fbc1a97 100644 --- a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs +++ b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs @@ -9,7 +9,7 @@ trait Foo { type Assoc where Self: Sized; type Assoc2 where T: Display; type Assoc3; - type WithDefault where T: Debug = Iterator; + type WithDefault where T: Debug = Iterator; type NoGenerics; } diff --git a/src/test/ui/rfc1598-generic-associated-types/shadowing.rs b/src/test/ui/rfc1598-generic-associated-types/shadowing.rs index 82a7c2510e5d7..920bebd90bdfb 100644 --- a/src/test/ui/rfc1598-generic-associated-types/shadowing.rs +++ b/src/test/ui/rfc1598-generic-associated-types/shadowing.rs @@ -1,6 +1,6 @@ #![feature(generic_associated_types)] -//FIXME(#44265): The lifetime shadowing and type parameter shadowing +// FIXME(#44265): The lifetime shadowing and type parameter shadowing // should cause an error. Now it compiles (erroneously) and this will be addressed // by a future PR. Then remove the following: // compile-pass diff --git a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs index e0184164b3ac2..deceab5458f2d 100644 --- a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs +++ b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs @@ -21,7 +21,7 @@ struct Foo { // Users can bound parameters by the type constructed by that trait's associated type constructor // of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid: -//FIXME(sunjay): This next line should parse and be valid +//FIXME(sunjay): this next line should parse and be valid //fn foo StreamingIterator=&'a [i32]>>(iter: T) { /* ... */ } fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } //~^ ERROR lifetime arguments are not allowed on this entity [E0110] @@ -69,5 +69,4 @@ fn test_stream_enumerate() { println!("{}", a); } - fn main() {} diff --git a/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed b/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed index eb48933dca537..164bb3fdf219f 100644 --- a/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed +++ b/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed @@ -12,13 +12,13 @@ use std::fmt::{Debug, Display}; // combinations— // // • one generic parameter (T) bound inline -// • one parameter (T) with a where clause +// • one parameter (T) with a where-clause // • two parameters (T and U), both bound inline -// • two parameters (T and U), one bound inline, one with a where clause -// • two parameters (T and U), both with where clauses +// • two parameters (T and U), one bound inline, one with a where-clause +// • two parameters (T and U), both with where-clauses // // —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1 -// trait bounds distributed among said parameters (subject to no where clause +// trait bounds distributed among said parameters (subject to no where-clause // being empty and the struct having at least one lifetime). @@ -193,7 +193,7 @@ struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug { // But outlives inference for 'static lifetimes is under a separate // feature-gate for now -// (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046). +// (see ). struct StaticRef { field: &'static T } diff --git a/src/test/ui/rust-2018/edition-lint-infer-outlives.rs b/src/test/ui/rust-2018/edition-lint-infer-outlives.rs index fd31341365c65..43d54350720f4 100644 --- a/src/test/ui/rust-2018/edition-lint-infer-outlives.rs +++ b/src/test/ui/rust-2018/edition-lint-infer-outlives.rs @@ -12,13 +12,13 @@ use std::fmt::{Debug, Display}; // combinations— // // • one generic parameter (T) bound inline -// • one parameter (T) with a where clause +// • one parameter (T) with a where-clause // • two parameters (T and U), both bound inline -// • two parameters (T and U), one bound inline, one with a where clause -// • two parameters (T and U), both with where clauses +// • two parameters (T and U), one bound inline, one with a where-clause +// • two parameters (T and U), both with where-clauses // // —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1 -// trait bounds distributed among said parameters (subject to no where clause +// trait bounds distributed among said parameters (subject to no where-clause // being empty and the struct having at least one lifetime). @@ -193,7 +193,7 @@ struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: D // But outlives inference for 'static lifetimes is under a separate // feature-gate for now -// (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046). +// (see ). struct StaticRef { field: &'static T } diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.rs b/src/test/ui/span/dropck_direct_cycle_with_drop.rs index 14d6e6654746f..c921e5044919b 100644 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.rs +++ b/src/test/ui/span/dropck_direct_cycle_with_drop.rs @@ -5,7 +5,7 @@ // name as well as the name of its sibling. // // By setting up a cyclic structure, the drop code cannot possibly -// work. Therefore this code must be rejected. +// work. Therefore, this code must be rejected. // // (As it turns out, essentially any attempt to install a sibling here // will be rejected, regardless of whether it forms a cyclic diff --git a/src/test/ui/span/regions-escape-loop-via-variable.rs b/src/test/ui/span/regions-escape-loop-via-variable.rs index ad468896b1302..3816dfb513e61 100644 --- a/src/test/ui/span/regions-escape-loop-via-variable.rs +++ b/src/test/ui/span/regions-escape-loop-via-variable.rs @@ -2,7 +2,7 @@ fn main() { let x = 3; // Here, the variable `p` gets inferred to a type with a lifetime - // of the loop body. The regionck then determines that this type + // of the loop body. The regionck then determines that this type // is invalid. let mut p = &x; diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.rs b/src/test/ui/span/vec-must-not-hide-type-from-dropck.rs index 9bfbfab06a0ac..e8aaa8d82d27a 100644 --- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.rs +++ b/src/test/ui/span/vec-must-not-hide-type-from-dropck.rs @@ -2,9 +2,9 @@ // implements `Drop` and might access methods of values that have // since been deallocated. // -// In this case, the values in question hold (non-zero) unique-ids +// In this case, the values in question hold (non-zero) unique IDs // that zero themselves out when dropped, and are wrapped in another -// type with a destructor that asserts that the ids it references are +// type with a destructor that asserts that the IDs it references are // indeed non-zero (i.e., effectively checking that the id's are not // dropped while there are still any outstanding references). // diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr index 87809d212d79d..022db81a98e5e 100644 --- a/src/test/ui/str/str-array-assignment.stderr +++ b/src/test/ui/str/str-array-assignment.stderr @@ -31,7 +31,7 @@ LL | let v = s[..2]; | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0308]: mismatched types diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index beb2272452363..ac2b8d12f0b43 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -20,7 +20,7 @@ LL | s[1..2] = bot(); | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: the left-hand-side of an assignment must have a statically known size + = note: the left-hand-side of an assignment must have a statically-known size error[E0277]: the type `str` cannot be indexed by `usize` --> $DIR/str-mut-idx.rs:7:5 diff --git a/src/test/ui/suggestions/dont-suggest-ref/simple.rs b/src/test/ui/suggestions/dont-suggest-ref/simple.rs index 58aab85ac2673..79c337906afc4 100644 --- a/src/test/ui/suggestions/dont-suggest-ref/simple.rs +++ b/src/test/ui/suggestions/dont-suggest-ref/simple.rs @@ -255,7 +255,7 @@ pub fn main() { // -------- move from tuple of &Either/&X -------- - // FIXME: These should have suggestions. + // FIXME: these should have suggestions. let (&X(_t),) = (&x.clone(),); //~^ ERROR cannot move diff --git a/src/test/ui/suggestions/path-by-value.stderr b/src/test/ui/suggestions/path-by-value.stderr index b073e10749cc1..278a2a2a3df90 100644 --- a/src/test/ui/suggestions/path-by-value.stderr +++ b/src/test/ui/suggestions/path-by-value.stderr @@ -7,7 +7,7 @@ LL | fn f(p: Path) { } = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `std::path::Path` - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/svh/svh-change-lit.rs b/src/test/ui/svh/svh-change-lit.rs index 7d991cc99716e..d285b5a4975f2 100644 --- a/src/test/ui/svh/svh-change-lit.rs +++ b/src/test/ui/svh/svh-change-lit.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-lit.rs diff --git a/src/test/ui/svh/svh-change-significant-cfg.rs b/src/test/ui/svh/svh-change-significant-cfg.rs index 8cf0d9ccaf1e8..d8c8f230dcc52 100644 --- a/src/test/ui/svh/svh-change-significant-cfg.rs +++ b/src/test/ui/svh/svh-change-significant-cfg.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-significant-cfg.rs diff --git a/src/test/ui/svh/svh-change-trait-bound.rs b/src/test/ui/svh/svh-change-trait-bound.rs index ddd10ac068df3..b72a3c7104178 100644 --- a/src/test/ui/svh/svh-change-trait-bound.rs +++ b/src/test/ui/svh/svh-change-trait-bound.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-trait-bound.rs diff --git a/src/test/ui/svh/svh-change-type-arg.rs b/src/test/ui/svh/svh-change-type-arg.rs index f845ab5bc6a91..7040f8ed63554 100644 --- a/src/test/ui/svh/svh-change-type-arg.rs +++ b/src/test/ui/svh/svh-change-type-arg.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-type-arg.rs diff --git a/src/test/ui/svh/svh-change-type-ret.rs b/src/test/ui/svh/svh-change-type-ret.rs index fb3e996c5fd8c..c5b8b7a5b3163 100644 --- a/src/test/ui/svh/svh-change-type-ret.rs +++ b/src/test/ui/svh/svh-change-type-ret.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-type-ret.rs diff --git a/src/test/ui/svh/svh-change-type-static.rs b/src/test/ui/svh/svh-change-type-static.rs index 0dfcaa0003b66..bb50cc596038a 100644 --- a/src/test/ui/svh/svh-change-type-static.rs +++ b/src/test/ui/svh/svh-change-type-static.rs @@ -1,6 +1,6 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-a-base.rs // aux-build:svh-b.rs // aux-build:svh-a-change-type-static.rs diff --git a/src/test/ui/svh/svh-use-trait.rs b/src/test/ui/svh/svh-use-trait.rs index 93daca034c067..cb4819d8006c0 100644 --- a/src/test/ui/svh/svh-use-trait.rs +++ b/src/test/ui/svh/svh-use-trait.rs @@ -1,12 +1,12 @@ -// ignore-msvc FIXME #31306 +// ignore-msvc FIXME(#31306) -// note that these aux-build directives must be in this order +// Note that these aux-build directives must be in this order: // aux-build:svh-uta-base.rs // aux-build:svh-utb.rs // aux-build:svh-uta-change-use-trait.rs // normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2" -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! `compile-fail/svh-uta-trait.rs` is checking that we detect a //! change from `use foo::TraitB` to use `foo::TraitB` in the hash //! (SVH) computation (#14132), since that will affect method //! resolution. diff --git a/src/test/ui/traits/conservative_impl_trait.rs b/src/test/ui/traits/conservative_impl_trait.rs index 964e21779d51b..772da5bc683d1 100644 --- a/src/test/ui/traits/conservative_impl_trait.rs +++ b/src/test/ui/traits/conservative_impl_trait.rs @@ -1,7 +1,7 @@ // compile-pass // #39665 -fn batches(n: &u32) -> impl Iterator { +fn batches(n: &u32) -> impl Iterator { std::iter::once(n) } diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index 5aee1e7e982a8..0f6c329f9c1c2 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -6,7 +6,7 @@ LL | fn foo(_x: Foo + Send) { | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + std::marker::Send + 'static)` = note: to learn more, visit - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs index fdbaec9a5c7ff..cf4e578827963 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs @@ -60,7 +60,7 @@ fn return_str() -> str where str: Sized { *"Sized".to_string().into_boxed_str() } -fn use_op(s: String) -> String where String: ::std::ops::Neg { +fn use_op(s: String) -> String where String: ::std::ops::Neg { -s } diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr index 744e146f83003..176dc61b7ef60 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr @@ -24,7 +24,7 @@ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters LL | union U where i32: Foo { f: i32 } | ^^^ -warning: where clauses are not enforced in type aliases +warning: where-clauses are not enforced in type aliases --> $DIR/trivial-bounds-inconsistent.rs:22:14 | LL | type Y where i32: Foo = (); @@ -78,8 +78,8 @@ LL | fn return_str() -> str where str: Sized { warning: Trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:63:46 | -LL | fn use_op(s: String) -> String where String: ::std::ops::Neg { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn use_op(s: String) -> String where String: ::std::ops::Neg { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: Trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:67:25 diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index aa055d3dc03f5..85e3bac63ea95 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -6,7 +6,7 @@ LL | fn cant_return_str() -> str { //~ ERROR | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error[E0599]: no method named `test` found for type `i32` in the current scope --> $DIR/trivial-bounds-leak.rs:24:10 diff --git a/src/test/ui/trivial-bounds/trivial-bounds-object.rs b/src/test/ui/trivial-bounds/trivial-bounds-object.rs index f5feeea7cd41c..0adf221ab8247 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-object.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-object.rs @@ -1,6 +1,6 @@ // run-pass // Check that the object bound dyn A + 'a: A is preferred over the -// where clause bound dyn A + 'static: A. +// where-clause bound dyn A + 'static: A. #![allow(unused)] diff --git a/src/test/ui/type/type-alias-bounds.rs b/src/test/ui/type/type-alias-bounds.rs index e2be2b9890251..e3b2868135dac 100644 --- a/src/test/ui/type/type-alias-bounds.rs +++ b/src/test/ui/type/type-alias-bounds.rs @@ -1,44 +1,44 @@ -// Test ignored_generic_bounds lint warning about bounds in type aliases +// Test `ignored_generic_bounds` lint warning about bounds in type aliases // compile-pass #![allow(dead_code)] use std::rc::Rc; -type SVec = Vec; +type SVec = Vec; //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type S2Vec where T: Send = Vec; -//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] -type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); +//~^ WARN where-clauses are not enforced in type aliases [type_alias_bounds] +type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>); //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] -type WVec<'b, T: 'b+'b> = (&'b u32, Vec); +type WVec<'b, T: 'b + 'b> = (&'b u32, Vec); //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); -//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] +//~^ WARN where-clauses are not enforced in type aliases [type_alias_bounds] -static STATIC : u32 = 0; +static STATIC: u32 = 0; fn foo<'a>(y: &'a i32) { // If any of the bounds above would matter, the code below would be rejected. // This can be seen when replacing the type aliases above by newtype structs. // (The type aliases have no unused parameters to make that a valid transformation.) - let mut x : SVec<_> = Vec::new(); + let mut x: SVec<_> = Vec::new(); x.push(Rc::new(42)); // is not send - let mut x : S2Vec<_> = Vec::new(); - x.push(Rc::new(42)); // is not send + let mut x: S2Vec<_> = Vec::new(); + x.push(Rc::new(42)); // is not `Send` - let mut x : VVec<'static, 'a> = (&STATIC, Vec::new()); - x.1.push(y); // 'a: 'static does not hold + let mut x: VVec<'static, 'a> = (&STATIC, Vec::new()); + x.1.push(y); // `'a: 'static` does not hold - let mut x : WVec<'static, &'a i32> = (&STATIC, Vec::new()); - x.1.push(y); // &'a i32: 'static does not hold + let mut x: WVec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // `&'a i32: 'static` does not hold - let mut x : W2Vec<'static, &'a i32> = (&STATIC, Vec::new()); - x.1.push(y); // &'a i32: 'static does not hold + let mut x: W2Vec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // `&'a i32: 'static` does not hold } -// Bounds are not checked either, i.e., the definition is not necessarily well-formed +// Bounds are not checked either, i.e., the definition is not necessarily well-formed. struct Sendable(T); type MySendable = Sendable; // no error here! @@ -47,9 +47,9 @@ trait Bound { type Assoc; } type T1 = U::Assoc; //~ WARN not enforced in type aliases type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases -// This errors -// type T3 = U::Assoc; -// Do this instead +// This errors: +// `type T3 = U::Assoc;` +// Do this instead: type T4 = ::Assoc; // Make sure the help about associatd types is not shown incorrectly diff --git a/src/test/ui/type/type-alias-bounds.stderr b/src/test/ui/type/type-alias-bounds.stderr index b13e400105210..0ff36f0e00e2b 100644 --- a/src/test/ui/type/type-alias-bounds.stderr +++ b/src/test/ui/type/type-alias-bounds.stderr @@ -1,13 +1,13 @@ warning: bounds on generic parameters are not enforced in type aliases --> $DIR/type-alias-bounds.rs:8:14 | -LL | type SVec = Vec; - | ^^^^ ^^^^ +LL | type SVec = Vec; + | ^^^^ ^^^^ | = note: #[warn(type_alias_bounds)] on by default = help: the bound will not be checked when the type alias is used, and should be removed -warning: where clauses are not enforced in type aliases +warning: where-clauses are not enforced in type aliases --> $DIR/type-alias-bounds.rs:10:21 | LL | type S2Vec where T: Send = Vec; @@ -18,20 +18,20 @@ LL | type S2Vec where T: Send = Vec; warning: bounds on generic parameters are not enforced in type aliases --> $DIR/type-alias-bounds.rs:12:19 | -LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); - | ^^ ^^ +LL | type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>); + | ^^ ^^ | = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases --> $DIR/type-alias-bounds.rs:14:18 | -LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); - | ^^ ^^ +LL | type WVec<'b, T: 'b + 'b> = (&'b u32, Vec); + | ^^ ^^ | = help: the bound will not be checked when the type alias is used, and should be removed -warning: where clauses are not enforced in type aliases +warning: where-clauses are not enforced in type aliases --> $DIR/type-alias-bounds.rs:16:25 | LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); @@ -52,7 +52,7 @@ help: use fully disambiguated paths (i.e., `::Assoc`) to refer to as LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ -warning: where clauses are not enforced in type aliases +warning: where-clauses are not enforced in type aliases --> $DIR/type-alias-bounds.rs:48:18 | LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases diff --git a/src/test/ui/type/type-check-defaults.rs b/src/test/ui/type/type-check-defaults.rs index 5748c9bcff8cb..77510b06a574e 100644 --- a/src/test/ui/type/type-check-defaults.rs +++ b/src/test/ui/type/type-check-defaults.rs @@ -8,13 +8,13 @@ struct WellFormed>(Z); struct WellFormedNoBounds>(Z); //~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32` -struct Bounds(T); +struct Bounds(T); //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] -struct WhereClause(T) where T: Copy; +struct WhereClause(T) where T: Copy; //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] -trait TraitBound {} +trait TraitBound {} //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] trait Super { } diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index a46d79ec3183e..59b4b016597bb 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -27,38 +27,38 @@ LL | struct Foo>(T, U); error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:11:1 | -LL | struct Bounds(T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | struct Bounds(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `Bounds` --> $DIR/type-check-defaults.rs:11:1 | -LL | struct Bounds(T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct Bounds(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:14:1 | -LL | struct WhereClause(T) where T: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | struct WhereClause(T) where T: Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `WhereClause` --> $DIR/type-check-defaults.rs:14:1 | -LL | struct WhereClause(T) where T: Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct WhereClause(T) where T: Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:17:1 | -LL | trait TraitBound {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` +LL | trait TraitBound {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | note: required by `TraitBound` --> $DIR/type-check-defaults.rs:17:1 | -LL | trait TraitBound {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait TraitBound {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:21:1 diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs index 3e1c876c76ba8..ceee51bc7a8a5 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs @@ -3,7 +3,7 @@ // the user, but pretty-printing the type during the error message // caused an ICE. -trait MyAdd { fn add(&self, other: &Rhs) -> Self; } +trait MyAdd { fn add(&self, other: &Rhs) -> Self; } impl MyAdd for i32 { fn add(&self, other: &i32) -> i32 { *self + *other } diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs index 721bf960a55c2..5f9f3d0b928a2 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs @@ -3,7 +3,7 @@ #![feature(default_type_params)] -trait Foo { +trait Foo { fn method(&self); } diff --git a/src/test/ui/type/type-params-in-different-spaces-1.rs b/src/test/ui/type/type-params-in-different-spaces-1.rs index 449a26e901d42..7ab2a83a78e98 100644 --- a/src/test/ui/type/type-params-in-different-spaces-1.rs +++ b/src/test/ui/type/type-params-in-different-spaces-1.rs @@ -1,6 +1,6 @@ use std::ops::Add; -trait BrokenAdd: Copy + Add { +trait BrokenAdd: Copy + Add { fn broken_add(&self, rhs: T) -> Self { *self + rhs //~ ERROR mismatched types //~| expected type `Self` @@ -9,7 +9,7 @@ trait BrokenAdd: Copy + Add { } } -impl> BrokenAdd for T {} +impl> BrokenAdd for T {} pub fn main() { let foo: u8 = 0; diff --git a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr index fc45520851889..8ce5820249125 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr @@ -6,7 +6,8 @@ LL | g(|_| { }); //~ ERROR closure/generator type that references itself | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, - see https://github.com/rust-lang/rust/issues/46062 for more details + see for more + details error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs index 044859de6a4a5..d1dded3a41e2c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs @@ -4,7 +4,7 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo { +trait Foo { type Output; fn dummy(&self, t: T, v: V); } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs index 95bd391f251b8..13aa88ec34839 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs @@ -36,7 +36,7 @@ fn test<'a,'b>() { Foo(&isize,&usize) -> usize >(); // lifetime elision - eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, + eq::< for<'x> Foo<(&'x isize,), Output = &'x isize>, Foo(&isize) -> &isize >(); // Errors expected: diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs index b61d8b8c8c790..84fd5ced92d64 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs @@ -18,7 +18,7 @@ impl Eq for X { } fn eq>() { } fn main() { - eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, + eq::< for<'a> Foo<(&'a isize,), Output = &'a isize>, Foo(&isize) -> &isize >(); eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, Foo(&isize) -> (&isize, &isize) >(); diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs index d5aa18eb0f4e7..a45a13ddfba4f 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs @@ -3,16 +3,16 @@ // // cc #48468 -fn a(items: &[T]) -> Box> { +fn a(items: &[T]) -> Box> { // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime } -fn b(items: &[T]) -> Box + '_> { +fn b(items: &[T]) -> Box + '_> { Box::new(items.iter()) // OK, equivalent to c } -fn c<'a, T>(items: &'a [T]) -> Box + 'a> { +fn c<'a, T>(items: &'a [T]) -> Box + 'a> { Box::new(items.iter()) // OK, equivalent to b } diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr index 4eb959311ca48..f8e890cc578b8 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr @@ -7,7 +7,7 @@ LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 6:1... --> $DIR/dyn-trait-underscore.rs:6:1 | -LL | / fn a(items: &[T]) -> Box> { +LL | / fn a(items: &[T]) -> Box> { LL | | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` LL | | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime LL | | } diff --git a/src/test/ui/unevaluated_fixed_size_array_len.rs b/src/test/ui/unevaluated_fixed_size_array_len.rs index 6c545913dd9dc..b8097e2a1c8e8 100644 --- a/src/test/ui/unevaluated_fixed_size_array_len.rs +++ b/src/test/ui/unevaluated_fixed_size_array_len.rs @@ -1,4 +1,4 @@ -// https://github.com/rust-lang/rust/issues/49208 +// Test for issue #49208. trait Foo { fn foo(); diff --git a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs index 38a52d5860d4b..5d48076cfc1a4 100644 --- a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs +++ b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs @@ -21,7 +21,7 @@ fn main() { }; let x: Void = unsafe { std::mem::uninitialized() }; - let _ = match x {}; // okay + let _ = match x {}; // ok let x: Result = Ok(23); let _ = match x { //~ ERROR non-exhaustive diff --git a/src/test/ui/unop-move-semantics.rs b/src/test/ui/unop-move-semantics.rs index 24bd89d4c39ce..6597d1ca02081 100644 --- a/src/test/ui/unop-move-semantics.rs +++ b/src/test/ui/unop-move-semantics.rs @@ -2,13 +2,13 @@ use std::ops::Not; -fn move_then_borrow + Clone>(x: T) { +fn move_then_borrow + Clone>(x: T) { !x; x.clone(); //~ ERROR: use of moved value } -fn move_borrowed>(x: T, mut y: T) { +fn move_borrowed>(x: T, mut y: T) { let m = &x; let n = &mut y; @@ -17,7 +17,7 @@ fn move_borrowed>(x: T, mut y: T) { !y; //~ ERROR: cannot move out of `y` because it is borrowed use_mut(n); use_imm(m); } -fn illegal_dereference>(mut x: T, y: T) { +fn illegal_dereference>(mut x: T, y: T) { let m = &mut x; let n = &y; diff --git a/src/test/ui/unsafe/unsafe-fn-autoderef.rs b/src/test/ui/unsafe/unsafe-fn-autoderef.rs index 60460fc6e49de..6bf6b052d3c1a 100644 --- a/src/test/ui/unsafe/unsafe-fn-autoderef.rs +++ b/src/test/ui/unsafe/unsafe-fn-autoderef.rs @@ -4,9 +4,9 @@ struct Rec { fn f(p: *const Rec) -> isize { - // Test that * ptrs do not autoderef. There is a deeper reason for + // Test that `*` ptrs do not auto-deref. There is a deeper reason for // prohibiting this, beyond making unsafe things annoying (which doesn't - // actually seem desirable to me). The deeper reason is that if you + // actually seem desirable to me). The deeper reason is that if you // have a type like: // // enum foo = *foo; diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr index 7b6c2d11ea169..5df1d642553d4 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr @@ -7,7 +7,7 @@ LL | A as fn(str) -> A; = help: within `main::A`, the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit = note: required because it appears within the type `main::A` - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to previous error diff --git a/src/test/ui/unsized-locals/issue-50940.stderr b/src/test/ui/unsized-locals/issue-50940.stderr index be006c09d6f5c..55a669cbf7454 100644 --- a/src/test/ui/unsized-locals/issue-50940.stderr +++ b/src/test/ui/unsized-locals/issue-50940.stderr @@ -6,7 +6,7 @@ LL | A as fn(str) -> A; | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized-locals/unsized-exprs.stderr b/src/test/ui/unsized-locals/unsized-exprs.stderr index 43c35cdd7b5b0..ce22edc26f655 100644 --- a/src/test/ui/unsized-locals/unsized-exprs.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs.stderr @@ -7,7 +7,7 @@ LL | udrop::<(i32, [u8])>((42, *foo())); = help: within `({integer}, [u8])`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `({integer}, [u8])` - = note: tuples must have a statically known size to be initialized + = note: tuples must have a statically-known size to be initialized error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/unsized-exprs.rs:24:22 @@ -18,7 +18,7 @@ LL | udrop::>(A { 0: *foo() }); = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` - = note: structs must have a statically known size to be initialized + = note: structs must have a statically-known size to be initialized error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/unsized-exprs.rs:26:22 @@ -29,7 +29,7 @@ LL | udrop::>(A(*foo())); = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` - = note: the return type of a function must have a statically known size + = note: the return type of a function must have a statically-known size error: aborting due to 3 previous errors diff --git a/src/test/ui/unsized-locals/unsized-exprs3.stderr b/src/test/ui/unsized-locals/unsized-exprs3.stderr index f9a7452a5ebf2..a7c4b0ce9ee9c 100644 --- a/src/test/ui/unsized-locals/unsized-exprs3.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs3.stderr @@ -6,7 +6,7 @@ LL | udrop as fn([u8]); | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit - = note: all function arguments must have a statically known size + = note: all function arguments must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index 2c7b86c5d8284..7e808893266ba 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -67,7 +67,7 @@ LL | f5(&(32, *x1)); = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: required because it appears within the type `({integer}, S)` - = note: tuples must have a statically known size to be initialized + = note: tuples must have a statically-known size to be initialized error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized3.rs:45:5 diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr index a6a26573e7c59..cf6fcca0c2c83 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized6.stderr @@ -7,7 +7,7 @@ LL | let y: Y; = help: the trait `std::marker::Sized` is not implemented for `Y` = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -41,7 +41,7 @@ LL | let y: X; = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `Y` cannot be known at compilation time @@ -64,7 +64,7 @@ LL | let y: X = *x1; = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -76,7 +76,7 @@ LL | let y = *x2; = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -88,7 +88,7 @@ LL | let (y, z) = (*x3, 4); = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -100,7 +100,7 @@ LL | let y: X = *x1; = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -112,7 +112,7 @@ LL | let y = *x2; = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -124,7 +124,7 @@ LL | let (y, z) = (*x3, 4); = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -136,7 +136,7 @@ LL | fn g1(x: X) {} = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -148,7 +148,7 @@ LL | fn g2(x: X) {} = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound - = note: all local variables must have a statically known size + = note: all local variables must have a statically-known size = help: unsized locals are gated as an unstable feature error: aborting due to 13 previous errors diff --git a/src/test/ui/unspecified-self-in-trait-ref.rs b/src/test/ui/unspecified-self-in-trait-ref.rs index 74a9af84cae85..914b7b500e021 100644 --- a/src/test/ui/unspecified-self-in-trait-ref.rs +++ b/src/test/ui/unspecified-self-in-trait-ref.rs @@ -1,8 +1,8 @@ -pub trait Foo { +pub trait Foo { fn foo(&self); } -pub trait Bar { +pub trait Bar { fn foo(&self); } diff --git a/src/test/ui/use/auxiliary/use_from_trait_xc.rs b/src/test/ui/use/auxiliary/use-from-trait-xc.rs similarity index 100% rename from src/test/ui/use/auxiliary/use_from_trait_xc.rs rename to src/test/ui/use/auxiliary/use-from-trait-xc.rs diff --git a/src/test/ui/use/use-after-move-self-based-on-type.rs b/src/test/ui/use/use-after-move-self-based-on-type.rs index 4d84ae9b27173..0018b193e3e4e 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.rs +++ b/src/test/ui/use/use-after-move-self-based-on-type.rs @@ -9,7 +9,7 @@ impl Drop for S { impl S { pub fn foo(self) -> isize { self.bar(); - return self.x; //~ ERROR use of moved value: `self.x` + return self.x; //~ ERROR use of moved value: `self.x` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self-based-on-type.stderr b/src/test/ui/use/use-after-move-self-based-on-type.stderr index a3acc1aad0f00..daef070db67d2 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-self-based-on-type.stderr @@ -3,7 +3,7 @@ error[E0382]: use of moved value: `self.x` | LL | self.bar(); | ---- value moved here -LL | return self.x; //~ ERROR use of moved value: `self.x` +LL | return self.x; //~ ERROR use of moved value: `self.x` | ^^^^^^ value used here after move | = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait diff --git a/src/test/ui/use/use-after-move-self.rs b/src/test/ui/use/use-after-move-self.rs index 1337d61a6d8e8..0b84abc0eb713 100644 --- a/src/test/ui/use/use-after-move-self.rs +++ b/src/test/ui/use/use-after-move-self.rs @@ -7,7 +7,7 @@ struct S { impl S { pub fn foo(self) -> isize { self.bar(); - return *self.x; //~ ERROR use of moved value: `*self.x` + return *self.x; //~ ERROR use of moved value: `*self.x` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self.stderr b/src/test/ui/use/use-after-move-self.stderr index 3cb77acaf3dd4..554f3230cb14f 100644 --- a/src/test/ui/use/use-after-move-self.stderr +++ b/src/test/ui/use/use-after-move-self.stderr @@ -3,7 +3,7 @@ error[E0382]: use of moved value: `*self.x` | LL | self.bar(); | ---- value moved here -LL | return *self.x; //~ ERROR use of moved value: `*self.x` +LL | return *self.x; //~ ERROR use of moved value: `*self.x` | ^^^^^^^ value used here after move | = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait diff --git a/src/test/ui/use/use-from-trait-xc.rs b/src/test/ui/use/use-from-trait-xc.rs index e6f102f6269a7..695ed66a1c183 100644 --- a/src/test/ui/use/use-from-trait-xc.rs +++ b/src/test/ui/use/use-from-trait-xc.rs @@ -1,4 +1,4 @@ -// aux-build:use_from_trait_xc.rs +// aux-build:use-from-trait-xc.rs extern crate use_from_trait_xc; diff --git a/src/test/ui/use/use-meta-mismatch.rs b/src/test/ui/use/use-meta-mismatch.rs index 459216a17e4f3..9c2e7c48bdf09 100644 --- a/src/test/ui/use/use-meta-mismatch.rs +++ b/src/test/ui/use/use-meta-mismatch.rs @@ -2,4 +2,4 @@ extern crate fake_crate as extra; -fn main() { } +fn main() {} diff --git a/src/test/ui/use/use-nested-groups-unused-imports.rs b/src/test/ui/use/use-nested-groups-unused-imports.rs index 5fe85954dc8e9..0f9f09b653c95 100644 --- a/src/test/ui/use/use-nested-groups-unused-imports.rs +++ b/src/test/ui/use/use-nested-groups-unused-imports.rs @@ -14,11 +14,11 @@ mod foo { } use foo::{Foo, bar::{baz::{}, foobar::*}, *}; - //~^ ERROR unused imports: `*`, `Foo`, `baz::{}`, `foobar::*` +//~^ ERROR unused imports: `*`, `Foo`, `baz::{}`, `foobar::*` use foo::bar::baz::{*, *}; - //~^ ERROR unused import: `*` +//~^ ERROR unused import: `*` use foo::{}; - //~^ ERROR unused import: `foo::{}` +//~^ ERROR unused import: `foo::{}` fn main() { let _: Bar; diff --git a/src/test/ui/use/use-super-global-path.rs b/src/test/ui/use/use-super-global-path.rs index 3e0ebccc0a0d6..5dc5ca75178d0 100644 --- a/src/test/ui/use/use-super-global-path.rs +++ b/src/test/ui/use/use-super-global-path.rs @@ -12,4 +12,6 @@ mod foo { } } -fn main() { foo::g(); } +fn main() { + foo::g(); +} diff --git a/src/test/ui/variants/variant-used-as-type.rs b/src/test/ui/variants/variant-used-as-type.rs index f27db1024760a..e882215f4ecb6 100644 --- a/src/test/ui/variants/variant-used-as-type.rs +++ b/src/test/ui/variants/variant-used-as-type.rs @@ -1,7 +1,6 @@ -// Test error message when enum variants are used as types +// Test error message when enum variants are used as types. - -// issue 21225 +// See issue #21225. enum Ty { A, B(Ty::A), @@ -9,7 +8,7 @@ enum Ty { } -// issue 19197 +// See issue #19197. enum E { A } diff --git a/src/test/ui/variants/variant-used-as-type.stderr b/src/test/ui/variants/variant-used-as-type.stderr index fdfc044d81f6c..2500e3540c9be 100644 --- a/src/test/ui/variants/variant-used-as-type.stderr +++ b/src/test/ui/variants/variant-used-as-type.stderr @@ -1,5 +1,5 @@ error[E0573]: expected type, found variant `Ty::A` - --> $DIR/variant-used-as-type.rs:7:7 + --> $DIR/variant-used-as-type.rs:6:7 | LL | B(Ty::A), | ^^^^^ not a type @@ -11,7 +11,7 @@ LL | B(Ty), | ^^ error[E0573]: expected type, found variant `E::A` - --> $DIR/variant-used-as-type.rs:17:6 + --> $DIR/variant-used-as-type.rs:16:6 | LL | impl E::A {} | ^^^^ not a type diff --git a/src/test/ui/wf/wf-in-fn-where-clause.rs b/src/test/ui/wf/wf-in-fn-where-clause.rs index 65a1771d41a48..46a99acb926a0 100644 --- a/src/test/ui/wf/wf-in-fn-where-clause.rs +++ b/src/test/ui/wf/wf-in-fn-where-clause.rs @@ -1,4 +1,4 @@ -// Check that we enforce WF conditions also for where clauses in fn items. +// Check that we enforce WF conditions also for where-clauses in fn items. #![allow(dead_code)] diff --git a/src/test/ui/wf/wf-trait-fn-where-clause.rs b/src/test/ui/wf/wf-trait-fn-where-clause.rs index 1d2427ff981d7..c2e58af548510 100644 --- a/src/test/ui/wf/wf-trait-fn-where-clause.rs +++ b/src/test/ui/wf/wf-trait-fn-where-clause.rs @@ -1,4 +1,4 @@ -// Check that we test WF conditions for fn where clauses in a trait definition. +// Check that we test WF conditions for fn where-clauses in a trait definition. #![allow(dead_code)] diff --git a/src/test/ui/where-clauses/where-clauses-method-unsatisfied.rs b/src/test/ui/where-clauses/where-clauses-method-unsatisfied.rs index d63f37a72215d..2268d30e0cc2c 100644 --- a/src/test/ui/where-clauses/where-clauses-method-unsatisfied.rs +++ b/src/test/ui/where-clauses/where-clauses-method-unsatisfied.rs @@ -1,4 +1,4 @@ -// Test that a where clause attached to a method allows us to add +// Test that a where-clause attached to a method allows us to add // additional constraints to a parameter out of scope. struct Foo { diff --git a/src/test/ui/where-clauses/where-equality-constraints.rs b/src/test/ui/where-clauses/where-equality-constraints.rs index f2349144b88ae..43acda65941ab 100644 --- a/src/test/ui/where-clauses/where-equality-constraints.rs +++ b/src/test/ui/where-clauses/where-equality-constraints.rs @@ -1,6 +1,6 @@ fn f() where u8 = u16 {} -//~^ ERROR equality constraints are not yet supported in where clauses +//~^ ERROR equality constraints are not yet supported in where-clauses fn g() where for<'a> &'static (u8,) == u16, {} -//~^ ERROR equality constraints are not yet supported in where clauses +//~^ ERROR equality constraints are not yet supported in where-clauses fn main() {} diff --git a/src/test/ui/where-clauses/where-equality-constraints.stderr b/src/test/ui/where-clauses/where-equality-constraints.stderr index 220447079c629..07c8b3faed323 100644 --- a/src/test/ui/where-clauses/where-equality-constraints.stderr +++ b/src/test/ui/where-clauses/where-equality-constraints.stderr @@ -1,10 +1,10 @@ -error: equality constraints are not yet supported in where clauses (see #20041) +error: equality constraints are not yet supported in where-clauses (see #20041) --> $DIR/where-equality-constraints.rs:1:14 | LL | fn f() where u8 = u16 {} | ^^^^^^^^ -error: equality constraints are not yet supported in where clauses (see #20041) +error: equality constraints are not yet supported in where-clauses (see #20041) --> $DIR/where-equality-constraints.rs:3:14 | LL | fn g() where for<'a> &'static (u8,) == u16, {} diff --git a/src/test/ui/where-clauses/where-for-self-2.rs b/src/test/ui/where-clauses/where-for-self-2.rs index 0ce38e69f6b0f..e5ea220d7eb22 100644 --- a/src/test/ui/where-clauses/where-for-self-2.rs +++ b/src/test/ui/where-clauses/where-for-self-2.rs @@ -1,5 +1,5 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. Specifically, test that implementing for a +// the self type) in a where-clause. Specifically, test that implementing for a // specific lifetime is not enough to satisfy the `for<'a> ...` constraint, which // should require *all* lifetimes. diff --git a/src/test/ui/where-clauses/where-for-self.rs b/src/test/ui/where-clauses/where-for-self.rs index 9380e72cd7c8b..5ec3f4e421e59 100644 --- a/src/test/ui/where-clauses/where-for-self.rs +++ b/src/test/ui/where-clauses/where-for-self.rs @@ -1,5 +1,5 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. Specifically, test that we cannot nest +// the self type) in a where-clause. Specifically, test that we cannot nest // quantification in constraints (to be clear, there is no reason this should not // we're testing we don't crash or do something stupid). diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 6b3117a1f74f4..042caf444ee7e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -145,101 +145,101 @@ pub struct Config { pub force_valgrind: bool, /// The path to the Clang executable to run Clang-based tests with. If - /// `None` then these tests will be ignored. + /// `None`, then these tests will be ignored. pub run_clang_based_tests_with: Option, - /// The directory containing the tests to run + /// The directory containing the tests to run. pub src_base: PathBuf, - /// The directory where programs should be built + /// The directory where programs should be built. pub build_base: PathBuf, - /// The name of the stage being built (stage1, etc) + /// The name of the stage being built (stage1, etc.) pub stage_id: String, - /// The test mode, compile-fail, run-fail, run-pass + /// The test mode, compile-fail, run-fail, run-pass. pub mode: Mode, - /// Run ignored tests + /// Run ignored tests. pub run_ignored: bool, - /// Only run tests that match this filter + /// Only run tests that match this filter. pub filter: Option, - /// Exactly match the filter, rather than a substring + /// Exactly match the filter, rather than a substring. pub filter_exact: bool, - /// Write out a parseable log of tests that were run + /// Write out a parseable log of tests that were run. pub logfile: Option, /// A command line to prefix program execution with, - /// for running under valgrind + /// for running under valgrind. pub runtool: Option, /// Flags to pass to the compiler when building for the host pub host_rustcflags: Option, - /// Flags to pass to the compiler when building for the target + /// Flags to pass to the compiler when building for the target. pub target_rustcflags: Option, - /// Target system to be tested + /// Target system to be tested. pub target: String, - /// Host triple for the compiler being invoked + /// Host triple for the compiler being invoked. pub host: String, - /// Path to / name of the GDB executable + /// Path to / name of the GDB executable. pub gdb: Option, - /// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch + /// Version of GDB, encoded as `((major * 1000) + minor) * 1000 + patch`. pub gdb_version: Option, - /// Whether GDB has native rust support + /// Whether GDB has native rust support. pub gdb_native_rust: bool, - /// Version of LLDB + /// Version of LLDB. pub lldb_version: Option, - /// Whether LLDB has native rust support + /// `true` if LLDB has native rust support. pub lldb_native_rust: bool, - /// Version of LLVM + /// Version of LLVM. pub llvm_version: Option, - /// Is LLVM a system LLVM + /// `true` if LLVM is system LLVM. pub system_llvm: bool, - /// Path to the android tools + /// Path to the Android tools. pub android_cross_path: PathBuf, - /// Extra parameter to run adb on arm-linux-androideabi + /// Extra parameter to run adb on arm-linux-androideabi. pub adb_path: String, - /// Extra parameter to run test suite on arm-linux-androideabi + /// Extra parameter to run test suite on arm-linux-androideabi. pub adb_test_dir: String, - /// status whether android device available or not + /// Status whether android device available or not. pub adb_device_status: bool, - /// the path containing LLDB's Python module + /// Path containing LLDB's Python module. pub lldb_python_dir: Option, - /// Explain what's going on + /// `true` to enable verbose output. pub verbose: bool, - /// Print one character per test instead of one line + /// Print one character per test instead of one line. pub quiet: bool, - /// Whether to use colors in test. + /// `true` to use colors in test. pub color: ColorConfig, - /// where to find the remote test client process, if we're using it + /// Where to find the remote test client process, if we're using it. pub remote_test_client: Option, - /// mode describing what file the actual ui output will be compared to + /// Mode describing what file the actual ui output will be compared to. pub compare_mode: Option, - // Configuration for various run-make tests frobbing things like C compilers + // Configuration for various run-make tests-frobbing things like C compilers, // or querying about various LLVM component information. pub cc: String, pub cxx: String, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index c2c4a6b69cca5..7cd9284fa9160 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -304,7 +304,7 @@ pub struct TestProps { pub dont_check_compiler_stderr: bool, // Don't force a --crate-type=dylib flag on the command line pub no_prefer_dynamic: bool, - // Run --pretty expanded when running pretty printing tests + // Run --pretty expanded when running pretty-printing tests pub pretty_expanded: bool, // Which pretty mode are we testing with, default to 'normal' pub pretty_mode: String, @@ -314,7 +314,7 @@ pub struct TestProps { pub forbid_output: Vec, // Revisions to test for incremental compilation. pub revisions: Vec, - // Directory (if any) to use for incremental compilation. This is + // Directory (if any) to use for incremental compilation. This is // not set by end-users; rather it is set by the incremental // testing harness and used when generating compilation // arguments. (In particular, it propagates to the aux-builds.) @@ -678,7 +678,7 @@ impl Config { fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> { self.parse_name_value_directive(line, name).map(|nv| { - // nv is either FOO or FOO=BAR + // `nv` is either `"FOO"` or `"FOO=BAR"`. let mut strs: Vec = nv.splitn(2, '=').map(str::to_owned).collect(); match strs.len() { @@ -867,7 +867,7 @@ fn expand_variables(mut value: String, config: &Config) -> String { /// assert_eq!(s, " -> \"something ($WORD bits)\"."); /// ``` fn parse_normalization_string(line: &mut &str) -> Option { - // FIXME support escapes in strings. + // FIXME: support escapes in strings. let begin = line.find('"')? + 1; let end = line[begin..].find('"')? + begin; let result = line[begin..end].to_owned(); diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 12aae303f29aa..eb6031d0d65ea 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -93,7 +93,7 @@ pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec Vec { // The compiler sometimes intermingles non-JSON stuff into the - // output. This hack just skips over such lines. Yuck. + // output. This hack just skips over such lines. Yuck. if line.starts_with('{') { match serde_json::from_str::(line) { Ok(diagnostic) => { @@ -147,7 +147,7 @@ fn push_expected_errors( }; // We break the output into multiple lines, and then append the - // [E123] to every line in the output. This may be overkill. The + // [E123] to every line in the output. This may be overkill. The // intention was to match existing tests that do things like "//| // found `i32` [E123]" and expect to match that somewhere, and yet // also ensure that `//~ ERROR E123` *always* works. The @@ -156,7 +156,7 @@ fn push_expected_errors( let with_code = |span: &DiagnosticSpan, text: &str| { match diagnostic.code { Some(ref code) => - // FIXME(#33000) -- it'd be better to use a dedicated + // FIXME(#33000): it'd be better to use a dedicated // UI harness than to include the line/col number like // this, but some current tests rely on it. // @@ -169,7 +169,7 @@ fn push_expected_errors( span.line_end, span.column_end, text, code.code.clone()), None => - // FIXME(#33000) -- it'd be better to use a dedicated UI harness + // FIXME(#33000): it'd be better to use a dedicated UI harness. format!("{}:{}: {}:{}: {}", span.line_start, span.column_start, span.line_end, span.column_end, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 86cdadade108f..0e27c31c3c22f 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -140,7 +140,7 @@ pub fn parse_config(args: Vec) -> Config { "", "runtool", "supervisor program to run tests under \ - (eg. emulator, valgrind)", + (e.g., emulator, valgrind)", "PROGRAM", ) .optopt( @@ -470,14 +470,14 @@ pub fn run_tests(config: &Config) { _ => { /* proceed */ } } - // FIXME(#33435) Avoid spurious failures in codegen-units/partitioning tests. + // FIXME(#33435): avoid spurious failures in codegen-units/partitioning tests. if let Mode::CodegenUnits = config.mode { let _ = fs::remove_dir_all("tmp/partitioning-tests"); } let opts = test_opts(config); let tests = make_tests(config); - // sadly osx needs some file descriptor limits raised for running tests in + // sadly macOS needs some file descriptor limits raised for running tests in // parallel (especially when we have lots and lots of child processes). // For context, see #8904 unsafe { @@ -619,7 +619,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec test::ShouldPanic::No, @@ -640,7 +640,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec) -> (Option, b // There doesn't seem to be a way to correlate the Apple version // with the upstream version, and since the tests were originally // written against Apple versions, we make a fake Apple version by - // multiplying the first number by 100. This is a hack, but + // multiplying the first number by 100. This is a hack, but // normally fine because the only non-Apple version we test is // rust-enabled. diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index 6dfd8e97c636d..63287f2281a85 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -1,5 +1,5 @@ -// FIXME: This is a complete copy of `cargo/src/cargo/util/read2.rs` -// Consider unify the read2() in libstd, cargo and this to prevent further code duplication. +// FIXME: this is a complete copy of `cargo/src/cargo/util/read2.rs` +// Consider unifying the `read2()` in libstd, cargo and this to prevent further code duplication. pub use self::imp::read2; @@ -56,7 +56,7 @@ mod imp { let mut errfd = 1; while nfds > 0 { - // wait for either pipe to become readable using `select` + // Wait for either pipe to become readable using `select`. let r = unsafe { libc::poll(fds.as_mut_ptr(), nfds, -1) }; if r == -1 { let err = io::Error::last_os_error(); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bac41a7c57904..2f5bef30c4538 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -394,7 +394,7 @@ impl<'test> TestCx<'test> { self.fatal_proc_rec("compilation failed!", &proc_res); } - // FIXME(#41968): Move this check to tidy? + // FIXME(#41968): move this check to *tidy*? let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); assert!( expected_errors.is_empty(), @@ -496,7 +496,7 @@ impl<'test> TestCx<'test> { let mut actual = srcs[srcs.len() - 1].clone(); if self.props.pp_exact.is_some() { - // Now we have to care about line endings + // Now we have to care about line endings. let cr = "\r".to_owned(); actual = actual.replace(&cr, "").to_owned(); expected = expected.replace(&cr, "").to_owned(); @@ -504,22 +504,22 @@ impl<'test> TestCx<'test> { self.compare_source(&expected, &actual); - // If we're only making sure that the output matches then just stop here + // If we're only making sure that the output matches then just stop here. if self.props.pretty_compare_only { return; } - // Finally, let's make sure it actually appears to remain valid code + // Finally, let's make sure it actually appears to remain valid code. let proc_res = self.typecheck_source(actual); if !proc_res.status.success() { - self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res); + self.fatal_proc_rec("pretty-printed source does not type-check", &proc_res); } if !self.props.pretty_expanded { return; } - // additionally, run `--pretty expanded` and try to build it. + // Additionally, run `--pretty expanded` and try to build it. let proc_res = self.print_source(ReadFrom::Path, "expanded"); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res); @@ -532,7 +532,7 @@ impl<'test> TestCx<'test> { let proc_res = self.typecheck_source(expanded_src); if !proc_res.status.success() { self.fatal_proc_rec( - "pretty-printed source (expanded) does not typecheck", + "pretty-printed source (expanded) does not type-check", &proc_res, ); } @@ -650,12 +650,12 @@ impl<'test> TestCx<'test> { fn run_debuginfo_gdb_test_no_opt(&self) { let prefixes = if self.config.gdb_native_rust { - // GDB with Rust + // GDB with Rust. static PREFIXES: &'static [&'static str] = &["gdb", "gdbr"]; println!("NOTE: compiletest thinks it is using GDB with native rust support"); PREFIXES } else { - // Generic GDB + // Generic GDB. static PREFIXES: &'static [&'static str] = &["gdb", "gdbg"]; println!("NOTE: compiletest thinks it is using GDB without native rust support"); PREFIXES @@ -668,7 +668,7 @@ impl<'test> TestCx<'test> { } = self.parse_debugger_commands(prefixes); let mut cmds = commands.join("\n"); - // compile test file (it should have 'compile-flags:-g' in the header) + // Compile test file (it should have `compile-flags:-g` in the header). let compiler_run_result = self.compile_test(); if !compiler_run_result.status.success() { self.fatal_proc_rec("compilation failed!", &compiler_run_result); @@ -685,7 +685,7 @@ impl<'test> TestCx<'test> { None => self.fatal("cannot find android cross path"), }; - // write debugger script + // Write debugger script. let mut script_str = String::with_capacity(2048); script_str.push_str(&format!("set charset {}\n", Self::charset())); script_str.push_str(&format!("set sysroot {}\n", tool_path)); @@ -819,7 +819,7 @@ impl<'test> TestCx<'test> { ); if version > extract_gdb_version("7.4").unwrap() { - // Add the directory containing the pretty printers to + // Add the directory containing the pretty-printers to // GDB's script auto loading safe path script_str.push_str(&format!( "add-auto-load-safe-path {}\n", @@ -835,14 +835,14 @@ impl<'test> TestCx<'test> { } } - // The following line actually doesn't have to do anything with - // pretty printing, it just tells GDB to print values on one line: + // Theis doesn't actually have to do anything with pretty-printing, + // it just tells GDB to print values on one line. script_str.push_str("set print pretty off\n"); - // Add the pretty printer directory to GDB's source-file search path + // Add the pretty-printer directory to GDB's source-file search path. script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)); - // Load the target executable + // Load the target executable. script_str.push_str(&format!( "file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\") @@ -853,7 +853,7 @@ impl<'test> TestCx<'test> { script_str.push_str("set language rust\n"); } - // Add line breakpoints + // Add line breakpoints. for line in &breakpoint_lines { script_str.push_str(&format!( "break '{}':{}\n", @@ -920,7 +920,7 @@ impl<'test> TestCx<'test> { } fn run_debuginfo_lldb_test_no_opt(&self) { - // compile test file (it should have 'compile-flags:-g' in the header) + // Compile test file (it should have `compile-flags:-g` in the header). let compile_result = self.compile_test(); if !compile_result.status.success() { self.fatal_proc_rec("compilation failed!", &compile_result); @@ -953,7 +953,7 @@ impl<'test> TestCx<'test> { PREFIXES }; - // Parse debugger commands etc from test files + // Parse debugger commands, etc., from test files. let DebuggerCommands { commands, check_lines, @@ -961,14 +961,14 @@ impl<'test> TestCx<'test> { .. } = self.parse_debugger_commands(prefixes); - // Write debugger script: - // We don't want to hang when calling `quit` while the process is still running + // Write debugger script. + // We don't want to hang when calling `quit` while the process is still running. let mut script_str = String::from("settings set auto-confirm true\n"); - // Make LLDB emit its version, so we have it documented in the test output + // Make LLDB emit its version, so we have it documented in the test output. script_str.push_str("version\n"); - // Switch LLDB into "Rust mode" + // Switch LLDB into "Rust mode". let rust_src_root = self .config .find_rust_src_root() @@ -987,7 +987,7 @@ impl<'test> TestCx<'test> { script_str.push_str("-x \".*\" --category Rust\n"); script_str.push_str("type category enable Rust\n"); - // Set breakpoints on every line that contains the string "#break" + // Set breakpoints on every line that contains the string `"#break"`. let source_file_name = self.testpaths.file.file_name().unwrap().to_string_lossy(); for line in &breakpoint_lines { script_str.push_str(&format!( @@ -996,21 +996,21 @@ impl<'test> TestCx<'test> { )); } - // Append the other commands + // Append the other commands. for line in &commands { script_str.push_str(line); script_str.push_str("\n"); } - // Finally, quit the debugger + // Finally, quit the debugger. script_str.push_str("\nquit\n"); - // Write the script into a file + // Write the script into a file. debug!("script_str = {}", script_str); self.dump_output_file(&script_str, "debugger.script"); let debugger_script = self.make_out_name("debugger.script"); - // Let LLDB execute the script via lldb_batchmode.py + // Let LLDB execute the script via `lldb_batchmode.py`. let debugger_run_result = self.run_lldb(&exe_file, &debugger_script, &rust_src_root); if !debugger_run_result.status.success() { @@ -1026,7 +1026,7 @@ impl<'test> TestCx<'test> { debugger_script: &Path, rust_src_root: &Path, ) -> ProcRes { - // Prepare the lldb_batchmode which executes the debugger script + // Prepare the lldb_batchmode which executes the debugger script. let lldb_script_path = rust_src_root.join("src/etc/lldb_batchmode.py"); self.cmd2procres( Command::new(&self.config.lldb_python) @@ -1115,7 +1115,8 @@ impl<'test> TestCx<'test> { return None; } - // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS. + // Remove options that are either unwanted (`-O`) or may lead to duplicates due to + // `RUSTFLAGS`. let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()]; let new_options = self .split_maybe_args(options) @@ -1180,7 +1181,7 @@ impl<'test> TestCx<'test> { fn check_single_line(line: &str, check_line: &str) -> bool { // Allow check lines to leave parts unspecified (e.g., uninitialized - // bits in the wrong case of an enum) with the notation "[...]". + // bits in the wrong case of an enum) with the notation `[...]`. let line = line.trim(); let check_line = check_line.trim(); let can_start_anywhere = check_line.starts_with("[...]"); @@ -1287,11 +1288,11 @@ impl<'test> TestCx<'test> { self.fatal_proc_rec("process did not return an error status", proc_res); } - // On Windows, keep all '\' path separators to match the paths reported in the JSON output - // from the compiler + // On Windows, keep all `\` path separators to match the paths reported in the JSON output + // from the compiler. let os_file_name = self.testpaths.file.display().to_string(); - // on windows, translate all '\' path separators to '/' + // On windows, translate all `\` path separators to `/`. let file_name = format!("{}", self.testpaths.file.display()).replace(r"\", "/"); // If the testcase being checked contains at least one expected "help" @@ -1321,7 +1322,7 @@ impl<'test> TestCx<'test> { match opt_index { Some(index) => { - // found a match, everybody is happy + // Found a match; everybody is happy. assert!(!found[index]); found[index] = true; } @@ -1345,7 +1346,7 @@ impl<'test> TestCx<'test> { } let mut not_found = Vec::new(); - // anything not yet found is a problem + // Anything not yet found is a problem. for (index, expected_error) in expected_errors.iter().enumerate() { if !found[index] { self.error(&format!( @@ -1535,7 +1536,7 @@ impl<'test> TestCx<'test> { }; if proc_res.status.success() { - // delete the executable after running it to save space. + // Delete the executable after running it to save space. // it is ok if the deletion failed. let _ = fs::remove_file(self.make_exe_name()); } @@ -1678,7 +1679,7 @@ impl<'test> TestCx<'test> { } path.insert(0, PathBuf::from(lib_path)); - // Add the new dylib search path var + // Add the new dylib search path var. let newpath = env::join_paths(&path).unwrap(); command.env(dylib_env_var(), newpath); @@ -1724,13 +1725,13 @@ impl<'test> TestCx<'test> { .expect("no rustdoc built yet"), ) }; - // FIXME Why is -L here? + // FIXME: why is `-L` here? rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base); - // Use a single thread for efficiency and a deterministic error message order + // Use a single thread for efficiency and a deterministic error message order. rustc.arg("-Zthreads=1"); - // Optionally prevent default --target if specified in test compile-flags. + // Optionally prevent default `--target` if specified in test compile-flags. let custom_target = self .props .compile_flags @@ -1865,11 +1866,11 @@ impl<'test> TestCx<'test> { fn make_exe_name(&self) -> PathBuf { // Using a single letter here to keep the path length down for - // Windows. Some test names get very long. rustc creates `rcgu` + // Windows. Some test names get very long. rustc creates `rcgu` // files with the module name appended to it which can more than // double the length. let mut f = self.output_base_dir().join("a"); - // FIXME: This is using the host architecture exe suffix, not target! + // FIXME: this is using the host architecture `exe` suffix, not target! if self.config.target.contains("emscripten") { f = f.with_extra_extension("js"); } else if self.config.target.contains("wasm32") { @@ -1910,10 +1911,10 @@ impl<'test> TestCx<'test> { let exe_file = self.make_exe_name(); - // FIXME (#9639): This needs to handle non-utf8 paths + // FIXME(#9639): This needs to handle non-UTF8 paths. args.push(exe_file.to_str().unwrap().to_owned()); - // Add the arguments in the run_flags directive + // Add the arguments in the `run_flags` directive. args.extend(self.split_maybe_args(&self.props.run_flags)); let prog = args.remove(0); @@ -1939,12 +1940,12 @@ impl<'test> TestCx<'test> { fn make_cmdline(&self, command: &Command, libpath: &str) -> String { use crate::util; - // Linux and mac don't require adjusting the library search path + // Linux and macOS don't require adjusting the library search path. if cfg!(unix) { format!("{:?}", command) } else { - // Build the LD_LIBRARY_PATH variable as it would be seen on the command line - // for diagnostic purposes + // Build the `LD_LIBRARY_PATH` variable as it would be seen on the command line + // for diagnostic purposes. fn lib_path_cmd_prefix(path: &str) -> String { format!( "{}=\"{}\"", @@ -2046,8 +2047,8 @@ impl<'test> TestCx<'test> { proc_res.fatal(None); } - // This function is a poor man's attempt to debug rust-lang/rust#38620, if - // that's closed then this should be deleted + // This function is a poor man's attempt to debug issue #38620 -- + // when that's closed, this should be deleted. // // This is a very "opportunistic" debugging attempt, so we ignore all // errors here. @@ -2085,7 +2086,7 @@ impl<'test> TestCx<'test> { println!("---------------------------------------------------"); } - // codegen tests (using FileCheck) + // Codegen tests (using `FileCheck`) fn compile_test_and_save_ir(&self) -> ProcRes { let aux_dir = self.aux_output_dir_name(); @@ -2133,7 +2134,7 @@ impl<'test> TestCx<'test> { } fn charset() -> &'static str { - // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset + // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset. if cfg!(target_os = "bitrig") { "auto" } else if cfg!(target_os = "freebsd") { @@ -2321,7 +2322,7 @@ impl<'test> TestCx<'test> { if let Some(actual_item) = actual_item_with_same_name { if !expected_item.codegen_units.is_empty() && - // Also check for codegen units + // Also check for codegen units. expected_item.codegen_units != actual_item.codegen_units { wrong_cgus.push((expected_item.clone(), actual_item.clone())); @@ -2394,7 +2395,7 @@ impl<'test> TestCx<'test> { string: String, } - // [MONO_ITEM] name [@@ (cgu)+] + // `[MONO_ITEM] name [@@ (cgu)+]` fn str_to_mono_item(s: &str, cgu_has_crate_disambiguator: bool) -> MonoItem { let s = if s.starts_with(PREFIX) { (&s[PREFIX.len()..]).trim() @@ -2451,8 +2452,8 @@ impl<'test> TestCx<'test> { string } - // Given a cgu-name-prefix of the form . or - // the form .-in-., + // Given a cgu-name-prefix of the form `.` or + // `.-in-.`, // remove all crate-disambiguators. fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String { lazy_static! { @@ -2479,16 +2480,16 @@ impl<'test> TestCx<'test> { } fn init_incremental_test(&self) { - // (See `run_incremental_test` for an overview of how incremental tests work.) + // See `run_incremental_test` for an overview of how incremental tests work. // Before any of the revisions have executed, create the - // incremental workproduct directory. Delete any old + // incremental workproduct directory. Delete any old // incremental work products that may be there from prior // runs. let incremental_dir = self.incremental_dir(); if incremental_dir.exists() { - // Canonicalizing the path will convert it to the //?/ format - // on Windows, which enables paths longer than 260 character + // Canonicalizing the path will convert it to the `//?/` format + // on Windows, which enables paths longer than 260 characters. let canonicalized = incremental_dir.canonicalize().unwrap(); fs::remove_dir_all(canonicalized).unwrap(); } @@ -2503,24 +2504,24 @@ impl<'test> TestCx<'test> { } fn run_incremental_test(&self) { - // Basic plan for a test incremental/foo/bar.rs: - // - load list of revisions rpass1, cfail2, rpass3 + // Basic plan for a test `incremental/foo/bar.rs`: + // - load list of revisions `rpass1`, `cfail2`, `rpass3` // - each should begin with `rpass`, `cfail`, or `rfail` // - if `rpass`, expect compile and execution to succeed // - if `cfail`, expect compilation to fail // - if `rfail`, expect execution to fail - // - create a directory build/foo/bar.incremental - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C rpass1 - // - because name of revision starts with "rpass", expect success - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C cfail2 - // - because name of revision starts with "cfail", expect an error + // - create a directory `build/foo/bar.incremental` + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C rpass1` + // - because name of revision starts with `rpass`, expect success + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C cfail2` + // - because name of revision starts with `cfail`, expect an error // - load expected errors as usual, but filter for those that end in `[rfail2]` - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C rpass3 - // - because name of revision starts with "rpass", expect success - // - execute build/foo/bar.exe and save output + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C rpass3` + // - because name of revision starts with `rpass`, expect success + // - execute `build/foo/bar` and save output // - // FIXME -- use non-incremental mode as an oracle? That doesn't apply - // to #[rustc_dirty] and clean tests I guess + // FIXME: use non-incremental mode as an oracle? That doesn't apply + // to `#[rustc_dirty]` and clean tests, I guess. let revision = self .revision @@ -2637,8 +2638,8 @@ impl<'test> TestCx<'test> { cmd.env("CLANG", clang); } - // We don't want RUSTFLAGS set from the outside to interfere with - // compiler flags set in the test cases: + // We don't want `RUSTFLAGS` set from the outside to interfere with + // compiler flags set in the test cases. cmd.env_remove("RUSTFLAGS"); if self.config.target.contains("msvc") && self.config.cc != "" { @@ -2694,7 +2695,7 @@ impl<'test> TestCx<'test> { if entry.file_type()?.is_dir() { self.aggressive_rm_rf(&path)?; } else { - // Remove readonly files as well on windows (by default we can't) + // Remove read-only files as well, on Windows (by default we can't). fs::remove_file(&path).or_else(|e| { if cfg!(windows) && e.kind() == io::ErrorKind::PermissionDenied { let mut meta = entry.metadata()?.permissions(); @@ -2711,9 +2712,9 @@ impl<'test> TestCx<'test> { } fn run_ui_test(&self) { - // if the user specified a format in the ui test + // If the user specified a format in the ui test // print the output to the stderr file, otherwise extract - // the rendered error messages from json and print them + // the rendered error messages from the JSON and print them. let explicit = self .props .compile_flags @@ -2749,9 +2750,9 @@ impl<'test> TestCx<'test> { self.prune_duplicate_outputs(&modes_to_prune); if self.config.compare_mode.is_some() { - // don't test rustfix with nll right now + // Don't test rustfix with NLL right now. } else if self.props.run_rustfix { - // Apply suggestions from rustc to the code itself + // Apply suggestions from rustc to the code itself. let unfixed_code = self .load_expected_output_from_path(&self.testpaths.file) .unwrap(); @@ -2968,7 +2969,7 @@ impl<'test> TestCx<'test> { }; // We expect each non-empty line to appear consecutively, non-consecutive lines - // must be separated by at least one Elision + // must be separated by at least one elision. let mut start_block_line = None; while let Some(dumped_line) = dumped_lines.next() { match expected_lines.next() { @@ -2993,7 +2994,7 @@ impl<'test> TestCx<'test> { } } Some(&ExpectedLine::Elision) => { - // skip any number of elisions in a row. + // Skip any number of elisions in a row. while let Some(&&ExpectedLine::Elision) = expected_lines.peek() { expected_lines.next(); } @@ -3041,7 +3042,7 @@ impl<'test> TestCx<'test> { let mut normalized = output.replace(&parent_dir_str, "$DIR"); - // Paths into the libstd/libcore + // Paths into the libstd/libcore. let src_dir = self.config.src_base.parent().unwrap().parent().unwrap(); let src_dir_str = if json { src_dir.display().to_string().replace("\\", "\\\\") @@ -3050,39 +3051,43 @@ impl<'test> TestCx<'test> { }; normalized = normalized.replace(&src_dir_str, "$SRC_DIR"); - // Paths into the build directory + // Paths into the build directory. let test_build_dir = &self.config.build_base; let parent_build_dir = test_build_dir.parent().unwrap().parent().unwrap().parent().unwrap(); - // eg. /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui + // E.g., `/home/user/rust/build/x86_64-unknown-linux-gnu/test/ui`. normalized = normalized.replace(test_build_dir.to_str().unwrap(), "$TEST_BUILD_DIR"); - // eg. /home/user/rust/build + // E.g., `/home/user/rust/build`. normalized = normalized.replace(&parent_build_dir.to_str().unwrap(), "$BUILD_DIR"); - // Paths into lib directory. + // Paths into `lib` directory. let mut lib_dir = parent_build_dir.parent().unwrap().to_path_buf(); lib_dir.push("lib"); normalized = normalized.replace(&lib_dir.to_str().unwrap(), "$LIB_DIR"); if json { - // escaped newlines in json strings should be readable - // in the stderr files. There's no point int being correct, + // Escaped newlines in JSON strings should be readable + // in the stderr files. There's no point in being correct, // since only humans process the stderr files. - // Thus we just turn escaped newlines back into newlines. + // Thus, we just turn escaped newlines back into newlines. normalized = normalized.replace("\\n", "\n"); } // If there are `$SRC_DIR` normalizations with line and column numbers, then replace them // with placeholders as we do not want tests needing updated when compiler source code // changes. - // eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL + // E.g., `$SRC_DIR/libcore/mem.rs:323:14` becomes `$SRC_DIR/libcore/mem.rs:LL:COL`. normalized = Regex::new("SRC_DIR(.+):\\d+:\\d+").unwrap() .replace_all(&normalized, "SRC_DIR$1:LL:COL").into_owned(); - normalized = normalized.replace("\\\\", "\\") // denormalize for paths on windows - .replace("\\", "/") // normalize for paths on windows - .replace("\r\n", "\n") // normalize for linebreaks on windows - .replace("\t", "\\t"); // makes tabs visible + // Denormalize for paths on Windows. + normalized = normalized.replace("\\\\", "\\") + // Normalize for paths on windows. + .replace("\\", "/") + // Normalize for line breaks on windows. + .replace("\r\n", "\n") + // Makes tabs visible. + .replace("\t", "\\t"); for rule in custom_rules { let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule"); normalized = re.replace_all(&normalized, &rule.1[..]).into_owned(); diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index af704ce260dc4..7dde5026d9520 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -86,7 +86,7 @@ impl FileEntry { *errors = true; println!("{}:{}: id is not unique: `{}`", file.display(), i, fragment); } - // Just in case, we also add the encoded id. + // Just in case, we also add the encoded ID. self.ids.insert(encoded); }); } diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs index 26ced7fc8297a..0e432fd1a68d5 100644 --- a/src/tools/tidy/src/cargo.rs +++ b/src/tools/tidy/src/cargo.rs @@ -41,7 +41,7 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) { // // We just look for: // - // ```` + // ```toml // [dependencies] // name = ... // name2 = ... diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 7126c0c2f6ecf..2e44c4dd3d141 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -173,7 +173,7 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features { let contents = t!(fs::read_to_string(base_src_path.join("libsyntax/feature_gate.rs"))); // We allow rustc-internal features to omit a tracking issue. - // These features must be marked with a `// rustc internal` in its own group. + // These features must be marked with `// rustc internal` in its own group. let mut next_feature_is_rustc_internal = false; contents.lines().zip(1..) @@ -327,7 +327,7 @@ fn map_lib_features(base_src_path: &Path, } becoming_feature = None; if line.contains("rustc_const_unstable(") { - // `const fn` features are handled specially. + // Const fn features are handled specially. let feature_name = match find_attr_val(line, "feature") { Some(name) => name, None => err!("malformed stability attribute"),