diff options
Diffstat (limited to 'src')
1022 files changed, 6295 insertions, 4156 deletions
diff --git a/src/bootstrap/CHANGELOG.md b/src/bootstrap/CHANGELOG.md index a103c9fb0b7..f899f21080e 100644 --- a/src/bootstrap/CHANGELOG.md +++ b/src/bootstrap/CHANGELOG.md @@ -4,7 +4,12 @@ All notable changes to bootstrap will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Non-breaking changes since the last major version] + +## [Changes since the last major version] + +- `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703) + +### Non-breaking changes - `x.py check` needs opt-in to check tests (--all-targets) [#77473](https://github.com/rust-lang/rust/pull/77473) - The default bootstrap profiles are now located at `bootstrap/defaults/config.$PROFILE.toml` (previously they were located at `bootstrap/defaults/config.toml.$PROFILE`) [#77558](https://github.com/rust-lang/rust/pull/77558) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 84ed9446ae7..a2e596bf4e9 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -201,7 +201,6 @@ build/ # Output for all compiletest-based test suites test/ ui/ - compile-fail/ debuginfo/ ... diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 97f40815b87..f60ae02bffe 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -351,11 +351,13 @@ def output(filepath): with open(tmp, 'w') as f: yield f try: - os.remove(filepath) # PermissionError/OSError on Win32 if in use - os.rename(tmp, filepath) + if os.path.exists(filepath): + os.remove(filepath) # PermissionError/OSError on Win32 if in use except OSError: shutil.copy2(tmp, filepath) os.remove(tmp) + return + os.rename(tmp, filepath) class RustBuild(object): @@ -391,7 +393,7 @@ class RustBuild(object): if self.rustc().startswith(self.bin_root()) and \ (not os.path.exists(self.rustc()) or - self.program_out_of_date(self.rustc_stamp())): + self.program_out_of_date(self.rustc_stamp(), self.date)): if os.path.exists(self.bin_root()): shutil.rmtree(self.bin_root()) tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz' @@ -427,7 +429,7 @@ class RustBuild(object): self.fix_bin_or_dylib("{}/bin/rustfmt".format(self.bin_root())) self.fix_bin_or_dylib("{}/bin/cargo-fmt".format(self.bin_root())) with output(self.rustfmt_stamp()) as rustfmt_stamp: - rustfmt_stamp.write(self.date + self.rustfmt_channel) + rustfmt_stamp.write(self.rustfmt_channel) if self.downloading_llvm(): # We want the most recent LLVM submodule update to avoid downloading @@ -454,7 +456,7 @@ class RustBuild(object): for binary in ["llvm-config", "FileCheck"]: self.fix_bin_or_dylib("{}/bin/{}".format(self.llvm_root(), binary)) with output(self.llvm_stamp()) as llvm_stamp: - llvm_stamp.write(self.date + llvm_sha + str(llvm_assertions)) + llvm_stamp.write(llvm_sha + str(llvm_assertions)) def downloading_llvm(self): opt = self.get_toml('download-ci-llvm', 'llvm') @@ -485,7 +487,12 @@ class RustBuild(object): url = "https://ci-artifacts.rust-lang.org/rustc-builds/{}".format(llvm_sha) if llvm_assertions: url = url.replace('rustc-builds', 'rustc-builds-alt') - tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz' + # ci-artifacts are only stored as .xz, not .gz + if not support_xz(): + print("error: XZ support is required to download LLVM") + print("help: consider disabling `download-ci-llvm` or using python3") + exit(1) + tarball_suffix = '.tar.xz' filename = "rust-dev-nightly-" + self.build + tarball_suffix tarball = os.path.join(rustc_cache, filename) if not os.path.exists(tarball): @@ -616,12 +623,12 @@ class RustBuild(object): return os.path.join(self.llvm_root(), '.llvm-stamp') - def program_out_of_date(self, stamp_path, extra=""): + def program_out_of_date(self, stamp_path, key): """Check if the given program stamp is out of date""" if not os.path.exists(stamp_path) or self.clean: return True with open(stamp_path, 'r') as stamp: - return (self.date + extra) != stamp.read() + return key != stamp.read() def bin_root(self): """Return the binary root directory diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index 0e941e13676..61507114159 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -70,6 +70,7 @@ class ProgramOutOfDate(unittest.TestCase): self.build.build_dir = self.container self.rustc_stamp_path = os.path.join(self.container, "stage0", ".rustc-stamp") + self.key = self.build.date + str(None) def tearDown(self): rmtree(self.container) @@ -78,19 +79,19 @@ class ProgramOutOfDate(unittest.TestCase): """Return True when the stamp file does not exists""" if os.path.exists(self.rustc_stamp_path): os.unlink(self.rustc_stamp_path) - self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path)) + self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path, self.key)) def test_dates_are_different(self): """Return True when the dates are different""" with open(self.rustc_stamp_path, "w") as rustc_stamp: - rustc_stamp.write("2017-06-14") - self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path)) + rustc_stamp.write("2017-06-14None") + self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path, self.key)) def test_same_dates(self): """Return False both dates match""" with open(self.rustc_stamp_path, "w") as rustc_stamp: - rustc_stamp.write("2017-06-15") - self.assertFalse(self.build.program_out_of_date(self.rustc_stamp_path)) + rustc_stamp.write("2017-06-15None") + self.assertFalse(self.build.program_out_of_date(self.rustc_stamp_path, self.key)) if __name__ == '__main__': diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0fdafa39386..ec9ce4c820c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -384,7 +384,6 @@ impl<'a> Builder<'a> { test::ExpandYamlAnchors, test::Tidy, test::Ui, - test::CompileFail, test::RunPassValgrind, test::MirOpt, test::Codegen, @@ -737,10 +736,7 @@ impl<'a> Builder<'a> { if self.config.deny_warnings { cmd.arg("-Dwarnings"); } - // cfg(not(bootstrap)), can be removed on the next beta bump - if compiler.stage != 0 { - cmd.arg("-Znormalize-docs"); - } + cmd.arg("-Znormalize-docs"); // Remove make-related flags that can cause jobserver problems. cmd.env_remove("MAKEFLAGS"); @@ -1538,7 +1534,7 @@ impl Rustflags { fn arg(&mut self, arg: &str) -> &mut Self { assert_eq!(arg.split(' ').count(), 1); if !self.0.is_empty() { - self.0.push_str(" "); + self.0.push(' '); } self.0.push_str(arg); self diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 2b82f6c30b2..6e65be93fec 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -74,9 +74,9 @@ impl GitInfo { if let Some(ref inner) = self.inner { version.push_str(" ("); version.push_str(&inner.short_sha); - version.push_str(" "); + version.push(' '); version.push_str(&inner.commit_date); - version.push_str(")"); + version.push(')'); } version } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index f65b2b2c79f..72a979338a5 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -21,6 +21,16 @@ fn args(builder: &Builder<'_>) -> Vec<String> { } if let Subcommand::Clippy { fix, .. } = builder.config.cmd { + // disable the most spammy clippy lints + let ignored_lints = vec![ + "many_single_char_names", // there are a lot in stdarch + "collapsible_if", + "type_complexity", + "missing_safety_doc", // almost 3K warnings + "too_many_arguments", + "needless_lifetimes", // people want to keep the lifetimes + "wrong_self_convention", + ]; let mut args = vec![]; if fix { #[rustfmt::skip] @@ -33,6 +43,7 @@ fn args(builder: &Builder<'_>) -> Vec<String> { ])); } args.extend(strings(&["--", "--cap-lints", "warn"])); + args.extend(ignored_lints.iter().map(|lint| format!("-Aclippy::{}", lint))); args } else { vec![] diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs index f83dfe8e635..9b9df36e7dc 100644 --- a/src/bootstrap/clean.rs +++ b/src/bootstrap/clean.rs @@ -21,6 +21,7 @@ pub fn clean(build: &Build, all: bool) { } else { rm_rf(&build.out.join("tmp")); rm_rf(&build.out.join("dist")); + rm_rf(&build.out.join("bootstrap")); for host in &build.hosts { let entries = match build.out.join(host.triple).read_dir() { diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 091bd2a1c5a..9477a7cb354 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -7,6 +7,7 @@ //! goes along from the output of the previous stage. use std::borrow::Cow; +use std::collections::HashSet; use std::env; use std::fs; use std::io::prelude::*; @@ -355,15 +356,12 @@ fn copy_sanitizers( let dst = libdir.join(&runtime.name); builder.copy(&runtime.path, &dst); - if target == "x86_64-apple-darwin" { - // Update the library install name reflect the fact it has been renamed. - let status = Command::new("install_name_tool") - .arg("-id") - .arg(format!("@rpath/{}", runtime.name)) - .arg(&dst) - .status() - .expect("failed to execute `install_name_tool`"); - assert!(status.success()); + if target == "x86_64-apple-darwin" || target == "aarch64-apple-darwin" { + // Update the library’s install name to reflect that it has has been renamed. + apple_darwin_update_library_name(&dst, &format!("@rpath/{}", &runtime.name)); + // Upon renaming the install name, the code signature of the file will invalidate, + // so we will sign it again. + apple_darwin_sign_file(&dst); } target_deps.push(dst); @@ -372,6 +370,27 @@ fn copy_sanitizers( target_deps } +fn apple_darwin_update_library_name(library_path: &Path, new_name: &str) { + let status = Command::new("install_name_tool") + .arg("-id") + .arg(new_name) + .arg(library_path) + .status() + .expect("failed to execute `install_name_tool`"); + assert!(status.success()); +} + +fn apple_darwin_sign_file(file_path: &Path) { + let status = Command::new("codesign") + .arg("-f") // Force to rewrite the existing signature + .arg("-s") + .arg("-") + .arg(file_path) + .status() + .expect("failed to execute `codesign`"); + assert!(status.success()); +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct StartupObjects { pub compiler: Compiler, @@ -991,13 +1010,26 @@ impl Step for Assemble { builder.info(&format!("Assembling stage{} compiler ({})", stage, host)); // Link in all dylibs to the libdir + let stamp = librustc_stamp(builder, build_compiler, target_compiler.host); + let proc_macros = builder + .read_stamp_file(&stamp) + .into_iter() + .filter_map(|(path, dependency_type)| { + if dependency_type == DependencyType::Host { + Some(path.file_name().unwrap().to_owned().into_string().unwrap()) + } else { + None + } + }) + .collect::<HashSet<_>>(); + let sysroot = builder.sysroot(target_compiler); let rustc_libdir = builder.rustc_libdir(target_compiler); t!(fs::create_dir_all(&rustc_libdir)); let src_libdir = builder.sysroot_libdir(build_compiler, host); for f in builder.read_dir(&src_libdir) { let filename = f.file_name().into_string().unwrap(); - if is_dylib(&filename) { + if is_dylib(&filename) && !proc_macros.contains(&filename) { builder.copy(&f.path(), &rustc_libdir.join(&filename)); } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index def8f215436..f4d89a89c14 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -148,6 +148,7 @@ pub struct Config { pub dist_sign_folder: Option<PathBuf>, pub dist_upload_addr: Option<String>, pub dist_gpg_password_file: Option<PathBuf>, + pub dist_compression_formats: Option<Vec<String>>, // libstd features pub backtrace: bool, // support for RUST_BACKTRACE @@ -334,7 +335,7 @@ impl Merge for TomlConfig { *x = Some(new); } } - }; + } do_merge(&mut self.build, build); do_merge(&mut self.install, install); do_merge(&mut self.llvm, llvm); @@ -438,6 +439,7 @@ struct Dist { upload_addr: Option<String>, src_tarball: Option<bool>, missing_tools: Option<bool>, + compression_formats: Option<Vec<String>>, } #[derive(Deserialize)] @@ -936,6 +938,7 @@ impl Config { config.dist_sign_folder = t.sign_folder.map(PathBuf::from); config.dist_gpg_password_file = t.gpg_password_file.map(PathBuf::from); config.dist_upload_addr = t.upload_addr; + config.dist_compression_formats = t.compression_formats; set(&mut config.rust_dist_src, t.src_tarball); set(&mut config.missing_tools, t.missing_tools); } diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 42f00ce9621..2cabaee68ea 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -147,6 +147,8 @@ v("experimental-targets", "llvm.experimental-targets", "experimental LLVM targets to build") v("release-channel", "rust.channel", "the name of the release channel to build") v("release-description", "rust.description", "optional descriptive string for version output") +v("dist-compression-formats", None, + "comma-separated list of compression formats to use") # Used on systems where "cc" is unavailable v("default-linker", "rust.default-linker", "the default linker") @@ -349,6 +351,8 @@ for key in known_args: elif option.name == 'option-checking': # this was handled above pass + elif option.name == 'dist-compression-formats': + set('dist.compression-formats', value.split(',')) else: raise RuntimeError("unhandled option {}".format(option.name)) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index fcbde9c438c..e2c2e19b0bc 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -19,6 +19,7 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::cache::{Interned, INTERNER}; use crate::compile; use crate::config::TargetSelection; +use crate::tarball::{GeneratedTarball, OverlayKind, Tarball}; use crate::tool::{self, Tool}; use crate::util::{exe, is_dylib, timeit}; use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; @@ -36,10 +37,6 @@ pub fn tmpdir(builder: &Builder<'_>) -> PathBuf { builder.out.join("tmp/dist") } -fn rust_installer(builder: &Builder<'_>) -> Command { - builder.tool_cmd(Tool::RustInstaller) -} - fn missing_tool(tool_name: &str, skip: bool) { if skip { println!("Unable to build {}, skipping dist", tool_name) @@ -54,7 +51,7 @@ pub struct Docs { } impl Step for Docs { - type Output = PathBuf; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -66,48 +63,20 @@ impl Step for Docs { } /// Builds the `rust-docs` installer component. - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let host = self.host; - - let name = pkgname(builder, "rust-docs"); - if !builder.config.docs { - return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)); + return None; } - builder.default_doc(None); - builder.info(&format!("Dist docs ({})", host)); - let _time = timeit(builder); + let dest = "share/doc/rust/html"; - let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple)); - let _ = fs::remove_dir_all(&image); - - let dst = image.join("share/doc/rust/html"); - t!(fs::create_dir_all(&dst)); - let src = builder.doc_out(host); - builder.cp_r(&src, &dst); - builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644); - - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust-Documentation") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-documentation-is-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, host.triple)) - .arg("--component-name=rust-docs") - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--bulk-dirs=share/doc/rust/html"); - builder.run(&mut cmd); - builder.remove_dir(&image); - - distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)) + let mut tarball = Tarball::new(builder, "rust-docs", &host.triple); + tarball.set_product_name("Rust Documentation"); + tarball.add_dir(&builder.doc_out(host), dest); + tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644); + Some(tarball.generate()) } } @@ -117,7 +86,7 @@ pub struct RustcDocs { } impl Step for RustcDocs { - type Output = PathBuf; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -129,47 +98,17 @@ impl Step for RustcDocs { } /// Builds the `rustc-docs` installer component. - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let host = self.host; - - let name = pkgname(builder, "rustc-docs"); - if !builder.config.compiler_docs { - return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)); + return None; } - builder.default_doc(None); - let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple)); - let _ = fs::remove_dir_all(&image); - - let dst = image.join("share/doc/rust/html/rustc"); - t!(fs::create_dir_all(&dst)); - let src = builder.compiler_doc_out(host); - builder.cp_r(&src, &dst); - - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rustc-Documentation") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rustc-documentation-is-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, host.triple)) - .arg("--component-name=rustc-docs") - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--bulk-dirs=share/doc/rust/html/rustc"); - - builder.info(&format!("Dist compiler docs ({})", host)); - let _time = timeit(builder); - builder.run(&mut cmd); - builder.remove_dir(&image); - - distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)) + let mut tarball = Tarball::new(builder, "rustc-docs", &host.triple); + tarball.set_product_name("Rustc Documentation"); + tarball.add_dir(&builder.compiler_doc_out(host), "share/doc/rust/html/rustc"); + Some(tarball.generate()) } } @@ -328,7 +267,7 @@ pub struct Mingw { } impl Step for Mingw { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -343,43 +282,22 @@ impl Step for Mingw { /// /// This contains all the bits and pieces to run the MinGW Windows targets /// without any extra installed software (e.g., we bundle gcc, libraries, etc). - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let host = self.host; - if !host.contains("pc-windows-gnu") { return None; } - builder.info(&format!("Dist mingw ({})", host)); - let _time = timeit(builder); - let name = pkgname(builder, "rust-mingw"); - let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple)); - let _ = fs::remove_dir_all(&image); - t!(fs::create_dir_all(&image)); + let mut tarball = Tarball::new(builder, "rust-mingw", &host.triple); + tarball.set_product_name("Rust MinGW"); // The first argument is a "temporary directory" which is just // thrown away (this contains the runtime DLLs included in the rustc package // above) and the second argument is where to place all the MinGW components // (which is what we want). - make_win_dist(&tmpdir(builder), &image, host, &builder); - - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust-MinGW") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-MinGW-is-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, host.triple)) - .arg("--component-name=rust-mingw") - .arg("--legacy-manifest-dirs=rustlib,cargo"); - builder.run(&mut cmd); - t!(fs::remove_dir_all(&image)); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple))) + make_win_dist(&tmpdir(builder), tarball.image_dir(), host, &builder); + + Some(tarball.generate()) } } @@ -389,7 +307,7 @@ pub struct Rustc { } impl Step for Rustc { - type Output = PathBuf; + type Output = GeneratedTarball; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -403,34 +321,14 @@ impl Step for Rustc { } /// Creates the `rustc` installer component. - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; let host = self.compiler.host; - let name = pkgname(builder, "rustc"); - let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple)); - let _ = fs::remove_dir_all(&image); - let overlay = tmpdir(builder).join(format!("{}-{}-overlay", name, host.triple)); - let _ = fs::remove_dir_all(&overlay); + let tarball = Tarball::new(builder, "rustc", &host.triple); // Prepare the rustc "image", what will actually end up getting installed - prepare_image(builder, compiler, &image); - - // Prepare the overlay which is part of the tarball but won't actually be - // installed - let cp = |file: &str| { - builder.install(&builder.src.join(file), &overlay, 0o644); - }; - cp("COPYRIGHT"); - cp("LICENSE-APACHE"); - cp("LICENSE-MIT"); - cp("README.md"); - // tiny morsel of metadata is used by rust-packaging - let version = builder.rust_version(); - builder.create(&overlay.join("version"), &version); - if let Some(sha) = builder.rust_sha() { - builder.create(&overlay.join("git-commit-hash"), &sha); - } + prepare_image(builder, compiler, tarball.image_dir()); // On MinGW we've got a few runtime DLL dependencies that we need to // include. The first argument to this script is where to put these DLLs @@ -443,38 +341,11 @@ impl Step for Rustc { // install will *also* include the rust-mingw package, which also needs // licenses, so to be safe we just include it here in all MinGW packages. if host.contains("pc-windows-gnu") { - make_win_dist(&image, &tmpdir(builder), host, builder); - - let dst = image.join("share/doc"); - t!(fs::create_dir_all(&dst)); - builder.cp_r(&builder.src.join("src/etc/third-party"), &dst); + make_win_dist(tarball.image_dir(), &tmpdir(builder), host, builder); + tarball.add_dir(builder.src.join("src/etc/third-party"), "share/doc"); } - // Finally, wrap everything up in a nice tarball! - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-is-ready-to-roll.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, host.triple)) - .arg("--component-name=rustc") - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host.triple)); - let _time = timeit(builder); - builder.run(&mut cmd); - builder.remove_dir(&image); - builder.remove_dir(&overlay); - - return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)); + return tarball.generate(); fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) { let host = compiler.host; @@ -684,7 +555,7 @@ pub struct Std { } impl Step for Std { - type Output = PathBuf; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -702,46 +573,24 @@ impl Step for Std { }); } - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; - let name = pkgname(builder, "rust-std"); - let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)); if skip_host_target_lib(builder, compiler) { - return archive; + return None; } builder.ensure(compile::Std { compiler, target }); - let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple)); - let _ = fs::remove_dir_all(&image); + let mut tarball = Tarball::new(builder, "rust-std", &target.triple); + tarball.include_target_in_component_name(true); let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); let stamp = compile::libstd_stamp(builder, compiler_to_use, target); - copy_target_libs(builder, target, &image, &stamp); - - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=std-is-standing-at-the-ready.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg(format!("--component-name=rust-std-{}", target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder - .info(&format!("Dist std stage{} ({} -> {})", compiler.stage, &compiler.host, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - builder.remove_dir(&image); - archive + copy_target_libs(builder, target, &tarball.image_dir(), &stamp); + + Some(tarball.generate()) } } @@ -752,7 +601,7 @@ pub struct RustcDev { } impl Step for RustcDev { - type Output = PathBuf; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -771,60 +620,36 @@ impl Step for RustcDev { }); } - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; - - let name = pkgname(builder, "rustc-dev"); - let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)); if skip_host_target_lib(builder, compiler) { - return archive; + return None; } builder.ensure(compile::Rustc { compiler, target }); - let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple)); - let _ = fs::remove_dir_all(&image); + let tarball = Tarball::new(builder, "rustc-dev", &target.triple); let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); let stamp = compile::librustc_stamp(builder, compiler_to_use, target); - copy_target_libs(builder, target, &image, &stamp); - - // Copy compiler sources. - let dst_src = image.join("lib/rustlib/rustc-src/rust"); - t!(fs::create_dir_all(&dst_src)); + copy_target_libs(builder, target, tarball.image_dir(), &stamp); - let src_files = ["Cargo.lock"]; + let src_files = &["Cargo.lock"]; // This is the reduced set of paths which will become the rustc-dev component // (essentially the compiler crates and all of their path dependencies). - copy_src_dirs(builder, &builder.src, &["compiler"], &[], &dst_src); - for file in src_files.iter() { - builder.copy(&builder.src.join(file), &dst_src.join(file)); + copy_src_dirs( + builder, + &builder.src, + &["compiler"], + &[], + &tarball.image_dir().join("lib/rustlib/rustc-src/rust"), + ); + for file in src_files { + tarball.add_file(builder.src.join(file), "lib/rustlib/rustc-src/rust", 0o644); } - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-is-ready-to-develop.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg(format!("--component-name=rustc-dev-{}", target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info(&format!( - "Dist rustc-dev stage{} ({} -> {})", - compiler.stage, &compiler.host, target - )); - let _time = timeit(builder); - builder.run(&mut cmd); - builder.remove_dir(&image); - archive + Some(tarball.generate()) } } @@ -835,7 +660,7 @@ pub struct Analysis { } impl Step for Analysis { - type Output = PathBuf; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -858,52 +683,26 @@ impl Step for Analysis { } /// Creates a tarball of save-analysis metadata, if available. - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - let name = pkgname(builder, "rust-analysis"); - if compiler.host != builder.config.build { - return distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)); + return None; } builder.ensure(compile::Std { compiler, target }); - - let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple)); - let src = builder .stage_out(compiler, Mode::Std) .join(target.triple) .join(builder.cargo_dir()) - .join("deps"); + .join("deps") + .join("save-analysis"); - let image_src = src.join("save-analysis"); - let dst = image.join("lib/rustlib").join(target.triple).join("analysis"); - t!(fs::create_dir_all(&dst)); - builder.info(&format!("image_src: {:?}, dst: {:?}", image_src, dst)); - builder.cp_r(&image_src, &dst); - - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=save-analysis-saved.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg(format!("--component-name=rust-analysis-{}", target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info("Dist analysis"); - let _time = timeit(builder); - builder.run(&mut cmd); - builder.remove_dir(&image); - distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)) + let mut tarball = Tarball::new(builder, "rust-analysis", &target.triple); + tarball.include_target_in_component_name(true); + tarball.add_dir(src, format!("lib/rustlib/{}/analysis", target.triple)); + Some(tarball.generate()) } } @@ -997,7 +796,7 @@ pub struct Src; impl Step for Src { /// The output path of the src installer tarball - type Output = PathBuf; + type Output = GeneratedTarball; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -1010,10 +809,8 @@ impl Step for Src { } /// Creates the `rust-src` installer component - fn run(self, builder: &Builder<'_>) -> PathBuf { - let name = pkgname(builder, "rust-src"); - let image = tmpdir(builder).join(format!("{}-image", name)); - let _ = fs::remove_dir_all(&image); + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { + let tarball = Tarball::new_targetless(builder, "rust-src"); // A lot of tools expect the rust-src component to be entirely in this directory, so if you // change that (e.g. by adding another directory `lib/rustlib/src/foo` or @@ -1022,8 +819,7 @@ impl Step for Src { // // NOTE: if you update the paths here, you also should update the "virtual" path // translation code in `imported_source_files` in `src/librustc_metadata/rmeta/decoder.rs` - let dst_src = image.join("lib/rustlib/src/rust"); - t!(fs::create_dir_all(&dst_src)); + let dst_src = tarball.image_dir().join("lib/rustlib/src/rust"); let src_files = ["Cargo.lock"]; // This is the reduced set of paths which will become the rust-src component @@ -1043,28 +839,7 @@ impl Step for Src { builder.copy(&builder.src.join(file), &dst_src.join(file)); } - // Create source tarball in rust-installer format - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Awesome-Source.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}", name)) - .arg("--component-name=rust-src") - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info("Dist src"); - let _time = timeit(builder); - builder.run(&mut cmd); - - builder.remove_dir(&image); - distdir(builder).join(&format!("{}.tar.gz", name)) + tarball.generate() } } @@ -1073,7 +848,7 @@ pub struct PlainSourceTarball; impl Step for PlainSourceTarball { /// Produces the location of the tarball generated - type Output = PathBuf; + type Output = GeneratedTarball; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -1087,12 +862,9 @@ impl Step for PlainSourceTarball { } /// Creates the plain source tarball - fn run(self, builder: &Builder<'_>) -> PathBuf { - // Make sure that the root folder of tarball has the correct name - let plain_name = format!("{}-src", pkgname(builder, "rustc")); - let plain_dst_src = tmpdir(builder).join(&plain_name); - let _ = fs::remove_dir_all(&plain_dst_src); - t!(fs::create_dir_all(&plain_dst_src)); + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { + let tarball = Tarball::new(builder, "rustc", "src"); + let plain_dst_src = tarball.image_dir(); // This is the set of root paths which will become part of the source package let src_files = [ @@ -1135,28 +907,7 @@ impl Step for PlainSourceTarball { builder.run(&mut cmd); } - // Create plain source tarball - let plain_name = format!("rustc-{}-src", builder.rust_package_vers()); - let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name)); - tarball.set_extension(""); // strip .gz - tarball.set_extension(""); // strip .tar - if let Some(dir) = tarball.parent() { - builder.create_dir(&dir); - } - builder.info("running installer"); - let mut cmd = rust_installer(builder); - cmd.arg("tarball") - .arg("--input") - .arg(&plain_name) - .arg("--output") - .arg(&tarball) - .arg("--work-dir=.") - .current_dir(tmpdir(builder)); - - builder.info("Create plain source tarball"); - let _time = timeit(builder); - builder.run(&mut cmd); - distdir(builder).join(&format!("{}.tar.gz", plain_name)) + tarball.bare() } } @@ -1190,7 +941,7 @@ pub struct Cargo { } impl Step for Cargo { - type Output = PathBuf; + type Output = GeneratedTarball; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1208,76 +959,32 @@ impl Step for Cargo { }); } - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; let target = self.target; + let cargo = builder.ensure(tool::Cargo { compiler, target }); let src = builder.src.join("src/tools/cargo"); let etc = src.join("src/etc"); - let release_num = builder.release_num("cargo"); - let name = pkgname(builder, "cargo"); - let version = builder.cargo_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("cargo-image"); - drop(fs::remove_dir_all(&image)); - builder.create_dir(&image); // Prepare the image directory - builder.create_dir(&image.join("share/zsh/site-functions")); - builder.create_dir(&image.join("etc/bash_completion.d")); - let cargo = builder.ensure(tool::Cargo { compiler, target }); - builder.install(&cargo, &image.join("bin"), 0o755); + let mut tarball = Tarball::new(builder, "cargo", &target.triple); + tarball.set_overlay(OverlayKind::Cargo); + + tarball.add_file(&cargo, "bin", 0o755); + tarball.add_file(etc.join("_cargo"), "share/zsh/site-functions", 0o644); + tarball.add_renamed_file(etc.join("cargo.bashcomp.sh"), "etc/bash_completion.d", "cargo"); + tarball.add_dir(etc.join("man"), "share/man/man1"); + tarball.add_legal_and_readme_to("share/doc/cargo"); + for dirent in fs::read_dir(cargo.parent().unwrap()).expect("read_dir") { let dirent = dirent.expect("read dir entry"); if dirent.file_name().to_str().expect("utf8").starts_with("cargo-credential-") { - builder.install(&dirent.path(), &image.join("libexec"), 0o755); + tarball.add_file(&dirent.path(), "libexec", 0o755); } } - for man in t!(etc.join("man").read_dir()) { - let man = t!(man); - builder.install(&man.path(), &image.join("share/man/man1"), 0o644); - } - builder.install(&etc.join("_cargo"), &image.join("share/zsh/site-functions"), 0o644); - builder.copy(&etc.join("cargo.bashcomp.sh"), &image.join("etc/bash_completion.d/cargo")); - let doc = image.join("share/doc/cargo"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-THIRD-PARTY"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("cargo-overlay"); - drop(fs::remove_dir_all(&overlay)); - builder.create_dir(&overlay); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - builder.install(&src.join("LICENSE-THIRD-PARTY"), &overlay, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-is-ready-to-roll.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--component-name=cargo") - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info(&format!("Dist cargo stage{} ({})", compiler.stage, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)) + + tarball.generate() } } @@ -1288,7 +995,7 @@ pub struct Rls { } impl Step for Rls { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1306,24 +1013,11 @@ impl Step for Rls { }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - let src = builder.src.join("src/tools/rls"); - let release_num = builder.release_num("rls"); - let name = pkgname(builder, "rls"); - let version = builder.rls_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("rls-image"); - drop(fs::remove_dir_all(&image)); - t!(fs::create_dir_all(&image)); - - // Prepare the image directory - // We expect RLS to build, because we've exited this step above if tool - // state for RLS isn't testing. let rls = builder .ensure(tool::Rls { compiler, target, extra_features: Vec::new() }) .or_else(|| { @@ -1331,43 +1025,12 @@ impl Step for Rls { None })?; - builder.install(&rls, &image.join("bin"), 0o755); - let doc = image.join("share/doc/rls"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("rls-overlay"); - drop(fs::remove_dir_all(&overlay)); - t!(fs::create_dir_all(&overlay)); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=RLS-ready-to-serve.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=rls-preview"); - - builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target.triple)); - let _time = timeit(builder); - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + let mut tarball = Tarball::new(builder, "rls", &target.triple); + tarball.set_overlay(OverlayKind::RLS); + tarball.is_preview(true); + tarball.add_file(rls, "bin", 0o755); + tarball.add_legal_and_readme_to("share/doc/rls"); + Some(tarball.generate()) } } @@ -1378,7 +1041,7 @@ pub struct RustAnalyzer { } impl Step for RustAnalyzer { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1396,7 +1059,7 @@ impl Step for RustAnalyzer { }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); @@ -1407,60 +1070,16 @@ impl Step for RustAnalyzer { return None; } - let src = builder.src.join("src/tools/rust-analyzer"); - let release_num = builder.release_num("rust-analyzer/crates/rust-analyzer"); - let name = pkgname(builder, "rust-analyzer"); - let version = builder.rust_analyzer_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("rust-analyzer-image"); - drop(fs::remove_dir_all(&image)); - builder.create_dir(&image); - - // Prepare the image directory - // We expect rust-analyer to always build, as it doesn't depend on rustc internals - // and doesn't have associated toolstate. let rust_analyzer = builder .ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() }) .expect("rust-analyzer always builds"); - builder.install(&rust_analyzer, &image.join("bin"), 0o755); - let doc = image.join("share/doc/rust-analyzer"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("rust-analyzer-overlay"); - drop(fs::remove_dir_all(&overlay)); - t!(fs::create_dir_all(&overlay)); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=rust-analyzer-ready-to-serve.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=rust-analyzer-preview"); - - builder.info(&format!("Dist rust-analyzer stage{} ({})", compiler.stage, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple); + tarball.set_overlay(OverlayKind::RustAnalyzer); + tarball.is_preview(true); + tarball.add_file(rust_analyzer, "bin", 0o755); + tarball.add_legal_and_readme_to("share/doc/rust-analyzer"); + Some(tarball.generate()) } } @@ -1471,7 +1090,7 @@ pub struct Clippy { } impl Step for Clippy { - type Output = PathBuf; + type Output = GeneratedTarball; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1489,21 +1108,11 @@ impl Step for Clippy { }); } - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - let src = builder.src.join("src/tools/clippy"); - let release_num = builder.release_num("clippy"); - let name = pkgname(builder, "clippy"); - let version = builder.clippy_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("clippy-image"); - drop(fs::remove_dir_all(&image)); - builder.create_dir(&image); - // Prepare the image directory // We expect clippy to build, because we've exited this step above if tool // state for clippy isn't testing. @@ -1514,44 +1123,13 @@ impl Step for Clippy { .ensure(tool::CargoClippy { compiler, target, extra_features: Vec::new() }) .expect("clippy expected to build - essential tool"); - builder.install(&clippy, &image.join("bin"), 0o755); - builder.install(&cargoclippy, &image.join("bin"), 0o755); - let doc = image.join("share/doc/clippy"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("clippy-overlay"); - drop(fs::remove_dir_all(&overlay)); - t!(fs::create_dir_all(&overlay)); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=clippy-ready-to-serve.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=clippy-preview"); - - builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)) + let mut tarball = Tarball::new(builder, "clippy", &target.triple); + tarball.set_overlay(OverlayKind::Clippy); + tarball.is_preview(true); + tarball.add_file(clippy, "bin", 0o755); + tarball.add_file(cargoclippy, "bin", 0o755); + tarball.add_legal_and_readme_to("share/doc/clippy"); + tarball.generate() } } @@ -1562,7 +1140,7 @@ pub struct Miri { } impl Step for Miri { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1580,24 +1158,11 @@ impl Step for Miri { }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - let src = builder.src.join("src/tools/miri"); - let release_num = builder.release_num("miri"); - let name = pkgname(builder, "miri"); - let version = builder.miri_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("miri-image"); - drop(fs::remove_dir_all(&image)); - builder.create_dir(&image); - - // Prepare the image directory - // We expect miri to build, because we've exited this step above if tool - // state for miri isn't testing. let miri = builder .ensure(tool::Miri { compiler, target, extra_features: Vec::new() }) .or_else(|| { @@ -1611,44 +1176,13 @@ impl Step for Miri { None })?; - builder.install(&miri, &image.join("bin"), 0o755); - builder.install(&cargomiri, &image.join("bin"), 0o755); - let doc = image.join("share/doc/miri"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("miri-overlay"); - drop(fs::remove_dir_all(&overlay)); - t!(fs::create_dir_all(&overlay)); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=miri-ready-to-serve.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=miri-preview"); - - builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + let mut tarball = Tarball::new(builder, "miri", &target.triple); + tarball.set_overlay(OverlayKind::Miri); + tarball.is_preview(true); + tarball.add_file(miri, "bin", 0o755); + tarball.add_file(cargomiri, "bin", 0o755); + tarball.add_legal_and_readme_to("share/doc/miri"); + Some(tarball.generate()) } } @@ -1659,7 +1193,7 @@ pub struct Rustfmt { } impl Step for Rustfmt { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1677,21 +1211,10 @@ impl Step for Rustfmt { }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let compiler = self.compiler; let target = self.target; - let src = builder.src.join("src/tools/rustfmt"); - let release_num = builder.release_num("rustfmt"); - let name = pkgname(builder, "rustfmt"); - let version = builder.rustfmt_info.version(builder, &release_num); - - let tmp = tmpdir(builder); - let image = tmp.join("rustfmt-image"); - drop(fs::remove_dir_all(&image)); - builder.create_dir(&image); - - // Prepare the image directory let rustfmt = builder .ensure(tool::Rustfmt { compiler, target, extra_features: Vec::new() }) .or_else(|| { @@ -1705,44 +1228,13 @@ impl Step for Rustfmt { None })?; - builder.install(&rustfmt, &image.join("bin"), 0o755); - builder.install(&cargofmt, &image.join("bin"), 0o755); - let doc = image.join("share/doc/rustfmt"); - builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - - // Prepare the overlay - let overlay = tmp.join("rustfmt-overlay"); - drop(fs::remove_dir_all(&overlay)); - builder.create_dir(&overlay); - builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - builder.create(&overlay.join("version"), &version); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=rustfmt-ready-to-fmt.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=rustfmt-preview"); - - builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target)); - let _time = timeit(builder); - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + let mut tarball = Tarball::new(builder, "rustfmt", &target.triple); + tarball.set_overlay(OverlayKind::Rustfmt); + tarball.is_preview(true); + tarball.add_file(rustfmt, "bin", 0o755); + tarball.add_file(cargofmt, "bin", 0o755); + tarball.add_legal_and_readme_to("share/doc/rustfmt"); + Some(tarball.generate()) } } @@ -1791,24 +1283,14 @@ impl Step for Extended { let analysis_installer = builder.ensure(Analysis { compiler, target }); let docs_installer = builder.ensure(Docs { host: target }); - let std_installer = - builder.ensure(Std { compiler: builder.compiler(stage, target), target }); + let std_installer = builder.ensure(Std { compiler, target }); - let tmp = tmpdir(builder); - let overlay = tmp.join("extended-overlay"); let etc = builder.src.join("src/etc/installer"); - let work = tmp.join("work"); - - let _ = fs::remove_dir_all(&overlay); - builder.install(&builder.src.join("COPYRIGHT"), &overlay, 0o644); - builder.install(&builder.src.join("LICENSE-APACHE"), &overlay, 0o644); - builder.install(&builder.src.join("LICENSE-MIT"), &overlay, 0o644); - let version = builder.rust_version(); - builder.create(&overlay.join("version"), &version); - if let Some(sha) = builder.rust_sha() { - builder.create(&overlay.join("git-commit-hash"), &sha); + + // Avoid producing tarballs during a dry run. + if builder.config.dry_run { + return; } - builder.install(&etc.join("README.md"), &overlay, 0o644); // When rust-std package split from rustc, we needed to ensure that during // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering @@ -1823,55 +1305,38 @@ impl Step for Extended { tarballs.extend(miri_installer.clone()); tarballs.extend(rustfmt_installer.clone()); tarballs.extend(llvm_tools_installer); - tarballs.push(analysis_installer); - tarballs.push(std_installer); - if builder.config.docs { + if let Some(analysis_installer) = analysis_installer { + tarballs.push(analysis_installer); + } + tarballs.push(std_installer.expect("missing std")); + if let Some(docs_installer) = docs_installer { tarballs.push(docs_installer); } if target.contains("pc-windows-gnu") { tarballs.push(mingw_installer.unwrap()); } - let mut input_tarballs = tarballs[0].as_os_str().to_owned(); - for tarball in &tarballs[1..] { - input_tarballs.push(","); - input_tarballs.push(tarball); - } - builder.info("building combined installer"); - let mut cmd = rust_installer(builder); - cmd.arg("combine") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-is-ready-to-roll.") - .arg("--work-dir") - .arg(&work) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", pkgname(builder, "rust"), target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--input-tarballs") - .arg(input_tarballs) - .arg("--non-installed-overlay") - .arg(&overlay); - let time = timeit(&builder); - builder.run(&mut cmd); - drop(time); + let tarball = Tarball::new(builder, "rust", &target.triple); + let generated = tarball.combine(&tarballs); + + let tmp = tmpdir(builder).join("combined-tarball"); + let work = generated.work_dir(); let mut license = String::new(); license += &builder.read(&builder.src.join("COPYRIGHT")); license += &builder.read(&builder.src.join("LICENSE-APACHE")); license += &builder.read(&builder.src.join("LICENSE-MIT")); - license.push_str("\n"); - license.push_str("\n"); + license.push('\n'); + license.push('\n'); let rtf = r"{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}\nowwrap\fs18"; let mut rtf = rtf.to_string(); - rtf.push_str("\n"); + rtf.push('\n'); for line in license.lines() { rtf.push_str(line); rtf.push_str("\\line "); } - rtf.push_str("}"); + rtf.push('}'); fn filter(contents: &str, marker: &str) -> String { let start = format!("tool-{}-start", marker); @@ -2405,7 +1870,7 @@ pub struct LlvmTools { } impl Step for LlvmTools { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -2416,7 +1881,7 @@ impl Step for LlvmTools { run.builder.ensure(LlvmTools { target: run.target }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let target = self.target; assert!(builder.config.extended); @@ -2428,58 +1893,25 @@ impl Step for LlvmTools { } } - builder.info(&format!("Dist LlvmTools ({})", target)); - let _time = timeit(builder); - let src = builder.src.join("src/llvm-project/llvm"); - let name = pkgname(builder, "llvm-tools"); - - let tmp = tmpdir(builder); - let image = tmp.join("llvm-tools-image"); - drop(fs::remove_dir_all(&image)); + let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple); + tarball.set_overlay(OverlayKind::LLVM); + tarball.is_preview(true); // Prepare the image directory let src_bindir = builder.llvm_out(target).join("bin"); - let dst_bindir = image.join("lib/rustlib").join(&*target.triple).join("bin"); - t!(fs::create_dir_all(&dst_bindir)); + let dst_bindir = format!("lib/rustlib/{}/bin", target.triple); for tool in LLVM_TOOLS { let exe = src_bindir.join(exe(tool, target)); - builder.install(&exe, &dst_bindir, 0o755); + tarball.add_file(&exe, &dst_bindir, 0o755); } // Copy libLLVM.so to the target lib dir as well, so the RPATH like // `$ORIGIN/../lib` can find it. It may also be used as a dependency // of `rustc-dev` to support the inherited `-lLLVM` when using the // compiler libraries. - maybe_install_llvm_target(builder, target, &image); - - // Prepare the overlay - let overlay = tmp.join("llvm-tools-overlay"); - drop(fs::remove_dir_all(&overlay)); - builder.create_dir(&overlay); - builder.install(&src.join("README.txt"), &overlay, 0o644); - builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644); - builder.create(&overlay.join("version"), &builder.llvm_tools_vers()); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=llvm-tools-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=llvm-tools-preview"); - - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + maybe_install_llvm_target(builder, target, tarball.image_dir()); + + Some(tarball.generate()) } } @@ -2492,7 +1924,7 @@ pub struct RustDev { } impl Step for RustDev { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -2504,7 +1936,7 @@ impl Step for RustDev { run.builder.ensure(RustDev { target: run.target }); } - fn run(self, builder: &Builder<'_>) -> Option<PathBuf> { + fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let target = self.target; /* run only if llvm-config isn't used */ @@ -2515,70 +1947,35 @@ impl Step for RustDev { } } - builder.info(&format!("Dist RustDev ({})", target)); - let _time = timeit(builder); - let src = builder.src.join("src/llvm-project/llvm"); - let name = pkgname(builder, "rust-dev"); - - let tmp = tmpdir(builder); - let image = tmp.join("rust-dev-image"); - drop(fs::remove_dir_all(&image)); - - // Prepare the image directory - let dst_bindir = image.join("bin"); - t!(fs::create_dir_all(&dst_bindir)); + let mut tarball = Tarball::new(builder, "rust-dev", &target.triple); + tarball.set_overlay(OverlayKind::LLVM); let src_bindir = builder.llvm_out(target).join("bin"); - let install_bin = - |name| builder.install(&src_bindir.join(exe(name, target)), &dst_bindir, 0o755); - install_bin("llvm-config"); - install_bin("llvm-ar"); - install_bin("llvm-objdump"); - install_bin("llvm-profdata"); - install_bin("llvm-bcanalyzer"); - install_bin("llvm-cov"); - install_bin("llvm-dwp"); - builder.install(&builder.llvm_filecheck(target), &dst_bindir, 0o755); + for bin in &[ + "llvm-config", + "llvm-ar", + "llvm-objdump", + "llvm-profdata", + "llvm-bcanalyzer", + "llvm-cov", + "llvm-dwp", + ] { + tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755); + } + tarball.add_file(&builder.llvm_filecheck(target), "bin", 0o755); // Copy the include directory as well; needed mostly to build // librustc_llvm properly (e.g., llvm-config.h is in here). But also // just broadly useful to be able to link against the bundled LLVM. - builder.cp_r(&builder.llvm_out(target).join("include"), &image.join("include")); + tarball.add_dir(&builder.llvm_out(target).join("include"), "include"); // Copy libLLVM.so to the target lib dir as well, so the RPATH like // `$ORIGIN/../lib` can find it. It may also be used as a dependency // of `rustc-dev` to support the inherited `-lLLVM` when using the // compiler libraries. - maybe_install_llvm(builder, target, &image.join("lib")); - - // Prepare the overlay - let overlay = tmp.join("rust-dev-overlay"); - drop(fs::remove_dir_all(&overlay)); - builder.create_dir(&overlay); - builder.install(&src.join("README.txt"), &overlay, 0o644); - builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644); - builder.create(&overlay.join("version"), &builder.rust_version()); - - // Generate the installer tarball - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=rust-dev-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=rust-dev"); - - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))) + maybe_install_llvm(builder, target, &tarball.image_dir().join("lib")); + + Some(tarball.generate()) } } @@ -2592,7 +1989,7 @@ pub struct BuildManifest { } impl Step for BuildManifest { - type Output = PathBuf; + type Output = GeneratedTarball; const DEFAULT: bool = false; const ONLY_HOSTS: bool = true; @@ -2604,48 +2001,12 @@ impl Step for BuildManifest { run.builder.ensure(BuildManifest { target: run.target }); } - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let build_manifest = builder.tool_exe(Tool::BuildManifest); - let name = pkgname(builder, "build-manifest"); - let tmp = tmpdir(builder); - - // Prepare the image. - let image = tmp.join("build-manifest-image"); - let image_bin = image.join("bin"); - let _ = fs::remove_dir_all(&image); - t!(fs::create_dir_all(&image_bin)); - builder.install(&build_manifest, &image_bin, 0o755); - - // Prepare the overlay. - let overlay = tmp.join("build-manifest-overlay"); - let _ = fs::remove_dir_all(&overlay); - builder.create_dir(&overlay); - builder.create(&overlay.join("version"), &builder.rust_version()); - for file in &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"] { - builder.install(&builder.src.join(file), &overlay, 0o644); - } - - // Create the final tarball. - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=build-manifest installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, self.target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=build-manifest"); - - builder.run(&mut cmd); - distdir(builder).join(format!("{}-{}.tar.gz", name, self.target.triple)) + let tarball = Tarball::new(builder, "build-manifest", &self.target.triple); + tarball.add_file(&build_manifest, "bin", 0o755); + tarball.generate() } } @@ -2660,7 +2021,7 @@ pub struct ReproducibleArtifacts { } impl Step for ReproducibleArtifacts { - type Output = Option<PathBuf>; + type Output = Option<GeneratedTarball>; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; @@ -2673,47 +2034,10 @@ impl Step for ReproducibleArtifacts { } fn run(self, builder: &Builder<'_>) -> Self::Output { - let name = pkgname(builder, "reproducible-artifacts"); - let tmp = tmpdir(builder); - - // Prepare the image. - let image = tmp.join("reproducible-artifacts-image"); - let _ = fs::remove_dir_all(&image); - - if let Some(path) = &builder.config.rust_profile_use { - builder.install(std::path::Path::new(path), &image, 0o644); - } else { - return None; - } - - // Prepare the overlay. - let overlay = tmp.join("reproducible-artifacts-overlay"); - let _ = fs::remove_dir_all(&overlay); - builder.create_dir(&overlay); - builder.create(&overlay.join("version"), &builder.rust_version()); - for file in &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"] { - builder.install(&builder.src.join(file), &overlay, 0o644); - } + let path = builder.config.rust_profile_use.as_ref()?; - // Create the final tarball. - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=reproducible-artifacts installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg("--non-installed-overlay") - .arg(&overlay) - .arg(format!("--package-name={}-{}", name, self.target.triple)) - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=reproducible-artifacts"); - - builder.run(&mut cmd); - Some(distdir(builder).join(format!("{}-{}.tar.gz", name, self.target.triple))) + let tarball = Tarball::new(builder, "reproducible-artifacts", &self.target.triple); + tarball.add_file(path, ".", 0o644); + Some(tarball.generate()) } } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 8cacc2512ef..8c849846676 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -500,18 +500,17 @@ impl Step for Rustc { let target = self.target; builder.info(&format!("Documenting stage{} compiler ({})", stage, target)); - // This is the intended out directory for compiler documentation. - let out = builder.compiler_doc_out(target); - t!(fs::create_dir_all(&out)); - - let compiler = builder.compiler(stage, builder.config.build); - if !builder.config.compiler_docs { builder.info("\tskipping - compiler/librustdoc docs disabled"); return; } + // This is the intended out directory for compiler documentation. + let out = builder.compiler_doc_out(target); + t!(fs::create_dir_all(&out)); + // Build rustc. + let compiler = builder.compiler(stage, builder.config.build); builder.ensure(compile::Rustc { compiler, target }); // This uses a shared directory so that librustdoc documentation gets @@ -521,16 +520,17 @@ impl Step for Rustc { // merging the search index, or generating local (relative) links. let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target.triple).join("doc"); t!(symlink_dir_force(&builder.config, &out, &out_dir)); + // Cargo puts proc macros in `target/doc` even if you pass `--target` + // explicitly (https://github.com/rust-lang/cargo/issues/7677). + let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc"); + t!(symlink_dir_force(&builder.config, &out, &proc_macro_out_dir)); // Build cargo command. let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc"); cargo.rustdocflag("--document-private-items"); cargo.rustdocflag("--enable-index-page"); cargo.rustdocflag("-Zunstable-options"); - // cfg(not(bootstrap)), can be removed on the next beta bump - if stage != 0 { - cargo.rustdocflag("-Znormalize-docs"); - } + cargo.rustdocflag("-Znormalize-docs"); compile::rustc_cargo(builder, &mut cargo, target); // Only include compiler crates, no dependencies of those, such as `libc`. @@ -628,6 +628,8 @@ impl Step for Rustdoc { cargo.arg("-p").arg("rustdoc"); cargo.rustdocflag("--document-private-items"); + cargo.rustdocflag("--enable-index-page"); + cargo.rustdocflag("-Zunstable-options"); builder.run(&mut cargo.into()); } } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 8f2b128b368..96164947943 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -10,60 +10,19 @@ use std::process::Command; use build_helper::t; -use crate::dist::{self, pkgname, sanitize_sh, tmpdir}; +use crate::dist::{self, sanitize_sh}; +use crate::tarball::GeneratedTarball; use crate::Compiler; use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::config::{Config, TargetSelection}; -pub fn install_docs(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "docs", "rust-docs", stage, Some(host)); -} - -pub fn install_std(builder: &Builder<'_>, stage: u32, target: TargetSelection) { - install_sh(builder, "std", "rust-std", stage, Some(target)); -} - -pub fn install_cargo(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "cargo", "cargo", stage, Some(host)); -} - -pub fn install_rls(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "rls", "rls", stage, Some(host)); -} - -pub fn install_rust_analyzer(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "rust-analyzer", "rust-analyzer", stage, Some(host)); -} - -pub fn install_clippy(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "clippy", "clippy", stage, Some(host)); -} -pub fn install_miri(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "miri", "miri", stage, Some(host)); -} - -pub fn install_rustfmt(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "rustfmt", "rustfmt", stage, Some(host)); -} - -pub fn install_analysis(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "analysis", "rust-analysis", stage, Some(host)); -} - -pub fn install_src(builder: &Builder<'_>, stage: u32) { - install_sh(builder, "src", "rust-src", stage, None); -} -pub fn install_rustc(builder: &Builder<'_>, stage: u32, host: TargetSelection) { - install_sh(builder, "rustc", "rustc", stage, Some(host)); -} - fn install_sh( builder: &Builder<'_>, package: &str, - name: &str, stage: u32, host: Option<TargetSelection>, + tarball: &GeneratedTarball, ) { builder.info(&format!("Install {} stage{} ({:?})", package, stage, host)); @@ -108,15 +67,10 @@ fn install_sh( let empty_dir = builder.out.join("tmp/empty_dir"); t!(fs::create_dir_all(&empty_dir)); - let package_name = if let Some(host) = host { - format!("{}-{}", pkgname(builder, name), host.triple) - } else { - pkgname(builder, name) - }; let mut cmd = Command::new("sh"); cmd.current_dir(&empty_dir) - .arg(sanitize_sh(&tmpdir(builder).join(&package_name).join("install.sh"))) + .arg(sanitize_sh(&tarball.decompressed_output().join("install.sh"))) .arg(format!("--prefix={}", sanitize_sh(&prefix))) .arg(format!("--sysconfdir={}", sanitize_sh(&sysconfdir))) .arg(format!("--datadir={}", sanitize_sh(&datadir))) @@ -191,25 +145,25 @@ macro_rules! install { install!((self, builder, _config), Docs, "src/doc", _config.docs, only_hosts: false, { - builder.ensure(dist::Docs { host: self.target }); - install_docs(builder, self.compiler.stage, self.target); + let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs"); + install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball); }; Std, "library/std", true, only_hosts: false, { for target in &builder.targets { - builder.ensure(dist::Std { + let tarball = builder.ensure(dist::Std { compiler: self.compiler, target: *target - }); - install_std(builder, self.compiler.stage, *target); + }).expect("missing std"); + install_sh(builder, "std", self.compiler.stage, Some(*target), &tarball); } }; Cargo, "cargo", Self::should_build(_config), only_hosts: true, { - builder.ensure(dist::Cargo { compiler: self.compiler, target: self.target }); - install_cargo(builder, self.compiler.stage, self.target); + let tarball = builder.ensure(dist::Cargo { compiler: self.compiler, target: self.target }); + install_sh(builder, "cargo", self.compiler.stage, Some(self.target), &tarball); }; Rls, "rls", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }).is_some() { - install_rls(builder, self.compiler.stage, self.target); + if let Some(tarball) = builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }) { + install_sh(builder, "rls", self.compiler.stage, Some(self.target), &tarball); } else { builder.info( &format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target), @@ -217,16 +171,18 @@ install!((self, builder, _config), } }; RustAnalyzer, "rust-analyzer", Self::should_build(_config), only_hosts: true, { - builder.ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target }); - install_rust_analyzer(builder, self.compiler.stage, self.target); + let tarball = builder + .ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target }) + .expect("missing rust-analyzer"); + install_sh(builder, "rust-analyzer", self.compiler.stage, Some(self.target), &tarball); }; Clippy, "clippy", Self::should_build(_config), only_hosts: true, { - builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target }); - install_clippy(builder, self.compiler.stage, self.target); + let tarball = builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target }); + install_sh(builder, "clippy", self.compiler.stage, Some(self.target), &tarball); }; Miri, "miri", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }).is_some() { - install_miri(builder, self.compiler.stage, self.target); + if let Some(tarball) = builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }) { + install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball); } else { builder.info( &format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target), @@ -234,11 +190,11 @@ install!((self, builder, _config), } }; Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rustfmt { + if let Some(tarball) = builder.ensure(dist::Rustfmt { compiler: self.compiler, target: self.target - }).is_some() { - install_rustfmt(builder, self.compiler.stage, self.target); + }) { + install_sh(builder, "rustfmt", self.compiler.stage, Some(self.target), &tarball); } else { builder.info( &format!("skipping Install Rustfmt stage{} ({})", self.compiler.stage, self.target), @@ -246,20 +202,20 @@ install!((self, builder, _config), } }; Analysis, "analysis", Self::should_build(_config), only_hosts: false, { - builder.ensure(dist::Analysis { + let tarball = builder.ensure(dist::Analysis { // Find the actual compiler (handling the full bootstrap option) which // produced the save-analysis data because that data isn't copied // through the sysroot uplifting. compiler: builder.compiler_for(builder.top_stage, builder.config.build, self.target), target: self.target - }); - install_analysis(builder, self.compiler.stage, self.target); + }).expect("missing analysis"); + install_sh(builder, "analysis", self.compiler.stage, Some(self.target), &tarball); }; Rustc, "src/librustc", true, only_hosts: true, { - builder.ensure(dist::Rustc { + let tarball = builder.ensure(dist::Rustc { compiler: builder.compiler(builder.top_stage, self.target), }); - install_rustc(builder, self.compiler.stage, self.target); + install_sh(builder, "rustc", self.compiler.stage, Some(self.target), &tarball); }; ); @@ -284,7 +240,7 @@ impl Step for Src { } fn run(self, builder: &Builder<'_>) { - builder.ensure(dist::Src); - install_src(builder, self.stage); + let tarball = builder.ensure(dist::Src); + install_sh(builder, "src", self.stage, None, &tarball); } } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index ece9bdc7a64..88fdcfa2d43 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -142,6 +142,7 @@ mod native; mod run; mod sanity; mod setup; +mod tarball; mod test; mod tool; mod toolstate; @@ -1068,10 +1069,6 @@ impl Build { self.package_vers(&self.version) } - fn llvm_tools_vers(&self) -> String { - self.rust_version() - } - fn llvm_link_tools_dynamically(&self, target: TargetSelection) -> bool { target.contains("linux-gnu") || target.contains("apple-darwin") } @@ -1086,7 +1083,7 @@ impl Build { if let Some(ref s) = self.config.description { version.push_str(" ("); version.push_str(s); - version.push_str(")"); + version.push(')'); } version } @@ -1147,7 +1144,7 @@ impl Build { && (dep != "profiler_builtins" || target .map(|t| self.config.profiler_enabled(t)) - .unwrap_or(self.config.any_profiler_enabled())) + .unwrap_or_else(|| self.config.any_profiler_enabled())) && (dep != "rustc_codegen_llvm" || self.config.llvm_enabled()) { list.push(*dep); diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 1564cfb0619..fd39944e176 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -66,7 +66,6 @@ check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu: TESTS_IN_2 := \ src/test/ui \ - src/test/compile-fail \ src/tools/linkchecker ci-subset-1: @@ -75,8 +74,7 @@ ci-subset-2: $(Q)$(BOOTSTRAP) test --stage 2 $(TESTS_IN_2) TESTS_IN_MINGW_2 := \ - src/test/ui \ - src/test/compile-fail + src/test/ui ci-mingw-subset-1: $(Q)$(BOOTSTRAP) test --stage 2 $(TESTS_IN_MINGW_2:%=--exclude %) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index d716b23af60..6412df3fd90 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -802,6 +802,7 @@ fn supported_sanitizers( }; match &*target.triple { + "aarch64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]), "aarch64-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]), "aarch64-unknown-linux-gnu" => { common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan"]) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index acb941d9540..08acc3d671f 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -163,7 +163,11 @@ pub fn check(build: &mut Build) { panic!("the iOS target is only supported on macOS"); } - build.config.target_config.entry(*target).or_insert(Target::from_triple(&target.triple)); + build + .config + .target_config + .entry(*target) + .or_insert_with(|| Target::from_triple(&target.triple)); if target.contains("-none-") || target.contains("nvptx") { if build.no_std(*target) == Some(false) { diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index 2d4484c562c..725147767db 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -89,7 +89,7 @@ pub fn setup(src_path: &Path, profile: Profile) { std::process::exit(1); } - let path = cfg_file.unwrap_or("config.toml".into()); + let path = cfg_file.unwrap_or_else(|| "config.toml".into()); let settings = format!( "# Includes one of the default files in src/bootstrap/defaults\n\ profile = \"{}\"\n\ @@ -156,7 +156,7 @@ pub fn interactive_path() -> io::Result<Profile> { io::stdout().flush()?; let mut input = String::new(); io::stdin().read_line(&mut input)?; - if input == "" { + if input.is_empty() { eprintln!("EOF on stdin, when expecting answer to question. Giving up."); std::process::exit(1); } diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs new file mode 100644 index 00000000000..7fb03056f1b --- /dev/null +++ b/src/bootstrap/tarball.rs @@ -0,0 +1,333 @@ +use std::{ + path::{Path, PathBuf}, + process::Command, +}; + +use build_helper::t; + +use crate::builder::Builder; + +#[derive(Copy, Clone)] +pub(crate) enum OverlayKind { + Rust, + LLVM, + Cargo, + Clippy, + Miri, + Rustfmt, + RLS, + RustAnalyzer, +} + +impl OverlayKind { + fn legal_and_readme(&self) -> &[&str] { + match self { + OverlayKind::Rust => &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"], + OverlayKind::LLVM => { + &["src/llvm-project/llvm/LICENSE.TXT", "src/llvm-project/llvm/README.txt"] + } + OverlayKind::Cargo => &[ + "src/tools/cargo/README.md", + "src/tools/cargo/LICENSE-MIT", + "src/tools/cargo/LICENSE-APACHE", + "src/tools/cargo/LICENSE-THIRD-PARTY", + ], + OverlayKind::Clippy => &[ + "src/tools/clippy/README.md", + "src/tools/clippy/LICENSE-APACHE", + "src/tools/clippy/LICENSE-MIT", + ], + OverlayKind::Miri => &[ + "src/tools/miri/README.md", + "src/tools/miri/LICENSE-APACHE", + "src/tools/miri/LICENSE-MIT", + ], + OverlayKind::Rustfmt => &[ + "src/tools/rustfmt/README.md", + "src/tools/rustfmt/LICENSE-APACHE", + "src/tools/rustfmt/LICENSE-MIT", + ], + OverlayKind::RLS => &[ + "src/tools/rls/README.md", + "src/tools/rls/LICENSE-APACHE", + "src/tools/rls/LICENSE-MIT", + ], + OverlayKind::RustAnalyzer => &[ + "src/tools/rust-analyzer/README.md", + "src/tools/rust-analyzer/LICENSE-APACHE", + "src/tools/rust-analyzer/LICENSE-MIT", + ], + } + } + + fn version(&self, builder: &Builder<'_>) -> String { + match self { + OverlayKind::Rust => builder.rust_version(), + OverlayKind::LLVM => builder.rust_version(), + OverlayKind::Cargo => { + builder.cargo_info.version(builder, &builder.release_num("cargo")) + } + OverlayKind::Clippy => { + builder.clippy_info.version(builder, &builder.release_num("clippy")) + } + OverlayKind::Miri => builder.miri_info.version(builder, &builder.release_num("miri")), + OverlayKind::Rustfmt => { + builder.rustfmt_info.version(builder, &builder.release_num("rustfmt")) + } + OverlayKind::RLS => builder.rls_info.version(builder, &builder.release_num("rls")), + OverlayKind::RustAnalyzer => builder + .rust_analyzer_info + .version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")), + } + } +} + +pub(crate) struct Tarball<'a> { + builder: &'a Builder<'a>, + + pkgname: String, + component: String, + target: Option<String>, + product_name: String, + overlay: OverlayKind, + + temp_dir: PathBuf, + image_dir: PathBuf, + overlay_dir: PathBuf, + + include_target_in_component_name: bool, + is_preview: bool, +} + +impl<'a> Tarball<'a> { + pub(crate) fn new(builder: &'a Builder<'a>, component: &str, target: &str) -> Self { + Self::new_inner(builder, component, Some(target.into())) + } + + pub(crate) fn new_targetless(builder: &'a Builder<'a>, component: &str) -> Self { + Self::new_inner(builder, component, None) + } + + fn new_inner(builder: &'a Builder<'a>, component: &str, target: Option<String>) -> Self { + let pkgname = crate::dist::pkgname(builder, component); + + let mut temp_dir = builder.out.join("tmp").join("tarball").join(component); + if let Some(target) = &target { + temp_dir = temp_dir.join(target); + } + let _ = std::fs::remove_dir_all(&temp_dir); + + let image_dir = temp_dir.join("image"); + let overlay_dir = temp_dir.join("overlay"); + + Self { + builder, + + pkgname, + component: component.into(), + target, + product_name: "Rust".into(), + overlay: OverlayKind::Rust, + + temp_dir, + image_dir, + overlay_dir, + + include_target_in_component_name: false, + is_preview: false, + } + } + + pub(crate) fn set_overlay(&mut self, overlay: OverlayKind) { + self.overlay = overlay; + } + + pub(crate) fn set_product_name(&mut self, name: &str) { + self.product_name = name.into(); + } + + pub(crate) fn include_target_in_component_name(&mut self, include: bool) { + self.include_target_in_component_name = include; + } + + pub(crate) fn is_preview(&mut self, is: bool) { + self.is_preview = is; + } + + pub(crate) fn image_dir(&self) -> &Path { + t!(std::fs::create_dir_all(&self.image_dir)); + &self.image_dir + } + + pub(crate) fn add_file(&self, src: impl AsRef<Path>, destdir: impl AsRef<Path>, perms: u32) { + // create_dir_all fails to create `foo/bar/.`, so when the destination is "." this simply + // uses the base directory as the destination directory. + let destdir = if destdir.as_ref() == Path::new(".") { + self.image_dir.clone() + } else { + self.image_dir.join(destdir.as_ref()) + }; + + t!(std::fs::create_dir_all(&destdir)); + self.builder.install(src.as_ref(), &destdir, perms); + } + + pub(crate) fn add_renamed_file( + &self, + src: impl AsRef<Path>, + destdir: impl AsRef<Path>, + new_name: &str, + ) { + let destdir = self.image_dir.join(destdir.as_ref()); + t!(std::fs::create_dir_all(&destdir)); + self.builder.copy(src.as_ref(), &destdir.join(new_name)); + } + + pub(crate) fn add_legal_and_readme_to(&self, destdir: impl AsRef<Path>) { + for file in self.overlay.legal_and_readme() { + self.add_file(self.builder.src.join(file), destdir.as_ref(), 0o644); + } + } + + pub(crate) fn add_dir(&self, src: impl AsRef<Path>, dest: impl AsRef<Path>) { + let dest = self.image_dir.join(dest.as_ref()); + + t!(std::fs::create_dir_all(&dest)); + self.builder.cp_r(src.as_ref(), &dest); + } + + pub(crate) fn generate(self) -> GeneratedTarball { + let mut component_name = self.component.clone(); + if self.is_preview { + component_name.push_str("-preview"); + } + if self.include_target_in_component_name { + component_name.push('-'); + component_name.push_str( + &self + .target + .as_ref() + .expect("include_target_in_component_name used in a targetless tarball"), + ); + } + + self.run(|this, cmd| { + cmd.arg("generate") + .arg("--image-dir") + .arg(&this.image_dir) + .arg(format!("--component-name={}", &component_name)); + this.non_bare_args(cmd); + }) + } + + pub(crate) fn combine(self, tarballs: &[GeneratedTarball]) -> GeneratedTarball { + let mut input_tarballs = tarballs[0].path.as_os_str().to_os_string(); + for tarball in &tarballs[1..] { + input_tarballs.push(","); + input_tarballs.push(&tarball.path); + } + + self.run(|this, cmd| { + cmd.arg("combine").arg("--input-tarballs").arg(input_tarballs); + this.non_bare_args(cmd); + }) + } + + pub(crate) fn bare(self) -> GeneratedTarball { + // Bare tarballs should have the top level directory match the package + // name, not "image". We rename the image directory just before passing + // into rust-installer. + let dest = self.temp_dir.join(self.package_name()); + t!(std::fs::rename(&self.image_dir, &dest)); + + self.run(|this, cmd| { + cmd.arg("tarball") + .arg("--input") + .arg(&dest) + .arg("--output") + .arg(crate::dist::distdir(this.builder).join(this.package_name())); + }) + } + + fn package_name(&self) -> String { + if let Some(target) = &self.target { + format!("{}-{}", self.pkgname, target) + } else { + self.pkgname.clone() + } + } + + fn non_bare_args(&self, cmd: &mut Command) { + cmd.arg("--rel-manifest-dir=rustlib") + .arg("--legacy-manifest-dirs=rustlib,cargo") + .arg(format!("--product-name={}", self.product_name)) + .arg(format!("--success-message={} installed.", self.component)) + .arg(format!("--package-name={}", self.package_name())) + .arg("--non-installed-overlay") + .arg(&self.overlay_dir) + .arg("--output-dir") + .arg(crate::dist::distdir(self.builder)); + } + + fn run(self, build_cli: impl FnOnce(&Tarball<'a>, &mut Command)) -> GeneratedTarball { + t!(std::fs::create_dir_all(&self.overlay_dir)); + self.builder.create(&self.overlay_dir.join("version"), &self.overlay.version(self.builder)); + if let Some(sha) = self.builder.rust_sha() { + self.builder.create(&self.overlay_dir.join("git-commit-hash"), &sha); + } + for file in self.overlay.legal_and_readme() { + self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644); + } + + let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller); + + let package_name = self.package_name(); + self.builder.info(&format!("Dist {}", package_name)); + let _time = crate::util::timeit(self.builder); + + build_cli(&self, &mut cmd); + cmd.arg("--work-dir").arg(&self.temp_dir); + if let Some(formats) = &self.builder.config.dist_compression_formats { + assert!(!formats.is_empty(), "dist.compression-formats can't be empty"); + cmd.arg("--compression-formats").arg(formats.join(",")); + } + self.builder.run(&mut cmd); + + // Use either the first compression format defined, or "gz" as the default. + let ext = self + .builder + .config + .dist_compression_formats + .as_ref() + .and_then(|formats| formats.get(0)) + .map(|s| s.as_str()) + .unwrap_or("gz"); + + GeneratedTarball { + path: crate::dist::distdir(self.builder).join(format!("{}.tar.{}", package_name, ext)), + decompressed_output: self.temp_dir.join(package_name), + work: self.temp_dir, + } + } +} + +#[derive(Debug, Clone)] +pub struct GeneratedTarball { + path: PathBuf, + decompressed_output: PathBuf, + work: PathBuf, +} + +impl GeneratedTarball { + pub(crate) fn tarball(&self) -> &Path { + &self.path + } + + pub(crate) fn decompressed_output(&self) -> &Path { + &self.decompressed_output + } + + pub(crate) fn work_dir(&self) -> &Path { + &self.work + } +} diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index b99692e8ba5..2e8c574044e 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -869,12 +869,6 @@ default_test_with_compare_mode!(Ui { compare_mode: "nll" }); -default_test!(CompileFail { - path: "src/test/compile-fail", - mode: "compile-fail", - suite: "compile-fail" -}); - default_test!(RunPassValgrind { path: "src/test/run-pass-valgrind", mode: "run-pass-valgrind", @@ -1132,7 +1126,19 @@ note: if you're sure you want to do this, please open an issue as to why. In the Ok(path) => path, Err(_) => p, }) - .filter(|p| p.starts_with(suite_path) && (p.is_dir() || p.is_file())) + .filter(|p| p.starts_with(suite_path)) + .filter(|p| { + let exists = p.is_dir() || p.is_file(); + if !exists { + if let Some(p) = p.to_str() { + builder.info(&format!( + "Warning: Skipping \"{}\": not a regular file or directory", + p + )); + } + } + exists + }) .filter_map(|p| { // Since test suite paths are themselves directories, if we don't // specify a directory or file, we'll get an empty string here @@ -1141,7 +1147,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the // flag is respected, so providing an empty --test-args conflicts with // any following it. match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) { - Some(s) if s != "" => Some(s), + Some(s) if !s.is_empty() => Some(s), _ => None, } }) @@ -1968,8 +1974,8 @@ impl Step for Distcheck { builder.ensure(dist::Src); let mut cmd = Command::new("tar"); - cmd.arg("-xzf") - .arg(builder.ensure(dist::PlainSourceTarball)) + cmd.arg("-xf") + .arg(builder.ensure(dist::PlainSourceTarball).tarball()) .arg("--strip-components=1") .current_dir(&dir); builder.run(&mut cmd); @@ -1992,8 +1998,8 @@ impl Step for Distcheck { t!(fs::create_dir_all(&dir)); let mut cmd = Command::new("tar"); - cmd.arg("-xzf") - .arg(builder.ensure(dist::Src)) + cmd.arg("-xf") + .arg(builder.ensure(dist::Src).tarball()) .arg("--strip-components=1") .current_dir(&dir); builder.run(&mut cmd); diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 8653aecc12c..147de5f8015 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -44,7 +44,6 @@ ENV WASM_TARGETS=wasm32-unknown-unknown ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \ src/test/run-make \ src/test/ui \ - src/test/compile-fail \ src/test/mir-opt \ src/test/codegen-units \ library/core diff --git a/src/ci/run.sh b/src/ci/run.sh index 181a7fcb732..1958b6ee41d 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -53,6 +53,11 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1" +# Only produce xz tarballs on CI. gz tarballs will be generated by the release +# process by recompressing the existing xz ones. This decreases the storage +# space required for CI artifacts. +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz" + if [ "$DIST_SRC" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src" fi diff --git a/src/doc/rustc/book.toml b/src/doc/rustc/book.toml index 8adc05c5137..21d127c39c9 100644 --- a/src/doc/rustc/book.toml +++ b/src/doc/rustc/book.toml @@ -3,3 +3,6 @@ authors = ["The Rust Project Developers"] multilingual = false src = "src" title = "The rustc book" + +[output.html] +git-repository-url = "https://github.com/rust-lang/rust/tree/master/src/doc/rustc" diff --git a/src/doc/rustdoc/book.toml b/src/doc/rustdoc/book.toml index ba30c107667..c2e7ff58906 100644 --- a/src/doc/rustdoc/book.toml +++ b/src/doc/rustdoc/book.toml @@ -2,3 +2,6 @@ authors = ["The Rust Project Developers"] src = "src" title = "The rustdoc book" + +[output.html] +git-repository-url = "https://github.com/rust-lang/rust/tree/master/src/doc/rustdoc" diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 31e002810ce..80f7851debf 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -237,6 +237,26 @@ for a target triple that's different than your host triple. All of the usual caveats of cross-compiling code apply. +## `--default-theme`: set the default theme + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs --default-theme=ayu +``` + +Sets the default theme (for users whose browser has not remembered a +previous theme selection from the on-page theme picker). + +The supplied value should be the lowercase version of the theme name. +The set of available themes can be seen in the theme picker in the +generated output. + +Note that the set of available themes - and their appearance - is not +necessarily stable from one rustdoc version to the next. If the +requested theme does not exist, the builtin default (currently +`light`) is used instead. + ## `--markdown-css`: include more CSS files when rendering markdown Using this flag looks like this: diff --git a/src/doc/rustdoc/src/what-is-rustdoc.md b/src/doc/rustdoc/src/what-is-rustdoc.md index 1f6dced180b..32dc1e02bb3 100644 --- a/src/doc/rustdoc/src/what-is-rustdoc.md +++ b/src/doc/rustdoc/src/what-is-rustdoc.md @@ -10,7 +10,7 @@ CSS, and JavaScript. Let's give it a try! Create a new project with Cargo: ```bash -$ cargo new docs +$ cargo new docs --lib $ cd docs ``` diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md index 93908e9190e..d03d5c75014 100644 --- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md +++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md @@ -31,7 +31,12 @@ with runtime flag `ASAN_OPTIONS=detect_leaks=1` on macOS. AddressSanitizer is supported on the following targets: +* `aarch64-apple-darwin` +* `aarch64-fuchsia` +* `aarch64-unknown-linux-gnu` * `x86_64-apple-darwin` +* `x86_64-fuchsia` +* `x86_64-unknown-freebsd` * `x86_64-unknown-linux-gnu` AddressSanitizer works with non-instrumented code although it will impede its @@ -169,10 +174,26 @@ Shadow byte legend (one shadow byte represents 8 application bytes): ==39249==ABORTING ``` +# LeakSanitizer + +LeakSanitizer is run-time memory leak detector. + +LeakSanitizer is supported on the following targets: + +* `aarch64-apple-darwin` +* `aarch64-unknown-linux-gnu` +* `x86_64-apple-darwin` +* `x86_64-unknown-linux-gnu` + # MemorySanitizer -MemorySanitizer is detector of uninitialized reads. It is only supported on the -`x86_64-unknown-linux-gnu` target. +MemorySanitizer is detector of uninitialized reads. + +MemorySanitizer is supported on the following targets: + +* `aarch64-unknown-linux-gnu` +* `x86_64-unknown-freebsd` +* `x86_64-unknown-linux-gnu` MemorySanitizer requires all program code to be instrumented. C/C++ dependencies need to be recompiled using Clang with `-fsanitize=memory` option. Failing to @@ -219,7 +240,10 @@ $ cargo run -Zbuild-std --target x86_64-unknown-linux-gnu ThreadSanitizer is a data race detection tool. It is supported on the following targets: +* `aarch64-apple-darwin` +* `aarch64-unknown-linux-gnu` * `x86_64-apple-darwin` +* `x86_64-unknown-freebsd` * `x86_64-unknown-linux-gnu` To work correctly ThreadSanitizer needs to be "aware" of all synchronization diff --git a/src/doc/unstable-book/src/language-features/ffi-pure.md b/src/doc/unstable-book/src/language-features/ffi-pure.md index 4aef4eeab55..236ccb9f905 100644 --- a/src/doc/unstable-book/src/language-features/ffi-pure.md +++ b/src/doc/unstable-book/src/language-features/ffi-pure.md @@ -31,7 +31,7 @@ parameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not referentially-transparent, and are therefore more relaxed than `#[ffi_const]` functions. -However, accesing global memory through volatile or atomic reads can violate the +However, accessing global memory through volatile or atomic reads can violate the requirement that two consecutive function calls shall return the same value. A `pure` function that returns unit has no effect on the abstract machine's diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index a0ba47e1dbe..d38f5add747 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -This script creates a pile of compile-fail tests check that all the +This script creates a pile of UI tests check that all the derives have spans that point to the fields, rather than the #[derive(...)] line. diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index 440181a7611..2f7233685db 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -218,7 +218,7 @@ def concat_multi_lines(f): LINE_PATTERN = re.compile(r''' - (?<=(?<!\S)@)(?P<negated>!?) + (?<=(?<!\S))(?P<invalid>!?)@(?P<negated>!?) (?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*) (?P<args>.*)$ ''', re.X | re.UNICODE) @@ -233,6 +233,16 @@ def get_commands(template): negated = (m.group('negated') == '!') cmd = m.group('cmd') + if m.group('invalid') == '!': + print_err( + lineno, + line, + 'Invalid command: `!@{0}{1}`, (help: try with `@!{1}`)'.format( + '!' if negated else '', + cmd, + ), + ) + continue args = m.group('args') if args and not args[:1].isspace(): print_err(lineno, line, 'Invalid template syntax') diff --git a/src/etc/natvis/intrinsic.natvis b/src/etc/natvis/intrinsic.natvis index 874550da8b0..030892a432b 100644 --- a/src/etc/natvis/intrinsic.natvis +++ b/src/etc/natvis/intrinsic.natvis @@ -4,17 +4,21 @@ <DisplayString>{data_ptr,[length]s8}</DisplayString> <StringView>data_ptr,[length]s8</StringView> <Expand> - <Item Name="[size]" ExcludeView="simple">length</Item> - <ArrayItems> - <Size>length</Size> - <ValuePointer>data_ptr</ValuePointer> - </ArrayItems> + <Item Name="[len]" ExcludeView="simple">length</Item> + <Synthetic Name="[chars]"> + <Expand> + <ArrayItems> + <Size>length</Size> + <ValuePointer>data_ptr</ValuePointer> + </ArrayItems> + </Expand> + </Synthetic> </Expand> </Type> <Type Name="slice<*>"> - <DisplayString>{{ length={length} }}</DisplayString> + <DisplayString>{{ len={length} }}</DisplayString> <Expand> - <Item Name="[size]" ExcludeView="simple">length</Item> + <Item Name="[len]" ExcludeView="simple">length</Item> <ArrayItems> <Size>length</Size> <ValuePointer>data_ptr</ValuePointer> diff --git a/src/etc/natvis/liballoc.natvis b/src/etc/natvis/liballoc.natvis index de30b58526a..cfaafc5734b 100644 --- a/src/etc/natvis/liballoc.natvis +++ b/src/etc/natvis/liballoc.natvis @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <Type Name="alloc::vec::Vec<*>"> - <DisplayString>{{ size={len} }}</DisplayString> + <DisplayString>{{ len={len} }}</DisplayString> <Expand> - <Item Name="[size]" ExcludeView="simple">len</Item> + <Item Name="[len]" ExcludeView="simple">len</Item> <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item> <ArrayItems> <Size>len</Size> @@ -12,9 +12,9 @@ </Expand> </Type> <Type Name="alloc::collections::vec_deque::VecDeque<*>"> - <DisplayString>{{ size={tail <= head ? head - tail : buf.cap - tail + head} }}</DisplayString> + <DisplayString>{{ len={tail <= head ? head - tail : buf.cap - tail + head} }}</DisplayString> <Expand> - <Item Name="[size]" ExcludeView="simple">tail <= head ? head - tail : buf.cap - tail + head</Item> + <Item Name="[len]" ExcludeView="simple">tail <= head ? head - tail : buf.cap - tail + head</Item> <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item> <CustomListItems> <Variable Name="i" InitialValue="tail" /> @@ -31,7 +31,7 @@ </Expand> </Type> <Type Name="alloc::collections::linked_list::LinkedList<*>"> - <DisplayString>{{ size={len} }}</DisplayString> + <DisplayString>{{ len={len} }}</DisplayString> <Expand> <LinkedListItems> <Size>len</Size> @@ -42,15 +42,37 @@ </Expand> </Type> <Type Name="alloc::string::String"> - <DisplayString>{*(char**)this,[vec.len]s8}</DisplayString> - <StringView>*(char**)this,[vec.len]s8</StringView> + <DisplayString>{(char*)vec.buf.ptr.pointer,[vec.len]s8}</DisplayString> + <StringView>(char*)vec.buf.ptr.pointer,[vec.len]s8</StringView> <Expand> - <Item Name="[size]" ExcludeView="simple">vec.len</Item> + <Item Name="[len]" ExcludeView="simple">vec.len</Item> <Item Name="[capacity]" ExcludeView="simple">vec.buf.cap</Item> - <ArrayItems> - <Size>vec.len</Size> - <ValuePointer>*(char**)this</ValuePointer> - </ArrayItems> + <Synthetic Name="[chars]"> + <Expand> + <ArrayItems> + <Size>vec.len</Size> + <ValuePointer>(char*)vec.buf.ptr.pointer</ValuePointer> + </ArrayItems> + </Expand> + </Synthetic> + </Expand> + </Type> + <Type Name="alloc::rc::Rc<*>"> + <DisplayString>{ptr.pointer->value}</DisplayString> + <Expand> + <ExpandedItem>ptr.pointer->value</ExpandedItem> + </Expand> + </Type> + <Type Name="alloc::sync::Arc<*>"> + <DisplayString>{ptr.pointer->data}</DisplayString> + <Expand> + <ExpandedItem>ptr.pointer->data</ExpandedItem> + </Expand> + </Type> + <Type Name="alloc::sync::Weak<*>"> + <DisplayString>{ptr.pointer->data}</DisplayString> + <Expand> + <ExpandedItem>ptr.pointer->data</ExpandedItem> </Expand> </Type> </AutoVisualizer> diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index 0e703b3b950..984a8bfb13c 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -6,34 +6,28 @@ <Item Name="[ptr]">pointer</Item> </Expand> </Type> + <Type Name="core::ptr::Shared<*>"> <DisplayString>{{ Shared {pointer} }}</DisplayString> <Expand> <Item Name="[ptr]">pointer</Item> </Expand> </Type> + <Type Name="core::option::Option<*>"> - <DisplayString Condition="RUST$ENUM$DISR == 0x0">{{ None }}</DisplayString> - <DisplayString Condition="RUST$ENUM$DISR == 0x1">{{ Some {__0} }}</DisplayString> + <DisplayString Condition="RUST$ENUM$DISR == 0x0">None</DisplayString> + <DisplayString Condition="RUST$ENUM$DISR == 0x1">Some({__0})</DisplayString> <Expand> - <Item Name="[size]" ExcludeView="simple">(ULONG)(RUST$ENUM$DISR != 0)</Item> - <Item Name="[value]" ExcludeView="simple">__0</Item> - <ArrayItems> - <Size>(ULONG)(RUST$ENUM$DISR != 0)</Size> - <ValuePointer>&__0</ValuePointer> - </ArrayItems> + <Item Name="[value]" ExcludeView="simple" Condition="RUST$ENUM$DISR == 1">__0</Item> </Expand> </Type> + <Type Name="core::option::Option<*>" Priority="MediumLow"> - <DisplayString Condition="*(PVOID *)this == nullptr">{{ None }}</DisplayString> - <DisplayString>{{ Some {($T1 *)this} }}</DisplayString> + <DisplayString Condition="*(void**)this == nullptr">None</DisplayString> + <DisplayString>Some({($T1 *)this})</DisplayString> <Expand> - <Item Name="[size]" ExcludeView="simple">(ULONG)(*(PVOID *)this != nullptr)</Item> - <Item Name="[value]" ExcludeView="simple" Condition="*(PVOID *)this != nullptr">($T1 *)this</Item> - <ArrayItems> - <Size>(ULONG)(*(PVOID *)this != nullptr)</Size> - <ValuePointer>($T1 *)this</ValuePointer> - </ArrayItems> + <Item Name="Some" ExcludeView="simple" Condition="*(void**)this != nullptr">($T1 *)this</Item> </Expand> </Type> + </AutoVisualizer> \ No newline at end of file diff --git a/src/etc/natvis/libstd.natvis b/src/etc/natvis/libstd.natvis index 9550c25f2fc..7e5ee7b13da 100644 --- a/src/etc/natvis/libstd.natvis +++ b/src/etc/natvis/libstd.natvis @@ -26,9 +26,9 @@ --> <Type Name="std::collections::hash::map::HashMap<*,*,*>"> - <DisplayString>{{ size={base.table.items} }}</DisplayString> + <DisplayString>{{ len={base.table.items} }}</DisplayString> <Expand> - <Item Name="[size]">base.table.items</Item> + <Item Name="[len]">base.table.items</Item> <Item Name="[capacity]">base.table.items + base.table.growth_left</Item> <Item Name="[state]">base.hash_builder</Item> @@ -50,9 +50,9 @@ </Type> <Type Name="std::collections::hash::set::HashSet<*,*>"> - <DisplayString>{{ size={base.map.table.items} }}</DisplayString> + <DisplayString>{{ len={base.map.table.items} }}</DisplayString> <Expand> - <Item Name="[size]">base.map.table.items</Item> + <Item Name="[len]">base.map.table.items</Item> <Item Name="[capacity]">base.map.table.items + base.map.table.growth_left</Item> <Item Name="[state]">base.map.hash_builder</Item> diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 96d19e8e17d..3b13cb9e98c 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -123,7 +123,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { attrs: Default::default(), visibility: Inherited, def_id: self.cx.next_def_id(param_env_def_id.krate), - kind: ImplItem(Impl { + kind: box ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, provided_trait_methods: Default::default(), @@ -351,8 +351,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { if let Some(data) = ty_to_fn.get(&ty) { let (poly_trait, output) = (data.0.as_ref().expect("as_ref failed").clone(), data.1.as_ref().cloned()); - let new_ty = match &poly_trait.trait_ { - &Type::ResolvedPath { + let new_ty = match poly_trait.trait_ { + Type::ResolvedPath { ref path, ref param_names, ref did, @@ -597,7 +597,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { ref mut bindings, .. } => { bindings.push(TypeBinding { - name: left_name.clone(), + name: left_name, kind: TypeBindingKind::Equality { ty: rhs }, }); } @@ -665,7 +665,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { GenericParamDefKind::Type { ref mut default, ref mut bounds, .. } => { // We never want something like `impl<T=Foo>`. default.take(); - let generic_ty = Type::Generic(param.name.clone()); + let generic_ty = Type::Generic(param.name); if !has_sized.contains(&generic_ty) { bounds.insert(0, GenericBound::maybe_sized(self.cx)); } @@ -738,11 +738,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } fn is_fn_ty(&self, tcx: TyCtxt<'_>, ty: &Type) -> bool { - match &ty { - &&Type::ResolvedPath { ref did, .. } => { - *did == tcx.require_lang_item(LangItem::Fn, None) - || *did == tcx.require_lang_item(LangItem::FnMut, None) - || *did == tcx.require_lang_item(LangItem::FnOnce, None) + match ty { + &Type::ResolvedPath { did, .. } => { + did == tcx.require_lang_item(LangItem::Fn, None) + || did == tcx.require_lang_item(LangItem::FnMut, None) + || did == tcx.require_lang_item(LangItem::FnOnce, None) } _ => false, } diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index d99055e1145..ba3eb007e38 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -112,7 +112,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { attrs: Default::default(), visibility: Inherited, def_id: self.cx.next_def_id(impl_def_id.krate), - kind: ImplItem(Impl { + kind: box ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: ( self.cx.tcx.generics_of(impl_def_id), diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 2f169d1d3f3..444b73246da 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -177,10 +177,7 @@ impl Cfg { Cfg::Any(ref sub_cfgs) | Cfg::All(ref sub_cfgs) => { sub_cfgs.first().map(Cfg::should_capitalize_first_letter).unwrap_or(false) } - Cfg::Cfg(name, _) => match name { - sym::debug_assertions | sym::target_endian => true, - _ => false, - }, + Cfg::Cfg(name, _) => name == sym::debug_assertions || name == sym::target_endian, } } @@ -188,18 +185,13 @@ impl Cfg { match *self { Cfg::False | Cfg::True => false, Cfg::Any(..) | Cfg::All(..) | Cfg::Cfg(..) => true, - Cfg::Not(ref child) => match **child { - Cfg::Cfg(..) => true, - _ => false, - }, + Cfg::Not(box Cfg::Cfg(..)) => true, + Cfg::Not(..) => false, } } fn should_use_with_in_description(&self) -> bool { - match *self { - Cfg::Cfg(name, _) if name == sym::target_feature => true, - _ => false, - } + matches!(self, Cfg::Cfg(sym::target_feature, _)) } /// Attempt to simplify this cfg by assuming that `assume` is already known to be true, will diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index be4c62d891d..ed972cc16e9 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -261,26 +261,12 @@ fn build_union(cx: &DocContext<'_>, did: DefId) -> clean::Union { fn build_type_alias(cx: &DocContext<'_>, did: DefId) -> clean::Typedef { let predicates = cx.tcx.explicit_predicates_of(did); + let type_ = cx.tcx.type_of(did).clean(cx); clean::Typedef { - type_: cx.tcx.type_of(did).clean(cx), + type_, generics: (cx.tcx.generics_of(did), predicates).clean(cx), - item_type: build_type_alias_type(cx, did), - } -} - -fn build_type_alias_type(cx: &DocContext<'_>, did: DefId) -> Option<clean::Type> { - let type_ = cx.tcx.type_of(did).clean(cx); - type_.def_id().and_then(|did| build_ty(cx, did)) -} - -crate fn build_ty(cx: &DocContext<'_>, did: DefId) -> Option<clean::Type> { - match cx.tcx.def_kind(did) { - DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::Const | DefKind::Static => { - Some(cx.tcx.type_of(did).clean(cx)) - } - DefKind::TyAlias => build_type_alias_type(cx, did), - _ => None, + item_type: None, } } @@ -482,7 +468,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>) source: clean::Span::dummy(), def_id: DefId::local(CRATE_DEF_INDEX), visibility: clean::Public, - kind: clean::ImportItem(clean::Import::new_simple( + kind: box clean::ImportItem(clean::Import::new_simple( item.ident.name, clean::ImportSource { path: clean::Path { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index de53ce8d95c..0b979120ff9 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -218,11 +218,6 @@ impl Clean<ExternalCrate> for CrateNum { impl Clean<Item> for doctree::Module<'_> { fn clean(&self, cx: &DocContext<'_>) -> Item { - // 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 - let attrs = self.attrs.clean(cx); - let mut items: Vec<Item> = vec![]; items.extend(self.imports.iter().flat_map(|x| x.clean(cx))); items.extend(self.foreigns.iter().map(|x| x.clean(cx))); @@ -251,7 +246,7 @@ impl Clean<Item> for doctree::Module<'_> { ModuleItem(Module { is_crate: self.is_crate, items }), cx, ); - Item { attrs, source: span.clean(cx), ..what_rustc_thinks } + Item { source: span.clean(cx), ..what_rustc_thinks } } } @@ -612,11 +607,12 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> { synthetic, }, ), - hir::GenericParamKind::Const { ref ty } => ( + hir::GenericParamKind::Const { ref ty, default: _ } => ( self.name.ident().name, GenericParamDefKind::Const { did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(), ty: ty.clean(cx), + // FIXME(const_generics_defaults): add `default` field here for docs }, ), }; @@ -638,6 +634,18 @@ impl Clean<Generics> for hir::Generics<'_> { _ => false, } } + /// This can happen for `async fn`, e.g. `async fn f<'_>(&'_ self)`. + /// + /// See [`lifetime_to_generic_param`] in [`rustc_ast_lowering`] for more information. + /// + /// [`lifetime_to_generic_param`]: rustc_ast_lowering::LoweringContext::lifetime_to_generic_param + fn is_elided_lifetime(param: &hir::GenericParam<'_>) -> bool { + matches!( + param.kind, + hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided } + ) + } + let impl_trait_params = self .params .iter() @@ -656,7 +664,7 @@ impl Clean<Generics> for hir::Generics<'_> { .collect::<Vec<_>>(); let mut params = Vec::with_capacity(self.params.len()); - for p in self.params.iter().filter(|p| !is_impl_trait(p)) { + for p in self.params.iter().filter(|p| !is_impl_trait(p) && !is_elided_lifetime(p)) { let p = p.clean(cx); params.push(p); } @@ -793,7 +801,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx for (param, mut bounds) in impl_trait { // Move trait bounds to the front. - bounds.sort_by_key(|b| if let GenericBound::TraitBound(..) = b { false } else { true }); + bounds.sort_by_key(|b| !matches!(b, GenericBound::TraitBound(..))); if let crate::core::ImplTraitParam::ParamIndex(idx) = param { if let Some(proj) = impl_trait_proj.remove(&idx) { @@ -824,7 +832,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx where_predicates.retain(|pred| match *pred { WP::BoundPredicate { ty: Generic(ref g), ref bounds } => { if bounds.iter().any(|b| b.is_sized_bound(cx)) { - sized_params.insert(g.clone()); + sized_params.insert(*g); false } else { true @@ -840,7 +848,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx && !sized_params.contains(&tp.name) { where_predicates.push(WP::BoundPredicate { - ty: Type::Generic(tp.name.clone()), + ty: Type::Generic(tp.name), bounds: vec![GenericBound::maybe_sized(cx)], }) } @@ -934,7 +942,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [Ident]) { .iter() .enumerate() .map(|(i, ty)| { - let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Invalid); + let mut name = self.1.get(i).map(|ident| ident.name).unwrap_or(kw::Empty); if name.is_empty() { name = kw::Underscore; } @@ -993,7 +1001,7 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) { .iter() .map(|t| Argument { type_: t.clean(cx), - name: names.next().map(|i| i.name).unwrap_or(kw::Invalid), + name: names.next().map(|i| i.name).unwrap_or(kw::Empty), }) .collect(), }, @@ -1111,10 +1119,17 @@ impl Clean<Item> for hir::ImplItem<'_> { } MethodItem(m, Some(self.defaultness)) } - hir::ImplItemKind::TyAlias(ref ty) => { - let type_ = ty.clean(cx); - let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did)); - TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true) + hir::ImplItemKind::TyAlias(ref hir_ty) => { + let type_ = hir_ty.clean(cx); + let item_type = hir_ty_to_ty(cx.tcx, hir_ty).clean(cx); + TypedefItem( + Typedef { + type_, + generics: Generics::default(), + item_type: Some(item_type), + }, + true, + ) } }; Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx) @@ -1260,13 +1275,13 @@ impl Clean<Item> for ty::AssocItem { AssocTypeItem(bounds, ty.clean(cx)) } else { + // FIXME: when could this happen? ASsociated items in inherent impls? let type_ = cx.tcx.type_of(self.def_id).clean(cx); - let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did)); TypedefItem( Typedef { type_, generics: Generics { params: Vec::new(), where_predicates: Vec::new() }, - item_type, + item_type: None, }, true, ) @@ -1378,7 +1393,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &DocContext<'_>) -> Type { if let Some(ct) = const_ { ct_substs.insert(const_param_def_id.to_def_id(), ct.clean(cx)); } - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) indices.consts += 1; } } @@ -1437,7 +1452,16 @@ impl Clean<Type> for hir::Ty<'_> { TyKind::Never => Never, TyKind::Ptr(ref m) => RawPointer(m.mutbl, box m.ty.clean(cx)), TyKind::Rptr(ref l, ref m) => { - let lifetime = if l.is_elided() { None } else { Some(l.clean(cx)) }; + // There are two times a `Fresh` lifetime can be created: + // 1. For `&'_ x`, written by the user. This corresponds to `lower_lifetime` in `rustc_ast_lowering`. + // 2. For `&x` as a parameter to an `async fn`. This corresponds to `elided_ref_lifetime in `rustc_ast_lowering`. + // See #59286 for more information. + // Ideally we would only hide the `'_` for case 2., but I don't know a way to distinguish it. + // Turning `fn f(&'_ self)` into `fn f(&self)` isn't the worst thing in the world, though; + // there's no case where it could cause the function to fail to compile. + let elided = + l.is_elided() || matches!(l.name, LifetimeName::Param(ParamName::Fresh(_))); + let lifetime = if elided { None } else { Some(l.clean(cx)) }; BorrowedRef { lifetime, mutability: m.mutbl, type_: box m.ty.clean(cx) } } TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), @@ -1970,11 +1994,15 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) { bounds: ty.bounds.clean(cx), generics: ty.generics.clean(cx), }), - ItemKind::TyAlias(ty, ref generics) => { - let rustdoc_ty = ty.clean(cx); - let item_type = rustdoc_ty.def_id().and_then(|did| inline::build_ty(cx, did)); + ItemKind::TyAlias(hir_ty, ref generics) => { + let rustdoc_ty = hir_ty.clean(cx); + let ty = hir_ty_to_ty(cx.tcx, hir_ty).clean(cx); TypedefItem( - Typedef { type_: rustdoc_ty, generics: generics.clean(cx), item_type }, + Typedef { + type_: rustdoc_ty, + generics: generics.clean(cx), + item_type: Some(ty), + }, false, ) } @@ -2144,7 +2172,7 @@ fn clean_extern_crate( source: krate.span.clean(cx), def_id: crate_def_id, visibility: krate.vis.clean(cx), - kind: ExternCrateItem(name, orig_name), + kind: box ExternCrateItem(name, orig_name), }] } @@ -2157,11 +2185,26 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { return Vec::new(); } + let (doc_meta_item, please_inline) = self.attrs.lists(sym::doc).get_word_attr(sym::inline); + let pub_underscore = self.vis.node.is_pub() && self.name == kw::Underscore; + + if pub_underscore && please_inline { + rustc_errors::struct_span_err!( + cx.tcx.sess, + doc_meta_item.unwrap().span(), + E0780, + "anonymous imports cannot be inlined" + ) + .span_label(self.span, "anonymous import") + .emit(); + } + // We consider inlining the documentation of `pub use` statements, but we // forcefully don't inline if this is not public or if the // #[doc(no_inline)] attribute is present. // Don't inline doc(hidden) imports so they can be stripped at a later stage. let mut denied = !self.vis.node.is_pub() + || pub_underscore || self.attrs.iter().any(|a| { a.has_name(sym::doc) && match a.meta_item_list() { @@ -2174,7 +2217,6 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { }); // Also check whether imports were asked to be inlined, in case we're trying to re-export a // crate in Rust 2018+ - let please_inline = self.attrs.lists(sym::doc).has_word(sym::inline); let path = self.path.clean(cx); let inner = if self.glob { if !denied { @@ -2212,7 +2254,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { source: self.span.clean(cx), def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(), visibility: self.vis.clean(cx), - kind: ImportItem(Import::new_simple( + kind: box ImportItem(Import::new_simple( self.name, resolve_use_source(cx, path), false, @@ -2230,7 +2272,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { source: self.span.clean(cx), def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(), visibility: self.vis.clean(cx), - kind: ImportItem(inner), + kind: box ImportItem(inner), }] } } @@ -2295,18 +2337,19 @@ impl Clean<Item> for (&hir::MacroDef<'_>, Option<Symbol>) { ) } else { let vis = item.vis.clean(cx); + let def_id = cx.tcx.hir().local_def_id(item.hir_id).to_def_id(); if matchers.len() <= 1 { format!( "{}macro {}{} {{\n ...\n}}", - vis.print_with_space(cx.tcx), + vis.print_with_space(cx.tcx, def_id), name, matchers.iter().map(|span| span.to_src(cx)).collect::<String>(), ) } else { format!( "{}macro {} {{\n{}}}", - vis.print_with_space(cx.tcx), + vis.print_with_space(cx.tcx, def_id), name, matchers .iter() diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 9b2003911a7..38791fcea54 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -84,10 +84,14 @@ crate struct Item { crate name: Option<Symbol>, crate attrs: Attributes, crate visibility: Visibility, - crate kind: ItemKind, + crate kind: Box<ItemKind>, crate def_id: DefId, } +// `Item` is used a lot. Make sure it doesn't unintentionally get bigger. +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Item, 136); + impl fmt::Debug for Item { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let def_id: &dyn fmt::Debug = if self.is_fake() { &"**FAKE**" } else { &self.def_id }; @@ -118,7 +122,7 @@ impl Item { /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. - crate fn doc_value(&self) -> Option<&str> { + crate fn doc_value(&self) -> Option<String> { self.attrs.doc_value() } @@ -152,7 +156,7 @@ impl Item { Item { def_id, - kind, + kind: box kind, name, source: source.clean(cx), attrs: cx.tcx.get_attrs(def_id).clean(cx), @@ -171,11 +175,9 @@ impl Item { } crate fn is_crate(&self) -> bool { - match self.kind { + matches!(*self.kind, StrippedItem(box ModuleItem(Module { is_crate: true, .. })) - | ModuleItem(Module { is_crate: true, .. }) => true, - _ => false, - } + | ModuleItem(Module { is_crate: true, .. })) } crate fn is_mod(&self) -> bool { self.type_() == ItemType::Module @@ -223,14 +225,14 @@ impl Item { self.type_() == ItemType::Keyword } crate fn is_stripped(&self) -> bool { - match self.kind { + match *self.kind { StrippedItem(..) => true, ImportItem(ref i) => !i.should_be_displayed, _ => false, } } crate fn has_stripped_fields(&self) -> Option<bool> { - match self.kind { + match *self.kind { StructItem(ref _struct) => Some(_struct.fields_stripped), UnionItem(ref union) => Some(union.fields_stripped), VariantItem(Variant { kind: VariantKind::Struct(ref vstruct) }) => { @@ -281,7 +283,7 @@ impl Item { } crate fn is_default(&self) -> bool { - match self.kind { + match *self.kind { ItemKind::MethodItem(_, Some(defaultness)) => { defaultness.has_value() && !defaultness.is_final() } @@ -289,7 +291,9 @@ impl Item { } } - /// See comments on next_def_id + /// See the documentation for [`next_def_id()`]. + /// + /// [`next_def_id()`]: DocContext::next_def_id() crate fn is_fake(&self) -> bool { MAX_DEF_ID.with(|m| { m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false) @@ -330,6 +334,10 @@ crate enum ItemKind { ProcMacroItem(ProcMacro), PrimitiveItem(PrimitiveType), AssocConstItem(Type, Option<String>), + /// An associated item in a trait or trait impl. + /// + /// The bounds may be non-empty if there is a `where` clause. + /// The `Option<Type>` is the default concrete type (e.g. `trait Trait { type Target = usize; }`) AssocTypeItem(Vec<GenericBound>, Option<Type>), /// An item that has been stripped by a rustdoc pass StrippedItem(Box<ItemKind>), @@ -374,10 +382,7 @@ impl ItemKind { } crate fn is_type_alias(&self) -> bool { - match *self { - ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true, - _ => false, - } + matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..)) } } @@ -435,12 +440,22 @@ impl AttributesExt for [ast::Attribute] { crate trait NestedAttributesExt { /// Returns `true` if the attribute list contains a specific `Word` fn has_word(self, word: Symbol) -> bool; + fn get_word_attr(self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool); } -impl<I: IntoIterator<Item = ast::NestedMetaItem>> NestedAttributesExt for I { +impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMetaItem>> + NestedAttributesExt for I +{ fn has_word(self, word: Symbol) -> bool { self.into_iter().any(|attr| attr.is_word() && attr.has_name(word)) } + + fn get_word_attr(mut self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool) { + match self.find(|attr| attr.is_word() && attr.has_name(word)) { + Some(a) => (Some(a), true), + None => (None, false), + } + } } /// A portion of documentation, extracted from a `#[doc]` attribute. @@ -460,11 +475,13 @@ crate struct DocFragment { /// This allows distinguishing between the original documentation and a pub re-export. /// If it is `None`, the item was not re-exported. crate parent_module: Option<DefId>, - crate doc: String, + crate doc: Symbol, crate kind: DocFragmentKind, + crate need_backline: bool, + crate indent: usize, } -#[derive(Clone, PartialEq, Eq, Debug, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] crate enum DocFragmentKind { /// A doc fragment created from a `///` or `//!` doc comment. SugaredDoc, @@ -472,7 +489,33 @@ crate enum DocFragmentKind { RawDoc, /// A doc fragment created from a `#[doc(include="filename")]` attribute. Contains both the /// given filename and the file contents. - Include { filename: String }, + Include { filename: Symbol }, +} + +// The goal of this function is to apply the `DocFragment` transformations that are required when +// transforming into the final markdown. So the transformations in here are: +// +// * Applying the computed indent to each lines in each doc fragment (a `DocFragment` can contain +// multiple lines in case of `#[doc = ""]`). +// * Adding backlines between `DocFragment`s and adding an extra one if required (stored in the +// `need_backline` field). +fn add_doc_fragment(out: &mut String, frag: &DocFragment) { + let s = frag.doc.as_str(); + let mut iter = s.lines().peekable(); + while let Some(line) = iter.next() { + if line.chars().any(|c| !c.is_whitespace()) { + assert!(line.len() >= frag.indent); + out.push_str(&line[frag.indent..]); + } else { + out.push_str(line); + } + if iter.peek().is_some() { + out.push('\n'); + } + } + if frag.need_backline { + out.push('\n'); + } } impl<'a> FromIterator<&'a DocFragment> for String { @@ -480,11 +523,18 @@ impl<'a> FromIterator<&'a DocFragment> for String { where T: IntoIterator<Item = &'a DocFragment>, { + let mut prev_kind: Option<DocFragmentKind> = None; iter.into_iter().fold(String::new(), |mut acc, frag| { - if !acc.is_empty() { + if !acc.is_empty() + && prev_kind + .take() + .map(|p| matches!(p, DocFragmentKind::Include { .. }) && p != frag.kind) + .unwrap_or(false) + { acc.push('\n'); } - acc.push_str(&frag.doc); + add_doc_fragment(&mut acc, &frag); + prev_kind = Some(frag.kind); acc }) } @@ -556,7 +606,7 @@ impl Attributes { /// Reads a `MetaItem` from within an attribute, looks for whether it is a /// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from /// its expansion. - crate fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> { + crate fn extract_include(mi: &ast::MetaItem) -> Option<(Symbol, Symbol)> { mi.meta_item_list().and_then(|list| { for meta in list { if meta.has_name(sym::include) { @@ -564,17 +614,17 @@ impl Attributes { // `#[doc(include(file="filename", contents="file contents")]` so we need to // look for that instead return meta.meta_item_list().and_then(|list| { - let mut filename: Option<String> = None; - let mut contents: Option<String> = None; + let mut filename: Option<Symbol> = None; + let mut contents: Option<Symbol> = None; for it in list { if it.has_name(sym::file) { if let Some(name) = it.value_str() { - filename = Some(name.to_string()); + filename = Some(name); } } else if it.has_name(sym::contents) { if let Some(docs) = it.value_str() { - contents = Some(docs.to_string()); + contents = Some(docs); } } } @@ -613,11 +663,26 @@ impl Attributes { attrs: &[ast::Attribute], additional_attrs: Option<(&[ast::Attribute], DefId)>, ) -> Attributes { - let mut doc_strings = vec![]; + let mut doc_strings: Vec<DocFragment> = vec![]; let mut sp = None; let mut cfg = Cfg::True; let mut doc_line = 0; + fn update_need_backline(doc_strings: &mut Vec<DocFragment>, frag: &DocFragment) { + if let Some(prev) = doc_strings.last_mut() { + if matches!(prev.kind, DocFragmentKind::Include { .. }) + || prev.kind != frag.kind + || prev.parent_module != frag.parent_module + { + // add a newline for extra padding between segments + prev.need_backline = prev.kind == DocFragmentKind::SugaredDoc + || prev.kind == DocFragmentKind::RawDoc + } else { + prev.need_backline = true; + } + } + } + let clean_attr = |(attr, parent_module): (&ast::Attribute, _)| { if let Some(value) = attr.doc_str() { trace!("got doc_str={:?}", value); @@ -629,14 +694,20 @@ impl Attributes { }; let line = doc_line; - doc_line += value.lines().count(); - doc_strings.push(DocFragment { + doc_line += value.as_str().lines().count(); + let frag = DocFragment { line, span: attr.span, doc: value, kind, parent_module, - }); + need_backline: false, + indent: 0, + }; + + update_need_backline(&mut doc_strings, &frag); + + doc_strings.push(frag); if sp.is_none() { sp = Some(attr.span); @@ -654,14 +725,18 @@ impl Attributes { } else if let Some((filename, contents)) = Attributes::extract_include(&mi) { let line = doc_line; - doc_line += contents.lines().count(); - doc_strings.push(DocFragment { + doc_line += contents.as_str().lines().count(); + let frag = DocFragment { line, span: attr.span, doc: contents, kind: DocFragmentKind::Include { filename }, - parent_module: parent_module, - }); + parent_module, + need_backline: false, + indent: 0, + }; + update_need_backline(&mut doc_strings, &frag); + doc_strings.push(frag); } } } @@ -712,14 +787,41 @@ impl Attributes { /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. - crate fn doc_value(&self) -> Option<&str> { - self.doc_strings.first().map(|s| s.doc.as_str()) + crate fn doc_value(&self) -> Option<String> { + let mut iter = self.doc_strings.iter(); + + let ori = iter.next()?; + let mut out = String::new(); + add_doc_fragment(&mut out, &ori); + while let Some(new_frag) = iter.next() { + if matches!(ori.kind, DocFragmentKind::Include { .. }) + || new_frag.kind != ori.kind + || new_frag.parent_module != ori.parent_module + { + break; + } + add_doc_fragment(&mut out, &new_frag); + } + if out.is_empty() { None } else { Some(out) } + } + + /// Return the doc-comments on this item, grouped by the module they came from. + /// + /// The module can be different if this is a re-export with added documentation. + crate fn collapsed_doc_value_by_module_level(&self) -> FxHashMap<Option<DefId>, String> { + let mut ret = FxHashMap::default(); + + for new_frag in self.doc_strings.iter() { + let out = ret.entry(new_frag.parent_module).or_default(); + add_doc_fragment(out, &new_frag); + } + ret } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. crate fn collapsed_doc_value(&self) -> Option<String> { - if !self.doc_strings.is_empty() { Some(self.doc_strings.iter().collect()) } else { None } + if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) } } /// Gets links as a vector @@ -736,7 +838,7 @@ impl Attributes { Some(did) => { if let Some((mut href, ..)) = href(did) { if let Some(ref fragment) = *fragment { - href.push_str("#"); + href.push('#'); href.push_str(fragment); } Some(RenderedLink { @@ -931,10 +1033,7 @@ crate enum GenericParamDefKind { impl GenericParamDefKind { crate fn is_type(&self) -> bool { - match *self { - GenericParamDefKind::Type { .. } => true, - _ => false, - } + matches!(self, GenericParamDefKind::Type { .. }) } // FIXME(eddyb) this either returns the default of a type parameter, or the @@ -1278,15 +1377,12 @@ impl Type { } crate fn is_full_generic(&self) -> bool { - match *self { - Type::Generic(_) => true, - _ => false, - } + matches!(self, Type::Generic(_)) } crate fn projection(&self) -> Option<(&Type, DefId, Symbol)> { let (self_, trait_, name) = match self { - QPath { ref self_type, ref trait_, name } => (self_type, trait_, name), + QPath { self_type, trait_, name } => (self_type, trait_, name), _ => return None, }; let trait_did = match **trait_ { @@ -1714,7 +1810,12 @@ crate struct PathSegment { crate struct Typedef { crate type_: Type, crate generics: Generics, - // Type of target item. + /// `type_` can come from either the HIR or from metadata. If it comes from HIR, it may be a type + /// alias instead of the final type. This will always have the final type, regardless of whether + /// `type_` came from HIR or from metadata. + /// + /// If `item_type.is_none()`, `type_` is guarenteed to come from metadata (and therefore hold the + /// final type). crate item_type: Option<Type>, } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 270321aaa11..3b2f50db8c7 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -8,14 +8,13 @@ use crate::clean::{ }; use crate::core::DocContext; -use itertools::Itertools; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_middle::mir::interpret::ConstValue; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; -use rustc_middle::ty::{self, DefIdTree, Ty}; +use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt}; use rustc_span::symbol::{kw, sym, Symbol}; use std::mem; @@ -43,7 +42,7 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { let mut module = module.clean(cx); let mut masked_crates = FxHashSet::default(); - match module.kind { + match *module.kind { ItemKind::ModuleItem(ref module) => { for it in &module.items { // `compiler_builtins` should be masked too, but we can't apply @@ -61,7 +60,7 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { let ExternalCrate { name, src, primitives, keywords, .. } = LOCAL_CRATE.clean(cx); { - let m = match module.kind { + let m = match *module.kind { ItemKind::ModuleItem(ref mut m) => m, _ => unreachable!(), }; @@ -74,7 +73,7 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { ) })); m.items.extend(keywords.into_iter().map(|(def_id, kw)| { - Item::from_def_id_and_parts(def_id, Some(kw.clone()), ItemKind::KeywordItem(kw), cx) + Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem(kw), cx) })); } @@ -180,12 +179,12 @@ crate fn get_real_types( if arg.is_full_generic() { let arg_s = Symbol::intern(&arg.print().to_string()); if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g { - &WherePredicate::BoundPredicate { ref ty, .. } => ty.def_id() == arg.def_id(), + WherePredicate::BoundPredicate { ty, .. } => ty.def_id() == arg.def_id(), _ => false, }) { let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]); for bound in bounds.iter() { - if let GenericBound::TraitBound(ref poly_trait, _) = *bound { + if let GenericBound::TraitBound(poly_trait, _) = bound { for x in poly_trait.generic_params.iter() { if !x.is_type() { continue; @@ -307,7 +306,7 @@ crate fn strip_path(path: &Path) -> Path { .segments .iter() .map(|s| PathSegment { - name: s.name.clone(), + name: s.name, args: GenericArgs::AngleBracketed { args: vec![], bindings: vec![] }, }) .collect(); @@ -338,7 +337,7 @@ crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut let tcx = cx.tcx; for item in items { - let target = match item.kind { + let target = match *item.kind { ItemKind::TypedefItem(ref t, true) => &t.type_, _ => continue, }; @@ -624,3 +623,24 @@ where *cx.impl_trait_bounds.borrow_mut() = old_bounds; r } + +/// Find the nearest parent module of a [`DefId`]. +/// +/// **Panics if the item it belongs to [is fake][Item::is_fake].** +crate fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> { + if def_id.is_top_level_module() { + // The crate root has no parent. Use it as the root instead. + Some(def_id) + } else { + let mut current = def_id; + // The immediate parent might not always be a module. + // Find the first parent which is. + while let Some(parent) = tcx.parent(current) { + if tcx.def_kind(parent) == DefKind::Mod { + return Some(parent); + } + current = parent; + } + None + } +} diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 2d58614b139..e43ea965c04 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -37,10 +37,7 @@ crate enum OutputFormat { impl OutputFormat { crate fn is_json(&self) -> bool { - match self { - OutputFormat::Json => true, - _ => false, - } + matches!(self, OutputFormat::Json) } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 819dc06845f..4db5a0bccc8 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -120,14 +120,20 @@ impl<'tcx> DocContext<'tcx> { r } - // This is an ugly hack, but it's the simplest way to handle synthetic impls without greatly - // refactoring either librustdoc or librustc_middle. In particular, allowing new DefIds to be - // 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 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 + /// Create a new "fake" [`DefId`]. + /// + /// This is an ugly hack, but it's the simplest way to handle synthetic impls without greatly + /// refactoring either rustdoc or [`rustc_middle`]. In particular, allowing new [`DefId`]s + /// to be 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" [`DefId`]s, which start immediately after the last `DefId`. + /// In the [`Debug`] impl for [`clean::Item`], we explicitly check for fake `DefId`s, + /// as we'll end up with a panic if we use the `DefId` `Debug` impl for fake `DefId`s. + /// + /// [`RefCell`]: std::cell::RefCell + /// [`Debug`]: std::fmt::Debug + /// [`clean::Item`]: crate::clean::types::Item crate fn next_def_id(&self, crate_num: CrateNum) -> DefId { let start_def_id = { let num_def_ids = if crate_num == LOCAL_CRATE { @@ -524,7 +530,7 @@ crate fn run_global_ctxt( let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt)); if let Some(ref m) = krate.module { - if let None | Some("") = m.doc_value() { + if m.doc_value().map(|d| d.is_empty()).unwrap_or(true) { let help = "The following guide may be of use:\n\ https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html"; tcx.struct_lint_node( @@ -622,6 +628,9 @@ crate fn run_global_ctxt( ctxt.sess().abort_if_errors(); + // The main crate doc comments are always collapsed. + krate.collapsed = true; + (krate, ctxt.renderinfo.into_inner(), ctxt.render_options) } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 37fe13c32ce..09627be9701 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -247,9 +247,10 @@ fn run_test( edition: Edition, outdir: DirState, path: PathBuf, + test_id: &str, ) -> Result<(), TestFailure> { let (test, line_offset, supports_color) = - make_test(test, Some(cratename), as_test_harness, opts, edition); + make_test(test, Some(cratename), as_test_harness, opts, edition, Some(test_id)); let output_file = outdir.path().join("rust_out"); @@ -387,6 +388,7 @@ crate fn make_test( dont_insert_main: bool, opts: &TestOptions, edition: Edition, + test_id: Option<&str>, ) -> (String, usize, bool) { let (crate_attrs, everything_else, crates) = partition_source(s); let everything_else = everything_else.trim(); @@ -542,16 +544,41 @@ crate fn make_test( prog.push_str(everything_else); } else { let returns_result = everything_else.trim_end().ends_with("(())"); + // Give each doctest main function a unique name. + // This is for example needed for the tooling around `-Z instrument-coverage`. + let inner_fn_name = if let Some(test_id) = test_id { + format!("_doctest_main_{}", test_id) + } else { + "_inner".into() + }; + let inner_attr = if test_id.is_some() { "#[allow(non_snake_case)] " } else { "" }; let (main_pre, main_post) = if returns_result { ( - "fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {", - "}\n_inner().unwrap() }", + format!( + "fn main() {{ {}fn {}() -> Result<(), impl core::fmt::Debug> {{\n", + inner_attr, inner_fn_name + ), + format!("\n}} {}().unwrap() }}", inner_fn_name), + ) + } else if test_id.is_some() { + ( + format!("fn main() {{ {}fn {}() {{\n", inner_attr, inner_fn_name), + format!("\n}} {}() }}", inner_fn_name), ) } else { - ("fn main() {\n", "\n}") + ("fn main() {\n".into(), "\n}".into()) }; - prog.extend([main_pre, everything_else, main_post].iter().cloned()); + // Note on newlines: We insert a line/newline *before*, and *after* + // the doctest and adjust the `line_offset` accordingly. + // In the case of `-Z instrument-coverage`, this means that the generated + // inner `main` function spans from the doctest opening codeblock to the + // closing one. For example + // /// ``` <- start of the inner main + // /// <- code under doctest + // /// ``` <- end of the inner main line_offset += 1; + + prog.extend([&main_pre, everything_else, &main_post].iter().cloned()); } debug!("final doctest:\n{}", prog); @@ -609,15 +636,15 @@ fn partition_source(s: &str) -> (String, String, String) { match state { PartitionState::Attrs => { before.push_str(line); - before.push_str("\n"); + before.push('\n'); } PartitionState::Crates => { crates.push_str(line); - crates.push_str("\n"); + crates.push('\n'); } PartitionState::Other => { after.push_str(line); - after.push_str("\n"); + after.push('\n'); } } } @@ -749,28 +776,24 @@ impl Tester for Collector { _ => PathBuf::from(r"doctest.rs"), }; + // For example `module/file.rs` would become `module_file_rs` + let file = filename + .to_string() + .chars() + .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }) + .collect::<String>(); + let test_id = format!( + "{file}_{line}_{number}", + file = file, + line = line, + number = { + // Increases the current test number, if this file already + // exists or it creates a new entry with a test number of 0. + self.visited_tests.entry((file.clone(), line)).and_modify(|v| *v += 1).or_insert(0) + }, + ); let outdir = if let Some(mut path) = options.persist_doctests.clone() { - // For example `module/file.rs` would become `module_file_rs` - let folder_name = filename - .to_string() - .chars() - .map(|c| if c == '\\' || c == '/' || c == '.' { '_' } else { c }) - .collect::<String>(); - - path.push(format!( - "{krate}_{file}_{line}_{number}", - krate = cratename, - file = folder_name, - line = line, - number = { - // Increases the current test number, if this file already - // exists or it creates a new entry with a test number of 0. - self.visited_tests - .entry((folder_name.clone(), line)) - .and_modify(|v| *v += 1) - .or_insert(0) - }, - )); + path.push(&test_id); std::fs::create_dir_all(&path) .expect("Couldn't create directory for doctest executables"); @@ -817,6 +840,7 @@ impl Tester for Collector { edition, outdir, path, + &test_id, ); if let Err(err) = res { @@ -963,7 +987,6 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> { self.collector.names.push(name); } - attrs.collapse_doc_comments(); attrs.unindent_doc_comments(); // The collapse-docs pass won't combine sugared/raw doc attributes, or included files with // anything else, this will combine them for us. diff --git a/src/librustdoc/doctest/tests.rs b/src/librustdoc/doctest/tests.rs index a024e9c72a4..465b2b1d69b 100644 --- a/src/librustdoc/doctest/tests.rs +++ b/src/librustdoc/doctest/tests.rs @@ -11,7 +11,7 @@ fn main() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -26,7 +26,7 @@ fn main() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -44,7 +44,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 3)); } @@ -61,7 +61,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -79,7 +79,7 @@ use std::*; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("std"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("std"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -98,7 +98,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -115,7 +115,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -134,7 +134,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 3)); // Adding more will also bump the returned line offset. @@ -147,7 +147,7 @@ use asdf::qwop; assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 4)); } @@ -164,7 +164,7 @@ fn main() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -180,7 +180,7 @@ fn main() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 1)); } @@ -196,7 +196,7 @@ fn main() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); } @@ -210,7 +210,7 @@ assert_eq!(2+2, 4);"; //Ceci n'est pas une `fn main` assert_eq!(2+2, 4);" .to_string(); - let (output, len, _) = make_test(input, None, true, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, true, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 1)); } @@ -224,7 +224,7 @@ fn make_test_display_warnings() { assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 1)); } @@ -242,7 +242,7 @@ assert_eq!(2+2, 4); }" .to_string(); - let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 2)); let input = "extern crate hella_qwop; @@ -256,7 +256,7 @@ assert_eq!(asdf::foo, 4); }" .to_string(); - let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("asdf"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 3)); } @@ -274,6 +274,41 @@ test_wrapper! { }" .to_string(); - let (output, len, _) = make_test(input, Some("my_crate"), false, &opts, DEFAULT_EDITION); + let (output, len, _) = make_test(input, Some("my_crate"), false, &opts, DEFAULT_EDITION, None); assert_eq!((output, len), (expected, 1)); } + +#[test] +fn make_test_returns_result() { + // creates an inner function and unwraps it + let opts = TestOptions::default(); + let input = "use std::io; +let mut input = String::new(); +io::stdin().read_line(&mut input)?; +Ok::<(), io:Error>(())"; + let expected = "#![allow(unused)] +fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> { +use std::io; +let mut input = String::new(); +io::stdin().read_line(&mut input)?; +Ok::<(), io:Error>(()) +} _inner().unwrap() }" + .to_string(); + let (output, len, _) = make_test(input, None, false, &opts, DEFAULT_EDITION, None); + assert_eq!((output, len), (expected, 2)); +} + +#[test] +fn make_test_named_wrapper() { + // creates an inner function with a specific name + let opts = TestOptions::default(); + let input = "assert_eq!(2+2, 4);"; + let expected = "#![allow(unused)] +fn main() { #[allow(non_snake_case)] fn _doctest_main__some_unique_name() { +assert_eq!(2+2, 4); +} _doctest_main__some_unique_name() }" + .to_string(); + let (output, len, _) = + make_test(input, None, false, &opts, DEFAULT_EDITION, Some("_some_unique_name")); + assert_eq!((output, len), (expected, 2)); +} diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index ee9a6981857..bc9f1cf8806 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -9,7 +9,6 @@ use rustc_hir as hir; crate struct Module<'hir> { crate name: Option<Symbol>, - crate attrs: &'hir [ast::Attribute], crate where_outer: Span, crate where_inner: Span, crate imports: Vec<Import<'hir>>, @@ -23,13 +22,12 @@ crate struct Module<'hir> { } impl Module<'hir> { - crate fn new(name: Option<Symbol>, attrs: &'hir [ast::Attribute]) -> Module<'hir> { + crate fn new(name: Option<Symbol>) -> Module<'hir> { Module { name, id: hir::CRATE_HIR_ID, where_outer: rustc_span::DUMMY_SP, where_inner: rustc_span::DUMMY_SP, - attrs, imports: Vec::new(), mods: Vec::new(), items: Vec::new(), diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 285fabdc372..4d45c8866a7 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -3,12 +3,12 @@ use crate::clean::*; crate struct StripItem(pub Item); impl StripItem { - crate fn strip(self) -> Option<Item> { + crate fn strip(self) -> Item { match self.0 { - Item { kind: StrippedItem(..), .. } => Some(self.0), + Item { kind: box StrippedItem(..), .. } => self.0, mut i => { - i.kind = StrippedItem(box i.kind); - Some(i) + i.kind = box StrippedItem(i.kind); + i } } } @@ -61,7 +61,7 @@ crate trait DocFolder: Sized { j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect(); j.fields_stripped |= num_fields != j.fields.len() || j.fields.iter().any(|f| f.is_stripped()); - VariantItem(Variant { kind: VariantKind::Struct(j), ..i2 }) + VariantItem(Variant { kind: VariantKind::Struct(j) }) } _ => VariantItem(i2), } @@ -72,9 +72,9 @@ crate trait DocFolder: Sized { /// don't override! fn fold_item_recur(&mut self, mut item: Item) -> Item { - item.kind = match item.kind { + item.kind = box match *item.kind { StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)), - _ => self.fold_inner_recur(item.kind), + _ => self.fold_inner_recur(*item.kind), }; item } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 77a3e9fa954..c1f8b12cac4 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -219,7 +219,7 @@ impl DocFolder for Cache { // If this is a stripped module, // we don't want it or its children in the search index. - let orig_stripped_mod = match item.kind { + let orig_stripped_mod = match *item.kind { clean::StrippedItem(box clean::ModuleItem(..)) => { mem::replace(&mut self.stripped_mod, true) } @@ -228,7 +228,7 @@ impl DocFolder for Cache { // If the impl is from a masked crate or references something from a // masked crate then remove it completely. - if let clean::ImplItem(ref i) = item.kind { + if let clean::ImplItem(ref i) = *item.kind { if self.masked_crates.contains(&item.def_id.krate) || i.trait_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) || i.for_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) @@ -239,12 +239,12 @@ impl DocFolder for Cache { // Propagate a trait method's documentation to all implementors of the // trait. - if let clean::TraitItem(ref t) = item.kind { + if let clean::TraitItem(ref t) = *item.kind { self.traits.entry(item.def_id).or_insert_with(|| t.clone()); } // Collect all the implementors of traits. - if let clean::ImplItem(ref i) = item.kind { + if let clean::ImplItem(ref i) = *item.kind { if let Some(did) = i.trait_.def_id() { if i.blanket_impl.is_none() { self.implementors @@ -257,7 +257,7 @@ impl DocFolder for Cache { // Index this method for searching later on. if let Some(ref s) = item.name { - let (parent, is_inherent_impl_item) = match item.kind { + let (parent, is_inherent_impl_item) = match *item.kind { clean::StrippedItem(..) => ((None, None), false), clean::AssocConstItem(..) | clean::TypedefItem(_, true) if self.parent_is_trait_impl => @@ -316,7 +316,7 @@ impl DocFolder for Cache { path: path.join("::"), desc: item .doc_value() - .map_or_else(|| String::new(), short_markdown_summary), + .map_or_else(String::new, |x| short_markdown_summary(&x.as_str())), parent, parent_idx: None, search_type: get_index_search_type(&item), @@ -348,7 +348,7 @@ impl DocFolder for Cache { _ => false, }; - match item.kind { + match *item.kind { clean::StructItem(..) | clean::EnumItem(..) | clean::TypedefItem(..) @@ -387,7 +387,7 @@ impl DocFolder for Cache { // Maintain the parent stack let orig_parent_is_trait_impl = self.parent_is_trait_impl; - let parent_pushed = match item.kind { + let parent_pushed = match *item.kind { clean::TraitItem(..) | clean::EnumItem(..) | clean::ForeignTypeItem @@ -425,38 +425,33 @@ impl DocFolder for Cache { // Once we've recursively found all the generics, hoard off all the // implementations elsewhere. let item = self.fold_item_recur(item); - let ret = if let clean::Item { kind: clean::ImplItem(_), .. } = item { + let ret = if let clean::Item { kind: box clean::ImplItem(ref i), .. } = item { // 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(); - if let clean::Item { kind: clean::ImplItem(ref i), .. } = item { - match i.for_ { - clean::ResolvedPath { did, .. } - | clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => { - dids.insert(did); - } - ref t => { - let did = t - .primitive_type() - .and_then(|t| self.primitive_locations.get(&t).cloned()); + match i.for_ { + clean::ResolvedPath { did, .. } + | clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => { + dids.insert(did); + } + ref t => { + let did = + t.primitive_type().and_then(|t| self.primitive_locations.get(&t).cloned()); - if let Some(did) = did { - dids.insert(did); - } + if let Some(did) = did { + dids.insert(did); } } + } - if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) { - for bound in generics { - if let Some(did) = bound.def_id() { - dids.insert(did); - } + if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) { + for bound in generics { + if let Some(did) = bound.def_id() { + dids.insert(did); } } - } else { - unreachable!() - }; + } let impl_item = Impl { impl_item: item }; if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) { for did in dids { diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index af512e37460..ad51adf2fe3 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -60,7 +60,7 @@ impl Serialize for ItemType { impl<'a> From<&'a clean::Item> for ItemType { fn from(item: &'a clean::Item) -> ItemType { - let kind = match item.kind { + let kind = match *item.kind { clean::StrippedItem(box ref item) => item, ref kind => kind, }; diff --git a/src/librustdoc/formats/mod.rs b/src/librustdoc/formats/mod.rs index 55fd4948f45..58b9f5fbf0f 100644 --- a/src/librustdoc/formats/mod.rs +++ b/src/librustdoc/formats/mod.rs @@ -32,7 +32,7 @@ crate struct Impl { impl Impl { crate fn inner_impl(&self) -> &clean::Impl { - match self.impl_item.kind { + match *self.impl_item.kind { clean::ImplItem(ref impl_) => impl_, _ => panic!("non-impl item found in impl"), } diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index fbbd3c1ccf5..e84a9853d9b 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -89,7 +89,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( } cx.mod_item_in(&item, &name, &cache)?; - let module = match item.kind { + let module = match *item.kind { clean::StrippedItem(box clean::ModuleItem(m)) | clean::ModuleItem(m) => m, _ => unreachable!(), }; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 7b0b219570b..6eeb7ad82c0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -15,7 +15,7 @@ use rustc_middle::ty::TyCtxt; use rustc_span::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_target::spec::abi::Abi; -use crate::clean::{self, PrimitiveType}; +use crate::clean::{self, utils::find_nearest_parent_module, PrimitiveType}; use crate::formats::cache::cache; use crate::formats::item_type::ItemType; use crate::html::escape::Escape; @@ -245,7 +245,7 @@ impl<'a> fmt::Display for WhereClause<'a> { } match pred { - &clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => { + clean::WherePredicate::BoundPredicate { ty, bounds } => { let bounds = bounds; if f.alternate() { clause.push_str(&format!( @@ -261,7 +261,7 @@ impl<'a> fmt::Display for WhereClause<'a> { )); } } - &clean::WherePredicate::RegionPredicate { ref lifetime, ref bounds } => { + clean::WherePredicate::RegionPredicate { lifetime, bounds } => { clause.push_str(&format!( "{}: {}", lifetime.print(), @@ -272,7 +272,7 @@ impl<'a> fmt::Display for WhereClause<'a> { .join(" + ") )); } - &clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => { + clean::WherePredicate::EqPredicate { lhs, rhs } => { if f.alternate() { clause.push_str(&format!("{:#} == {:#}", lhs.print(), rhs.print())); } else { @@ -376,8 +376,8 @@ impl clean::GenericBound { impl clean::GenericArgs { fn print(&self) -> impl fmt::Display + '_ { display_fn(move |f| { - match *self { - clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { + match self { + clean::GenericArgs::AngleBracketed { args, bindings } => { if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; @@ -414,7 +414,7 @@ impl clean::GenericArgs { } } } - clean::GenericArgs::Parenthesized { ref inputs, ref output } => { + clean::GenericArgs::Parenthesized { inputs, output } => { f.write_str("(")?; let mut comma = false; for ty in inputs { @@ -501,7 +501,7 @@ crate fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> { }; for component in &fqp[..fqp.len() - 1] { url.push_str(component); - url.push_str("/"); + url.push('/'); } match shortty { ItemType::Module => { @@ -510,7 +510,7 @@ crate fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> { } _ => { url.push_str(shortty.as_str()); - url.push_str("."); + url.push('.'); url.push_str(fqp.last().unwrap()); url.push_str(".html"); } @@ -1021,7 +1021,7 @@ impl Function<'_> { } else { if i > 0 { args.push_str(" <br>"); - args_plain.push_str(" "); + args_plain.push(' '); } if !input.name.is_empty() { args.push_str(&format!("{}: ", input.name)); @@ -1085,32 +1085,54 @@ impl Function<'_> { } impl clean::Visibility { - crate fn print_with_space<'tcx>(self, tcx: TyCtxt<'tcx>) -> impl fmt::Display + 'tcx { + crate fn print_with_space<'tcx>( + self, + tcx: TyCtxt<'tcx>, + item_did: DefId, + ) -> impl fmt::Display + 'tcx { use rustc_span::symbol::kw; display_fn(move |f| match self { clean::Public => f.write_str("pub "), clean::Inherited => Ok(()), - clean::Visibility::Restricted(did) if did.index == CRATE_DEF_INDEX => { - write!(f, "pub(crate) ") - } - clean::Visibility::Restricted(did) => { - f.write_str("pub(")?; - let path = tcx.def_path(did); - debug!("path={:?}", path); - let first_name = - path.data[0].data.get_opt_name().expect("modules are always named"); - if path.data.len() != 1 || (first_name != kw::SelfLower && first_name != kw::Super) + + clean::Visibility::Restricted(vis_did) => { + // FIXME(camelid): This may not work correctly if `item_did` is a module. + // However, rustdoc currently never displays a module's + // visibility, so it shouldn't matter. + let parent_module = find_nearest_parent_module(tcx, item_did); + + if vis_did.index == CRATE_DEF_INDEX { + write!(f, "pub(crate) ") + } else if parent_module == Some(vis_did) { + // `pub(in foo)` where `foo` is the parent module + // is the same as no visibility modifier + Ok(()) + } else if parent_module + .map(|parent| find_nearest_parent_module(tcx, parent)) + .flatten() + == Some(vis_did) { - f.write_str("in ")?; - } - // modified from `resolved_path()` to work with `DefPathData` - let last_name = path.data.last().unwrap().data.get_opt_name().unwrap(); - for seg in &path.data[..path.data.len() - 1] { - write!(f, "{}::", seg.data.get_opt_name().unwrap())?; + write!(f, "pub(super) ") + } else { + f.write_str("pub(")?; + let path = tcx.def_path(vis_did); + debug!("path={:?}", path); + let first_name = + path.data[0].data.get_opt_name().expect("modules are always named"); + if path.data.len() != 1 + || (first_name != kw::SelfLower && first_name != kw::Super) + { + f.write_str("in ")?; + } + // modified from `resolved_path()` to work with `DefPathData` + let last_name = path.data.last().unwrap().data.get_opt_name().unwrap(); + for seg in &path.data[..path.data.len() - 1] { + write!(f, "{}::", seg.data.get_opt_name().unwrap())?; + } + let path = anchor(vis_did, &last_name.as_str()).to_string(); + write!(f, "{}) ", path) } - let path = anchor(did, &last_name.as_str()).to_string(); - write!(f, "{}) ", path) } }) } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 1cbfbf50dd7..d21998bb8cf 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -11,7 +11,8 @@ use std::fmt::{Display, Write}; use std::iter::Peekable; use rustc_lexer::{LiteralKind, TokenKind}; -use rustc_span::symbol::Ident; +use rustc_span::edition::Edition; +use rustc_span::symbol::Symbol; use rustc_span::with_default_session_globals; /// Highlights `src`, returning the HTML output. @@ -19,22 +20,27 @@ crate fn render_with_highlighting( src: String, class: Option<&str>, playground_button: Option<&str>, - tooltip: Option<(&str, &str)>, + tooltip: Option<(Option<Edition>, &str)>, + edition: Edition, ) -> String { debug!("highlighting: ================\n{}\n==============", src); let mut out = String::with_capacity(src.len()); - if let Some((tooltip, class)) = tooltip { + if let Some((edition_info, class)) = tooltip { write!( out, - "<div class='information'><div class='tooltip {}'>ⓘ<span \ - class='tooltiptext'>{}</span></div></div>", - class, tooltip + "<div class='information'><div class='tooltip {}'{}>ⓘ</div></div>", + class, + if let Some(edition_info) = edition_info { + format!(" data-edition=\"{}\"", edition_info) + } else { + String::new() + }, ) .unwrap(); } write_header(&mut out, class); - write_code(&mut out, &src); + write_code(&mut out, &src, edition); write_footer(&mut out, playground_button); out @@ -45,10 +51,10 @@ fn write_header(out: &mut String, class: Option<&str>) { .unwrap() } -fn write_code(out: &mut String, src: &str) { +fn write_code(out: &mut String, src: &str, edition: Edition) { // This replace allows to fix how the code source with DOS backline characters is displayed. let src = src.replace("\r\n", "\n"); - Classifier::new(&src).highlight(&mut |highlight| { + Classifier::new(&src, edition).highlight(&mut |highlight| { match highlight { Highlight::Token { text, class } => string(out, Escape(text), class), Highlight::EnterSpan { class } => enter_span(out, class), @@ -139,12 +145,19 @@ struct Classifier<'a> { in_attribute: bool, in_macro: bool, in_macro_nonterminal: bool, + edition: Edition, } impl<'a> Classifier<'a> { - fn new(src: &str) -> Classifier<'_> { + fn new(src: &str, edition: Edition) -> Classifier<'_> { let tokens = TokenIter { src }.peekable(); - Classifier { tokens, in_attribute: false, in_macro: false, in_macro_nonterminal: false } + Classifier { + tokens, + in_attribute: false, + in_macro: false, + in_macro_nonterminal: false, + edition, + } } /// Exhausts the `Classifier` writing the output into `sink`. @@ -296,7 +309,7 @@ impl<'a> Classifier<'a> { "Option" | "Result" => Class::PreludeTy, "Some" | "None" | "Ok" | "Err" => Class::PreludeVal, // Keywords are also included in the identifier set. - _ if Ident::from_str(text).is_reserved() => Class::KeyWord, + _ if Symbol::intern(text).is_reserved(|| self.edition) => Class::KeyWord, _ if self.in_macro_nonterminal => { self.in_macro_nonterminal = false; Class::MacroNonTerminal diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs index f57f52d6f08..f97c8a7ab71 100644 --- a/src/librustdoc/html/highlight/tests.rs +++ b/src/librustdoc/html/highlight/tests.rs @@ -1,5 +1,6 @@ use super::write_code; use expect_test::expect_file; +use rustc_span::edition::Edition; const STYLE: &str = r#" <style> @@ -18,7 +19,7 @@ fn test_html_highlighting() { let src = include_str!("fixtures/sample.rs"); let html = { let mut out = String::new(); - write_code(&mut out, src); + write_code(&mut out, src, Edition::Edition2018); format!("{}<pre><code>{}</code></pre>\n", STYLE, out) }; expect_file!["fixtures/sample.html"].assert_eq(&html); @@ -30,6 +31,6 @@ fn test_dos_backline() { println!(\"foo\");\r\n\ }\r\n"; let mut html = String::new(); - write_code(&mut html, src); + write_code(&mut html, src, Edition::Edition2018); expect_file!["fixtures/dos_line.html"].assert_eq(&html); } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 6261e843d23..336249e3afb 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -25,6 +25,7 @@ use rustc_session::lint; use rustc_span::edition::Edition; use rustc_span::Span; use std::borrow::Cow; +use std::cell::RefCell; use std::collections::VecDeque; use std::default::Default; use std::fmt::Write; @@ -36,7 +37,9 @@ use crate::doctest; use crate::html::highlight; use crate::html::toc::TocBuilder; -use pulldown_cmark::{html, BrokenLink, CodeBlockKind, CowStr, Event, Options, Parser, Tag}; +use pulldown_cmark::{ + html, BrokenLink, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag, +}; #[cfg(test)] mod tests; @@ -248,7 +251,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { .join("\n"); let krate = krate.as_ref().map(|s| &**s); let (test, _, _) = - doctest::make_test(&test, krate, false, &Default::default(), edition); + doctest::make_test(&test, krate, false, &Default::default(), edition, None); let channel = if test.contains("#![feature(") { "&version=nightly" } else { "" }; let edition_string = format!("&edition={}", edition); @@ -284,60 +287,28 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { }); let tooltip = if ignore != Ignore::None { - Some(("This example is not tested".to_owned(), "ignore")) + Some((None, "ignore")) } else if compile_fail { - Some(("This example deliberately fails to compile".to_owned(), "compile_fail")) + Some((None, "compile_fail")) } else if should_panic { - Some(("This example panics".to_owned(), "should_panic")) + Some((None, "should_panic")) } else if explicit_edition { - Some((format!("This code runs with edition {}", edition), "edition")) + Some((Some(edition), "edition")) } else { None }; - if let Some((s1, s2)) = tooltip { - s.push_str(&highlight::render_with_highlighting( - text, - Some(&format!( - "rust-example-rendered{}", - if ignore != Ignore::None { - " ignore" - } else if compile_fail { - " compile_fail" - } else if should_panic { - " should_panic" - } else if explicit_edition { - " edition " - } else { - "" - } - )), - playground_button.as_deref(), - Some((s1.as_str(), s2)), - )); - Some(Event::Html(s.into())) - } else { - s.push_str(&highlight::render_with_highlighting( - text, - Some(&format!( - "rust-example-rendered{}", - if ignore != Ignore::None { - " ignore" - } else if compile_fail { - " compile_fail" - } else if should_panic { - " should_panic" - } else if explicit_edition { - " edition " - } else { - "" - } - )), - playground_button.as_deref(), - None, - )); - Some(Event::Html(s.into())) - } + s.push_str(&highlight::render_with_highlighting( + text, + Some(&format!( + "rust-example-rendered{}", + if let Some((_, class)) = tooltip { format!(" {}", class) } else { String::new() } + )), + playground_button.as_deref(), + tooltip, + edition, + )); + Some(Event::Html(s.into())) } } @@ -358,8 +329,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, I> { type Item = Event<'a>; fn next(&mut self) -> Option<Self::Item> { - use pulldown_cmark::LinkType; - let mut event = self.inner.next(); // Replace intra-doc links and remove disambiguators from shortcut links (`[fn@f]`). @@ -446,11 +415,13 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, I> { } } +type SpannedEvent<'a> = (Event<'a>, Range<usize>); + /// Make headings links with anchor IDs and build up TOC. struct HeadingLinks<'a, 'b, 'ids, I> { inner: I, toc: Option<&'b mut TocBuilder>, - buf: VecDeque<(Event<'a>, Range<usize>)>, + buf: VecDeque<SpannedEvent<'a>>, id_map: &'ids mut IdMap, } @@ -460,10 +431,10 @@ impl<'a, 'b, 'ids, I> HeadingLinks<'a, 'b, 'ids, I> { } } -impl<'a, 'b, 'ids, I: Iterator<Item = (Event<'a>, Range<usize>)>> Iterator +impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator for HeadingLinks<'a, 'b, 'ids, I> { - type Item = (Event<'a>, Range<usize>); + type Item = SpannedEvent<'a>; fn next(&mut self) -> Option<Self::Item> { if let Some(e) = self.buf.pop_front() { @@ -521,15 +492,10 @@ impl<'a, I: Iterator<Item = Event<'a>>> SummaryLine<'a, I> { } fn check_if_allowed_tag(t: &Tag<'_>) -> bool { - match *t { - Tag::Paragraph - | Tag::Item - | Tag::Emphasis - | Tag::Strong - | Tag::Link(..) - | Tag::BlockQuote => true, - _ => false, - } + matches!( + t, + Tag::Paragraph | Tag::Item | Tag::Emphasis | Tag::Strong | Tag::Link(..) | Tag::BlockQuote + ) } impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> { @@ -592,8 +558,8 @@ impl<'a, I> Footnotes<'a, I> { } } -impl<'a, I: Iterator<Item = (Event<'a>, Range<usize>)>> Iterator for Footnotes<'a, I> { - type Item = (Event<'a>, Range<usize>); +impl<'a, I: Iterator<Item = SpannedEvent<'a>>> Iterator for Footnotes<'a, I> { + type Item = SpannedEvent<'a>; fn next(&mut self) -> Option<Self::Item> { loop { @@ -1059,7 +1025,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) fn push(s: &mut String, text_length: &mut usize, text: &str) { s.push_str(text); *text_length += text.len(); - }; + } 'outer: for event in Parser::new_ext(md, summary_opts()) { match &event { @@ -1157,51 +1123,75 @@ crate fn plain_text_summary(md: &str) -> String { s } -crate fn markdown_links(md: &str) -> Vec<(String, Range<usize>)> { +crate struct MarkdownLink { + pub kind: LinkType, + pub link: String, + pub range: Range<usize>, +} + +crate fn markdown_links(md: &str) -> Vec<MarkdownLink> { if md.is_empty() { return vec![]; } - let mut links = vec![]; - // Used to avoid mutable borrow issues in the `push` closure - // Probably it would be more efficient to use a `RefCell` but it doesn't seem worth the churn. - let mut shortcut_links = vec![]; - - let span_for_link = |link: &str, span: Range<usize>| { - // Pulldown includes the `[]` as well as the URL. Only highlight the relevant span. - // NOTE: uses `rfind` in case the title and url are the same: `[Ok][Ok]` - match md[span.clone()].rfind(link) { - Some(start) => { - let start = span.start + start; - start..start + link.len() - } - // This can happen for things other than intra-doc links, like `#1` expanded to `https://github.com/rust-lang/rust/issues/1`. - None => span, + let links = RefCell::new(vec![]); + + // FIXME: remove this function once pulldown_cmark can provide spans for link definitions. + let locate = |s: &str, fallback: Range<usize>| unsafe { + let s_start = s.as_ptr(); + let s_end = s_start.add(s.len()); + let md_start = md.as_ptr(); + let md_end = md_start.add(md.len()); + if md_start <= s_start && s_end <= md_end { + let start = s_start.offset_from(md_start) as usize; + let end = s_end.offset_from(md_start) as usize; + start..end + } else { + fallback } }; + + let span_for_link = |link: &CowStr<'_>, span: Range<usize>| { + // For diagnostics, we want to underline the link's definition but `span` will point at + // where the link is used. This is a problem for reference-style links, where the definition + // is separate from the usage. + match link { + // `Borrowed` variant means the string (the link's destination) may come directly from + // the markdown text and we can locate the original link destination. + // NOTE: LinkReplacer also provides `Borrowed` but possibly from other sources, + // so `locate()` can fall back to use `span`. + CowStr::Borrowed(s) => locate(s, span), + + // For anything else, we can only use the provided range. + CowStr::Boxed(_) | CowStr::Inlined(_) => span, + } + }; + let mut push = |link: BrokenLink<'_>| { - let span = span_for_link(link.reference, link.span); - shortcut_links.push((link.reference.to_owned(), span)); + let span = span_for_link(&CowStr::Borrowed(link.reference), link.span); + links.borrow_mut().push(MarkdownLink { + kind: LinkType::ShortcutUnknown, + link: link.reference.to_owned(), + range: span, + }); None }; - let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)); + let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter(); // There's no need to thread an IdMap through to here because // the IDs generated aren't going to be emitted anywhere. let mut ids = IdMap::new(); - let iter = Footnotes::new(HeadingLinks::new(p.into_offset_iter(), None, &mut ids)); + let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids)); for ev in iter { - if let Event::Start(Tag::Link(_, dest, _)) = ev.0 { + if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 { debug!("found link: {}", dest); let span = span_for_link(&dest, ev.1); - links.push((dest.into_string(), span)); + links.borrow_mut().push(MarkdownLink { kind, link: dest.into_string(), range: span }); } } - links.append(&mut shortcut_links); - - links + links.into_inner() } #[derive(Debug)] @@ -1213,6 +1203,7 @@ crate struct RustCodeBlock { crate code: Range<usize>, crate is_fenced: bool, crate syntax: Option<String>, + crate is_ignore: bool, } /// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or @@ -1228,7 +1219,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC while let Some((event, offset)) = p.next() { if let Event::Start(Tag::CodeBlock(syntax)) = event { - let (syntax, code_start, code_end, range, is_fenced) = match syntax { + let (syntax, code_start, code_end, range, is_fenced, is_ignore) = match syntax { CodeBlockKind::Fenced(syntax) => { let syntax = syntax.as_ref(); let lang_string = if syntax.is_empty() { @@ -1239,6 +1230,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC if !lang_string.rust { continue; } + let is_ignore = lang_string.ignore != Ignore::None; let syntax = if syntax.is_empty() { None } else { Some(syntax.to_owned()) }; let (code_start, mut code_end) = match p.next() { Some((Event::Text(_), offset)) => (offset.start, offset.end), @@ -1249,6 +1241,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC range: offset, code, syntax, + is_ignore, }); continue; } @@ -1259,6 +1252,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC range: offset, code, syntax, + is_ignore, }); continue; } @@ -1266,7 +1260,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC while let Some((Event::Text(_), offset)) = p.next() { code_end = offset.end; } - (syntax, code_start, code_end, offset, true) + (syntax, code_start, code_end, offset, true, is_ignore) } CodeBlockKind::Indented => { // The ending of the offset goes too far sometime so we reduce it by one in @@ -1278,9 +1272,10 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC offset.end, Range { start: offset.start, end: offset.end - 1 }, false, + false, ) } else { - (None, offset.start, offset.end, offset, false) + (None, offset.start, offset.end, offset, false, false) } } }; @@ -1290,6 +1285,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC range, code: Range { start: code_start, end: code_end }, syntax, + is_ignore, }); } } diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index 25fe31aab59..497cbbb4250 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -78,7 +78,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { ty: item.type_(), name: item.name.unwrap().to_string(), path: fqp[..fqp.len() - 1].join("::"), - desc: item.doc_value().map_or_else(|| String::new(), short_markdown_summary), + desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)), parent: Some(did), parent_idx: None, search_type: get_index_search_type(&item), @@ -127,7 +127,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { let crate_doc = krate .module .as_ref() - .map(|module| module.doc_value().map_or_else(|| String::new(), short_markdown_summary)) + .map(|module| module.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s))) .unwrap_or_default(); #[derive(Serialize)] @@ -165,7 +165,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { } crate fn get_index_search_type(item: &clean::Item) -> Option<IndexItemFunctionType> { - let (all_types, ret_types) = match item.kind { + let (all_types, ret_types) = match *item.kind { clean::FunctionItem(ref f) => (&f.all_types, &f.ret_types), clean::MethodItem(ref m, _) => (&m.all_types, &m.ret_types), clean::TyMethodItem(ref m) => (&m.all_types, &m.ret_types), diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 97e7c38ecb8..f7eb136a754 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -30,7 +30,6 @@ crate mod cache; #[cfg(test)] mod tests; -use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::cmp::Ordering; use std::collections::{BTreeMap, VecDeque}; @@ -198,12 +197,8 @@ impl SharedContext<'_> { /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the /// `collapsed_doc_value` of the given item. - crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<Cow<'a, str>> { - if self.collapsed { - item.collapsed_doc_value().map(|s| s.into()) - } else { - item.doc_value().map(|s| s.into()) - } + crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> { + if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() } } } @@ -538,7 +533,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> { let final_file = self.dst.join(&*krate.name.as_str()).join("all.html"); let settings_file = self.dst.join("settings.html"); - let crate_name = krate.name.clone(); + let crate_name = krate.name; let mut root_path = self.dst.to_str().expect("invalid path").to_owned(); if !root_path.ends_with('/') { @@ -633,7 +628,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { // Render sidebar-items.js used throughout this module. if !self.render_redirect_pages { - let module = match item.kind { + let module = match *item.kind { clean::StrippedItem(box clean::ModuleItem(ref m)) | clean::ModuleItem(ref m) => m, _ => unreachable!(), }; @@ -979,7 +974,7 @@ themePicker.onblur = handleThemeButtonsBlur; .iter() .map(|s| format!("\"{}\"", s.to_str().expect("invalid osstring conversion"))) .collect::<Vec<_>>(); - files.sort_unstable_by(|a, b| a.cmp(b)); + files.sort_unstable(); let subs = subs.iter().map(|s| s.to_json_string()).collect::<Vec<_>>().join(","); let dirs = if subs.is_empty() { String::new() } else { format!(",\"dirs\":[{}]", subs) }; @@ -1428,7 +1423,7 @@ impl Setting { .map(|opt| format!( "<option value=\"{}\" {}>{}</option>", opt.0, - if &opt.0 == default_value { "selected" } else { "" }, + if opt.0 == default_value { "selected" } else { "" }, opt.1, )) .collect::<String>(), @@ -1595,7 +1590,7 @@ impl Context<'_> { if let Some(&(ref names, ty)) = cache.paths.get(&it.def_id) { for name in &names[..names.len() - 1] { url.push_str(name); - url.push_str("/"); + url.push('/'); } url.push_str(&item_path(ty, names.last().unwrap())); layout::redirect(&url) @@ -1622,7 +1617,7 @@ impl Context<'_> { let short = short.to_string(); map.entry(short).or_default().push(( myname, - Some(item.doc_value().map_or_else(|| String::new(), plain_text_summary)), + Some(item.doc_value().map_or_else(String::new, |s| plain_text_summary(&s))), )); } @@ -1739,7 +1734,7 @@ fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, cache: &Ca write!(buf, "</span>"); // out-of-band write!(buf, "<span class=\"in-band\">"); - let name = match item.kind { + let name = match *item.kind { clean::ModuleItem(ref m) => { if m.is_crate { "Crate " @@ -1788,7 +1783,7 @@ fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, cache: &Ca write!(buf, "</span></h1>"); // in-band - match item.kind { + match *item.kind { clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items), clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) => { item_function(buf, cx, item, f) @@ -1880,7 +1875,7 @@ fn document_short( return; } if let Some(s) = item.doc_value() { - let mut summary_html = MarkdownSummaryLine(s, &item.links()).into_string(); + let mut summary_html = MarkdownSummaryLine(&s, &item.links()).into_string(); if s.contains('\n') { let link = format!(r#" <a href="{}">Read more</a>"#, naive_assoc_href(item, link)); @@ -2086,8 +2081,8 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl (true, false) => return Ordering::Greater, } } - let lhs = i1.name.unwrap_or(kw::Invalid).as_str(); - let rhs = i2.name.unwrap_or(kw::Invalid).as_str(); + let lhs = i1.name.unwrap_or(kw::Empty).as_str(); + let rhs = i2.name.unwrap_or(kw::Empty).as_str(); compare_names(&lhs, &rhs) } @@ -2149,7 +2144,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl ); } - match myitem.kind { + match *myitem.kind { clean::ExternCrateItem(ref name, ref src) => { use crate::html::format::anchor; @@ -2157,14 +2152,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl Some(ref src) => write!( w, "<tr><td><code>{}extern crate {} as {};", - myitem.visibility.print_with_space(cx.tcx()), + myitem.visibility.print_with_space(cx.tcx(), myitem.def_id), anchor(myitem.def_id, &*src.as_str()), name ), None => write!( w, "<tr><td><code>{}extern crate {};", - myitem.visibility.print_with_space(cx.tcx()), + myitem.visibility.print_with_space(cx.tcx(), myitem.def_id), anchor(myitem.def_id, &*name.as_str()) ), } @@ -2175,7 +2170,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl write!( w, "<tr><td><code>{}{}</code></td></tr>", - myitem.visibility.print_with_space(cx.tcx()), + myitem.visibility.print_with_space(cx.tcx(), myitem.def_id), import.print() ); } @@ -2185,7 +2180,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl continue; } - let unsafety_flag = match myitem.kind { + let unsafety_flag = match *myitem.kind { clean::FunctionItem(ref func) | clean::ForeignFunctionItem(ref func) if func.header.unsafety == hir::Unsafety::Unsafe => { @@ -2197,7 +2192,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let stab = myitem.stability_class(cx.tcx()); let add = if stab.is_some() { " " } else { "" }; - let doc_value = myitem.doc_value().unwrap_or(""); + let doc_value = myitem.doc_value().unwrap_or_default(); write!( w, "<tr class=\"{stab}{add}module-item\">\ @@ -2207,7 +2202,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl </tr>", name = *myitem.name.as_ref().unwrap(), stab_tags = extra_info_tags(myitem, item, cx.tcx()), - docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(), + docs = MarkdownSummaryLine(&doc_value, &myitem.links()).into_string(), class = myitem.type_(), add = add, stab = stab.unwrap_or_else(String::new), @@ -2308,7 +2303,7 @@ fn short_item_info( let since = &since.as_str(); if !stability::deprecation_in_effect(is_since_rustc_version, Some(since)) { if *since == "TBD" { - format!("Deprecating in a future Rust version") + String::from("Deprecating in a future Rust version") } else { format!("Deprecating in {}", Escape(since)) } @@ -2392,7 +2387,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean:: write!( w, "{vis}const {name}: {typ}", - vis = it.visibility.print_with_space(cx.tcx()), + vis = it.visibility.print_with_space(cx.tcx(), it.def_id), name = it.name.as_ref().unwrap(), typ = c.type_.print(), ); @@ -2426,7 +2421,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St write!( w, "{vis}static {mutability}{name}: {typ}</pre>", - vis = it.visibility.print_with_space(cx.tcx()), + vis = it.visibility.print_with_space(cx.tcx(), it.def_id), mutability = s.mutability.print_with_space(), name = it.name.as_ref().unwrap(), typ = s.type_.print() @@ -2437,7 +2432,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::Function) { let header_len = format!( "{}{}{}{}{:#}fn {}{:#}", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), f.header.constness.print_with_space(), f.header.asyncness.print_with_space(), f.header.unsafety.print_with_space(), @@ -2452,7 +2447,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean:: w, "{vis}{constness}{asyncness}{unsafety}{abi}fn \ {name}{generics}{decl}{spotlight}{where_clause}</pre>", - vis = it.visibility.print_with_space(cx.tcx()), + vis = it.visibility.print_with_space(cx.tcx(), it.def_id), constness = f.header.constness.print_with_space(), asyncness = f.header.asyncness.print_with_space(), unsafety = f.header.unsafety.print_with_space(), @@ -2578,7 +2573,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra write!( w, "{}{}{}trait {}{}{}", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), t.unsafety.print_with_space(), if t.is_auto { "auto " } else { "" }, it.name.as_ref().unwrap(), @@ -2624,7 +2619,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra } for (pos, m) in provided.iter().enumerate() { render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait, cx); - match m.kind { + match *m.kind { clean::MethodItem(ref inner, _) if !inner.generics.where_predicates.is_empty() => { @@ -2896,7 +2891,7 @@ fn assoc_const( w, "{}{}const <a href=\"{}\" class=\"constant\"><b>{}</b></a>: {}", extra, - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), naive_assoc_href(it, link), it.name.as_ref().unwrap(), ty.print() @@ -3015,7 +3010,7 @@ fn render_assoc_item( }; let mut header_len = format!( "{}{}{}{}{}{:#}fn {}{:#}", - meth.visibility.print_with_space(cx.tcx()), + meth.visibility.print_with_space(cx.tcx(), meth.def_id), header.constness.print_with_space(), header.asyncness.print_with_space(), header.unsafety.print_with_space(), @@ -3037,7 +3032,7 @@ fn render_assoc_item( "{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\ {generics}{decl}{spotlight}{where_clause}", if parent == ItemType::Trait { " " } else { "" }, - meth.visibility.print_with_space(cx.tcx()), + meth.visibility.print_with_space(cx.tcx(), meth.def_id), header.constness.print_with_space(), header.asyncness.print_with_space(), header.unsafety.print_with_space(), @@ -3051,7 +3046,7 @@ fn render_assoc_item( where_clause = WhereClause { gens: g, indent, end_newline } ) } - match item.kind { + match *item.kind { clean::StrippedItem(..) => {} clean::TyMethodItem(ref m) => { method(w, item, m.header, &m.generics, &m.decl, link, parent, cx) @@ -3098,7 +3093,7 @@ fn item_struct( let mut fields = s .fields .iter() - .filter_map(|f| match f.kind { + .filter_map(|f| match *f.kind { clean::StructFieldItem(ref ty) => Some((f, ty)), _ => None, }) @@ -3148,7 +3143,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni let mut fields = s .fields .iter() - .filter_map(|f| match f.kind { + .filter_map(|f| match *f.kind { clean::StructFieldItem(ref ty) => Some((f, ty)), _ => None, }) @@ -3189,7 +3184,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum write!( w, "{}enum {}{}{}", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), it.name.as_ref().unwrap(), e.generics.print(), WhereClause { gens: &e.generics, indent: 0, end_newline: true } @@ -3201,7 +3196,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum for v in &e.variants { write!(w, " "); let name = v.name.as_ref().unwrap(); - match v.kind { + match *v.kind { clean::VariantItem(ref var) => match var.kind { clean::VariantKind::CLike => write!(w, "{}", name), clean::VariantKind::Tuple(ref tys) => { @@ -3251,7 +3246,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum id = id, name = variant.name.as_ref().unwrap() ); - if let clean::VariantItem(ref var) = variant.kind { + if let clean::VariantItem(ref var) = *variant.kind { if let clean::VariantKind::Tuple(ref tys) = var.kind { write!(w, "("); for (i, ty) in tys.iter().enumerate() { @@ -3268,7 +3263,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum document_non_exhaustive(w, variant); use crate::clean::{Variant, VariantKind}; - if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) = variant.kind { + if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) = *variant.kind + { let variant_id = cx.derive_id(format!( "{}.{}.fields", ItemType::Variant, @@ -3282,7 +3278,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum ); for field in &s.fields { use crate::clean::StructFieldItem; - if let StructFieldItem(ref ty) = field.kind { + if let StructFieldItem(ref ty) = *field.kind { let id = cx.derive_id(format!( "variant.{}.field.{}", variant.name.as_ref().unwrap(), @@ -3364,7 +3360,7 @@ fn render_struct( write!( w, "{}{}{}", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), if structhead { "struct " } else { "" }, it.name.as_ref().unwrap() ); @@ -3379,12 +3375,12 @@ fn render_struct( let mut has_visible_fields = false; write!(w, " {{"); for field in fields { - if let clean::StructFieldItem(ref ty) = field.kind { + if let clean::StructFieldItem(ref ty) = *field.kind { write!( w, "\n{} {}{}: {},", tab, - field.visibility.print_with_space(cx.tcx()), + field.visibility.print_with_space(cx.tcx(), field.def_id), field.name.as_ref().unwrap(), ty.print() ); @@ -3410,10 +3406,15 @@ fn render_struct( if i > 0 { write!(w, ", "); } - match field.kind { + match *field.kind { clean::StrippedItem(box clean::StructFieldItem(..)) => write!(w, "_"), clean::StructFieldItem(ref ty) => { - write!(w, "{}{}", field.visibility.print_with_space(cx.tcx()), ty.print()) + write!( + w, + "{}{}", + field.visibility.print_with_space(cx.tcx(), field.def_id), + ty.print() + ) } _ => unreachable!(), } @@ -3446,7 +3447,7 @@ fn render_union( write!( w, "{}{}{}", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), if structhead { "union " } else { "" }, it.name.as_ref().unwrap() ); @@ -3457,11 +3458,11 @@ fn render_union( write!(w, " {{\n{}", tab); for field in fields { - if let clean::StructFieldItem(ref ty) = field.kind { + if let clean::StructFieldItem(ref ty) = *field.kind { write!( w, " {}{}: {},\n{}", - field.visibility.print_with_space(cx.tcx()), + field.visibility.print_with_space(cx.tcx(), field.def_id), field.name.as_ref().unwrap(), ty.print(), tab @@ -3482,7 +3483,7 @@ enum AssocItemLink<'a> { } impl<'a> AssocItemLink<'a> { - fn anchor(&self, id: &'a String) -> Self { + fn anchor(&self, id: &'a str) -> Self { match *self { AssocItemLink::Anchor(_) => AssocItemLink::Anchor(Some(&id)), ref other => *other, @@ -3619,7 +3620,7 @@ fn render_deref_methods( .inner_impl() .items .iter() - .find_map(|item| match item.kind { + .find_map(|item| match *item.kind { clean::TypedefItem(ref t, true) => Some(match *t { clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_), _ => (&t.type_, &t.type_), @@ -3641,7 +3642,7 @@ fn render_deref_methods( } fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool { - let self_type_opt = match item.kind { + let self_type_opt = match *item.kind { clean::MethodItem(ref method, _) => method.decl.self_type(), clean::TyMethodItem(ref method) => method.decl.self_type(), _ => None, @@ -3692,7 +3693,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String { )); let t_did = impl_.trait_.def_id().unwrap(); for it in &impl_.items { - if let clean::TypedefItem(ref tydef, _) = it.kind { + if let clean::TypedefItem(ref tydef, _) = *it.kind { out.push_str("<span class=\"where fmt-newline\"> "); assoc_type( &mut out, @@ -3764,7 +3765,7 @@ fn render_impl( fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute); if show_def_docs { for it in &i.inner_impl().items { - if let clean::TypedefItem(ref tydef, _) = it.kind { + if let clean::TypedefItem(ref tydef, _) = *it.kind { write!(w, "<span class=\"where fmt-newline\"> "); assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None), ""); write!(w, ";</span>"); @@ -3846,7 +3847,7 @@ fn render_impl( } else { (true, " hidden") }; - match item.kind { + match *item.kind { clean::MethodItem(..) | clean::TyMethodItem(_) => { // Only render when the method is not static or we allow static methods if render_method_item { @@ -3966,7 +3967,7 @@ fn render_impl( cache: &Cache, ) { for trait_item in &t.items { - let n = trait_item.name.clone(); + let n = trait_item.name; if i.items.iter().any(|m| m.name == n) { continue; } @@ -4100,7 +4101,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, cache: write!( w, " {}type {};\n}}</pre>", - it.visibility.print_with_space(cx.tcx()), + it.visibility.print_with_space(cx.tcx(), it.def_id), it.name.as_ref().unwrap(), ); @@ -4123,7 +4124,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache: write!( buffer, "<p class=\"location\">{}{}</p>", - match it.kind { + match *it.kind { clean::StructItem(..) => "Struct ", clean::TraitItem(..) => "Trait ", clean::PrimitiveItem(..) => "Primitive Type ", @@ -4163,7 +4164,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache: it.name.as_ref().expect("crates always have a name") ); } - match it.kind { + match *it.kind { clean::StructItem(ref s) => sidebar_struct(buffer, it, s), clean::TraitItem(ref t) => sidebar_trait(buffer, it, t), clean::PrimitiveItem(_) => sidebar_primitive(buffer, it), @@ -4206,7 +4207,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache: ty: \"{ty}\", \ relpath: \"{path}\"\ }};</script>", - name = it.name.unwrap_or(kw::Invalid), + name = it.name.unwrap_or(kw::Empty), ty = it.type_(), path = relpath ); @@ -4302,8 +4303,9 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { .filter(|i| i.inner_impl().trait_.is_some()) .find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did) { + debug!("found Deref: {:?}", impl_); if let Some((target, real_target)) = - impl_.inner_impl().items.iter().find_map(|item| match item.kind { + impl_.inner_impl().items.iter().find_map(|item| match *item.kind { clean::TypedefItem(ref t, true) => Some(match *t { clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_), _ => (&t.type_, &t.type_), @@ -4311,17 +4313,21 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { _ => None, }) { + debug!("found target, real_target: {:?} {:?}", target, real_target); let deref_mut = v .iter() .filter(|i| i.inner_impl().trait_.is_some()) .any(|i| i.inner_impl().trait_.def_id() == c.deref_mut_trait_did); let inner_impl = target .def_id() - .or(target - .primitive_type() - .and_then(|prim| c.primitive_locations.get(&prim).cloned())) + .or_else(|| { + target + .primitive_type() + .and_then(|prim| c.primitive_locations.get(&prim).cloned()) + }) .and_then(|did| c.impls.get(&did)); if let Some(impls) = inner_impl { + debug!("found inner_impl: {:?}", impls); out.push_str("<a class=\"sidebar-title\" href=\"#deref-methods\">"); out.push_str(&format!( "Methods from {}<Target={}>", @@ -4442,7 +4448,7 @@ fn get_id_for_impl_on_foreign_type(for_: &clean::Type, trait_: &clean::Type) -> } fn extract_for_impl_name(item: &clean::Item) -> Option<(String, String)> { - match item.kind { + match *item.kind { clean::ItemKind::ImplItem(ref i) => { if let Some(ref trait_) = i.trait_ { Some(( @@ -4593,7 +4599,7 @@ fn sidebar_typedef(buf: &mut Buffer, it: &clean::Item) { fn get_struct_fields_name(fields: &[clean::Item]) -> String { let mut fields = fields .iter() - .filter(|f| if let clean::StructFieldItem(..) = f.kind { true } else { false }) + .filter(|f| matches!(*f.kind, clean::StructFieldItem(..))) .filter_map(|f| match f.name { Some(ref name) => { Some(format!("<a href=\"#structfield.{name}\">{name}</a>", name = name)) @@ -4747,6 +4753,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac Some("macro"), None, None, + it.source.span().edition(), )) }); document(w, cx, it, None) diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 87934c8a0e5..ac07aeb8bc8 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -8,6 +8,7 @@ use crate::html::layout; use crate::html::render::{SharedContext, BASIC_KEYWORDS}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_session::Session; +use rustc_span::edition::Edition; use rustc_span::source_map::FileName; use std::ffi::OsStr; use std::fs; @@ -132,7 +133,7 @@ impl SourceCollector<'_, '_> { &self.scx.layout, &page, "", - |buf: &mut _| print_src(buf, contents), + |buf: &mut _| print_src(buf, contents, self.scx.edition), &self.scx.style_files, ); self.scx.fs.write(&cur, v.as_bytes())?; @@ -170,7 +171,7 @@ where /// Wrapper struct to render the source code of a file. This will do things like /// adding line numbers to the left-hand side. -fn print_src(buf: &mut Buffer, s: String) { +fn print_src(buf: &mut Buffer, s: String, edition: Edition) { let lines = s.lines().count(); let mut cols = 0; let mut tmp = lines; @@ -183,5 +184,5 @@ fn print_src(buf: &mut Buffer, s: String) { write!(buf, "<span id=\"{0}\">{0:1$}</span>\n", i, cols); } write!(buf, "</pre>"); - write!(buf, "{}", highlight::render_with_highlighting(s, None, None, None)); + write!(buf, "{}", highlight::render_with_highlighting(s, None, None, None, edition)); } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1de4b0016c5..ec8024ffca5 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -493,11 +493,7 @@ function defocusSearchBar() { document.addEventListener("keypress", handleShortcut); document.addEventListener("keydown", handleShortcut); - function resetMouseMoved(ev) { - mouseMovedAfterSearch = true; - } - - document.addEventListener("mousemove", resetMouseMoved); + document.addEventListener("mousemove", function() { mouseMovedAfterSearch = true; }); var handleSourceHighlight = (function() { var prev_line_id = 0; @@ -667,13 +663,7 @@ function defocusSearchBar() { results = {}, results_in_args = {}, results_returned = {}, split = valLower.split("::"); - var length = split.length; - for (var z = 0; z < length; ++z) { - if (split[z] === "") { - split.splice(z, 1); - z -= 1; - } - } + split = split.filter(function(segment) { return segment !== ""; }); function transformResults(results, isType) { var out = []; @@ -2157,14 +2147,14 @@ function defocusSearchBar() { var code = document.createElement("code"); code.innerHTML = struct.text; - var x = code.getElementsByTagName("a"); - var xlength = x.length; - for (var it = 0; it < xlength; it++) { - var href = x[it].getAttribute("href"); + onEachLazy(code.getElementsByTagName("a"), function(elem) { + var href = elem.getAttribute("href"); + if (href && href.indexOf("http") !== 0) { - x[it].setAttribute("href", rootPath + href); + elem.setAttribute("href", rootPath + href); } - } + }); + var display = document.createElement("h3"); addClass(display, "impl"); display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" + @@ -2553,14 +2543,12 @@ function defocusSearchBar() { var hiddenElems = e.getElementsByClassName("hidden"); var needToggle = false; - var hlength = hiddenElems.length; - for (var i = 0; i < hlength; ++i) { - if (hasClass(hiddenElems[i], "content") === false && - hasClass(hiddenElems[i], "docblock") === false) { - needToggle = true; - break; + var needToggle = onEachLazy(e.getElementsByClassName("hidden"), function(hiddenElem) { + if (hasClass(hiddenElem, "content") === false && + hasClass(hiddenElem, "docblock") === false) { + return true; } - } + }); if (needToggle === true) { var inner_toggle = newToggle.cloneNode(true); inner_toggle.onclick = toggleClicked; diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 42e4fa05152..8dad26dced9 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -122,7 +122,9 @@ h3.impl, h3.method, h3.type { h1, h2, h3, h4, .sidebar, a.source, .search-input, .content table td:first-child > a, .collapse-toggle, div.item-list .out-of-band, -#source-sidebar, #sidebar-toggle { +#source-sidebar, #sidebar-toggle, +/* This selector is for the items listed in the "all items" page. */ +#main > ul.docblock > li > a { font-family: "Fira Sans", sans-serif; } @@ -1079,20 +1081,29 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { cursor: pointer; } -.tooltip .tooltiptext { - width: 120px; +.tooltip::after { display: none; text-align: center; padding: 5px 3px 3px 3px; border-radius: 6px; margin-left: 5px; - top: -5px; - left: 105%; - z-index: 10; font-size: 16px; } -.tooltip .tooltiptext::after { +.tooltip.ignore::after { + content: "This example is not tested"; +} +.tooltip.compile_fail::after { + content: "This example deliberately fails to compile"; +} +.tooltip.should_panic::after { + content: "This example panics"; +} +.tooltip.edition::after { + content: "This code runs with edition " attr(data-edition); +} + +.tooltip::before { content: " "; position: absolute; top: 50%; @@ -1100,9 +1111,10 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { margin-top: -5px; border-width: 5px; border-style: solid; + display: none; } -.tooltip:hover .tooltiptext { +.tooltip:hover::before, .tooltip:hover::after { display: inline; } @@ -1400,6 +1412,7 @@ h4 > .notable-traits { .sidebar > .block.version { border-bottom: none; margin-top: 12px; + margin-bottom: 0; } nav.sub { @@ -1570,7 +1583,10 @@ h4 > .notable-traits { height: 73px; } - #main { + /* This is to prevent the search bar from being underneath the <section> + * element following it. + */ + #main, #search { margin-top: 100px; } diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index 76bbe4f6201..fd8153519af 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -388,13 +388,13 @@ pre.ignore:hover, .information:hover + pre.ignore { color: #39AFD7; } -.tooltip .tooltiptext { +.tooltip::after { background-color: #314559; color: #c5c5c5; border: 1px solid #5c6773; } -.tooltip .tooltiptext::after { +.tooltip::before { border-color: transparent #314559 transparent transparent; } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 86ce99284eb..8c7794479a7 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -337,13 +337,13 @@ pre.ignore:hover, .information:hover + pre.ignore { color: #0089ff; } -.tooltip .tooltiptext { +.tooltip::after { background-color: #000; color: #fff; border-color: #000; } -.tooltip .tooltiptext::after { +.tooltip::before { border-color: transparent black transparent transparent; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 997e1f00f85..814043b35ae 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -329,12 +329,12 @@ pre.ignore:hover, .information:hover + pre.ignore { color: #0089ff; } -.tooltip .tooltiptext { +.tooltip::after { background-color: #000; color: #fff; } -.tooltip .tooltiptext::after { +.tooltip::before { border-color: transparent black transparent transparent; } diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index b39a4e179cd..c55f2459a9c 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -132,7 +132,7 @@ impl TocBuilder { } Some(entry) => { sec_number = entry.sec_number.clone(); - sec_number.push_str("."); + sec_number.push('.'); (entry.level, &entry.children) } }; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 3b7ac624ccd..e347f7f8411 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -19,9 +19,9 @@ impl JsonRenderer<'_> { let item_type = ItemType::from(&item); let deprecation = item.deprecation(self.tcx); let clean::Item { source, name, attrs, kind, visibility, def_id } = item; - match kind { + match *kind { clean::StrippedItem(_) => None, - _ => Some(Item { + kind => Some(Item { id: def_id.into(), crate_id: def_id.krate.as_u32(), name: name.map(|sym| sym.to_string()), diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index dc2bc14e7ce..df7ab9b7361 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -178,9 +178,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { cache: &Cache, ) -> Result<(), Error> { use clean::types::ItemKind::*; - if let ModuleItem(m) = &item.kind { + if let ModuleItem(m) = &*item.kind { for item in &m.items { - match &item.kind { + match &*item.kind { // These don't have names so they don't get added to the output by default ImportItem(_) => self.item(item.clone(), cache).unwrap(), ExternCrateItem(_, _) => self.item(item.clone(), cache).unwrap(), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 72f1b817d5d..7ed64c5813f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -17,6 +17,7 @@ #![feature(type_ascription)] #![feature(split_inclusive)] #![feature(str_split_once)] +#![feature(iter_intersperse)] #![recursion_limit = "256"] #[macro_use] @@ -263,13 +264,13 @@ fn opts() -> Vec<RustcOptGroup> { "sort modules by where they appear in the program, rather than alphabetically", ) }), - unstable("default-theme", |o| { + stable("default-theme", |o| { o.optopt( "", "default-theme", "Set the default theme. THEME should be the theme name, generally lowercase. \ If an unknown default theme is specified, the builtin default is used. \ - The set of themes, and the rustdoc built-in default is not stable.", + The set of themes, and the rustdoc built-in default, are not stable.", "THEME", ) }), diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 52f6a97089b..05a3a15adac 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -5,7 +5,7 @@ use crate::html::markdown::{find_testable_code, ErrorCodes}; use crate::passes::doc_test_lints::{should_have_doc_example, Tests}; use crate::passes::Pass; use rustc_lint::builtin::MISSING_DOCS; -use rustc_middle::lint::LintSource; +use rustc_middle::lint::LintLevelSource; use rustc_session::lint; use rustc_span::symbol::sym; use rustc_span::FileName; @@ -187,7 +187,7 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> { impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> { fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> { - match i.kind { + match *i.kind { _ if !i.def_id.is_local() => { // non-local items are skipped because they can be out of the users control, // especially in the case of trait impls, which rustdoc eagerly inlines @@ -235,12 +235,7 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> { let mut tests = Tests { found_tests: 0 }; find_testable_code( - &i.attrs - .doc_strings - .iter() - .map(|d| d.doc.as_str()) - .collect::<Vec<_>>() - .join("\n"), + &i.attrs.collapsed_doc_value().unwrap_or_default(), &mut tests, ErrorCodes::No, false, @@ -254,7 +249,7 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> { // `missing_docs` is allow-by-default, so don't treat this as ignoring the item // unless the user had an explicit `allow` let should_have_docs = - level != lint::Level::Allow || matches!(source, LintSource::Default); + level != lint::Level::Allow || matches!(source, LintLevelSource::Default); debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename); self.items.entry(filename).or_default().count_item( has_docs, diff --git a/src/librustdoc/passes/check_code_block_syntax.rs b/src/librustdoc/passes/check_code_block_syntax.rs index 0c76dc571be..554392c213e 100644 --- a/src/librustdoc/passes/check_code_block_syntax.rs +++ b/src/librustdoc/passes/check_code_block_syntax.rs @@ -51,10 +51,10 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> { let mut diag = if let Some(sp) = super::source_span_for_markdown_range(self.cx, &dox, &code_block.range, &item.attrs) { - let warning_message = if buffer.has_errors { - "could not parse code block as Rust code" + let (warning_message, suggest_using_text) = if buffer.has_errors { + ("could not parse code block as Rust code", true) } else { - "Rust code block is empty" + ("Rust code block is empty", false) }; let mut diag = self.cx.sess().struct_span_warn(sp, warning_message); @@ -67,6 +67,15 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> { String::from("```text"), Applicability::MachineApplicable, ); + } else if suggest_using_text && code_block.is_ignore { + let sp = sp.from_inner(InnerSpan::new(0, 3)); + diag.span_suggestion( + sp, + "`ignore` code blocks require valid Rust code for syntax highlighting. \ + Mark blocks that do not contain Rust code as text", + String::from("```text,"), + Applicability::MachineApplicable, + ); } diag diff --git a/src/librustdoc/passes/collapse_docs.rs b/src/librustdoc/passes/collapse_docs.rs deleted file mode 100644 index e1ba75baa0f..00000000000 --- a/src/librustdoc/passes/collapse_docs.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::clean::{self, DocFragment, DocFragmentKind, Item}; -use crate::core::DocContext; -use crate::fold; -use crate::fold::DocFolder; -use crate::passes::Pass; - -use std::mem::take; - -crate const COLLAPSE_DOCS: Pass = Pass { - name: "collapse-docs", - run: collapse_docs, - description: "concatenates all document attributes into one document attribute", -}; - -crate fn collapse_docs(krate: clean::Crate, _: &DocContext<'_>) -> clean::Crate { - let mut krate = Collapser.fold_crate(krate); - krate.collapsed = true; - krate -} - -struct Collapser; - -impl fold::DocFolder for Collapser { - fn fold_item(&mut self, mut i: Item) -> Option<Item> { - i.attrs.collapse_doc_comments(); - Some(self.fold_item_recur(i)) - } -} - -fn collapse(doc_strings: &mut Vec<DocFragment>) { - let mut docs = vec![]; - let mut last_frag: Option<DocFragment> = None; - - for frag in take(doc_strings) { - if let Some(mut curr_frag) = last_frag.take() { - let curr_kind = &curr_frag.kind; - let new_kind = &frag.kind; - - if matches!(*curr_kind, DocFragmentKind::Include { .. }) - || curr_kind != new_kind - || curr_frag.parent_module != frag.parent_module - { - if *curr_kind == DocFragmentKind::SugaredDoc - || *curr_kind == DocFragmentKind::RawDoc - { - // add a newline for extra padding between segments - curr_frag.doc.push('\n'); - } - docs.push(curr_frag); - last_frag = Some(frag); - } else { - curr_frag.doc.push('\n'); - curr_frag.doc.push_str(&frag.doc); - curr_frag.span = curr_frag.span.to(frag.span); - last_frag = Some(curr_frag); - } - } else { - last_frag = Some(frag); - } - } - - if let Some(frag) = last_frag.take() { - docs.push(frag); - } - *doc_strings = docs; -} - -impl clean::Attributes { - crate fn collapse_doc_comments(&mut self) { - collapse(&mut self.doc_strings); - } -} diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index a8adfe08b25..11ee59b2401 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -10,31 +10,33 @@ use rustc_hir as hir; use rustc_hir::def::{ DefKind, Namespace::{self, *}, - PerNS, Res, + PerNS, }; use rustc_hir::def_id::{CrateNum, DefId}; -use rustc_middle::ty; +use rustc_middle::{bug, ty}; use rustc_resolve::ParentScope; use rustc_session::lint::{ builtin::{BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS}, Lint, }; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::sym; use rustc_span::symbol::Ident; use rustc_span::symbol::Symbol; use rustc_span::DUMMY_SP; use smallvec::{smallvec, SmallVec}; +use pulldown_cmark::LinkType; + use std::borrow::Cow; use std::cell::Cell; +use std::convert::{TryFrom, TryInto}; use std::mem; use std::ops::Range; -use crate::clean::{self, Crate, Item, ItemLink, PrimitiveType}; +use crate::clean::{self, utils::find_nearest_parent_module, Crate, Item, ItemLink, PrimitiveType}; use crate::core::DocContext; use crate::fold::DocFolder; -use crate::html::markdown::markdown_links; +use crate::html::markdown::{markdown_links, MarkdownLink}; use crate::passes::Pass; use super::span_of_attrs; @@ -61,6 +63,71 @@ impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> { } } +#[derive(Copy, Clone, Debug, Hash)] +enum Res { + Def(DefKind, DefId), + Primitive(PrimitiveType), +} + +type ResolveRes = rustc_hir::def::Res<rustc_ast::NodeId>; + +impl Res { + fn descr(self) -> &'static str { + match self { + Res::Def(kind, id) => ResolveRes::Def(kind, id).descr(), + Res::Primitive(_) => "builtin type", + } + } + + fn article(self) -> &'static str { + match self { + Res::Def(kind, id) => ResolveRes::Def(kind, id).article(), + Res::Primitive(_) => "a", + } + } + + fn name(self, tcx: ty::TyCtxt<'_>) -> String { + match self { + Res::Def(_, id) => tcx.item_name(id).to_string(), + Res::Primitive(prim) => prim.as_str().to_string(), + } + } + + fn def_id(self) -> DefId { + self.opt_def_id().expect("called def_id() on a primitive") + } + + fn opt_def_id(self) -> Option<DefId> { + match self { + Res::Def(_, id) => Some(id), + Res::Primitive(_) => None, + } + } + + fn as_hir_res(self) -> Option<rustc_hir::def::Res> { + match self { + Res::Def(kind, id) => Some(rustc_hir::def::Res::Def(kind, id)), + // FIXME: maybe this should handle the subset of PrimitiveType that fits into hir::PrimTy? + Res::Primitive(_) => None, + } + } +} + +impl TryFrom<ResolveRes> for Res { + type Error = (); + + fn try_from(res: ResolveRes) -> Result<Self, ()> { + use rustc_hir::def::Res::*; + match res { + Def(kind, id) => Ok(Res::Def(kind, id)), + PrimTy(prim) => Ok(Res::Primitive(PrimitiveType::from_hir(prim))), + // e.g. `#[derive]` + NonMacroAttr(..) | Err => Result::Err(()), + other => bug!("unrecognized res {:?}", other), + } + } +} + #[derive(Debug)] /// A link failed to resolve. enum ResolutionFailure<'a> { @@ -200,8 +267,9 @@ struct LinkCollector<'a, 'tcx> { /// because `clean` and the disambiguator code expect them to be different. /// See the code for associated items on inherent impls for details. kind_side_channel: Cell<Option<(DefKind, DefId)>>, - /// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link - visited_links: FxHashMap<ResolutionInfo, CachedLink>, + /// Cache the resolved links so we can avoid resolving (and emitting errors for) the same link. + /// The link will be `None` if it could not be resolved (i.e. the error was cached). + visited_links: FxHashMap<ResolutionInfo, Option<CachedLink>>, } impl<'a, 'tcx> LinkCollector<'a, 'tcx> { @@ -253,12 +321,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { .enter_resolver(|resolver| { resolver.resolve_str_path_error(DUMMY_SP, &path, TypeNS, module_id) }) - .map(|(_, res)| res) - .unwrap_or(Res::Err); - if let Res::Err = ty_res { - return Err(no_res().into()); - } - let ty_res = ty_res.map_id(|_| panic!("unexpected node_id")); + .and_then(|(_, res)| res.try_into()) + .map_err(|()| no_res())?; + match ty_res { Res::Def(DefKind::Enum, did) => { if cx @@ -309,7 +374,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { /// lifetimes on `&'path` will work. fn resolve_primitive_associated_item( &self, - prim_ty: hir::PrimTy, + prim_ty: PrimitiveType, ns: Namespace, module_id: DefId, item_name: Symbol, @@ -317,7 +382,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ) -> Result<(Res, Option<String>), ErrorKind<'path>> { let cx = self.cx; - PrimitiveType::from_hir(prim_ty) + prim_ty .impls(cx.tcx) .into_iter() .find_map(|&impl_| { @@ -329,28 +394,32 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ns, impl_, ) - .map(|item| match item.kind { - ty::AssocKind::Fn => "method", - ty::AssocKind::Const => "associatedconstant", - ty::AssocKind::Type => "associatedtype", + .map(|item| { + let kind = item.kind; + self.kind_side_channel.set(Some((kind.as_def_kind(), item.def_id))); + match kind { + ty::AssocKind::Fn => "method", + ty::AssocKind::Const => "associatedconstant", + ty::AssocKind::Type => "associatedtype", + } }) .map(|out| { ( - Res::PrimTy(prim_ty), - Some(format!("{}#{}.{}", prim_ty.name(), out, item_str)), + Res::Primitive(prim_ty), + Some(format!("{}#{}.{}", prim_ty.as_str(), out, item_str)), ) }) }) .ok_or_else(|| { debug!( "returning primitive error for {}::{} in {} namespace", - prim_ty.name(), + prim_ty.as_str(), item_name, ns.descr() ); ResolutionFailure::NotResolved { module_id, - partial_res: Some(Res::PrimTy(prim_ty)), + partial_res: Some(Res::Primitive(prim_ty)), unresolved: item_str.into(), } .into() @@ -377,19 +446,18 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { false, ) { if let SyntaxExtensionKind::LegacyBang { .. } = ext.kind { - return Ok(res.map_id(|_| panic!("unexpected id"))); + return Ok(res.try_into().unwrap()); } } - if let Some(res) = resolver.all_macros().get(&Symbol::intern(path_str)) { - return Ok(res.map_id(|_| panic!("unexpected id"))); + if let Some(&res) = resolver.all_macros().get(&Symbol::intern(path_str)) { + return Ok(res.try_into().unwrap()); } debug!("resolving {} as a macro in the module {:?}", path_str, module_id); if let Ok((_, res)) = resolver.resolve_str_path_error(DUMMY_SP, path_str, MacroNS, module_id) { // don't resolve builtins like `#[derive]` - if let Res::Def(..) = res { - let res = res.map_id(|_| panic!("unexpected node_id")); + if let Ok(res) = res.try_into() { return Ok(res); } } @@ -408,14 +476,16 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { /// Associated items will never be resolved by this function. fn resolve_path(&self, path_str: &str, ns: Namespace, module_id: DefId) -> Option<Res> { let result = self.cx.enter_resolver(|resolver| { - resolver.resolve_str_path_error(DUMMY_SP, &path_str, ns, module_id) + resolver + .resolve_str_path_error(DUMMY_SP, &path_str, ns, module_id) + .and_then(|(_, res)| res.try_into()) }); debug!("{} resolved to {:?} in namespace {:?}", path_str, result, ns); - match result.map(|(_, res)| res) { - // resolver doesn't know about true and false so we'll have to resolve them + match result { + // resolver doesn't know about true, false, and types that aren't paths (e.g. `()`) // manually as bool - Ok(Res::Err) | Err(()) => is_bool_value(path_str, ns).map(|(_, res)| res), - Ok(res) => Some(res.map_id(|_| panic!("unexpected node_id"))), + Err(()) => resolve_primitive(path_str, ns), + Ok(res) => Some(res), } } @@ -444,13 +514,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { return handle_variant(cx, res, extra_fragment); } // Not a trait item; just return what we found. - Res::PrimTy(ty) => { + Res::Primitive(ty) => { if extra_fragment.is_some() { return Err(ErrorKind::AnchorFailure( AnchorFailure::RustdocAnchorConflict(res), )); } - return Ok((res, Some(ty.name_str().to_owned()))); + return Ok((res, Some(ty.as_str().to_owned()))); } Res::Def(DefKind::Mod, _) => { return Ok((res, extra_fragment.clone())); @@ -483,7 +553,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // FIXME: are these both necessary? let ty_res = if let Some(ty_res) = resolve_primitive(&path_root, TypeNS) - .map(|(_, res)| res) .or_else(|| self.resolve_path(&path_root, TypeNS, module_id)) { ty_res @@ -502,7 +571,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { }; let res = match ty_res { - Res::PrimTy(prim) => Some( + Res::Primitive(prim) => Some( self.resolve_primitive_associated_item(prim, ns, module_id, item_name, item_str), ), Res::Def( @@ -768,31 +837,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { use rustc_middle::ty::DefIdTree; let parent_node = if item.is_fake() { - // FIXME: is this correct? None - // If we're documenting the crate root itself, it has no parent. Use the root instead. - } else if item.def_id.is_top_level_module() { - Some(item.def_id) } else { - let mut current = item.def_id; - // The immediate parent might not always be a module. - // Find the first parent which is. - loop { - if let Some(parent) = self.cx.tcx.parent(current) { - if self.cx.tcx.def_kind(parent) == DefKind::Mod { - break Some(parent); - } - current = parent; - } else { - debug!( - "{:?} has no parent (kind={:?}, original was {:?})", - current, - self.cx.tcx.def_kind(current), - item.def_id - ); - break None; - } - } + find_nearest_parent_module(self.cx.tcx, item.def_id) }; if parent_node.is_some() { @@ -851,43 +898,18 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { // In the presence of re-exports, this is not the same as the module of the item. // Rather than merging all documentation into one, resolve it one attribute at a time // so we know which module it came from. - let mut attrs = item.attrs.doc_strings.iter().peekable(); - while let Some(attr) = attrs.next() { - // `collapse_docs` does not have the behavior we want: - // we want `///` and `#[doc]` to count as the same attribute, - // but currently it will treat them as separate. - // As a workaround, combine all attributes with the same parent module into the same attribute. - let mut combined_docs = attr.doc.clone(); - loop { - match attrs.peek() { - Some(next) if next.parent_module == attr.parent_module => { - combined_docs.push('\n'); - combined_docs.push_str(&attrs.next().unwrap().doc); - } - _ => break, - } - } - debug!("combined_docs={}", combined_docs); + for (parent_module, doc) in item.attrs.collapsed_doc_value_by_module_level() { + debug!("combined_docs={}", doc); - let (krate, parent_node) = if let Some(id) = attr.parent_module { - trace!("docs {:?} came from {:?}", attr.doc, id); + let (krate, parent_node) = if let Some(id) = parent_module { (id.krate, Some(id)) } else { - trace!("no parent found for {:?}", attr.doc); (item.def_id.krate, parent_node) }; // NOTE: if there are links that start in one crate and end in another, this will not resolve them. // This is a degenerate case and it's not supported by rustdoc. - for (ori_link, link_range) in markdown_links(&combined_docs) { - let link = self.resolve_link( - &item, - &combined_docs, - &self_name, - parent_node, - krate, - ori_link, - link_range, - ); + for md_link in markdown_links(&doc) { + let link = self.resolve_link(&item, &doc, &self_name, parent_node, krate, md_link); if let Some(link) = link { item.attrs.links.push(link); } @@ -919,27 +941,26 @@ impl LinkCollector<'_, '_> { self_name: &Option<String>, parent_node: Option<DefId>, krate: CrateNum, - ori_link: String, - link_range: Range<usize>, + ori_link: MarkdownLink, ) -> Option<ItemLink> { - trace!("considering link '{}'", ori_link); + trace!("considering link '{}'", ori_link.link); // Bail early for real links. - if ori_link.contains('/') { + if ori_link.link.contains('/') { return None; } // [] is mostly likely not supposed to be a link - if ori_link.is_empty() { + if ori_link.link.is_empty() { return None; } let cx = self.cx; - let link = ori_link.replace("`", ""); + let link = ori_link.link.replace("`", ""); let parts = link.split('#').collect::<Vec<_>>(); let (link, extra_fragment) = if parts.len() > 2 { // A valid link can't have multiple #'s - anchor_failure(cx, &item, &link, dox, link_range, AnchorFailure::MultipleAnchors); + anchor_failure(cx, &item, &link, dox, ori_link.range, AnchorFailure::MultipleAnchors); return None; } else if parts.len() == 2 { if parts[0].trim().is_empty() { @@ -958,7 +979,7 @@ impl LinkCollector<'_, '_> { (link.trim(), None) }; - if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !".contains(ch))) { + if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !*&;".contains(ch))) { return None; } @@ -995,7 +1016,7 @@ impl LinkCollector<'_, '_> { path_str, disambiguator, dox, - link_range, + ori_link.range, smallvec![ResolutionFailure::NoParentItem], ); return None; @@ -1035,7 +1056,7 @@ impl LinkCollector<'_, '_> { path_str, disambiguator, dox, - link_range, + ori_link.range, smallvec![err_kind], ); return None; @@ -1046,21 +1067,27 @@ impl LinkCollector<'_, '_> { // Sanity check to make sure we don't have any angle brackets after stripping generics. assert!(!path_str.contains(['<', '>'].as_slice())); - // The link is not an intra-doc link if it still contains commas or spaces after - // stripping generics. - if path_str.contains([',', ' '].as_slice()) { + // The link is not an intra-doc link if it still contains spaces after stripping generics. + if path_str.contains(' ') { return None; } - let key = ResolutionInfo { - module_id, - dis: disambiguator, - path_str: path_str.to_owned(), - extra_fragment, + let diag_info = DiagnosticInfo { + item, + dox, + ori_link: &ori_link.link, + link_range: ori_link.range.clone(), }; - let diag = - DiagnosticInfo { item, dox, ori_link: &ori_link, link_range: link_range.clone() }; - let (mut res, mut fragment) = self.resolve_with_disambiguator_cached(key, diag)?; + let (mut res, mut fragment) = self.resolve_with_disambiguator_cached( + ResolutionInfo { + module_id, + dis: disambiguator, + path_str: path_str.to_owned(), + extra_fragment, + }, + diag_info, + matches!(ori_link.kind, LinkType::Reference | LinkType::Shortcut), + )?; // Check for a primitive which might conflict with a module // Report the ambiguity and require that the user specify which one they meant. @@ -1068,9 +1095,9 @@ impl LinkCollector<'_, '_> { if matches!( disambiguator, None | Some(Disambiguator::Namespace(Namespace::TypeNS) | Disambiguator::Primitive) - ) && !matches!(res, Res::PrimTy(_)) + ) && !matches!(res, Res::Primitive(_)) { - if let Some((path, prim)) = resolve_primitive(path_str, TypeNS) { + if let Some(prim) = resolve_primitive(path_str, TypeNS) { // `prim@char` if matches!(disambiguator, Some(Disambiguator::Primitive)) { if fragment.is_some() { @@ -1079,17 +1106,17 @@ impl LinkCollector<'_, '_> { &item, path_str, dox, - link_range, + ori_link.range, AnchorFailure::RustdocAnchorConflict(prim), ); return None; } res = prim; - fragment = Some(path.as_str().to_string()); + fragment = Some(prim.name(self.cx.tcx)); } else { // `[char]` when a `char` module is in scope let candidates = vec![res, prim]; - ambiguity_error(cx, &item, path_str, dox, link_range, candidates); + ambiguity_error(cx, &item, path_str, dox, ori_link.range, candidates); return None; } } @@ -1107,49 +1134,45 @@ impl LinkCollector<'_, '_> { specified.descr() ); diag.note(¬e); - suggest_disambiguator(resolved, diag, path_str, dox, sp, &link_range); + suggest_disambiguator(resolved, diag, path_str, dox, sp, &ori_link.range); }; - report_diagnostic(cx, BROKEN_INTRA_DOC_LINKS, &msg, &item, dox, &link_range, callback); + report_diagnostic( + cx, + BROKEN_INTRA_DOC_LINKS, + &msg, + &item, + dox, + &ori_link.range, + callback, + ); }; - if let Res::PrimTy(..) = res { - match disambiguator { - Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => { - Some(ItemLink { link: ori_link, link_text, did: None, fragment }) - } - Some(other) => { - report_mismatch(other, Disambiguator::Primitive); - None - } - } - } else { + + let verify = |kind: DefKind, id: DefId| { debug!("intra-doc link to {} resolved to {:?}", path_str, res); // Disallow e.g. linking to enums with `struct@` - if let Res::Def(kind, _) = res { - debug!("saw kind {:?} with disambiguator {:?}", kind, disambiguator); - match (self.kind_side_channel.take().map(|(kind, _)| kind).unwrap_or(kind), disambiguator) { - | (DefKind::Const | DefKind::ConstParam | DefKind::AssocConst | DefKind::AnonConst, Some(Disambiguator::Kind(DefKind::Const))) - // NOTE: this allows 'method' to mean both normal functions and associated functions - // This can't cause ambiguity because both are in the same namespace. - | (DefKind::Fn | DefKind::AssocFn, Some(Disambiguator::Kind(DefKind::Fn))) - // These are namespaces; allow anything in the namespace to match - | (_, Some(Disambiguator::Namespace(_))) - // If no disambiguator given, allow anything - | (_, None) - // All of these are valid, so do nothing - => {} - (actual, Some(Disambiguator::Kind(expected))) if actual == expected => {} - (_, Some(specified @ Disambiguator::Kind(_) | specified @ Disambiguator::Primitive)) => { - report_mismatch(specified, Disambiguator::Kind(kind)); - return None; - } + debug!("saw kind {:?} with disambiguator {:?}", kind, disambiguator); + match (self.kind_side_channel.take().map(|(kind, _)| kind).unwrap_or(kind), disambiguator) { + | (DefKind::Const | DefKind::ConstParam | DefKind::AssocConst | DefKind::AnonConst, Some(Disambiguator::Kind(DefKind::Const))) + // NOTE: this allows 'method' to mean both normal functions and associated functions + // This can't cause ambiguity because both are in the same namespace. + | (DefKind::Fn | DefKind::AssocFn, Some(Disambiguator::Kind(DefKind::Fn))) + // These are namespaces; allow anything in the namespace to match + | (_, Some(Disambiguator::Namespace(_))) + // If no disambiguator given, allow anything + | (_, None) + // All of these are valid, so do nothing + => {} + (actual, Some(Disambiguator::Kind(expected))) if actual == expected => {} + (_, Some(specified @ Disambiguator::Kind(_) | specified @ Disambiguator::Primitive)) => { + report_mismatch(specified, Disambiguator::Kind(kind)); + return None; } } // item can be non-local e.g. when using #[doc(primitive = "pointer")] - if let Some((src_id, dst_id)) = res - .opt_def_id() - .and_then(|def_id| def_id.as_local()) + if let Some((src_id, dst_id)) = id + .as_local() .and_then(|dst_id| item.def_id.as_local().map(|src_id| (src_id, dst_id))) { use rustc_hir::def_id::LOCAL_CRATE; @@ -1160,11 +1183,41 @@ impl LinkCollector<'_, '_> { if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src) && !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst) { - privacy_error(cx, &item, &path_str, dox, link_range); + privacy_error(cx, &item, &path_str, dox, &ori_link); } } - let id = clean::register_res(cx, res); - Some(ItemLink { link: ori_link, link_text, did: Some(id), fragment }) + + Some((kind, id)) + }; + + match res { + Res::Primitive(_) => { + if let Some((kind, id)) = self.kind_side_channel.take() { + // We're actually resolving an associated item of a primitive, so we need to + // verify the disambiguator (if any) matches the type of the associated item. + // This case should really follow the same flow as the `Res::Def` branch below, + // but attempting to add a call to `clean::register_res` causes an ICE. @jyn514 + // thinks `register_res` is only needed for cross-crate re-exports, but Rust + // doesn't allow statements like `use str::trim;`, making this a (hopefully) + // valid omission. See https://github.com/rust-lang/rust/pull/80660#discussion_r551585677 + // for discussion on the matter. + verify(kind, id)?; + } else { + match disambiguator { + Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => {} + Some(other) => { + report_mismatch(other, Disambiguator::Primitive); + return None; + } + } + } + Some(ItemLink { link: ori_link.link, link_text, did: None, fragment }) + } + Res::Def(kind, id) => { + let (kind, id) = verify(kind, id)?; + let id = clean::register_res(cx, rustc_hir::def::Res::Def(kind, id)); + Some(ItemLink { link: ori_link.link, link_text, did: Some(id), fragment }) + } } } @@ -1172,28 +1225,47 @@ impl LinkCollector<'_, '_> { &mut self, key: ResolutionInfo, diag: DiagnosticInfo<'_>, + cache_resolution_failure: bool, ) -> Option<(Res, Option<String>)> { // Try to look up both the result and the corresponding side channel value if let Some(ref cached) = self.visited_links.get(&key) { - self.kind_side_channel.set(cached.side_channel.clone()); - return Some(cached.res.clone()); + match cached { + Some(cached) => { + self.kind_side_channel.set(cached.side_channel.clone()); + return Some(cached.res.clone()); + } + None if cache_resolution_failure => return None, + None => { + // Although we hit the cache and found a resolution error, this link isn't + // supposed to cache those. Run link resolution again to emit the expected + // resolution error. + } + } } let res = self.resolve_with_disambiguator(&key, diag); // Cache only if resolved successfully - don't silence duplicate errors - if let Some(res) = &res { + if let Some(res) = res { // Store result for the actual namespace self.visited_links.insert( key, - CachedLink { + Some(CachedLink { res: res.clone(), side_channel: self.kind_side_channel.clone().into_inner(), - }, + }), ); - } - res + Some(res) + } else { + if cache_resolution_failure { + // For reference-style links we only want to report one resolution error + // so let's cache them as well. + self.visited_links.insert(key, None); + } + + None + } } /// After parsing the disambiguator, resolve the main part of the link. @@ -1239,7 +1311,7 @@ impl LinkCollector<'_, '_> { // This could just be a normal link or a broken link // we could potentially check if something is // "intra-doc-link-like" and warn in that case. - return None; + None } Err(ErrorKind::AnchorFailure(msg)) => { anchor_failure( @@ -1250,7 +1322,7 @@ impl LinkCollector<'_, '_> { diag.link_range, msg, ); - return None; + None } } } @@ -1296,16 +1368,18 @@ impl LinkCollector<'_, '_> { .and_then(|(res, fragment)| { // Constructors are picked up in the type namespace. match res { - Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) => { + Res::Def(DefKind::Ctor(..), _) => { Err(ResolutionFailure::WrongNamespace(res, TypeNS)) } - _ => match (fragment, extra_fragment.clone()) { - (Some(fragment), Some(_)) => { - // Shouldn't happen but who knows? - Ok((res, Some(fragment))) + _ => { + match (fragment, extra_fragment.clone()) { + (Some(fragment), Some(_)) => { + // Shouldn't happen but who knows? + Ok((res, Some(fragment))) + } + (fragment, None) | (None, fragment) => Ok((res, fragment)), } - (fragment, None) | (None, fragment) => Ok((res, fragment)), - }, + } } }), }; @@ -1344,7 +1418,7 @@ impl LinkCollector<'_, '_> { diag.link_range, candidates.present_items().collect(), ); - return None; + None } } Some(MacroNS) => { @@ -1369,7 +1443,7 @@ impl LinkCollector<'_, '_> { diag.link_range, smallvec![kind], ); - return None; + None } } } @@ -1414,8 +1488,11 @@ impl Disambiguator { ("!", DefKind::Macro(MacroKind::Bang)), ]; for &(suffix, kind) in &suffixes { - if link.ends_with(suffix) { - return Ok((Kind(kind), link.trim_end_matches(suffix))); + if let Some(link) = link.strip_suffix(suffix) { + // Avoid turning `!` or `()` into an empty string + if !link.is_empty() { + return Ok((Kind(kind), link)); + } } } Err(()) @@ -1445,12 +1522,10 @@ impl Disambiguator { } } - /// WARNING: panics on `Res::Err` fn from_res(res: Res) -> Self { match res { Res::Def(kind, _) => Disambiguator::Kind(kind), - Res::PrimTy(_) => Disambiguator::Primitive, - _ => Disambiguator::Namespace(res.ns().expect("can't call `from_res` on Res::err")), + Res::Primitive(_) => Disambiguator::Primitive, } } @@ -1585,6 +1660,7 @@ fn report_diagnostic( let mut diag = lint.build(msg); let span = super::source_span_for_markdown_range(cx, dox, link_range, attrs); + if let Some(sp) = span { diag.set_span(sp); } else { @@ -1598,7 +1674,7 @@ fn report_diagnostic( // Print the line containing the `link_range` and manually mark it with '^'s. diag.note(&format!( "the link appears in this line:\n\n{line}\n\ - {indicator: <before$}{indicator:^<found$}", + {indicator: <before$}{indicator:^<found$}", line = line, indicator = "", before = link_range.start - last_new_line_offset, @@ -1626,6 +1702,7 @@ fn resolution_failure( link_range: Range<usize>, kinds: SmallVec<[ResolutionFailure<'_>; 3]>, ) { + let tcx = collector.cx.tcx; report_diagnostic( collector.cx, BROKEN_INTRA_DOC_LINKS, @@ -1634,16 +1711,9 @@ fn resolution_failure( dox, &link_range, |diag, sp| { - let item = |res: Res| { - format!( - "the {} `{}`", - res.descr(), - collector.cx.tcx.item_name(res.def_id()).to_string() - ) - }; + let item = |res: Res| format!("the {} `{}`", res.descr(), res.name(tcx),); let assoc_item_not_allowed = |res: Res| { - let def_id = res.def_id(); - let name = collector.cx.tcx.item_name(def_id); + let name = res.name(tcx); format!( "`{}` is {} {}, not a module or type, and cannot have associated items", name, @@ -1709,7 +1779,7 @@ fn resolution_failure( if let Some(module) = last_found_module { let note = if partial_res.is_some() { // Part of the link resolved; e.g. `std::io::nonexistent` - let module_name = collector.cx.tcx.item_name(module); + let module_name = tcx.item_name(module); format!("no item named `{}` in module `{}`", unresolved, module_name) } else { // None of the link resolved; e.g. `Notimported` @@ -1733,14 +1803,10 @@ fn resolution_failure( // Otherwise, it must be an associated item or variant let res = partial_res.expect("None case was handled by `last_found_module`"); - let diagnostic_name; - let (kind, name) = match res { - Res::Def(kind, def_id) => { - diagnostic_name = collector.cx.tcx.item_name(def_id).as_str(); - (Some(kind), &*diagnostic_name) - } - Res::PrimTy(ty) => (None, ty.name_str()), - _ => unreachable!("only ADTs and primitives are in scope at module level"), + let name = res.name(tcx); + let kind = match res { + Res::Def(kind, _) => Some(kind), + Res::Primitive(_) => None, }; let path_description = if let Some(kind) = kind { match kind { @@ -1950,13 +2016,7 @@ fn suggest_disambiguator( } /// Report a link from a public item to a private one. -fn privacy_error( - cx: &DocContext<'_>, - item: &Item, - path_str: &str, - dox: &str, - link_range: Range<usize>, -) { +fn privacy_error(cx: &DocContext<'_>, item: &Item, path_str: &str, dox: &str, link: &MarkdownLink) { let sym; let item_name = match item.name { Some(name) => { @@ -1968,7 +2028,7 @@ fn privacy_error( let msg = format!("public documentation for `{}` links to private item `{}`", item_name, path_str); - report_diagnostic(cx, PRIVATE_INTRA_DOC_LINKS, &msg, item, dox, &link_range, |diag, sp| { + report_diagnostic(cx, PRIVATE_INTRA_DOC_LINKS, &msg, item, dox, &link.range, |diag, sp| { if let Some(sp) = sp { diag.span_label(sp, "this item is private"); } @@ -1997,53 +2057,49 @@ fn handle_variant( .parent(res.def_id()) .map(|parent| { let parent_def = Res::Def(DefKind::Enum, parent); - let variant = cx.tcx.expect_variant_res(res); + let variant = cx.tcx.expect_variant_res(res.as_hir_res().unwrap()); (parent_def, Some(format!("variant.{}", variant.ident.name))) }) .ok_or_else(|| ResolutionFailure::NoParentItem.into()) } -// FIXME: At this point, this is basically a copy of the PrimitiveTypeTable -const PRIMITIVES: &[(Symbol, Res)] = &[ - (sym::u8, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::U8))), - (sym::u16, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::U16))), - (sym::u32, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::U32))), - (sym::u64, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::U64))), - (sym::u128, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::U128))), - (sym::usize, Res::PrimTy(hir::PrimTy::Uint(rustc_ast::UintTy::Usize))), - (sym::i8, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::I8))), - (sym::i16, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::I16))), - (sym::i32, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::I32))), - (sym::i64, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::I64))), - (sym::i128, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::I128))), - (sym::isize, Res::PrimTy(hir::PrimTy::Int(rustc_ast::IntTy::Isize))), - (sym::f32, Res::PrimTy(hir::PrimTy::Float(rustc_ast::FloatTy::F32))), - (sym::f64, Res::PrimTy(hir::PrimTy::Float(rustc_ast::FloatTy::F64))), - (sym::str, Res::PrimTy(hir::PrimTy::Str)), - (sym::bool, Res::PrimTy(hir::PrimTy::Bool)), - (sym::char, Res::PrimTy(hir::PrimTy::Char)), -]; - /// Resolve a primitive type or value. -fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<(Symbol, Res)> { - is_bool_value(path_str, ns).or_else(|| { - if ns == TypeNS { - // FIXME: this should be replaced by a lookup in PrimitiveTypeTable - let maybe_primitive = Symbol::intern(path_str); - PRIMITIVES.iter().find(|x| x.0 == maybe_primitive).copied() - } else { - None - } - }) -} - -/// Resolve a primitive value. -fn is_bool_value(path_str: &str, ns: Namespace) -> Option<(Symbol, Res)> { - if ns == TypeNS && (path_str == "true" || path_str == "false") { - Some((sym::bool, Res::PrimTy(hir::PrimTy::Bool))) - } else { - None +fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<Res> { + if ns != TypeNS { + return None; } + use PrimitiveType::*; + let prim = match path_str { + "isize" => Isize, + "i8" => I8, + "i16" => I16, + "i32" => I32, + "i64" => I64, + "i128" => I128, + "usize" => Usize, + "u8" => U8, + "u16" => U16, + "u32" => U32, + "u64" => U64, + "u128" => U128, + "f32" => F32, + "f64" => F64, + "char" => Char, + "bool" | "true" | "false" => Bool, + "str" => Str, + // See #80181 for why these don't have symbols associated. + "slice" => Slice, + "array" => Array, + "tuple" => Tuple, + "unit" => Unit, + "pointer" | "*" | "*const" | "*mut" => RawPointer, + "reference" | "&" | "&mut" => Reference, + "fn" => Fn, + "never" | "!" => Never, + _ => return None, + }; + debug!("resolved primitives {:?}", prim); + Some(Res::Primitive(prim)) } fn strip_generics_from_path(path_str: &str) -> Result<String, ResolutionFailure<'static>> { diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 60fcbe74872..9b0ae09cb3f 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -58,11 +58,11 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate { // scan through included items ahead of time to splice in Deref targets to the "valid" sets for it in &new_items { - if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = it.kind { + if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = *it.kind { if cleaner.keep_item(for_) && trait_.def_id() == cx.tcx.lang_items().deref_trait() { let target = items .iter() - .find_map(|item| match item.kind { + .find_map(|item| match *item.kind { TypedefItem(ref t, true) => Some(&t.type_), _ => None, }) @@ -78,7 +78,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate { } new_items.retain(|it| { - if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = it.kind { + if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = *it.kind { cleaner.keep_item(for_) || trait_.as_ref().map_or(false, |t| cleaner.keep_item(t)) || blanket_impl.is_some() @@ -124,7 +124,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate { } if let Some(ref mut it) = krate.module { - if let ModuleItem(Module { ref mut items, .. }) = it.kind { + if let ModuleItem(Module { ref mut items, .. }) = *it.kind { items.extend(synth.impls); items.extend(new_items); } else { diff --git a/src/librustdoc/passes/doc_test_lints.rs b/src/librustdoc/passes/doc_test_lints.rs index 1c1141e7c81..a513c2abc87 100644 --- a/src/librustdoc/passes/doc_test_lints.rs +++ b/src/librustdoc/passes/doc_test_lints.rs @@ -9,7 +9,7 @@ use crate::clean::*; use crate::core::DocContext; use crate::fold::DocFolder; use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString}; -use rustc_middle::lint::LintSource; +use rustc_middle::lint::LintLevelSource; use rustc_session::lint; crate const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass { @@ -59,7 +59,7 @@ impl crate::doctest::Tester for Tests { crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool { if matches!( - item.kind, + *item.kind, clean::StructFieldItem(_) | clean::VariantItem(_) | clean::AssocConstItem(_, _) @@ -77,7 +77,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local()); let (level, source) = cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id); - level != lint::Level::Allow || matches!(source, LintSource::Default) + level != lint::Level::Allow || matches!(source, LintLevelSource::Default) } crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) { diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index a7a1ba1118d..38ec2bef0ad 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -59,7 +59,7 @@ fn drop_tag( continue; } let last_tag_name_low = last_tag_name.to_lowercase(); - if ALLOWED_UNCLOSED.iter().any(|&at| at == &last_tag_name_low) { + if ALLOWED_UNCLOSED.iter().any(|&at| at == last_tag_name_low) { continue; } // `tags` is used as a queue, meaning that everything after `pos` is included inside it. diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 51818d7faf0..7ac42c75992 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -14,9 +14,6 @@ crate use stripper::*; mod non_autolinks; crate use self::non_autolinks::CHECK_NON_AUTOLINKS; -mod collapse_docs; -crate use self::collapse_docs::COLLAPSE_DOCS; - mod strip_hidden; crate use self::strip_hidden::STRIP_HIDDEN; @@ -84,7 +81,6 @@ crate const PASSES: &[Pass] = &[ CHECK_PRIVATE_ITEMS_DOC_TESTS, STRIP_HIDDEN, UNINDENT_COMMENTS, - COLLAPSE_DOCS, STRIP_PRIVATE, STRIP_PRIV_IMPORTS, PROPAGATE_DOC_CFG, @@ -99,7 +95,6 @@ crate const PASSES: &[Pass] = &[ /// The list of passes run by default. crate const DEFAULT_PASSES: &[ConditionalPass] = &[ ConditionalPass::always(COLLECT_TRAIT_IMPLS), - ConditionalPass::always(COLLAPSE_DOCS), ConditionalPass::always(UNINDENT_COMMENTS), ConditionalPass::always(CHECK_PRIVATE_ITEMS_DOC_TESTS), ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden), diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index 6b59eb8cf28..a276b7a6337 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -26,9 +26,7 @@ crate fn strip_hidden(krate: clean::Crate, _: &DocContext<'_>) -> clean::Crate { // strip all impls referencing stripped items let mut stripper = ImplStripper { retained: &retained }; - let krate = stripper.fold_crate(krate); - - krate + stripper.fold_crate(krate) } struct Stripper<'a> { @@ -41,7 +39,7 @@ impl<'a> DocFolder for Stripper<'a> { if i.attrs.lists(sym::doc).has_word(sym::hidden) { debug!("strip_hidden: stripping {:?} {:?}", i.type_(), i.name); // use a dedicated hidden item for given item type if any - match i.kind { + match *i.kind { clean::StructFieldItem(..) | clean::ModuleItem(..) => { // We need to recurse into stripped modules to // strip things like impl methods but when doing so @@ -49,7 +47,7 @@ impl<'a> DocFolder for Stripper<'a> { let old = mem::replace(&mut self.update_retained, false); let ret = StripItem(self.fold_item_recur(i)).strip(); self.update_retained = old; - return ret; + return Some(ret); } _ => return None, } diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 444fd593ec9..a1924422f0e 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -13,7 +13,7 @@ crate struct Stripper<'a> { impl<'a> DocFolder for Stripper<'a> { fn fold_item(&mut self, i: Item) -> Option<Item> { - match i.kind { + match *i.kind { clean::StrippedItem(..) => { // We need to recurse into stripped modules to strip things // like impl methods but when doing so we must not add any @@ -51,7 +51,7 @@ impl<'a> DocFolder for Stripper<'a> { clean::StructFieldItem(..) => { if !i.visibility.is_public() { - return StripItem(i).strip(); + return Some(StripItem(i).strip()); } } @@ -61,7 +61,7 @@ impl<'a> DocFolder for Stripper<'a> { let old = mem::replace(&mut self.update_retained, false); let ret = StripItem(self.fold_item_recur(i)).strip(); self.update_retained = old; - return ret; + return Some(ret); } } @@ -86,7 +86,7 @@ impl<'a> DocFolder for Stripper<'a> { clean::KeywordItem(..) => {} } - let fastreturn = match i.kind { + let fastreturn = match *i.kind { // nothing left to do for traits (don't want to filter their // methods out, visibility controlled by the trait) clean::TraitItem(..) => true, @@ -121,7 +121,7 @@ crate struct ImplStripper<'a> { impl<'a> DocFolder for ImplStripper<'a> { fn fold_item(&mut self, i: Item) -> Option<Item> { - if let clean::ImplItem(ref imp) = i.kind { + if let clean::ImplItem(ref imp) = *i.kind { // emptied none trait impls can be stripped if imp.trait_.is_none() && imp.items.is_empty() { return None; @@ -160,7 +160,7 @@ crate struct ImportStripper; impl DocFolder for ImportStripper { fn fold_item(&mut self, i: Item) -> Option<Item> { - match i.kind { + match *i.kind { clean::ExternCrateItem(..) | clean::ImportItem(..) if !i.visibility.is_public() => None, _ => Some(self.fold_item_recur(i)), } diff --git a/src/librustdoc/passes/unindent_comments.rs b/src/librustdoc/passes/unindent_comments.rs index d0345d1e48c..1cad480d4e8 100644 --- a/src/librustdoc/passes/unindent_comments.rs +++ b/src/librustdoc/passes/unindent_comments.rs @@ -68,7 +68,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) { let min_indent = match docs .iter() .map(|fragment| { - fragment.doc.lines().fold(usize::MAX, |min_indent, line| { + fragment.doc.as_str().lines().fold(usize::MAX, |min_indent, line| { if line.chars().all(|c| c.is_whitespace()) { min_indent } else { @@ -87,7 +87,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) { }; for fragment in docs { - if fragment.doc.lines().count() == 0 { + if fragment.doc.as_str().lines().count() == 0 { continue; } @@ -97,18 +97,6 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) { min_indent }; - fragment.doc = fragment - .doc - .lines() - .map(|line| { - if line.chars().all(|c| c.is_whitespace()) { - line.to_string() - } else { - assert!(line.len() >= min_indent); - line[min_indent..].to_string() - } - }) - .collect::<Vec<_>>() - .join("\n"); + fragment.indent = min_indent; } } diff --git a/src/librustdoc/passes/unindent_comments/tests.rs b/src/librustdoc/passes/unindent_comments/tests.rs index 9dec71f7683..9c9924841b9 100644 --- a/src/librustdoc/passes/unindent_comments/tests.rs +++ b/src/librustdoc/passes/unindent_comments/tests.rs @@ -1,21 +1,27 @@ use super::*; use rustc_span::source_map::DUMMY_SP; +use rustc_span::symbol::Symbol; +use rustc_span::with_default_session_globals; fn create_doc_fragment(s: &str) -> Vec<DocFragment> { vec![DocFragment { line: 0, span: DUMMY_SP, parent_module: None, - doc: s.to_string(), + doc: Symbol::intern(s), kind: DocFragmentKind::SugaredDoc, + need_backline: false, + indent: 0, }] } #[track_caller] fn run_test(input: &str, expected: &str) { - let mut s = create_doc_fragment(input); - unindent_fragments(&mut s); - assert_eq!(s[0].doc, expected); + with_default_session_globals(|| { + let mut s = create_doc_fragment(input); + unindent_fragments(&mut s); + assert_eq!(&s.iter().collect::<String>(), expected); + }); } #[test] diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index 3bcf64f91c9..2e14a8a977e 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -70,15 +70,12 @@ impl Events { } fn is_comment(&self) -> bool { - match *self { - Events::StartLineComment(_) | Events::StartComment(_) | Events::EndComment(_) => true, - _ => false, - } + matches!(self, Events::StartLineComment(_) | Events::StartComment(_) | Events::EndComment(_)) } } fn previous_is_line_comment(events: &[Events]) -> bool { - if let Some(&Events::StartLineComment(_)) = events.last() { true } else { false } + matches!(events.last(), Some(&Events::StartLineComment(_))) } fn is_line_comment(pos: usize, v: &[u8], events: &[Events]) -> bool { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index f9cb1d586b1..3c0aeaad43e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -1,7 +1,6 @@ //! The Rust AST Visitor. Extracts useful information and massages it into a form //! usable for `clean`. -use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -64,7 +63,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> { let mut module = self.visit_mod_contents( krate.item.span, - krate.item.attrs, &Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public }, hir::CRATE_HIR_ID, &krate.item.module, @@ -82,13 +80,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { fn visit_mod_contents( &mut self, span: Span, - attrs: &'tcx [ast::Attribute], vis: &'tcx hir::Visibility<'_>, id: hir::HirId, m: &'tcx hir::Mod<'tcx>, name: Option<Symbol>, ) -> Module<'tcx> { - let mut om = Module::new(name, attrs); + let mut om = Module::new(name); om.where_outer = span; om.where_inner = m.inner; om.id = id; @@ -292,7 +289,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { hir::ItemKind::Mod(ref m) => { om.mods.push(self.visit_mod_contents( item.span, - &item.attrs, &item.vis, item.hir_id, m, diff --git a/src/llvm-project b/src/llvm-project -Subproject 8d78ad13896b955f630714f386a95ed91b237e3 +Subproject fb115ee43b77601b237717c21ab0a8f5b5b9d50 diff --git a/src/stage0.txt b/src/stage0.txt index 6e05b66c3fe..e853b9b4e41 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # stable release's version number. `date` is the date where the release we're # bootstrapping off was released. -date: 2020-11-18 +date: 2020-12-30 rustc: beta # We use a nightly rustfmt to format the source because it solves some diff --git a/src/test/codegen/sanitizer-no-sanitize.rs b/src/test/codegen/sanitizer-no-sanitize.rs index 1b2b18822e6..fb9d249da03 100644 --- a/src/test/codegen/sanitizer-no-sanitize.rs +++ b/src/test/codegen/sanitizer-no-sanitize.rs @@ -1,4 +1,4 @@ -// Verifies that no_sanitze attribute can be used to +// Verifies that no_sanitize attribute can be used to // selectively disable sanitizer instrumentation. // // needs-sanitizer-address diff --git a/src/test/codegen/slice-ref-equality.rs b/src/test/codegen/slice-ref-equality.rs new file mode 100644 index 00000000000..acc7879e7b1 --- /dev/null +++ b/src/test/codegen/slice-ref-equality.rs @@ -0,0 +1,16 @@ +// compile-flags: -C opt-level=3 + +#![crate_type = "lib"] + +// #71602: check that slice equality just generates a single bcmp + +// CHECK-LABEL: @is_zero_slice +#[no_mangle] +pub fn is_zero_slice(data: &[u8; 4]) -> bool { + // CHECK: start: + // CHECK-NEXT: %{{.+}} = getelementptr {{.+}} + // CHECK-NEXT: %[[BCMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{.+}}) + // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[BCMP]], 0 + // CHECK-NEXT: ret i1 %[[EQ]] + *data == [0; 4] +} diff --git a/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs b/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs deleted file mode 100644 index b9ef2f32941..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs +++ /dev/null @@ -1,15 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#![no_std] -#![feature(lang_items)] - -use core::panic::PanicInfo; - -#[lang = "panic_impl"] -fn panic_impl(info: &PanicInfo) -> ! { loop {} } -#[lang = "eh_personality"] -fn eh_personality() {} -#[lang = "eh_catch_typeinfo"] -static EH_CATCH_TYPEINFO: u8 = 0; diff --git a/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs b/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs deleted file mode 100644 index 97452a342ab..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs b/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs deleted file mode 100644 index 97452a342ab..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/auxiliary/some-panic-impl.rs b/src/test/compile-fail/auxiliary/some-panic-impl.rs deleted file mode 100644 index 0348b3a2d76..00000000000 --- a/src/test/compile-fail/auxiliary/some-panic-impl.rs +++ /dev/null @@ -1,11 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -use core::panic::PanicInfo; - -#[panic_handler] -fn panic(info: &PanicInfo) -> ! { - loop {} -} diff --git a/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs b/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs deleted file mode 100644 index d5f0102196f..00000000000 --- a/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs +++ /dev/null @@ -1,6 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -extern crate panic_runtime_unwind; diff --git a/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr b/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr deleted file mode 100644 index 27e27dda5ef..00000000000 --- a/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` - -error: aborting due to previous error - diff --git a/src/test/debuginfo/pretty-std-collections-hash.rs b/src/test/debuginfo/pretty-std-collections-hash.rs index 9f59936a92d..7115aec1041 100644 --- a/src/test/debuginfo/pretty-std-collections-hash.rs +++ b/src/test/debuginfo/pretty-std-collections-hash.rs @@ -10,8 +10,8 @@ // cdb-command: g // cdb-command: dx hash_set,d -// cdb-check:hash_set,d [...] : { size=15 } [Type: [...]::HashSet<u64, [...]>] -// cdb-check: [size] : 15 [Type: [...]] +// cdb-check:hash_set,d [...] : { len=15 } [Type: [...]::HashSet<u64, [...]>] +// cdb-check: [len] : 15 [Type: [...]] // cdb-check: [capacity] : [...] // cdb-check: [[...]] [...] : 0 [Type: u64] // cdb-command: dx hash_set,d @@ -44,8 +44,8 @@ // cdb-check: [[...]] [...] : 14 [Type: u64] // cdb-command: dx hash_map,d -// cdb-check:hash_map,d [...] : { size=15 } [Type: [...]::HashMap<u64, u64, [...]>] -// cdb-check: [size] : 15 [Type: [...]] +// cdb-check:hash_map,d [...] : { len=15 } [Type: [...]::HashMap<u64, u64, [...]>] +// cdb-check: [len] : 15 [Type: [...]] // cdb-check: [capacity] : [...] // cdb-check: ["0x0"] : 0 [Type: unsigned __int64] // cdb-command: dx hash_map,d diff --git a/src/test/debuginfo/pretty-std.rs b/src/test/debuginfo/pretty-std.rs index 6632488171d..1a99f841250 100644 --- a/src/test/debuginfo/pretty-std.rs +++ b/src/test/debuginfo/pretty-std.rs @@ -74,8 +74,8 @@ // NOTE: While slices have a .natvis entry that works in VS & VS Code, it fails in CDB 10.0.18362.1 // cdb-command: dx vec,d -// cdb-check:vec,d [...] : { size=4 } [Type: [...]::Vec<u64, alloc::alloc::Global>] -// cdb-check: [size] : 4 [Type: [...]] +// cdb-check:vec,d [...] : { len=4 } [Type: [...]::Vec<u64, alloc::alloc::Global>] +// cdb-check: [len] : 4 [Type: [...]] // cdb-check: [capacity] : [...] [Type: [...]] // cdb-check: [0] : 4 [Type: unsigned __int64] // cdb-check: [1] : 5 [Type: unsigned __int64] @@ -89,8 +89,10 @@ // cdb-command: dx string // cdb-check:string : "IAMA string!" [Type: [...]::String] // cdb-check: [<Raw View>] [Type: [...]::String] -// cdb-check: [size] : 0xc [Type: [...]] +// cdb-check: [len] : 0xc [Type: [...]] // cdb-check: [capacity] : 0xc [Type: [...]] + +// cdb-command: dx -r2 string // cdb-check: [0] : 73 'I' [Type: char] // cdb-check: [1] : 65 'A' [Type: char] // cdb-check: [2] : 77 'M' [Type: char] @@ -109,11 +111,11 @@ // NOTE: OsString doesn't have a .natvis entry yet. // cdb-command: dx some -// cdb-check:some : { Some 8 } [Type: [...]::Option<i16>] +// cdb-check:some : Some(8) [Type: [...]::Option<i16>] // cdb-command: dx none -// cdb-check:none : { None } [Type: [...]::Option<i64>] +// cdb-check:none : None [Type: [...]::Option<i64>] // cdb-command: dx some_string -// cdb-check:some_string : { Some "IAMA optional string!" } [[...]::Option<[...]::String>] +// cdb-check:some_string : Some("IAMA optional string!") [[...]::Option<[...]::String>] #![allow(unused_variables)] use std::ffi::OsString; diff --git a/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff index f01676b6da8..3397ef95856 100644 --- a/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff @@ -14,9 +14,6 @@ - _2 = CheckedAdd(const 1_u32, const 1_u32); // scope 0 at $DIR/checked_add.rs:5:18: 5:23 - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; // scope 0 at $DIR/checked_add.rs:5:18: 5:23 + _2 = const (2_u32, false); // scope 0 at $DIR/checked_add.rs:5:18: 5:23 -+ // ty::Const -+ // + ty: (u32, bool) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [2, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/checked_add.rs:5:18: 5:23 + // + literal: Const { ty: (u32, bool), val: Value(ByRef { alloc: Allocation { bytes: [2, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff b/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff index 8c7b35887c9..9ddb34e58e5 100644 --- a/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff @@ -18,9 +18,6 @@ - assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; // scope 0 at $DIR/indirect.rs:5:13: 5:29 + _2 = const 2_u8; // scope 0 at $DIR/indirect.rs:5:13: 5:25 + _3 = const (3_u8, false); // scope 0 at $DIR/indirect.rs:5:13: 5:29 -+ // ty::Const -+ // + ty: (u8, bool) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [3, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/indirect.rs:5:13: 5:29 + // + literal: Const { ty: (u8, bool), val: Value(ByRef { alloc: Allocation { bytes: [3, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff index 492938fc206..da35bf18c71 100644 --- a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -15,9 +15,6 @@ (_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17 - (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 -+ // ty::Const -+ // + ty: (u8, u8) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [1, 2], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/issue-67019.rs:11:10: 11:19 + // + literal: Const { ty: (u8, u8), val: Value(ByRef { alloc: Allocation { bytes: [1, 2], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index 204c1acecf5..12b02e90345 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -20,9 +20,6 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:9: 7:10 - _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14 + _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14 -+ // ty::Const -+ // + ty: (i32, i32) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [42, 0, 0, 0, 99, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/mutable_variable_aggregate.rs:7:13: 7:14 + // + literal: Const { ty: (i32, i32), val: Value(ByRef { alloc: Allocation { bytes: [42, 0, 0, 0, 99, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff index 53ffc01ccaf..a10bac4f3ea 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff @@ -27,9 +27,6 @@ - _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 -+ // ty::Const -+ // + ty: (i32, bool) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 + // + literal: Const { ty: (i32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff index 53ffc01ccaf..a10bac4f3ea 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff @@ -27,9 +27,6 @@ - _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 -+ // ty::Const -+ // + ty: (i32, bool) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 + // + literal: Const { ty: (i32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/return_place.add.ConstProp.diff b/src/test/mir-opt/const_prop/return_place.add.ConstProp.diff index fc8a5437232..f0e9916e630 100644 --- a/src/test/mir-opt/const_prop/return_place.add.ConstProp.diff +++ b/src/test/mir-opt/const_prop/return_place.add.ConstProp.diff @@ -9,9 +9,6 @@ - _1 = CheckedAdd(const 2_u32, const 2_u32); // scope 0 at $DIR/return_place.rs:6:5: 6:10 - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:6:5: 6:10 + _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:6:5: 6:10 -+ // ty::Const -+ // + ty: (u32, bool) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/return_place.rs:6:5: 6:10 + // + literal: Const { ty: (u32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index 2de1ab19b7c..da4b135d4c6 100644 --- a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -18,9 +18,6 @@ StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14 - _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14 + _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14 -+ // ty::Const -+ // + ty: (u32, u32) -+ // + val: Value(ByRef { alloc: Allocation { bytes: [1, 0, 0, 0, 2, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant + // + span: $DIR/tuple_literal_propagation.rs:5:13: 5:14 + // + literal: Const { ty: (u32, u32), val: Value(ByRef { alloc: Allocation { bytes: [1, 0, 0, 0, 2, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } diff --git a/src/test/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff b/src/test/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff index e9cc72f2138..096bba64c0b 100644 --- a/src/test/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff +++ b/src/test/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff @@ -4,27 +4,21 @@ fn forget(_1: T) -> () { debug t => _1; // in scope 0 at $DIR/lower_intrinsics.rs:18:18: 18:19 let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:18:24: 18:24 - let _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:19:14: 19:41 - let mut _3: T; // in scope 0 at $DIR/lower_intrinsics.rs:19:39: 19:40 - scope 1 { - } + let mut _2: T; // in scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31 bb0: { - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:43 - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:19:39: 19:40 - _3 = move _1; // scope 1 at $DIR/lower_intrinsics.rs:19:39: 19:40 -- _2 = std::intrinsics::forget::<T>(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:19:14: 19:41 + StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31 + _2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31 +- _0 = std::intrinsics::forget::<T>(move _2) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:19:14: 19:38 -- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(Scalar(<ZST>)) } -+ _2 = const (); // scope 1 at $DIR/lower_intrinsics.rs:19:14: 19:41 -+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:19:14: 19:41 +- // + span: $DIR/lower_intrinsics.rs:19:5: 19:29 +- // + literal: Const { ty: extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(Scalar(<ZST>)) } ++ _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32 } bb1: { - StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:19:40: 19:41 - StorageDead(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:43: 19:44 - _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:18:24: 20:2 + StorageDead(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:31: 19:32 goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:20:1: 20:2 } diff --git a/src/test/mir-opt/lower_intrinsics.rs b/src/test/mir-opt/lower_intrinsics.rs index 8d28354a5f1..d9891465dab 100644 --- a/src/test/mir-opt/lower_intrinsics.rs +++ b/src/test/mir-opt/lower_intrinsics.rs @@ -16,7 +16,7 @@ pub fn size_of<T>() -> usize { // EMIT_MIR lower_intrinsics.forget.LowerIntrinsics.diff pub fn forget<T>(t: T) { - unsafe { core::intrinsics::forget(t) }; + core::intrinsics::forget(t) } // EMIT_MIR lower_intrinsics.unreachable.LowerIntrinsics.diff diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff index 3064e92f900..34f8ca870cd 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff @@ -42,9 +42,6 @@ // mir::Constant // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12 // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(Scalar(<ZST>)) } - // ty::Const - // + ty: ((), ()) - // + val: Value(Scalar(<ZST>)) // mir::Constant // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) } diff --git a/src/test/run-make-fulldeps/coverage-reports/Makefile b/src/test/run-make-fulldeps/coverage-reports/Makefile index 5c24f909130..c4700b317ef 100644 --- a/src/test/run-make-fulldeps/coverage-reports/Makefile +++ b/src/test/run-make-fulldeps/coverage-reports/Makefile @@ -98,7 +98,7 @@ endif # Run it in order to generate some profiling data, # with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to # output the coverage stats for this run. - LLVM_PROFILE_FILE="$(TMPDIR)"/$@.profraw \ + LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \ $(call RUN,$@) || \ ( \ status=$$?; \ @@ -108,9 +108,16 @@ endif ) \ ) + # Run it through rustdoc as well to cover doctests + LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \ + $(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \ + $$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && echo "--edition=2018" ) \ + -L "$(TMPDIR)" -Zinstrument-coverage \ + -Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@ + # Postprocess the profiling data so it can be used by the llvm-cov tool "$(LLVM_BIN_DIR)"/llvm-profdata merge --sparse \ - "$(TMPDIR)"/$@.profraw \ + "$(TMPDIR)"/$@-*.profraw \ -o "$(TMPDIR)"/$@.profdata # Generate a coverage report using `llvm-cov show`. @@ -121,8 +128,15 @@ endif --show-line-counts-or-regions \ --instr-profile="$(TMPDIR)"/$@.profdata \ $(call BIN,"$(TMPDIR)"/$@) \ - > "$(TMPDIR)"/actual_show_coverage.$@.txt \ - 2> "$(TMPDIR)"/show_coverage_stderr.$@.txt || \ + $$( \ + for file in $(TMPDIR)/rustdoc-$@/*/rust_out; \ + do \ + [[ -x $$file ]] && printf "%s %s " -object $$file; \ + done \ + ) \ + 2> "$(TMPDIR)"/show_coverage_stderr.$@.txt \ + | "$(PYTHON)" $(BASEDIR)/normalize_paths.py \ + > "$(TMPDIR)"/actual_show_coverage.$@.txt || \ ( status=$$? ; \ >&2 cat "$(TMPDIR)"/show_coverage_stderr.$@.txt ; \ exit $$status \ diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.doctest.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.doctest.txt new file mode 100644 index 00000000000..8f67170561a --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.doctest.txt @@ -0,0 +1,115 @@ +../coverage/doctest.rs: + 1| |//! This test ensures that code from doctests is properly re-mapped. + 2| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info. + 3| |//! + 4| |//! Just some random code: + 5| 1|//! ``` + 6| 1|//! if true { + 7| |//! // this is executed! + 8| 1|//! assert_eq!(1, 1); + 9| |//! } else { + 10| |//! // this is not! + 11| |//! assert_eq!(1, 2); + 12| |//! } + 13| 1|//! ``` + 14| |//! + 15| |//! doctest testing external code: + 16| |//! ``` + 17| 1|//! extern crate doctest_crate; + 18| 1|//! doctest_crate::fn_run_in_doctests(1); + 19| 1|//! ``` + 20| |//! + 21| |//! doctest returning a result: + 22| 1|//! ``` + 23| 2|//! #[derive(Debug, PartialEq)] + ^1 + 24| 1|//! struct SomeError { + 25| 1|//! msg: String, + 26| 1|//! } + 27| 1|//! let mut res = Err(SomeError { msg: String::from("a message") }); + 28| 1|//! if res.is_ok() { + 29| 0|//! res?; + 30| |//! } else { + 31| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { + 32| 1|//! println!("{:?}", res); + 33| 1|//! } + ^0 + 34| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { + 35| 1|//! res = Ok(1); + 36| 1|//! } + ^0 + 37| 1|//! res = Ok(0); + 38| |//! } + 39| |//! // need to be explicit because rustdoc cant infer the return type + 40| 1|//! Ok::<(), SomeError>(()) + 41| 1|//! ``` + 42| |//! + 43| |//! doctest with custom main: + 44| |//! ``` + 45| 1|//! fn some_func() { + 46| 1|//! println!("called some_func()"); + 47| 1|//! } + 48| |//! + 49| |//! #[derive(Debug)] + 50| |//! struct SomeError; + 51| |//! + 52| |//! extern crate doctest_crate; + 53| |//! + 54| 1|//! fn doctest_main() -> Result<(), SomeError> { + 55| 1|//! some_func(); + 56| 1|//! doctest_crate::fn_run_in_doctests(2); + 57| 1|//! Ok(()) + 58| 1|//! } + 59| |//! + 60| |//! // this `main` is not shown as covered, as it clashes with all the other + 61| |//! // `main` functions that were automatically generated for doctests + 62| |//! fn main() -> Result<(), SomeError> { + 63| |//! doctest_main() + 64| |//! } + 65| |//! ``` + 66| | + 67| |/// doctest attached to fn testing external code: + 68| |/// ``` + 69| 1|/// extern crate doctest_crate; + 70| 1|/// doctest_crate::fn_run_in_doctests(3); + 71| 1|/// ``` + 72| |/// + 73| 1|fn main() { + 74| 1| if true { + 75| 1| assert_eq!(1, 1); + 76| | } else { + 77| | assert_eq!(1, 2); + 78| | } + 79| 1|} + 80| | + 81| |// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the + 82| |// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc + 83| |// comment characters). This test produces `llvm-cov show` results demonstrating the problem. + 84| |// + 85| |// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show` + 86| |// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong + 87| |// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or + 88| |// one character past, the `if` block's closing brace. In both cases, these are most likely off + 89| |// by the number of characters stripped from the beginning of each doc comment line: indent + 90| |// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character + 91| |// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are + 92| |// more pronounced, and show up in more places, with background color used to show some distinct + 93| |// code regions with different coverage counts. + 94| |// + 95| |// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each + 96| |// character stripped from the beginning of doc comment lines with a space. This will give coverage + 97| |// results the correct column offsets, and I think it should compile correctly, but I don't know + 98| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care + 99| |// if the indentation changed. I don't know if there is a more viable solution. + +../coverage/lib/doctest_crate.rs: + 1| |/// A function run only from within doctests + 2| 3|pub fn fn_run_in_doctests(conditional: usize) { + 3| 3| match conditional { + 4| 1| 1 => assert_eq!(1, 1), // this is run, + 5| 1| 2 => assert_eq!(1, 1), // this, + 6| 1| 3 => assert_eq!(1, 1), // and this too + 7| 0| _ => assert_eq!(1, 2), // however this is not + 8| | } + 9| 3|} + diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt index e14e733fff6..4c03e950af0 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt @@ -19,12 +19,12 @@ 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); 19| 2|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&str>: + | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>: | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>: + | used_crate::used_only_from_bin_crate_generic_function::<&str>: | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} diff --git a/src/test/run-make-fulldeps/coverage-reports/normalize_paths.py b/src/test/run-make-fulldeps/coverage-reports/normalize_paths.py new file mode 100755 index 00000000000..e5777ad2512 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-reports/normalize_paths.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import sys + +# Normalize file paths in output +for line in sys.stdin: + if line.startswith("..") and line.rstrip().endswith(".rs:"): + print(line.replace("\\", "/"), end='') + else: + print(line, end='') diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html new file mode 100644 index 00000000000..333476a2df5 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html @@ -0,0 +1,127 @@ +<!DOCTYPE html> +<!-- + +Preview this file as rendered HTML from the github source at: +https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html + +For revisions in Pull Requests (PR): + * Replace "rust-lang" with the github PR author + * Replace "master" with the PR branch name + +--> +<html> +<head> +<title>doctest.main - Coverage Spans</title> +<style> + .line { + counter-increment: line; + } + .line:before { + content: counter(line) ": "; + font-family: Menlo, Monaco, monospace; + font-style: italic; + width: 3.8em; + display: inline-block; + text-align: right; + filter: opacity(50%); + -webkit-user-select: none; + } + .code { + color: #dddddd; + background-color: #222222; + font-family: Menlo, Monaco, monospace; + line-height: 1.4em; + border-bottom: 2px solid #222222; + white-space: pre; + display: inline-block; + } + .odd { + background-color: #55bbff; + color: #223311; + } + .even { + background-color: #ee7756; + color: #551133; + } + .code { + --index: calc(var(--layer) - 1); + padding-top: calc(var(--index) * 0.15em); + filter: + hue-rotate(calc(var(--index) * 25deg)) + saturate(calc(100% - (var(--index) * 2%))) + brightness(calc(100% - (var(--index) * 1.5%))); + } + .annotation { + color: #4444ff; + font-family: monospace; + font-style: italic; + display: none; + -webkit-user-select: none; + } + body:active .annotation { + /* requires holding mouse down anywhere on the page */ + display: inline-block; + } + span:hover .annotation { + /* requires hover over a span ONLY on its first line */ + display: inline-block; + } +</style> +</head> +<body> +<div class="code" style="counter-reset: line 72"><span class="line"><span><span class="code even" style="--layer: 1"><span class="annotation">@0⦊</span>fn main() <span class="annotation">⦉@0</span></span></span><span class="code" style="--layer: 0">{</span></span> +<span class="line"><span class="code" style="--layer: 0"> if </span><span><span class="code even" style="--layer: 1" title="74:8-74:12: @0[1]: _1 = const true +74:8-74:12: @0[2]: FakeRead(ForMatchedPlace, _1)"><span class="annotation">@0⦊</span>true<span class="annotation">⦉@0</span></span></span><span class="code" style="--layer: 0"> {</span></span> +<span class="line"><span class="code" style="--layer: 0"> </span><span><span class="code odd" style="--layer: 1" title="75:9-75:26: @5[0]: _2 = const ()"><span class="annotation">@5⦊</span></span></span><span class="code even" style="--layer: 2" title="75:9-75:26: @6[5]: _75 = const main::promoted[3] +75:9-75:26: @6[6]: _18 = &(*_75) +75:9-75:26: @6[7]: _17 = &(*_18) +75:9-75:26: @6[8]: _16 = move _17 as &[&str] (Pointer(Unsize)) +75:9-75:26: @6[17]: _26 = &(*_8) +75:9-75:26: @6[18]: _25 = &_26 +75:9-75:26: @6[21]: _28 = &(*_9) +75:9-75:26: @6[22]: _27 = &_28 +75:9-75:26: @6[23]: _24 = (move _25, move _27) +75:9-75:26: @6[26]: FakeRead(ForMatchedPlace, _24) +75:9-75:26: @6[28]: _29 = (_24.0: &&i32) +75:9-75:26: @6[30]: _30 = (_24.1: &&i32) +75:9-75:26: @6[33]: _32 = &(*_29) +75:9-75:26: @6[35]: _33 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +75:9-75:26: @6.Call: _31 = ArgumentV1::new::<&i32>(move _32, move _33) -> [return: bb7, unwind: bb17] +75:9-75:26: @7[4]: _35 = &(*_30) +75:9-75:26: @7[6]: _36 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +75:9-75:26: @7.Call: _34 = ArgumentV1::new::<&i32>(move _35, move _36) -> [return: bb8, unwind: bb17] +75:9-75:26: @8[2]: _23 = [move _31, move _34] +75:9-75:26: @8[7]: _22 = &_23 +75:9-75:26: @8[8]: _21 = &(*_22) +75:9-75:26: @8[9]: _20 = move _21 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +75:9-75:26: @8.Call: _15 = Arguments::new_v1(move _16, move _20) -> [return: bb9, unwind: bb17] +75:9-75:26: @9.Call: core::panicking::panic_fmt(move _15) -> bb17"><span class="annotation">@4,6,7,8,9⦊</span>assert_eq!(1, 1);<span class="annotation">⦉@4,6,7,8,9</span></span><span><span class="code odd" style="--layer: 1" title="75:9-75:26: @5[0]: _2 = const ()"><span class="annotation">⦉@5</span></span></span><span class="code" style="--layer: 0"></span></span> +<span class="line"><span class="code" style="--layer: 0"> } else {</span></span> +<span class="line"><span class="code" style="--layer: 0"> </span><span><span class="code even" style="--layer: 1" title="77:9-77:26: @11[0]: _37 = const ()"><span class="annotation">@11⦊</span></span></span><span class="code even" style="--layer: 2" title="77:9-77:26: @12[5]: _72 = const main::promoted[0] +77:9-77:26: @12[6]: _53 = &(*_72) +77:9-77:26: @12[7]: _52 = &(*_53) +77:9-77:26: @12[8]: _51 = move _52 as &[&str] (Pointer(Unsize)) +77:9-77:26: @12[17]: _61 = &(*_43) +77:9-77:26: @12[18]: _60 = &_61 +77:9-77:26: @12[21]: _63 = &(*_44) +77:9-77:26: @12[22]: _62 = &_63 +77:9-77:26: @12[23]: _59 = (move _60, move _62) +77:9-77:26: @12[26]: FakeRead(ForMatchedPlace, _59) +77:9-77:26: @12[28]: _64 = (_59.0: &&i32) +77:9-77:26: @12[30]: _65 = (_59.1: &&i32) +77:9-77:26: @12[33]: _67 = &(*_64) +77:9-77:26: @12[35]: _68 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +77:9-77:26: @12.Call: _66 = ArgumentV1::new::<&i32>(move _67, move _68) -> [return: bb13, unwind: bb17] +77:9-77:26: @13[4]: _70 = &(*_65) +77:9-77:26: @13[6]: _71 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +77:9-77:26: @13.Call: _69 = ArgumentV1::new::<&i32>(move _70, move _71) -> [return: bb14, unwind: bb17] +77:9-77:26: @14[2]: _58 = [move _66, move _69] +77:9-77:26: @14[7]: _57 = &_58 +77:9-77:26: @14[8]: _56 = &(*_57) +77:9-77:26: @14[9]: _55 = move _56 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +77:9-77:26: @14.Call: _50 = Arguments::new_v1(move _51, move _55) -> [return: bb15, unwind: bb17] +77:9-77:26: @15.Call: core::panicking::panic_fmt(move _50) -> bb17"><span class="annotation">@10,12,13,14,15⦊</span>assert_eq!(1, 2);<span class="annotation">⦉@10,12,13,14,15</span></span><span><span class="code even" style="--layer: 1" title="77:9-77:26: @11[0]: _37 = const ()"><span class="annotation">⦉@11</span></span></span><span class="code" style="--layer: 0"></span></span> +<span class="line"><span class="code" style="--layer: 0"> }</span></span> +<span class="line"><span class="code" style="--layer: 0">}</span><span><span class="code odd" style="--layer: 1" title="79:2-79:2: @16.Return: return"><span class="annotation">@16⦊</span>‸<span class="annotation">⦉@16</span></span></span></span></div> +</body> +</html> diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html new file mode 100644 index 00000000000..ae119d9ca9f --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html @@ -0,0 +1,173 @@ +<!DOCTYPE html> +<!-- + +Preview this file as rendered HTML from the github source at: +https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html + +For revisions in Pull Requests (PR): + * Replace "rust-lang" with the github PR author + * Replace "master" with the PR branch name + +--> +<html> +<head> +<title>doctest_crate.fn_run_in_doctests - Coverage Spans</title> +<style> + .line { + counter-increment: line; + } + .line:before { + content: counter(line) ": "; + font-family: Menlo, Monaco, monospace; + font-style: italic; + width: 3.8em; + display: inline-block; + text-align: right; + filter: opacity(50%); + -webkit-user-select: none; + } + .code { + color: #dddddd; + background-color: #222222; + font-family: Menlo, Monaco, monospace; + line-height: 1.4em; + border-bottom: 2px solid #222222; + white-space: pre; + display: inline-block; + } + .odd { + background-color: #55bbff; + color: #223311; + } + .even { + background-color: #ee7756; + color: #551133; + } + .code { + --index: calc(var(--layer) - 1); + padding-top: calc(var(--index) * 0.15em); + filter: + hue-rotate(calc(var(--index) * 25deg)) + saturate(calc(100% - (var(--index) * 2%))) + brightness(calc(100% - (var(--index) * 1.5%))); + } + .annotation { + color: #4444ff; + font-family: monospace; + font-style: italic; + display: none; + -webkit-user-select: none; + } + body:active .annotation { + /* requires holding mouse down anywhere on the page */ + display: inline-block; + } + span:hover .annotation { + /* requires hover over a span ONLY on its first line */ + display: inline-block; + } +</style> +</head> +<body> +<div class="code" style="counter-reset: line 1"><span class="line"><span><span class="code even" style="--layer: 1"><span class="annotation">@0⦊</span>pub fn fn_run_in_doctests(conditional: usize) <span class="annotation">⦉@0</span></span></span><span class="code" style="--layer: 0">{</span></span> +<span class="line"><span class="code" style="--layer: 0"> match </span><span><span class="code even" style="--layer: 1" title="3:11-3:22: @0[0]: FakeRead(ForMatchedPlace, _1)"><span class="annotation">@0⦊</span>conditional<span class="annotation">⦉@0</span></span></span><span class="code" style="--layer: 0"> {</span></span> +<span class="line"><span class="code" style="--layer: 0"> 1 => </span><span><span class="code odd" style="--layer: 1" title="4:14-4:30: @7[0]: _0 = const ()"><span class="annotation">@7⦊</span></span></span><span class="code even" style="--layer: 2" title="4:14-4:30: @8[5]: _138 = const fn_run_in_doctests::promoted[0] +4:14-4:30: @8[6]: _17 = &(*_138) +4:14-4:30: @8[7]: _16 = &(*_17) +4:14-4:30: @8[8]: _15 = move _16 as &[&str] (Pointer(Unsize)) +4:14-4:30: @8[17]: _25 = &(*_7) +4:14-4:30: @8[18]: _24 = &_25 +4:14-4:30: @8[21]: _27 = &(*_8) +4:14-4:30: @8[22]: _26 = &_27 +4:14-4:30: @8[23]: _23 = (move _24, move _26) +4:14-4:30: @8[26]: FakeRead(ForMatchedPlace, _23) +4:14-4:30: @8[28]: _28 = (_23.0: &&i32) +4:14-4:30: @8[30]: _29 = (_23.1: &&i32) +4:14-4:30: @8[33]: _31 = &(*_28) +4:14-4:30: @8[35]: _32 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +4:14-4:30: @8.Call: _30 = ArgumentV1::new::<&i32>(move _31, move _32) -> [return: bb9, unwind: bb33] +4:14-4:30: @9[4]: _34 = &(*_29) +4:14-4:30: @9[6]: _35 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +4:14-4:30: @9.Call: _33 = ArgumentV1::new::<&i32>(move _34, move _35) -> [return: bb10, unwind: bb33] +4:14-4:30: @10[2]: _22 = [move _30, move _33] +4:14-4:30: @10[7]: _21 = &_22 +4:14-4:30: @10[8]: _20 = &(*_21) +4:14-4:30: @10[9]: _19 = move _20 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +4:14-4:30: @10.Call: _14 = Arguments::new_v1(move _15, move _19) -> [return: bb11, unwind: bb33] +4:14-4:30: @11.Call: core::panicking::panic_fmt(move _14) -> bb33"><span class="annotation">@6,8,9,10,11⦊</span>assert_eq!(1, 1)<span class="annotation">⦉@6,8,9,10,11</span></span><span><span class="code odd" style="--layer: 1" title="4:14-4:30: @7[0]: _0 = const ()"><span class="annotation">⦉@7</span></span></span><span class="code" style="--layer: 0">, // this is run,</span></span> +<span class="line"><span class="code" style="--layer: 0"> 2 => </span><span><span class="code even" style="--layer: 1" title="5:14-5:30: @14[0]: _0 = const ()"><span class="annotation">@14⦊</span></span></span><span class="code even" style="--layer: 2" title="5:14-5:30: @15[5]: _141 = const fn_run_in_doctests::promoted[3] +5:14-5:30: @15[6]: _51 = &(*_141) +5:14-5:30: @15[7]: _50 = &(*_51) +5:14-5:30: @15[8]: _49 = move _50 as &[&str] (Pointer(Unsize)) +5:14-5:30: @15[17]: _59 = &(*_41) +5:14-5:30: @15[18]: _58 = &_59 +5:14-5:30: @15[21]: _61 = &(*_42) +5:14-5:30: @15[22]: _60 = &_61 +5:14-5:30: @15[23]: _57 = (move _58, move _60) +5:14-5:30: @15[26]: FakeRead(ForMatchedPlace, _57) +5:14-5:30: @15[28]: _62 = (_57.0: &&i32) +5:14-5:30: @15[30]: _63 = (_57.1: &&i32) +5:14-5:30: @15[33]: _65 = &(*_62) +5:14-5:30: @15[35]: _66 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +5:14-5:30: @15.Call: _64 = ArgumentV1::new::<&i32>(move _65, move _66) -> [return: bb16, unwind: bb33] +5:14-5:30: @16[4]: _68 = &(*_63) +5:14-5:30: @16[6]: _69 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +5:14-5:30: @16.Call: _67 = ArgumentV1::new::<&i32>(move _68, move _69) -> [return: bb17, unwind: bb33] +5:14-5:30: @17[2]: _56 = [move _64, move _67] +5:14-5:30: @17[7]: _55 = &_56 +5:14-5:30: @17[8]: _54 = &(*_55) +5:14-5:30: @17[9]: _53 = move _54 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +5:14-5:30: @17.Call: _48 = Arguments::new_v1(move _49, move _53) -> [return: bb18, unwind: bb33] +5:14-5:30: @18.Call: core::panicking::panic_fmt(move _48) -> bb33"><span class="annotation">@13,15,16,17,18⦊</span>assert_eq!(1, 1)<span class="annotation">⦉@13,15,16,17,18</span></span><span><span class="code even" style="--layer: 1" title="5:14-5:30: @14[0]: _0 = const ()"><span class="annotation">⦉@14</span></span></span><span class="code" style="--layer: 0">, // this,</span></span> +<span class="line"><span class="code" style="--layer: 0"> 3 => </span><span><span class="code odd" style="--layer: 1" title="6:14-6:30: @21[0]: _0 = const ()"><span class="annotation">@21⦊</span></span></span><span class="code even" style="--layer: 2" title="6:14-6:30: @22[5]: _144 = const fn_run_in_doctests::promoted[6] +6:14-6:30: @22[6]: _85 = &(*_144) +6:14-6:30: @22[7]: _84 = &(*_85) +6:14-6:30: @22[8]: _83 = move _84 as &[&str] (Pointer(Unsize)) +6:14-6:30: @22[17]: _93 = &(*_75) +6:14-6:30: @22[18]: _92 = &_93 +6:14-6:30: @22[21]: _95 = &(*_76) +6:14-6:30: @22[22]: _94 = &_95 +6:14-6:30: @22[23]: _91 = (move _92, move _94) +6:14-6:30: @22[26]: FakeRead(ForMatchedPlace, _91) +6:14-6:30: @22[28]: _96 = (_91.0: &&i32) +6:14-6:30: @22[30]: _97 = (_91.1: &&i32) +6:14-6:30: @22[33]: _99 = &(*_96) +6:14-6:30: @22[35]: _100 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +6:14-6:30: @22.Call: _98 = ArgumentV1::new::<&i32>(move _99, move _100) -> [return: bb23, unwind: bb33] +6:14-6:30: @23[4]: _102 = &(*_97) +6:14-6:30: @23[6]: _103 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +6:14-6:30: @23.Call: _101 = ArgumentV1::new::<&i32>(move _102, move _103) -> [return: bb24, unwind: bb33] +6:14-6:30: @24[2]: _90 = [move _98, move _101] +6:14-6:30: @24[7]: _89 = &_90 +6:14-6:30: @24[8]: _88 = &(*_89) +6:14-6:30: @24[9]: _87 = move _88 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +6:14-6:30: @24.Call: _82 = Arguments::new_v1(move _83, move _87) -> [return: bb25, unwind: bb33] +6:14-6:30: @25.Call: core::panicking::panic_fmt(move _82) -> bb33"><span class="annotation">@20,22,23,24,25⦊</span>assert_eq!(1, 1)<span class="annotation">⦉@20,22,23,24,25</span></span><span><span class="code odd" style="--layer: 1" title="6:14-6:30: @21[0]: _0 = const ()"><span class="annotation">⦉@21</span></span></span><span class="code" style="--layer: 0">, // and this too</span></span> +<span class="line"><span class="code" style="--layer: 0"> _ => </span><span><span class="code even" style="--layer: 1" title="7:14-7:30: @27[0]: _0 = const ()"><span class="annotation">@27⦊</span></span></span><span class="code even" style="--layer: 2" title="7:14-7:30: @28[5]: _147 = const fn_run_in_doctests::promoted[9] +7:14-7:30: @28[6]: _119 = &(*_147) +7:14-7:30: @28[7]: _118 = &(*_119) +7:14-7:30: @28[8]: _117 = move _118 as &[&str] (Pointer(Unsize)) +7:14-7:30: @28[17]: _127 = &(*_109) +7:14-7:30: @28[18]: _126 = &_127 +7:14-7:30: @28[21]: _129 = &(*_110) +7:14-7:30: @28[22]: _128 = &_129 +7:14-7:30: @28[23]: _125 = (move _126, move _128) +7:14-7:30: @28[26]: FakeRead(ForMatchedPlace, _125) +7:14-7:30: @28[28]: _130 = (_125.0: &&i32) +7:14-7:30: @28[30]: _131 = (_125.1: &&i32) +7:14-7:30: @28[33]: _133 = &(*_130) +7:14-7:30: @28[35]: _134 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +7:14-7:30: @28.Call: _132 = ArgumentV1::new::<&i32>(move _133, move _134) -> [return: bb29, unwind: bb33] +7:14-7:30: @29[4]: _136 = &(*_131) +7:14-7:30: @29[6]: _137 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +7:14-7:30: @29.Call: _135 = ArgumentV1::new::<&i32>(move _136, move _137) -> [return: bb30, unwind: bb33] +7:14-7:30: @30[2]: _124 = [move _132, move _135] +7:14-7:30: @30[7]: _123 = &_124 +7:14-7:30: @30[8]: _122 = &(*_123) +7:14-7:30: @30[9]: _121 = move _122 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +7:14-7:30: @30.Call: _116 = Arguments::new_v1(move _117, move _121) -> [return: bb31, unwind: bb33] +7:14-7:30: @31.Call: core::panicking::panic_fmt(move _116) -> bb33"><span class="annotation">@26,28,29,30,31⦊</span>assert_eq!(1, 2)<span class="annotation">⦉@26,28,29,30,31</span></span><span><span class="code even" style="--layer: 1" title="7:14-7:30: @27[0]: _0 = const ()"><span class="annotation">⦉@27</span></span></span><span class="code" style="--layer: 0">, // however this is not</span></span> +<span class="line"><span class="code" style="--layer: 0"> }</span></span> +<span class="line"><span class="code" style="--layer: 0">}</span><span><span class="code odd" style="--layer: 1" title="9:2-9:2: @32.Return: return"><span class="annotation">@32⦊</span>‸<span class="annotation">⦉@32</span></span></span></span></div> +</body> +</html> diff --git a/src/test/run-make-fulldeps/coverage/compiletest-ignore-dir b/src/test/run-make-fulldeps/coverage/compiletest-ignore-dir index abf8df8fdc9..d1824d189e3 100644 --- a/src/test/run-make-fulldeps/coverage/compiletest-ignore-dir +++ b/src/test/run-make-fulldeps/coverage/compiletest-ignore-dir @@ -1,3 +1,3 @@ -# Directory "instrument-coverage" supports the tests at prefix ../instrument-coverage-* +# Directory "coverage" supports the tests at prefix ../coverage-* -# Use ./x.py [options] test src/test/run-make-fulldeps/instrument-coverage to run all related tests. +# Use ./x.py [options] test src/test/run-make-fulldeps/coverage to run all related tests. diff --git a/src/test/run-make-fulldeps/coverage/coverage_tools.mk b/src/test/run-make-fulldeps/coverage/coverage_tools.mk index 7dc485cd94d..4d340d4b1da 100644 --- a/src/test/run-make-fulldeps/coverage/coverage_tools.mk +++ b/src/test/run-make-fulldeps/coverage/coverage_tools.mk @@ -1,7 +1,7 @@ -# Common Makefile include for Rust `run-make-fulldeps/instrument-coverage-* tests. Include this +# Common Makefile include for Rust `run-make-fulldeps/coverage-* tests. Include this # file with the line: # -# -include ../instrument-coverage/coverage_tools.mk +# -include ../coverage/coverage_tools.mk -include ../tools.mk diff --git a/src/test/run-make-fulldeps/coverage/doctest.rs b/src/test/run-make-fulldeps/coverage/doctest.rs new file mode 100644 index 00000000000..ec04ea57063 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage/doctest.rs @@ -0,0 +1,99 @@ +//! This test ensures that code from doctests is properly re-mapped. +//! See <https://github.com/rust-lang/rust/issues/79417> for more info. +//! +//! Just some random code: +//! ``` +//! if true { +//! // this is executed! +//! assert_eq!(1, 1); +//! } else { +//! // this is not! +//! assert_eq!(1, 2); +//! } +//! ``` +//! +//! doctest testing external code: +//! ``` +//! extern crate doctest_crate; +//! doctest_crate::fn_run_in_doctests(1); +//! ``` +//! +//! doctest returning a result: +//! ``` +//! #[derive(Debug, PartialEq)] +//! struct SomeError { +//! msg: String, +//! } +//! let mut res = Err(SomeError { msg: String::from("a message") }); +//! if res.is_ok() { +//! res?; +//! } else { +//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { +//! println!("{:?}", res); +//! } +//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() { +//! res = Ok(1); +//! } +//! res = Ok(0); +//! } +//! // need to be explicit because rustdoc cant infer the return type +//! Ok::<(), SomeError>(()) +//! ``` +//! +//! doctest with custom main: +//! ``` +//! fn some_func() { +//! println!("called some_func()"); +//! } +//! +//! #[derive(Debug)] +//! struct SomeError; +//! +//! extern crate doctest_crate; +//! +//! fn doctest_main() -> Result<(), SomeError> { +//! some_func(); +//! doctest_crate::fn_run_in_doctests(2); +//! Ok(()) +//! } +//! +//! // this `main` is not shown as covered, as it clashes with all the other +//! // `main` functions that were automatically generated for doctests +//! fn main() -> Result<(), SomeError> { +//! doctest_main() +//! } +//! ``` + +/// doctest attached to fn testing external code: +/// ``` +/// extern crate doctest_crate; +/// doctest_crate::fn_run_in_doctests(3); +/// ``` +/// +fn main() { + if true { + assert_eq!(1, 1); + } else { + assert_eq!(1, 2); + } +} + +// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the +// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc +// comment characters). This test produces `llvm-cov show` results demonstrating the problem. +// +// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show` +// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong +// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or +// one character past, the `if` block's closing brace. In both cases, these are most likely off +// by the number of characters stripped from the beginning of each doc comment line: indent +// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character +// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are +// more pronounced, and show up in more places, with background color used to show some distinct +// code regions with different coverage counts. +// +// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each +// character stripped from the beginning of doc comment lines with a space. This will give coverage +// results the correct column offsets, and I think it should compile correctly, but I don't know +// what affect it might have on diagnostic messages from the compiler, and whether anyone would care +// if the indentation changed. I don't know if there is a more viable solution. diff --git a/src/test/run-make-fulldeps/coverage/lib/doctest_crate.rs b/src/test/run-make-fulldeps/coverage/lib/doctest_crate.rs new file mode 100644 index 00000000000..c3210146d69 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage/lib/doctest_crate.rs @@ -0,0 +1,9 @@ +/// A function run only from within doctests +pub fn fn_run_in_doctests(conditional: usize) { + match conditional { + 1 => assert_eq!(1, 1), // this is run, + 2 => assert_eq!(1, 1), // this, + 3 => assert_eq!(1, 1), // and this too + _ => assert_eq!(1, 2), // however this is not + } +} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile index 03a797d95f9..e7268311b13 100644 --- a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile @@ -1,9 +1,8 @@ -include ../tools.mk -# Modelled after compile-fail/changing-crates test, but this one puts +# Modelled after ui/changing-crates.rs test, but this one puts # more than one (mismatching) candidate crate into the search path, -# which did not appear directly expressible in compile-fail/aux-build -# infrastructure. +# which did not appear directly expressible in UI testing infrastructure. # # Note that we move the built libraries into target direcrtories rather than # use the `--out-dir` option because the `../tools.mk` file already bakes a @@ -33,4 +32,4 @@ all: 'crate `crateA`:' \ 'crate `crateB`:' \ < $(LOG) - # the 'crate `crateA`' will match two entries. \ No newline at end of file + # the 'crate `crateA`' will match two entries. diff --git a/src/test/run-make-fulldeps/separate-link/Makefile b/src/test/run-make-fulldeps/separate-link/Makefile new file mode 100644 index 00000000000..060484e89f9 --- /dev/null +++ b/src/test/run-make-fulldeps/separate-link/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + echo 'fn main(){}' | $(RUSTC) -Z no-link - + $(RUSTC) -Z link-only $(TMPDIR)/rust_out.rlink + $(call RUN,rust_out) diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs index 12898aa5c74..71b38a9f8ca 100644 --- a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs @@ -5,7 +5,7 @@ // causing a type mismatch. // The test is nearly the same as the one in -// compile-fail/type-mismatch-same-crate-name.rs +// ui/type/type-mismatch-same-crate-name.rs // but deals with the case where one of the crates // is only introduced as an indirect dependency. // and the type is accessed via a re-export. diff --git a/src/test/rustdoc-ui/auxiliary/issue-61592.rs b/src/test/rustdoc-ui/auxiliary/issue-61592.rs new file mode 100644 index 00000000000..57a365b3f38 --- /dev/null +++ b/src/test/rustdoc-ui/auxiliary/issue-61592.rs @@ -0,0 +1,3 @@ +#![crate_name = "foo"] + +pub trait Foo {} diff --git a/src/test/rustdoc-ui/doc-alias-crate-level.rs b/src/test/rustdoc-ui/doc-alias-crate-level.rs index 309d0bc4d43..70618ac01df 100644 --- a/src/test/rustdoc-ui/doc-alias-crate-level.rs +++ b/src/test/rustdoc-ui/doc-alias-crate-level.rs @@ -1,5 +1,3 @@ -#![feature(doc_alias)] - #![doc(alias = "crate-level-not-working")] //~ ERROR #[doc(alias = "shouldn't work!")] //~ ERROR diff --git a/src/test/rustdoc-ui/doc-alias-crate-level.stderr b/src/test/rustdoc-ui/doc-alias-crate-level.stderr index a58e91c5aa7..9e746cba05f 100644 --- a/src/test/rustdoc-ui/doc-alias-crate-level.stderr +++ b/src/test/rustdoc-ui/doc-alias-crate-level.stderr @@ -1,11 +1,11 @@ error: '\'' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/doc-alias-crate-level.rs:5:15 + --> $DIR/doc-alias-crate-level.rs:3:15 | LL | #[doc(alias = "shouldn't work!")] | ^^^^^^^^^^^^^^^^^ error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute - --> $DIR/doc-alias-crate-level.rs:3:8 + --> $DIR/doc-alias-crate-level.rs:1:8 | LL | #![doc(alias = "crate-level-not-working")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/doc-alias-same-name.rs b/src/test/rustdoc-ui/doc-alias-same-name.rs new file mode 100644 index 00000000000..da97c267618 --- /dev/null +++ b/src/test/rustdoc-ui/doc-alias-same-name.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[doc(alias = "Foo")] //~ ERROR +pub struct Foo; diff --git a/src/test/rustdoc-ui/doc-alias-same-name.stderr b/src/test/rustdoc-ui/doc-alias-same-name.stderr new file mode 100644 index 00000000000..5ba09a2eae1 --- /dev/null +++ b/src/test/rustdoc-ui/doc-alias-same-name.stderr @@ -0,0 +1,8 @@ +error: `#[doc(alias = "...")]` is the same as the item's name + --> $DIR/doc-alias-same-name.rs:3:7 + | +LL | #[doc(alias = "Foo")] + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs b/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs index 97760cbf8fb..ed62f0208aa 100644 --- a/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs +++ b/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs @@ -1,6 +1,5 @@ // check-pass // edition:2018 -#![feature(min_const_generics)] trait ValidTrait {} /// This has docs diff --git a/src/test/rustdoc-ui/ignore-block-help.rs b/src/test/rustdoc-ui/ignore-block-help.rs new file mode 100644 index 00000000000..c22dddd11df --- /dev/null +++ b/src/test/rustdoc-ui/ignore-block-help.rs @@ -0,0 +1,7 @@ +// check-pass + +/// ```ignore (to-prevent-tidy-error) +/// let heart = '❤️'; +/// ``` +//~^^^ WARN +pub struct X; diff --git a/src/test/rustdoc-ui/ignore-block-help.stderr b/src/test/rustdoc-ui/ignore-block-help.stderr new file mode 100644 index 00000000000..d45cd92d2d1 --- /dev/null +++ b/src/test/rustdoc-ui/ignore-block-help.stderr @@ -0,0 +1,17 @@ +warning: could not parse code block as Rust code + --> $DIR/ignore-block-help.rs:3:5 + | +LL | /// ```ignore (to-prevent-tidy-error) + | _____^ +LL | | /// let heart = '❤️'; +LL | | /// ``` + | |_______^ + | + = note: error from rustc: character literal may only contain one codepoint +help: `ignore` code blocks require valid Rust code for syntax highlighting. Mark blocks that do not contain Rust code as text + | +LL | /// ```text,ignore (to-prevent-tidy-error) + | ^^^^^^^^ + +warning: 1 warning emitted + diff --git a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs new file mode 100644 index 00000000000..0d1d5d1134b --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs @@ -0,0 +1,3 @@ +#![deny(broken_intra_doc_links)] +//! [static@u8::MIN] +//~^ ERROR incompatible link kind diff --git a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr new file mode 100644 index 00000000000..ed1c10f9e0c --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr @@ -0,0 +1,15 @@ +error: incompatible link kind for `u8::MIN` + --> $DIR/incompatible-primitive-disambiguator.rs:2:6 + | +LL | //! [static@u8::MIN] + | ^^^^^^^^^^^^^^ help: to link to the associated constant, prefix with `const@`: `const@u8::MIN` + | +note: the lint level is defined here + --> $DIR/incompatible-primitive-disambiguator.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: this link resolved to an associated constant, which is not a static + +error: aborting due to previous error + diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs new file mode 100644 index 00000000000..114502b0ddf --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs @@ -0,0 +1,34 @@ +#![deny(broken_intra_doc_links)] +// These are links that could reasonably expected to work, but don't. + +// `[]` isn't supported because it had too many false positives. +//! [X]([T]::not_here) +//! [Y](&[]::not_here) +//! [X]([]::not_here) +//! [Y]([T;N]::not_here) + +// These don't work because markdown syntax doesn't allow it. +//! [[T]::rotate_left] //~ ERROR unresolved link to `T` +//! [&[]::not_here] +// //~ ERROR unresolved link to `Z` +//! [`[T; N]::map`] +//! [[]::map] +//! [Z][] //~ ERROR unresolved link to `Z` +//! +//! [Z]: [T; N]::map //~ ERROR unresolved link to `Z` + +// `()` isn't supported because it had too many false positives. +//! [()::not_here] +//! [X]((,)::not_here) +//! [(,)::not_here] + +// FIXME: Associated items on some primitives aren't working, because the impls +// are part of the compiler instead of being part of the source code. +//! [unit::eq] //~ ERROR unresolved +//! [tuple::eq] //~ ERROR unresolved +//! [fn::eq] //~ ERROR unresolved +//! [never::eq] //~ ERROR unresolved + +// FIXME(#78800): This breaks because it's a blanket impl +// (I think? Might break for other reasons too.) +//! [reference::deref] //~ ERROR unresolved diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr new file mode 100644 index 00000000000..ea831e648f6 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr @@ -0,0 +1,69 @@ +error: unresolved link to `T` + --> $DIR/non-path-primitives.rs:11:7 + | +LL | //! [[T]::rotate_left] + | ^ no item named `T` in scope + | +note: the lint level is defined here + --> $DIR/non-path-primitives.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `Z` + --> $DIR/non-path-primitives.rs:13:5 + | +LL | // + | ^ no item named `Z` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `Z` + --> $DIR/non-path-primitives.rs:16:6 + | +LL | //! [Z][] + | ^ no item named `Z` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `Z` + --> $DIR/non-path-primitives.rs:18:6 + | +LL | //! [Z]: [T; N]::map + | ^ no item named `Z` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `unit::eq` + --> $DIR/non-path-primitives.rs:27:6 + | +LL | //! [unit::eq] + | ^^^^^^^^ the builtin type `unit` has no associated item named `eq` + +error: unresolved link to `tuple::eq` + --> $DIR/non-path-primitives.rs:28:6 + | +LL | //! [tuple::eq] + | ^^^^^^^^^ the builtin type `tuple` has no associated item named `eq` + +error: unresolved link to `fn::eq` + --> $DIR/non-path-primitives.rs:29:6 + | +LL | //! [fn::eq] + | ^^^^^^ the builtin type `fn` has no associated item named `eq` + +error: unresolved link to `never::eq` + --> $DIR/non-path-primitives.rs:30:6 + | +LL | //! [never::eq] + | ^^^^^^^^^ the builtin type `never` has no associated item named `eq` + +error: unresolved link to `reference::deref` + --> $DIR/non-path-primitives.rs:34:6 + | +LL | //! [reference::deref] + | ^^^^^^^^^^^^^^^^ the builtin type `reference` has no associated item named `deref` + +error: aborting due to 9 previous errors + diff --git a/src/test/rustdoc-ui/invalid-syntax.stderr b/src/test/rustdoc-ui/invalid-syntax.stderr index 9a7a4d21013..75acdc5ab5f 100644 --- a/src/test/rustdoc-ui/invalid-syntax.stderr +++ b/src/test/rustdoc-ui/invalid-syntax.stderr @@ -127,8 +127,10 @@ LL | /// ```text warning: could not parse code block as Rust code --> $DIR/invalid-syntax.rs:92:9 | -LL | /// \____/ - | ^^^^^^ +LL | /// \____/ + | _________^ +LL | | /// + | |_ | = note: error from rustc: unknown start of token: \ diff --git a/src/test/rustdoc-ui/issue-61592-2.rs b/src/test/rustdoc-ui/issue-61592-2.rs new file mode 100644 index 00000000000..5b4fc5ee700 --- /dev/null +++ b/src/test/rustdoc-ui/issue-61592-2.rs @@ -0,0 +1,10 @@ +// aux-build:issue-61592.rs + +extern crate foo; + +#[doc = "bar"] +#[doc(inline)] //~ ERROR +#[doc = "baz"] +pub use foo::Foo as _; + +fn main() {} diff --git a/src/test/rustdoc-ui/issue-61592-2.stderr b/src/test/rustdoc-ui/issue-61592-2.stderr new file mode 100644 index 00000000000..1b7f8bb552c --- /dev/null +++ b/src/test/rustdoc-ui/issue-61592-2.stderr @@ -0,0 +1,12 @@ +error[E0780]: anonymous imports cannot be inlined + --> $DIR/issue-61592-2.rs:6:7 + | +LL | #[doc(inline)] + | ^^^^^^ +LL | #[doc = "baz"] +LL | pub use foo::Foo as _; + | ---------------------- anonymous import + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0780`. diff --git a/src/test/rustdoc-ui/issue-61592.rs b/src/test/rustdoc-ui/issue-61592.rs new file mode 100644 index 00000000000..66772557f2c --- /dev/null +++ b/src/test/rustdoc-ui/issue-61592.rs @@ -0,0 +1,8 @@ +// aux-build:issue-61592.rs + +extern crate foo; + +#[doc(inline)] //~ ERROR +pub use foo::Foo as _; + +fn main() {} diff --git a/src/test/rustdoc-ui/issue-61592.stderr b/src/test/rustdoc-ui/issue-61592.stderr new file mode 100644 index 00000000000..9c9c9106f8a --- /dev/null +++ b/src/test/rustdoc-ui/issue-61592.stderr @@ -0,0 +1,11 @@ +error[E0780]: anonymous imports cannot be inlined + --> $DIR/issue-61592.rs:5:7 + | +LL | #[doc(inline)] + | ^^^^^^ +LL | pub use foo::Foo as _; + | ---------------------- anonymous import + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0780`. diff --git a/src/test/rustdoc-ui/reference-link-reports-error-once.rs b/src/test/rustdoc-ui/reference-link-reports-error-once.rs new file mode 100644 index 00000000000..7957ee373c4 --- /dev/null +++ b/src/test/rustdoc-ui/reference-link-reports-error-once.rs @@ -0,0 +1,20 @@ +#![deny(broken_intra_doc_links)] + +/// Links to [a] [link][a] +/// And also a [third link][a] +/// And also a [reference link][b] +/// +/// Other links to the same target should still emit error: [ref] //~ERROR unresolved link to `ref` +/// Duplicate [ref] //~ERROR unresolved link to `ref` +/// +/// Other links to other targets should still emit error: [ref2] //~ERROR unresolved link to `ref2` +/// Duplicate [ref2] //~ERROR unresolved link to `ref2` +/// +/// [a]: ref +//~^ ERROR unresolved link to `ref` +/// [b]: ref2 +//~^ ERROR unresolved link to + +/// [ref][] +//~^ ERROR unresolved link +pub fn f() {} diff --git a/src/test/rustdoc-ui/reference-link-reports-error-once.stderr b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr new file mode 100644 index 00000000000..218eb334a6f --- /dev/null +++ b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr @@ -0,0 +1,63 @@ +error: unresolved link to `ref` + --> $DIR/reference-link-reports-error-once.rs:13:10 + | +LL | /// [a]: ref + | ^^^ no item named `ref` in scope + | +note: the lint level is defined here + --> $DIR/reference-link-reports-error-once.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref2` + --> $DIR/reference-link-reports-error-once.rs:15:10 + | +LL | /// [b]: ref2 + | ^^^^ no item named `ref2` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref` + --> $DIR/reference-link-reports-error-once.rs:7:62 + | +LL | /// Other links to the same target should still emit error: [ref] + | ^^^ no item named `ref` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref` + --> $DIR/reference-link-reports-error-once.rs:8:16 + | +LL | /// Duplicate [ref] + | ^^^ no item named `ref` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref2` + --> $DIR/reference-link-reports-error-once.rs:10:60 + | +LL | /// Other links to other targets should still emit error: [ref2] + | ^^^^ no item named `ref2` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref2` + --> $DIR/reference-link-reports-error-once.rs:11:16 + | +LL | /// Duplicate [ref2] + | ^^^^ no item named `ref2` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `ref` + --> $DIR/reference-link-reports-error-once.rs:18:6 + | +LL | /// [ref][] + | ^^^ no item named `ref` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: aborting due to 7 previous errors + diff --git a/src/test/rustdoc-ui/reference-links.rs b/src/test/rustdoc-ui/reference-links.rs new file mode 100644 index 00000000000..6e00b9f0fa1 --- /dev/null +++ b/src/test/rustdoc-ui/reference-links.rs @@ -0,0 +1,6 @@ +// Test that errors point to the reference, not to the title text. +#![deny(broken_intra_doc_links)] +//! Links to [a] [link][a] +//! +//! [a]: std::process::Comman +//~^ ERROR unresolved diff --git a/src/test/rustdoc-ui/reference-links.stderr b/src/test/rustdoc-ui/reference-links.stderr new file mode 100644 index 00000000000..3df89df21b4 --- /dev/null +++ b/src/test/rustdoc-ui/reference-links.stderr @@ -0,0 +1,14 @@ +error: unresolved link to `std::process::Comman` + --> $DIR/reference-links.rs:5:10 + | +LL | //! [a]: std::process::Comman + | ^^^^^^^^^^^^^^^^^^^^ no item named `Comman` in module `process` + | +note: the lint level is defined here + --> $DIR/reference-links.rs:2:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/rustdoc/async-fn.rs b/src/test/rustdoc/async-fn.rs index e7a7d1831f7..aa4ad261c80 100644 --- a/src/test/rustdoc/async-fn.rs +++ b/src/test/rustdoc/async-fn.rs @@ -1,6 +1,5 @@ +// ignore-tidy-linelength // edition:2018 -#![feature(min_const_generics)] - // @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>' pub async fn foo() -> Option<Foo> { None @@ -48,7 +47,50 @@ impl Foo { pub async fn mut_self(mut self, mut first: usize) {} } +pub trait Pattern<'a> {} + pub trait Trait<const N: usize> {} // @has async_fn/fn.const_generics.html // @has - '//pre[@class="rust fn"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)' pub async fn const_generics<const N: usize>(_: impl Trait<N>) {} + +// test that elided lifetimes are properly elided and not displayed as `'_` +// regression test for #63037 +// @has async_fn/fn.elided.html +// @has - '//pre[@class="rust fn"]' 'pub async fn elided(foo: &str) -> &str' +pub async fn elided(foo: &str) -> &str {} +// This should really be shown as written, but for implementation reasons it's difficult. +// See `impl Clean for TyKind::Rptr`. +// @has async_fn/fn.user_elided.html +// @has - '//pre[@class="rust fn"]' 'pub async fn user_elided(foo: &str) -> &str' +pub async fn user_elided(foo: &'_ str) -> &str {} +// @has async_fn/fn.static_trait.html +// @has - '//pre[@class="rust fn"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>' +pub async fn static_trait(foo: &str) -> Box<dyn Bar> {} +// @has async_fn/fn.lifetime_for_trait.html +// @has - '//pre[@class="rust fn"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>" +pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> {} +// @has async_fn/fn.elided_in_input_trait.html +// @has - '//pre[@class="rust fn"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" +pub async fn elided_in_input_trait(t: impl Pattern<'_>) {} + +struct AsyncFdReadyGuard<'a, T> { x: &'a T } + +impl Foo { + // @has async_fn/struct.Foo.html + // @has - '//h4[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar) -> impl Iterator<Item = &usize>' + pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> {} + // taken from `tokio` as an example of a method that was particularly bad before + // @has - '//h4[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>" + pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> {} + // @has - '//h4[@class="method"]' "pub async fn mut_self(&mut self)" + pub async fn mut_self(&mut self) {} +} + +// test named lifetimes, just in case +// @has async_fn/fn.named.html +// @has - '//pre[@class="rust fn"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" +pub async fn named<'a, 'b>(foo: &'a str) -> &'b str {} +// @has async_fn/fn.named_trait.html +// @has - '//pre[@class="rust fn"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" +pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {} diff --git a/src/test/rustdoc/auxiliary/issue-61592.rs b/src/test/rustdoc/auxiliary/issue-61592.rs new file mode 100644 index 00000000000..6e16a4caf59 --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-61592.rs @@ -0,0 +1,4 @@ +#![crate_name = "foo"] + +pub trait FooTrait {} +pub struct FooStruct; diff --git a/src/test/rustdoc/codeblock-title.rs b/src/test/rustdoc/codeblock-title.rs index b59b21111b0..140c5b3a672 100644 --- a/src/test/rustdoc/codeblock-title.rs +++ b/src/test/rustdoc/codeblock-title.rs @@ -1,10 +1,9 @@ #![crate_name = "foo"] -// ignore-tidy-linelength - -// @has foo/fn.bar.html '//*[@class="tooltip compile_fail"]/span' "This example deliberately fails to compile" -// @has foo/fn.bar.html '//*[@class="tooltip ignore"]/span' "This example is not tested" -// @has foo/fn.bar.html '//*[@class="tooltip should_panic"]/span' "This example panics" +// @has foo/fn.bar.html '//*[@class="tooltip compile_fail"]' "ⓘ" +// @has foo/fn.bar.html '//*[@class="tooltip ignore"]' "ⓘ" +// @has foo/fn.bar.html '//*[@class="tooltip should_panic"]' "ⓘ" +// @has foo/fn.bar.html '//*[@data-edition="2018"]' "ⓘ" /// foo /// @@ -20,7 +19,7 @@ /// hoo(); /// ``` /// -/// ``` +/// ```edition2018 /// let x = 0; /// ``` pub fn bar() -> usize { 2 } diff --git a/src/test/rustdoc/const-generics/auxiliary/extern_crate.rs b/src/test/rustdoc/const-generics/auxiliary/extern_crate.rs index b8bd040f7a4..55b632a48f2 100644 --- a/src/test/rustdoc/const-generics/auxiliary/extern_crate.rs +++ b/src/test/rustdoc/const-generics/auxiliary/extern_crate.rs @@ -1,6 +1,4 @@ // edition:2018 -#![feature(min_const_generics)] - pub fn extern_fn<const N: usize>() -> impl Iterator<Item = [u8; N]> { [[0; N]; N].iter().copied() } diff --git a/src/test/rustdoc/const-generics/const-generics-docs.rs b/src/test/rustdoc/const-generics/const-generics-docs.rs index 9c68e067c6f..21bf216c304 100644 --- a/src/test/rustdoc/const-generics/const-generics-docs.rs +++ b/src/test/rustdoc/const-generics/const-generics-docs.rs @@ -1,6 +1,5 @@ // edition:2018 // aux-build: extern_crate.rs -#![feature(min_const_generics)] #![crate_name = "foo"] extern crate extern_crate; diff --git a/src/test/rustdoc/const-generics/type-alias.rs b/src/test/rustdoc/const-generics/type-alias.rs index 3064d0701e3..85160dc07a7 100644 --- a/src/test/rustdoc/const-generics/type-alias.rs +++ b/src/test/rustdoc/const-generics/type-alias.rs @@ -1,5 +1,4 @@ // ignore-tidy-linelength -#![feature(min_const_generics)] #![crate_name = "foo"] // @has foo/type.CellIndex.html '//pre[@class="rust typedef"]' 'type CellIndex<const D: usize> = [i64; D];' diff --git a/src/test/rustdoc/deref-typedef.rs b/src/test/rustdoc/deref-typedef.rs index 770f8d7289c..e2dac2cf417 100644 --- a/src/test/rustdoc/deref-typedef.rs +++ b/src/test/rustdoc/deref-typedef.rs @@ -1,18 +1,27 @@ #![crate_name = "foo"] // @has 'foo/struct.Bar.html' -// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooC>' +// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref<Target = FooJ>' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' -// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooC>' +// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' +// @has '-' '//*[@class="sidebar-title"]' 'Methods from Deref<Target=FooJ>' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c' +// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_j"]' 'foo_j' pub struct FooA; pub type FooB = FooA; pub type FooC = FooB; +pub type FooD = FooC; +pub type FooE = FooD; +pub type FooF = FooE; +pub type FooG = FooF; +pub type FooH = FooG; +pub type FooI = FooH; +pub type FooJ = FooI; impl FooA { pub fn foo_a(&self) {} @@ -26,8 +35,12 @@ impl FooC { pub fn foo_c(&self) {} } +impl FooJ { + pub fn foo_j(&self) {} +} + pub struct Bar; impl std::ops::Deref for Bar { - type Target = FooC; + type Target = FooJ; fn deref(&self) -> &Self::Target { unimplemented!() } } diff --git a/src/test/rustdoc/inline_local/trait-vis.rs b/src/test/rustdoc/inline_local/trait-vis.rs index a997d1e25f0..a9b54fbe79e 100644 --- a/src/test/rustdoc/inline_local/trait-vis.rs +++ b/src/test/rustdoc/inline_local/trait-vis.rs @@ -14,5 +14,5 @@ mod asdf { // @has trait_vis/struct.SomeStruct.html // @has - '//code' 'impl ThisTrait for SomeStruct' -// !@has - '//code' 'impl PrivateTrait for SomeStruct' +// @!has - '//code' 'impl PrivateTrait for SomeStruct' pub use asdf::SomeStruct; diff --git a/src/test/rustdoc/intra-doc/non-path-primitives.rs b/src/test/rustdoc/intra-doc/non-path-primitives.rs new file mode 100644 index 00000000000..ad4f6ddd9de --- /dev/null +++ b/src/test/rustdoc/intra-doc/non-path-primitives.rs @@ -0,0 +1,39 @@ +// ignore-tidy-linelength +#![crate_name = "foo"] +#![deny(broken_intra_doc_links)] + +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.rotate_left"]' 'slice::rotate_left' +//! [slice::rotate_left] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.array.html#method.map"]' 'array::map' +//! [array::map] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*const::is_null' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*mut::is_null' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*::is_null' +//! [pointer::is_null] +//! [*const::is_null] +//! [*mut::is_null] +//! [*::is_null] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.unit.html"]' 'unit' +//! [unit] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html"]' 'tuple' +//! [tuple] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.reference.html"]' 'reference' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.reference.html"]' '&' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.reference.html"]' '&mut' +//! [reference] +//! [&] +//! [&mut] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.fn.html"]' 'fn' +//! [fn] + +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.never.html"]' 'never' +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.never.html"]' '!' +//! [never] +//! [!] diff --git a/src/test/rustdoc/intra-doc/primitive-disambiguators.rs b/src/test/rustdoc/intra-doc/primitive-disambiguators.rs new file mode 100644 index 00000000000..acdd07566c9 --- /dev/null +++ b/src/test/rustdoc/intra-doc/primitive-disambiguators.rs @@ -0,0 +1,4 @@ +#![deny(broken_intra_doc_links)] +// @has primitive_disambiguators/index.html +// @has - '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim' +//! [str::trim()] diff --git a/src/test/rustdoc/issue-61592.rs b/src/test/rustdoc/issue-61592.rs new file mode 100644 index 00000000000..aef038c07d8 --- /dev/null +++ b/src/test/rustdoc/issue-61592.rs @@ -0,0 +1,15 @@ +// aux-build:issue-61592.rs + +extern crate foo; + +// @has issue_61592/index.html +// @has - '//a[@href="#reexports"]' 'Re-exports' +// @has - '//code' 'pub use foo::FooTrait as _;' +// @!has - '//a[@href="trait._.html"]' +pub use foo::FooTrait as _; + +// @has issue_61592/index.html +// @has - '//a[@href="#reexports"]' 'Re-exports' +// @has - '//code' 'pub use foo::FooStruct as _;' +// @!has - '//a[@href="struct._.html"]' +pub use foo::FooStruct as _; diff --git a/src/test/rustdoc/issue-74083.rs b/src/test/rustdoc/issue-74083.rs index 28585dafa14..c7f5d7eaa58 100644 --- a/src/test/rustdoc/issue-74083.rs +++ b/src/test/rustdoc/issue-74083.rs @@ -7,7 +7,7 @@ impl Foo { } // @has issue_74083/struct.Bar.html -// !@has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +// @!has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' pub struct Bar { foo: Foo, } diff --git a/src/test/rustdoc/macros.rs b/src/test/rustdoc/macros.rs index fb4f02ad160..ae0cf7a1478 100644 --- a/src/test/rustdoc/macros.rs +++ b/src/test/rustdoc/macros.rs @@ -8,3 +8,17 @@ macro_rules! my_macro { ($a:tt) => (); ($e:expr) => {}; } + +// Check that exported macro defined in a module are shown at crate root. +// @has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {' +// @has - //pre '() => { ... };' +// @has - //pre '($a:tt) => { ... };' +// @has - //pre '($e:expr) => { ... };' +mod sub { + #[macro_export] + macro_rules! my_sub_macro { + () => {}; + ($a:tt) => {}; + ($e:expr) => {}; + } +} diff --git a/src/test/rustdoc/pub-restricted.rs b/src/test/rustdoc/pub-restricted.rs deleted file mode 100644 index 6720d848ac3..00000000000 --- a/src/test/rustdoc/pub-restricted.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: --document-private-items - -#![feature(crate_visibility_modifier)] - -#![crate_name = "foo"] - -// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' -pub struct FooPublic; -// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate' -crate struct FooJustCrate; -// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate' -pub(crate) struct FooPubCrate; -// @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf' -pub(self) struct FooSelf; -// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf' -pub(in self) struct FooInSelf; -mod a { - // @has 'foo/a/struct.FooSuper.html' '//pre' 'pub(crate) struct FooSuper' - pub(super) struct FooSuper; - // @has 'foo/a/struct.FooInSuper.html' '//pre' 'pub(crate) struct FooInSuper' - pub(in super) struct FooInSuper; - // @has 'foo/a/struct.FooInA.html' '//pre' 'pub(in a) struct FooInA' - pub(in a) struct FooInA; - mod b { - // @has 'foo/a/b/struct.FooInSelfSuperB.html' '//pre' 'pub(in a::b) struct FooInSelfSuperB' - pub(in a::b) struct FooInSelfSuperB; - // @has 'foo/a/b/struct.FooInSuperSuper.html' '//pre' 'pub(crate) struct FooInSuperSuper' - pub(in super::super) struct FooInSuperSuper; - // @has 'foo/a/b/struct.FooInAB.html' '//pre' 'pub(in a::b) struct FooInAB' - pub(in a::b) struct FooInAB; - } -} diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs index 9761c1ddbe2..e2b232a6efb 100644 --- a/src/test/rustdoc/remove-url-from-headings.rs +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] // @has foo/fn.foo.html -// !@has - '//a[@href="http://a.a"]' +// @!has - '//a[@href="http://a.a"]' // @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere' // @has - '//a[@href="#another-one-urg"]' 'Another one urg' diff --git a/src/test/rustdoc/visibility.rs b/src/test/rustdoc/visibility.rs new file mode 100644 index 00000000000..59427693c5a --- /dev/null +++ b/src/test/rustdoc/visibility.rs @@ -0,0 +1,44 @@ +// compile-flags: --document-private-items + +#![feature(crate_visibility_modifier)] + +#![crate_name = "foo"] + +// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' +pub struct FooPublic; +// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate' +crate struct FooJustCrate; +// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate' +pub(crate) struct FooPubCrate; +// @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf' +pub(self) struct FooSelf; +// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf' +pub(in self) struct FooInSelf; +// @has 'foo/struct.FooPriv.html' '//pre' 'pub(crate) struct FooPriv' +struct FooPriv; + +mod a { + // @has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper' + pub(super) struct FooASuper; + // @has 'foo/a/struct.FooAInSuper.html' '//pre' 'pub(crate) struct FooAInSuper' + pub(in super) struct FooAInSuper; + // @has 'foo/a/struct.FooAInA.html' '//pre' 'struct FooAInA' + // @!has 'foo/a/struct.FooAInA.html' '//pre' 'pub' + pub(in a) struct FooAInA; + // @has 'foo/a/struct.FooAPriv.html' '//pre' 'struct FooAPriv' + // @!has 'foo/a/struct.FooAPriv.html' '//pre' 'pub' + struct FooAPriv; + + mod b { + // @has 'foo/a/b/struct.FooBSuper.html' '//pre' 'pub(super) struct FooBSuper' + pub(super) struct FooBSuper; + // @has 'foo/a/b/struct.FooBInSuperSuper.html' '//pre' 'pub(crate) struct FooBInSuperSuper' + pub(in super::super) struct FooBInSuperSuper; + // @has 'foo/a/b/struct.FooBInAB.html' '//pre' 'struct FooBInAB' + // @!has 'foo/a/b/struct.FooBInAB.html' '//pre' 'pub' + pub(in a::b) struct FooBInAB; + // @has 'foo/a/b/struct.FooBPriv.html' '//pre' 'struct FooBPriv' + // @!has 'foo/a/b/struct.FooBPriv.html' '//pre' 'pub' + struct FooBPriv; + } +} diff --git a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs index fabcd727482..cc97971a0dd 100644 --- a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs +++ b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs @@ -1,8 +1,8 @@ // Reject mixing cyclic structure and Drop when using TypedArena. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against dropck-vec-cycle-checked.rs) // -// (Also compare against compile-fail/dropck_tarena_unsound_drop.rs, +// (Also compare against ui-fulldeps/dropck-tarena-unsound-drop.rs, // which is a reduction of this code to more directly show the reason // for the error message we see here.) diff --git a/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs b/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs index c5b9efee8e7..187f9a24a90 100644 --- a/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs +++ b/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs @@ -5,7 +5,7 @@ // methods might access borrowed data, as long as the borrowed data // has lifetime that strictly outlives the arena itself. // -// Compare against compile-fail/dropck_tarena_unsound_drop.rs, which +// Compare against ui-fulldeps/dropck-tarena-unsound-drop.rs, which // shows a similar setup, but restricts `f` so that the struct `C<'a>` // is force-fed a lifetime equal to that of the borrowed arena. diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.rs b/src/test/ui/abi/issues/issue-22565-rust-call.rs index 055d959b46e..383eaab454e 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.rs +++ b/src/test/ui/abi/issues/issue-22565-rust-call.rs @@ -3,6 +3,30 @@ extern "rust-call" fn b(_i: i32) {} //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument that is a tuple +trait Tr { + extern "rust-call" fn a(); + + extern "rust-call" fn b() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + +struct Foo; + +impl Foo { + extern "rust-call" fn bar() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + +impl Tr for Foo { + extern "rust-call" fn a() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + fn main () { b(10); + + Foo::bar(); + + <Foo as Tr>::a(); + <Foo as Tr>::b(); } diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.stderr b/src/test/ui/abi/issues/issue-22565-rust-call.stderr index 31fb035eb99..f7c3d1de793 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.stderr +++ b/src/test/ui/abi/issues/issue-22565-rust-call.stderr @@ -4,5 +4,23 @@ error: A function with the "rust-call" ABI must take a single non-self argument LL | extern "rust-call" fn b(_i: i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple + --> $DIR/issue-22565-rust-call.rs:9:5 + | +LL | extern "rust-call" fn b() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple + --> $DIR/issue-22565-rust-call.rs:16:5 + | +LL | extern "rust-call" fn bar() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple + --> $DIR/issue-22565-rust-call.rs:21:5 + | +LL | extern "rust-call" fn a() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors diff --git a/src/test/ui/array-break-length.rs b/src/test/ui/array-slice-vec/array-break-length.rs index 60589f7c264..60589f7c264 100644 --- a/src/test/ui/array-break-length.rs +++ b/src/test/ui/array-slice-vec/array-break-length.rs diff --git a/src/test/ui/array-break-length.stderr b/src/test/ui/array-slice-vec/array-break-length.stderr index 93f1c238bcc..93f1c238bcc 100644 --- a/src/test/ui/array-break-length.stderr +++ b/src/test/ui/array-slice-vec/array-break-length.stderr diff --git a/src/test/ui/array-not-vector.rs b/src/test/ui/array-slice-vec/array-not-vector.rs index 5e46f015baf..5e46f015baf 100644 --- a/src/test/ui/array-not-vector.rs +++ b/src/test/ui/array-slice-vec/array-not-vector.rs diff --git a/src/test/ui/array-not-vector.stderr b/src/test/ui/array-slice-vec/array-not-vector.stderr index 0e187d9072a..0e187d9072a 100644 --- a/src/test/ui/array-not-vector.stderr +++ b/src/test/ui/array-slice-vec/array-not-vector.stderr diff --git a/src/test/ui/array_const_index-0.rs b/src/test/ui/array-slice-vec/array_const_index-0.rs index 4021dfcc6eb..4021dfcc6eb 100644 --- a/src/test/ui/array_const_index-0.rs +++ b/src/test/ui/array-slice-vec/array_const_index-0.rs diff --git a/src/test/ui/array_const_index-0.stderr b/src/test/ui/array-slice-vec/array_const_index-0.stderr index 7ccc3aa087e..7ccc3aa087e 100644 --- a/src/test/ui/array_const_index-0.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-0.stderr diff --git a/src/test/ui/array-slice-vec/array_const_index-1.rs b/src/test/ui/array-slice-vec/array_const_index-1.rs index 8ee225f5cdf..d0ee1796c0f 100644 --- a/src/test/ui/array-slice-vec/array_const_index-1.rs +++ b/src/test/ui/array-slice-vec/array_const_index-1.rs @@ -1,12 +1,8 @@ -// run-pass -#![allow(dead_code)] -#![allow(stable_features)] - -#![feature(const_indexing)] +const A: [i32; 0] = []; +const B: i32 = A[1]; +//~^ index out of bounds: the length is 0 but the index is 1 +//~| ERROR any use of this value will cause an error fn main() { - const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; - const IDX: usize = 3; - const VAL: i32 = ARR[IDX]; - const BLUB: [i32; (ARR[0] - 41) as usize] = [5]; + let _ = B; } diff --git a/src/test/ui/array_const_index-1.stderr b/src/test/ui/array-slice-vec/array_const_index-1.stderr index 37de61b9df0..37de61b9df0 100644 --- a/src/test/ui/array_const_index-1.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-1.stderr diff --git a/src/test/ui/array-slice-vec/array_const_index-2.rs b/src/test/ui/array-slice-vec/array_const_index-2.rs new file mode 100644 index 00000000000..8ee225f5cdf --- /dev/null +++ b/src/test/ui/array-slice-vec/array_const_index-2.rs @@ -0,0 +1,12 @@ +// run-pass +#![allow(dead_code)] +#![allow(stable_features)] + +#![feature(const_indexing)] + +fn main() { + const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; + const IDX: usize = 3; + const VAL: i32 = ARR[IDX]; + const BLUB: [i32; (ARR[0] - 41) as usize] = [5]; +} diff --git a/src/test/ui/array-slice-vec/copy-out-of-array-1.rs b/src/test/ui/array-slice-vec/copy-out-of-array-1.rs index e64985ae3f6..c6d311148d0 100644 --- a/src/test/ui/array-slice-vec/copy-out-of-array-1.rs +++ b/src/test/ui/array-slice-vec/copy-out-of-array-1.rs @@ -2,7 +2,7 @@ // Ensure that we can copy out of a fixed-size array. // -// (Compare with compile-fail/move-out-of-array-1.rs) +// (Compare with ui/moves/move-out-of-array-1.rs) #[derive(Copy, Clone)] struct C { _x: u8 } diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr index 7c1a92c79d9..0ad05b3adeb 100644 --- a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr +++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0308]: mismatched types --> $DIR/match_arr_unknown_len.rs:6:9 diff --git a/src/test/ui/slice-2.rs b/src/test/ui/array-slice-vec/slice-2.rs index 5423e295a87..5423e295a87 100644 --- a/src/test/ui/slice-2.rs +++ b/src/test/ui/array-slice-vec/slice-2.rs diff --git a/src/test/ui/slice-2.stderr b/src/test/ui/array-slice-vec/slice-2.stderr index 561feb90f0a..561feb90f0a 100644 --- a/src/test/ui/slice-2.stderr +++ b/src/test/ui/array-slice-vec/slice-2.stderr diff --git a/src/test/ui/slice-mut-2.rs b/src/test/ui/array-slice-vec/slice-mut-2.rs index 216edbb7808..216edbb7808 100644 --- a/src/test/ui/slice-mut-2.rs +++ b/src/test/ui/array-slice-vec/slice-mut-2.rs diff --git a/src/test/ui/slice-mut-2.stderr b/src/test/ui/array-slice-vec/slice-mut-2.stderr index bad0268772b..bad0268772b 100644 --- a/src/test/ui/slice-mut-2.stderr +++ b/src/test/ui/array-slice-vec/slice-mut-2.stderr diff --git a/src/test/ui/slice-mut.rs b/src/test/ui/array-slice-vec/slice-mut.rs index e9989f0f481..e9989f0f481 100644 --- a/src/test/ui/slice-mut.rs +++ b/src/test/ui/array-slice-vec/slice-mut.rs diff --git a/src/test/ui/slice-mut.stderr b/src/test/ui/array-slice-vec/slice-mut.stderr index 7d34defc1d5..7d34defc1d5 100644 --- a/src/test/ui/slice-mut.stderr +++ b/src/test/ui/array-slice-vec/slice-mut.stderr diff --git a/src/test/ui/slice-to-vec-comparison.rs b/src/test/ui/array-slice-vec/slice-to-vec-comparison.rs index 7026a49000c..7026a49000c 100644 --- a/src/test/ui/slice-to-vec-comparison.rs +++ b/src/test/ui/array-slice-vec/slice-to-vec-comparison.rs diff --git a/src/test/ui/slice-to-vec-comparison.stderr b/src/test/ui/array-slice-vec/slice-to-vec-comparison.stderr index e3b3b040f66..e3b3b040f66 100644 --- a/src/test/ui/slice-to-vec-comparison.stderr +++ b/src/test/ui/array-slice-vec/slice-to-vec-comparison.stderr diff --git a/src/test/ui/vec/vec-macro-with-comma-only.rs b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.rs index 574a53c58fe..574a53c58fe 100644 --- a/src/test/ui/vec/vec-macro-with-comma-only.rs +++ b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.rs diff --git a/src/test/ui/vec/vec-macro-with-comma-only.stderr b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr index abbee347c00..abbee347c00 100644 --- a/src/test/ui/vec/vec-macro-with-comma-only.stderr +++ b/src/test/ui/array-slice-vec/vec-macro-with-comma-only.stderr diff --git a/src/test/ui/vec/vec-mut-iter-borrow.rs b/src/test/ui/array-slice-vec/vec-mut-iter-borrow.rs index 4aa737446b5..4aa737446b5 100644 --- a/src/test/ui/vec/vec-mut-iter-borrow.rs +++ b/src/test/ui/array-slice-vec/vec-mut-iter-borrow.rs diff --git a/src/test/ui/vec/vec-mut-iter-borrow.stderr b/src/test/ui/array-slice-vec/vec-mut-iter-borrow.stderr index 679fd899773..679fd899773 100644 --- a/src/test/ui/vec/vec-mut-iter-borrow.stderr +++ b/src/test/ui/array-slice-vec/vec-mut-iter-borrow.stderr diff --git a/src/test/ui/vec/vec-overrun.rs b/src/test/ui/array-slice-vec/vec-overrun.rs index bdc7d507d53..bdc7d507d53 100644 --- a/src/test/ui/vec/vec-overrun.rs +++ b/src/test/ui/array-slice-vec/vec-overrun.rs diff --git a/src/test/ui/vec/vec-res-add.rs b/src/test/ui/array-slice-vec/vec-res-add.rs index 57b552ee558..57b552ee558 100644 --- a/src/test/ui/vec/vec-res-add.rs +++ b/src/test/ui/array-slice-vec/vec-res-add.rs diff --git a/src/test/ui/vec/vec-res-add.stderr b/src/test/ui/array-slice-vec/vec-res-add.stderr index 7511271361d..7511271361d 100644 --- a/src/test/ui/vec/vec-res-add.stderr +++ b/src/test/ui/array-slice-vec/vec-res-add.stderr diff --git a/src/test/ui/vector-cast-weirdness.rs b/src/test/ui/array-slice-vec/vector-cast-weirdness.rs index 79b9243765b..79b9243765b 100644 --- a/src/test/ui/vector-cast-weirdness.rs +++ b/src/test/ui/array-slice-vec/vector-cast-weirdness.rs diff --git a/src/test/ui/vector-cast-weirdness.stderr b/src/test/ui/array-slice-vec/vector-cast-weirdness.stderr index 37055bb75f5..37055bb75f5 100644 --- a/src/test/ui/vector-cast-weirdness.stderr +++ b/src/test/ui/array-slice-vec/vector-cast-weirdness.stderr diff --git a/src/test/ui/vector-no-ann.rs b/src/test/ui/array-slice-vec/vector-no-ann.rs index 1f11d9c8dff..1f11d9c8dff 100644 --- a/src/test/ui/vector-no-ann.rs +++ b/src/test/ui/array-slice-vec/vector-no-ann.rs diff --git a/src/test/ui/vector-no-ann.stderr b/src/test/ui/array-slice-vec/vector-no-ann.stderr index 8a7b8d22760..8a7b8d22760 100644 --- a/src/test/ui/vector-no-ann.stderr +++ b/src/test/ui/array-slice-vec/vector-no-ann.stderr diff --git a/src/test/ui/array_const_index-1.rs b/src/test/ui/array_const_index-1.rs deleted file mode 100644 index d0ee1796c0f..00000000000 --- a/src/test/ui/array_const_index-1.rs +++ /dev/null @@ -1,8 +0,0 @@ -const A: [i32; 0] = []; -const B: i32 = A[1]; -//~^ index out of bounds: the length is 0 but the index is 1 -//~| ERROR any use of this value will cause an error - -fn main() { - let _ = B; -} diff --git a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs index d51821059fc..5152d784047 100644 --- a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs +++ b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs @@ -14,8 +14,7 @@ impl Foo for Def { pub fn test<A: Foo, B: Foo>() { let _array: [u32; <A as Foo>::Y]; - //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] + //~^ ERROR generic parameters may not be used } -fn main() { -} +fn main() {} diff --git a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr index ac40e390cfb..d3a1cd30e2b 100644 --- a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr +++ b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr @@ -1,17 +1,11 @@ -error[E0277]: the trait bound `A: Foo` is not satisfied - --> $DIR/associated-const-type-parameter-arrays.rs:16:23 +error: generic parameters may not be used in const operations + --> $DIR/associated-const-type-parameter-arrays.rs:16:24 | -LL | const Y: usize; - | --------------- required by `Foo::Y` -... LL | let _array: [u32; <A as Foo>::Y]; - | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A` + | ^ cannot perform const operation using `A` | -help: consider further restricting this bound - | -LL | pub fn test<A: Foo + Foo, B: Foo>() { - | ^^^^^ + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-item/associated-item-duplicate-bounds.rs b/src/test/ui/associated-item/associated-item-duplicate-bounds.rs index bec922b0721..242a02353a1 100644 --- a/src/test/ui/associated-item/associated-item-duplicate-bounds.rs +++ b/src/test/ui/associated-item/associated-item-duplicate-bounds.rs @@ -5,7 +5,7 @@ trait Adapter { struct Foo<A: Adapter> { adapter: A, links: [u32; A::LINKS], // Shouldn't suggest bounds already there. - //~^ ERROR: no associated item named `LINKS` found + //~^ ERROR generic parameters may not be used in const operations } fn main() {} diff --git a/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr b/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr index ff1ad4c006e..0d84dca5b80 100644 --- a/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr +++ b/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr @@ -1,11 +1,11 @@ -error[E0599]: no associated item named `LINKS` found for type parameter `A` in the current scope - --> $DIR/associated-item-duplicate-bounds.rs:7:21 +error: generic parameters may not be used in const operations + --> $DIR/associated-item-duplicate-bounds.rs:7:18 | LL | links: [u32; A::LINKS], // Shouldn't suggest bounds already there. - | ^^^^^ associated item not found in `A` + | ^^^^^^^^ cannot perform const operation using `A` | - = help: items from traits can only be used if the type parameter is bounded by the trait + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs index 5f06a829600..3b8c8c019e5 100644 --- a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs +++ b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs @@ -3,7 +3,7 @@ // the trait definition if there is no default method and for every impl, // `Self` does implement `Get`. // -// See also compile-fail tests associated-types-no-suitable-supertrait +// See also tests associated-types-no-suitable-supertrait // and associated-types-no-suitable-supertrait-2, which show how small // variants of the code below can fail. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs index afb2b3df716..61ef013236e 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs @@ -24,13 +24,13 @@ impl Tr for u32 { // ...but not in an impl that redefines one of the types. impl Tr for bool { type A = Box<Self::B>; - //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` + //~^ ERROR overflow evaluating the requirement `<bool as Tr>::B == _` } // (the error is shown twice for some reason) impl Tr for usize { type B = &'static Self::A; - //~^ ERROR type mismatch resolving `<usize as Tr>::A == _` + //~^ ERROR overflow evaluating the requirement `<usize as Tr>::A == _` } fn main() { diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr index ae7150d47ca..5e98520b411 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr @@ -1,15 +1,15 @@ -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` +error[E0275]: overflow evaluating the requirement `<bool as Tr>::B == _` --> $DIR/defaults-cyclic-fail-1.rs:26:5 | LL | type A = Box<Self::B>; - | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0271]: type mismatch resolving `<usize as Tr>::A == _` +error[E0275]: overflow evaluating the requirement `<usize as Tr>::A == _` --> $DIR/defaults-cyclic-fail-1.rs:32:5 | LL | type B = &'static Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs index ba4bb0d5a29..e91c9f2d29a 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs @@ -25,13 +25,13 @@ impl Tr for u32 { impl Tr for bool { type A = Box<Self::B>; - //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` + //~^ ERROR overflow evaluating the requirement `<bool as Tr>::B == _` } // (the error is shown twice for some reason) impl Tr for usize { type B = &'static Self::A; - //~^ ERROR type mismatch resolving `<usize as Tr>::A == _` + //~^ ERROR overflow evaluating the requirement `<usize as Tr>::A == _` } fn main() { diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr index 0dfbac2dec5..c538805f858 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr @@ -1,15 +1,15 @@ -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` +error[E0275]: overflow evaluating the requirement `<bool as Tr>::B == _` --> $DIR/defaults-cyclic-fail-2.rs:27:5 | LL | type A = Box<Self::B>; - | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0271]: type mismatch resolving `<usize as Tr>::A == _` +error[E0275]: overflow evaluating the requirement `<usize as Tr>::A == _` --> $DIR/defaults-cyclic-fail-2.rs:33:5 | LL | type B = &'static Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr index 4c43e6a182d..d4fa5be742f 100644 --- a/src/test/ui/associated-types/defaults-wf.stderr +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation LL | type Ty = Vec<[u8]>; | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - ::: $SRC_DIR/alloc/src/vec.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { | - required by this bound in `Vec` diff --git a/src/test/ui/associated-types/impl-wf-cycle-1.rs b/src/test/ui/associated-types/impl-wf-cycle-1.rs new file mode 100644 index 00000000000..ba074210a2b --- /dev/null +++ b/src/test/ui/associated-types/impl-wf-cycle-1.rs @@ -0,0 +1,29 @@ +// Regression test for #79714 + +trait Baz {} +impl Baz for () {} +impl<T> Baz for (T,) {} + +trait Fiz {} +impl Fiz for bool {} + +trait Grault { + type A; + type B; +} + +impl<T: Grault> Grault for (T,) +where + Self::A: Baz, + Self::B: Fiz, +{ + type A = (); + //~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _` + type B = bool; + //~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _` +} +//~^^^^^^^^^^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _` + +fn main() { + let x: <(_,) as Grault>::A = (); +} diff --git a/src/test/ui/associated-types/impl-wf-cycle-1.stderr b/src/test/ui/associated-types/impl-wf-cycle-1.stderr new file mode 100644 index 00000000000..82328048c99 --- /dev/null +++ b/src/test/ui/associated-types/impl-wf-cycle-1.stderr @@ -0,0 +1,39 @@ +error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` + --> $DIR/impl-wf-cycle-1.rs:15:1 + | +LL | / impl<T: Grault> Grault for (T,) +LL | | where +LL | | Self::A: Baz, +LL | | Self::B: Fiz, +... | +LL | | +LL | | } + | |_^ + | + = note: required because of the requirements on the impl of `Grault` for `(T,)` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Grault` for `(T,)` + +error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` + --> $DIR/impl-wf-cycle-1.rs:20:5 + | +LL | type A = (); + | ^^^^^^^^^^^^ + | + = note: required because of the requirements on the impl of `Grault` for `(T,)` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Grault` for `(T,)` + +error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` + --> $DIR/impl-wf-cycle-1.rs:22:5 + | +LL | type B = bool; + | ^^^^^^^^^^^^^^ + | + = note: required because of the requirements on the impl of `Grault` for `(T,)` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Grault` for `(T,)` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/associated-types/impl-wf-cycle-2.rs b/src/test/ui/associated-types/impl-wf-cycle-2.rs new file mode 100644 index 00000000000..6fccc54f229 --- /dev/null +++ b/src/test/ui/associated-types/impl-wf-cycle-2.rs @@ -0,0 +1,16 @@ +// Regression test for #79714 + +trait Grault { + type A; +} + +impl<T: Grault> Grault for (T,) +where + Self::A: Copy, +{ + type A = (); + //~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _` +} +//~^^^^^^^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _` + +fn main() {} diff --git a/src/test/ui/associated-types/impl-wf-cycle-2.stderr b/src/test/ui/associated-types/impl-wf-cycle-2.stderr new file mode 100644 index 00000000000..5cd18a33adf --- /dev/null +++ b/src/test/ui/associated-types/impl-wf-cycle-2.stderr @@ -0,0 +1,25 @@ +error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` + --> $DIR/impl-wf-cycle-2.rs:7:1 + | +LL | / impl<T: Grault> Grault for (T,) +LL | | where +LL | | Self::A: Copy, +LL | | { +LL | | type A = (); +LL | | +LL | | } + | |_^ + | + = note: required because of the requirements on the impl of `Grault` for `(T,)` + +error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` + --> $DIR/impl-wf-cycle-2.rs:11:5 + | +LL | type A = (); + | ^^^^^^^^^^^^ + | + = note: required because of the requirements on the impl of `Grault` for `(T,)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/ui/associated-types/issue-23595-1.rs index 483c205f42d..483c205f42d 100644 --- a/src/test/compile-fail/issue-23595-1.rs +++ b/src/test/ui/associated-types/issue-23595-1.rs diff --git a/src/test/ui/associated-types/issue-23595-1.stderr b/src/test/ui/associated-types/issue-23595-1.stderr new file mode 100644 index 00000000000..bb455684ee3 --- /dev/null +++ b/src/test/ui/associated-types/issue-23595-1.stderr @@ -0,0 +1,16 @@ +error[E0191]: the value of the associated types `ChildKey` (from trait `Hierarchy`), `Children` (from trait `Hierarchy`), `Value` (from trait `Hierarchy`) must be specified + --> $DIR/issue-23595-1.rs:8:58 + | +LL | type Value; + | ----------- `Value` defined here +LL | type ChildKey; + | -------------- `ChildKey` defined here +LL | type Children = dyn Index<Self::ChildKey, Output=dyn Hierarchy>; + | -----------------------------------------------------^^^^^^^^^-- + | | | + | | help: specify the associated types: `Hierarchy<Value = Type, ChildKey = Type, Children = Type>` + | `Children` defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0191`. diff --git a/src/test/compile-fail/issue-27675-unchecked-bounds.rs b/src/test/ui/associated-types/issue-27675-unchecked-bounds.rs index 1cfc2304531..1cfc2304531 100644 --- a/src/test/compile-fail/issue-27675-unchecked-bounds.rs +++ b/src/test/ui/associated-types/issue-27675-unchecked-bounds.rs diff --git a/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr new file mode 100644 index 00000000000..02396bd00a5 --- /dev/null +++ b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/issue-27675-unchecked-bounds.rs:15:31 + | +LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From { + | ----- required by this bound in `copy` +... +LL | copy::<dyn Setup<From=T>>(t) + | ^ the trait `Copy` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | pub fn copy_any<T: Copy>(t: &T) -> T { + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.rs b/src/test/ui/async-await/edition-deny-async-fns-2015.rs index 5d2d186137e..e5dc9c8a5fe 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.rs +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.rs @@ -1,21 +1,21 @@ // edition:2015 -async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition +async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 -fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in the 2015 edition +fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in Rust 2015 -async fn async_baz() { //~ ERROR `async fn` is not permitted in the 2015 edition - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition +async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015 + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } struct Foo {} impl Foo { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } trait Bar { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 //~^ ERROR functions in traits cannot be declared `async` } @@ -23,16 +23,16 @@ fn main() { macro_rules! accept_item { ($x:item) => {} } accept_item! { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } accept_item! { impl Foo { - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } } let inside_closure = || { - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 }; } diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr index 8bffeb2131d..43364a8e858 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr @@ -1,80 +1,80 @@ -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:3:1 | LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:5:12 | LL | fn baz() { async fn foo() {} } - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:7:1 | LL | async fn async_baz() { - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:8:5 | LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:14:5 | LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:18:5 | LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:36:9 | LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:26:9 | LL | async fn foo() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:31:13 | LL | async fn bar() {} - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide diff --git a/src/test/ui/async-await/issues/issue-78654.full.stderr b/src/test/ui/async-await/issues/issue-78654.full.stderr index ff0260523db..a9208ade740 100644 --- a/src/test/ui/async-await/issues/issue-78654.full.stderr +++ b/src/test/ui/async-await/issues/issue-78654.full.stderr @@ -1,11 +1,11 @@ error[E0573]: expected type, found built-in attribute `feature` - --> $DIR/issue-78654.rs:10:15 + --> $DIR/issue-78654.rs:9:15 | LL | impl<const H: feature> Foo { | ^^^^^^^ not a type error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-78654.rs:10:12 + --> $DIR/issue-78654.rs:9:12 | LL | impl<const H: feature> Foo { | ^ unconstrained const parameter diff --git a/src/test/ui/async-await/issues/issue-78654.min.stderr b/src/test/ui/async-await/issues/issue-78654.min.stderr index ff0260523db..a9208ade740 100644 --- a/src/test/ui/async-await/issues/issue-78654.min.stderr +++ b/src/test/ui/async-await/issues/issue-78654.min.stderr @@ -1,11 +1,11 @@ error[E0573]: expected type, found built-in attribute `feature` - --> $DIR/issue-78654.rs:10:15 + --> $DIR/issue-78654.rs:9:15 | LL | impl<const H: feature> Foo { | ^^^^^^^ not a type error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-78654.rs:10:12 + --> $DIR/issue-78654.rs:9:12 | LL | impl<const H: feature> Foo { | ^ unconstrained const parameter diff --git a/src/test/ui/async-await/issues/issue-78654.rs b/src/test/ui/async-await/issues/issue-78654.rs index b57ed35f8e3..37ebb4ecac8 100644 --- a/src/test/ui/async-await/issues/issue-78654.rs +++ b/src/test/ui/async-await/issues/issue-78654.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo; diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr index 695d7dd59fb..9ac2bc5cc89 100644 --- a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr +++ b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr @@ -4,7 +4,7 @@ error[E0609]: no field `await` on type `await_on_struct_missing::S` LL | x.await; | ^^^^^ unknown field | - = note: to `.await` a `Future`, switch to Rust 2018 + = note: to `.await` a `Future`, switch to Rust 2018 or later = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide @@ -14,7 +14,7 @@ error[E0609]: no field `await` on type `await_on_struct_similar::S` LL | x.await; | ^^^^^ help: a field with a similar name exists: `awai` | - = note: to `.await` a `Future`, switch to Rust 2018 + = note: to `.await` a `Future`, switch to Rust 2018 or later = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide @@ -24,7 +24,7 @@ error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>` LL | x.await; | ^^^^^ unknown field | - = note: to `.await` a `Future`, switch to Rust 2018 + = note: to `.await` a `Future`, switch to Rust 2018 or later = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide @@ -34,7 +34,7 @@ error[E0609]: no field `await` on type `impl Future<Output = ()>` LL | x.await; | ^^^^^ | - = note: to `.await` a `Future`, switch to Rust 2018 + = note: to `.await` a `Future`, switch to Rust 2018 or later = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide diff --git a/src/test/ui/auxiliary/trait_superkinds_in_metadata.rs b/src/test/ui/auxiliary/trait_superkinds_in_metadata.rs deleted file mode 100644 index acfd1e13e93..00000000000 --- a/src/test/ui/auxiliary/trait_superkinds_in_metadata.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Test library crate for cross-crate usages of traits inheriting -// from the builtin kinds. Mostly tests metadata correctness. - -#![crate_type="lib"] - -pub trait RequiresShare : Sync { } -pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } -pub trait RequiresCopy : Copy { } diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index 60a5bb9f786..260d78b543a 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -15,7 +15,7 @@ error[E0277]: the size for values of type `dyn Trait` cannot be known at compila LL | let x: Vec<dyn Trait + Sized> = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - ::: $SRC_DIR/alloc/src/vec.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { | - required by this bound in `Vec` diff --git a/src/test/ui/binding/const-param.full.stderr b/src/test/ui/binding/const-param.full.stderr new file mode 100644 index 00000000000..0200c6def24 --- /dev/null +++ b/src/test/ui/binding/const-param.full.stderr @@ -0,0 +1,9 @@ +error[E0158]: const parameters cannot be referenced in patterns + --> $DIR/const-param.rs:8:9 + | +LL | N => {} + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0158`. diff --git a/src/test/ui/binding/const-param.min.stderr b/src/test/ui/binding/const-param.min.stderr new file mode 100644 index 00000000000..0200c6def24 --- /dev/null +++ b/src/test/ui/binding/const-param.min.stderr @@ -0,0 +1,9 @@ +error[E0158]: const parameters cannot be referenced in patterns + --> $DIR/const-param.rs:8:9 + | +LL | N => {} + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0158`. diff --git a/src/test/ui/binding/const-param.rs b/src/test/ui/binding/const-param.rs index 3c7f4d071f6..4aec801cb15 100644 --- a/src/test/ui/binding/const-param.rs +++ b/src/test/ui/binding/const-param.rs @@ -1,6 +1,7 @@ // Identifier pattern referring to a const generic parameter is an error (issue #68853). - -#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] fn check<const N: usize>() { match 1 { diff --git a/src/test/ui/binding/const-param.stderr b/src/test/ui/binding/const-param.stderr deleted file mode 100644 index d3d06a2d834..00000000000 --- a/src/test/ui/binding/const-param.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/const-param.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete - -error[E0158]: const parameters cannot be referenced in patterns - --> $DIR/const-param.rs:7:9 - | -LL | N => {} - | ^ - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0158`. diff --git a/src/test/ui/binary-minus-without-space.rs b/src/test/ui/binop/binary-minus-without-space.rs index 2fbd5300dd1..2fbd5300dd1 100644 --- a/src/test/ui/binary-minus-without-space.rs +++ b/src/test/ui/binop/binary-minus-without-space.rs diff --git a/src/test/ui/binary-op-on-double-ref.fixed b/src/test/ui/binop/binary-op-on-double-ref.fixed index de9dc19af29..de9dc19af29 100644 --- a/src/test/ui/binary-op-on-double-ref.fixed +++ b/src/test/ui/binop/binary-op-on-double-ref.fixed diff --git a/src/test/ui/binary-op-on-double-ref.rs b/src/test/ui/binop/binary-op-on-double-ref.rs index 2616c560cbe..2616c560cbe 100644 --- a/src/test/ui/binary-op-on-double-ref.rs +++ b/src/test/ui/binop/binary-op-on-double-ref.rs diff --git a/src/test/ui/binary-op-on-double-ref.stderr b/src/test/ui/binop/binary-op-on-double-ref.stderr index 02b0488488c..02b0488488c 100644 --- a/src/test/ui/binary-op-on-double-ref.stderr +++ b/src/test/ui/binop/binary-op-on-double-ref.stderr diff --git a/src/test/ui/binops-issue-22743.rs b/src/test/ui/binop/binops-issue-22743.rs index 393ba0a56cb..393ba0a56cb 100644 --- a/src/test/ui/binops-issue-22743.rs +++ b/src/test/ui/binop/binops-issue-22743.rs diff --git a/src/test/ui/binops.rs b/src/test/ui/binop/binops.rs index a7abf6087b3..a7abf6087b3 100644 --- a/src/test/ui/binops.rs +++ b/src/test/ui/binop/binops.rs diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index ca1496a6c8d..a4090777939 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -23,7 +23,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 | LL | _ => { addr.push(&mut x); } - | ^^^^^^ mutable borrow starts here in previous iteration of loop + | ^^^^^^ `x` was mutably borrowed here in the previous iteration of the loop error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.stderr index 260b9673d74..b621694a548 100644 --- a/src/test/ui/borrowck/mut-borrow-in-loop.stderr +++ b/src/test/ui/borrowck/mut-borrow-in-loop.stderr @@ -15,7 +15,7 @@ LL | impl<'a, T : 'a> FuncWrapper<'a, T> { LL | (self.func)(arg) | ------------^^^- | | | - | | mutable borrow starts here in previous iteration of loop + | | `*arg` was mutably borrowed here in the previous iteration of the loop | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time @@ -27,7 +27,7 @@ LL | impl<'a, T : 'a> FuncWrapper<'a, T> { LL | (self.func)(arg) | ------------^^^- | | | - | | mutable borrow starts here in previous iteration of loop + | | `*arg` was mutably borrowed here in the previous iteration of the loop | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time @@ -39,7 +39,7 @@ LL | impl<'a, T : 'a> FuncWrapper<'a, T> { LL | (self.func)(arg) | ------------^^^- | | | - | | mutable borrow starts here in previous iteration of loop + | | `*arg` was mutably borrowed here in the previous iteration of the loop | argument requires that `*arg` is borrowed for `'a` error: aborting due to 3 previous errors; 1 warning emitted diff --git a/src/test/ui/borrowck/two-phase-across-loop.stderr b/src/test/ui/borrowck/two-phase-across-loop.stderr index 38993a50bf6..d4e515d12bb 100644 --- a/src/test/ui/borrowck/two-phase-across-loop.stderr +++ b/src/test/ui/borrowck/two-phase-across-loop.stderr @@ -2,7 +2,7 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-across-loop.rs:17:22 | LL | strings.push(foo.get_string()); - | ^^^ mutable borrow starts here in previous iteration of loop + | ^^^ `foo` was mutably borrowed here in the previous iteration of the loop error: aborting due to previous error diff --git a/src/test/ui/builtin-superkinds-capabilities-transitive.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities-transitive.rs index 1f997d37122..1f997d37122 100644 --- a/src/test/ui/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities-transitive.rs diff --git a/src/test/ui/builtin-superkinds-capabilities-xc.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities-xc.rs index 8416bb3a377..8416bb3a377 100644 --- a/src/test/ui/builtin-superkinds-capabilities-xc.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities-xc.rs diff --git a/src/test/ui/builtin-superkinds-capabilities.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities.rs index e936f921a82..e936f921a82 100644 --- a/src/test/ui/builtin-superkinds-capabilities.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-capabilities.rs diff --git a/src/test/ui/builtin-superkinds-in-metadata.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs index 117014b44ee..117014b44ee 100644 --- a/src/test/ui/builtin-superkinds-in-metadata.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs diff --git a/src/test/ui/builtin-superkinds-phantom-typaram.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-phantom-typaram.rs index 9b80664b04e..9b80664b04e 100644 --- a/src/test/ui/builtin-superkinds-phantom-typaram.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-phantom-typaram.rs diff --git a/src/test/ui/builtin-superkinds-simple.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-simple2.rs index 8d247715784..8d247715784 100644 --- a/src/test/ui/builtin-superkinds-simple.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-simple2.rs diff --git a/src/test/ui/builtin-superkinds-typaram.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram.rs index f999dfff786..f999dfff786 100644 --- a/src/test/ui/builtin-superkinds-typaram.rs +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram.rs diff --git a/src/test/ui/cast-char.rs b/src/test/ui/cast/cast-char.rs index 9634ed56f7b..9634ed56f7b 100644 --- a/src/test/ui/cast-char.rs +++ b/src/test/ui/cast/cast-char.rs diff --git a/src/test/ui/cast-char.stderr b/src/test/ui/cast/cast-char.stderr index 211937c9d6f..211937c9d6f 100644 --- a/src/test/ui/cast-char.stderr +++ b/src/test/ui/cast/cast-char.stderr diff --git a/src/test/ui/cast-does-fallback.rs b/src/test/ui/cast/cast-does-fallback.rs index 770f7a31c76..770f7a31c76 100644 --- a/src/test/ui/cast-does-fallback.rs +++ b/src/test/ui/cast/cast-does-fallback.rs diff --git a/src/test/ui/cast-region-to-uint.rs b/src/test/ui/cast/cast-region-to-uint.rs index 33ec2d27610..33ec2d27610 100644 --- a/src/test/ui/cast-region-to-uint.rs +++ b/src/test/ui/cast/cast-region-to-uint.rs diff --git a/src/test/ui/cast-rfc0401-vtable-kinds.rs b/src/test/ui/cast/cast-rfc0401-vtable-kinds.rs index 249481467e6..249481467e6 100644 --- a/src/test/ui/cast-rfc0401-vtable-kinds.rs +++ b/src/test/ui/cast/cast-rfc0401-vtable-kinds.rs diff --git a/src/test/ui/cast-rfc0401.rs b/src/test/ui/cast/cast-rfc0401.rs index 996fa013fed..996fa013fed 100644 --- a/src/test/ui/cast-rfc0401.rs +++ b/src/test/ui/cast/cast-rfc0401.rs diff --git a/src/test/ui/cast-to-infer-ty.rs b/src/test/ui/cast/cast-to-infer-ty.rs index 053ebb621a7..053ebb621a7 100644 --- a/src/test/ui/cast-to-infer-ty.rs +++ b/src/test/ui/cast/cast-to-infer-ty.rs diff --git a/src/test/ui/cast.rs b/src/test/ui/cast/cast.rs index 218275c4d99..218275c4d99 100644 --- a/src/test/ui/cast.rs +++ b/src/test/ui/cast/cast.rs diff --git a/src/test/ui/casts-differing-anon.rs b/src/test/ui/cast/casts-differing-anon.rs index d4a0f961305..d4a0f961305 100644 --- a/src/test/ui/casts-differing-anon.rs +++ b/src/test/ui/cast/casts-differing-anon.rs diff --git a/src/test/ui/casts-differing-anon.stderr b/src/test/ui/cast/casts-differing-anon.stderr index a30e9b35f5c..a30e9b35f5c 100644 --- a/src/test/ui/casts-differing-anon.stderr +++ b/src/test/ui/cast/casts-differing-anon.stderr diff --git a/src/test/ui/casts-issue-46365.rs b/src/test/ui/cast/casts-issue-46365.rs index 3d0fea245c0..3d0fea245c0 100644 --- a/src/test/ui/casts-issue-46365.rs +++ b/src/test/ui/cast/casts-issue-46365.rs diff --git a/src/test/ui/casts-issue-46365.stderr b/src/test/ui/cast/casts-issue-46365.stderr index 84175473696..84175473696 100644 --- a/src/test/ui/casts-issue-46365.stderr +++ b/src/test/ui/cast/casts-issue-46365.stderr diff --git a/src/test/ui/check-doc-alias-attr-location.rs b/src/test/ui/check-doc-alias-attr-location.rs index dac9b7372e0..3a0436e468d 100644 --- a/src/test/ui/check-doc-alias-attr-location.rs +++ b/src/test/ui/check-doc-alias-attr-location.rs @@ -1,5 +1,4 @@ #![crate_type="lib"] -#![feature(doc_alias)] pub struct Bar; pub trait Foo { diff --git a/src/test/ui/check-doc-alias-attr-location.stderr b/src/test/ui/check-doc-alias-attr-location.stderr index 29a99e4470e..a66e9939eaf 100644 --- a/src/test/ui/check-doc-alias-attr-location.stderr +++ b/src/test/ui/check-doc-alias-attr-location.stderr @@ -1,23 +1,23 @@ error: `#[doc(alias = "...")]` isn't allowed on extern block - --> $DIR/check-doc-alias-attr-location.rs:10:7 + --> $DIR/check-doc-alias-attr-location.rs:9:7 | LL | #[doc(alias = "foo")] | ^^^^^^^^^^^^^ error: `#[doc(alias = "...")]` isn't allowed on implementation block - --> $DIR/check-doc-alias-attr-location.rs:13:7 + --> $DIR/check-doc-alias-attr-location.rs:12:7 | LL | #[doc(alias = "bar")] | ^^^^^^^^^^^^^ error: `#[doc(alias = "...")]` isn't allowed on implementation block - --> $DIR/check-doc-alias-attr-location.rs:19:7 + --> $DIR/check-doc-alias-attr-location.rs:18:7 | LL | #[doc(alias = "foobar")] | ^^^^^^^^^^^^^^^^ error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block - --> $DIR/check-doc-alias-attr-location.rs:21:11 + --> $DIR/check-doc-alias-attr-location.rs:20:11 | LL | #[doc(alias = "assoc")] | ^^^^^^^^^^^^^^^ diff --git a/src/test/ui/check-doc-alias-attr.rs b/src/test/ui/check-doc-alias-attr.rs index 0ca2349a43b..912e35f9165 100644 --- a/src/test/ui/check-doc-alias-attr.rs +++ b/src/test/ui/check-doc-alias-attr.rs @@ -1,5 +1,4 @@ #![crate_type = "lib"] -#![feature(doc_alias)] #[doc(alias = "foo")] // ok! pub struct Bar; diff --git a/src/test/ui/check-doc-alias-attr.stderr b/src/test/ui/check-doc-alias-attr.stderr index dce325f9d38..1c7fc83bb8d 100644 --- a/src/test/ui/check-doc-alias-attr.stderr +++ b/src/test/ui/check-doc-alias-attr.stderr @@ -1,35 +1,35 @@ error: doc alias attribute expects a string: #[doc(alias = "a")] - --> $DIR/check-doc-alias-attr.rs:7:7 + --> $DIR/check-doc-alias-attr.rs:6:7 | LL | #[doc(alias)] | ^^^^^ error: doc alias attribute expects a string: #[doc(alias = "a")] - --> $DIR/check-doc-alias-attr.rs:8:7 + --> $DIR/check-doc-alias-attr.rs:7:7 | LL | #[doc(alias = 0)] | ^^^^^^^^^ error: doc alias attribute expects a string: #[doc(alias = "a")] - --> $DIR/check-doc-alias-attr.rs:9:7 + --> $DIR/check-doc-alias-attr.rs:8:7 | LL | #[doc(alias("bar"))] | ^^^^^^^^^^^^ error: '\"' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/check-doc-alias-attr.rs:10:15 + --> $DIR/check-doc-alias-attr.rs:9:15 | LL | #[doc(alias = "\"")] | ^^^^ error: '\n' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/check-doc-alias-attr.rs:11:15 + --> $DIR/check-doc-alias-attr.rs:10:15 | LL | #[doc(alias = "\n")] | ^^^^ error: '\n' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/check-doc-alias-attr.rs:12:15 + --> $DIR/check-doc-alias-attr.rs:11:15 | LL | #[doc(alias = " | _______________^ @@ -37,19 +37,19 @@ LL | | ")] | |_^ error: '\t' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/check-doc-alias-attr.rs:14:15 + --> $DIR/check-doc-alias-attr.rs:13:15 | LL | #[doc(alias = "\t")] | ^^^^ error: `#[doc(alias = "...")]` cannot start or end with ' ' - --> $DIR/check-doc-alias-attr.rs:15:15 + --> $DIR/check-doc-alias-attr.rs:14:15 | LL | #[doc(alias = " hello")] | ^^^^^^^^ error: `#[doc(alias = "...")]` cannot start or end with ' ' - --> $DIR/check-doc-alias-attr.rs:16:15 + --> $DIR/check-doc-alias-attr.rs:15:15 | LL | #[doc(alias = "hello ")] | ^^^^^^^^ diff --git a/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs index 36777693fab..36777693fab 100644 --- a/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs +++ b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr new file mode 100644 index 00000000000..a1fb1c02e46 --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31 + | +LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/compile-fail/coerce-unsafe-to-closure.rs b/src/test/ui/closures/coerce-unsafe-to-closure.rs index 78bdd36f9cc..78bdd36f9cc 100644 --- a/src/test/compile-fail/coerce-unsafe-to-closure.rs +++ b/src/test/ui/closures/coerce-unsafe-to-closure.rs diff --git a/src/test/ui/closures/coerce-unsafe-to-closure.stderr b/src/test/ui/closures/coerce-unsafe-to-closure.stderr new file mode 100644 index 00000000000..ab035d03b05 --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-to-closure.stderr @@ -0,0 +1,11 @@ +error[E0277]: expected a `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + --> $DIR/coerce-unsafe-to-closure.rs:2:44 + | +LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); + | ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + | + = help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/block-arg-call-as.rs b/src/test/ui/closures/old-closure-arg-call-as.rs index 87cf3a487bf..87cf3a487bf 100644 --- a/src/test/ui/block-arg-call-as.rs +++ b/src/test/ui/closures/old-closure-arg-call-as.rs diff --git a/src/test/ui/block-arg.rs b/src/test/ui/closures/old-closure-arg.rs index bd1385e5c33..bd1385e5c33 100644 --- a/src/test/ui/block-arg.rs +++ b/src/test/ui/closures/old-closure-arg.rs diff --git a/src/test/ui/block-explicit-types.rs b/src/test/ui/closures/old-closure-explicit-types.rs index 860fcc8df21..860fcc8df21 100644 --- a/src/test/ui/block-explicit-types.rs +++ b/src/test/ui/closures/old-closure-explicit-types.rs diff --git a/src/test/ui/block-expr-precedence.rs b/src/test/ui/closures/old-closure-expr-precedence.rs index 13b2fe9c3d1..13b2fe9c3d1 100644 --- a/src/test/ui/block-expr-precedence.rs +++ b/src/test/ui/closures/old-closure-expr-precedence.rs diff --git a/src/test/ui/block-expr-precedence.stderr b/src/test/ui/closures/old-closure-expr-precedence.stderr index c28980bf147..fabece1ad4a 100644 --- a/src/test/ui/block-expr-precedence.stderr +++ b/src/test/ui/closures/old-closure-expr-precedence.stderr @@ -1,5 +1,5 @@ warning: unnecessary trailing semicolons - --> $DIR/block-expr-precedence.rs:60:21 + --> $DIR/old-closure-expr-precedence.rs:60:21 | LL | if (true) { 12; };;; -num; | ^^ help: remove these semicolons diff --git a/src/test/ui/block-expression-remove-semicolon.fixed b/src/test/ui/closures/old-closure-expression-remove-semicolon.fixed index 5629d4b6e6e..5629d4b6e6e 100644 --- a/src/test/ui/block-expression-remove-semicolon.fixed +++ b/src/test/ui/closures/old-closure-expression-remove-semicolon.fixed diff --git a/src/test/ui/block-expression-remove-semicolon.rs b/src/test/ui/closures/old-closure-expression-remove-semicolon.rs index 33f11b50afc..33f11b50afc 100644 --- a/src/test/ui/block-expression-remove-semicolon.rs +++ b/src/test/ui/closures/old-closure-expression-remove-semicolon.rs diff --git a/src/test/ui/block-expression-remove-semicolon.stderr b/src/test/ui/closures/old-closure-expression-remove-semicolon.stderr index 74dc4d595a9..ab7983dc9e4 100644 --- a/src/test/ui/block-expression-remove-semicolon.stderr +++ b/src/test/ui/closures/old-closure-expression-remove-semicolon.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/block-expression-remove-semicolon.rs:8:19 + --> $DIR/old-closure-expression-remove-semicolon.rs:8:19 | LL | let _x: i32 = { | ___________________^ diff --git a/src/test/ui/block-fn-coerce.rs b/src/test/ui/closures/old-closure-fn-coerce.rs index d993ad99459..d993ad99459 100644 --- a/src/test/ui/block-fn-coerce.rs +++ b/src/test/ui/closures/old-closure-fn-coerce.rs diff --git a/src/test/ui/block-iter-1.rs b/src/test/ui/closures/old-closure-iter-1.rs index caf0266cff1..caf0266cff1 100644 --- a/src/test/ui/block-iter-1.rs +++ b/src/test/ui/closures/old-closure-iter-1.rs diff --git a/src/test/ui/block-iter-2.rs b/src/test/ui/closures/old-closure-iter-2.rs index e90c1ee815a..e90c1ee815a 100644 --- a/src/test/ui/block-iter-2.rs +++ b/src/test/ui/closures/old-closure-iter-2.rs diff --git a/src/test/ui/const-generics/apit-with-const-param.rs b/src/test/ui/const-generics/apit-with-const-param.rs index facc0bcf513..3bc62141927 100644 --- a/src/test/ui/const-generics/apit-with-const-param.rs +++ b/src/test/ui/const-generics/apit-with-const-param.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Trait {} diff --git a/src/test/ui/const-generics/arg-in-pat-1.rs b/src/test/ui/const-generics/arg-in-pat-1.rs new file mode 100644 index 00000000000..82555084e41 --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-1.rs @@ -0,0 +1,23 @@ +// check-pass +enum ConstGenericEnum<const N: usize> { + Foo([i32; N]), + Bar, +} + +fn foo<const N: usize>(val: &ConstGenericEnum<N>) { + if let ConstGenericEnum::<N>::Foo(field, ..) = val {} +} + +fn bar<const N: usize>(val: &ConstGenericEnum<N>) { + match val { + ConstGenericEnum::<N>::Foo(field, ..) => (), + ConstGenericEnum::<N>::Bar => (), + } +} + +fn main() { + match ConstGenericEnum::Bar { + ConstGenericEnum::<3>::Foo(field, ..) => (), + ConstGenericEnum::<3>::Bar => (), + } +} diff --git a/src/test/ui/const-generics/arg-in-pat-2.rs b/src/test/ui/const-generics/arg-in-pat-2.rs new file mode 100644 index 00000000000..dc9e722eda8 --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-2.rs @@ -0,0 +1,10 @@ +// check-pass +enum Generic<const N: usize> { + Variant, +} + +fn main() { + match todo!() { + Generic::<0usize>::Variant => todo!() + } +} diff --git a/src/test/ui/const-generics/arg-in-pat-3.rs b/src/test/ui/const-generics/arg-in-pat-3.rs new file mode 100644 index 00000000000..24626a3b68a --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-3.rs @@ -0,0 +1,43 @@ +// check-pass +struct Foo<const N: usize>; + +fn bindingp() { + match Foo { + mut x @ Foo::<3> => { + let ref mut _x @ Foo::<3> = x; + } + } +} + +struct Bar<const N: usize> { + field: Foo<N>, +} + +fn structp() { + match todo!() { + Bar::<3> { + field: Foo::<3>, + } => (), + } +} + +struct Baz<const N: usize>(Foo<N>); + +fn tuplestructp() { + match Baz(Foo) { + Baz::<3>(Foo::<3>) => (), + } +} + +impl<const N: usize> Baz<N> { + const ASSOC: usize = 3; +} + +fn pathp() { + match 3 { + Baz::<3>::ASSOC => (), + _ => (), + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/argument_order.full.stderr b/src/test/ui/const-generics/argument_order.full.stderr index b52e5050703..e533d4f7fb8 100644 --- a/src/test/ui/const-generics/argument_order.full.stderr +++ b/src/test/ui/const-generics/argument_order.full.stderr @@ -1,11 +1,11 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/argument_order.rs:12:32 + --> $DIR/argument_order.rs:11:32 | LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> { | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>` error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:20:23 + --> $DIR/argument_order.rs:19:23 | LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ diff --git a/src/test/ui/const-generics/argument_order.min.stderr b/src/test/ui/const-generics/argument_order.min.stderr index 728ae69b41f..f23bc6d6a2b 100644 --- a/src/test/ui/const-generics/argument_order.min.stderr +++ b/src/test/ui/const-generics/argument_order.min.stderr @@ -1,23 +1,23 @@ error: type parameters must be declared prior to const parameters - --> $DIR/argument_order.rs:6:28 + --> $DIR/argument_order.rs:5:28 | LL | struct Bad<const N: usize, T> { | -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` error: lifetime parameters must be declared prior to const parameters - --> $DIR/argument_order.rs:12:32 + --> $DIR/argument_order.rs:11:32 | LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> { | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>` error: type parameters must be declared prior to const parameters - --> $DIR/argument_order.rs:12:36 + --> $DIR/argument_order.rs:11:36 | LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> { | ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>` error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:20:23 + --> $DIR/argument_order.rs:19:23 | LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ diff --git a/src/test/ui/const-generics/argument_order.rs b/src/test/ui/const-generics/argument_order.rs index 507baf5fd75..95eaeea5818 100644 --- a/src/test/ui/const-generics/argument_order.rs +++ b/src/test/ui/const-generics/argument_order.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Bad<const N: usize, T> { //[min]~^ ERROR type parameters must be declared prior to const parameters diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr index cf4487b5829..0fb23e41b01 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/array-size-in-generic-struct-param.rs:9:38 + --> $DIR/array-size-in-generic-struct-param.rs:8:38 | LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/array-size-in-generic-struct-param.rs:20:10 + --> $DIR/array-size-in-generic-struct-param.rs:19:10 | LL | arr: [u8; CFG.arr_size], | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr index 73c9ea59c95..8f6e56826fa 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/array-size-in-generic-struct-param.rs:9:48 + --> $DIR/array-size-in-generic-struct-param.rs:8:48 | LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/array-size-in-generic-struct-param.rs:20:15 + --> $DIR/array-size-in-generic-struct-param.rs:19:15 | LL | arr: [u8; CFG.arr_size], | ^^^ cannot perform const operation using `CFG` @@ -17,13 +17,13 @@ LL | arr: [u8; CFG.arr_size], = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: `Config` is forbidden as the type of a const generic parameter - --> $DIR/array-size-in-generic-struct-param.rs:18:21 + --> $DIR/array-size-in-generic-struct-param.rs:17:21 | LL | struct B<const CFG: Config> { | ^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 3 previous errors diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs index 768180d0813..cd0a9742cd1 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[allow(dead_code)] struct ArithArrayLen<const N: usize>([u32; 0 + N]); diff --git a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs index 390b6cc2049..732a1871456 100644 --- a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs +++ b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code)] diff --git a/src/test/ui/const-generics/associated-type-bound-fail.full.stderr b/src/test/ui/const-generics/associated-type-bound-fail.full.stderr index 8ccbe5dee0e..6644e74f97a 100644 --- a/src/test/ui/const-generics/associated-type-bound-fail.full.stderr +++ b/src/test/ui/const-generics/associated-type-bound-fail.full.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `u16: Bar<N>` is not satisfied - --> $DIR/associated-type-bound-fail.rs:14:5 + --> $DIR/associated-type-bound-fail.rs:13:5 | LL | type Assoc: Bar<N>; | ------ required by this bound in `Foo::Assoc` diff --git a/src/test/ui/const-generics/associated-type-bound-fail.min.stderr b/src/test/ui/const-generics/associated-type-bound-fail.min.stderr index 8ccbe5dee0e..6644e74f97a 100644 --- a/src/test/ui/const-generics/associated-type-bound-fail.min.stderr +++ b/src/test/ui/const-generics/associated-type-bound-fail.min.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `u16: Bar<N>` is not satisfied - --> $DIR/associated-type-bound-fail.rs:14:5 + --> $DIR/associated-type-bound-fail.rs:13:5 | LL | type Assoc: Bar<N>; | ------ required by this bound in `Foo::Assoc` diff --git a/src/test/ui/const-generics/associated-type-bound-fail.rs b/src/test/ui/const-generics/associated-type-bound-fail.rs index 3440b1356c2..83b26700805 100644 --- a/src/test/ui/const-generics/associated-type-bound-fail.rs +++ b/src/test/ui/const-generics/associated-type-bound-fail.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] trait Bar<const N: usize> {} diff --git a/src/test/ui/const-generics/associated-type-bound.rs b/src/test/ui/const-generics/associated-type-bound.rs index 374a49194b1..02f77396c0b 100644 --- a/src/test/ui/const-generics/associated-type-bound.rs +++ b/src/test/ui/const-generics/associated-type-bound.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] trait Bar<const N: usize> {} diff --git a/src/test/ui/const-generics/auxiliary/const_generic_lib.rs b/src/test/ui/const-generics/auxiliary/const_generic_lib.rs index 899a5a1836c..8d4cd9c0d6b 100644 --- a/src/test/ui/const-generics/auxiliary/const_generic_lib.rs +++ b/src/test/ui/const-generics/auxiliary/const_generic_lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct Struct<const N: usize>(pub [u8; N]); diff --git a/src/test/ui/const-generics/auxiliary/crayte.rs b/src/test/ui/const-generics/auxiliary/crayte.rs index 725005971e1..d9baab956c9 100644 --- a/src/test/ui/const-generics/auxiliary/crayte.rs +++ b/src/test/ui/const-generics/auxiliary/crayte.rs @@ -1,7 +1,6 @@ // edition:2018 #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub trait Foo<const N: usize> {} struct Local; diff --git a/src/test/ui/const-generics/auxiliary/impl-const.rs b/src/test/ui/const-generics/auxiliary/impl-const.rs index 2e25dadf119..4a6b5784221 100644 --- a/src/test/ui/const-generics/auxiliary/impl-const.rs +++ b/src/test/ui/const-generics/auxiliary/impl-const.rs @@ -1,6 +1,5 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct Num<const N: usize>; diff --git a/src/test/ui/const-generics/broken-mir-1.rs b/src/test/ui/const-generics/broken-mir-1.rs index d13ae12c03b..34255fa9f58 100644 --- a/src/test/ui/const-generics/broken-mir-1.rs +++ b/src/test/ui/const-generics/broken-mir-1.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub trait Foo { fn foo(&self); diff --git a/src/test/ui/const-generics/broken-mir-2.rs b/src/test/ui/const-generics/broken-mir-2.rs index 2f9afe0b464..ac358b01672 100644 --- a/src/test/ui/const-generics/broken-mir-2.rs +++ b/src/test/ui/const-generics/broken-mir-2.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::fmt::Debug; diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs index 931f6ade7f1..44aef859f2d 100644 --- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // This test confirms that the types can be inferred correctly for this example with const // generics. Previously this would ICE, and more recently error. diff --git a/src/test/ui/const-generics/closing-args-token.full.stderr b/src/test/ui/const-generics/closing-args-token.full.stderr index 1c3ddd345a5..7737705440e 100644 --- a/src/test/ui/const-generics/closing-args-token.full.stderr +++ b/src/test/ui/const-generics/closing-args-token.full.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/closing-args-token.rs:11:9 + --> $DIR/closing-args-token.rs:10:9 | LL | S::<5 + 2 >> 7>; | ^^^^^ @@ -10,7 +10,7 @@ LL | S::<{ 5 + 2 } >> 7>; | ^ ^ error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:11:16 + --> $DIR/closing-args-token.rs:10:16 | LL | S::<5 + 2 >> 7>; | ^ ^ @@ -21,7 +21,7 @@ LL | S::<5 + 2 >> 7 && 7>; | ^^^^ error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:17:20 + --> $DIR/closing-args-token.rs:16:20 | LL | S::<{ 5 + 2 } >> 7>; | ^ ^ @@ -32,13 +32,13 @@ LL | S::<{ 5 + 2 } >> 7 && 7>; | ^^^^ error: expected expression, found `;` - --> $DIR/closing-args-token.rs:22:16 + --> $DIR/closing-args-token.rs:21:16 | LL | T::<0 >= 3>; | ^ expected expression error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:28:12 + --> $DIR/closing-args-token.rs:27:12 | LL | T::<x >>= 2 > 0>; | ^^ ^ diff --git a/src/test/ui/const-generics/closing-args-token.min.stderr b/src/test/ui/const-generics/closing-args-token.min.stderr index 1c3ddd345a5..7737705440e 100644 --- a/src/test/ui/const-generics/closing-args-token.min.stderr +++ b/src/test/ui/const-generics/closing-args-token.min.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/closing-args-token.rs:11:9 + --> $DIR/closing-args-token.rs:10:9 | LL | S::<5 + 2 >> 7>; | ^^^^^ @@ -10,7 +10,7 @@ LL | S::<{ 5 + 2 } >> 7>; | ^ ^ error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:11:16 + --> $DIR/closing-args-token.rs:10:16 | LL | S::<5 + 2 >> 7>; | ^ ^ @@ -21,7 +21,7 @@ LL | S::<5 + 2 >> 7 && 7>; | ^^^^ error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:17:20 + --> $DIR/closing-args-token.rs:16:20 | LL | S::<{ 5 + 2 } >> 7>; | ^ ^ @@ -32,13 +32,13 @@ LL | S::<{ 5 + 2 } >> 7 && 7>; | ^^^^ error: expected expression, found `;` - --> $DIR/closing-args-token.rs:22:16 + --> $DIR/closing-args-token.rs:21:16 | LL | T::<0 >= 3>; | ^ expected expression error: comparison operators cannot be chained - --> $DIR/closing-args-token.rs:28:12 + --> $DIR/closing-args-token.rs:27:12 | LL | T::<x >>= 2 > 0>; | ^^ ^ diff --git a/src/test/ui/const-generics/closing-args-token.rs b/src/test/ui/const-generics/closing-args-token.rs index 8699637c54e..a9b552ebed7 100644 --- a/src/test/ui/const-generics/closing-args-token.rs +++ b/src/test/ui/const-generics/closing-args-token.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct S<const X: u32>; struct T<const X: bool>; diff --git a/src/test/ui/const-generics/coerce_unsized_array.rs b/src/test/ui/const-generics/coerce_unsized_array.rs index a3c295f73c7..8e20df28103 100644 --- a/src/test/ui/const-generics/coerce_unsized_array.rs +++ b/src/test/ui/const-generics/coerce_unsized_array.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const N: usize>(v: &[u8; N]) -> &[u8] { v diff --git a/src/test/ui/const-generics/concrete-const-as-fn-arg.rs b/src/test/ui/const-generics/concrete-const-as-fn-arg.rs index 7771bf33601..8c31c8651a2 100644 --- a/src/test/ui/const-generics/concrete-const-as-fn-arg.rs +++ b/src/test/ui/const-generics/concrete-const-as-fn-arg.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize>; // ok diff --git a/src/test/ui/const-generics/concrete-const-impl-method.rs b/src/test/ui/const-generics/concrete-const-impl-method.rs index edb403ce8fd..3d3bd2664c8 100644 --- a/src/test/ui/const-generics/concrete-const-impl-method.rs +++ b/src/test/ui/const-generics/concrete-const-impl-method.rs @@ -5,7 +5,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct A<const N: u32>; diff --git a/src/test/ui/const-generics/condition-in-trait-const-arg.rs b/src/test/ui/const-generics/condition-in-trait-const-arg.rs index 77b68052fc0..ad40b48afe5 100644 --- a/src/test/ui/const-generics/condition-in-trait-const-arg.rs +++ b/src/test/ui/const-generics/condition-in-trait-const-arg.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait IsZeroTrait<const IS_ZERO: bool>{} diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr index 042fa9ad958..bfa4ba30686 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:14:23 + --> $DIR/const-arg-in-const-arg.rs:13:23 | LL | let _: [u8; foo::<T>()]; | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | let _: [u8; foo::<T>()]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:15:23 + --> $DIR/const-arg-in-const-arg.rs:14:23 | LL | let _: [u8; bar::<N>()]; | ^ cannot perform const operation using `N` @@ -17,7 +17,7 @@ LL | let _: [u8; bar::<N>()]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:25:23 + --> $DIR/const-arg-in-const-arg.rs:24:23 | LL | let _ = [0; bar::<N>()]; | ^ cannot perform const operation using `N` @@ -26,7 +26,7 @@ LL | let _ = [0; bar::<N>()]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:30:24 + --> $DIR/const-arg-in-const-arg.rs:29:24 | LL | let _: Foo<{ foo::<T>() }>; | ^ cannot perform const operation using `T` @@ -35,7 +35,7 @@ LL | let _: Foo<{ foo::<T>() }>; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:31:24 + --> $DIR/const-arg-in-const-arg.rs:30:24 | LL | let _: Foo<{ bar::<N>() }>; | ^ cannot perform const operation using `N` @@ -44,7 +44,7 @@ LL | let _: Foo<{ bar::<N>() }>; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:36:27 + --> $DIR/const-arg-in-const-arg.rs:35:27 | LL | let _ = Foo::<{ foo::<T>() }>; | ^ cannot perform const operation using `T` @@ -53,7 +53,7 @@ LL | let _ = Foo::<{ foo::<T>() }>; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:37:27 + --> $DIR/const-arg-in-const-arg.rs:36:27 | LL | let _ = Foo::<{ bar::<N>() }>; | ^ cannot perform const operation using `N` @@ -62,7 +62,7 @@ LL | let _ = Foo::<{ bar::<N>() }>; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:16:23 + --> $DIR/const-arg-in-const-arg.rs:15:23 | LL | let _: [u8; faz::<'a>(&())]; | ^^ @@ -71,7 +71,7 @@ LL | let _: [u8; faz::<'a>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:17:23 + --> $DIR/const-arg-in-const-arg.rs:16:23 | LL | let _: [u8; baz::<'a>(&())]; | ^^ @@ -80,7 +80,7 @@ LL | let _: [u8; baz::<'a>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:18:23 + --> $DIR/const-arg-in-const-arg.rs:17:23 | LL | let _: [u8; faz::<'b>(&())]; | ^^ @@ -89,7 +89,7 @@ LL | let _: [u8; faz::<'b>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:19:23 + --> $DIR/const-arg-in-const-arg.rs:18:23 | LL | let _: [u8; baz::<'b>(&())]; | ^^ @@ -98,7 +98,7 @@ LL | let _: [u8; baz::<'b>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:26:23 + --> $DIR/const-arg-in-const-arg.rs:25:23 | LL | let _ = [0; faz::<'a>(&())]; | ^^ @@ -107,7 +107,7 @@ LL | let _ = [0; faz::<'a>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:27:23 + --> $DIR/const-arg-in-const-arg.rs:26:23 | LL | let _ = [0; baz::<'a>(&())]; | ^^ @@ -116,7 +116,7 @@ LL | let _ = [0; baz::<'a>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:28:23 + --> $DIR/const-arg-in-const-arg.rs:27:23 | LL | let _ = [0; faz::<'b>(&())]; | ^^ @@ -125,7 +125,7 @@ LL | let _ = [0; faz::<'b>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:29:23 + --> $DIR/const-arg-in-const-arg.rs:28:23 | LL | let _ = [0; baz::<'b>(&())]; | ^^ @@ -134,7 +134,7 @@ LL | let _ = [0; baz::<'b>(&())]; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:32:24 + --> $DIR/const-arg-in-const-arg.rs:31:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; | ^^ @@ -143,7 +143,7 @@ LL | let _: Foo<{ faz::<'a>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:33:24 + --> $DIR/const-arg-in-const-arg.rs:32:24 | LL | let _: Foo<{ baz::<'a>(&()) }>; | ^^ @@ -152,7 +152,7 @@ LL | let _: Foo<{ baz::<'a>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:34:24 + --> $DIR/const-arg-in-const-arg.rs:33:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; | ^^ @@ -161,7 +161,7 @@ LL | let _: Foo<{ faz::<'b>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:35:24 + --> $DIR/const-arg-in-const-arg.rs:34:24 | LL | let _: Foo<{ baz::<'b>(&()) }>; | ^^ @@ -170,7 +170,7 @@ LL | let _: Foo<{ baz::<'b>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:38:27 + --> $DIR/const-arg-in-const-arg.rs:37:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; | ^^ @@ -179,7 +179,7 @@ LL | let _ = Foo::<{ faz::<'a>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:39:27 + --> $DIR/const-arg-in-const-arg.rs:38:27 | LL | let _ = Foo::<{ baz::<'a>(&()) }>; | ^^ @@ -188,7 +188,7 @@ LL | let _ = Foo::<{ baz::<'a>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:40:27 + --> $DIR/const-arg-in-const-arg.rs:39:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; | ^^ @@ -197,7 +197,7 @@ LL | let _ = Foo::<{ faz::<'b>(&()) }>; = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:41:27 + --> $DIR/const-arg-in-const-arg.rs:40:27 | LL | let _ = Foo::<{ baz::<'b>(&()) }>; | ^^ diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.rs b/src/test/ui/const-generics/const-arg-in-const-arg.rs index 9927538ef50..8279f4a3f61 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.rs +++ b/src/test/ui/const-generics/const-arg-in-const-arg.rs @@ -2,7 +2,6 @@ // FIXME(const_generics): This test currently causes an ICE because // we don't yet correctly deal with lifetimes, reenable this test once // this is fixed. -#![cfg_attr(min, feature(min_const_generics))] const fn foo<T>() -> usize { std::mem::size_of::<T>() } const fn bar<const N: usize>() -> usize { N } diff --git a/src/test/ui/const-generics/const-arg-in-fn.rs b/src/test/ui/const-generics/const-arg-in-fn.rs index 5c438efd82a..43ed12efb89 100644 --- a/src/test/ui/const-generics/const-arg-in-fn.rs +++ b/src/test/ui/const-generics/const-arg-in-fn.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn const_u32_identity<const X: u32>() -> u32 { X diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr index 3827002ff4b..d0ea51ea417 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr @@ -1,5 +1,5 @@ error[E0747]: constant provided when a type was expected - --> $DIR/const-arg-type-arg-misordered.rs:8:35 + --> $DIR/const-arg-type-arg-misordered.rs:7:35 | LL | fn foo<const N: usize>() -> Array<N, ()> { | ^ diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr index 2c5fc8dcc01..d7b7df0eb55 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr @@ -1,5 +1,5 @@ error[E0747]: constant provided when a type was expected - --> $DIR/const-arg-type-arg-misordered.rs:8:35 + --> $DIR/const-arg-type-arg-misordered.rs:7:35 | LL | fn foo<const N: usize>() -> Array<N, ()> { | ^ diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs index 6680f772fa3..5415791d21b 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] type Array<T, const N: usize> = [T; N]; diff --git a/src/test/ui/const-generics/const-argument-if-length.full.stderr b/src/test/ui/const-generics/const-argument-if-length.full.stderr index 4d627f05adc..5dca01f0dc0 100644 --- a/src/test/ui/const-generics/const-argument-if-length.full.stderr +++ b/src/test/ui/const-generics/const-argument-if-length.full.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/const-argument-if-length.rs:8:28 + --> $DIR/const-argument-if-length.rs:7:28 | LL | pub const fn is_zst<T: ?Sized>() -> usize { | - this type parameter needs to be `Sized` @@ -12,7 +12,7 @@ LL | pub const fn size_of<T>() -> usize { | - required by this bound in `std::mem::size_of` error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/const-argument-if-length.rs:17:12 + --> $DIR/const-argument-if-length.rs:16:12 | LL | pub struct AtLeastByte<T: ?Sized> { | - this type parameter needs to be `Sized` diff --git a/src/test/ui/const-generics/const-argument-if-length.min.stderr b/src/test/ui/const-generics/const-argument-if-length.min.stderr index 8a1074392a5..ea177c19746 100644 --- a/src/test/ui/const-generics/const-argument-if-length.min.stderr +++ b/src/test/ui/const-generics/const-argument-if-length.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/const-argument-if-length.rs:19:24 + --> $DIR/const-argument-if-length.rs:18:24 | LL | pad: [u8; is_zst::<T>()], | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | pad: [u8; is_zst::<T>()], = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/const-argument-if-length.rs:17:12 + --> $DIR/const-argument-if-length.rs:16:12 | LL | pub struct AtLeastByte<T: ?Sized> { | - this type parameter needs to be `Sized` diff --git a/src/test/ui/const-generics/const-argument-if-length.rs b/src/test/ui/const-generics/const-argument-if-length.rs index 80907383124..67ed85f96af 100644 --- a/src/test/ui/const-generics/const-argument-if-length.rs +++ b/src/test/ui/const-generics/const-argument-if-length.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] pub const fn is_zst<T: ?Sized>() -> usize { if std::mem::size_of::<T>() == 0 { diff --git a/src/test/ui/const-generics/const-expression-parameter.full.stderr b/src/test/ui/const-generics/const-expression-parameter.full.stderr index 0615a4c206d..93c5173554f 100644 --- a/src/test/ui/const-generics/const-expression-parameter.full.stderr +++ b/src/test/ui/const-generics/const-expression-parameter.full.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/const-expression-parameter.rs:16:20 + --> $DIR/const-expression-parameter.rs:15:20 | LL | i32_identity::<1 + 2>(); | ^^^^^ diff --git a/src/test/ui/const-generics/const-expression-parameter.min.stderr b/src/test/ui/const-generics/const-expression-parameter.min.stderr index 0615a4c206d..93c5173554f 100644 --- a/src/test/ui/const-generics/const-expression-parameter.min.stderr +++ b/src/test/ui/const-generics/const-expression-parameter.min.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/const-expression-parameter.rs:16:20 + --> $DIR/const-expression-parameter.rs:15:20 | LL | i32_identity::<1 + 2>(); | ^^^^^ diff --git a/src/test/ui/const-generics/const-expression-parameter.rs b/src/test/ui/const-generics/const-expression-parameter.rs index 3ef7c8b32e0..cb609a56416 100644 --- a/src/test/ui/const-generics/const-expression-parameter.rs +++ b/src/test/ui/const-generics/const-expression-parameter.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn i32_identity<const X: i32>() -> i32 { 5 diff --git a/src/test/ui/const-generics/const-fn-with-const-param.rs b/src/test/ui/const-generics/const-fn-with-const-param.rs index add1290b1d9..5c1ee4e0d5a 100644 --- a/src/test/ui/const-generics/const-fn-with-const-param.rs +++ b/src/test/ui/const-generics/const-fn-with-const-param.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] const fn const_u32_identity<const X: u32>() -> u32 { X diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.rs b/src/test/ui/const-generics/const-generic-array-wrapper.rs index 34edd0b4a8e..224fc794e32 100644 --- a/src/test/ui/const-generics/const-generic-array-wrapper.rs +++ b/src/test/ui/const-generics/const-generic-array-wrapper.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<T, const N: usize>([T; N]); diff --git a/src/test/ui/const-generics/const-generic-type_name.rs b/src/test/ui/const-generics/const-generic-type_name.rs index a954c026352..95632f79896 100644 --- a/src/test/ui/const-generics/const-generic-type_name.rs +++ b/src/test/ui/const-generics/const-generic-type_name.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(Debug)] struct S<const N: usize>; diff --git a/src/test/ui/const-generics/const-param-after-const-literal-arg.rs b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs index 3982f7a7f12..6c2b14f2770 100644 --- a/src/test/ui/const-generics/const-param-after-const-literal-arg.rs +++ b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<const A: usize, const B: usize>; diff --git a/src/test/ui/const-generics/const-param-before-other-params.full.stderr b/src/test/ui/const-generics/const-param-before-other-params.full.stderr index c2acaabbd88..09a4f66de39 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.full.stderr +++ b/src/test/ui/const-generics/const-param-before-other-params.full.stderr @@ -1,5 +1,5 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/const-param-before-other-params.rs:6:21 + --> $DIR/const-param-before-other-params.rs:5:21 | LL | fn bar<const X: (), 'a>(_: &'a ()) { | --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>` diff --git a/src/test/ui/const-generics/const-param-before-other-params.min.stderr b/src/test/ui/const-generics/const-param-before-other-params.min.stderr index 354c6d0615f..a9349ce43c9 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.min.stderr +++ b/src/test/ui/const-generics/const-param-before-other-params.min.stderr @@ -1,32 +1,32 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/const-param-before-other-params.rs:6:21 + --> $DIR/const-param-before-other-params.rs:5:21 | LL | fn bar<const X: (), 'a>(_: &'a ()) { | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>` error: type parameters must be declared prior to const parameters - --> $DIR/const-param-before-other-params.rs:11:21 + --> $DIR/const-param-before-other-params.rs:10:21 | LL | fn foo<const X: (), T>(_: &T) {} | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/const-param-before-other-params.rs:6:17 + --> $DIR/const-param-before-other-params.rs:5:17 | LL | fn bar<const X: (), 'a>(_: &'a ()) { | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/const-param-before-other-params.rs:11:17 + --> $DIR/const-param-before-other-params.rs:10:17 | LL | fn foo<const X: (), T>(_: &T) {} | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 4 previous errors diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs index f1be90cf2e4..508bb3e6a68 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.rs +++ b/src/test/ui/const-generics/const-param-before-other-params.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn bar<const X: (), 'a>(_: &'a ()) { //~^ ERROR lifetime parameters must be declared prior to const parameters diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr index aa29d61d917..119f932745b 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr +++ b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr @@ -1,29 +1,29 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:11:19 + --> $DIR/const-param-elided-lifetime.rs:10:19 | LL | struct A<const N: &u8>; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:16:15 + --> $DIR/const-param-elided-lifetime.rs:15:15 | LL | impl<const N: &u8> A<N> { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:19:21 + --> $DIR/const-param-elided-lifetime.rs:18:21 | LL | fn foo<const M: &u8>(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:24:15 + --> $DIR/const-param-elided-lifetime.rs:23:15 | LL | impl<const N: &u8> B for A<N> {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:28:17 + --> $DIR/const-param-elided-lifetime.rs:27:17 | LL | fn bar<const N: &u8>() {} | ^ explicit lifetime name needed here diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr index ed30182690a..48d33a785ae 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr +++ b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr @@ -1,77 +1,77 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:11:19 + --> $DIR/const-param-elided-lifetime.rs:10:19 | LL | struct A<const N: &u8>; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:16:15 + --> $DIR/const-param-elided-lifetime.rs:15:15 | LL | impl<const N: &u8> A<N> { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:19:21 + --> $DIR/const-param-elided-lifetime.rs:18:21 | LL | fn foo<const M: &u8>(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:24:15 + --> $DIR/const-param-elided-lifetime.rs:23:15 | LL | impl<const N: &u8> B for A<N> {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:28:17 + --> $DIR/const-param-elided-lifetime.rs:27:17 | LL | fn bar<const N: &u8>() {} | ^ explicit lifetime name needed here error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:11:19 + --> $DIR/const-param-elided-lifetime.rs:10:19 | LL | struct A<const N: &u8>; | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:16:15 + --> $DIR/const-param-elided-lifetime.rs:15:15 | LL | impl<const N: &u8> A<N> { | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:24:15 + --> $DIR/const-param-elided-lifetime.rs:23:15 | LL | impl<const N: &u8> B for A<N> {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:28:17 + --> $DIR/const-param-elided-lifetime.rs:27:17 | LL | fn bar<const N: &u8>() {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:19:21 + --> $DIR/const-param-elided-lifetime.rs:18:21 | LL | fn foo<const M: &u8>(&self) {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 10 previous errors diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.rs b/src/test/ui/const-generics/const-param-elided-lifetime.rs index 633e876f1d7..89715a7b8e9 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.rs +++ b/src/test/ui/const-generics/const-param-elided-lifetime.rs @@ -6,7 +6,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: &u8>; //~^ ERROR `&` without an explicit lifetime name cannot be used here diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr b/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr index 5a126f5c3c6..c2ec7359c9f 100644 --- a/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr +++ b/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer function - --> $DIR/const-param-from-outer-fn.rs:9:9 + --> $DIR/const-param-from-outer-fn.rs:8:9 | LL | fn foo<const X: u32>() { | - const parameter from outer function diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr b/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr index 5a126f5c3c6..c2ec7359c9f 100644 --- a/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr +++ b/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer function - --> $DIR/const-param-from-outer-fn.rs:9:9 + --> $DIR/const-param-from-outer-fn.rs:8:9 | LL | fn foo<const X: u32>() { | - const parameter from outer function diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.rs b/src/test/ui/const-generics/const-param-from-outer-fn.rs index e1376c6e108..27b9ca9c291 100644 --- a/src/test/ui/const-generics/const-param-from-outer-fn.rs +++ b/src/test/ui/const-generics/const-param-from-outer-fn.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const X: u32>() { fn bar() -> u32 { diff --git a/src/test/ui/const-generics/const-param-hygiene.rs b/src/test/ui/const-generics/const-param-hygiene.rs index c8cefc36732..9cafb05fbcb 100644 --- a/src/test/ui/const-generics/const-param-hygiene.rs +++ b/src/test/ui/const-generics/const-param-hygiene.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] macro_rules! bar { ($($t:tt)*) => { impl<const N: usize> $($t)* }; diff --git a/src/test/ui/const-generics/const-param-in-async.rs b/src/test/ui/const-generics/const-param-in-async.rs index e8601985287..9dc9c80241d 100644 --- a/src/test/ui/const-generics/const-param-in-async.rs +++ b/src/test/ui/const-generics/const-param-in-async.rs @@ -3,7 +3,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] async fn foo<const N: usize>(arg: [u8; N]) -> usize { arg.len() } diff --git a/src/test/ui/const-generics/const-param-in-trait-ungated.rs b/src/test/ui/const-generics/const-param-in-trait-ungated.rs deleted file mode 100644 index 8a81bcc1a80..00000000000 --- a/src/test/ui/const-generics/const-param-in-trait-ungated.rs +++ /dev/null @@ -1,3 +0,0 @@ -trait Trait<const T: ()> {} //~ ERROR const generics are unstable - -fn main() {} diff --git a/src/test/ui/const-generics/const-param-in-trait-ungated.stderr b/src/test/ui/const-generics/const-param-in-trait-ungated.stderr deleted file mode 100644 index d53a4ac2d4c..00000000000 --- a/src/test/ui/const-generics/const-param-in-trait-ungated.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: const generics are unstable - --> $DIR/const-param-in-trait-ungated.rs:1:19 - | -LL | trait Trait<const T: ()> {} - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/const-param-in-trait.rs b/src/test/ui/const-generics/const-param-in-trait.rs index 9d31162c1c6..79b3ae2037e 100644 --- a/src/test/ui/const-generics/const-param-in-trait.rs +++ b/src/test/ui/const-generics/const-param-in-trait.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Trait<const T: u8> {} diff --git a/src/test/ui/const-generics/const-param-shadowing.rs b/src/test/ui/const-generics/const-param-shadowing.rs index 8440e47968e..ddd15dbc41b 100644 --- a/src/test/ui/const-generics/const-param-shadowing.rs +++ b/src/test/ui/const-generics/const-param-shadowing.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - type N = u32; struct Foo<const M: usize>; fn test<const N: usize>() -> Foo<N> { //~ ERROR type provided when diff --git a/src/test/ui/const-generics/const-param-shadowing.stderr b/src/test/ui/const-generics/const-param-shadowing.stderr index df170278026..7447ca3ff36 100644 --- a/src/test/ui/const-generics/const-param-shadowing.stderr +++ b/src/test/ui/const-generics/const-param-shadowing.stderr @@ -1,5 +1,5 @@ error[E0747]: type provided when a constant was expected - --> $DIR/const-param-shadowing.rs:5:34 + --> $DIR/const-param-shadowing.rs:3:34 | LL | fn test<const N: usize>() -> Foo<N> { | ^ diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.full.stderr b/src/test/ui/const-generics/const-param-type-depends-on-const-param.full.stderr index f7ad579dbca..f639e276f46 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.full.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-const-param.rs:12:52 + --> $DIR/const-param-type-depends-on-const-param.rs:11:52 | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-const-param.rs:16:40 + --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index 6b7a218ada5..9804363f39a 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -1,32 +1,32 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-const-param.rs:12:52 + --> $DIR/const-param-type-depends-on-const-param.rs:11:52 | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-const-param.rs:16:40 + --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/const-param-type-depends-on-const-param.rs:12:47 + --> $DIR/const-param-type-depends-on-const-param.rs:11:47 | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/const-param-type-depends-on-const-param.rs:16:35 + --> $DIR/const-param-type-depends-on-const-param.rs:15:35 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 4 previous errors diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs index 29371eeb21d..62b146e016a 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs +++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // Currently, const parameters cannot depend on other generic parameters, // as our current implementation can't really support this. diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs index ea75a3d0403..781f50e6173 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; -struct B<T, const N: T>(PhantomData<[T; N]>); //~ ERROR const generics are unstable +struct B<T, const N: T>(PhantomData<[T; N]>); //~^ ERROR the type of const parameters must not depend on other generic parameters fn main() {} diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr index 5d379ff083c..8e14defd65d 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr @@ -4,16 +4,6 @@ error[E0770]: the type of const parameters must not depend on other generic para LL | struct B<T, const N: T>(PhantomData<[T; N]>); | ^ the type must not depend on the parameter `T` -error[E0658]: const generics are unstable - --> $DIR/const-param-type-depends-on-type-param-ungated.rs:6:19 - | -LL | struct B<T, const N: T>(PhantomData<[T; N]>); - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0658, E0770. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index f860788e778..a83ee627187 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-type-param.rs:12:34 + --> $DIR/const-param-type-depends-on-type-param.rs:11:34 | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` error[E0392]: parameter `T` is never used - --> $DIR/const-param-type-depends-on-type-param.rs:12:22 + --> $DIR/const-param-type-depends-on-type-param.rs:11:22 | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ unused parameter diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index f860788e778..a83ee627187 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/const-param-type-depends-on-type-param.rs:12:34 + --> $DIR/const-param-type-depends-on-type-param.rs:11:34 | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` error[E0392]: parameter `T` is never used - --> $DIR/const-param-type-depends-on-type-param.rs:12:22 + --> $DIR/const-param-type-depends-on-type-param.rs:11:22 | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ unused parameter diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs index 93ae1117512..910a9643502 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // Currently, const parameters cannot depend on other generic parameters, // as our current implementation can't really support this. diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr b/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr index 0f4f007f9d2..923964a4070 100644 --- a/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr +++ b/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr @@ -1,11 +1,11 @@ error: const parameter `x` should have an upper case name - --> $DIR/const-parameter-uppercase-lint.rs:9:15 + --> $DIR/const-parameter-uppercase-lint.rs:8:15 | LL | fn noop<const x: u32>() { | ^ help: convert the identifier to upper case (notice the capitalization): `X` | note: the lint level is defined here - --> $DIR/const-parameter-uppercase-lint.rs:7:9 + --> $DIR/const-parameter-uppercase-lint.rs:6:9 | LL | #![deny(non_upper_case_globals)] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr b/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr index 0f4f007f9d2..923964a4070 100644 --- a/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr +++ b/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr @@ -1,11 +1,11 @@ error: const parameter `x` should have an upper case name - --> $DIR/const-parameter-uppercase-lint.rs:9:15 + --> $DIR/const-parameter-uppercase-lint.rs:8:15 | LL | fn noop<const x: u32>() { | ^ help: convert the identifier to upper case (notice the capitalization): `X` | note: the lint level is defined here - --> $DIR/const-parameter-uppercase-lint.rs:7:9 + --> $DIR/const-parameter-uppercase-lint.rs:6:9 | LL | #![deny(non_upper_case_globals)] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.rs b/src/test/ui/const-generics/const-parameter-uppercase-lint.rs index b9bd6666af3..5d97907c2e7 100644 --- a/src/test/ui/const-generics/const-parameter-uppercase-lint.rs +++ b/src/test/ui/const-generics/const-parameter-uppercase-lint.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![deny(non_upper_case_globals)] diff --git a/src/test/ui/const-generics/const-types.rs b/src/test/ui/const-generics/const-types.rs index cd34cfc0478..fb150f892ed 100644 --- a/src/test/ui/const-generics/const-types.rs +++ b/src/test/ui/const-generics/const-types.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code, unused_variables)] diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr index b2816367ea1..d6a54ead131 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/feature-gate-const_evaluatable_checked.rs:9:30 + --> $DIR/feature-gate-const_evaluatable_checked.rs:8:30 | LL | fn test<const N: usize>() -> Arr<N> where Arr<N>: Default { | ^^^^^^ diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr index 573bc66b7c7..7de4bfcdd05 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/feature-gate-const_evaluatable_checked.rs:6:33 + --> $DIR/feature-gate-const_evaluatable_checked.rs:5:33 | LL | type Arr<const N: usize> = [u8; N - 1]; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs index 9746adab29b..f49ca0251aa 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] type Arr<const N: usize> = [u8; N - 1]; //[min]~^ ERROR generic parameters may not be used in const operations diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr index d476a7eb645..9f3d94bbd8a 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/simple.rs:8:53 + --> $DIR/simple.rs:7:53 | LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default { | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default { = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/simple.rs:8:35 + --> $DIR/simple.rs:7:35 | LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default { | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple.rs index dcf0071cb29..94ad71b6c1a 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.rs @@ -1,7 +1,6 @@ // [full] run-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] #![feature(const_evaluatable_checked)] #![allow(incomplete_features)] diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr index f95d6d2d570..c8549f101da 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/simple_fail.rs:7:33 + --> $DIR/simple_fail.rs:6:33 | LL | type Arr<const N: usize> = [u8; N - 1]; | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr index bd81e0bc5a8..df54b4cbca5 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/simple_fail.rs:7:33 + --> $DIR/simple_fail.rs:6:33 | LL | type Arr<const N: usize> = [u8; N - 1]; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs index 5e2c080927f..3cbc077f4f1 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs @@ -1,6 +1,5 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] #![feature(const_evaluatable_checked)] #![allow(incomplete_features)] diff --git a/src/test/ui/const-generics/core-types.rs b/src/test/ui/const-generics/core-types.rs index c4351e059de..b6fa478f48d 100644 --- a/src/test/ui/const-generics/core-types.rs +++ b/src/test/ui/const-generics/core-types.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: u8>; struct B<const N: u16>; diff --git a/src/test/ui/const-generics/cross_crate_complex.rs b/src/test/ui/const-generics/cross_crate_complex.rs index 30749b8bc6d..1d495c9562d 100644 --- a/src/test/ui/const-generics/cross_crate_complex.rs +++ b/src/test/ui/const-generics/cross_crate_complex.rs @@ -5,7 +5,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] extern crate crayte; use crayte::*; diff --git a/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr b/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr index 0574ddfb255..8e8d26a0004 100644 --- a/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr +++ b/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr @@ -1,8 +1,8 @@ error: type parameters must be declared prior to const parameters - --> $DIR/complex-unord-param.rs:9:41 + --> $DIR/complex-unord-param.rs:8:41 | LL | struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> { - | ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a, const N: usize, const M: usize>` + | ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a = u32, const N: usize, const M: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/complex-unord-param.rs b/src/test/ui/const-generics/defaults/complex-unord-param.rs index e83a96388c1..82b3627d22f 100644 --- a/src/test/ui/const-generics/defaults/complex-unord-param.rs +++ b/src/test/ui/const-generics/defaults/complex-unord-param.rs @@ -3,7 +3,6 @@ // Checks a complicated usage of unordered params #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code)] struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> { diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr index 9cc3e9c0da6..c4a666a829d 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr @@ -1,14 +1,14 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/intermixed-lifetime.rs:7:28 + --> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` + | -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` error: lifetime parameters must be declared prior to type parameters - --> $DIR/intermixed-lifetime.rs:11:37 + --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` + | --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr index 4d80fdb5bcb..69a490978d1 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr @@ -1,26 +1,26 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/intermixed-lifetime.rs:7:28 + --> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: type parameters must be declared prior to const parameters - --> $DIR/intermixed-lifetime.rs:7:32 + --> $DIR/intermixed-lifetime.rs:6:32 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: lifetime parameters must be declared prior to const parameters - --> $DIR/intermixed-lifetime.rs:11:37 + --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: type parameters must be declared prior to const parameters - --> $DIR/intermixed-lifetime.rs:11:28 + --> $DIR/intermixed-lifetime.rs:10:28 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: aborting due to 4 previous errors diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs index cc0d1c6c0c9..9e83bf92a59 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs @@ -2,7 +2,6 @@ // Checks that lifetimes cannot be interspersed between consts and types. #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<const N: usize, 'a, T = u32>(&'a (), T); //~^ Error lifetime parameters must be declared prior to const parameters diff --git a/src/test/ui/const-generics/defaults/needs-feature.min.stderr b/src/test/ui/const-generics/defaults/needs-feature.min.stderr index 7058327fdce..a4006203e4a 100644 --- a/src/test/ui/const-generics/defaults/needs-feature.min.stderr +++ b/src/test/ui/const-generics/defaults/needs-feature.min.stderr @@ -1,8 +1,8 @@ error: type parameters must be declared prior to const parameters - --> $DIR/needs-feature.rs:10:26 + --> $DIR/needs-feature.rs:9:26 | LL | struct A<const N: usize, T=u32>(T); - | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` + | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/needs-feature.none.stderr b/src/test/ui/const-generics/defaults/needs-feature.none.stderr index 3b6f63a8efe..a4006203e4a 100644 --- a/src/test/ui/const-generics/defaults/needs-feature.none.stderr +++ b/src/test/ui/const-generics/defaults/needs-feature.none.stderr @@ -1,18 +1,8 @@ error: type parameters must be declared prior to const parameters - --> $DIR/needs-feature.rs:10:26 + --> $DIR/needs-feature.rs:9:26 | LL | struct A<const N: usize, T=u32>(T); - | -----------------^----- help: reorder the parameters: lifetimes, then types: `<T, const N: usize>` + | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>` -error[E0658]: const generics are unstable - --> $DIR/needs-feature.rs:10:16 - | -LL | struct A<const N: usize, T=u32>(T); - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/defaults/needs-feature.rs b/src/test/ui/const-generics/defaults/needs-feature.rs index ec02dbf407d..7eb7764a644 100644 --- a/src/test/ui/const-generics/defaults/needs-feature.rs +++ b/src/test/ui/const-generics/defaults/needs-feature.rs @@ -1,16 +1,13 @@ //[full] run-pass // Verifies that having generic parameters after constants is not permitted without the // `const_generics` feature. -// revisions: none min full +// revisions: min full #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize, T=u32>(T); -//[none]~^ ERROR type parameters must be declared prior -//[none]~| ERROR const generics are unstable -//[min]~^^^ ERROR type parameters must be declared prior +//[min]~^ ERROR type parameters must be declared prior fn main() { let _: A<3> = A(0); diff --git a/src/test/ui/const-generics/defaults/simple-defaults.min.stderr b/src/test/ui/const-generics/defaults/simple-defaults.min.stderr index 59cc6f28af8..0746c64ac8c 100644 --- a/src/test/ui/const-generics/defaults/simple-defaults.min.stderr +++ b/src/test/ui/const-generics/defaults/simple-defaults.min.stderr @@ -1,8 +1,8 @@ error: type parameters must be declared prior to const parameters - --> $DIR/simple-defaults.rs:9:40 + --> $DIR/simple-defaults.rs:8:40 | LL | struct FixedOutput<'a, const N: usize, T=u32> { - | ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/simple-defaults.rs b/src/test/ui/const-generics/defaults/simple-defaults.rs index 78abe351998..1f1b6c2260d 100644 --- a/src/test/ui/const-generics/defaults/simple-defaults.rs +++ b/src/test/ui/const-generics/defaults/simple-defaults.rs @@ -3,7 +3,6 @@ // Checks some basic test cases for defaults. #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code)] struct FixedOutput<'a, const N: usize, T=u32> { diff --git a/src/test/ui/const-generics/defaults/wrong-order.full.stderr b/src/test/ui/const-generics/defaults/wrong-order.full.stderr index 99f46309bf6..96deb4a8b5a 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.full.stderr +++ b/src/test/ui/const-generics/defaults/wrong-order.full.stderr @@ -1,5 +1,5 @@ error: type parameters with a default must be trailing - --> $DIR/wrong-order.rs:5:10 + --> $DIR/wrong-order.rs:4:10 | LL | struct A<T = u32, const N: usize> { | ^ @@ -14,7 +14,6 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/defaults/wrong-order.min.stderr b/src/test/ui/const-generics/defaults/wrong-order.min.stderr index 29a46367004..b19da76f415 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.min.stderr +++ b/src/test/ui/const-generics/defaults/wrong-order.min.stderr @@ -1,5 +1,5 @@ error: type parameters with a default must be trailing - --> $DIR/wrong-order.rs:5:10 + --> $DIR/wrong-order.rs:4:10 | LL | struct A<T = u32, const N: usize> { | ^ diff --git a/src/test/ui/const-generics/defaults/wrong-order.rs b/src/test/ui/const-generics/defaults/wrong-order.rs index cb36d456f38..4f1c05011b0 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.rs +++ b/src/test/ui/const-generics/defaults/wrong-order.rs @@ -1,6 +1,5 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] struct A<T = u32, const N: usize> { //~^ ERROR type parameters with a default must be trailing diff --git a/src/test/ui/const-generics/derive-debug-array-wrapper.rs b/src/test/ui/const-generics/derive-debug-array-wrapper.rs index 13fd87f1e3e..ce1481d97e9 100644 --- a/src/test/ui/const-generics/derive-debug-array-wrapper.rs +++ b/src/test/ui/const-generics/derive-debug-array-wrapper.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(Debug)] struct X<const N: usize> { diff --git a/src/test/ui/const-generics/different_byref.full.stderr b/src/test/ui/const-generics/different_byref.full.stderr index 4463ed7fcdd..d6b32323e2d 100644 --- a/src/test/ui/const-generics/different_byref.full.stderr +++ b/src/test/ui/const-generics/different_byref.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/different_byref.rs:13:9 + --> $DIR/different_byref.rs:12:9 | LL | x = Const::<{ [4] }> {}; | ^^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize` diff --git a/src/test/ui/const-generics/different_byref.min.stderr b/src/test/ui/const-generics/different_byref.min.stderr index e5b393ffe99..93874fb1f5f 100644 --- a/src/test/ui/const-generics/different_byref.min.stderr +++ b/src/test/ui/const-generics/different_byref.min.stderr @@ -1,11 +1,11 @@ error: `[usize; 1]` is forbidden as the type of a const generic parameter - --> $DIR/different_byref.rs:8:23 + --> $DIR/different_byref.rs:7:23 | LL | struct Const<const V: [usize; 1]> {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/different_byref.rs b/src/test/ui/const-generics/different_byref.rs index cd3960eeb8e..7977560ecbc 100644 --- a/src/test/ui/const-generics/different_byref.rs +++ b/src/test/ui/const-generics/different_byref.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Const<const V: [usize; 1]> {} //[min]~^ ERROR `[usize; 1]` is forbidden diff --git a/src/test/ui/const-generics/different_byref_simple.full.stderr b/src/test/ui/const-generics/different_byref_simple.full.stderr index b6729c852ab..027e282c398 100644 --- a/src/test/ui/const-generics/different_byref_simple.full.stderr +++ b/src/test/ui/const-generics/different_byref_simple.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/different_byref_simple.rs:12:9 + --> $DIR/different_byref_simple.rs:11:9 | LL | u = ConstUsize::<4> {}; | ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize` diff --git a/src/test/ui/const-generics/different_byref_simple.min.stderr b/src/test/ui/const-generics/different_byref_simple.min.stderr index b6729c852ab..027e282c398 100644 --- a/src/test/ui/const-generics/different_byref_simple.min.stderr +++ b/src/test/ui/const-generics/different_byref_simple.min.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/different_byref_simple.rs:12:9 + --> $DIR/different_byref_simple.rs:11:9 | LL | u = ConstUsize::<4> {}; | ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize` diff --git a/src/test/ui/const-generics/different_byref_simple.rs b/src/test/ui/const-generics/different_byref_simple.rs index 93289f93331..b48189fc2cb 100644 --- a/src/test/ui/const-generics/different_byref_simple.rs +++ b/src/test/ui/const-generics/different_byref_simple.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct ConstUsize<const V: usize> {} diff --git a/src/test/ui/const-generics/dyn-supertraits.rs b/src/test/ui/const-generics/dyn-supertraits.rs index 0295255d809..73ed23521c3 100644 --- a/src/test/ui/const-generics/dyn-supertraits.rs +++ b/src/test/ui/const-generics/dyn-supertraits.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Foo<const N: usize> { fn myfun(&self) -> usize; diff --git a/src/test/ui/const-generics/exhaustive-value.full.stderr b/src/test/ui/const-generics/exhaustive-value.full.stderr index fdea1fb0c3e..e0e1423ba01 100644 --- a/src/test/ui/const-generics/exhaustive-value.full.stderr +++ b/src/test/ui/const-generics/exhaustive-value.full.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Foo<N>` is not satisfied - --> $DIR/exhaustive-value.rs:267:5 + --> $DIR/exhaustive-value.rs:266:5 | LL | fn test() {} | --------- required by `Foo::test` diff --git a/src/test/ui/const-generics/exhaustive-value.min.stderr b/src/test/ui/const-generics/exhaustive-value.min.stderr index fdea1fb0c3e..e0e1423ba01 100644 --- a/src/test/ui/const-generics/exhaustive-value.min.stderr +++ b/src/test/ui/const-generics/exhaustive-value.min.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Foo<N>` is not satisfied - --> $DIR/exhaustive-value.rs:267:5 + --> $DIR/exhaustive-value.rs:266:5 | LL | fn test() {} | --------- required by `Foo::test` diff --git a/src/test/ui/const-generics/exhaustive-value.rs b/src/test/ui/const-generics/exhaustive-value.rs index fce036b0da6..921f9a46707 100644 --- a/src/test/ui/const-generics/exhaustive-value.rs +++ b/src/test/ui/const-generics/exhaustive-value.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Foo<const N: u8> { fn test() {} diff --git a/src/test/ui/const-generics/fn-const-param-call.full.stderr b/src/test/ui/const-generics/fn-const-param-call.full.stderr index f1bd8def9ff..d984449e6ca 100644 --- a/src/test/ui/const-generics/fn-const-param-call.full.stderr +++ b/src/test/ui/const-generics/fn-const-param-call.full.stderr @@ -1,11 +1,11 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-call.rs:12:25 + --> $DIR/fn-const-param-call.rs:11:25 | LL | struct Wrapper<const F: fn() -> u32>; | ^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-call.rs:14:15 + --> $DIR/fn-const-param-call.rs:13:15 | LL | impl<const F: fn() -> u32> Wrapper<F> { | ^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/fn-const-param-call.min.stderr b/src/test/ui/const-generics/fn-const-param-call.min.stderr index f1bd8def9ff..d984449e6ca 100644 --- a/src/test/ui/const-generics/fn-const-param-call.min.stderr +++ b/src/test/ui/const-generics/fn-const-param-call.min.stderr @@ -1,11 +1,11 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-call.rs:12:25 + --> $DIR/fn-const-param-call.rs:11:25 | LL | struct Wrapper<const F: fn() -> u32>; | ^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-call.rs:14:15 + --> $DIR/fn-const-param-call.rs:13:15 | LL | impl<const F: fn() -> u32> Wrapper<F> { | ^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/fn-const-param-call.rs b/src/test/ui/const-generics/fn-const-param-call.rs index bba6c1f7a16..70a104e2222 100644 --- a/src/test/ui/const-generics/fn-const-param-call.rs +++ b/src/test/ui/const-generics/fn-const-param-call.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn function() -> u32 { 17 diff --git a/src/test/ui/const-generics/fn-const-param-infer.full.stderr b/src/test/ui/const-generics/fn-const-param-infer.full.stderr index 4bdc9b89af6..f0767a10994 100644 --- a/src/test/ui/const-generics/fn-const-param-infer.full.stderr +++ b/src/test/ui/const-generics/fn-const-param-infer.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-infer.rs:7:25 + --> $DIR/fn-const-param-infer.rs:6:25 | LL | struct Checked<const F: fn(usize) -> bool>; | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/fn-const-param-infer.min.stderr b/src/test/ui/const-generics/fn-const-param-infer.min.stderr index 4bdc9b89af6..f0767a10994 100644 --- a/src/test/ui/const-generics/fn-const-param-infer.min.stderr +++ b/src/test/ui/const-generics/fn-const-param-infer.min.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/fn-const-param-infer.rs:7:25 + --> $DIR/fn-const-param-infer.rs:6:25 | LL | struct Checked<const F: fn(usize) -> bool>; | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/fn-const-param-infer.rs b/src/test/ui/const-generics/fn-const-param-infer.rs index 3ed75e7b00d..d090479d4c3 100644 --- a/src/test/ui/const-generics/fn-const-param-infer.rs +++ b/src/test/ui/const-generics/fn-const-param-infer.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Checked<const F: fn(usize) -> bool>; //~^ ERROR: using function pointers as const generic parameters diff --git a/src/test/ui/const-generics/fn-taking-const-generic-array.rs b/src/test/ui/const-generics/fn-taking-const-generic-array.rs index 950684aaa8d..58c1b95893e 100644 --- a/src/test/ui/const-generics/fn-taking-const-generic-array.rs +++ b/src/test/ui/const-generics/fn-taking-const-generic-array.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::fmt::Display; diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr b/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr index adcaa759963..5c0f17537fa 100644 --- a/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr +++ b/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr @@ -1,5 +1,5 @@ error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/forbid-non-structural_match-types.rs:15:19 + --> $DIR/forbid-non-structural_match-types.rs:14:19 | LL | struct D<const X: C>; | ^ `C` doesn't derive both `PartialEq` and `Eq` diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr b/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr index 014200178b9..80eac994d55 100644 --- a/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr +++ b/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr @@ -1,23 +1,23 @@ error: `A` is forbidden as the type of a const generic parameter - --> $DIR/forbid-non-structural_match-types.rs:10:19 + --> $DIR/forbid-non-structural_match-types.rs:9:19 | LL | struct B<const X: A>; // ok | ^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `C` is forbidden as the type of a const generic parameter - --> $DIR/forbid-non-structural_match-types.rs:15:19 + --> $DIR/forbid-non-structural_match-types.rs:14:19 | LL | struct D<const X: C>; | ^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/forbid-non-structural_match-types.rs:15:19 + --> $DIR/forbid-non-structural_match-types.rs:14:19 | LL | struct D<const X: C>; | ^ `C` doesn't derive both `PartialEq` and `Eq` diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.rs b/src/test/ui/const-generics/forbid-non-structural_match-types.rs index e7356d485db..0fdb3ed4a5a 100644 --- a/src/test/ui/const-generics/forbid-non-structural_match-types.rs +++ b/src/test/ui/const-generics/forbid-non-structural_match-types.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(PartialEq, Eq)] struct A; diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr b/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr index 0ac51e8c9e6..b827e482977 100644 --- a/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr +++ b/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr @@ -1,5 +1,5 @@ error[E0044]: foreign items may not have const parameters - --> $DIR/foreign-item-const-parameter.rs:8:5 + --> $DIR/foreign-item-const-parameter.rs:7:5 | LL | fn foo<const X: usize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters @@ -7,7 +7,7 @@ LL | fn foo<const X: usize>(); = help: replace the const parameters with concrete consts error[E0044]: foreign items may not have type or const parameters - --> $DIR/foreign-item-const-parameter.rs:10:5 + --> $DIR/foreign-item-const-parameter.rs:9:5 | LL | fn bar<T, const X: usize>(_: T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr b/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr index 0ac51e8c9e6..b827e482977 100644 --- a/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr +++ b/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr @@ -1,5 +1,5 @@ error[E0044]: foreign items may not have const parameters - --> $DIR/foreign-item-const-parameter.rs:8:5 + --> $DIR/foreign-item-const-parameter.rs:7:5 | LL | fn foo<const X: usize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters @@ -7,7 +7,7 @@ LL | fn foo<const X: usize>(); = help: replace the const parameters with concrete consts error[E0044]: foreign items may not have type or const parameters - --> $DIR/foreign-item-const-parameter.rs:10:5 + --> $DIR/foreign-item-const-parameter.rs:9:5 | LL | fn bar<T, const X: usize>(_: T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.rs b/src/test/ui/const-generics/foreign-item-const-parameter.rs index 44b6d0332c3..83caa89f033 100644 --- a/src/test/ui/const-generics/foreign-item-const-parameter.rs +++ b/src/test/ui/const-generics/foreign-item-const-parameter.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] extern "C" { fn foo<const X: usize>(); //~ ERROR foreign items may not have const parameters diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr b/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr index 43b42d82d0c..2d19a58a145 100644 --- a/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr +++ b/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/generic-function-call-in-array-length.rs:9:29 + --> $DIR/generic-function-call-in-array-length.rs:8:29 | LL | fn bar<const N: usize>() -> [u32; foo(N)] { | ^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr b/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr index 526f98fe8cd..d7a3f04a8da 100644 --- a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr +++ b/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/generic-function-call-in-array-length.rs:9:39 + --> $DIR/generic-function-call-in-array-length.rs:8:39 | LL | fn bar<const N: usize>() -> [u32; foo(N)] { | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | fn bar<const N: usize>() -> [u32; foo(N)] { = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/generic-function-call-in-array-length.rs:12:13 + --> $DIR/generic-function-call-in-array-length.rs:11:13 | LL | [0; foo(N)] | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/generic-function-call-in-array-length.rs index c838070dc95..a6d2bbd17ea 100644 --- a/src/test/ui/const-generics/generic-function-call-in-array-length.rs +++ b/src/test/ui/const-generics/generic-function-call-in-array-length.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] const fn foo(n: usize) -> usize { n * 2 } diff --git a/src/test/ui/const-generics/generic-param-mismatch.full.stderr b/src/test/ui/const-generics/generic-param-mismatch.full.stderr index 6befa9d1f69..aff8780fb0d 100644 --- a/src/test/ui/const-generics/generic-param-mismatch.full.stderr +++ b/src/test/ui/const-generics/generic-param-mismatch.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/generic-param-mismatch.rs:7:5 + --> $DIR/generic-param-mismatch.rs:6:5 | LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type diff --git a/src/test/ui/const-generics/generic-param-mismatch.min.stderr b/src/test/ui/const-generics/generic-param-mismatch.min.stderr index 6befa9d1f69..aff8780fb0d 100644 --- a/src/test/ui/const-generics/generic-param-mismatch.min.stderr +++ b/src/test/ui/const-generics/generic-param-mismatch.min.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/generic-param-mismatch.rs:7:5 + --> $DIR/generic-param-mismatch.rs:6:5 | LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type diff --git a/src/test/ui/const-generics/generic-param-mismatch.rs b/src/test/ui/const-generics/generic-param-mismatch.rs index e409094eb73..22fffe47dcc 100644 --- a/src/test/ui/const-generics/generic-param-mismatch.rs +++ b/src/test/ui/const-generics/generic-param-mismatch.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] fn test<const N: usize, const M: usize>() -> [u8; M] { [0; N] //~ ERROR mismatched types diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr index d311e1c0bae..c13882e7fe1 100644 --- a/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr +++ b/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/generic-sum-in-array-length.rs:7:45 + --> $DIR/generic-sum-in-array-length.rs:6:45 | LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr index e531b612b56..cff5a62193c 100644 --- a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr +++ b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/generic-sum-in-array-length.rs:7:53 + --> $DIR/generic-sum-in-array-length.rs:6:53 | LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} | ^ cannot perform const operation using `A` @@ -8,7 +8,7 @@ LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/generic-sum-in-array-length.rs:7:57 + --> $DIR/generic-sum-in-array-length.rs:6:57 | LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} | ^ cannot perform const operation using `B` diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.rs b/src/test/ui/const-generics/generic-sum-in-array-length.rs index 84ddfe055dc..7ee0394ba14 100644 --- a/src/test/ui/const-generics/generic-sum-in-array-length.rs +++ b/src/test/ui/const-generics/generic-sum-in-array-length.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} //[min]~^ ERROR generic parameters may not be used in const operations diff --git a/src/test/ui/const-generics/impl-const-generic-struct.rs b/src/test/ui/const-generics/impl-const-generic-struct.rs index 05cabc46baa..1aa22698b64 100644 --- a/src/test/ui/const-generics/impl-const-generic-struct.rs +++ b/src/test/ui/const-generics/impl-const-generic-struct.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct S<const X: u32>; diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr index a587cb61873..26b965901a4 100644 --- a/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr @@ -1,5 +1,5 @@ error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position - --> $DIR/impl-trait-with-const-arguments.rs:24:20 + --> $DIR/impl-trait-with-const-arguments.rs:23:20 | LL | assert_eq!(f::<4usize>(Usizable), 20usize); | ^^^^^^ explicit generic argument not allowed diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr index a587cb61873..26b965901a4 100644 --- a/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr @@ -1,5 +1,5 @@ error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position - --> $DIR/impl-trait-with-const-arguments.rs:24:20 + --> $DIR/impl-trait-with-const-arguments.rs:23:20 | LL | assert_eq!(f::<4usize>(Usizable), 20usize); | ^^^^^^ explicit generic argument not allowed diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.rs b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs index a4c75792ee3..2e6e49b9c0a 100644 --- a/src/test/ui/const-generics/impl-trait-with-const-arguments.rs +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] trait Usizer { fn m(self) -> usize; diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr b/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr index 6b902e2d658..9c8359b08a5 100644 --- a/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr +++ b/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr @@ -1,11 +1,11 @@ error[E0107]: wrong number of const arguments: expected 2, found 1 - --> $DIR/incorrect-number-of-const-args.rs:12:5 + --> $DIR/incorrect-number-of-const-args.rs:11:5 | LL | foo::<0>(); | ^^^^^^^^ expected 2 const arguments error[E0107]: wrong number of const arguments: expected 2, found 3 - --> $DIR/incorrect-number-of-const-args.rs:13:17 + --> $DIR/incorrect-number-of-const-args.rs:12:17 | LL | foo::<0, 0, 0>(); | ^ unexpected const argument diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr b/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr index 6b902e2d658..9c8359b08a5 100644 --- a/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr +++ b/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr @@ -1,11 +1,11 @@ error[E0107]: wrong number of const arguments: expected 2, found 1 - --> $DIR/incorrect-number-of-const-args.rs:12:5 + --> $DIR/incorrect-number-of-const-args.rs:11:5 | LL | foo::<0>(); | ^^^^^^^^ expected 2 const arguments error[E0107]: wrong number of const arguments: expected 2, found 3 - --> $DIR/incorrect-number-of-const-args.rs:13:17 + --> $DIR/incorrect-number-of-const-args.rs:12:17 | LL | foo::<0, 0, 0>(); | ^ unexpected const argument diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.rs b/src/test/ui/const-generics/incorrect-number-of-const-args.rs index f7bdf761f7d..3c4290df056 100644 --- a/src/test/ui/const-generics/incorrect-number-of-const-args.rs +++ b/src/test/ui/const-generics/incorrect-number-of-const-args.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const X: usize, const Y: usize>() -> usize { 0 diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr index 05bf67a5ff7..e85bf8829ae 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/cannot-infer-const-args.rs:12:5 + --> $DIR/cannot-infer-const-args.rs:11:5 | LL | foo(); | ^^^ cannot infer the value of const parameter `X` declared on the function `foo` diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr index 05bf67a5ff7..e85bf8829ae 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/cannot-infer-const-args.rs:12:5 + --> $DIR/cannot-infer-const-args.rs:11:5 | LL | foo(); | ^^^ cannot infer the value of const parameter `X` declared on the function `foo` diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.rs b/src/test/ui/const-generics/infer/cannot-infer-const-args.rs index 2d74b4788bf..cc52892bd04 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.rs +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const X: usize>() -> usize { 0 diff --git a/src/test/ui/const-generics/infer/issue-77092.rs b/src/test/ui/const-generics/infer/issue-77092.rs index 9a1dd1a8258..fcf7d3282b4 100644 --- a/src/test/ui/const-generics/infer/issue-77092.rs +++ b/src/test/ui/const-generics/infer/issue-77092.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - use std::convert::TryInto; fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] { diff --git a/src/test/ui/const-generics/infer/issue-77092.stderr b/src/test/ui/const-generics/infer/issue-77092.stderr index 99894173bc8..5857a421198 100644 --- a/src/test/ui/const-generics/infer/issue-77092.stderr +++ b/src/test/ui/const-generics/infer/issue-77092.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/issue-77092.rs:13:26 + --> $DIR/issue-77092.rs:11:26 | LL | println!("{:?}", take_array_from_mut(&mut arr, i)); | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `take_array_from_mut` diff --git a/src/test/ui/const-generics/infer/method-chain.full.stderr b/src/test/ui/const-generics/infer/method-chain.full.stderr index 7aa3bd44df8..f6d9c4a2645 100644 --- a/src/test/ui/const-generics/infer/method-chain.full.stderr +++ b/src/test/ui/const-generics/infer/method-chain.full.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/method-chain.rs:21:33 + --> $DIR/method-chain.rs:20:33 | LL | Foo.bar().bar().bar().bar().baz(); | ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz` diff --git a/src/test/ui/const-generics/infer/method-chain.min.stderr b/src/test/ui/const-generics/infer/method-chain.min.stderr index 7aa3bd44df8..f6d9c4a2645 100644 --- a/src/test/ui/const-generics/infer/method-chain.min.stderr +++ b/src/test/ui/const-generics/infer/method-chain.min.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/method-chain.rs:21:33 + --> $DIR/method-chain.rs:20:33 | LL | Foo.bar().bar().bar().bar().baz(); | ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz` diff --git a/src/test/ui/const-generics/infer/method-chain.rs b/src/test/ui/const-generics/infer/method-chain.rs index 9389ca20d10..8ac6a7d6267 100644 --- a/src/test/ui/const-generics/infer/method-chain.rs +++ b/src/test/ui/const-generics/infer/method-chain.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo; diff --git a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr b/src/test/ui/const-generics/infer/uninferred-consts.full.stderr index 4be625ba909..254a28f70e2 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr +++ b/src/test/ui/const-generics/infer/uninferred-consts.full.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/uninferred-consts.rs:14:9 + --> $DIR/uninferred-consts.rs:13:9 | LL | Foo.foo(); | ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo` diff --git a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr b/src/test/ui/const-generics/infer/uninferred-consts.min.stderr index 4be625ba909..254a28f70e2 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr +++ b/src/test/ui/const-generics/infer/uninferred-consts.min.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/uninferred-consts.rs:14:9 + --> $DIR/uninferred-consts.rs:13:9 | LL | Foo.foo(); | ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo` diff --git a/src/test/ui/const-generics/infer/uninferred-consts.rs b/src/test/ui/const-generics/infer/uninferred-consts.rs index 00fb6eac992..bcd9aadb78a 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.rs +++ b/src/test/ui/const-generics/infer/uninferred-consts.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893 struct Foo; diff --git a/src/test/ui/const-generics/infer_arg_from_pat.rs b/src/test/ui/const-generics/infer_arg_from_pat.rs index 609fdb35cf1..5e2a3eaff54 100644 --- a/src/test/ui/const-generics/infer_arg_from_pat.rs +++ b/src/test/ui/const-generics/infer_arg_from_pat.rs @@ -5,7 +5,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize> { arr: [u8; N], diff --git a/src/test/ui/const-generics/infer_arr_len_from_pat.rs b/src/test/ui/const-generics/infer_arr_len_from_pat.rs index cbf48e3d249..0273383856f 100644 --- a/src/test/ui/const-generics/infer_arr_len_from_pat.rs +++ b/src/test/ui/const-generics/infer_arr_len_from_pat.rs @@ -5,7 +5,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn as_chunks<const N: usize>() -> [u8; N] { loop {} diff --git a/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs b/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs index bdbf338295c..96e5976e44b 100644 --- a/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs +++ b/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn takes_closure_of_array_3<F>(f: F) where F: Fn([i32; 3]) { f([1, 2, 3]); diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr index c09d16d0ab0..3e90dbeece9 100644 --- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr +++ b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/intrinsics-type_name-as-const-argument.rs:15:8 + --> $DIR/intrinsics-type_name-as-const-argument.rs:14:8 | LL | T: Trait<{std::intrinsics::type_name::<T>()}> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr index 02467df193c..8701d54f5c9 100644 --- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr +++ b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/intrinsics-type_name-as-const-argument.rs:15:44 + --> $DIR/intrinsics-type_name-as-const-argument.rs:14:44 | LL | T: Trait<{std::intrinsics::type_name::<T>()}> | ^ cannot perform const operation using `T` @@ -8,13 +8,13 @@ LL | T: Trait<{std::intrinsics::type_name::<T>()}> = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/intrinsics-type_name-as-const-argument.rs:10:22 + --> $DIR/intrinsics-type_name-as-const-argument.rs:9:22 | LL | trait Trait<const S: &'static str> {} | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs index 8971c00ed5a..f24dd42eb2d 100644 --- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs +++ b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] #![feature(core_intrinsics)] #![feature(const_type_name)] diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr index 8855f187e97..56deec16548 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-61522-array-len-succ.rs:7:40 + --> $DIR/issue-61522-array-len-succ.rs:6:40 | LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); | ^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-61522-array-len-succ.rs:12:24 + --> $DIR/issue-61522-array-len-succ.rs:11:24 | LL | fn inner(&self) -> &[u8; COUNT + 1] { | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr index 2eaef95c232..36a0a37ae9c 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-61522-array-len-succ.rs:7:45 + --> $DIR/issue-61522-array-len-succ.rs:6:45 | LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); | ^^^^^ cannot perform const operation using `COUNT` @@ -8,7 +8,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-61522-array-len-succ.rs:12:30 + --> $DIR/issue-61522-array-len-succ.rs:11:30 | LL | fn inner(&self) -> &[u8; COUNT + 1] { | ^^^^^ cannot perform const operation using `COUNT` diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issue-61522-array-len-succ.rs index 8c0a3a03774..d4a948b9259 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.rs +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); //[full]~^ ERROR constant expression depends on a generic parameter diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr index 1c2e7e069a1..e96b9e70352 100644 --- a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr @@ -1,11 +1,11 @@ error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:9:25 + --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:8:25 | LL | trait Trait<const NAME: &'static str> { | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs index 11d4bf4c3e6..2a741ba87a9 100644 --- a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Trait<const NAME: &'static str> { diff --git a/src/test/ui/const-generics/issue-67375.full.stderr b/src/test/ui/const-generics/issue-67375.full.stderr index e15d65f197e..2f004f75de5 100644 --- a/src/test/ui/const-generics/issue-67375.full.stderr +++ b/src/test/ui/const-generics/issue-67375.full.stderr @@ -1,5 +1,5 @@ warning: cannot use constants which depend on generic parameters in types - --> $DIR/issue-67375.rs:9:12 + --> $DIR/issue-67375.rs:8:12 | LL | inner: [(); { [|_: &T| {}; 0].len() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | inner: [(); { [|_: &T| {}; 0].len() }], = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200> error[E0392]: parameter `T` is never used - --> $DIR/issue-67375.rs:7:12 + --> $DIR/issue-67375.rs:6:12 | LL | struct Bug<T> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67375.min.stderr b/src/test/ui/const-generics/issue-67375.min.stderr index da96b5374a5..337e7bc1409 100644 --- a/src/test/ui/const-generics/issue-67375.min.stderr +++ b/src/test/ui/const-generics/issue-67375.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-67375.rs:9:25 + --> $DIR/issue-67375.rs:8:25 | LL | inner: [(); { [|_: &T| {}; 0].len() }], | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | inner: [(); { [|_: &T| {}; 0].len() }], = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0392]: parameter `T` is never used - --> $DIR/issue-67375.rs:7:12 + --> $DIR/issue-67375.rs:6:12 | LL | struct Bug<T> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67375.rs b/src/test/ui/const-generics/issue-67375.rs index ecc76bcae06..a8875b8b6bf 100644 --- a/src/test/ui/const-generics/issue-67375.rs +++ b/src/test/ui/const-generics/issue-67375.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] struct Bug<T> { //~^ ERROR parameter `T` is never used diff --git a/src/test/ui/const-generics/issue-67945-1.full.stderr b/src/test/ui/const-generics/issue-67945-1.full.stderr index e79c4f5374e..5cdcefe3501 100644 --- a/src/test/ui/const-generics/issue-67945-1.full.stderr +++ b/src/test/ui/const-generics/issue-67945-1.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-67945-1.rs:14:20 + --> $DIR/issue-67945-1.rs:13:20 | LL | struct Bug<S> { | - this type parameter @@ -13,7 +13,7 @@ LL | let x: S = MaybeUninit::uninit(); found union `MaybeUninit<_>` error[E0392]: parameter `S` is never used - --> $DIR/issue-67945-1.rs:11:12 + --> $DIR/issue-67945-1.rs:10:12 | LL | struct Bug<S> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67945-1.min.stderr b/src/test/ui/const-generics/issue-67945-1.min.stderr index 8fea130baa5..a3e086ea954 100644 --- a/src/test/ui/const-generics/issue-67945-1.min.stderr +++ b/src/test/ui/const-generics/issue-67945-1.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-67945-1.rs:14:16 + --> $DIR/issue-67945-1.rs:13:16 | LL | let x: S = MaybeUninit::uninit(); | ^ cannot perform const operation using `S` @@ -8,7 +8,7 @@ LL | let x: S = MaybeUninit::uninit(); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-67945-1.rs:17:45 + --> $DIR/issue-67945-1.rs:16:45 | LL | let b = &*(&x as *const _ as *const S); | ^ cannot perform const operation using `S` @@ -17,7 +17,7 @@ LL | let b = &*(&x as *const _ as *const S); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0392]: parameter `S` is never used - --> $DIR/issue-67945-1.rs:11:12 + --> $DIR/issue-67945-1.rs:10:12 | LL | struct Bug<S> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67945-1.rs b/src/test/ui/const-generics/issue-67945-1.rs index 6771603f259..84737e4e985 100644 --- a/src/test/ui/const-generics/issue-67945-1.rs +++ b/src/test/ui/const-generics/issue-67945-1.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] use std::marker::PhantomData; diff --git a/src/test/ui/const-generics/issue-67945-2.full.stderr b/src/test/ui/const-generics/issue-67945-2.full.stderr index 2f54b802df8..4d96058b395 100644 --- a/src/test/ui/const-generics/issue-67945-2.full.stderr +++ b/src/test/ui/const-generics/issue-67945-2.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-67945-2.rs:12:20 + --> $DIR/issue-67945-2.rs:11:20 | LL | struct Bug<S> { | - this type parameter @@ -13,7 +13,7 @@ LL | let x: S = MaybeUninit::uninit(); found union `MaybeUninit<_>` error[E0392]: parameter `S` is never used - --> $DIR/issue-67945-2.rs:9:12 + --> $DIR/issue-67945-2.rs:8:12 | LL | struct Bug<S> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67945-2.min.stderr b/src/test/ui/const-generics/issue-67945-2.min.stderr index 50633772b75..860be4a9b6a 100644 --- a/src/test/ui/const-generics/issue-67945-2.min.stderr +++ b/src/test/ui/const-generics/issue-67945-2.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-67945-2.rs:12:16 + --> $DIR/issue-67945-2.rs:11:16 | LL | let x: S = MaybeUninit::uninit(); | ^ cannot perform const operation using `S` @@ -8,7 +8,7 @@ LL | let x: S = MaybeUninit::uninit(); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-67945-2.rs:15:45 + --> $DIR/issue-67945-2.rs:14:45 | LL | let b = &*(&x as *const _ as *const S); | ^ cannot perform const operation using `S` @@ -17,7 +17,7 @@ LL | let b = &*(&x as *const _ as *const S); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0392]: parameter `S` is never used - --> $DIR/issue-67945-2.rs:9:12 + --> $DIR/issue-67945-2.rs:8:12 | LL | struct Bug<S> { | ^ unused parameter diff --git a/src/test/ui/const-generics/issue-67945-2.rs b/src/test/ui/const-generics/issue-67945-2.rs index 72dbb674e66..4a46786e9a9 100644 --- a/src/test/ui/const-generics/issue-67945-2.rs +++ b/src/test/ui/const-generics/issue-67945-2.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] use std::mem::MaybeUninit; diff --git a/src/test/ui/const-generics/issue-67945-3.full.stderr b/src/test/ui/const-generics/issue-67945-3.full.stderr index c33b88588c0..fa66252bd69 100644 --- a/src/test/ui/const-generics/issue-67945-3.full.stderr +++ b/src/test/ui/const-generics/issue-67945-3.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-67945-3.rs:8:8 + --> $DIR/issue-67945-3.rs:7:8 | LL | A: [(); { | ________^ diff --git a/src/test/ui/const-generics/issue-67945-3.min.stderr b/src/test/ui/const-generics/issue-67945-3.min.stderr index 9c6e101ece8..5c30429c895 100644 --- a/src/test/ui/const-generics/issue-67945-3.min.stderr +++ b/src/test/ui/const-generics/issue-67945-3.min.stderr @@ -1,5 +1,5 @@ error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/issue-67945-3.rs:10:27 + --> $DIR/issue-67945-3.rs:9:27 | LL | let x: Option<Box<Self>> = None; | ^^^^ diff --git a/src/test/ui/const-generics/issue-67945-3.rs b/src/test/ui/const-generics/issue-67945-3.rs index bca079101e2..5bad61cfc76 100644 --- a/src/test/ui/const-generics/issue-67945-3.rs +++ b/src/test/ui/const-generics/issue-67945-3.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] struct Bug<S: ?Sized> { A: [(); { diff --git a/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs b/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs index eab63d3a6e6..43c3999133c 100644 --- a/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs +++ b/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] extern crate impl_const; diff --git a/src/test/ui/const-generics/issue-70180-1-stalled_on.rs b/src/test/ui/const-generics/issue-70180-1-stalled_on.rs index 9cfa57006d5..f0554823273 100644 --- a/src/test/ui/const-generics/issue-70180-1-stalled_on.rs +++ b/src/test/ui/const-generics/issue-70180-1-stalled_on.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub fn works() { let array/*: [_; _]*/ = default_array(); diff --git a/src/test/ui/const-generics/issue-70180-2-stalled_on.rs b/src/test/ui/const-generics/issue-70180-2-stalled_on.rs index bbde404966c..21cefc09c25 100644 --- a/src/test/ui/const-generics/issue-70180-2-stalled_on.rs +++ b/src/test/ui/const-generics/issue-70180-2-stalled_on.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn works() { let array/*: [u8; _]*/ = default_byte_array(); diff --git a/src/test/ui/const-generics/issue-71986.rs b/src/test/ui/const-generics/issue-71986.rs index d4c962452d1..6bfdba5711e 100644 --- a/src/test/ui/const-generics/issue-71986.rs +++ b/src/test/ui/const-generics/issue-71986.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub trait Foo<const B: bool> {} pub fn bar<T: Foo<{ true }>>() {} diff --git a/src/test/ui/const-generics/issue-74906.rs b/src/test/ui/const-generics/issue-74906.rs index 9162d1142b6..dc3c33736da 100644 --- a/src/test/ui/const-generics/issue-74906.rs +++ b/src/test/ui/const-generics/issue-74906.rs @@ -3,7 +3,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] const SIZE: usize = 16; diff --git a/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs index 7ea8d936d61..f59eb60cb38 100644 --- a/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs +++ b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // All of these three items must be in `lib2` to reproduce the error diff --git a/src/test/ui/const-generics/issues/issue-56445.full.stderr b/src/test/ui/const-generics/issues/issue-56445.full.stderr index 50e91418551..61fba92c196 100644 --- a/src/test/ui/const-generics/issues/issue-56445.full.stderr +++ b/src/test/ui/const-generics/issues/issue-56445.full.stderr @@ -6,10 +6,9 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0771]: use of non-static lifetime `'a` in const generic - --> $DIR/issue-56445.rs:9:26 + --> $DIR/issue-56445.rs:8:26 | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | ^^ diff --git a/src/test/ui/const-generics/issues/issue-56445.min.stderr b/src/test/ui/const-generics/issues/issue-56445.min.stderr index bcb27d8d1e1..80702dd4bc3 100644 --- a/src/test/ui/const-generics/issues/issue-56445.min.stderr +++ b/src/test/ui/const-generics/issues/issue-56445.min.stderr @@ -1,5 +1,5 @@ error[E0771]: use of non-static lifetime `'a` in const generic - --> $DIR/issue-56445.rs:9:26 + --> $DIR/issue-56445.rs:8:26 | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | ^^ diff --git a/src/test/ui/const-generics/issues/issue-56445.rs b/src/test/ui/const-generics/issues/issue-56445.rs index 0bcde348b05..bc9e1dee853 100644 --- a/src/test/ui/const-generics/issues/issue-56445.rs +++ b/src/test/ui/const-generics/issues/issue-56445.rs @@ -1,7 +1,6 @@ // Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995. // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] #![crate_type = "lib"] use std::marker::PhantomData; diff --git a/src/test/ui/const-generics/issues/issue-60263.rs b/src/test/ui/const-generics/issues/issue-60263.rs deleted file mode 100644 index 70cbc242c41..00000000000 --- a/src/test/ui/const-generics/issues/issue-60263.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct B<const I: u8>; //~ ERROR const generics are unstable - -impl B<0> { - fn bug() -> Self { - panic!() - } -} - -fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-60263.stderr b/src/test/ui/const-generics/issues/issue-60263.stderr deleted file mode 100644 index aeef296f385..00000000000 --- a/src/test/ui/const-generics/issues/issue-60263.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: const generics are unstable - --> $DIR/issue-60263.rs:1:16 - | -LL | struct B<const I: u8>; - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr index cc014ea429d..c03b7252a3c 100644 --- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr +++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr @@ -6,7 +6,6 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs index ae2b0520fb1..6e64c78cd8c 100644 --- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs +++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs @@ -1,7 +1,6 @@ // check-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] struct Generic<const V: usize>; diff --git a/src/test/ui/const-generics/issues/issue-61336-1.full.stderr b/src/test/ui/const-generics/issues/issue-61336-1.full.stderr index 3a9f819a626..f18728eabbb 100644 --- a/src/test/ui/const-generics/issues/issue-61336-1.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-1.full.stderr @@ -6,7 +6,6 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61336-1.rs b/src/test/ui/const-generics/issues/issue-61336-1.rs index 201c0d039d9..c93b296dbb5 100644 --- a/src/test/ui/const-generics/issues/issue-61336-1.rs +++ b/src/test/ui/const-generics/issues/issue-61336-1.rs @@ -1,7 +1,6 @@ // build-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; N] diff --git a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr index 883ebbef3e8..9f8e68d211d 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr @@ -6,10 +6,9 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336-2.rs:10:5 + --> $DIR/issue-61336-2.rs:9:5 | LL | [x; { N }] | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr index 40863a4f718..82d17a87e0a 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336-2.rs:10:5 + --> $DIR/issue-61336-2.rs:9:5 | LL | [x; { N }] | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/const-generics/issues/issue-61336-2.rs b/src/test/ui/const-generics/issues/issue-61336-2.rs index 44995157cc9..a1cf641ff74 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.rs +++ b/src/test/ui/const-generics/issues/issue-61336-2.rs @@ -1,6 +1,5 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; { N }] diff --git a/src/test/ui/const-generics/issues/issue-61336.full.stderr b/src/test/ui/const-generics/issues/issue-61336.full.stderr index 3863da8da05..974e2af6fd2 100644 --- a/src/test/ui/const-generics/issues/issue-61336.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.full.stderr @@ -6,10 +6,9 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336.rs:10:5 + --> $DIR/issue-61336.rs:9:5 | LL | [x; N] | ^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/const-generics/issues/issue-61336.min.stderr b/src/test/ui/const-generics/issues/issue-61336.min.stderr index 6c57f9ccbf5..19c7153582c 100644 --- a/src/test/ui/const-generics/issues/issue-61336.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.min.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336.rs:10:5 + --> $DIR/issue-61336.rs:9:5 | LL | [x; N] | ^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/const-generics/issues/issue-61336.rs b/src/test/ui/const-generics/issues/issue-61336.rs index 7c34250e6b2..c0106ee38c2 100644 --- a/src/test/ui/const-generics/issues/issue-61336.rs +++ b/src/test/ui/const-generics/issues/issue-61336.rs @@ -1,6 +1,5 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; N] diff --git a/src/test/ui/const-generics/issues/issue-61422.full.stderr b/src/test/ui/const-generics/issues/issue-61422.full.stderr index 294378a6690..ac6c378295d 100644 --- a/src/test/ui/const-generics/issues/issue-61422.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61422.full.stderr @@ -6,7 +6,6 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61422.rs b/src/test/ui/const-generics/issues/issue-61422.rs index 649f8b4255b..421f696f3fd 100644 --- a/src/test/ui/const-generics/issues/issue-61422.rs +++ b/src/test/ui/const-generics/issues/issue-61422.rs @@ -1,7 +1,6 @@ // check-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] use std::mem; diff --git a/src/test/ui/const-generics/issues/issue-61432.full.stderr b/src/test/ui/const-generics/issues/issue-61432.full.stderr index eec1b20254e..82b36de45a2 100644 --- a/src/test/ui/const-generics/issues/issue-61432.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61432.full.stderr @@ -6,7 +6,6 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs index 91a4794099c..0e228126d77 100644 --- a/src/test/ui/const-generics/issues/issue-61432.rs +++ b/src/test/ui/const-generics/issues/issue-61432.rs @@ -1,7 +1,6 @@ // run-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] fn promote<const N: i32>() { // works: diff --git a/src/test/ui/const-generics/issues/issue-61747.full.stderr b/src/test/ui/const-generics/issues/issue-61747.full.stderr index 3a266c8e974..b7f66345c4a 100644 --- a/src/test/ui/const-generics/issues/issue-61747.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.full.stderr @@ -6,10 +6,9 @@ LL | #![cfg_attr(full, feature(const_generics))] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: constant expression depends on a generic parameter - --> $DIR/issue-61747.rs:8:23 + --> $DIR/issue-61747.rs:7:23 | LL | fn successor() -> Const<{C + 1}> { | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-61747.min.stderr b/src/test/ui/const-generics/issues/issue-61747.min.stderr index 1de9e71b6eb..b85533ccb46 100644 --- a/src/test/ui/const-generics/issues/issue-61747.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-61747.rs:8:30 + --> $DIR/issue-61747.rs:7:30 | LL | fn successor() -> Const<{C + 1}> { | ^ cannot perform const operation using `C` diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs index 3a4dd1cdd18..3aa2e6a5c31 100644 --- a/src/test/ui/const-generics/issues/issue-61747.rs +++ b/src/test/ui/const-generics/issues/issue-61747.rs @@ -1,6 +1,5 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![cfg_attr(min, feature(min_const_generics))] struct Const<const N: usize>; diff --git a/src/test/ui/const-generics/issues/issue-61935.full.stderr b/src/test/ui/const-generics/issues/issue-61935.full.stderr index b805bc0db7e..b970f4e4c8e 100644 --- a/src/test/ui/const-generics/issues/issue-61935.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-61935.rs:10:14 + --> $DIR/issue-61935.rs:9:14 | LL | Self:FooImpl<{N==0}> | ^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-61935.min.stderr b/src/test/ui/const-generics/issues/issue-61935.min.stderr index b1d92056a54..9382dca3153 100644 --- a/src/test/ui/const-generics/issues/issue-61935.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-61935.rs:10:23 + --> $DIR/issue-61935.rs:9:23 | LL | Self:FooImpl<{N==0}> | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-61935.rs b/src/test/ui/const-generics/issues/issue-61935.rs index 9fa02329a71..ed861c63bf1 100644 --- a/src/test/ui/const-generics/issues/issue-61935.rs +++ b/src/test/ui/const-generics/issues/issue-61935.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Foo {} diff --git a/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs index a8fa3780356..1a0e46e599d 100644 --- a/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs +++ b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs @@ -3,7 +3,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub trait BitLen: Sized { const BIT_LEN: usize; diff --git a/src/test/ui/const-generics/issues/issue-62220.full.stderr b/src/test/ui/const-generics/issues/issue-62220.full.stderr index 120aa8e4af5..373360c7ced 100644 --- a/src/test/ui/const-generics/issues/issue-62220.full.stderr +++ b/src/test/ui/const-generics/issues/issue-62220.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-62220.rs:13:27 + --> $DIR/issue-62220.rs:12:27 | LL | pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-62220.min.stderr b/src/test/ui/const-generics/issues/issue-62220.min.stderr index b338cdb87e1..72311d030cf 100644 --- a/src/test/ui/const-generics/issues/issue-62220.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62220.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-62220.rs:8:59 + --> $DIR/issue-62220.rs:7:59 | LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-62220.rs b/src/test/ui/const-generics/issues/issue-62220.rs index 2017473fa9e..c26784c9813 100644 --- a/src/test/ui/const-generics/issues/issue-62220.rs +++ b/src/test/ui/const-generics/issues/issue-62220.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct Vector<T, const N: usize>([T; N]); diff --git a/src/test/ui/const-generics/issues/issue-62456.full.stderr b/src/test/ui/const-generics/issues/issue-62456.full.stderr index a8d44074db9..833e70ca6d3 100644 --- a/src/test/ui/const-generics/issues/issue-62456.full.stderr +++ b/src/test/ui/const-generics/issues/issue-62456.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-62456.rs:7:20 + --> $DIR/issue-62456.rs:6:20 | LL | let _ = [0u64; N + 1]; | ^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-62456.min.stderr b/src/test/ui/const-generics/issues/issue-62456.min.stderr index a4b501a7bb1..920318fa0ac 100644 --- a/src/test/ui/const-generics/issues/issue-62456.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62456.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-62456.rs:7:20 + --> $DIR/issue-62456.rs:6:20 | LL | let _ = [0u64; N + 1]; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-62456.rs b/src/test/ui/const-generics/issues/issue-62456.rs index cbb2a11a931..e24cf36c8ce 100644 --- a/src/test/ui/const-generics/issues/issue-62456.rs +++ b/src/test/ui/const-generics/issues/issue-62456.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const N: usize>() { let _ = [0u64; N + 1]; diff --git a/src/test/ui/const-generics/issues/issue-62504.full.stderr b/src/test/ui/const-generics/issues/issue-62504.full.stderr index 9c84f06ce9f..f09af76325e 100644 --- a/src/test/ui/const-generics/issues/issue-62504.full.stderr +++ b/src/test/ui/const-generics/issues/issue-62504.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-62504.rs:19:25 + --> $DIR/issue-62504.rs:18:25 | LL | ArrayHolder([0; Self::SIZE]) | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-62504.min.stderr b/src/test/ui/const-generics/issues/issue-62504.min.stderr index 865eaf74932..5d45e302888 100644 --- a/src/test/ui/const-generics/issues/issue-62504.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62504.min.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-62504.rs:19:21 + --> $DIR/issue-62504.rs:18:21 | LL | ArrayHolder([0; Self::SIZE]) | ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE` @@ -8,7 +8,7 @@ LL | ArrayHolder([0; Self::SIZE]) found array `[u32; _]` error: constant expression depends on a generic parameter - --> $DIR/issue-62504.rs:19:25 + --> $DIR/issue-62504.rs:18:25 | LL | ArrayHolder([0; Self::SIZE]) | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-62504.rs b/src/test/ui/const-generics/issues/issue-62504.rs index 5630962ff53..0b95754cab4 100644 --- a/src/test/ui/const-generics/issues/issue-62504.rs +++ b/src/test/ui/const-generics/issues/issue-62504.rs @@ -2,7 +2,6 @@ #![allow(incomplete_features)] #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait HasSize { const SIZE: usize; diff --git a/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr b/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr index 5117e20d626..5c9387d4012 100644 --- a/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr @@ -1,11 +1,11 @@ error: `NoMatch` is forbidden as the type of a const generic parameter - --> $DIR/issue-62579-no-match.rs:10:17 + --> $DIR/issue-62579-no-match.rs:9:17 | LL | fn foo<const T: NoMatch>() -> bool { | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-62579-no-match.rs b/src/test/ui/const-generics/issues/issue-62579-no-match.rs index c9853aa9162..46813f5256e 100644 --- a/src/test/ui/const-generics/issues/issue-62579-no-match.rs +++ b/src/test/ui/const-generics/issues/issue-62579-no-match.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(PartialEq, Eq)] struct NoMatch; diff --git a/src/test/ui/const-generics/issues/issue-62878.full.stderr b/src/test/ui/const-generics/issues/issue-62878.full.stderr index dce2e27c71a..6e6aa196633 100644 --- a/src/test/ui/const-generics/issues/issue-62878.full.stderr +++ b/src/test/ui/const-generics/issues/issue-62878.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-62878.rs:6:38 + --> $DIR/issue-62878.rs:5:38 | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` error[E0747]: type provided when a constant was expected - --> $DIR/issue-62878.rs:11:11 + --> $DIR/issue-62878.rs:10:11 | LL | foo::<_, {[1]}>(); | ^ @@ -13,7 +13,7 @@ LL | foo::<_, {[1]}>(); = help: const arguments cannot yet be inferred with `_` error[E0308]: mismatched types - --> $DIR/issue-62878.rs:11:15 + --> $DIR/issue-62878.rs:10:15 | LL | foo::<_, {[1]}>(); | ^^^ expected `usize`, found array `[{integer}; 1]` diff --git a/src/test/ui/const-generics/issues/issue-62878.min.stderr b/src/test/ui/const-generics/issues/issue-62878.min.stderr index 9f95e5d8862..e4a71fe0618 100644 --- a/src/test/ui/const-generics/issues/issue-62878.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62878.min.stderr @@ -1,17 +1,17 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-62878.rs:6:38 + --> $DIR/issue-62878.rs:5:38 | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-62878.rs:6:33 + --> $DIR/issue-62878.rs:5:33 | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-62878.rs b/src/test/ui/const-generics/issues/issue-62878.rs index c087711e5f9..a70606c4a7d 100644 --- a/src/test/ui/const-generics/issues/issue-62878.rs +++ b/src/test/ui/const-generics/issues/issue-62878.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const N: usize, const A: [u8; N]>() {} //~^ ERROR the type of const parameters must not diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr index a20c7264acf..e1c20e6ae78 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr @@ -1,5 +1,5 @@ error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/issue-63322-forbid-dyn.rs:10:18 + --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr index 5dbfdc6d652..2fb38addb2d 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -1,14 +1,14 @@ error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/issue-63322-forbid-dyn.rs:10:18 + --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/issue-63322-forbid-dyn.rs:10:18 + --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs index 2194eb97a41..334e2aac02a 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait A {} struct B; diff --git a/src/test/ui/const-generics/issues/issue-64494.full.stderr b/src/test/ui/const-generics/issues/issue-64494.full.stderr index a97ec9308f8..abb26d6cf17 100644 --- a/src/test/ui/const-generics/issues/issue-64494.full.stderr +++ b/src/test/ui/const-generics/issues/issue-64494.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-64494.rs:16:53 + --> $DIR/issue-64494.rs:15:53 | LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {} | ^^^^ @@ -7,7 +7,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {} = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-64494.rs:19:53 + --> $DIR/issue-64494.rs:18:53 | LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {} | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-64494.min.stderr b/src/test/ui/const-generics/issues/issue-64494.min.stderr index 681166b1d2b..936ab7f6e7e 100644 --- a/src/test/ui/const-generics/issues/issue-64494.min.stderr +++ b/src/test/ui/const-generics/issues/issue-64494.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-64494.rs:16:38 + --> $DIR/issue-64494.rs:15:38 | LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {} | ^^^^^^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {} = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-64494.rs:19:38 + --> $DIR/issue-64494.rs:18:38 | LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {} | ^^^^^^ cannot perform const operation using `T` @@ -17,7 +17,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {} = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/issue-64494.rs:19:1 + --> $DIR/issue-64494.rs:18:1 | LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {} | ------------------------------------ first implementation here diff --git a/src/test/ui/const-generics/issues/issue-64494.rs b/src/test/ui/const-generics/issues/issue-64494.rs index 014742be03d..96d19203109 100644 --- a/src/test/ui/const-generics/issues/issue-64494.rs +++ b/src/test/ui/const-generics/issues/issue-64494.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Foo { const VAL: usize; diff --git a/src/test/ui/const-generics/issues/issue-64519.rs b/src/test/ui/const-generics/issues/issue-64519.rs index 1ca709d0975..8c603b74b90 100644 --- a/src/test/ui/const-generics/issues/issue-64519.rs +++ b/src/test/ui/const-generics/issues/issue-64519.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<const D: usize> { state: Option<[u8; D]>, diff --git a/src/test/ui/const-generics/issues/issue-66205.full.stderr b/src/test/ui/const-generics/issues/issue-66205.full.stderr index a1520912e4e..7e150f5f6db 100644 --- a/src/test/ui/const-generics/issues/issue-66205.full.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-66205.rs:8:12 + --> $DIR/issue-66205.rs:7:12 | LL | fact::<{ N - 1 }>(); | ^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-66205.min.stderr b/src/test/ui/const-generics/issues/issue-66205.min.stderr index ecd96ac37e4..b41793b62d2 100644 --- a/src/test/ui/const-generics/issues/issue-66205.min.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-66205.rs:8:14 + --> $DIR/issue-66205.rs:7:14 | LL | fact::<{ N - 1 }>(); | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs index 4e37c247d00..14249b62cee 100644 --- a/src/test/ui/const-generics/issues/issue-66205.rs +++ b/src/test/ui/const-generics/issues/issue-66205.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code, unconditional_recursion)] fn fact<const N: usize>() { diff --git a/src/test/ui/const-generics/issues/issue-66906.rs b/src/test/ui/const-generics/issues/issue-66906.rs index 3e048593c9b..a871b118dcc 100644 --- a/src/test/ui/const-generics/issues/issue-66906.rs +++ b/src/test/ui/const-generics/issues/issue-66906.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct Tuple; diff --git a/src/test/ui/const-generics/issues/issue-67185-1.rs b/src/test/ui/const-generics/issues/issue-67185-1.rs index 09d88ef89a3..ed35a5f7c0a 100644 --- a/src/test/ui/const-generics/issues/issue-67185-1.rs +++ b/src/test/ui/const-generics/issues/issue-67185-1.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Baz { type Quaks; diff --git a/src/test/ui/const-generics/issues/issue-67185-2.full.stderr b/src/test/ui/const-generics/issues/issue-67185-2.full.stderr index 78c7ebff059..fa9c680d4b8 100644 --- a/src/test/ui/const-generics/issues/issue-67185-2.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67185-2.full.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:17:1 + --> $DIR/issue-67185-2.rs:16:1 | LL | / trait Foo LL | | @@ -17,7 +17,7 @@ LL | | } = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:17:1 + --> $DIR/issue-67185-2.rs:16:1 | LL | / trait Foo LL | | @@ -35,7 +35,7 @@ LL | | } = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:27:6 + --> $DIR/issue-67185-2.rs:26:6 | LL | trait Foo | --- required by a bound in this @@ -51,7 +51,7 @@ LL | impl Foo for FooImpl {} <[u16; 4] as Bar> error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:27:6 + --> $DIR/issue-67185-2.rs:26:6 | LL | trait Foo | --- required by a bound in this @@ -67,7 +67,7 @@ LL | impl Foo for FooImpl {} <[u16; 4] as Bar> error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:31:14 + --> $DIR/issue-67185-2.rs:30:14 | LL | trait Foo | --- required by a bound in this @@ -83,7 +83,7 @@ LL | fn f(_: impl Foo) {} <[u16; 4] as Bar> error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:31:14 + --> $DIR/issue-67185-2.rs:30:14 | LL | trait Foo | --- required by a bound in this diff --git a/src/test/ui/const-generics/issues/issue-67185-2.min.stderr b/src/test/ui/const-generics/issues/issue-67185-2.min.stderr index 78c7ebff059..fa9c680d4b8 100644 --- a/src/test/ui/const-generics/issues/issue-67185-2.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67185-2.min.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:17:1 + --> $DIR/issue-67185-2.rs:16:1 | LL | / trait Foo LL | | @@ -17,7 +17,7 @@ LL | | } = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:17:1 + --> $DIR/issue-67185-2.rs:16:1 | LL | / trait Foo LL | | @@ -35,7 +35,7 @@ LL | | } = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:27:6 + --> $DIR/issue-67185-2.rs:26:6 | LL | trait Foo | --- required by a bound in this @@ -51,7 +51,7 @@ LL | impl Foo for FooImpl {} <[u16; 4] as Bar> error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:27:6 + --> $DIR/issue-67185-2.rs:26:6 | LL | trait Foo | --- required by a bound in this @@ -67,7 +67,7 @@ LL | impl Foo for FooImpl {} <[u16; 4] as Bar> error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:31:14 + --> $DIR/issue-67185-2.rs:30:14 | LL | trait Foo | --- required by a bound in this @@ -83,7 +83,7 @@ LL | fn f(_: impl Foo) {} <[u16; 4] as Bar> error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied - --> $DIR/issue-67185-2.rs:31:14 + --> $DIR/issue-67185-2.rs:30:14 | LL | trait Foo | --- required by a bound in this diff --git a/src/test/ui/const-generics/issues/issue-67185-2.rs b/src/test/ui/const-generics/issues/issue-67185-2.rs index 1176d0c6904..94a713d7cf9 100644 --- a/src/test/ui/const-generics/issues/issue-67185-2.rs +++ b/src/test/ui/const-generics/issues/issue-67185-2.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Baz { type Quaks; diff --git a/src/test/ui/const-generics/issues/issue-67739.full.stderr b/src/test/ui/const-generics/issues/issue-67739.full.stderr index 27a56b8eb02..dcbe5b94a62 100644 --- a/src/test/ui/const-generics/issues/issue-67739.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67739.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-67739.rs:12:15 + --> $DIR/issue-67739.rs:11:15 | LL | [0u8; mem::size_of::<Self::Associated>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-67739.min.stderr b/src/test/ui/const-generics/issues/issue-67739.min.stderr index 27a56b8eb02..dcbe5b94a62 100644 --- a/src/test/ui/const-generics/issues/issue-67739.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67739.min.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-67739.rs:12:15 + --> $DIR/issue-67739.rs:11:15 | LL | [0u8; mem::size_of::<Self::Associated>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-67739.rs b/src/test/ui/const-generics/issues/issue-67739.rs index 0f5860f22fd..e4960e56c9e 100644 --- a/src/test/ui/const-generics/issues/issue-67739.rs +++ b/src/test/ui/const-generics/issues/issue-67739.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::mem; diff --git a/src/test/ui/const-generics/issues/issue-68366.full.stderr b/src/test/ui/const-generics/issues/issue-68366.full.stderr index ac774f50c74..4015fb090b9 100644 --- a/src/test/ui/const-generics/issues/issue-68366.full.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.full.stderr @@ -1,5 +1,5 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:12:13 + --> $DIR/issue-68366.rs:11:13 | LL | impl <const N: usize> Collatz<{Some(N)}> {} | ^ unconstrained const parameter @@ -8,7 +8,7 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {} = note: proving the result of expressions other than the parameter are unique is not supported error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:18:12 + --> $DIR/issue-68366.rs:17:12 | LL | impl<const N: usize> Foo {} | ^ unconstrained const parameter diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr index acaf4a33ee0..da4cbd3081f 100644 --- a/src/test/ui/const-generics/issues/issue-68366.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-68366.rs:12:37 + --> $DIR/issue-68366.rs:11:37 | LL | impl <const N: usize> Collatz<{Some(N)}> {} | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {} = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:12:13 + --> $DIR/issue-68366.rs:11:13 | LL | impl <const N: usize> Collatz<{Some(N)}> {} | ^ unconstrained const parameter @@ -17,7 +17,7 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {} = note: proving the result of expressions other than the parameter are unique is not supported error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-68366.rs:18:12 + --> $DIR/issue-68366.rs:17:12 | LL | impl<const N: usize> Foo {} | ^ unconstrained const parameter diff --git a/src/test/ui/const-generics/issues/issue-68366.rs b/src/test/ui/const-generics/issues/issue-68366.rs index 474cdb7258d..37afed62327 100644 --- a/src/test/ui/const-generics/issues/issue-68366.rs +++ b/src/test/ui/const-generics/issues/issue-68366.rs @@ -5,7 +5,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Collatz<const N: Option<usize>>; diff --git a/src/test/ui/const-generics/issues/issue-68596.rs b/src/test/ui/const-generics/issues/issue-68596.rs index 3b27d4d68c5..0bb23be1eb4 100644 --- a/src/test/ui/const-generics/issues/issue-68596.rs +++ b/src/test/ui/const-generics/issues/issue-68596.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct S(u8); diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr index 59653114a6b..4782b1d98eb 100644 --- a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -1,11 +1,11 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter - --> $DIR/issue-68615-adt.rs:7:23 + --> $DIR/issue-68615-adt.rs:6:23 | LL | struct Const<const V: [usize; 0]> {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.rs b/src/test/ui/const-generics/issues/issue-68615-adt.rs index d616f3ab95a..ddea3e8ab65 100644 --- a/src/test/ui/const-generics/issues/issue-68615-adt.rs +++ b/src/test/ui/const-generics/issues/issue-68615-adt.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Const<const V: [usize; 0]> {} //[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter diff --git a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr index 1ee881b96ec..d0c190b91b0 100644 --- a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr @@ -1,11 +1,11 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter - --> $DIR/issue-68615-array.rs:7:21 + --> $DIR/issue-68615-array.rs:6:21 | LL | struct Foo<const V: [usize; 0] > {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-68615-array.rs b/src/test/ui/const-generics/issues/issue-68615-array.rs index 24c9a59a185..56afd9b2a15 100644 --- a/src/test/ui/const-generics/issues/issue-68615-array.rs +++ b/src/test/ui/const-generics/issues/issue-68615-array.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<const V: [usize; 0] > {} //[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter diff --git a/src/test/ui/const-generics/issues/issue-68977.full.stderr b/src/test/ui/const-generics/issues/issue-68977.full.stderr index 3690bac3eb3..25dcd88a4af 100644 --- a/src/test/ui/const-generics/issues/issue-68977.full.stderr +++ b/src/test/ui/const-generics/issues/issue-68977.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-68977.rs:35:44 + --> $DIR/issue-68977.rs:34:44 | LL | FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage, | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-68977.min.stderr b/src/test/ui/const-generics/issues/issue-68977.min.stderr index ea91df1e0bf..0b3d5b9a760 100644 --- a/src/test/ui/const-generics/issues/issue-68977.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68977.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-68977.rs:29:17 + --> $DIR/issue-68977.rs:28:17 | LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; | ^^^^^^^^ cannot perform const operation using `INT_BITS` @@ -8,7 +8,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-68977.rs:29:28 + --> $DIR/issue-68977.rs:28:28 | LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; | ^^^^^^^^^ cannot perform const operation using `FRAC_BITS` diff --git a/src/test/ui/const-generics/issues/issue-68977.rs b/src/test/ui/const-generics/issues/issue-68977.rs index 4fea94cb465..a0ffcc84c7a 100644 --- a/src/test/ui/const-generics/issues/issue-68977.rs +++ b/src/test/ui/const-generics/issues/issue-68977.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct PhantomU8<const X: u8>; diff --git a/src/test/ui/const-generics/issues/issue-70125-1.rs b/src/test/ui/const-generics/issues/issue-70125-1.rs index 04175089dc0..5c118d245a1 100644 --- a/src/test/ui/const-generics/issues/issue-70125-1.rs +++ b/src/test/ui/const-generics/issues/issue-70125-1.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] const L: usize = 4; diff --git a/src/test/ui/const-generics/issues/issue-70125-2.rs b/src/test/ui/const-generics/issues/issue-70125-2.rs index ceefc2dcb32..f82131262d6 100644 --- a/src/test/ui/const-generics/issues/issue-70125-2.rs +++ b/src/test/ui/const-generics/issues/issue-70125-2.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn main() { <()>::foo(); diff --git a/src/test/ui/const-generics/issues/issue-70167.rs b/src/test/ui/const-generics/issues/issue-70167.rs index 04c76a4dcaf..9e912b69177 100644 --- a/src/test/ui/const-generics/issues/issue-70167.rs +++ b/src/test/ui/const-generics/issues/issue-70167.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub trait Trait<const N: usize>: From<<Self as Trait<N>>::Item> { type Item; diff --git a/src/test/ui/const-generics/issues/issue-71169.full.stderr b/src/test/ui/const-generics/issues/issue-71169.full.stderr index b87825d20ce..7b1a2f98dfe 100644 --- a/src/test/ui/const-generics/issues/issue-71169.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71169.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71169.rs:6:43 + --> $DIR/issue-71169.rs:5:43 | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` error: constant expression depends on a generic parameter - --> $DIR/issue-71169.rs:11:14 + --> $DIR/issue-71169.rs:10:14 | LL | foo::<4, DATA>(); | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71169.min.stderr b/src/test/ui/const-generics/issues/issue-71169.min.stderr index 9b0a2946ca6..1c6e08adffd 100644 --- a/src/test/ui/const-generics/issues/issue-71169.min.stderr +++ b/src/test/ui/const-generics/issues/issue-71169.min.stderr @@ -1,17 +1,17 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71169.rs:6:43 + --> $DIR/issue-71169.rs:5:43 | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-71169.rs:6:38 + --> $DIR/issue-71169.rs:5:38 | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-71169.rs b/src/test/ui/const-generics/issues/issue-71169.rs index 7007ec222ca..a574da4b6b3 100644 --- a/src/test/ui/const-generics/issues/issue-71169.rs +++ b/src/test/ui/const-generics/issues/issue-71169.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} //~^ ERROR the type of const parameters must not diff --git a/src/test/ui/const-generics/issues/issue-71381.full.stderr b/src/test/ui/const-generics/issues/issue-71381.full.stderr index 453ef00e6dc..3950317b370 100644 --- a/src/test/ui/const-generics/issues/issue-71381.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71381.full.stderr @@ -1,23 +1,23 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:15:82 + --> $DIR/issue-71381.rs:14:82 | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:24:40 + --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:15:61 + --> $DIR/issue-71381.rs:14:61 | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:24:19 + --> $DIR/issue-71381.rs:23:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71381.min.stderr b/src/test/ui/const-generics/issues/issue-71381.min.stderr index 453ef00e6dc..3950317b370 100644 --- a/src/test/ui/const-generics/issues/issue-71381.min.stderr +++ b/src/test/ui/const-generics/issues/issue-71381.min.stderr @@ -1,23 +1,23 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:15:82 + --> $DIR/issue-71381.rs:14:82 | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:24:40 + --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:15:61 + --> $DIR/issue-71381.rs:14:61 | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:24:19 + --> $DIR/issue-71381.rs:23:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs index 65d88e553b9..f015d694695 100644 --- a/src/test/ui/const-generics/issues/issue-71381.rs +++ b/src/test/ui/const-generics/issues/issue-71381.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Test(*const usize); diff --git a/src/test/ui/const-generics/issues/issue-71382.full.stderr b/src/test/ui/const-generics/issues/issue-71382.full.stderr index 3da85ee040d..715037bd5f1 100644 --- a/src/test/ui/const-generics/issues/issue-71382.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71382.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:17:23 + --> $DIR/issue-71382.rs:16:23 | LL | fn test<const FN: fn()>(&self) { | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71382.min.stderr b/src/test/ui/const-generics/issues/issue-71382.min.stderr index 3da85ee040d..715037bd5f1 100644 --- a/src/test/ui/const-generics/issues/issue-71382.min.stderr +++ b/src/test/ui/const-generics/issues/issue-71382.min.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:17:23 + --> $DIR/issue-71382.rs:16:23 | LL | fn test<const FN: fn()>(&self) { | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71382.rs b/src/test/ui/const-generics/issues/issue-71382.rs index 12a7d08382a..3a56db937de 100644 --- a/src/test/ui/const-generics/issues/issue-71382.rs +++ b/src/test/ui/const-generics/issues/issue-71382.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Test(); diff --git a/src/test/ui/const-generics/issues/issue-71611.full.stderr b/src/test/ui/const-generics/issues/issue-71611.full.stderr index 48d4bb361a1..01a85b745ce 100644 --- a/src/test/ui/const-generics/issues/issue-71611.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71611.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71611.rs:6:31 + --> $DIR/issue-71611.rs:5:31 | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71611.rs:6:21 + --> $DIR/issue-71611.rs:5:21 | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71611.min.stderr b/src/test/ui/const-generics/issues/issue-71611.min.stderr index 48d4bb361a1..01a85b745ce 100644 --- a/src/test/ui/const-generics/issues/issue-71611.min.stderr +++ b/src/test/ui/const-generics/issues/issue-71611.min.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71611.rs:6:31 + --> $DIR/issue-71611.rs:5:31 | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71611.rs:6:21 + --> $DIR/issue-71611.rs:5:21 | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71611.rs b/src/test/ui/const-generics/issues/issue-71611.rs index 9b8e8be6bc6..6468d0b6bda 100644 --- a/src/test/ui/const-generics/issues/issue-71611.rs +++ b/src/test/ui/const-generics/issues/issue-71611.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn func<A, const F: fn(inner: A)>(outer: A) { //~^ ERROR: using function pointers as const generic parameters is forbidden diff --git a/src/test/ui/const-generics/issues/issue-72352.full.stderr b/src/test/ui/const-generics/issues/issue-72352.full.stderr index 51f94678467..eedd73c4dcc 100644 --- a/src/test/ui/const-generics/issues/issue-72352.full.stderr +++ b/src/test/ui/const-generics/issues/issue-72352.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-72352.rs:8:42 + --> $DIR/issue-72352.rs:7:42 | LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize { | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-72352.min.stderr b/src/test/ui/const-generics/issues/issue-72352.min.stderr index 51f94678467..eedd73c4dcc 100644 --- a/src/test/ui/const-generics/issues/issue-72352.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72352.min.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-72352.rs:8:42 + --> $DIR/issue-72352.rs:7:42 | LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize { | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-72352.rs b/src/test/ui/const-generics/issues/issue-72352.rs index 1517f3dae4f..9cd95c11026 100644 --- a/src/test/ui/const-generics/issues/issue-72352.rs +++ b/src/test/ui/const-generics/issues/issue-72352.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::ffi::{CStr, CString}; diff --git a/src/test/ui/const-generics/issues/issue-72787.full.stderr b/src/test/ui/const-generics/issues/issue-72787.full.stderr index b4c79d4171b..fbb7ae59bef 100644 --- a/src/test/ui/const-generics/issues/issue-72787.full.stderr +++ b/src/test/ui/const-generics/issues/issue-72787.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-72787.rs:11:32 + --> $DIR/issue-72787.rs:10:32 | LL | Condition<{ LHS <= RHS }>: True | ^^^^ @@ -7,7 +7,7 @@ LL | Condition<{ LHS <= RHS }>: True = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-72787.rs:26:42 + --> $DIR/issue-72787.rs:25:42 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^^^^ @@ -15,7 +15,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-72787.rs:26:42 + --> $DIR/issue-72787.rs:25:42 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^^^^ @@ -23,7 +23,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-72787.rs:26:42 + --> $DIR/issue-72787.rs:25:42 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^^^^ @@ -31,7 +31,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-72787.rs:26:42 + --> $DIR/issue-72787.rs:25:42 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-72787.min.stderr b/src/test/ui/const-generics/issues/issue-72787.min.stderr index 27bbc28011f..aadf19ba6b6 100644 --- a/src/test/ui/const-generics/issues/issue-72787.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72787.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-72787.rs:11:17 + --> $DIR/issue-72787.rs:10:17 | LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `LHS` @@ -8,7 +8,7 @@ LL | Condition<{ LHS <= RHS }>: True = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-72787.rs:11:24 + --> $DIR/issue-72787.rs:10:24 | LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `RHS` @@ -17,7 +17,7 @@ LL | Condition<{ LHS <= RHS }>: True = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-72787.rs:26:25 + --> $DIR/issue-72787.rs:25:25 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `I` @@ -26,7 +26,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-72787.rs:26:36 + --> $DIR/issue-72787.rs:25:36 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `J` @@ -35,7 +35,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0283]: type annotations needed - --> $DIR/issue-72787.rs:22:26 + --> $DIR/issue-72787.rs:21:26 | LL | pub trait True {} | -------------- required by this bound in `True` @@ -46,7 +46,7 @@ LL | IsLessOrEqual<I, 8>: True, = note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True` error[E0283]: type annotations needed - --> $DIR/issue-72787.rs:22:26 + --> $DIR/issue-72787.rs:21:26 | LL | pub trait True {} | -------------- required by this bound in `True` diff --git a/src/test/ui/const-generics/issues/issue-72787.rs b/src/test/ui/const-generics/issues/issue-72787.rs index 57572e23aa4..16bc9470470 100644 --- a/src/test/ui/const-generics/issues/issue-72787.rs +++ b/src/test/ui/const-generics/issues/issue-72787.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>; pub struct Condition<const CONDITION: bool>; diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr index b4994004721..82f9b9d346d 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-72819-generic-in-const-eval.rs:9:39 + --> $DIR/issue-72819-generic-in-const-eval.rs:8:39 | LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr index 8df3c85ec1f..6646be47b31 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-72819-generic-in-const-eval.rs:9:17 + --> $DIR/issue-72819-generic-in-const-eval.rs:8:17 | LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs index 4c0004795f0..f612d8bd3f6 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs @@ -3,7 +3,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Arr<const N: usize> where Assert::<{N < usize::MAX / 2}>: IsTrue, diff --git a/src/test/ui/const-generics/issues/issue-73491.min.stderr b/src/test/ui/const-generics/issues/issue-73491.min.stderr index 3ff0563acc7..c8f2e0dadc1 100644 --- a/src/test/ui/const-generics/issues/issue-73491.min.stderr +++ b/src/test/ui/const-generics/issues/issue-73491.min.stderr @@ -1,11 +1,11 @@ error: `[u32; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-73491.rs:9:19 + --> $DIR/issue-73491.rs:8:19 | LL | fn hoge<const IN: [u32; LEN]>() {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-73491.rs b/src/test/ui/const-generics/issues/issue-73491.rs index 4f6c44ad2cd..c7cb92baf30 100644 --- a/src/test/ui/const-generics/issues/issue-73491.rs +++ b/src/test/ui/const-generics/issues/issue-73491.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] const LEN: usize = 1024; diff --git a/src/test/ui/const-generics/issues/issue-73508.full.stderr b/src/test/ui/const-generics/issues/issue-73508.full.stderr index 0816bad35b2..81691a14ef6 100644 --- a/src/test/ui/const-generics/issues/issue-73508.full.stderr +++ b/src/test/ui/const-generics/issues/issue-73508.full.stderr @@ -1,5 +1,5 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/issue-73508.rs:6:33 + --> $DIR/issue-73508.rs:5:33 | LL | pub const fn func_name<const X: *const u32>() {} | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-73508.min.stderr b/src/test/ui/const-generics/issues/issue-73508.min.stderr index 0816bad35b2..81691a14ef6 100644 --- a/src/test/ui/const-generics/issues/issue-73508.min.stderr +++ b/src/test/ui/const-generics/issues/issue-73508.min.stderr @@ -1,5 +1,5 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/issue-73508.rs:6:33 + --> $DIR/issue-73508.rs:5:33 | LL | pub const fn func_name<const X: *const u32>() {} | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-73508.rs b/src/test/ui/const-generics/issues/issue-73508.rs index 21b87f7f901..f02c4161dc1 100644 --- a/src/test/ui/const-generics/issues/issue-73508.rs +++ b/src/test/ui/const-generics/issues/issue-73508.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub const fn func_name<const X: *const u32>() {} //~^ ERROR using raw pointers diff --git a/src/test/ui/const-generics/issues/issue-74101.min.stderr b/src/test/ui/const-generics/issues/issue-74101.min.stderr index 1351246667e..a7f0ecf0a26 100644 --- a/src/test/ui/const-generics/issues/issue-74101.min.stderr +++ b/src/test/ui/const-generics/issues/issue-74101.min.stderr @@ -1,20 +1,20 @@ error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-74101.rs:7:18 + --> $DIR/issue-74101.rs:6:18 | LL | fn test<const N: [u8; 1 + 2]>() {} | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-74101.rs:10:21 + --> $DIR/issue-74101.rs:9:21 | LL | struct Foo<const N: [u8; 1 + 2]>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-74101.rs b/src/test/ui/const-generics/issues/issue-74101.rs index 2a7d31ac8dd..d4fd72eb6da 100644 --- a/src/test/ui/const-generics/issues/issue-74101.rs +++ b/src/test/ui/const-generics/issues/issue-74101.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn test<const N: [u8; 1 + 2]>() {} //[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter diff --git a/src/test/ui/const-generics/issues/issue-74255.min.stderr b/src/test/ui/const-generics/issues/issue-74255.min.stderr index e3e8502ae63..62ad43974f4 100644 --- a/src/test/ui/const-generics/issues/issue-74255.min.stderr +++ b/src/test/ui/const-generics/issues/issue-74255.min.stderr @@ -1,11 +1,11 @@ error: `IceEnum` is forbidden as the type of a const generic parameter - --> $DIR/issue-74255.rs:15:31 + --> $DIR/issue-74255.rs:14:31 | LL | fn ice_struct_fn<const I: IceEnum>() {} | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-74255.rs b/src/test/ui/const-generics/issues/issue-74255.rs index b277c273461..75a876c27e5 100644 --- a/src/test/ui/const-generics/issues/issue-74255.rs +++ b/src/test/ui/const-generics/issues/issue-74255.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(PartialEq, Eq)] enum IceEnum { diff --git a/src/test/ui/const-generics/issues/issue-74950.min.stderr b/src/test/ui/const-generics/issues/issue-74950.min.stderr index 12947a2ab37..4e640ff857e 100644 --- a/src/test/ui/const-generics/issues/issue-74950.min.stderr +++ b/src/test/ui/const-generics/issues/issue-74950.min.stderr @@ -1,47 +1,47 @@ error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:18:23 + --> $DIR/issue-74950.rs:17:23 | LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:18:23 + --> $DIR/issue-74950.rs:17:23 | LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:18:23 + --> $DIR/issue-74950.rs:17:23 | LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:18:23 + --> $DIR/issue-74950.rs:17:23 | LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:18:23 + --> $DIR/issue-74950.rs:17:23 | LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 5 previous errors diff --git a/src/test/ui/const-generics/issues/issue-74950.rs b/src/test/ui/const-generics/issues/issue-74950.rs index 39f91f2b83d..91e5cc776fa 100644 --- a/src/test/ui/const-generics/issues/issue-74950.rs +++ b/src/test/ui/const-generics/issues/issue-74950.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[derive(PartialEq, Eq)] diff --git a/src/test/ui/const-generics/issues/issue-75047.min.stderr b/src/test/ui/const-generics/issues/issue-75047.min.stderr index b87bb18a5a6..3c1c3ea97b5 100644 --- a/src/test/ui/const-generics/issues/issue-75047.min.stderr +++ b/src/test/ui/const-generics/issues/issue-75047.min.stderr @@ -1,11 +1,11 @@ error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/issue-75047.rs:15:21 + --> $DIR/issue-75047.rs:14:21 | LL | struct Foo<const N: [u8; Bar::<u32>::value()]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-75047.rs b/src/test/ui/const-generics/issues/issue-75047.rs index 7bab7cdd098..97437748177 100644 --- a/src/test/ui/const-generics/issues/issue-75047.rs +++ b/src/test/ui/const-generics/issues/issue-75047.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Bar<T>(T); diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr index 089937e66ca..88b8ff89ffe 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-76701-ty-param-in-const.rs:6:21 + --> $DIR/issue-76701-ty-param-in-const.rs:5:21 | LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-76701-ty-param-in-const.rs:12:37 + --> $DIR/issue-76701-ty-param-in-const.rs:11:37 | LL | fn const_param<const N: usize>() -> [u8; N + 1] { | ^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr index 551b8e43e1d..32f70fa3007 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/issue-76701-ty-param-in-const.rs:6:46 + --> $DIR/issue-76701-ty-param-in-const.rs:5:46 | LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/issue-76701-ty-param-in-const.rs:12:42 + --> $DIR/issue-76701-ty-param-in-const.rs:11:42 | LL | fn const_param<const N: usize>() -> [u8; N + 1] { | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs index 9051c36fe81..99489826563 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { //[full]~^ ERROR constant expression depends on a generic parameter diff --git a/src/test/ui/const-generics/issues/issue-80062.rs b/src/test/ui/const-generics/issues/issue-80062.rs new file mode 100644 index 00000000000..56dc53298fb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80062.rs @@ -0,0 +1,10 @@ +// Regression test for issue #80062 (fixed by `min_const_generics`) + +fn sof<T>() -> T { unimplemented!() } + +fn test<T>() { + let _: [u8; sof::<T>()]; + //~^ ERROR generic parameters may not be used in const operations +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-80062.stderr b/src/test/ui/const-generics/issues/issue-80062.stderr new file mode 100644 index 00000000000..aad8907bda2 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80062.stderr @@ -0,0 +1,11 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-80062.rs:6:23 + | +LL | let _: [u8; sof::<T>()]; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-80375.rs b/src/test/ui/const-generics/issues/issue-80375.rs new file mode 100644 index 00000000000..c906bb2c4d9 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80375.rs @@ -0,0 +1,4 @@ +struct MyArray<const COUNT: usize>([u8; COUNT + 1]); +//~^ ERROR generic parameters may not be used in const operations + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-80375.stderr b/src/test/ui/const-generics/issues/issue-80375.stderr new file mode 100644 index 00000000000..9765a639a48 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80375.stderr @@ -0,0 +1,11 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-80375.rs:1:41 + | +LL | struct MyArray<const COUNT: usize>([u8; COUNT + 1]); + | ^^^^^ cannot perform const operation using `COUNT` + | + = help: const parameters may only be used as standalone arguments, i.e. `COUNT` + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs b/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs index 28f80702dcf..189a32570f7 100644 --- a/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs +++ b/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait T<const A: usize> { fn f(); diff --git a/src/test/ui/const-generics/macro_rules-braces.full.stderr b/src/test/ui/const-generics/macro_rules-braces.full.stderr index 3c9d4c9b470..1883f454e60 100644 --- a/src/test/ui/const-generics/macro_rules-braces.full.stderr +++ b/src/test/ui/const-generics/macro_rules-braces.full.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/macro_rules-braces.rs:49:17 + --> $DIR/macro_rules-braces.rs:48:17 | LL | let _: baz!(m::P); | ^^^^ @@ -10,7 +10,7 @@ LL | let _: baz!({ m::P }); | ^ ^ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/macro_rules-braces.rs:69:17 + --> $DIR/macro_rules-braces.rs:68:17 | LL | let _: baz!(10 + 7); | ^^^^^^ @@ -21,7 +21,7 @@ LL | let _: baz!({ 10 + 7 }); | ^ ^ error: constant expression depends on a generic parameter - --> $DIR/macro_rules-braces.rs:16:13 + --> $DIR/macro_rules-braces.rs:15:13 | LL | [u8; $x] | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _: foo!({{ N }}); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: constant expression depends on a generic parameter - --> $DIR/macro_rules-braces.rs:21:13 + --> $DIR/macro_rules-braces.rs:20:13 | LL | [u8; { $x }] | ^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | let _: bar!({ N }); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: constant expression depends on a generic parameter - --> $DIR/macro_rules-braces.rs:26:13 + --> $DIR/macro_rules-braces.rs:25:13 | LL | Foo<$x> | ^^^^^^^ @@ -57,7 +57,7 @@ LL | let _: baz!({{ N }}); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: constant expression depends on a generic parameter - --> $DIR/macro_rules-braces.rs:31:13 + --> $DIR/macro_rules-braces.rs:30:13 | LL | Foo<{ $x }> | ^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/macro_rules-braces.min.stderr b/src/test/ui/const-generics/macro_rules-braces.min.stderr index c400e2c814d..60583d43c01 100644 --- a/src/test/ui/const-generics/macro_rules-braces.min.stderr +++ b/src/test/ui/const-generics/macro_rules-braces.min.stderr @@ -1,5 +1,5 @@ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/macro_rules-braces.rs:49:17 + --> $DIR/macro_rules-braces.rs:48:17 | LL | let _: baz!(m::P); | ^^^^ @@ -10,7 +10,7 @@ LL | let _: baz!({ m::P }); | ^ ^ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/macro_rules-braces.rs:69:17 + --> $DIR/macro_rules-braces.rs:68:17 | LL | let _: baz!(10 + 7); | ^^^^^^ @@ -21,7 +21,7 @@ LL | let _: baz!({ 10 + 7 }); | ^ ^ error: generic parameters may not be used in const operations - --> $DIR/macro_rules-braces.rs:37:20 + --> $DIR/macro_rules-braces.rs:36:20 | LL | let _: foo!({{ N }}); | ^ cannot perform const operation using `N` @@ -30,7 +30,7 @@ LL | let _: foo!({{ N }}); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/macro_rules-braces.rs:41:19 + --> $DIR/macro_rules-braces.rs:40:19 | LL | let _: bar!({ N }); | ^ cannot perform const operation using `N` @@ -39,7 +39,7 @@ LL | let _: bar!({ N }); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/macro_rules-braces.rs:46:20 + --> $DIR/macro_rules-braces.rs:45:20 | LL | let _: baz!({{ N }}); | ^ cannot perform const operation using `N` @@ -48,7 +48,7 @@ LL | let _: baz!({{ N }}); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/macro_rules-braces.rs:51:19 + --> $DIR/macro_rules-braces.rs:50:19 | LL | let _: biz!({ N }); | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/macro_rules-braces.rs b/src/test/ui/const-generics/macro_rules-braces.rs index c6b43bec243..605a10880bb 100644 --- a/src/test/ui/const-generics/macro_rules-braces.rs +++ b/src/test/ui/const-generics/macro_rules-braces.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] mod m { pub const P: usize = 0; diff --git a/src/test/ui/const-generics/min-and-full-same-time.rs b/src/test/ui/const-generics/min-and-full-same-time.rs deleted file mode 100644 index 2365adc3a86..00000000000 --- a/src/test/ui/const-generics/min-and-full-same-time.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(const_generics)] -//~^ ERROR features `const_generics` and `min_const_generics` are incompatible -#![allow(incomplete_features)] -#![feature(min_const_generics)] - - -fn main() {} diff --git a/src/test/ui/const-generics/min-and-full-same-time.stderr b/src/test/ui/const-generics/min-and-full-same-time.stderr deleted file mode 100644 index 907fec9bbe1..00000000000 --- a/src/test/ui/const-generics/min-and-full-same-time.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: features `const_generics` and `min_const_generics` are incompatible, using them at the same time is not allowed - --> $DIR/min-and-full-same-time.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ -... -LL | #![feature(min_const_generics)] - | ^^^^^^^^^^^^^^^^^^ - | - = help: remove one of these features - -error: aborting due to previous error - diff --git a/src/test/ui/const-generics/min_const_generics/assoc_const.rs b/src/test/ui/const-generics/min_const_generics/assoc_const.rs index fa75613d9dd..27e971b5b6f 100644 --- a/src/test/ui/const-generics/min_const_generics/assoc_const.rs +++ b/src/test/ui/const-generics/min_const_generics/assoc_const.rs @@ -1,6 +1,4 @@ // check-pass -#![feature(min_const_generics)] - struct Foo<const N: usize>; impl<const N: usize> Foo<N> { diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.rs b/src/test/ui/const-generics/min_const_generics/complex-expression.rs index 686ce98fcdf..7840989cb08 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.rs +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - use std::mem::size_of; fn test<const N: usize>() {} diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr index 2ea66279d46..17669244849 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:11:38 + --> $DIR/complex-expression.rs:9:38 | LL | struct Break0<const N: usize>([u8; { N + 1 }]); | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:14:40 + --> $DIR/complex-expression.rs:12:40 | LL | struct Break1<const N: usize>([u8; { { N } }]); | ^ cannot perform const operation using `N` @@ -17,7 +17,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:18:17 + --> $DIR/complex-expression.rs:16:17 | LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` @@ -26,7 +26,7 @@ LL | let _: [u8; N + 1]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:23:17 + --> $DIR/complex-expression.rs:21:17 | LL | let _ = [0; N + 1]; | ^ cannot perform const operation using `N` @@ -35,7 +35,7 @@ LL | let _ = [0; N + 1]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:27:45 + --> $DIR/complex-expression.rs:25:45 | LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]); | ^ cannot perform const operation using `T` @@ -44,7 +44,7 @@ LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:30:47 + --> $DIR/complex-expression.rs:28:47 | LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]); | ^ cannot perform const operation using `T` @@ -53,7 +53,7 @@ LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:34:32 + --> $DIR/complex-expression.rs:32:32 | LL | let _: [u8; size_of::<*mut T>() + 1]; | ^ cannot perform const operation using `T` @@ -62,7 +62,7 @@ LL | let _: [u8; size_of::<*mut T>() + 1]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions warning: cannot use constants which depend on generic parameters in types - --> $DIR/complex-expression.rs:39:17 + --> $DIR/complex-expression.rs:37:17 | LL | let _ = [0; size_of::<*mut T>() + 1]; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/complex-types.rs b/src/test/ui/const-generics/min_const_generics/complex-types.rs index 2aaf2c39875..057bd5af89e 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-types.rs +++ b/src/test/ui/const-generics/min_const_generics/complex-types.rs @@ -1,4 +1,3 @@ -#![feature(min_const_generics)] #![feature(never_type)] struct Foo<const N: [u8; 0]>; diff --git a/src/test/ui/const-generics/min_const_generics/complex-types.stderr b/src/test/ui/const-generics/min_const_generics/complex-types.stderr index 5d473f1f876..a658a7b3956 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-types.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-types.stderr @@ -1,65 +1,65 @@ error: `[u8; 0]` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:4:21 + --> $DIR/complex-types.rs:3:21 | LL | struct Foo<const N: [u8; 0]>; | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:7:21 + --> $DIR/complex-types.rs:6:21 | LL | struct Bar<const N: ()>; | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `No` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:12:21 + --> $DIR/complex-types.rs:11:21 | LL | struct Fez<const N: No>; | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:15:21 + --> $DIR/complex-types.rs:14:21 | LL | struct Faz<const N: &'static u8>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `!` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:18:21 + --> $DIR/complex-types.rs:17:21 | LL | struct Fiz<const N: !>; | ^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:21:19 + --> $DIR/complex-types.rs:20:19 | LL | enum Goo<const N: ()> { A, B } | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:24:20 + --> $DIR/complex-types.rs:23:20 | LL | union Boo<const N: ()> { a: () } | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 7 previous errors diff --git a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs index dd82be33a8e..71d13ca61c9 100644 --- a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs +++ b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs @@ -1,5 +1,4 @@ // check-pass -#![feature(min_const_generics)] #![allow(dead_code)] fn foo<T>() { diff --git a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr index 4d0cab012f9..f9f6660f6b8 100644 --- a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr @@ -1,5 +1,5 @@ warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:6:9 + --> $DIR/const-evaluatable-unchecked.rs:5:9 | LL | [0; std::mem::size_of::<*mut T>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | [0; std::mem::size_of::<*mut T>()]; = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200> warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:17:21 + --> $DIR/const-evaluatable-unchecked.rs:16:21 | LL | let _ = [0; Self::ASSOC]; | ^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = [0; Self::ASSOC]; = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200> warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:29:21 + --> $DIR/const-evaluatable-unchecked.rs:28:21 | LL | let _ = [0; Self::ASSOC]; | ^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.rs b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.rs index b9afd226430..fac3777cf21 100644 --- a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.rs +++ b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - fn foo<const C: usize>() {} const BAR: usize = 42; diff --git a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr index 13742238a20..beea0acac60 100644 --- a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr @@ -1,5 +1,5 @@ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:8:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:6:8 | LL | foo<BAR + 3>(); | ^ ^ @@ -10,7 +10,7 @@ LL | foo::<BAR + 3>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:11:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:9:8 | LL | foo<BAR + BAR>(); | ^ ^ @@ -21,7 +21,7 @@ LL | foo::<BAR + BAR>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:14:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:12:8 | LL | foo<3 + 3>(); | ^ ^ @@ -32,7 +32,7 @@ LL | foo::<3 + 3>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:17:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:15:8 | LL | foo<BAR - 3>(); | ^ ^ @@ -43,7 +43,7 @@ LL | foo::<BAR - 3>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:20:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:18:8 | LL | foo<BAR - BAR>(); | ^ ^ @@ -54,7 +54,7 @@ LL | foo::<BAR - BAR>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:23:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:21:8 | LL | foo<100 - BAR>(); | ^ ^ @@ -65,7 +65,7 @@ LL | foo::<100 - BAR>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:26:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:24:8 | LL | foo<bar<i32>()>(); | ^ ^ @@ -76,13 +76,13 @@ LL | foo::<bar<i32>()>(); | ^^ error: expected one of `;` or `}`, found `>` - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:26:19 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:24:19 | LL | foo<bar<i32>()>(); | ^ expected one of `;` or `}` error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:30:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:28:8 | LL | foo<bar::<i32>()>(); | ^ ^ @@ -93,7 +93,7 @@ LL | foo::<bar::<i32>()>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:33:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:31:8 | LL | foo<bar::<i32>() + BAR>(); | ^ ^ @@ -104,7 +104,7 @@ LL | foo::<bar::<i32>() + BAR>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:36:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:34:8 | LL | foo<bar::<i32>() - BAR>(); | ^ ^ @@ -115,7 +115,7 @@ LL | foo::<bar::<i32>() - BAR>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:39:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:37:8 | LL | foo<BAR - bar::<i32>()>(); | ^ ^ @@ -126,7 +126,7 @@ LL | foo::<BAR - bar::<i32>()>(); | ^^ error: comparison operators cannot be chained - --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:42:8 + --> $DIR/const-expression-suggest-missing-braces-without-turbofish.rs:40:8 | LL | foo<BAR - bar::<i32>()>(); | ^ ^ diff --git a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs index b96d5c561ff..f8b9d7adbfe 100644 --- a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs +++ b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - fn foo<const C: usize>() {} const BAR: usize = 42; diff --git a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr index 6adcf6a3e36..ad451fcf65d 100644 --- a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr @@ -1,5 +1,5 @@ error: expected one of `,` or `>`, found `3` - --> $DIR/const-expression-suggest-missing-braces.rs:8:17 + --> $DIR/const-expression-suggest-missing-braces.rs:6:17 | LL | foo::<BAR + 3>(); | ^ expected one of `,` or `>` @@ -10,7 +10,7 @@ LL | foo::<{ BAR + 3 }>(); | ^ ^ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/const-expression-suggest-missing-braces.rs:20:11 + --> $DIR/const-expression-suggest-missing-braces.rs:18:11 | LL | foo::<3 + 3>(); | ^^^^^ @@ -21,7 +21,7 @@ LL | foo::<{ 3 + 3 }>(); | ^ ^ error: expected one of `,` or `>`, found `-` - --> $DIR/const-expression-suggest-missing-braces.rs:23:15 + --> $DIR/const-expression-suggest-missing-braces.rs:21:15 | LL | foo::<BAR - 3>(); | ^ expected one of `,` or `>` @@ -32,7 +32,7 @@ LL | foo::<{ BAR - 3 }>(); | ^ ^ error: expected one of `,` or `>`, found `-` - --> $DIR/const-expression-suggest-missing-braces.rs:26:15 + --> $DIR/const-expression-suggest-missing-braces.rs:24:15 | LL | foo::<BAR - BAR>(); | ^ expected one of `,` or `>` @@ -43,7 +43,7 @@ LL | foo::<{ BAR - BAR }>(); | ^ ^ error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/const-expression-suggest-missing-braces.rs:29:11 + --> $DIR/const-expression-suggest-missing-braces.rs:27:11 | LL | foo::<100 - BAR>(); | ^^^^^^^^^ @@ -54,7 +54,7 @@ LL | foo::<{ 100 - BAR }>(); | ^ ^ error: expected one of `,` or `>`, found `(` - --> $DIR/const-expression-suggest-missing-braces.rs:32:19 + --> $DIR/const-expression-suggest-missing-braces.rs:30:19 | LL | foo::<bar<i32>()>(); | ^ expected one of `,` or `>` @@ -65,7 +65,7 @@ LL | foo::<{ bar<i32>() }>(); | ^ ^ error: expected one of `,` or `>`, found `(` - --> $DIR/const-expression-suggest-missing-braces.rs:35:21 + --> $DIR/const-expression-suggest-missing-braces.rs:33:21 | LL | foo::<bar::<i32>()>(); | ^ expected one of `,` or `>` @@ -76,7 +76,7 @@ LL | foo::<{ bar::<i32>() }>(); | ^ ^ error: expected one of `,` or `>`, found `(` - --> $DIR/const-expression-suggest-missing-braces.rs:38:21 + --> $DIR/const-expression-suggest-missing-braces.rs:36:21 | LL | foo::<bar::<i32>() + BAR>(); | ^ expected one of `,` or `>` @@ -87,7 +87,7 @@ LL | foo::<{ bar::<i32>() + BAR }>(); | ^ ^ error: expected one of `,` or `>`, found `(` - --> $DIR/const-expression-suggest-missing-braces.rs:41:21 + --> $DIR/const-expression-suggest-missing-braces.rs:39:21 | LL | foo::<bar::<i32>() - BAR>(); | ^ expected one of `,` or `>` @@ -98,7 +98,7 @@ LL | foo::<{ bar::<i32>() - BAR }>(); | ^ ^ error: expected one of `,` or `>`, found `-` - --> $DIR/const-expression-suggest-missing-braces.rs:44:15 + --> $DIR/const-expression-suggest-missing-braces.rs:42:15 | LL | foo::<BAR - bar::<i32>()>(); | ^ expected one of `,` or `>` @@ -109,7 +109,7 @@ LL | foo::<{ BAR - bar::<i32>() }>(); | ^ ^ error: expected one of `,` or `>`, found `-` - --> $DIR/const-expression-suggest-missing-braces.rs:47:15 + --> $DIR/const-expression-suggest-missing-braces.rs:45:15 | LL | foo::<BAR - bar::<i32>()>(); | ^ expected one of `,` or `>` @@ -120,19 +120,19 @@ LL | foo::<{ BAR - bar::<i32>() }>(); | ^ ^ error[E0404]: expected trait, found constant `BAR` - --> $DIR/const-expression-suggest-missing-braces.rs:13:11 + --> $DIR/const-expression-suggest-missing-braces.rs:11:11 | LL | foo::<BAR + BAR>(); | ^^^ not a trait error[E0404]: expected trait, found constant `BAR` - --> $DIR/const-expression-suggest-missing-braces.rs:13:17 + --> $DIR/const-expression-suggest-missing-braces.rs:11:17 | LL | foo::<BAR + BAR>(); | ^^^ not a trait warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/const-expression-suggest-missing-braces.rs:13:11 + --> $DIR/const-expression-suggest-missing-braces.rs:11:11 | LL | foo::<BAR + BAR>(); | ^^^^^^^^^ help: use `dyn`: `dyn BAR + BAR` @@ -140,7 +140,7 @@ LL | foo::<BAR + BAR>(); = note: `#[warn(bare_trait_objects)]` on by default error[E0747]: type provided when a constant was expected - --> $DIR/const-expression-suggest-missing-braces.rs:13:11 + --> $DIR/const-expression-suggest-missing-braces.rs:11:11 | LL | foo::<BAR + BAR>(); | ^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs index 3370666cc5c..0c10af6c43f 100644 --- a/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs +++ b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs @@ -1,7 +1,5 @@ // run-pass -#![feature(min_const_generics)] - const fn identity<const T: u32>() -> u32 { T } #[derive(Eq, PartialEq, Debug)] diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs index 7e0c1c2ed9f..5b0a42a4556 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs @@ -1,6 +1,4 @@ -#![feature(min_const_generics)] - fn foo<const SIZE: usize = 5>() {} - //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` +//~^ ERROR default values for const generic parameters are experimental fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr index ed1a83b6a4d..31b5ad5123e 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,8 +1,12 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` - --> $DIR/default_function_param.rs:3:26 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/default_function_param.rs:1:26 | LL | fn foo<const SIZE: usize = 5>() {} - | ^ expected one of 7 possible tokens + | ^^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs index 322ddccbf18..14bac473ed9 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs @@ -1,6 +1,4 @@ -#![feature(min_const_generics)] - trait Foo<const KIND: bool = true> {} - //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` +//~^ ERROR default values for const generic parameters are experimental fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr index 49c3ac86744..5617b35ad01 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr @@ -1,8 +1,12 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` - --> $DIR/default_trait_param.rs:3:28 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/default_trait_param.rs:1:28 | LL | trait Foo<const KIND: bool = true> {} - | ^ expected one of 7 possible tokens + | ^^^^^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.rs b/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.rs deleted file mode 100644 index 423deae4600..00000000000 --- a/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn test<const N: usize>() {} -//~^ ERROR const generics are unstable - -fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.stderr b/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.stderr deleted file mode 100644 index 7f82a960da2..00000000000 --- a/src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: const generics are unstable - --> $DIR/feature-gate-min_const_generics.rs:1:15 - | -LL | fn test<const N: usize>() {} - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs index 02944e2bff2..881f8b98aad 100644 --- a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs +++ b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - // This test checks that non-static lifetimes are prohibited under `min_const_generics`. It // currently emits an error with `min_const_generics`. This will ICE under `const_generics`. diff --git a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr index cdfd491e395..5def54ca26d 100644 --- a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr +++ b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr @@ -1,5 +1,5 @@ error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/forbid-non-static-lifetimes.rs:9:22 + --> $DIR/forbid-non-static-lifetimes.rs:7:22 | LL | test::<{ let _: &'a (); 3 },>(); | ^^ @@ -8,7 +8,7 @@ LL | test::<{ let _: &'a (); 3 },>(); = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/forbid-non-static-lifetimes.rs:23:16 + --> $DIR/forbid-non-static-lifetimes.rs:21:16 | LL | [(); (|_: &'a u8| (), 0).1]; | ^^ diff --git a/src/test/ui/const-generics/min_const_generics/invalid-patterns.rs b/src/test/ui/const-generics/min_const_generics/invalid-patterns.rs index e59b97922be..a120eee67ee 100644 --- a/src/test/ui/const-generics/min_const_generics/invalid-patterns.rs +++ b/src/test/ui/const-generics/min_const_generics/invalid-patterns.rs @@ -1,4 +1,3 @@ -#![feature(min_const_generics)] use std::mem::transmute; fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> { diff --git a/src/test/ui/const-generics/min_const_generics/invalid-patterns.stderr b/src/test/ui/const-generics/min_const_generics/invalid-patterns.stderr index a3157c6b564..04f716fa733 100644 --- a/src/test/ui/const-generics/min_const_generics/invalid-patterns.stderr +++ b/src/test/ui/const-generics/min_const_generics/invalid-patterns.stderr @@ -1,29 +1,29 @@ error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:29:21 + --> $DIR/invalid-patterns.rs:28:21 | LL | get_flag::<false, 0xFF>(); | ^^^^ expected `char`, found `u8` error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:31:14 + --> $DIR/invalid-patterns.rs:30:14 | LL | get_flag::<7, 'c'>(); | ^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:14 + --> $DIR/invalid-patterns.rs:32:14 | LL | get_flag::<42, 0x5ad>(); | ^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:18 + --> $DIR/invalid-patterns.rs:32:18 | LL | get_flag::<42, 0x5ad>(); | ^^^^^ expected `char`, found `u8` error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:38:21 + --> $DIR/invalid-patterns.rs:37:21 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -31,7 +31,7 @@ LL | get_flag::<false, { unsafe { char_raw.character } }>(); = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:40:14 + --> $DIR/invalid-patterns.rs:39:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x42, but expected a boolean @@ -39,7 +39,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:42:14 + --> $DIR/invalid-patterns.rs:41:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x42, but expected a boolean @@ -47,7 +47,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:42:47 + --> $DIR/invalid-patterns.rs:41:47 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) diff --git a/src/test/ui/const-generics/min_const_generics/macro-fail.rs b/src/test/ui/const-generics/min_const_generics/macro-fail.rs index 1bd0c46f55e..f83518fc9d4 100644 --- a/src/test/ui/const-generics/min_const_generics/macro-fail.rs +++ b/src/test/ui/const-generics/min_const_generics/macro-fail.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - struct Example<const N: usize>; macro_rules! external_macro { diff --git a/src/test/ui/const-generics/min_const_generics/macro-fail.stderr b/src/test/ui/const-generics/min_const_generics/macro-fail.stderr index a5dedf6fe20..22930a352a8 100644 --- a/src/test/ui/const-generics/min_const_generics/macro-fail.stderr +++ b/src/test/ui/const-generics/min_const_generics/macro-fail.stderr @@ -1,5 +1,5 @@ error: expected type, found `{` - --> $DIR/macro-fail.rs:31:27 + --> $DIR/macro-fail.rs:29:27 | LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> { | ---------------------- @@ -13,7 +13,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: expected type, found `{` - --> $DIR/macro-fail.rs:31:27 + --> $DIR/macro-fail.rs:29:27 | LL | Example::<gimme_a_const!(marker)> | ---------------------- @@ -27,7 +27,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: expected type, found `{` - --> $DIR/macro-fail.rs:6:10 + --> $DIR/macro-fail.rs:4:10 | LL | () => {{ | __________^ @@ -46,7 +46,7 @@ LL | let _fail = Example::<external_macro!()>; = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: unexpected end of macro invocation - --> $DIR/macro-fail.rs:41:25 + --> $DIR/macro-fail.rs:39:25 | LL | macro_rules! gimme_a_const { | -------------------------- when calling this macro @@ -55,25 +55,25 @@ LL | let _fail = Example::<gimme_a_const!()>; | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:16:33 + --> $DIR/macro-fail.rs:14:33 | LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> { | ^^^^^^^^^^^^^^^^^^^^^^ error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:18:13 + --> $DIR/macro-fail.rs:16:13 | LL | Example::<gimme_a_const!(marker)> | ^^^^^^^^^^^^^^^^^^^^^^ error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:38:25 + --> $DIR/macro-fail.rs:36:25 | LL | let _fail = Example::<external_macro!()>; | ^^^^^^^^^^^^^^^^^ error[E0747]: type provided when a constant was expected - --> $DIR/macro-fail.rs:41:25 + --> $DIR/macro-fail.rs:39:25 | LL | let _fail = Example::<gimme_a_const!()>; | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/macro.rs b/src/test/ui/const-generics/min_const_generics/macro.rs index 575fbd33572..9b63f76987a 100644 --- a/src/test/ui/const-generics/min_const_generics/macro.rs +++ b/src/test/ui/const-generics/min_const_generics/macro.rs @@ -1,6 +1,4 @@ // run-pass -#![feature(min_const_generics)] - struct Example<const N: usize>; macro_rules! external_macro { diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.rs b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.rs index 0973b373c12..9ef619365a0 100644 --- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.rs +++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - trait Foo { fn t1() -> [u8; std::mem::size_of::<Self>()]; //~ERROR generic parameters } diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr index 40c73f0b951..4fdfb5fbcb1 100644 --- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr +++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/self-ty-in-const-1.rs:4:41 + --> $DIR/self-ty-in-const-1.rs:2:41 | LL | fn t1() -> [u8; std::mem::size_of::<Self>()]; | ^^^^ cannot perform const operation using `Self` @@ -8,13 +8,13 @@ LL | fn t1() -> [u8; std::mem::size_of::<Self>()]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/self-ty-in-const-1.rs:14:41 + --> $DIR/self-ty-in-const-1.rs:12:41 | LL | fn t3() -> [u8; std::mem::size_of::<Self>()] {} | ^^^^ | note: not a concrete type - --> $DIR/self-ty-in-const-1.rs:13:9 + --> $DIR/self-ty-in-const-1.rs:11:9 | LL | impl<T> Bar<T> { | ^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.rs b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.rs index e7f80d50082..286ec2d2450 100644 --- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.rs +++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - struct Bar<T>(T); trait Baz { diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.stderr b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.stderr index 9ac6410a290..41546292c47 100644 --- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.stderr +++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-2.stderr @@ -1,11 +1,11 @@ error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/self-ty-in-const-2.rs:17:41 + --> $DIR/self-ty-in-const-2.rs:15:41 | LL | let _: [u8; std::mem::size_of::<Self>()]; | ^^^^ | note: not a concrete type - --> $DIR/self-ty-in-const-2.rs:15:17 + --> $DIR/self-ty-in-const-2.rs:13:17 | LL | impl<T> Baz for Bar<T> { | ^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs index 0ef17109bed..7518dc59e59 100644 --- a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs +++ b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - fn a<const X: &'static [u32]>() {} //~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr index 6c39f6b4c1d..647ef5400cb 100644 --- a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr +++ b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr @@ -1,11 +1,11 @@ error: `&'static [u32]` is forbidden as the type of a const generic parameter - --> $DIR/static-reference-array-const-param.rs:3:15 + --> $DIR/static-reference-array-const-param.rs:1:15 | LL | fn a<const X: &'static [u32]>() {} | ^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs index dfa1ece2f36..560795a51f5 100644 --- a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs +++ b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs @@ -1,5 +1,3 @@ -#![feature(min_const_generics)] - struct Const<const P: &'static ()>; //~^ ERROR `&'static ()` is forbidden as the type of a const generic parameter diff --git a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr index 6b90329b72c..d612e0c35a1 100644 --- a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr +++ b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr @@ -1,11 +1,11 @@ error: `&'static ()` is forbidden as the type of a const generic parameter - --> $DIR/transmute-const-param-static-reference.rs:3:23 + --> $DIR/transmute-const-param-static-reference.rs:1:23 | LL | struct Const<const P: &'static ()>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to previous error diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.rs b/src/test/ui/const-generics/mut-ref-const-param-array.rs index cf24cbe7e82..6a5739db3ae 100644 --- a/src/test/ui/const-generics/mut-ref-const-param-array.rs +++ b/src/test/ui/const-generics/mut-ref-const-param-array.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::ops::AddAssign; diff --git a/src/test/ui/const-generics/nested-type.full.stderr b/src/test/ui/const-generics/nested-type.full.stderr index 06ab9a6ff29..9d7ca36545c 100644 --- a/src/test/ui/const-generics/nested-type.full.stderr +++ b/src/test/ui/const-generics/nested-type.full.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/nested-type.rs:16:5 + --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/nested-type.min.stderr b/src/test/ui/const-generics/nested-type.min.stderr index 369e387508e..6defd393ba0 100644 --- a/src/test/ui/const-generics/nested-type.min.stderr +++ b/src/test/ui/const-generics/nested-type.min.stderr @@ -1,5 +1,5 @@ error: `[u8; _]` is forbidden as the type of a const generic parameter - --> $DIR/nested-type.rs:7:21 + --> $DIR/nested-type.rs:6:21 | LL | struct Foo<const N: [u8; { | _____________________^ @@ -12,10 +12,10 @@ LL | | }]>; | |__^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/nested-type.rs:16:5 + --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/nested-type.rs b/src/test/ui/const-generics/nested-type.rs index c5660983985..be8ebb7f401 100644 --- a/src/test/ui/const-generics/nested-type.rs +++ b/src/test/ui/const-generics/nested-type.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden struct Foo<const N: usize>; diff --git a/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr b/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr index 8a1462c59e8..671f1103dcc 100644 --- a/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr +++ b/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: constant expression depends on a generic parameter --> $DIR/unify-fixpoint.rs:9:32 diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr index 3dccfd73dcc..debb272da36 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr @@ -1,5 +1,5 @@ error: type parameters with a default must be trailing - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:12 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:12 | LL | struct Bar<T = [u8; N], const N: usize>(T); | ^ @@ -7,13 +7,13 @@ LL | struct Bar<T = [u8; N], const N: usize>(T); = note: using type defaults and const parameters in the same parameter list is currently not permitted error: constant values inside of type parameter defaults must not depend on generic parameters - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:6:44 | LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); | ^ the anonymous constant must not depend on the parameter `T` error: constant values inside of type parameter defaults must not depend on generic parameters - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:21 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:21 | LL | struct Bar<T = [u8; N], const N: usize>(T); | ^ the anonymous constant must not depend on the parameter `N` diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr index 9e0837a0a62..171efca1938 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr @@ -1,5 +1,5 @@ error: type parameters with a default must be trailing - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:12 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:12 | LL | struct Bar<T = [u8; N], const N: usize>(T); | ^ @@ -7,7 +7,7 @@ LL | struct Bar<T = [u8; N], const N: usize>(T); = note: using type defaults and const parameters in the same parameter list is currently not permitted error: generic parameters may not be used in const operations - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:6:44 | LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); | ^ cannot perform const operation using `T` @@ -16,7 +16,7 @@ LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: constant values inside of type parameter defaults must not depend on generic parameters - --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:21 + --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:21 | LL | struct Bar<T = [u8; N], const N: usize>(T); | ^ the anonymous constant must not depend on the parameter `N` diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs index 51f0cff3f21..a85e2a2f2c4 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs @@ -2,13 +2,12 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); //[full]~^ ERROR constant values inside of type parameter defaults //[min]~^^ ERROR generic parameters may not be used in const operations -// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults. +// FIXME(const_generics_defaults): We still don't know how to deal with type defaults. struct Bar<T = [u8; N], const N: usize>(T); //~^ ERROR constant values inside of type parameter defaults //~| ERROR type parameters with a default diff --git a/src/test/ui/const-generics/promotion.rs b/src/test/ui/const-generics/promotion.rs index ac568bb75f0..ce9a1a0feb4 100644 --- a/src/test/ui/const-generics/promotion.rs +++ b/src/test/ui/const-generics/promotion.rs @@ -1,7 +1,5 @@ // run-pass // tests that promoting expressions containing const parameters is allowed. -#![feature(min_const_generics)] - fn promotion_test<const N: usize>() -> &'static usize { &(3 + N) } diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr b/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr index ffaab51f766..04bc46cb4ab 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr @@ -1,11 +1,11 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param-deref.rs:10:23 + --> $DIR/raw-ptr-const-param-deref.rs:9:23 | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param-deref.rs:12:15 + --> $DIR/raw-ptr-const-param-deref.rs:11:15 | LL | impl<const P: *const u32> Const<P> { | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr b/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr index ffaab51f766..04bc46cb4ab 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr @@ -1,11 +1,11 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param-deref.rs:10:23 + --> $DIR/raw-ptr-const-param-deref.rs:9:23 | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param-deref.rs:12:15 + --> $DIR/raw-ptr-const-param-deref.rs:11:15 | LL | impl<const P: *const u32> Const<P> { | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs index 20cc62ebc17..ca7d33c0eb9 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] const A: u32 = 3; diff --git a/src/test/ui/const-generics/raw-ptr-const-param.full.stderr b/src/test/ui/const-generics/raw-ptr-const-param.full.stderr index d317aa0f585..310422aafcd 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.full.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param.full.stderr @@ -1,5 +1,5 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param.rs:7:23 + --> $DIR/raw-ptr-const-param.rs:6:23 | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/raw-ptr-const-param.min.stderr b/src/test/ui/const-generics/raw-ptr-const-param.min.stderr index d317aa0f585..310422aafcd 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.min.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param.min.stderr @@ -1,5 +1,5 @@ error: using raw pointers as const generic parameters is forbidden - --> $DIR/raw-ptr-const-param.rs:7:23 + --> $DIR/raw-ptr-const-param.rs:6:23 | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/raw-ptr-const-param.rs b/src/test/ui/const-generics/raw-ptr-const-param.rs index 36e593aa210..a04c6d5e64e 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.rs +++ b/src/test/ui/const-generics/raw-ptr-const-param.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.full.stderr b/src/test/ui/const-generics/slice-const-param-mismatch.full.stderr index d06da2ef063..80dd1be33c2 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.full.stderr +++ b/src/test/ui/const-generics/slice-const-param-mismatch.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/slice-const-param-mismatch.rs:15:35 + --> $DIR/slice-const-param-mismatch.rs:14:35 | LL | let _: ConstString<"Hello"> = ConstString::<"World">; | -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"` @@ -10,7 +10,7 @@ LL | let _: ConstString<"Hello"> = ConstString::<"World">; found struct `ConstString<"World">` error[E0308]: mismatched types - --> $DIR/slice-const-param-mismatch.rs:17:33 + --> $DIR/slice-const-param-mismatch.rs:16:33 | LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; | ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"` @@ -21,7 +21,7 @@ LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; found struct `ConstString<"ℇ㇈↥">` error[E0308]: mismatched types - --> $DIR/slice-const-param-mismatch.rs:19:33 + --> $DIR/slice-const-param-mismatch.rs:18:33 | LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; | ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"` diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr b/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr index 46997fed770..166a35ee455 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr +++ b/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr @@ -1,20 +1,20 @@ error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/slice-const-param-mismatch.rs:8:29 + --> $DIR/slice-const-param-mismatch.rs:7:29 | LL | struct ConstString<const T: &'static str>; | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static [u8]` is forbidden as the type of a const generic parameter - --> $DIR/slice-const-param-mismatch.rs:10:28 + --> $DIR/slice-const-param-mismatch.rs:9:28 | LL | struct ConstBytes<const T: &'static [u8]>; | ^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.rs b/src/test/ui/const-generics/slice-const-param-mismatch.rs index 0f8ae9bac4a..f020e2bf66f 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.rs +++ b/src/test/ui/const-generics/slice-const-param-mismatch.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct ConstString<const T: &'static str>; diff --git a/src/test/ui/const-generics/slice-const-param.min.stderr b/src/test/ui/const-generics/slice-const-param.min.stderr index 7a9f65233e7..ed39a0c56b4 100644 --- a/src/test/ui/const-generics/slice-const-param.min.stderr +++ b/src/test/ui/const-generics/slice-const-param.min.stderr @@ -1,20 +1,20 @@ error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/slice-const-param.rs:8:40 + --> $DIR/slice-const-param.rs:7:40 | LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str { | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static [u8]` is forbidden as the type of a const generic parameter - --> $DIR/slice-const-param.rs:13:41 + --> $DIR/slice-const-param.rs:12:41 | LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { | ^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/slice-const-param.rs b/src/test/ui/const-generics/slice-const-param.rs index f76e948c4af..bf1bf8af922 100644 --- a/src/test/ui/const-generics/slice-const-param.rs +++ b/src/test/ui/const-generics/slice-const-param.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub fn function_with_str<const STRING: &'static str>() -> &'static str { //[min]~^ ERROR `&'static str` is forbidden diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr index 9274ccd2b92..86e6159fdb5 100644 --- a/src/test/ui/const-generics/std/const-generics-range.min.stderr +++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr @@ -1,56 +1,56 @@ error: `std::ops::Range<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:8:24 + --> $DIR/const-generics-range.rs:7:24 | LL | struct _Range<const R: std::ops::Range<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:13:28 + --> $DIR/const-generics-range.rs:12:28 | LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `RangeFull` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:18:28 + --> $DIR/const-generics-range.rs:17:28 | LL | struct _RangeFull<const R: std::ops::RangeFull>; | ^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:24:33 + --> $DIR/const-generics-range.rs:23:33 | LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `RangeTo<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:29:26 + --> $DIR/const-generics-range.rs:28:26 | LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:34:35 + --> $DIR/const-generics-range.rs:33:35 | LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 6 previous errors diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs index 136ac352890..deaab830e91 100644 --- a/src/test/ui/const-generics/std/const-generics-range.rs +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // `Range` should be usable within const generics: struct _Range<const R: std::ops::Range<usize>>; diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr index e73a297c878..db998033c0a 100644 --- a/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr @@ -1,5 +1,5 @@ error[E0573]: expected type, found const parameter `C` - --> $DIR/struct-with-invalid-const-param.rs:8:23 + --> $DIR/struct-with-invalid-const-param.rs:7:23 | LL | struct S<const C: u8>(C); | ^ not a type diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr index e73a297c878..db998033c0a 100644 --- a/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr @@ -1,5 +1,5 @@ error[E0573]: expected type, found const parameter `C` - --> $DIR/struct-with-invalid-const-param.rs:8:23 + --> $DIR/struct-with-invalid-const-param.rs:7:23 | LL | struct S<const C: u8>(C); | ^ not a type diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.rs b/src/test/ui/const-generics/struct-with-invalid-const-param.rs index f0122ace3ae..32970ccaa5d 100644 --- a/src/test/ui/const-generics/struct-with-invalid-const-param.rs +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct S<const C: u8>(C); //~ ERROR expected type, found const parameter diff --git a/src/test/ui/const-generics/suggest_const_for_array.rs b/src/test/ui/const-generics/suggest_const_for_array.rs new file mode 100644 index 00000000000..f3e5a3186cd --- /dev/null +++ b/src/test/ui/const-generics/suggest_const_for_array.rs @@ -0,0 +1,10 @@ +#![crate_type = "lib"] + +fn example<const N: usize>() {} + +fn other() { + example::<[usize; 3]>(); + //~^ ERROR type provided when a const + example::<[usize; 4+5]>(); + //~^ ERROR type provided when a const +} diff --git a/src/test/ui/const-generics/suggest_const_for_array.stderr b/src/test/ui/const-generics/suggest_const_for_array.stderr new file mode 100644 index 00000000000..a617bf2bb0d --- /dev/null +++ b/src/test/ui/const-generics/suggest_const_for_array.stderr @@ -0,0 +1,15 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:6:13 + | +LL | example::<[usize; 3]>(); + | ^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 3 }` + +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:8:13 + | +LL | example::<[usize; 4+5]>(); + | ^^^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 4+5 }` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/trait-const-args.rs b/src/test/ui/const-generics/trait-const-args.rs index b66d79845f9..30d05c708e1 100644 --- a/src/test/ui/const-generics/trait-const-args.rs +++ b/src/test/ui/const-generics/trait-const-args.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Const<const N: usize>; trait Foo<const N: usize> {} diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs index e041e9709d0..bf855d4dcaa 100644 --- a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs +++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::mem::MaybeUninit; diff --git a/src/test/ui/const-generics/type-after-const-ok.min.stderr b/src/test/ui/const-generics/type-after-const-ok.min.stderr index 67a44d2c5b4..ad38754c741 100644 --- a/src/test/ui/const-generics/type-after-const-ok.min.stderr +++ b/src/test/ui/const-generics/type-after-const-ok.min.stderr @@ -1,5 +1,5 @@ error: type parameters must be declared prior to const parameters - --> $DIR/type-after-const-ok.rs:9:26 + --> $DIR/type-after-const-ok.rs:8:26 | LL | struct A<const N: usize, T>(T); | -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` diff --git a/src/test/ui/const-generics/type-after-const-ok.rs b/src/test/ui/const-generics/type-after-const-ok.rs index 69227cdf19c..920c067dc1a 100644 --- a/src/test/ui/const-generics/type-after-const-ok.rs +++ b/src/test/ui/const-generics/type-after-const-ok.rs @@ -3,7 +3,6 @@ // Verifies that having generic parameters after constants is permitted #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #[allow(dead_code)] struct A<const N: usize, T>(T); diff --git a/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs b/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs index aa85376bf0d..cd9c3ae7bbc 100644 --- a/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs +++ b/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub struct Struct<const N: usize>(()); diff --git a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs index 3ccdd472613..4997d493bbb 100644 --- a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs +++ b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs @@ -1,7 +1,6 @@ // run-pass // revisions: full min #![cfg_attr(full, feature(const_generics))] -#![cfg_attr(min, feature(min_const_generics))] #![allow(incomplete_features)] struct Foo; diff --git a/src/test/ui/const-generics/type-dependent/issue-61936.rs b/src/test/ui/const-generics/type-dependent/issue-61936.rs index f3b19109a7c..417fe2501ae 100644 --- a/src/test/ui/const-generics/type-dependent/issue-61936.rs +++ b/src/test/ui/const-generics/type-dependent/issue-61936.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait SliceExt<T: Clone> { fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N>; diff --git a/src/test/ui/const-generics/type-dependent/issue-63695.rs b/src/test/ui/const-generics/type-dependent/issue-63695.rs index 465b66b09ce..2ece25bb41b 100644 --- a/src/test/ui/const-generics/type-dependent/issue-63695.rs +++ b/src/test/ui/const-generics/type-dependent/issue-63695.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait T { fn test<const A: i32>(&self) -> i32 { A } diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs index 3d4910e9e4b..4a2c303095e 100644 --- a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs +++ b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct X; diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs index 0868d309b33..a1163fca8d4 100644 --- a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs +++ b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize>; diff --git a/src/test/ui/const-generics/type-dependent/issue-69816.rs b/src/test/ui/const-generics/type-dependent/issue-69816.rs index 4a374dc1db6..75ddd839f66 100644 --- a/src/test/ui/const-generics/type-dependent/issue-69816.rs +++ b/src/test/ui/const-generics/type-dependent/issue-69816.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait IterExt: Sized + Iterator { fn default_for_size<const N: usize>(self) -> [Self::Item; N] diff --git a/src/test/ui/const-generics/type-dependent/issue-70217.rs b/src/test/ui/const-generics/type-dependent/issue-70217.rs index ba5a42e47e9..b3585d5fc10 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70217.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70217.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Struct<const N: usize>; diff --git a/src/test/ui/const-generics/type-dependent/issue-70507.rs b/src/test/ui/const-generics/type-dependent/issue-70507.rs index 234c09e04ae..df7c277f605 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70507.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70507.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait ConstChunksExactTrait<T> { fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'_, T, {N}>; diff --git a/src/test/ui/const-generics/type-dependent/issue-70586.rs b/src/test/ui/const-generics/type-dependent/issue-70586.rs index fd52373cee2..5fb571f2394 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70586.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70586.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::marker::PhantomData; diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr index 8f240f0d930..f3516d1de96 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr +++ b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -1,20 +1,20 @@ error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/issue-71348.rs:11:24 + --> $DIR/issue-71348.rs:10:24 | LL | trait Get<'a, const N: &'static str> { | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: `&'static str` is forbidden as the type of a const generic parameter - --> $DIR/issue-71348.rs:19:25 + --> $DIR/issue-71348.rs:18:25 | LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#[feature(const_generics)]` + = help: more complex types are supported with `#![feature(const_generics)]` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.rs b/src/test/ui/const-generics/type-dependent/issue-71348.rs index 772e179746d..33735ef87c5 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71348.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71348.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Foo { i: i32, diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr index da1d3270b7c..8ac9bab6320 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr +++ b/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:17:23 + --> $DIR/issue-71382.rs:16:23 | LL | fn test<const FN: fn() -> u8>(&self) -> u8 { | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr index da1d3270b7c..8ac9bab6320 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr +++ b/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:17:23 + --> $DIR/issue-71382.rs:16:23 | LL | fn test<const FN: fn() -> u8>(&self) -> u8 { | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.rs b/src/test/ui/const-generics/type-dependent/issue-71382.rs index 497fd1381de..b3677613dbc 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71382.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71382.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct Test; diff --git a/src/test/ui/const-generics/type-dependent/issue-71805.rs b/src/test/ui/const-generics/type-dependent/issue-71805.rs index 2aaf12cea4f..3701e14eadc 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71805.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71805.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::mem::MaybeUninit; diff --git a/src/test/ui/const-generics/type-dependent/issue-73730.rs b/src/test/ui/const-generics/type-dependent/issue-73730.rs index 3e53190ee48..5d7dcb9c458 100644 --- a/src/test/ui/const-generics/type-dependent/issue-73730.rs +++ b/src/test/ui/const-generics/type-dependent/issue-73730.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Foo<'a, A>: Iterator<Item=A> { fn bar<const N: usize>(&mut self) -> *const [A; N]; diff --git a/src/test/ui/const-generics/type-dependent/non-local.rs b/src/test/ui/const-generics/type-dependent/non-local.rs index 747664a0962..9e4afba3114 100644 --- a/src/test/ui/const-generics/type-dependent/non-local.rs +++ b/src/test/ui/const-generics/type-dependent/non-local.rs @@ -3,7 +3,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] extern crate type_dependent_lib; diff --git a/src/test/ui/const-generics/type-dependent/qpath.rs b/src/test/ui/const-generics/type-dependent/qpath.rs index ec23ff1d221..b61e970cfb3 100644 --- a/src/test/ui/const-generics/type-dependent/qpath.rs +++ b/src/test/ui/const-generics/type-dependent/qpath.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A; impl A { diff --git a/src/test/ui/const-generics/type-dependent/simple.rs b/src/test/ui/const-generics/type-dependent/simple.rs index 70af6550923..a4776a43b21 100644 --- a/src/test/ui/const-generics/type-dependent/simple.rs +++ b/src/test/ui/const-generics/type-dependent/simple.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct R; diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr index a530e63449d..b942c397a8d 100644 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:12:27 + --> $DIR/type-mismatch.rs:11:27 | LL | assert_eq!(R.method::<1u16>(), 1); | ^^^^ expected `u8`, found `u16` diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr index a530e63449d..b942c397a8d 100644 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:12:27 + --> $DIR/type-mismatch.rs:11:27 | LL | assert_eq!(R.method::<1u16>(), 1); | ^^^^ expected `u8`, found `u16` diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.rs b/src/test/ui/const-generics/type-dependent/type-mismatch.rs index 67d80973f03..7fba1afe918 100644 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.rs +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct R; diff --git a/src/test/ui/const-generics/type_of_anon_const.rs b/src/test/ui/const-generics/type_of_anon_const.rs index f424fd03341..9a2e9f09319 100644 --- a/src/test/ui/const-generics/type_of_anon_const.rs +++ b/src/test/ui/const-generics/type_of_anon_const.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait T<const A: usize> { fn l<const N: bool>() -> usize; diff --git a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr index 265e9ee618b..480ecdb3873 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:15:41 + --> $DIR/types-mismatch-const-args.rs:14:41 | LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32` @@ -8,7 +8,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data found type `4_u32` error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:17:41 + --> $DIR/types-mismatch-const-args.rs:16:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` diff --git a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr index 27277f0c0be..c19c8db737a 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:15:41 + --> $DIR/types-mismatch-const-args.rs:14:41 | LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32` @@ -10,7 +10,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data found struct `A<'_, _, 4_u32, _>` error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:17:41 + --> $DIR/types-mismatch-const-args.rs:16:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` diff --git a/src/test/ui/const-generics/types-mismatch-const-args.rs b/src/test/ui/const-generics/types-mismatch-const-args.rs index 34b85304cc4..14cef083d83 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.rs +++ b/src/test/ui/const-generics/types-mismatch-const-args.rs @@ -1,7 +1,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] // tests the diagnostic output of type mismatches for types that have const generics arguments. diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs index 45afbdc9ab1..9592f266230 100644 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs +++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::fmt; diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs index 65ae05e1198..4bab2bb5a77 100644 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs +++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] use std::fmt; diff --git a/src/test/ui/const-generics/unknown_adt.full.stderr b/src/test/ui/const-generics/unknown_adt.full.stderr index 94f3165eaec..b8b2e90aa66 100644 --- a/src/test/ui/const-generics/unknown_adt.full.stderr +++ b/src/test/ui/const-generics/unknown_adt.full.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `UnknownStruct` in this scope - --> $DIR/unknown_adt.rs:8:12 + --> $DIR/unknown_adt.rs:7:12 | LL | let _: UnknownStruct<7>; | ^^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/const-generics/unknown_adt.min.stderr b/src/test/ui/const-generics/unknown_adt.min.stderr index 94f3165eaec..b8b2e90aa66 100644 --- a/src/test/ui/const-generics/unknown_adt.min.stderr +++ b/src/test/ui/const-generics/unknown_adt.min.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `UnknownStruct` in this scope - --> $DIR/unknown_adt.rs:8:12 + --> $DIR/unknown_adt.rs:7:12 | LL | let _: UnknownStruct<7>; | ^^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/const-generics/unknown_adt.rs b/src/test/ui/const-generics/unknown_adt.rs index c6131402aeb..977f90aad11 100644 --- a/src/test/ui/const-generics/unknown_adt.rs +++ b/src/test/ui/const-generics/unknown_adt.rs @@ -2,7 +2,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] fn main() { let _: UnknownStruct<7>; diff --git a/src/test/ui/const-generics/unused-const-param.rs b/src/test/ui/const-generics/unused-const-param.rs index 3c305167b4b..2918e399dc8 100644 --- a/src/test/ui/const-generics/unused-const-param.rs +++ b/src/test/ui/const-generics/unused-const-param.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize>; // ok diff --git a/src/test/ui/const-generics/unused_braces.full.fixed b/src/test/ui/const-generics/unused_braces.full.fixed index 1b075ade16a..46d57e0dcfc 100644 --- a/src/test/ui/const-generics/unused_braces.full.fixed +++ b/src/test/ui/const-generics/unused_braces.full.fixed @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![warn(unused_braces)] diff --git a/src/test/ui/const-generics/unused_braces.full.stderr b/src/test/ui/const-generics/unused_braces.full.stderr index 1752779a60a..8899139aa6b 100644 --- a/src/test/ui/const-generics/unused_braces.full.stderr +++ b/src/test/ui/const-generics/unused_braces.full.stderr @@ -1,11 +1,11 @@ warning: unnecessary braces around const expression - --> $DIR/unused_braces.rs:15:14 + --> $DIR/unused_braces.rs:14:14 | LL | let _: A<{ 7 }>; | ^^^^^ help: remove these braces | note: the lint level is defined here - --> $DIR/unused_braces.rs:8:9 + --> $DIR/unused_braces.rs:7:9 | LL | #![warn(unused_braces)] | ^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/unused_braces.min.fixed b/src/test/ui/const-generics/unused_braces.min.fixed index 1b075ade16a..46d57e0dcfc 100644 --- a/src/test/ui/const-generics/unused_braces.min.fixed +++ b/src/test/ui/const-generics/unused_braces.min.fixed @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![warn(unused_braces)] diff --git a/src/test/ui/const-generics/unused_braces.min.stderr b/src/test/ui/const-generics/unused_braces.min.stderr index 1752779a60a..8899139aa6b 100644 --- a/src/test/ui/const-generics/unused_braces.min.stderr +++ b/src/test/ui/const-generics/unused_braces.min.stderr @@ -1,11 +1,11 @@ warning: unnecessary braces around const expression - --> $DIR/unused_braces.rs:15:14 + --> $DIR/unused_braces.rs:14:14 | LL | let _: A<{ 7 }>; | ^^^^^ help: remove these braces | note: the lint level is defined here - --> $DIR/unused_braces.rs:8:9 + --> $DIR/unused_braces.rs:7:9 | LL | #![warn(unused_braces)] | ^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/unused_braces.rs b/src/test/ui/const-generics/unused_braces.rs index 31c4caf7ab8..0348bbacaab 100644 --- a/src/test/ui/const-generics/unused_braces.rs +++ b/src/test/ui/const-generics/unused_braces.rs @@ -4,7 +4,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] #![warn(unused_braces)] diff --git a/src/test/ui/const-generics/wf-misc.full.stderr b/src/test/ui/const-generics/wf-misc.full.stderr index 4af48fa1590..dfb593a9507 100644 --- a/src/test/ui/const-generics/wf-misc.full.stderr +++ b/src/test/ui/const-generics/wf-misc.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/wf-misc.rs:9:12 + --> $DIR/wf-misc.rs:8:12 | LL | let _: [u8; N + 1]; | ^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _: [u8; N + 1]; = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/wf-misc.rs:17:12 + --> $DIR/wf-misc.rs:16:12 | LL | let _: Const::<{N + 1}>; | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/wf-misc.min.stderr b/src/test/ui/const-generics/wf-misc.min.stderr index 99142cb6ce7..9967a2218f6 100644 --- a/src/test/ui/const-generics/wf-misc.min.stderr +++ b/src/test/ui/const-generics/wf-misc.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/wf-misc.rs:9:17 + --> $DIR/wf-misc.rs:8:17 | LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | let _: [u8; N + 1]; = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/wf-misc.rs:17:21 + --> $DIR/wf-misc.rs:16:21 | LL | let _: Const::<{N + 1}>; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/wf-misc.rs b/src/test/ui/const-generics/wf-misc.rs index 103c580f28f..8a5b6ddfe26 100644 --- a/src/test/ui/const-generics/wf-misc.rs +++ b/src/test/ui/const-generics/wf-misc.rs @@ -3,7 +3,6 @@ #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] pub fn arr_len<const N: usize>() { let _: [u8; N + 1]; diff --git a/src/test/ui/const-generics/where-clauses.rs b/src/test/ui/const-generics/where-clauses.rs index cdcaf250942..dc09cad3180 100644 --- a/src/test/ui/const-generics/where-clauses.rs +++ b/src/test/ui/const-generics/where-clauses.rs @@ -2,7 +2,6 @@ // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] -#![cfg_attr(min, feature(min_const_generics))] trait Bar<const N: usize> { fn bar() {} } trait Foo<const N: usize>: Bar<N> {} diff --git a/src/test/ui/const-ptr/out_of_bounds_read.rs b/src/test/ui/const-ptr/out_of_bounds_read.rs new file mode 100644 index 00000000000..183aa9e5122 --- /dev/null +++ b/src/test/ui/const-ptr/out_of_bounds_read.rs @@ -0,0 +1,16 @@ +// error-pattern: any use of this value will cause an error + +#![feature(const_ptr_read)] +#![feature(const_ptr_offset)] + +fn main() { + use std::ptr; + + const DATA: [u32; 1] = [42]; + + const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) }; + + const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; + const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; + const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; +} diff --git a/src/test/ui/const-ptr/out_of_bounds_read.stderr b/src/test/ui/const-ptr/out_of_bounds_read.stderr new file mode 100644 index 00000000000..ca65a079947 --- /dev/null +++ b/src/test/ui/const-ptr/out_of_bounds_read.stderr @@ -0,0 +1,54 @@ +error: any use of this value will cause an error + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + | +LL | unsafe { copy_nonoverlapping(src, dst, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 + | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL + | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | inside `_READ` at $DIR/out_of_bounds_read.rs:13:33 + | + ::: $DIR/out_of_bounds_read.rs:13:5 + | +LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; + | ------------------------------------------------------ + | + = note: `#[deny(const_err)]` on by default + +error: any use of this value will cause an error + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + | +LL | unsafe { copy_nonoverlapping(src, dst, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 + | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL + | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39 + | + ::: $DIR/out_of_bounds_read.rs:14:5 + | +LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; + | -------------------------------------------------------- + +error: any use of this value will cause an error + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + | +LL | unsafe { copy_nonoverlapping(src, dst, count) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 + | inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL + | inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + | inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37 + | + ::: $DIR/out_of_bounds_read.rs:15:5 + | +LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; + | -------------------------------------------------------------------- + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/consts/const-address-of-interior-mut.stderr b/src/test/ui/consts/const-address-of-interior-mut.stderr index f15174c33b3..93120753b1a 100644 --- a/src/test/ui/consts/const-address-of-interior-mut.stderr +++ b/src/test/ui/consts/const-address-of-interior-mut.stderr @@ -1,27 +1,39 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/const-address-of-interior-mut.rs:5:39 | LL | const A: () = { let x = Cell::new(2); &raw const x; }; | ^^^^^^^^^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/const-address-of-interior-mut.rs:7:40 | LL | static B: () = { let x = Cell::new(2); &raw const x; }; | ^^^^^^^^^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/const-address-of-interior-mut.rs:9:44 | LL | static mut C: () = { let x = Cell::new(2); &raw const x; }; | ^^^^^^^^^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/const-address-of-interior-mut.rs:13:13 | LL | let y = &raw const x; | ^^^^^^^^^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0492`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/compile-fail/consts/const-fn-error.rs b/src/test/ui/consts/const-fn-error.rs index 68a4d414ff3..68a4d414ff3 100644 --- a/src/test/compile-fail/consts/const-fn-error.rs +++ b/src/test/ui/consts/const-fn-error.rs diff --git a/src/test/ui/consts/const-fn-error.stderr b/src/test/ui/consts/const-fn-error.stderr new file mode 100644 index 00000000000..86b1eebcb2c --- /dev/null +++ b/src/test/ui/consts/const-fn-error.stderr @@ -0,0 +1,49 @@ +error[E0744]: `for` is not allowed in a `const fn` + --> $DIR/const-fn-error.rs:7:5 + | +LL | / for i in 0..x { +LL | | +LL | | +LL | | +... | +LL | | sum += i; +LL | | } + | |_____^ + +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + | + = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + | | + | calling non-const function `<std::ops::Range<usize> as IntoIterator>::into_iter` + | inside `f` at $DIR/const-fn-error.rs:7:14 +... +LL | let a : [i32; f(X)]; + | ---- inside `main::{constant#0}` at $DIR/const-fn-error.rs:20:19 + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0015, E0080, E0658, E0744. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-multi-ref.rs b/src/test/ui/consts/const-multi-ref.rs index 18645efc887..7e0f1a812fd 100644 --- a/src/test/ui/consts/const-multi-ref.rs +++ b/src/test/ui/consts/const-multi-ref.rs @@ -13,7 +13,7 @@ const _: i32 = { const _: std::cell::Cell<i32> = { let mut a = std::cell::Cell::new(5); - let p = &a; //~ ERROR cannot borrow a constant which may contain interior mutability + let p = &a; //~ ERROR borrowed element may contain interior mutability let reborrow = {p}; let pp = &reborrow; diff --git a/src/test/ui/consts/const-multi-ref.stderr b/src/test/ui/consts/const-multi-ref.stderr index 9a7914b4588..c0a320d46cb 100644 --- a/src/test/ui/consts/const-multi-ref.stderr +++ b/src/test/ui/consts/const-multi-ref.stderr @@ -4,13 +4,16 @@ error[E0764]: mutable references are not allowed in constants LL | let p = &mut a; | ^^^^^^ `&mut` is only allowed in `const fn` -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/const-multi-ref.rs:16:13 | LL | let p = &a; | ^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable error: aborting due to 2 previous errors -Some errors have detailed explanations: E0492, E0764. -For more information about an error, try `rustc --explain E0492`. +Some errors have detailed explanations: E0658, E0764. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-size_of_val-align_of_val.rs b/src/test/ui/consts/const-size_of_val-align_of_val.rs index e8e6f1d3900..5c0d7d94d64 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val.rs @@ -1,6 +1,7 @@ // run-pass #![feature(const_size_of_val, const_align_of_val)] +#![feature(const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr)] use std::mem; @@ -32,6 +33,9 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH); const SIZE_OF_SLICE: usize = mem::size_of_val("foobar".as_bytes()); +const SIZE_OF_DANGLING: usize = unsafe { mem::size_of_val_raw(0x100 as *const i32) }; +const ALIGN_OF_DANGLING: usize = unsafe { mem::align_of_val_raw(0x100 as *const i16) }; + fn main() { assert_eq!(SIZE_OF_FOO, mem::size_of::<Foo>()); assert_eq!(SIZE_OF_BAR, mem::size_of::<Bar>()); @@ -41,5 +45,8 @@ fn main() { assert_eq!(ALIGN_OF_BAR, mem::align_of::<Bar>()); assert_eq!(ALIGN_OF_UGH, mem::align_of::<Ugh>()); + assert_eq!(SIZE_OF_DANGLING, mem::size_of::<i32>()); + assert_eq!(ALIGN_OF_DANGLING, mem::align_of::<i16>()); + assert_eq!(SIZE_OF_SLICE, "foobar".len()); } diff --git a/src/test/compile-fail/issue-44415.rs b/src/test/ui/consts/issue-44415.rs index 71e764620d1..71e764620d1 100644 --- a/src/test/compile-fail/issue-44415.rs +++ b/src/test/ui/consts/issue-44415.rs diff --git a/src/test/ui/consts/issue-44415.stderr b/src/test/ui/consts/issue-44415.stderr new file mode 100644 index 00000000000..38841e99a72 --- /dev/null +++ b/src/test/ui/consts/issue-44415.stderr @@ -0,0 +1,28 @@ +error[E0391]: cycle detected when simplifying constant for the type system `Foo::bytes::{constant#0}` + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], + | ^^^^^^ + | +note: ...which requires simplifying constant for the type system `Foo::bytes::{constant#0}`... + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], + | ^^^^^^ +note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`... + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], + | ^^^^^^ + = note: ...which requires computing layout of `Foo`... + = note: ...which requires normalizing `[u8; _]`... + = note: ...which again requires simplifying constant for the type system `Foo::bytes::{constant#0}`, completing the cycle +note: cycle used when checking that `Foo` is well-formed + --> $DIR/issue-44415.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/ui/consts/issue-55878.rs index fee664caa17..c1c54646db8 100644 --- a/src/test/compile-fail/consts/issue-55878.rs +++ b/src/test/ui/consts/issue-55878.rs @@ -1,3 +1,4 @@ +// build-fail // normalize-stderr-64bit "18446744073709551615" -> "SIZE" // normalize-stderr-32bit "4294967295" -> "SIZE" diff --git a/src/test/ui/consts/issue-55878.stderr b/src/test/ui/consts/issue-55878.stderr new file mode 100644 index 00000000000..924910e9cb6 --- /dev/null +++ b/src/test/ui/consts/issue-55878.stderr @@ -0,0 +1,25 @@ +error[E0080]: values of the type `[u8; SIZE]` are too big for the current architecture + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | inside `std::mem::size_of::<[u8; SIZE]>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | inside `main` at $DIR/issue-55878.rs:7:26 + | + ::: $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ---------------------------------------------- + +error: erroneous constant used + --> $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | + = note: `#[deny(const_err)]` on by default + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/partial_qualif.rs b/src/test/ui/consts/partial_qualif.rs index 32c68e69f4b..7c28b8b8a62 100644 --- a/src/test/ui/consts/partial_qualif.rs +++ b/src/test/ui/consts/partial_qualif.rs @@ -3,7 +3,7 @@ use std::cell::Cell; const FOO: &(Cell<usize>, bool) = { let mut a = (Cell::new(0), false); a.1 = true; // sets `qualif(a)` to `qualif(a) | qualif(true)` - &{a} //~ ERROR cannot borrow a constant which may contain interior mutability + &{a} //~ ERROR cannot refer to interior mutable }; fn main() {} diff --git a/src/test/ui/consts/partial_qualif.stderr b/src/test/ui/consts/partial_qualif.stderr index 221e449b6f9..32c25be2173 100644 --- a/src/test/ui/consts/partial_qualif.stderr +++ b/src/test/ui/consts/partial_qualif.stderr @@ -1,8 +1,8 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/partial_qualif.rs:6:5 | LL | &{a} - | ^^^^ + | ^^^^ this borrow of an interior mutable value may end up in the final value error: aborting due to previous error diff --git a/src/test/ui/consts/promotion.rs b/src/test/ui/consts/promotion.rs index e6f5c3d27ca..b6e7127a9b7 100644 --- a/src/test/ui/consts/promotion.rs +++ b/src/test/ui/consts/promotion.rs @@ -4,12 +4,23 @@ fn foo(_: &'static [&'static str]) {} fn bar(_: &'static [&'static str; 3]) {} -fn baz_i32(_: &'static i32) {} -fn baz_u32(_: &'static u32) {} +const fn baz_i32(_: &'static i32) {} +const fn baz_u32(_: &'static u32) {} + +const fn fail() -> i32 { 1/0 } +const C: i32 = { + // Promoted that fails to evaluate in dead code -- this must work + // (for backwards compatibility reasons). + if false { + baz_i32(&fail()); + } + 42 +}; fn main() { foo(&["a", "b", "c"]); bar(&["d", "e", "f"]); + assert_eq!(C, 42); // make sure that these do not cause trouble despite overflowing baz_u32(&(0-1)); diff --git a/src/test/ui/consts/qualif_overwrite.rs b/src/test/ui/consts/qualif_overwrite.rs index 430eea37de7..aae4e41ffd7 100644 --- a/src/test/ui/consts/qualif_overwrite.rs +++ b/src/test/ui/consts/qualif_overwrite.rs @@ -7,7 +7,7 @@ use std::cell::Cell; const FOO: &Option<Cell<usize>> = { let mut a = Some(Cell::new(0)); a = None; // sets `qualif(a)` to `qualif(a) | qualif(None)` - &{a} //~ ERROR cannot borrow a constant which may contain interior mutability + &{a} //~ ERROR cannot refer to interior mutable }; fn main() {} diff --git a/src/test/ui/consts/qualif_overwrite.stderr b/src/test/ui/consts/qualif_overwrite.stderr index fbaae711d7c..86a669c433d 100644 --- a/src/test/ui/consts/qualif_overwrite.stderr +++ b/src/test/ui/consts/qualif_overwrite.stderr @@ -1,8 +1,8 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/qualif_overwrite.rs:10:5 | LL | &{a} - | ^^^^ + | ^^^^ this borrow of an interior mutable value may end up in the final value error: aborting due to previous error diff --git a/src/test/ui/consts/qualif_overwrite_2.rs b/src/test/ui/consts/qualif_overwrite_2.rs index fa79b5c14a7..1819d9a6d20 100644 --- a/src/test/ui/consts/qualif_overwrite_2.rs +++ b/src/test/ui/consts/qualif_overwrite_2.rs @@ -5,7 +5,7 @@ use std::cell::Cell; const FOO: &Option<Cell<usize>> = { let mut a = (Some(Cell::new(0)),); a.0 = None; // sets `qualif(a)` to `qualif(a) | qualif(None)` - &{a.0} //~ ERROR cannot borrow a constant which may contain interior mutability + &{a.0} //~ ERROR cannot refer to interior mutable }; fn main() {} diff --git a/src/test/ui/consts/qualif_overwrite_2.stderr b/src/test/ui/consts/qualif_overwrite_2.stderr index a393c4e336d..9eb123d0b01 100644 --- a/src/test/ui/consts/qualif_overwrite_2.stderr +++ b/src/test/ui/consts/qualif_overwrite_2.stderr @@ -1,8 +1,8 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/qualif_overwrite_2.rs:8:5 | LL | &{a.0} - | ^^^^^^ + | ^^^^^^ this borrow of an interior mutable value may end up in the final value error: aborting due to previous error diff --git a/src/test/ui/consts/std/cell.rs b/src/test/ui/consts/std/cell.rs index cf6c0f2379d..f1ef541319a 100644 --- a/src/test/ui/consts/std/cell.rs +++ b/src/test/ui/consts/std/cell.rs @@ -1,18 +1,31 @@ +#![feature(const_refs_to_cell)] + use std::cell::*; -// not ok, because this would create a silent constant with interior mutability. -// the rules could be relaxed in the future +// not ok, because this creates a dangling pointer, just like `let x = Cell::new(42).as_ptr()` would static FOO: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); -//~^ ERROR cannot borrow a constant which may contain interior mutability +//~^ ERROR encountered dangling pointer +const FOO_CONST: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); +//~^ ERROR encountered dangling pointer +// Ok, these are just base values and it is the `Wrap` author's job to uphold `Send` and `Sync` +// invariants, since they used `unsafe impl`. static FOO3: Wrap<Cell<u32>> = Wrap(Cell::new(42)); -// ok +const FOO3_CONST: Wrap<Cell<u32>> = Wrap(Cell::new(42)); + +// ok, we are referring to the memory of another static item. static FOO4: Wrap<*mut u32> = Wrap(FOO3.0.as_ptr()); -// not ok, because the `as_ptr` call takes a reference to a type with interior mutability -// which is not allowed in constants +// not ok, the use of a constant here is equivalent to an inline declaration of the value, so +// its memory will get freed before the constant is finished evaluating, thus creating a dangling +// pointer. This would happen exactly the same at runtime. +const FOO4_CONST: Wrap<*mut u32> = Wrap(FOO3_CONST.0.as_ptr()); +//~^ ERROR encountered dangling pointer + +// not ok, because the `as_ptr` call takes a reference to a temporary that will get freed +// before the constant is finished evaluating. const FOO2: *mut u32 = Cell::new(42).as_ptr(); -//~^ ERROR cannot borrow a constant which may contain interior mutability +//~^ ERROR encountered dangling pointer struct IMSafeTrustMe(UnsafeCell<u32>); unsafe impl Send for IMSafeTrustMe {} @@ -21,10 +34,13 @@ unsafe impl Sync for IMSafeTrustMe {} static BAR: IMSafeTrustMe = IMSafeTrustMe(UnsafeCell::new(5)); + struct Wrap<T>(T); unsafe impl<T> Send for Wrap<T> {} unsafe impl<T> Sync for Wrap<T> {} static BAR_PTR: Wrap<*mut u32> = Wrap(BAR.0.get()); +const fn fst_ref<T, U>(x: &(T, U)) -> &T { &x.0 } + fn main() {} diff --git a/src/test/ui/consts/std/cell.stderr b/src/test/ui/consts/std/cell.stderr index f75aadff6d5..355c326f0b6 100644 --- a/src/test/ui/consts/std/cell.stderr +++ b/src/test/ui/consts/std/cell.stderr @@ -1,15 +1,26 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/cell.rs:5:35 +error: encountered dangling pointer in final constant + --> $DIR/cell.rs:6:1 | LL | static FOO: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/cell.rs:14:24 +error: encountered dangling pointer in final constant + --> $DIR/cell.rs:8:1 + | +LL | const FOO_CONST: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: encountered dangling pointer in final constant + --> $DIR/cell.rs:22:1 + | +LL | const FOO4_CONST: Wrap<*mut u32> = Wrap(FOO3_CONST.0.as_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: encountered dangling pointer in final constant + --> $DIR/cell.rs:27:1 | LL | const FOO2: *mut u32 = Cell::new(42).as_ptr(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0492`. diff --git a/src/test/compile-fail/auxiliary/crateresolve1-1.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs index a00a19e46d5..a00a19e46d5 100644 --- a/src/test/compile-fail/auxiliary/crateresolve1-1.rs +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs diff --git a/src/test/compile-fail/auxiliary/crateresolve1-2.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs index 71cc0a12ea3..71cc0a12ea3 100644 --- a/src/test/compile-fail/auxiliary/crateresolve1-2.rs +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs diff --git a/src/test/compile-fail/auxiliary/crateresolve1-3.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs index 921687d4c3b..921687d4c3b 100644 --- a/src/test/compile-fail/auxiliary/crateresolve1-3.rs +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs diff --git a/src/test/compile-fail/crateresolve1.rs b/src/test/ui/crate-loading/crateresolve1.rs index 453c8d97622..49e47dacc3d 100644 --- a/src/test/compile-fail/crateresolve1.rs +++ b/src/test/ui/crate-loading/crateresolve1.rs @@ -1,3 +1,4 @@ +// dont-check-compiler-stderr // aux-build:crateresolve1-1.rs // aux-build:crateresolve1-2.rs // aux-build:crateresolve1-3.rs diff --git a/src/test/ui/doc-alias-crate-level.rs b/src/test/ui/doc-alias-crate-level.rs index 9b596ece5b5..c7783aae5ea 100644 --- a/src/test/ui/doc-alias-crate-level.rs +++ b/src/test/ui/doc-alias-crate-level.rs @@ -1,7 +1,5 @@ // compile-flags: -Zdeduplicate-diagnostics=no -#![feature(doc_alias)] - #![crate_type = "lib"] #![doc(alias = "not working!")] //~ ERROR diff --git a/src/test/ui/doc-alias-crate-level.stderr b/src/test/ui/doc-alias-crate-level.stderr index b6437fad5d0..c0467514ae1 100644 --- a/src/test/ui/doc-alias-crate-level.stderr +++ b/src/test/ui/doc-alias-crate-level.stderr @@ -1,11 +1,11 @@ error: '\'' character isn't allowed in `#[doc(alias = "...")]` - --> $DIR/doc-alias-crate-level.rs:9:15 + --> $DIR/doc-alias-crate-level.rs:7:15 | LL | #[doc(alias = "shouldn't work!")] | ^^^^^^^^^^^^^^^^^ error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute - --> $DIR/doc-alias-crate-level.rs:7:8 + --> $DIR/doc-alias-crate-level.rs:5:8 | LL | #![doc(alias = "not working!")] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/doc-alias-same-name.rs b/src/test/ui/doc-alias-same-name.rs new file mode 100644 index 00000000000..da97c267618 --- /dev/null +++ b/src/test/ui/doc-alias-same-name.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[doc(alias = "Foo")] //~ ERROR +pub struct Foo; diff --git a/src/test/ui/doc-alias-same-name.stderr b/src/test/ui/doc-alias-same-name.stderr new file mode 100644 index 00000000000..5ba09a2eae1 --- /dev/null +++ b/src/test/ui/doc-alias-same-name.stderr @@ -0,0 +1,8 @@ +error: `#[doc(alias = "...")]` is the same as the item's name + --> $DIR/doc-alias-same-name.rs:3:7 + | +LL | #[doc(alias = "Foo")] + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.rs b/src/test/ui/dropck/dropck_trait_cycle_checked.rs index bea77dc9f5c..be6ec3e4ed1 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.rs +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.rs @@ -1,7 +1,7 @@ // Reject mixing cyclic structure and Drop when using trait // objects to hide the cross-references. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against ui/span/dropck_vec_cycle_checked.rs) use std::cell::Cell; use id::Id; diff --git a/src/test/ui/dropck/reject-specialized-drops-8142.rs b/src/test/ui/dropck/reject-specialized-drops-8142.rs index 02e8665cd2e..c9599f6e805 100644 --- a/src/test/ui/dropck/reject-specialized-drops-8142.rs +++ b/src/test/ui/dropck/reject-specialized-drops-8142.rs @@ -1,7 +1,5 @@ // Issue 8142: Test that Drop impls cannot be specialized beyond the // predicates attached to the type definition itself. -#![feature(min_const_generics)] - trait Bound { fn foo(&self) { } } struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } diff --git a/src/test/ui/dropck/reject-specialized-drops-8142.stderr b/src/test/ui/dropck/reject-specialized-drops-8142.stderr index 284cf59c822..cb4d97a8b20 100644 --- a/src/test/ui/dropck/reject-specialized-drops-8142.stderr +++ b/src/test/ui/dropck/reject-specialized-drops-8142.stderr @@ -1,108 +1,108 @@ error[E0367]: `Drop` impl requires `'adds_bnd: 'al` but the struct it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:26:20 + --> $DIR/reject-specialized-drops-8142.rs:24:20 | LL | impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT | ^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:6:1 + --> $DIR/reject-specialized-drops-8142.rs:4:1 | LL | struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `'adds_bnd: 'al` but the struct it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:30:67 + --> $DIR/reject-specialized-drops-8142.rs:28:67 | LL | impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT | ^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:7:1 + --> $DIR/reject-specialized-drops-8142.rs:5:1 | LL | struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/reject-specialized-drops-8142.rs:36:1 + --> $DIR/reject-specialized-drops-8142.rs:34:1 | LL | impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected struct `N<'n>` found struct `N<'static>` -note: the lifetime `'n` as defined on the struct at 9:10... - --> $DIR/reject-specialized-drops-8142.rs:9:10 +note: the lifetime `'n` as defined on the struct at 7:10... + --> $DIR/reject-specialized-drops-8142.rs:7:10 | LL | struct N<'n> { x: &'n i8 } | ^^ = note: ...does not necessarily outlive the static lifetime error[E0366]: `Drop` impls cannot be specialized - --> $DIR/reject-specialized-drops-8142.rs:43:1 + --> $DIR/reject-specialized-drops-8142.rs:41:1 | LL | impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: use the same sequence of generic type, lifetime and const parameters as the struct definition - --> $DIR/reject-specialized-drops-8142.rs:11:1 + --> $DIR/reject-specialized-drops-8142.rs:9:1 | LL | struct P<Tp> { x: *const Tp } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the struct it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:46:14 + --> $DIR/reject-specialized-drops-8142.rs:44:14 | LL | impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:12:1 + --> $DIR/reject-specialized-drops-8142.rs:10:1 | LL | struct Q<Tq> { x: *const Tq } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `AddsRBnd: 'rbnd` but the struct it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:49:21 + --> $DIR/reject-specialized-drops-8142.rs:47:21 | LL | impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:13:1 + --> $DIR/reject-specialized-drops-8142.rs:11:1 | LL | struct R<Tr> { x: *const Tr } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0366]: `Drop` impls cannot be specialized - --> $DIR/reject-specialized-drops-8142.rs:58:1 + --> $DIR/reject-specialized-drops-8142.rs:56:1 | LL | impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: use the same sequence of generic type, lifetime and const parameters as the struct definition - --> $DIR/reject-specialized-drops-8142.rs:17:1 + --> $DIR/reject-specialized-drops-8142.rs:15:1 | LL | struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'lw` due to conflicting requirements - --> $DIR/reject-specialized-drops-8142.rs:61:1 + --> $DIR/reject-specialized-drops-8142.rs:59:1 | LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'l1` as defined on the struct at 18:10... - --> $DIR/reject-specialized-drops-8142.rs:18:10 +note: first, the lifetime cannot outlive the lifetime `'l1` as defined on the struct at 16:10... + --> $DIR/reject-specialized-drops-8142.rs:16:10 | LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } | ^^^ -note: ...but the lifetime must also be valid for the lifetime `'l2` as defined on the struct at 18:15... - --> $DIR/reject-specialized-drops-8142.rs:18:15 +note: ...but the lifetime must also be valid for the lifetime `'l2` as defined on the struct at 16:15... + --> $DIR/reject-specialized-drops-8142.rs:16:15 | LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } | ^^^ note: ...so that the types are compatible - --> $DIR/reject-specialized-drops-8142.rs:61:1 + --> $DIR/reject-specialized-drops-8142.rs:59:1 | LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,61 +110,61 @@ LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJ found `W<'_, '_>` error[E0366]: `Drop` impls cannot be specialized - --> $DIR/reject-specialized-drops-8142.rs:64:1 + --> $DIR/reject-specialized-drops-8142.rs:62:1 | LL | impl Drop for X<3> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: use the same sequence of generic type, lifetime and const parameters as the struct definition - --> $DIR/reject-specialized-drops-8142.rs:19:1 + --> $DIR/reject-specialized-drops-8142.rs:17:1 | LL | struct X<const Ca: usize>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0366]: `Drop` impls cannot be specialized - --> $DIR/reject-specialized-drops-8142.rs:67:1 + --> $DIR/reject-specialized-drops-8142.rs:65:1 | LL | impl<const Ca: usize> Drop for Y<Ca, Ca> { fn drop(&mut self) { } } // REJECT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: use the same sequence of generic type, lifetime and const parameters as the struct definition - --> $DIR/reject-specialized-drops-8142.rs:20:1 + --> $DIR/reject-specialized-drops-8142.rs:18:1 | LL | struct Y<const Ca: usize, const Cb: usize>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the enum it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:70:14 + --> $DIR/reject-specialized-drops-8142.rs:68:14 | LL | impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:22:1 + --> $DIR/reject-specialized-drops-8142.rs:20:1 | LL | enum Enum<T> { Variant(T) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the struct it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:73:14 + --> $DIR/reject-specialized-drops-8142.rs:71:14 | LL | impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:23:1 + --> $DIR/reject-specialized-drops-8142.rs:21:1 | LL | struct TupleStruct<T>(T); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the union it is implemented for does not - --> $DIR/reject-specialized-drops-8142.rs:76:21 + --> $DIR/reject-specialized-drops-8142.rs:74:21 | LL | impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/reject-specialized-drops-8142.rs:24:1 + --> $DIR/reject-specialized-drops-8142.rs:22:1 | LL | union Union<T: Copy> { f: T } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/editions/async-block-2015.rs b/src/test/ui/editions/async-block-2015.rs index 985606a6f25..92eae9e3c14 100644 --- a/src/test/ui/editions/async-block-2015.rs +++ b/src/test/ui/editions/async-block-2015.rs @@ -1,13 +1,13 @@ async fn foo() { -//~^ ERROR `async fn` is not permitted in the 2015 edition -//~| NOTE to use `async fn`, switch to Rust 2018 +//~^ ERROR `async fn` is not permitted in Rust 2015 +//~| NOTE to use `async fn`, switch to Rust 2018 or later //~| HELP set `edition = "2018"` in `Cargo.toml` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide let x = async {}; //~^ ERROR cannot find struct, variant or union type `async` in this scope - //~| NOTE `async` blocks are only allowed in the 2018 edition - let y = async { //~ NOTE `async` blocks are only allowed in the 2018 edition + //~| NOTE `async` blocks are only allowed in Rust 2018 or later + let y = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later let x = 42; //~^ ERROR expected identifier, found keyword `let` //~| NOTE expected identifier, found keyword @@ -15,7 +15,7 @@ async fn foo() { //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide 42 }; - let z = async { //~ NOTE `async` blocks are only allowed in the 2018 edition + let z = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later 42 //~^ ERROR expected identifier, found `42` //~| NOTE expected identifier diff --git a/src/test/ui/editions/async-block-2015.stderr b/src/test/ui/editions/async-block-2015.stderr index 8e5e5d8bfab..e42747c804c 100644 --- a/src/test/ui/editions/async-block-2015.stderr +++ b/src/test/ui/editions/async-block-2015.stderr @@ -1,8 +1,8 @@ -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/async-block-2015.rs:1:1 | LL | async fn foo() { - | ^^^^^ to use `async fn`, switch to Rust 2018 + | ^^^^^ to use `async fn`, switch to Rust 2018 or later | = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide @@ -11,7 +11,7 @@ error: expected identifier, found keyword `let` --> $DIR/async-block-2015.rs:11:9 | LL | let y = async { - | ----- `async` blocks are only allowed in the 2018 edition + | ----- `async` blocks are only allowed in Rust 2018 or later LL | let x = 42; | ^^^ expected identifier, found keyword | @@ -22,7 +22,7 @@ error: expected identifier, found `42` --> $DIR/async-block-2015.rs:19:9 | LL | let z = async { - | ----- `async` blocks are only allowed in the 2018 edition + | ----- `async` blocks are only allowed in Rust 2018 or later LL | 42 | ^^ expected identifier | @@ -33,7 +33,7 @@ error[E0422]: cannot find struct, variant or union type `async` in this scope --> $DIR/async-block-2015.rs:7:13 | LL | let x = async {}; - | ^^^^^ `async` blocks are only allowed in the 2018 edition + | ^^^^^ `async` blocks are only allowed in Rust 2018 or later error: aborting due to 4 previous errors diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs index 0cfb93d4668..f927dd18903 100644 --- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs +++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs @@ -7,7 +7,7 @@ use core::intrinsics::discriminant_value; enum MyWeirdOption<T> { None = 0, Some(T) = std::mem::size_of::<T>(), - //~^ ERROR constant expression depends on a generic parameter + //~^ ERROR generic parameters may not be used in const operations } fn main() { diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr index 91d488a07cc..4d57765e13f 100644 --- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr +++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr @@ -1,10 +1,11 @@ -error: constant expression depends on a generic parameter - --> $DIR/issue-70453-generics-in-discr-ice-2.rs:9:15 +error: generic parameters may not be used in const operations + --> $DIR/issue-70453-generics-in-discr-ice-2.rs:9:35 | LL | Some(T) = std::mem::size_of::<T>(), - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ cannot perform const operation using `T` | - = note: this may fail depending on what value the parameter takes + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs index 676f1115dde..a0fb788a510 100644 --- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs +++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs @@ -8,7 +8,7 @@ enum MyWeirdOption<T> { //~^ ERROR parameter `T` is never used None = 0, Some = std::mem::size_of::<T>(), - //~^ ERROR constant expression depends on a generic parameter + //~^ ERROR generic parameters may not be used in const operations } fn main() { diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr index 0dc5432d28c..1d43903928b 100644 --- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr +++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr @@ -1,10 +1,11 @@ -error: constant expression depends on a generic parameter - --> $DIR/issue-70453-generics-in-discr-ice.rs:10:12 +error: generic parameters may not be used in const operations + --> $DIR/issue-70453-generics-in-discr-ice.rs:10:32 | LL | Some = std::mem::size_of::<T>(), - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ cannot perform const operation using `T` | - = note: this may fail depending on what value the parameter takes + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error[E0392]: parameter `T` is never used --> $DIR/issue-70453-generics-in-discr-ice.rs:7:20 diff --git a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.rs b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.rs index cdc1db4c0b4..e62582fb516 100644 --- a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.rs +++ b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.rs @@ -1,4 +1,3 @@ -// run-pass #![feature(arbitrary_enum_discriminant, core_intrinsics)] extern crate core; @@ -8,8 +7,7 @@ use core::intrinsics::discriminant_value; enum MyWeirdOption<T> { None = 0, Some(T) = core::mem::size_of::<*mut T>(), - //~^ WARN cannot use constants which depend on generic parameters in types - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR generic parameters may not be used } fn main() { diff --git a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr index 906927e705e..8c97af263b2 100644 --- a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr +++ b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr @@ -1,12 +1,11 @@ -warning: cannot use constants which depend on generic parameters in types - --> $DIR/issue-70453-polymorphic-ctfe.rs:10:15 +error: generic parameters may not be used in const operations + --> $DIR/issue-70453-polymorphic-ctfe.rs:9:41 | LL | Some(T) = core::mem::size_of::<*mut T>(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ cannot perform const operation using `T` | - = note: `#[warn(const_evaluatable_unchecked)]` on by default - = 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 #76200 <https://github.com/rust-lang/rust/issues/76200> + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions -warning: 1 warning emitted +error: aborting due to previous error diff --git a/src/test/ui/enum/issue-67945-1.rs b/src/test/ui/enum/issue-67945-1.rs index 7977bddae7b..f4697344cc7 100644 --- a/src/test/ui/enum/issue-67945-1.rs +++ b/src/test/ui/enum/issue-67945-1.rs @@ -1,6 +1,6 @@ -enum Bug<S> { +enum Bug<S> { //~ ERROR parameter `S` is never used Var = { - let x: S = 0; //~ ERROR: mismatched types + let x: S = 0; //~ ERROR generic parameters may not be used 0 }, } diff --git a/src/test/ui/enum/issue-67945-1.stderr b/src/test/ui/enum/issue-67945-1.stderr index 6583fe13d0c..32ca94203e6 100644 --- a/src/test/ui/enum/issue-67945-1.stderr +++ b/src/test/ui/enum/issue-67945-1.stderr @@ -1,17 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-67945-1.rs:3:20 +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-1.rs:3:16 | -LL | enum Bug<S> { - | - this type parameter -LL | Var = { LL | let x: S = 0; - | - ^ expected type parameter `S`, found integer - | | - | expected due to this + | ^ cannot perform const operation using `S` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions + +error[E0392]: parameter `S` is never used + --> $DIR/issue-67945-1.rs:1:10 + | +LL | enum Bug<S> { + | ^ unused parameter | - = note: expected type parameter `S` - found type `{integer}` + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/enum/issue-67945-2.rs b/src/test/ui/enum/issue-67945-2.rs index 16bd8530ab3..e5044468da1 100644 --- a/src/test/ui/enum/issue-67945-2.rs +++ b/src/test/ui/enum/issue-67945-2.rs @@ -1,9 +1,8 @@ #![feature(type_ascription)] -enum Bug<S> { +enum Bug<S> { //~ ERROR parameter `S` is never used Var = 0: S, - //~^ ERROR: mismatched types - //~| ERROR: mismatched types + //~^ ERROR generic parameters may not be used } fn main() {} diff --git a/src/test/ui/enum/issue-67945-2.stderr b/src/test/ui/enum/issue-67945-2.stderr index c40506d59ed..a738d3b15a5 100644 --- a/src/test/ui/enum/issue-67945-2.stderr +++ b/src/test/ui/enum/issue-67945-2.stderr @@ -1,25 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-67945-2.rs:4:11 +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-2.rs:4:14 | -LL | enum Bug<S> { - | - this type parameter LL | Var = 0: S, - | ^ expected type parameter `S`, found integer + | ^ cannot perform const operation using `S` | - = note: expected type parameter `S` - found type `{integer}` + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions -error[E0308]: mismatched types - --> $DIR/issue-67945-2.rs:4:11 +error[E0392]: parameter `S` is never used + --> $DIR/issue-67945-2.rs:3:10 | LL | enum Bug<S> { - | - this type parameter -LL | Var = 0: S, - | ^^^^ expected `isize`, found type parameter `S` + | ^ unused parameter | - = note: expected type `isize` - found type parameter `S` + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/error-codes/E0435.stderr b/src/test/ui/error-codes/E0435.stderr index 349aa0d07c5..21827d1fd87 100644 --- a/src/test/ui/error-codes/E0435.stderr +++ b/src/test/ui/error-codes/E0435.stderr @@ -1,6 +1,8 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/E0435.rs:3:17 | +LL | let foo = 42u32; + | --- help: consider using `const` instead of `let` LL | let _: [u8; foo]; | ^^^ non-constant value diff --git a/src/test/ui/error-codes/E0492.rs b/src/test/ui/error-codes/E0492.rs index 2de4c12eb64..2c735fcc9f9 100644 --- a/src/test/ui/error-codes/E0492.rs +++ b/src/test/ui/error-codes/E0492.rs @@ -1,7 +1,10 @@ use std::sync::atomic::AtomicUsize; const A: AtomicUsize = AtomicUsize::new(0); -static B: &'static AtomicUsize = &A; //~ ERROR E0492 +const B: &'static AtomicUsize = &A; //~ ERROR E0492 +static C: &'static AtomicUsize = &A; //~ ERROR E0492 + +const NONE: &'static Option<AtomicUsize> = &None; fn main() { } diff --git a/src/test/ui/error-codes/E0492.stderr b/src/test/ui/error-codes/E0492.stderr index 5f337dd7f42..557c977e87d 100644 --- a/src/test/ui/error-codes/E0492.stderr +++ b/src/test/ui/error-codes/E0492.stderr @@ -1,9 +1,17 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/E0492.rs:4:34 +error[E0492]: constants cannot refer to interior mutable data + --> $DIR/E0492.rs:4:33 | -LL | static B: &'static AtomicUsize = &A; - | ^^ +LL | const B: &'static AtomicUsize = &A; + | ^^ this borrow of an interior mutable value may end up in the final value -error: aborting due to previous error +error[E0492]: statics cannot refer to interior mutable data + --> $DIR/E0492.rs:5:34 + | +LL | static C: &'static AtomicUsize = &A; + | ^^ this borrow of an interior mutable value may end up in the final value + | + = help: to fix this, the value can be extracted to a separate `static` item and then referenced + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0492`. diff --git a/src/test/ui/error-codes/E0730.stderr b/src/test/ui/error-codes/E0730.stderr index 356e4f36042..f915f6edef5 100644 --- a/src/test/ui/error-codes/E0730.stderr +++ b/src/test/ui/error-codes/E0730.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0730]: cannot pattern-match on an array without a fixed length --> $DIR/E0730.rs:6:9 diff --git a/src/test/ui/error-codes/E0771.stderr b/src/test/ui/error-codes/E0771.stderr index b184b599817..60220be6b57 100644 --- a/src/test/ui/error-codes/E0771.stderr +++ b/src/test/ui/error-codes/E0771.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error[E0771]: use of non-static lifetime `'a` in const generic --> $DIR/E0771.rs:4:41 diff --git a/src/test/compile-fail/empty-extern-arg.rs b/src/test/ui/extern-flag/empty-extern-arg.rs index d3cb5aaaeba..d3cb5aaaeba 100644 --- a/src/test/compile-fail/empty-extern-arg.rs +++ b/src/test/ui/extern-flag/empty-extern-arg.rs diff --git a/src/test/ui/extern-flag/empty-extern-arg.stderr b/src/test/ui/extern-flag/empty-extern-arg.stderr new file mode 100644 index 00000000000..199c4fb616b --- /dev/null +++ b/src/test/ui/extern-flag/empty-extern-arg.stderr @@ -0,0 +1,4 @@ +error: extern location for std does not exist: + +error: aborting due to previous error + diff --git a/src/test/ui/feature-gate-edition_macro_pats.rs b/src/test/ui/feature-gate-edition_macro_pats.rs new file mode 100644 index 00000000000..bd8a21ea36a --- /dev/null +++ b/src/test/ui/feature-gate-edition_macro_pats.rs @@ -0,0 +1,8 @@ +// Feature gate test for `edition_macro_pats` feature. + +macro_rules! foo { + ($x:pat2018) => {}; //~ERROR `pat2018` and `pat2021` are unstable + ($x:pat2021) => {}; //~ERROR `pat2018` and `pat2021` are unstable +} + +fn main() {} diff --git a/src/test/ui/feature-gate-edition_macro_pats.stderr b/src/test/ui/feature-gate-edition_macro_pats.stderr new file mode 100644 index 00000000000..89bfb239d9e --- /dev/null +++ b/src/test/ui/feature-gate-edition_macro_pats.stderr @@ -0,0 +1,21 @@ +error[E0658]: `pat2018` and `pat2021` are unstable. + --> $DIR/feature-gate-edition_macro_pats.rs:4:9 + | +LL | ($x:pat2018) => {}; + | ^^^^^^^ + | + = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information + = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable + +error[E0658]: `pat2018` and `pat2021` are unstable. + --> $DIR/feature-gate-edition_macro_pats.rs:5:9 + | +LL | ($x:pat2021) => {}; + | ^^^^^^^ + | + = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information + = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate/feature-gate-const_refs_to_cell.rs b/src/test/ui/feature-gate/feature-gate-const_refs_to_cell.rs new file mode 100644 index 00000000000..63159ed0553 --- /dev/null +++ b/src/test/ui/feature-gate/feature-gate-const_refs_to_cell.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(const_refs_to_cell)] + +const FOO: () = { + let x = std::cell::Cell::new(42); + let y = &x; +}; + +fn main() { + FOO; +} diff --git a/src/test/ui/feature-gate/allow-features-empty.rs b/src/test/ui/feature-gates/allow-features-empty.rs index 88a60934927..88a60934927 100644 --- a/src/test/ui/feature-gate/allow-features-empty.rs +++ b/src/test/ui/feature-gates/allow-features-empty.rs diff --git a/src/test/ui/feature-gate/allow-features-empty.stderr b/src/test/ui/feature-gates/allow-features-empty.stderr index f88b3ea0a60..f88b3ea0a60 100644 --- a/src/test/ui/feature-gate/allow-features-empty.stderr +++ b/src/test/ui/feature-gates/allow-features-empty.stderr diff --git a/src/test/ui/feature-gate/allow-features.rs b/src/test/ui/feature-gates/allow-features.rs index 2ce4701a818..2ce4701a818 100644 --- a/src/test/ui/feature-gate/allow-features.rs +++ b/src/test/ui/feature-gates/allow-features.rs diff --git a/src/test/ui/feature-gate/allow-features.stderr b/src/test/ui/feature-gates/allow-features.stderr index 9caf48dd138..9caf48dd138 100644 --- a/src/test/ui/feature-gate/allow-features.stderr +++ b/src/test/ui/feature-gates/allow-features.stderr diff --git a/src/test/ui/feature-gate/duplicate-features.rs b/src/test/ui/feature-gates/duplicate-features.rs index d8f7818054a..d8f7818054a 100644 --- a/src/test/ui/feature-gate/duplicate-features.rs +++ b/src/test/ui/feature-gates/duplicate-features.rs diff --git a/src/test/ui/feature-gate/duplicate-features.stderr b/src/test/ui/feature-gates/duplicate-features.stderr index dbde806f6cc..dbde806f6cc 100644 --- a/src/test/ui/feature-gate/duplicate-features.stderr +++ b/src/test/ui/feature-gates/duplicate-features.stderr diff --git a/src/test/ui/feature-gate/feature-gate-c_variadic.rs b/src/test/ui/feature-gates/feature-gate-c_variadic.rs index 8b40c36c7db..8b40c36c7db 100644 --- a/src/test/ui/feature-gate/feature-gate-c_variadic.rs +++ b/src/test/ui/feature-gates/feature-gate-c_variadic.rs diff --git a/src/test/ui/feature-gate/feature-gate-c_variadic.stderr b/src/test/ui/feature-gates/feature-gate-c_variadic.stderr index 7b3af8d994f..7b3af8d994f 100644 --- a/src/test/ui/feature-gate/feature-gate-c_variadic.stderr +++ b/src/test/ui/feature-gates/feature-gate-c_variadic.stderr diff --git a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.rs b/src/test/ui/feature-gates/feature-gate-const_generics-ptr.rs deleted file mode 100644 index dc602ba7e6f..00000000000 --- a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct ConstFn<const F: fn()>; -//~^ ERROR const generics are unstable -//~^^ ERROR using function pointers as const generic parameters is forbidden - -struct ConstPtr<const P: *const u32>; -//~^ ERROR const generics are unstable -//~^^ ERROR using raw pointers as const generic parameters is forbidden - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr b/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr deleted file mode 100644 index eef465318a3..00000000000 --- a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics-ptr.rs:1:22 - | -LL | struct ConstFn<const F: fn()>; - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics-ptr.rs:5:23 - | -LL | struct ConstPtr<const P: *const u32>; - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: using function pointers as const generic parameters is forbidden - --> $DIR/feature-gate-const_generics-ptr.rs:1:25 - | -LL | struct ConstFn<const F: fn()>; - | ^^^^ - -error: using raw pointers as const generic parameters is forbidden - --> $DIR/feature-gate-const_generics-ptr.rs:5:26 - | -LL | struct ConstPtr<const P: *const u32>; - | ^^^^^^^^^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.rs b/src/test/ui/feature-gates/feature-gate-const_generics.rs index fe1ded1c4bb..06364eebef9 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics.rs +++ b/src/test/ui/feature-gates/feature-gate-const_generics.rs @@ -1,5 +1,5 @@ -fn foo<const X: ()>() {} //~ ERROR const generics are unstable +fn foo<const X: ()>() {} //~ ERROR `()` is forbidden as the type of a const generic parameter -struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable +struct Foo<const X: usize>([(); X]); fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.stderr b/src/test/ui/feature-gates/feature-gate-const_generics.stderr index f80362252f9..ed19109b38b 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_generics.stderr @@ -1,21 +1,11 @@ -error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics.rs:1:14 +error: `()` is forbidden as the type of a const generic parameter + --> $DIR/feature-gate-const_generics.rs:1:17 | LL | fn foo<const X: ()>() {} - | ^ + | ^^ | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(const_generics)]` -error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics.rs:3:18 - | -LL | struct Foo<const X: usize>([(); X]); - | ^ - | - = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information - = help: add `#![feature(min_const_generics)]` to the crate attributes to enable - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs new file mode 100644 index 00000000000..5b5ccc88873 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs @@ -0,0 +1,9 @@ +#[cfg(FALSE)] +struct A<const N: usize = 3>; +//~^ ERROR default values for const generic parameters are experimental + +#[cfg(FALSE)] +fn foo<const B: bool = false>() {} +//~^ ERROR default values for const generic parameters are experimental + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr new file mode 100644 index 00000000000..e2b48d793fd --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr @@ -0,0 +1,21 @@ +error[E0658]: default values for const generic parameters are experimental + --> $DIR/feature-gate-const_generics_defaults.rs:2:25 + | +LL | struct A<const N: usize = 3>; + | ^^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable + +error[E0658]: default values for const generic parameters are experimental + --> $DIR/feature-gate-const_generics_defaults.rs:6:22 + | +LL | fn foo<const B: bool = false>() {} + | ^^^^^^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate-inline_const.rs b/src/test/ui/feature-gates/feature-gate-inline_const.rs index 43ff90d234c..43ff90d234c 100644 --- a/src/test/ui/feature-gate-inline_const.rs +++ b/src/test/ui/feature-gates/feature-gate-inline_const.rs diff --git a/src/test/ui/feature-gate-inline_const.stderr b/src/test/ui/feature-gates/feature-gate-inline_const.stderr index be2f567155c..be2f567155c 100644 --- a/src/test/ui/feature-gate-inline_const.stderr +++ b/src/test/ui/feature-gates/feature-gate-inline_const.stderr diff --git a/src/test/ui/feature-gate-isa_attribute.rs b/src/test/ui/feature-gates/feature-gate-isa_attribute.rs index cb02a0955e9..cb02a0955e9 100644 --- a/src/test/ui/feature-gate-isa_attribute.rs +++ b/src/test/ui/feature-gates/feature-gate-isa_attribute.rs diff --git a/src/test/ui/feature-gate-isa_attribute.stderr b/src/test/ui/feature-gates/feature-gate-isa_attribute.stderr index 2a95a80ca61..2a95a80ca61 100644 --- a/src/test/ui/feature-gate-isa_attribute.stderr +++ b/src/test/ui/feature-gates/feature-gate-isa_attribute.stderr diff --git a/src/test/ui/feature-gate-optimize_attribute.rs b/src/test/ui/feature-gates/feature-gate-optimize_attribute.rs index 15aa3a6af4c..15aa3a6af4c 100644 --- a/src/test/ui/feature-gate-optimize_attribute.rs +++ b/src/test/ui/feature-gates/feature-gate-optimize_attribute.rs diff --git a/src/test/ui/feature-gate-optimize_attribute.stderr b/src/test/ui/feature-gates/feature-gate-optimize_attribute.stderr index 50ce6427e8b..50ce6427e8b 100644 --- a/src/test/ui/feature-gate-optimize_attribute.stderr +++ b/src/test/ui/feature-gates/feature-gate-optimize_attribute.stderr diff --git a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs index b6c8648a7d0..b6c8648a7d0 100644 --- a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs diff --git a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr index d96a48cde9f..d96a48cde9f 100644 --- a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr diff --git a/src/test/ui/feature-gated-feature-in-macro-arg.rs b/src/test/ui/feature-gates/feature-gated-feature-in-macro-arg.rs index 1285cca6b8b..1285cca6b8b 100644 --- a/src/test/ui/feature-gated-feature-in-macro-arg.rs +++ b/src/test/ui/feature-gates/feature-gated-feature-in-macro-arg.rs diff --git a/src/test/ui/feature-gated-feature-in-macro-arg.stderr b/src/test/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr index 218e0292776..218e0292776 100644 --- a/src/test/ui/feature-gated-feature-in-macro-arg.stderr +++ b/src/test/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs b/src/test/ui/feature-gates/issue-43106-gating-of-bench.rs index 31eee88d1fa..31eee88d1fa 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-bench.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-bench.stderr index d0305c5160f..d0305c5160f 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-bench.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.rs b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs index 6404b2c3115..6404b2c3115 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index 3ca1bd2ea7e..3ca1bd2ea7e 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index aba6c08f41d..aba6c08f41d 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index ef9c9ef48a8..ef9c9ef48a8 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs b/src/test/ui/feature-gates/issue-43106-gating-of-deprecated.rs index 5e1d08dd919..5e1d08dd919 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-deprecated.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs b/src/test/ui/feature-gates/issue-43106-gating-of-derive-2.rs index 3276309f745..3276309f745 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive-2.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-derive-2.stderr index ab165917344..ab165917344 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive-2.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs b/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs index c5d9e0db4d3..c5d9e0db4d3 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr index ffec76f409e..ffec76f409e 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs b/src/test/ui/feature-gates/issue-43106-gating-of-macro_escape.rs index de00bc4cbac..de00bc4cbac 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-macro_escape.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-macro_escape.stderr index 0eaec5202c4..0eaec5202c4 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-macro_escape.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs b/src/test/ui/feature-gates/issue-43106-gating-of-macro_use.rs index 6a7ef793924..6a7ef793924 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-macro_use.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-macro_use.stderr index 52a682e4bfa..52a682e4bfa 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-macro_use.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs b/src/test/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs index a94ffd602ef..a94ffd602ef 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr index e202b472d9c..e202b472d9c 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs index a01d85515a8..a01d85515a8 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr index 3c4dcfec02b..3c4dcfec02b 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-rustc_deprecated.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs b/src/test/ui/feature-gates/issue-43106-gating-of-stable.rs index 73ff965307f..73ff965307f 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-stable.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-stable.stderr index 2573db1d684..2573db1d684 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-stable.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-test.rs b/src/test/ui/feature-gates/issue-43106-gating-of-test.rs index ee3fe712e36..ee3fe712e36 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-test.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-test.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-test.stderr index 335af5e7905..335af5e7905 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-test.stderr diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs b/src/test/ui/feature-gates/issue-43106-gating-of-unstable.rs index d8339b00c12..d8339b00c12 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-unstable.rs diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-unstable.stderr index 500675e054c..500675e054c 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-unstable.stderr diff --git a/src/test/ui/feature-gate/issue-49983-see-issue-0.rs b/src/test/ui/feature-gates/issue-49983-see-issue-0.rs index eeb80d014b2..eeb80d014b2 100644 --- a/src/test/ui/feature-gate/issue-49983-see-issue-0.rs +++ b/src/test/ui/feature-gates/issue-49983-see-issue-0.rs diff --git a/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr b/src/test/ui/feature-gates/issue-49983-see-issue-0.stderr index 314238a34df..314238a34df 100644 --- a/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr +++ b/src/test/ui/feature-gates/issue-49983-see-issue-0.stderr diff --git a/src/test/ui/feature-gate/rustc-private.rs b/src/test/ui/feature-gates/rustc-private.rs index 7b8944bb0a0..7b8944bb0a0 100644 --- a/src/test/ui/feature-gate/rustc-private.rs +++ b/src/test/ui/feature-gates/rustc-private.rs diff --git a/src/test/ui/feature-gate/rustc-private.stderr b/src/test/ui/feature-gates/rustc-private.stderr index 1a8536d37d6..1a8536d37d6 100644 --- a/src/test/ui/feature-gate/rustc-private.stderr +++ b/src/test/ui/feature-gates/rustc-private.stderr diff --git a/src/test/ui/feature-gate/stability-attribute-consistency.rs b/src/test/ui/feature-gates/stability-attribute-consistency.rs index 6ee7003c31e..6ee7003c31e 100644 --- a/src/test/ui/feature-gate/stability-attribute-consistency.rs +++ b/src/test/ui/feature-gates/stability-attribute-consistency.rs diff --git a/src/test/ui/feature-gate/stability-attribute-consistency.stderr b/src/test/ui/feature-gates/stability-attribute-consistency.stderr index d49b44c8a35..d49b44c8a35 100644 --- a/src/test/ui/feature-gate/stability-attribute-consistency.stderr +++ b/src/test/ui/feature-gates/stability-attribute-consistency.stderr diff --git a/src/test/ui/feature-gate/unknown-feature.rs b/src/test/ui/feature-gates/unknown-feature.rs index 20fd932d4c2..20fd932d4c2 100644 --- a/src/test/ui/feature-gate/unknown-feature.rs +++ b/src/test/ui/feature-gates/unknown-feature.rs diff --git a/src/test/ui/feature-gate/unknown-feature.stderr b/src/test/ui/feature-gates/unknown-feature.stderr index e5c05872dbf..e5c05872dbf 100644 --- a/src/test/ui/feature-gate/unknown-feature.stderr +++ b/src/test/ui/feature-gates/unknown-feature.stderr diff --git a/src/test/ui/feature-gate/unstable-attribute-allow-issue-0.rs b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.rs index bffe43262e0..bffe43262e0 100644 --- a/src/test/ui/feature-gate/unstable-attribute-allow-issue-0.rs +++ b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.rs diff --git a/src/test/ui/feature-gate/unstable-attribute-allow-issue-0.stderr b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr index 7bbaf92fc68..7bbaf92fc68 100644 --- a/src/test/ui/feature-gate/unstable-attribute-allow-issue-0.stderr +++ b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr diff --git a/src/test/ui/fn/issue-80179.rs b/src/test/ui/fn/issue-80179.rs new file mode 100644 index 00000000000..7609b1525cc --- /dev/null +++ b/src/test/ui/fn/issue-80179.rs @@ -0,0 +1,27 @@ +// Functions with a type placeholder `_` as the return type should +// show a function pointer suggestion when given a function item +// and suggest how to return closures correctly from a function. +// This is a regression test of #80179 + +fn returns_i32() -> i32 { + 0 +} + +fn returns_fn_ptr() -> _ { +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121] +//~| NOTE not allowed in type signatures +//~| HELP replace with the correct return type +//~| SUGGESTION fn() -> i32 + returns_i32 +} + +fn returns_closure() -> _ { +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121] +//~| NOTE not allowed in type signatures +//~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound +//~| NOTE for more information on `Fn` traits and closure types, see +// https://doc.rust-lang.org/book/ch13-01-closures.html + || 0 +} + +fn main() {} diff --git a/src/test/ui/fn/issue-80179.stderr b/src/test/ui/fn/issue-80179.stderr new file mode 100644 index 00000000000..63571e71b34 --- /dev/null +++ b/src/test/ui/fn/issue-80179.stderr @@ -0,0 +1,21 @@ +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-80179.rs:10:24 + | +LL | fn returns_fn_ptr() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with the correct return type: `fn() -> i32` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-80179.rs:18:25 + | +LL | fn returns_closure() -> _ { + | ^ not allowed in type signatures + | + = help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound + = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/fsu-moves-and-copies.rs b/src/test/ui/fsu-moves-and-copies.rs index c41bcc73fa5..6a0b4ed17b9 100644 --- a/src/test/ui/fsu-moves-and-copies.rs +++ b/src/test/ui/fsu-moves-and-copies.rs @@ -36,7 +36,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 - // compile-fail test: borrowck-struct-update-with-dtor.rs). + // test ui/borrowck/borrowck-struct-update-with-dtor.rs). // Case 1: Nocopyable let f = DropNoFoo::new(1, 2); diff --git a/src/test/ui/functions-closures/closure-expected-type/README.md b/src/test/ui/functions-closures/closure-expected-type/README.md index fd493e1ff37..11d2c9b7fb7 100644 --- a/src/test/ui/functions-closures/closure-expected-type/README.md +++ b/src/test/ui/functions-closures/closure-expected-type/README.md @@ -5,4 +5,4 @@ inputs. This investigation was kicked off by #38714, which revealed some pretty deep flaws in the ad-hoc way that we were doing things before. -See also `src/test/compile-fail/closure-expected-type`. +See also `src/test/ui/closure-expected-type`. diff --git a/src/test/ui/generics/param-in-ct-in-ty-param-default.rs b/src/test/ui/generics/param-in-ct-in-ty-param-default.rs index dd89bc0f7a0..3c62e47381c 100644 --- a/src/test/ui/generics/param-in-ct-in-ty-param-default.rs +++ b/src/test/ui/generics/param-in-ct-in-ty-param-default.rs @@ -1,4 +1,4 @@ struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); -//~^ ERROR constant values inside of type parameter defaults +//~^ ERROR generic parameters may not be used in const operations fn main() {} diff --git a/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr b/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr index ea867240269..41a0a03ff66 100644 --- a/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr +++ b/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr @@ -1,8 +1,11 @@ -error: constant values inside of type parameter defaults must not depend on generic parameters +error: generic parameters may not be used in const operations --> $DIR/param-in-ct-in-ty-param-default.rs:1:44 | LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); - | ^ the anonymous constant must not depend on the parameter `T` + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error diff --git a/src/test/ui/hello2021.rs b/src/test/ui/hello2021.rs new file mode 100644 index 00000000000..738f151b0f6 --- /dev/null +++ b/src/test/ui/hello2021.rs @@ -0,0 +1,7 @@ +// run-pass +// edition:2021 +// compile-flags: -Zunstable-options + +fn main() { + println!("hello, 2021"); +} diff --git a/src/test/ui/hygiene/generic_params.stderr b/src/test/ui/hygiene/generic_params.stderr index 6de36deb597..4ca6d199835 100644 --- a/src/test/ui/hygiene/generic_params.stderr +++ b/src/test/ui/hygiene/generic_params.stderr @@ -6,7 +6,6 @@ LL | #![feature(decl_macro, rustc_attrs, const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/hygiene/issue-61574-const-parameters.stderr b/src/test/ui/hygiene/issue-61574-const-parameters.stderr index 3f85383eb33..b351b8b73a0 100644 --- a/src/test/ui/hygiene/issue-61574-const-parameters.stderr +++ b/src/test/ui/hygiene/issue-61574-const-parameters.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/impl-trait/bindings.stderr b/src/test/ui/impl-trait/bindings.stderr index e983fdecdba..ad5f13d0672 100644 --- a/src/test/ui/impl-trait/bindings.stderr +++ b/src/test/ui/impl-trait/bindings.stderr @@ -2,25 +2,33 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/bindings.rs:5:29 | LL | const foo: impl Clone = x; - | ^ non-constant value + | --- ^ non-constant value + | | + | help: consider using `let` instead of `const` error[E0435]: attempt to use a non-constant value in a constant --> $DIR/bindings.rs:11:33 | LL | const foo: impl Clone = x; - | ^ non-constant value + | --- ^ non-constant value + | | + | help: consider using `let` instead of `const` error[E0435]: attempt to use a non-constant value in a constant --> $DIR/bindings.rs:18:33 | LL | const foo: impl Clone = x; - | ^ non-constant value + | --- ^ non-constant value + | | + | help: consider using `let` instead of `const` error[E0435]: attempt to use a non-constant value in a constant --> $DIR/bindings.rs:25:33 | LL | const foo: impl Clone = x; - | ^ non-constant value + | --- ^ non-constant value + | | + | help: consider using `let` instead of `const` warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/bindings.rs:1:12 diff --git a/src/test/ui/issues/issue-17718-const-borrow.rs b/src/test/ui/issues/issue-17718-const-borrow.rs index 8a31bd0c66a..89316dbd5c4 100644 --- a/src/test/ui/issues/issue-17718-const-borrow.rs +++ b/src/test/ui/issues/issue-17718-const-borrow.rs @@ -2,13 +2,13 @@ use std::cell::UnsafeCell; const A: UnsafeCell<usize> = UnsafeCell::new(1); const B: &'static UnsafeCell<usize> = &A; -//~^ ERROR: cannot borrow a constant which may contain interior mutability +//~^ ERROR: cannot refer to interior mutable struct C { a: UnsafeCell<usize> } const D: C = C { a: UnsafeCell::new(1) }; const E: &'static UnsafeCell<usize> = &D.a; -//~^ ERROR: cannot borrow a constant which may contain interior mutability +//~^ ERROR: cannot refer to interior mutable const F: &'static C = &D; -//~^ ERROR: cannot borrow a constant which may contain interior mutability +//~^ ERROR: cannot refer to interior mutable fn main() {} diff --git a/src/test/ui/issues/issue-17718-const-borrow.stderr b/src/test/ui/issues/issue-17718-const-borrow.stderr index b4330049689..e3ff6c923ad 100644 --- a/src/test/ui/issues/issue-17718-const-borrow.stderr +++ b/src/test/ui/issues/issue-17718-const-borrow.stderr @@ -1,20 +1,20 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/issue-17718-const-borrow.rs:4:39 | LL | const B: &'static UnsafeCell<usize> = &A; - | ^^ + | ^^ this borrow of an interior mutable value may end up in the final value -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/issue-17718-const-borrow.rs:9:39 | LL | const E: &'static UnsafeCell<usize> = &D.a; - | ^^^^ + | ^^^^ this borrow of an interior mutable value may end up in the final value -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0492]: constants cannot refer to interior mutable data --> $DIR/issue-17718-const-borrow.rs:11:23 | LL | const F: &'static C = &D; - | ^^ + | ^^ this borrow of an interior mutable value may end up in the final value error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index 3f7226c79bf..5fed02164b5 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `[i32]` cannot be known at compilation LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^ doesn't have a size known at compile-time | - ::: $SRC_DIR/alloc/src/vec.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { | - required by this bound in `Vec` diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index ce3bffe602c..ff7e884ea6f 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,11 +1,10 @@ -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` +error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next` --> $DIR/issue-23122-2.rs:9:5 | LL | type Next = <GetNext<T::Next> as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) - = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26996.rs b/src/test/ui/issues/issue-26996.rs index 04382be27d7..84037b72a27 100644 --- a/src/test/ui/issues/issue-26996.rs +++ b/src/test/ui/issues/issue-26996.rs @@ -1,6 +1,6 @@ // run-pass -// This test is bogus (i.e., should be compile-fail) during the period +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/issues/issue-27021.rs b/src/test/ui/issues/issue-27021.rs index 30551375450..ef3b114a5fa 100644 --- a/src/test/ui/issues/issue-27021.rs +++ b/src/test/ui/issues/issue-27021.rs @@ -1,6 +1,6 @@ // run-pass -// This test is bogus (i.e., should be compile-fail) during the period +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/issues/issue-27433.stderr b/src/test/ui/issues/issue-27433.stderr index e232d17e6d7..201b7e8549c 100644 --- a/src/test/ui/issues/issue-27433.stderr +++ b/src/test/ui/issues/issue-27433.stderr @@ -2,7 +2,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-27433.rs:3:23 | LL | const FOO : u32 = foo; - | ^^^ non-constant value + | --- ^^^ non-constant value + | | + | help: consider using `let` instead of `const` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs b/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs index aea9fde5309..43c0bfb26cd 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a lifetime param // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-lifetime-param.rs +// Compare with ui/span/issue28498-reject-lifetime-param.rs #![feature(dropck_eyepatch)] diff --git a/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs b/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs index 91ef5a7c98d..23fd86a093b 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a type param in negative position // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-lifetime-param.rs +// Compare with ui/span/issue28498-reject-lifetime-param.rs // Demonstrate that a type param in negative position causes dropck to reject code // that might indirectly access previously dropped value. diff --git a/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs b/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs index 808f3b6e81e..61d11cf3834 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a trait bound // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-trait-bound.rs +// Compare with ui/span/issue28498-reject-trait-bound.rs #![feature(dropck_eyepatch)] diff --git a/src/test/ui/issues/issue-3521-2.stderr b/src/test/ui/issues/issue-3521-2.stderr index d54bbbcdc33..ba29d1becb8 100644 --- a/src/test/ui/issues/issue-3521-2.stderr +++ b/src/test/ui/issues/issue-3521-2.stderr @@ -2,7 +2,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-3521-2.rs:4:23 | LL | static y: isize = foo + 1; - | ^^^ non-constant value + | - ^^^ non-constant value + | | + | help: consider using `let` instead of `static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3521.stderr b/src/test/ui/issues/issue-3521.stderr index ae199875269..8473526006c 100644 --- a/src/test/ui/issues/issue-3521.stderr +++ b/src/test/ui/issues/issue-3521.stderr @@ -1,6 +1,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-3521.rs:6:15 | +LL | let foo = 100; + | --- help: consider using `const` instead of `let` +... LL | Bar = foo | ^^^ non-constant value diff --git a/src/test/ui/issues/issue-3668-2.stderr b/src/test/ui/issues/issue-3668-2.stderr index d6a6e837960..7cee497b0bc 100644 --- a/src/test/ui/issues/issue-3668-2.stderr +++ b/src/test/ui/issues/issue-3668-2.stderr @@ -2,7 +2,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-3668-2.rs:2:27 | LL | static child: isize = x + 1; - | ^ non-constant value + | ----- ^ non-constant value + | | + | help: consider using `let` instead of `static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3668.stderr b/src/test/ui/issues/issue-3668.stderr index 98cd3631a53..e45472929ab 100644 --- a/src/test/ui/issues/issue-3668.stderr +++ b/src/test/ui/issues/issue-3668.stderr @@ -2,7 +2,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-3668.rs:8:34 | LL | static childVal: Box<P> = self.child.get(); - | ^^^^ non-constant value + | -------- ^^^^ non-constant value + | | + | help: consider using `let` instead of `static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39559.rs b/src/test/ui/issues/issue-39559.rs index 3a75956af52..58d25940733 100644 --- a/src/test/ui/issues/issue-39559.rs +++ b/src/test/ui/issues/issue-39559.rs @@ -12,7 +12,7 @@ impl Dim for Dim3 { pub struct Vector<T, D: Dim> { entries: [T; D::dim()], - //~^ ERROR no function or associated item named `dim` found + //~^ ERROR generic parameters may not be used _dummy: D, } diff --git a/src/test/ui/issues/issue-39559.stderr b/src/test/ui/issues/issue-39559.stderr index 5e8d487f416..91e31ca0bd8 100644 --- a/src/test/ui/issues/issue-39559.stderr +++ b/src/test/ui/issues/issue-39559.stderr @@ -1,11 +1,11 @@ -error[E0599]: no function or associated item named `dim` found for type parameter `D` in the current scope - --> $DIR/issue-39559.rs:14:21 +error: generic parameters may not be used in const operations + --> $DIR/issue-39559.rs:14:18 | LL | entries: [T; D::dim()], - | ^^^ function or associated item not found in `D` + | ^^^^^^ cannot perform const operation using `D` | - = help: items from traits can only be used if the type parameter is bounded by the trait + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/issues/issue-42060.stderr b/src/test/ui/issues/issue-42060.stderr index 72408c79194..dc089b856bb 100644 --- a/src/test/ui/issues/issue-42060.stderr +++ b/src/test/ui/issues/issue-42060.stderr @@ -1,12 +1,16 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:3:23 | +LL | let thing = (); + | ----- help: consider using `const` instead of `let` LL | let other: typeof(thing) = thing; | ^^^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:9:13 | +LL | let q = 1; + | - help: consider using `const` instead of `let` LL | <typeof(q)>::N | ^ non-constant value diff --git a/src/test/ui/issues/issue-44239.stderr b/src/test/ui/issues/issue-44239.stderr index bc5a6a03f03..bbd3d116c96 100644 --- a/src/test/ui/issues/issue-44239.stderr +++ b/src/test/ui/issues/issue-44239.stderr @@ -1,6 +1,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-44239.rs:6:26 | +LL | let n = 0; + | - help: consider using `const` instead of `let` +... LL | const N: usize = n; | ^ non-constant value diff --git a/src/test/ui/issues/issue-49298.rs b/src/test/ui/issues/issue-49298.rs index 697a160b4ec..e3ffa8e7c6e 100644 --- a/src/test/ui/issues/issue-49298.rs +++ b/src/test/ui/issues/issue-49298.rs @@ -2,7 +2,7 @@ #![feature(test)] #![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 +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/issues/issue-59508-1.stderr b/src/test/ui/issues/issue-59508-1.stderr index 2a4ccda8929..5e97339f148 100644 --- a/src/test/ui/issues/issue-59508-1.stderr +++ b/src/test/ui/issues/issue-59508-1.stderr @@ -12,7 +12,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/issues/issue-59508.stderr b/src/test/ui/issues/issue-59508.stderr index c0fdb2ef34a..33e967cebff 100644 --- a/src/test/ui/issues/issue-59508.stderr +++ b/src/test/ui/issues/issue-59508.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-59508.rs:10:25 | LL | pub fn do_things<T, 'a, 'b: 'a>() { - | ----^^--^^----- help: reorder the parameters: lifetimes, then types: `<'a, 'b: 'a, T>` + | ----^^--^^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b: 'a, T>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-80512-param-reordering-with-defaults.rs b/src/test/ui/issues/issue-80512-param-reordering-with-defaults.rs new file mode 100644 index 00000000000..fe3e4fbc7e0 --- /dev/null +++ b/src/test/ui/issues/issue-80512-param-reordering-with-defaults.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +struct S<T = (), 'a>(&'a T); +//~^ ERROR lifetime parameters must be declared prior to type parameters diff --git a/src/test/ui/issues/issue-80512-param-reordering-with-defaults.stderr b/src/test/ui/issues/issue-80512-param-reordering-with-defaults.stderr new file mode 100644 index 00000000000..a1e9a903f81 --- /dev/null +++ b/src/test/ui/issues/issue-80512-param-reordering-with-defaults.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18 + | +LL | struct S<T = (), 'a>(&'a T); + | ---------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = ()>` + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-80607.rs b/src/test/ui/issues/issue-80607.rs new file mode 100644 index 00000000000..63f4df359b8 --- /dev/null +++ b/src/test/ui/issues/issue-80607.rs @@ -0,0 +1,10 @@ +// This tests makes sure the diagnostics print the offending enum variant, not just the type. +pub enum Enum { + V1(i32), +} + +pub fn foo(x: i32) -> Enum { + Enum::V1 { x } //~ ERROR `Enum::V1` has no field named `x` +} + +fn main() {} diff --git a/src/test/ui/issues/issue-80607.stderr b/src/test/ui/issues/issue-80607.stderr new file mode 100644 index 00000000000..5375478942b --- /dev/null +++ b/src/test/ui/issues/issue-80607.stderr @@ -0,0 +1,14 @@ +error[E0559]: variant `Enum::V1` has no field named `x` + --> $DIR/issue-80607.rs:7:16 + | +LL | V1(i32), + | -- `Enum::V1` defined here +... +LL | Enum::V1 { x } + | -------- ^ field does not exist + | | + | `Enum::V1` is a tuple variant, use the appropriate syntax: `Enum::V1(/* fields */)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0559`. diff --git a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs index 44cb74815c6..46ae9403c03 100644 --- a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs +++ b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs @@ -4,7 +4,7 @@ pub const fn sof<T>() -> usize { fn test<T>() { let _: [u8; sof::<T>()]; - //~^ ERROR the size for values of type `T` + //~^ ERROR generic parameters may not be used in const operations } fn main() {} diff --git a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr index 5a6c86d133b..5c167ea0834 100644 --- a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr +++ b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr @@ -1,19 +1,11 @@ -error[E0277]: the size for values of type `T` cannot be known at compilation time +error: generic parameters may not be used in const operations --> $DIR/feature-gate-lazy_normalization_consts.rs:6:23 | -LL | pub const fn sof<T>() -> usize { - | - required by this bound in `sof` -... -LL | fn test<T>() { - | - this type parameter needs to be `Sized` LL | let _: [u8; sof::<T>()]; - | ^ doesn't have a size known at compile-time + | ^ cannot perform const operation using `T` | -help: consider relaxing the implicit `Sized` restriction - | -LL | pub const fn sof<T: ?Sized>() -> usize { - | ^^^^^^^^ + = note: type parameters may not be used in const expressions + = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/lifetime-before-type-params.stderr b/src/test/ui/lifetime-before-type-params.stderr index 76d7d0f024d..047bc7f6d90 100644 --- a/src/test/ui/lifetime-before-type-params.stderr +++ b/src/test/ui/lifetime-before-type-params.stderr @@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:2:13 | LL | fn first<T, 'a, 'b>() {} - | ----^^--^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | ----^^--^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:4:18 | LL | fn second<'a, T, 'b>() {} - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:6:16 | LL | fn third<T, U, 'a>() {} - | -------^^- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` + | -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:8:18 | LL | fn fourth<'a, T, 'b, U, 'c, V>() {} - | --------^^-----^^---- help: reorder the parameters: lifetimes, then types: `<'a, 'b, 'c, T, U, V>` + | --------^^-----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` error: aborting due to 4 previous errors diff --git a/src/test/compile-fail/invalid-link-args.rs b/src/test/ui/linkage-attr/invalid-link-args.rs index 1e68b4f8b70..5eb1c637f09 100644 --- a/src/test/compile-fail/invalid-link-args.rs +++ b/src/test/ui/linkage-attr/invalid-link-args.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // ignore-msvc due to linker-flavor=ld // error-pattern:aFdEfSeVEEE // compile-flags: -C linker-flavor=ld diff --git a/src/test/compile-fail/issue-10755.rs b/src/test/ui/linkage-attr/issue-10755.rs index 3c6fcddc0d2..5ce69bceed3 100644 --- a/src/test/compile-fail/issue-10755.rs +++ b/src/test/ui/linkage-attr/issue-10755.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // compile-flags: -C linker=llllll -C linker-flavor=ld // error-pattern: linker `llllll` not found diff --git a/src/test/ui/lint/expansion-time.rs b/src/test/ui/lint/expansion-time.rs index a9c7ac363b0..f23c7cb0dca 100644 --- a/src/test/ui/lint/expansion-time.rs +++ b/src/test/ui/lint/expansion-time.rs @@ -5,6 +5,10 @@ macro_rules! foo { ( $($i:ident)* ) => { $($i)+ }; //~ WARN meta-variable repeats with different Kleene operator } +#[warn(missing_fragment_specifier)] +macro_rules! m { ($i) => {} } //~ WARN missing fragment specifier + //~| WARN this was previously accepted + #[warn(soft_unstable)] mod benches { #[bench] //~ WARN use of unstable library feature 'test' diff --git a/src/test/ui/lint/expansion-time.stderr b/src/test/ui/lint/expansion-time.stderr index 24e2733064e..b0fc1f8e5ee 100644 --- a/src/test/ui/lint/expansion-time.stderr +++ b/src/test/ui/lint/expansion-time.stderr @@ -12,14 +12,28 @@ note: the lint level is defined here LL | #[warn(meta_variable_misuse)] | ^^^^^^^^^^^^^^^^^^^^ +warning: missing fragment specifier + --> $DIR/expansion-time.rs:9:19 + | +LL | macro_rules! m { ($i) => {} } + | ^^ + | +note: the lint level is defined here + --> $DIR/expansion-time.rs:8:8 + | +LL | #[warn(missing_fragment_specifier)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = 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 #40107 <https://github.com/rust-lang/rust/issues/40107> + warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable - --> $DIR/expansion-time.rs:10:7 + --> $DIR/expansion-time.rs:14:7 | LL | #[bench] | ^^^^^ | note: the lint level is defined here - --> $DIR/expansion-time.rs:8:8 + --> $DIR/expansion-time.rs:12:8 | LL | #[warn(soft_unstable)] | ^^^^^^^^^^^^^ @@ -33,10 +47,10 @@ LL | 2 | ^ | note: the lint level is defined here - --> $DIR/expansion-time.rs:25:8 + --> $DIR/expansion-time.rs:29:8 | LL | #[warn(incomplete_include)] | ^^^^^^^^^^^^^^^^^^ -warning: 3 warnings emitted +warning: 4 warnings emitted diff --git a/src/test/ui/lint/function-item-references.rs b/src/test/ui/lint/function-item-references.rs index 5f7f5e66eaa..05213f4ed4b 100644 --- a/src/test/ui/lint/function-item-references.rs +++ b/src/test/ui/lint/function-item-references.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(c_variadic, min_const_generics)] +#![feature(c_variadic)] #![warn(function_item_references)] use std::fmt::Pointer; use std::fmt::Formatter; diff --git a/src/test/ui/lint/lint-const-item-mutation.stderr b/src/test/ui/lint/lint-const-item-mutation.stderr index 74505eeb987..3973af540c8 100644 --- a/src/test/ui/lint/lint-const-item-mutation.stderr +++ b/src/test/ui/lint/lint-const-item-mutation.stderr @@ -107,7 +107,7 @@ LL | VEC.push(0); = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: mutable reference created due to call to this method - --> $SRC_DIR/alloc/src/vec.rs:LL:COL + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | / pub fn push(&mut self, value: T) { LL | | // This will panic or abort if we would allocate > isize::MAX bytes diff --git a/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.rs b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.rs new file mode 100644 index 00000000000..8cc4f976a4b --- /dev/null +++ b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.rs @@ -0,0 +1,19 @@ +#![warn(unused)] +#![allow(dead_code)] +#![deny(non_snake_case)] + +mod Impl {} +//~^ ERROR module `Impl` should have a snake case name + +fn While() {} +//~^ ERROR function `While` should have a snake case name + +fn main() { + let Mod: usize = 0; + //~^ ERROR variable `Mod` should have a snake case name + //~^^ WARN unused variable: `Mod` + + let Super: usize = 0; + //~^ ERROR variable `Super` should have a snake case name + //~^^ WARN unused variable: `Super` +} diff --git a/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr new file mode 100644 index 00000000000..c179f4a25bd --- /dev/null +++ b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr @@ -0,0 +1,67 @@ +warning: unused variable: `Mod` + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9 + | +LL | let Mod: usize = 0; + | ^^^ help: if this is intentional, prefix it with an underscore: `_Mod` + | +note: the lint level is defined here + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:1:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` + +warning: unused variable: `Super` + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9 + | +LL | let Super: usize = 0; + | ^^^^^ help: if this is intentional, prefix it with an underscore: `_Super` + +error: module `Impl` should have a snake case name + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:5:5 + | +LL | mod Impl {} + | ^^^^ + | +note: the lint level is defined here + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:3:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ +help: rename the identifier or convert it to a snake case raw identifier + | +LL | mod r#impl {} + | ^^^^^^ + +error: function `While` should have a snake case name + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:8:4 + | +LL | fn While() {} + | ^^^^^ + | +help: rename the identifier or convert it to a snake case raw identifier + | +LL | fn r#while() {} + | ^^^^^^^ + +error: variable `Mod` should have a snake case name + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9 + | +LL | let Mod: usize = 0; + | ^^^ + | +help: rename the identifier or convert it to a snake case raw identifier + | +LL | let r#mod: usize = 0; + | ^^^^^ + +error: variable `Super` should have a snake case name + --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9 + | +LL | let Super: usize = 0; + | ^^^^^ help: rename the identifier + | + = note: `super` cannot be used as a raw identifier + +error: aborting due to 4 previous errors; 2 warnings emitted + diff --git a/src/test/compile-fail/must_use-in-stdlib-traits.rs b/src/test/ui/lint/must_use-in-stdlib-traits.rs index 70dddf61fb7..70dddf61fb7 100644 --- a/src/test/compile-fail/must_use-in-stdlib-traits.rs +++ b/src/test/ui/lint/must_use-in-stdlib-traits.rs diff --git a/src/test/ui/lint/must_use-in-stdlib-traits.stderr b/src/test/ui/lint/must_use-in-stdlib-traits.stderr new file mode 100644 index 00000000000..76978d29dc8 --- /dev/null +++ b/src/test/ui/lint/must_use-in-stdlib-traits.stderr @@ -0,0 +1,47 @@ +error: unused implementer of `Iterator` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:42:4 + | +LL | iterator(); + | ^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/must_use-in-stdlib-traits.rs:1:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + = note: iterators are lazy and do nothing unless consumed + +error: unused implementer of `Future` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:43:4 + | +LL | future(); + | ^^^^^^^^^ + | + = note: futures do nothing unless you `.await` or poll them + +error: unused implementer of `FnOnce` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:44:4 + | +LL | square_fn_once(); + | ^^^^^^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: unused implementer of `FnMut` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:45:4 + | +LL | square_fn_mut(); + | ^^^^^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: unused implementer of `Fn` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:46:4 + | +LL | square_fn(); + | ^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs index 4592bc31a39..8c79630b7fd 100644 --- a/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs +++ b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs @@ -1,10 +1,6 @@ -// check-pass -// This test should stop compiling -// we decide to enable this lint for item statements. - #![deny(redundant_semicolons)] fn main() { - fn inner() {}; - struct Bar {}; + fn inner() {}; //~ ERROR unnecessary + struct Bar {}; //~ ERROR unnecessary } diff --git a/src/test/ui/lint/redundant-semicolon/item-stmt-semi.stderr b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.stderr new file mode 100644 index 00000000000..451b152cbe5 --- /dev/null +++ b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.stderr @@ -0,0 +1,20 @@ +error: unnecessary trailing semicolon + --> $DIR/item-stmt-semi.rs:4:18 + | +LL | fn inner() {}; + | ^ help: remove this semicolon + | +note: the lint level is defined here + --> $DIR/item-stmt-semi.rs:1:9 + | +LL | #![deny(redundant_semicolons)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unnecessary trailing semicolon + --> $DIR/item-stmt-semi.rs:5:18 + | +LL | struct Bar {}; + | ^ help: remove this semicolon + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/asm-src-loc-codegen-units.rs b/src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs index 5b8690c3b98..387822d00f6 100644 --- a/src/test/compile-fail/asm-src-loc-codegen-units.rs +++ b/src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // compile-flags: -C codegen-units=2 // ignore-emscripten diff --git a/src/test/compile-fail/asm-src-loc.rs b/src/test/ui/llvm-asm/asm-src-loc.rs index 7c87f370d4f..063066df11c 100644 --- a/src/test/compile-fail/asm-src-loc.rs +++ b/src/test/ui/llvm-asm/asm-src-loc.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // ignore-emscripten #![feature(llvm_asm)] diff --git a/src/test/ui/macros/edition-macro-pats.rs b/src/test/ui/macros/edition-macro-pats.rs new file mode 100644 index 00000000000..ea1f9bff6bf --- /dev/null +++ b/src/test/ui/macros/edition-macro-pats.rs @@ -0,0 +1,14 @@ +// run-pass + +#![feature(or_patterns)] +#![feature(edition_macro_pats)] + +macro_rules! foo { + (a $x:pat2018) => {}; + (b $x:pat2021) => {}; +} + +fn main() { + foo!(a None); + foo!(b 1 | 2); +} diff --git a/src/test/ui/macros/issue-39404.rs b/src/test/ui/macros/issue-39404.rs index 054958ba00b..2229f2c3900 100644 --- a/src/test/ui/macros/issue-39404.rs +++ b/src/test/ui/macros/issue-39404.rs @@ -2,5 +2,6 @@ macro_rules! m { ($i) => {} } //~^ ERROR missing fragment specifier +//~| WARN previously accepted fn main() {} diff --git a/src/test/ui/macros/issue-39404.stderr b/src/test/ui/macros/issue-39404.stderr index 645f06e59d8..d2f2a823c2a 100644 --- a/src/test/ui/macros/issue-39404.stderr +++ b/src/test/ui/macros/issue-39404.stderr @@ -3,6 +3,10 @@ error: missing fragment specifier | LL | macro_rules! m { ($i) => {} } | ^^ + | + = note: `#[deny(missing_fragment_specifier)]` on by default + = 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 #40107 <https://github.com/rust-lang/rust/issues/40107> error: aborting due to previous error diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index e5e656de6fa..c46274d59b6 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -8,7 +8,7 @@ // to it being e.g., a place where the addition of an argument // causes it to go down a code path with subtly different behavior). // -// There is a companion test in compile-fail. +// There is a companion failing test. // compile-flags: --test -C debug_assertions=yes // revisions: std core @@ -68,26 +68,26 @@ fn to_format_or_not_to_format() { assert!(true, "{}",); - // assert_eq!(1, 1, "{}",); // see compile-fail - // assert_ne!(1, 2, "{}",); // see compile-fail + // assert_eq!(1, 1, "{}",); // see check-fail + // assert_ne!(1, 2, "{}",); // see check-fail debug_assert!(true, "{}",); - // debug_assert_eq!(1, 1, "{}",); // see compile-fail - // debug_assert_ne!(1, 2, "{}",); // see compile-fail - // eprint!("{}",); // see compile-fail - // eprintln!("{}",); // see compile-fail - // format!("{}",); // see compile-fail - // format_args!("{}",); // see compile-fail + // debug_assert_eq!(1, 1, "{}",); // see check-fail + // debug_assert_ne!(1, 2, "{}",); // see check-fail + // eprint!("{}",); // see check-fail + // eprintln!("{}",); // see check-fail + // format!("{}",); // see check-fail + // format_args!("{}",); // see check-fail if falsum() { panic!("{}",); } - // print!("{}",); // see compile-fail - // println!("{}",); // see compile-fail - // unimplemented!("{}",); // see compile-fail + // print!("{}",); // see check-fail + // println!("{}",); // see check-fail + // unimplemented!("{}",); // see check-fail if falsum() { unreachable!("{}",); } - // write!(&mut stdout, "{}",); // see compile-fail - // writeln!(&mut stdout, "{}",); // see compile-fail + // write!(&mut stdout, "{}",); // see check-fail + // writeln!(&mut stdout, "{}",); // see check-fail } diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index dd0cac659fd..ac15e9fa8ea 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -23,22 +23,28 @@ LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:54:19 + --> $DIR/macro-comma-behavior.rs:52:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:72:21 + --> $DIR/macro-comma-behavior.rs:68:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:81:24 + --> $DIR/macro-comma-behavior.rs:77:24 | LL | write!(f, "{}",)?; | ^^ -error: aborting due to 7 previous errors +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:81:26 + | +LL | writeln!(f, "{}",)?; + | ^^ + +error: aborting due to 8 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 0bfe0683078..27d50ff3d57 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -40,10 +40,8 @@ fn to_format_or_not_to_format() { } #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // eprintln!("{}",); - // <DISABLED> [std]~^ ERROR no arguments + eprintln!("{}",); + //[std]~^ ERROR no arguments } #[cfg(std)] { @@ -63,10 +61,8 @@ fn to_format_or_not_to_format() { } #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // println!("{}",); - // <DISABLED> [std]~^ ERROR no arguments + println!("{}",); + //[std]~^ ERROR no arguments } unimplemented!("{}",); @@ -82,11 +78,9 @@ fn to_format_or_not_to_format() { //[core]~^ ERROR no arguments //[std]~^^ ERROR no arguments - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // writeln!(f, "{}",)?; - // <DISABLED> [core]~^ ERROR no arguments - // <DISABLED> [std]~^^ ERROR no arguments + writeln!(f, "{}",)?; + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments Ok(()) } } diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index 4372d89fbf5..7fd060e2224 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -29,34 +29,52 @@ LL | eprint!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:50:18 + --> $DIR/macro-comma-behavior.rs:43:20 + | +LL | eprintln!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:48:18 | LL | format!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:54:19 + --> $DIR/macro-comma-behavior.rs:52:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:61:17 + --> $DIR/macro-comma-behavior.rs:59:17 | LL | print!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:72:21 + --> $DIR/macro-comma-behavior.rs:64:19 + | +LL | println!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:68:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:81:24 + --> $DIR/macro-comma-behavior.rs:77:24 | LL | write!(f, "{}",)?; | ^^ -error: aborting due to 10 previous errors +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:81:26 + | +LL | writeln!(f, "{}",)?; + | ^^ + +error: aborting due to 13 previous errors diff --git a/src/test/ui/macros/macro-comma-support-rpass.rs b/src/test/ui/macros/macro-comma-support-rpass.rs index 50c0ef3451d..f6c4f896d67 100644 --- a/src/test/ui/macros/macro-comma-support-rpass.rs +++ b/src/test/ui/macros/macro-comma-support-rpass.rs @@ -68,7 +68,7 @@ fn column() { let _ = column!(); } -// compile_error! is in a companion to this test in compile-fail +// compile_error! is in a check-fail companion to this test #[test] fn concat() { diff --git a/src/test/ui/macros/macro-match-nonterminal.rs b/src/test/ui/macros/macro-match-nonterminal.rs index 6b023e41372..b23e5c71c03 100644 --- a/src/test/ui/macros/macro-match-nonterminal.rs +++ b/src/test/ui/macros/macro-match-nonterminal.rs @@ -2,6 +2,7 @@ macro_rules! test { ($a, $b) => { //~^ ERROR missing fragment //~| ERROR missing fragment + //~| WARN this was previously accepted () }; } diff --git a/src/test/ui/macros/macro-match-nonterminal.stderr b/src/test/ui/macros/macro-match-nonterminal.stderr index 334d62812cd..674ce3434aa 100644 --- a/src/test/ui/macros/macro-match-nonterminal.stderr +++ b/src/test/ui/macros/macro-match-nonterminal.stderr @@ -9,6 +9,10 @@ error: missing fragment specifier | LL | ($a, $b) => { | ^^ + | + = note: `#[deny(missing_fragment_specifier)]` on by default + = 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 #40107 <https://github.com/rust-lang/rust/issues/40107> error: aborting due to 2 previous errors diff --git a/src/test/compile-fail/not-utf8.bin b/src/test/ui/macros/not-utf8.bin index 4148e5b88fe..4148e5b88fe 100644 --- a/src/test/compile-fail/not-utf8.bin +++ b/src/test/ui/macros/not-utf8.bin Binary files differdiff --git a/src/test/compile-fail/not-utf8.rs b/src/test/ui/macros/not-utf8.rs index 1cb1fdcb8c9..1cb1fdcb8c9 100644 --- a/src/test/compile-fail/not-utf8.rs +++ b/src/test/ui/macros/not-utf8.rs diff --git a/src/test/ui/macros/not-utf8.stderr b/src/test/ui/macros/not-utf8.stderr new file mode 100644 index 00000000000..f47be14fae3 --- /dev/null +++ b/src/test/ui/macros/not-utf8.stderr @@ -0,0 +1,10 @@ +error: couldn't read $DIR/not-utf8.bin: stream did not contain valid UTF-8 + --> $DIR/not-utf8.rs:4:5 + | +LL | include!("not-utf8.bin") + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr new file mode 100644 index 00000000000..583b2c4cfe0 --- /dev/null +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/meta-expected-error-wrong-rev.rs:13:18 + | +LL | let x: u32 = 22_usize; + | --- ^^^^^^^^ expected `u32`, found `usize` + | | + | expected due to this + | +help: change the type of the numeric literal from `usize` to `u32` + | +LL | let x: u32 = 22_u32; + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/compile-fail/meta-expected-error-wrong-rev.rs b/src/test/ui/meta/meta-expected-error-wrong-rev.rs index 7e49434142b..7e49434142b 100644 --- a/src/test/compile-fail/meta-expected-error-wrong-rev.rs +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.rs diff --git a/src/test/ui/mir/mir-inlining/array-clone-with-generic-size.rs b/src/test/ui/mir/mir-inlining/array-clone-with-generic-size.rs index 8a96303e6b9..eec0a4599c3 100644 --- a/src/test/ui/mir/mir-inlining/array-clone-with-generic-size.rs +++ b/src/test/ui/mir/mir-inlining/array-clone-with-generic-size.rs @@ -3,8 +3,6 @@ // // build-pass // compile-flags: -Zmir-opt-level=2 -Zvalidate-mir -#![feature(min_const_generics)] - #[derive(Clone)] struct Array<T, const N: usize>([T; N]); diff --git a/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.rs b/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.rs new file mode 100644 index 00000000000..2437155d981 --- /dev/null +++ b/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.rs @@ -0,0 +1,21 @@ +// Ensures -Zmir-opt-level=2 (specifically, inlining) is not allowed with -Zinstrument-coverage. +// Regression test for issue #80060. +// +// needs-profiler-support +// build-pass +// compile-flags: -Zmir-opt-level=2 -Zinstrument-coverage +#[inline(never)] +fn foo() {} + +pub fn baz() { + bar(); +} + +#[inline(always)] +fn bar() { + foo(); +} + +fn main() { + bar(); +} diff --git a/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.stderr b/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.stderr new file mode 100644 index 00000000000..eb50e5075ca --- /dev/null +++ b/src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.stderr @@ -0,0 +1,2 @@ +warning: `-Z mir-opt-level=2` (or any level > 1) enables function inlining, which is incompatible with `-Z instrument-coverage`. Inlining will be disabled. + diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/ui/never_type/issue-52443.rs index 4519833b864..4519833b864 100644 --- a/src/test/compile-fail/issue-52443.rs +++ b/src/test/ui/never_type/issue-52443.rs diff --git a/src/test/ui/never_type/issue-52443.stderr b/src/test/ui/never_type/issue-52443.stderr new file mode 100644 index 00000000000..051896cb89c --- /dev/null +++ b/src/test/ui/never_type/issue-52443.stderr @@ -0,0 +1,57 @@ +warning: denote infinite loops with `loop { ... }` + --> $DIR/issue-52443.rs:6:11 + | +LL | [(); {while true {break}; 0}]; + | ^^^^^^^^^^ help: use `loop` + | + = note: `#[warn(while_true)]` on by default + +error[E0744]: `for` is not allowed in a `const` + --> $DIR/issue-52443.rs:9:12 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-52443.rs:2:10 + | +LL | [(); & { loop { continue } } ]; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `usize`, found reference + | help: consider removing the borrow: `{ loop { continue } }` + | + = note: expected type `usize` + found reference `&_` + +error[E0308]: mismatched types + --> $DIR/issue-52443.rs:4:17 + | +LL | [(); loop { break }]; + | ^^^^^ + | | + | expected `usize`, found `()` + | help: give it a value of the expected type: `break 42` + +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + +error[E0764]: mutable references are not allowed in constants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ `&mut` is only allowed in `const fn` + +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + +error: aborting due to 6 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0015, E0308, E0744, E0764. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/nll/closures-in-loops.stderr b/src/test/ui/nll/closures-in-loops.stderr index 37638a93d77..2f134f83ced 100644 --- a/src/test/ui/nll/closures-in-loops.stderr +++ b/src/test/ui/nll/closures-in-loops.stderr @@ -15,7 +15,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time LL | v.push(|| x = String::new()); | ^^ - borrows occur due to use of `x` in closure | | - | mutable borrow starts here in previous iteration of loop + | `x` was mutably borrowed here in the previous iteration of the loop error[E0524]: two closures require unique access to `x` at the same time --> $DIR/closures-in-loops.rs:20:16 diff --git a/src/test/ui/nll/issue-62007-assign-const-index.stderr b/src/test/ui/nll/issue-62007-assign-const-index.stderr index 758a14d0177..0db9fe62c38 100644 --- a/src/test/ui/nll/issue-62007-assign-const-index.stderr +++ b/src/test/ui/nll/issue-62007-assign-const-index.stderr @@ -5,7 +5,7 @@ LL | fn to_refs<T>(mut list: [&mut List<T>; 2]) -> Vec<&mut T> { | - let's call the lifetime of this reference `'1` ... LL | result.push(&mut list[0].value); - | ^^^^^^^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop + | ^^^^^^^^^^^^^^^^^^ `list[_].value` was mutably borrowed here in the previous iteration of the loop ... LL | return result; | ------ returning this value requires that `list[_].value` is borrowed for `'1` @@ -19,7 +19,7 @@ LL | fn to_refs<T>(mut list: [&mut List<T>; 2]) -> Vec<&mut T> { LL | if let Some(n) = list[0].next.as_mut() { | ^^^^^^^^^^^^--------- | | - | mutable borrow starts here in previous iteration of loop + | `list[_].next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list[_].next` is borrowed for `'1` error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/issue-62007-assign-differing-fields.stderr b/src/test/ui/nll/issue-62007-assign-differing-fields.stderr index f942d7628b5..f1af2e855af 100644 --- a/src/test/ui/nll/issue-62007-assign-differing-fields.stderr +++ b/src/test/ui/nll/issue-62007-assign-differing-fields.stderr @@ -5,7 +5,7 @@ LL | fn to_refs<'a, T>(mut list: (&'a mut List<T>, &'a mut List<T>)) -> Vec<&'a | -- lifetime `'a` defined here ... LL | result.push(&mut (list.0).value); - | ^^^^^^^^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop + | ^^^^^^^^^^^^^^^^^^^ `list.0.value` was mutably borrowed here in the previous iteration of the loop ... LL | return result; | ------ returning this value requires that `list.0.value` is borrowed for `'a` @@ -19,7 +19,7 @@ LL | fn to_refs<'a, T>(mut list: (&'a mut List<T>, &'a mut List<T>)) -> Vec<&'a LL | if let Some(n) = (list.0).next.as_mut() { | ^^^^^^^^^^^^^--------- | | - | mutable borrow starts here in previous iteration of loop + | `list.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.next` is borrowed for `'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/polonius/assignment-to-differing-field.stderr b/src/test/ui/nll/polonius/assignment-to-differing-field.stderr index 07ca021b53b..2fe6a53a49a 100644 --- a/src/test/ui/nll/polonius/assignment-to-differing-field.stderr +++ b/src/test/ui/nll/polonius/assignment-to-differing-field.stderr @@ -5,7 +5,7 @@ LL | fn assignment_to_field_projection<'a, T>( | -- lifetime `'a` defined here ... LL | result.push(&mut (list.0).value); - | ^^^^^^^^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop + | ^^^^^^^^^^^^^^^^^^^ `list.0.value` was mutably borrowed here in the previous iteration of the loop ... LL | return result; | ------ returning this value requires that `list.0.value` is borrowed for `'a` @@ -19,7 +19,7 @@ LL | fn assignment_to_field_projection<'a, T>( LL | if let Some(n) = (list.0).next.as_mut() { | ^^^^^^^^^^^^^--------- | | - | mutable borrow starts here in previous iteration of loop + | `list.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.next` is borrowed for `'a` error[E0499]: cannot borrow `list.0.0.0.0.0.value` as mutable more than once at a time @@ -29,7 +29,7 @@ LL | fn assignment_through_projection_chain<'a, T>( | -- lifetime `'a` defined here ... LL | result.push(&mut ((((list.0).0).0).0).0.value); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `list.0.0.0.0.0.value` was mutably borrowed here in the previous iteration of the loop ... LL | return result; | ------ returning this value requires that `list.0.0.0.0.0.value` is borrowed for `'a` @@ -43,7 +43,7 @@ LL | fn assignment_through_projection_chain<'a, T>( LL | if let Some(n) = ((((list.0).0).0).0).0.next.as_mut() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^--------- | | - | mutable borrow starts here in previous iteration of loop + | `list.0.0.0.0.0.next` was mutably borrowed here in the previous iteration of the loop | argument requires that `list.0.0.0.0.0.next` is borrowed for `'a` error: aborting due to 4 previous errors diff --git a/src/test/ui/non-constant-expr-for-arr-len.stderr b/src/test/ui/non-constant-expr-for-arr-len.stderr index b947cb7e19c..01da6bcf49a 100644 --- a/src/test/ui/non-constant-expr-for-arr-len.stderr +++ b/src/test/ui/non-constant-expr-for-arr-len.stderr @@ -1,6 +1,8 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/non-constant-expr-for-arr-len.rs:5:22 | +LL | fn bar(n: usize) { + | - help: consider using `const` instead of `let` LL | let _x = [0; n]; | ^ non-constant value diff --git a/src/test/ui/object-lifetime-default-from-rptr-box.rs b/src/test/ui/object-lifetime-default-from-rptr-box.rs index 8ac45b3db71..b61083078cc 100644 --- a/src/test/ui/object-lifetime-default-from-rptr-box.rs +++ b/src/test/ui/object-lifetime-default-from-rptr-box.rs @@ -23,7 +23,7 @@ fn b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) { ss.u = t; } -// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs +// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs fn d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.u = t; diff --git a/src/test/compile-fail/auxiliary/weak-lang-items.rs b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs index 7a698cf76ae..7a698cf76ae 100644 --- a/src/test/compile-fail/auxiliary/weak-lang-items.rs +++ b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs diff --git a/src/test/compile-fail/panic-handler-missing.rs b/src/test/ui/panic-handler/panic-handler-missing.rs index 1c380c99c18..6bb062ba657 100644 --- a/src/test/compile-fail/panic-handler-missing.rs +++ b/src/test/ui/panic-handler/panic-handler-missing.rs @@ -1,3 +1,4 @@ +// dont-check-compiler-stderr // error-pattern: `#[panic_handler]` function required, but not found #![feature(lang_items)] diff --git a/src/test/compile-fail/panic-handler-twice.rs b/src/test/ui/panic-handler/panic-handler-twice.rs index 0c5359b9bd8..05bef66d849 100644 --- a/src/test/compile-fail/panic-handler-twice.rs +++ b/src/test/ui/panic-handler/panic-handler-twice.rs @@ -1,3 +1,4 @@ +// dont-check-compiler-stderr // aux-build:some-panic-impl.rs #![feature(lang_items)] diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/ui/panic-handler/weak-lang-item.rs index 3fa3822831b..3fa3822831b 100644 --- a/src/test/compile-fail/weak-lang-item.rs +++ b/src/test/ui/panic-handler/weak-lang-item.rs diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr new file mode 100644 index 00000000000..68e3e21df3e --- /dev/null +++ b/src/test/ui/panic-handler/weak-lang-item.stderr @@ -0,0 +1,19 @@ +error[E0259]: the name `core` is defined multiple times + --> $DIR/weak-lang-item.rs:8:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: you can use `as` to change the binding name of the import + | +LL | extern crate core as other_core; + | + +error: language item required, but not found: `eh_personality` + +error: `#[panic_handler]` function required, but not found + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0259`. diff --git a/src/test/compile-fail/auxiliary/depends.rs b/src/test/ui/panic-runtime/auxiliary/depends.rs index e9bc2f4893e..e9bc2f4893e 100644 --- a/src/test/compile-fail/auxiliary/depends.rs +++ b/src/test/ui/panic-runtime/auxiliary/depends.rs diff --git a/src/test/compile-fail/auxiliary/needs-panic-runtime.rs b/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs index 3f030c169f6..3f030c169f6 100644 --- a/src/test/compile-fail/auxiliary/needs-panic-runtime.rs +++ b/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs diff --git a/src/test/compile-fail/runtime-depend-on-needs-runtime.rs b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs index 866c5b2e34b..d57f1643e98 100644 --- a/src/test/compile-fail/runtime-depend-on-needs-runtime.rs +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -1,3 +1,4 @@ +// dont-check-compiler-stderr // aux-build:needs-panic-runtime.rs // aux-build:depends.rs // error-pattern:cannot depend on a crate that needs a panic runtime diff --git a/src/test/compile-fail/two-panic-runtimes.rs b/src/test/ui/panic-runtime/two-panic-runtimes.rs index 671d44564e6..c968b5ea1e1 100644 --- a/src/test/compile-fail/two-panic-runtimes.rs +++ b/src/test/ui/panic-runtime/two-panic-runtimes.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 // ignore-tidy-linelength // aux-build:panic-runtime-unwind.rs diff --git a/src/test/compile-fail/unwind-tables-panic-required.rs b/src/test/ui/panic-runtime/unwind-tables-panic-required.rs index 314d9e778d5..6393a27046b 100644 --- a/src/test/compile-fail/unwind-tables-panic-required.rs +++ b/src/test/ui/panic-runtime/unwind-tables-panic-required.rs @@ -1,6 +1,7 @@ // Tests that the compiler errors if the user tries to turn off unwind tables // when they are required. // +// dont-check-compiler-stderr // compile-flags: -C panic=unwind -C force-unwind-tables=no // ignore-tidy-linelength // diff --git a/src/test/compile-fail/unwind-tables-target-required.rs b/src/test/ui/panic-runtime/unwind-tables-target-required.rs index 14c17893764..14c17893764 100644 --- a/src/test/compile-fail/unwind-tables-target-required.rs +++ b/src/test/ui/panic-runtime/unwind-tables-target-required.rs diff --git a/src/test/compile-fail/want-abort-got-unwind.rs b/src/test/ui/panic-runtime/want-abort-got-unwind.rs index 30782e18229..e33c3bcc3f0 100644 --- a/src/test/compile-fail/want-abort-got-unwind.rs +++ b/src/test/ui/panic-runtime/want-abort-got-unwind.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // error-pattern:is not compiled with this crate's panic strategy `abort` // aux-build:panic-runtime-unwind.rs // compile-flags:-C panic=abort diff --git a/src/test/compile-fail/want-abort-got-unwind2.rs b/src/test/ui/panic-runtime/want-abort-got-unwind2.rs index 35d8d46b55e..438f1d85a28 100644 --- a/src/test/compile-fail/want-abort-got-unwind2.rs +++ b/src/test/ui/panic-runtime/want-abort-got-unwind2.rs @@ -1,3 +1,5 @@ +// build-fail +// dont-check-compiler-stderr // error-pattern:is not compiled with this crate's panic strategy `abort` // aux-build:panic-runtime-unwind.rs // aux-build:wants-panic-runtime-unwind.rs diff --git a/src/test/ui/parser/incorrect-move-async-order-issue-79694.fixed b/src/test/ui/parser/incorrect-move-async-order-issue-79694.fixed new file mode 100644 index 00000000000..055800d23b6 --- /dev/null +++ b/src/test/ui/parser/incorrect-move-async-order-issue-79694.fixed @@ -0,0 +1,8 @@ +// run-rustfix +// edition:2018 + +// Regression test for issue 79694 + +fn main() { + let _ = async move { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect +} diff --git a/src/test/ui/parser/incorrect-move-async-order-issue-79694.rs b/src/test/ui/parser/incorrect-move-async-order-issue-79694.rs new file mode 100644 index 00000000000..e8be16516d6 --- /dev/null +++ b/src/test/ui/parser/incorrect-move-async-order-issue-79694.rs @@ -0,0 +1,8 @@ +// run-rustfix +// edition:2018 + +// Regression test for issue 79694 + +fn main() { + let _ = move async { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect +} diff --git a/src/test/ui/parser/incorrect-move-async-order-issue-79694.stderr b/src/test/ui/parser/incorrect-move-async-order-issue-79694.stderr new file mode 100644 index 00000000000..2add9fb33c7 --- /dev/null +++ b/src/test/ui/parser/incorrect-move-async-order-issue-79694.stderr @@ -0,0 +1,13 @@ +error: the order of `move` and `async` is incorrect + --> $DIR/incorrect-move-async-order-issue-79694.rs:7:13 + | +LL | let _ = move async { }; + | ^^^^^^^^^^ + | +help: try switching the order + | +LL | let _ = async move { }; + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-14303-enum.stderr b/src/test/ui/parser/issue-14303-enum.stderr index 46f16ea0cc4..bcecd75b1ab 100644 --- a/src/test/ui/parser/issue-14303-enum.stderr +++ b/src/test/ui/parser/issue-14303-enum.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-enum.rs:1:15 | LL | enum X<'a, T, 'b> { - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-fn-def.stderr b/src/test/ui/parser/issue-14303-fn-def.stderr index 8cbab4b9653..082c37e0be7 100644 --- a/src/test/ui/parser/issue-14303-fn-def.stderr +++ b/src/test/ui/parser/issue-14303-fn-def.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-fn-def.rs:1:15 | LL | fn foo<'a, T, 'b>(x: &'a T) {} - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-impl.stderr b/src/test/ui/parser/issue-14303-impl.stderr index 56cd4fb3810..3b5615d2a9e 100644 --- a/src/test/ui/parser/issue-14303-impl.stderr +++ b/src/test/ui/parser/issue-14303-impl.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-impl.rs:3:13 | LL | impl<'a, T, 'b> X<T> {} - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-struct.stderr b/src/test/ui/parser/issue-14303-struct.stderr index f31cb92ad66..dbd0b987dd1 100644 --- a/src/test/ui/parser/issue-14303-struct.stderr +++ b/src/test/ui/parser/issue-14303-struct.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-struct.rs:1:17 | LL | struct X<'a, T, 'b> { - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-trait.stderr b/src/test/ui/parser/issue-14303-trait.stderr index 0e7399102bf..7dfa62d823f 100644 --- a/src/test/ui/parser/issue-14303-trait.stderr +++ b/src/test/ui/parser/issue-14303-trait.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-trait.rs:1:18 | LL | trait Foo<'a, T, 'b> {} - | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/macro/issue-33569.rs b/src/test/ui/parser/macro/issue-33569.rs index cf81f0480a2..80e2d7c6545 100644 --- a/src/test/ui/parser/macro/issue-33569.rs +++ b/src/test/ui/parser/macro/issue-33569.rs @@ -2,7 +2,6 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` - //~^ ERROR attempted to repeat an expression containing no syntax variables } } diff --git a/src/test/ui/parser/macro/issue-33569.stderr b/src/test/ui/parser/macro/issue-33569.stderr index f54efaa6996..b4d38d3ce48 100644 --- a/src/test/ui/parser/macro/issue-33569.stderr +++ b/src/test/ui/parser/macro/issue-33569.stderr @@ -4,23 +4,17 @@ error: expected identifier, found `+` LL | { $+ } => { | ^ -error: missing fragment specifier - --> $DIR/issue-33569.rs:2:8 - | -LL | { $+ } => { - | ^ - error: expected one of: `*`, `+`, or `?` --> $DIR/issue-33569.rs:4:13 | LL | $(x)(y) | ^^^ -error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth - --> $DIR/issue-33569.rs:4:10 +error: missing fragment specifier + --> $DIR/issue-33569.rs:2:8 | -LL | $(x)(y) - | ^^^ +LL | { $+ } => { + | ^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs new file mode 100644 index 00000000000..f3ae3aba9b9 --- /dev/null +++ b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs @@ -0,0 +1,12 @@ +// Regression test for #80134. + +fn main() { + (()é); + //~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator + //~| ERROR: cannot find value `é` in this scope + //~| ERROR: non-ascii idents are not fully supported + (()氷); + //~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator + //~| ERROR: cannot find value `氷` in this scope + //~| ERROR: non-ascii idents are not fully supported +} diff --git a/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr new file mode 100644 index 00000000000..892cc92b1bd --- /dev/null +++ b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr @@ -0,0 +1,52 @@ +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `é` + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8 + | +LL | (()é); + | ^ + | | + | expected one of `)`, `,`, `.`, `?`, or an operator + | help: missing `,` + +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `氷` + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8 + | +LL | (()氷); + | -^ + | | + | expected one of `)`, `,`, `.`, `?`, or an operator + | help: missing `,` + +error[E0425]: cannot find value `é` in this scope + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8 + | +LL | (()é); + | ^ not found in this scope + +error[E0425]: cannot find value `氷` in this scope + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8 + | +LL | (()氷); + | ^^ not found in this scope + +error[E0658]: non-ascii idents are not fully supported + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8 + | +LL | (()é); + | ^ + | + = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information + = help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable + +error[E0658]: non-ascii idents are not fully supported + --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8 + | +LL | (()氷); + | ^^ + | + = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information + = help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/parse-assoc-type-lt.rs b/src/test/ui/parser/parse-assoc-type-lt.rs index d3fe6079a5d..d3fe6079a5d 100644 --- a/src/test/ui/parse-assoc-type-lt.rs +++ b/src/test/ui/parser/parse-assoc-type-lt.rs diff --git a/src/test/ui/parse-error-correct.rs b/src/test/ui/parser/parse-error-correct.rs index 13759a23519..13759a23519 100644 --- a/src/test/ui/parse-error-correct.rs +++ b/src/test/ui/parser/parse-error-correct.rs diff --git a/src/test/ui/parse-error-correct.stderr b/src/test/ui/parser/parse-error-correct.stderr index c54baf00b27..c54baf00b27 100644 --- a/src/test/ui/parse-error-correct.stderr +++ b/src/test/ui/parser/parse-error-correct.stderr diff --git a/src/test/ui/parse-panic.rs b/src/test/ui/parser/parse-panic.rs index aeb2ba4faa5..aeb2ba4faa5 100644 --- a/src/test/ui/parse-panic.rs +++ b/src/test/ui/parser/parse-panic.rs diff --git a/src/test/ui/parser-recovery-1.rs b/src/test/ui/parser/parser-recovery-1.rs index 7e26b4f2b6a..7e26b4f2b6a 100644 --- a/src/test/ui/parser-recovery-1.rs +++ b/src/test/ui/parser/parser-recovery-1.rs diff --git a/src/test/ui/parser-recovery-1.stderr b/src/test/ui/parser/parser-recovery-1.stderr index f56060c3e35..f56060c3e35 100644 --- a/src/test/ui/parser-recovery-1.stderr +++ b/src/test/ui/parser/parser-recovery-1.stderr diff --git a/src/test/ui/parser-recovery-2.rs b/src/test/ui/parser/parser-recovery-2.rs index 48b22afffe7..48b22afffe7 100644 --- a/src/test/ui/parser-recovery-2.rs +++ b/src/test/ui/parser/parser-recovery-2.rs diff --git a/src/test/ui/parser-recovery-2.stderr b/src/test/ui/parser/parser-recovery-2.stderr index cd3da4c71f0..cd3da4c71f0 100644 --- a/src/test/ui/parser-recovery-2.stderr +++ b/src/test/ui/parser/parser-recovery-2.stderr diff --git a/src/test/ui/parser-unicode-whitespace.rs b/src/test/ui/parser/parser-unicode-whitespace.rs index 2d1fa7dc42e..2d1fa7dc42e 100644 --- a/src/test/ui/parser-unicode-whitespace.rs +++ b/src/test/ui/parser/parser-unicode-whitespace.rs diff --git a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr index 0fa77fb73da..2ca774a48b6 100644 --- a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr +++ b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr @@ -6,6 +6,7 @@ LL | match uninhab_ref() { | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&!` + = note: references are always considered inhabited error[E0004]: non-exhaustive patterns: type `Foo` is non-empty --> $DIR/always-inhabited-union-ref.rs:27:11 diff --git a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs new file mode 100644 index 00000000000..6c5a331b4b5 --- /dev/null +++ b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs @@ -0,0 +1,11 @@ +enum A {} + //~^ NOTE `A` defined here + +fn f(a: &A) { + match a {} + //~^ ERROR non-exhaustive patterns: type `&A` is non-empty + //~| NOTE the matched value is of type `&A` + //~| NOTE references are always considered inhabited +} + +fn main() {} diff --git a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr new file mode 100644 index 00000000000..e992632a91f --- /dev/null +++ b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr @@ -0,0 +1,16 @@ +error[E0004]: non-exhaustive patterns: type `&A` is non-empty + --> $DIR/issue-78123-non-exhaustive-reference.rs:5:11 + | +LL | enum A {} + | --------- `A` defined here +... +LL | match a {} + | ^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `&A` + = note: references are always considered inhabited + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/polymorphization/const_parameters/closures.stderr b/src/test/ui/polymorphization/const_parameters/closures.stderr index 63335586b76..266b6e62afd 100644 --- a/src/test/ui/polymorphization/const_parameters/closures.stderr +++ b/src/test/ui/polymorphization/const_parameters/closures.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics, rustc_attrs)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: item has unused generic parameters --> $DIR/closures.rs:19:19 diff --git a/src/test/ui/polymorphization/const_parameters/functions.stderr b/src/test/ui/polymorphization/const_parameters/functions.stderr index c976a5b62aa..e379e32c1fc 100644 --- a/src/test/ui/polymorphization/const_parameters/functions.stderr +++ b/src/test/ui/polymorphization/const_parameters/functions.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics, rustc_attrs)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: item has unused generic parameters --> $DIR/functions.rs:15:8 diff --git a/src/test/ui/polymorphization/generators.stderr b/src/test/ui/polymorphization/generators.stderr index b2b32db045d..c59055ba9d6 100644 --- a/src/test/ui/polymorphization/generators.stderr +++ b/src/test/ui/polymorphization/generators.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics, generators, generator_trait, rustc_attrs)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: item has unused generic parameters --> $DIR/generators.rs:36:5 diff --git a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs index d54c9931479..d54c9931479 100644 --- a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs +++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs diff --git a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr new file mode 100644 index 00000000000..b876bab6c54 --- /dev/null +++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr @@ -0,0 +1,44 @@ +error: variant `JuniorGrade` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^^^^^^^^ +... +LL | enum Lieutenant { + | --------------- help: consider making the enum public: `pub enum Lieutenant` + +error: variant `Full` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^ + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:4:13 + | +LL | pub use self::Professor::*; + | ^^^^^^^^^^^^^^^^^^ +... +LL | enum Professor { + | -------------- help: consider making the enum public: `pub enum Professor` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:9:13 + | +LL | pub use self::PettyOfficer::*; + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | pub(in rank) enum PettyOfficer { + | ------------------------------ help: consider making the enum public: `pub enum PettyOfficer` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:11:13 + | +LL | pub use self::Crewman::*; + | ^^^^^^^^^^^^^^^^ +... +LL | crate enum Crewman { + | ------------------ help: consider making the enum public: `pub enum Crewman` + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout index 4c0810217bf..5f513684cfa 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -1211,141 +1211,141 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "b", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "a", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '<', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "second", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "third", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1353,58 +1353,58 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Inner", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "match", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1412,146 +1412,146 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "warnings", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "false", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "_", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "c", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fn", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "kept_fn", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1559,82 +1559,82 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "let", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "my_val", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "enum", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleEnum", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1642,69 +1642,69 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleStruct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1712,120 +1712,120 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "d", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fourth", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ] diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout index c4ee44f6541..40da5aa93bf 100644 --- a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -34,11 +34,11 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ stream: TokenStream [ Ident { ident: "mod", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Ident { ident: "bar", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Group { delimiter: Brace, @@ -46,36 +46,36 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "doc", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Literal { kind: StrRaw(0), symbol: " Foo", suffix: None, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), diff --git a/src/test/ui/regions/regions-early-bound-trait-param.rs b/src/test/ui/regions/regions-early-bound-trait-param.rs index cc2bde78d85..276a64b8e9a 100644 --- a/src/test/ui/regions/regions-early-bound-trait-param.rs +++ b/src/test/ui/regions/regions-early-bound-trait-param.rs @@ -117,7 +117,7 @@ pub fn main() { let m : Box<dyn Trait> = make_val(); // assert_eq!(object_invoke1(&*m), (4,5)); // ~~~~~~~~~~~~~~~~~~~ - // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs + // this call yields a compilation error; see ui/span/dropck-object-cycle.rs // for details. assert_eq!(object_invoke2(&*m), 5); diff --git a/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs index f10d5a25f16..e6377867018 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs @@ -4,7 +4,7 @@ // Test that a type which is contravariant with respect to its region // parameter compiles successfully when used in a contravariant way. // -// Note: see compile-fail/variance-regions-*.rs for the tests that check that the +// Note: see ui/variance/variance-regions-*.rs for the tests that check that the // variance inference works in the first place. // pretty-expanded FIXME #23616 diff --git a/src/test/ui/regions/regions-variance-covariant-use-covariant.rs b/src/test/ui/regions/regions-variance-covariant-use-covariant.rs index 9316aa15d32..c5c80ce54f1 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-covariant-use-covariant.rs @@ -3,7 +3,7 @@ // Test that a type which is covariant with respect to its region // parameter is successful when used in a covariant way. // -// Note: see compile-fail/variance-regions-*.rs for the tests that +// Note: see ui/variance/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 diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat_count.stderr index 5fcda348ab3..aa1b2e60d51 100644 --- a/src/test/ui/repeat_count.stderr +++ b/src/test/ui/repeat_count.stderr @@ -1,6 +1,8 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/repeat_count.rs:5:17 | +LL | let n = 1; + | - help: consider using `const` instead of `let` LL | let a = [0; n]; | ^ non-constant value diff --git a/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr b/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr index 5de8eb21582..7f8151db06f 100644 --- a/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr +++ b/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr @@ -48,7 +48,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete error: aborting due to 5 previous errors; 1 warning emitted diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr index 11155038a91..861a4a80ad6 100644 --- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -521,7 +521,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: the feature `let_chains` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/disallowed-positions.rs:22:12 diff --git a/src/test/ui/auxiliary/rmeta-meta.rs b/src/test/ui/rmeta/auxiliary/rmeta-meta.rs index 6d8ed95bd38..6d8ed95bd38 100644 --- a/src/test/ui/auxiliary/rmeta-meta.rs +++ b/src/test/ui/rmeta/auxiliary/rmeta-meta.rs diff --git a/src/test/ui/auxiliary/rmeta-rlib-rpass.rs b/src/test/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs index f5e8c3d2a5c..f5e8c3d2a5c 100644 --- a/src/test/ui/auxiliary/rmeta-rlib-rpass.rs +++ b/src/test/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs diff --git a/src/test/ui/auxiliary/rmeta-rlib.rs b/src/test/ui/rmeta/auxiliary/rmeta-rlib.rs index 4a05710db66..4a05710db66 100644 --- a/src/test/ui/auxiliary/rmeta-rlib.rs +++ b/src/test/ui/rmeta/auxiliary/rmeta-rlib.rs diff --git a/src/test/ui/auxiliary/rmeta-rmeta.rs b/src/test/ui/rmeta/auxiliary/rmeta-rmeta.rs index 4a6d055a81f..4a6d055a81f 100644 --- a/src/test/ui/auxiliary/rmeta-rmeta.rs +++ b/src/test/ui/rmeta/auxiliary/rmeta-rmeta.rs diff --git a/src/test/ui/rmeta-lib-pass.rs b/src/test/ui/rmeta/rmeta-lib-pass.rs index fdd0516e4d6..fdd0516e4d6 100644 --- a/src/test/ui/rmeta-lib-pass.rs +++ b/src/test/ui/rmeta/rmeta-lib-pass.rs diff --git a/src/test/ui/rmeta-pass.rs b/src/test/ui/rmeta/rmeta-pass.rs index 4f0db23f47d..4f0db23f47d 100644 --- a/src/test/ui/rmeta-pass.rs +++ b/src/test/ui/rmeta/rmeta-pass.rs diff --git a/src/test/ui/rmeta-priv-warn.rs b/src/test/ui/rmeta/rmeta-priv-warn.rs index 430c1f06f43..430c1f06f43 100644 --- a/src/test/ui/rmeta-priv-warn.rs +++ b/src/test/ui/rmeta/rmeta-priv-warn.rs diff --git a/src/test/ui/rmeta-rpass.rs b/src/test/ui/rmeta/rmeta-rpass.rs index 173a6a394eb..173a6a394eb 100644 --- a/src/test/ui/rmeta-rpass.rs +++ b/src/test/ui/rmeta/rmeta-rpass.rs diff --git a/src/test/ui/rmeta.rs b/src/test/ui/rmeta/rmeta.rs index 63ed236505e..63ed236505e 100644 --- a/src/test/ui/rmeta.rs +++ b/src/test/ui/rmeta/rmeta.rs diff --git a/src/test/ui/rmeta.stderr b/src/test/ui/rmeta/rmeta.stderr index d15caeb6698..d15caeb6698 100644 --- a/src/test/ui/rmeta.stderr +++ b/src/test/ui/rmeta/rmeta.stderr diff --git a/src/test/ui/rmeta_lib.rs b/src/test/ui/rmeta/rmeta_lib.rs index fa6826450c9..fa6826450c9 100644 --- a/src/test/ui/rmeta_lib.rs +++ b/src/test/ui/rmeta/rmeta_lib.rs diff --git a/src/test/ui/rmeta_lib.stderr b/src/test/ui/rmeta/rmeta_lib.stderr index 8a9179cca6b..8a9179cca6b 100644 --- a/src/test/ui/rmeta_lib.stderr +++ b/src/test/ui/rmeta/rmeta_lib.stderr diff --git a/src/test/ui/rmeta_meta_main.rs b/src/test/ui/rmeta/rmeta_meta_main.rs index 839f350d741..839f350d741 100644 --- a/src/test/ui/rmeta_meta_main.rs +++ b/src/test/ui/rmeta/rmeta_meta_main.rs diff --git a/src/test/ui/rmeta_meta_main.stderr b/src/test/ui/rmeta/rmeta_meta_main.stderr index 0c6ed9afd35..0c6ed9afd35 100644 --- a/src/test/ui/rmeta_meta_main.stderr +++ b/src/test/ui/rmeta/rmeta_meta_main.stderr diff --git a/src/test/ui/sanitize/unsupported-target.stderr b/src/test/ui/sanitize/unsupported-target.stderr index f5961a11b1f..093678707fb 100644 --- a/src/test/ui/sanitize/unsupported-target.stderr +++ b/src/test/ui/sanitize/unsupported-target.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=leak` only works with targets: aarch64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-unknown-linux-gnu +error: `-Zsanitizer=leak` only works with targets: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-unknown-linux-gnu error: aborting due to previous error diff --git a/src/test/ui/simd/simd-array-type.rs b/src/test/ui/simd/simd-array-type.rs index e84186a42ad..7d66395a3c8 100644 --- a/src/test/ui/simd/simd-array-type.rs +++ b/src/test/ui/simd/simd-array-type.rs @@ -3,7 +3,7 @@ // pretty-expanded FIXME #23616 -#![feature(repr_simd, platform_intrinsics, min_const_generics)] +#![feature(repr_simd, platform_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] diff --git a/src/test/ui/simd/simd-generics.rs b/src/test/ui/simd/simd-generics.rs index dedca6276cd..50a4bfd9f51 100644 --- a/src/test/ui/simd/simd-generics.rs +++ b/src/test/ui/simd/simd-generics.rs @@ -1,6 +1,6 @@ // run-pass #![allow(non_camel_case_types)] -#![feature(repr_simd, platform_intrinsics, min_const_generics)] +#![feature(repr_simd, platform_intrinsics)] use std::ops; diff --git a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs b/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs index 4c459fa4bc8..c11d14b99d4 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs +++ b/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs @@ -2,7 +2,7 @@ // ignore-emscripten #![allow(non_camel_case_types)] -#![feature(repr_simd, platform_intrinsics, min_const_generics)] +#![feature(repr_simd, platform_intrinsics)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] diff --git a/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs b/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs index 5b0ff88432e..96c2c6c5399 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs +++ b/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs @@ -3,7 +3,7 @@ // ignore-emscripten FIXME(#45351) hits an LLVM assert -#![feature(repr_simd, platform_intrinsics, min_const_generics)] +#![feature(repr_simd, platform_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] diff --git a/src/test/ui/similar-tokens.fixed b/src/test/ui/similar-tokens.fixed deleted file mode 100644 index addba76ae3b..00000000000 --- a/src/test/ui/similar-tokens.fixed +++ /dev/null @@ -1,13 +0,0 @@ -// run-rustfix - -#![allow(unused_imports)] - -pub mod x { - pub struct A; - pub struct B; -} - -// `.` is similar to `,` so list parsing should continue to closing `}` -use x::{A, B}; //~ ERROR expected one of `,`, `::`, `as`, or `}`, found `.` - -fn main() {} diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs index 3d1bf5fe54a..e3024c61ad2 100644 --- a/src/test/ui/similar-tokens.rs +++ b/src/test/ui/similar-tokens.rs @@ -1,5 +1,3 @@ -// run-rustfix - #![allow(unused_imports)] pub mod x { diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr index 6a8d09ebae6..90acfc052dd 100644 --- a/src/test/ui/similar-tokens.stderr +++ b/src/test/ui/similar-tokens.stderr @@ -1,5 +1,5 @@ error: expected one of `,`, `::`, `as`, or `}`, found `.` - --> $DIR/similar-tokens.rs:11:10 + --> $DIR/similar-tokens.rs:9:10 | LL | use x::{A. B}; | ^ diff --git a/src/test/ui/span/dropck_arr_cycle_checked.rs b/src/test/ui/span/dropck_arr_cycle_checked.rs index ac31e4910d5..a14db5ff089 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.rs +++ b/src/test/ui/span/dropck_arr_cycle_checked.rs @@ -1,7 +1,7 @@ // Reject mixing cyclic structure and Drop when using fixed length // arrays. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against ui/span/dropck_vec_cycle_checked.rs) diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index bacd99c6825..c5d21507d76 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -1,6 +1,6 @@ // Reject mixing cyclic structure and Drop when using Vec. // -// (Compare against compile-fail/dropck_arr_cycle_checked.rs) +// (Compare against ui/span/dropck_arr_cycle_checked.rs) use std::cell::Cell; use id::Id; diff --git a/src/test/ui/specialization/defaultimpl/projection.rs b/src/test/ui/specialization/defaultimpl/projection.rs index 4a914096932..f19c55b043b 100644 --- a/src/test/ui/specialization/defaultimpl/projection.rs +++ b/src/test/ui/specialization/defaultimpl/projection.rs @@ -4,7 +4,7 @@ #![feature(specialization)] //~ WARN the feature `specialization` is incomplete // Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs +// cf ui/specialization/specialization-default-projection.rs // First, do so without any use of specialization diff --git a/src/test/compile-fail/specialization/issue-50452.rs b/src/test/ui/specialization/issue-50452-fail.rs index 958f0eb2668..fe21e9b6ede 100644 --- a/src/test/compile-fail/specialization/issue-50452.rs +++ b/src/test/ui/specialization/issue-50452-fail.rs @@ -1,4 +1,3 @@ -// compile-fail #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete diff --git a/src/test/ui/specialization/issue-50452-fail.stderr b/src/test/ui/specialization/issue-50452-fail.stderr new file mode 100644 index 00000000000..8e7c5037eff --- /dev/null +++ b/src/test/ui/specialization/issue-50452-fail.stderr @@ -0,0 +1,26 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-50452-fail.rs:1:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + +error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/issue-50452-fail.rs:10:5 + | +LL | fn foo() {} + | ^^^^^^^^^^^ cannot specialize default item `foo` +... +LL | / impl<T> Foo for T { +LL | | fn foo() {} +LL | | } + | |_- parent `impl` is here + | + = note: to specialize, `foo` in the parent `impl` must be marked `default` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0520`. diff --git a/src/test/ui/specialization/specialization-projection.rs b/src/test/ui/specialization/specialization-projection.rs index 700975e3b82..78afe7a9495 100644 --- a/src/test/ui/specialization/specialization-projection.rs +++ b/src/test/ui/specialization/specialization-projection.rs @@ -4,7 +4,7 @@ #![feature(specialization)] //~ WARN the feature `specialization` is incomplete // Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs +// cf ui/specialization/specialization-default-projection.rs // First, do so without any use of specialization diff --git a/src/test/ui/structs-enums/discrim-explicit-23030.rs b/src/test/ui/structs-enums/discrim-explicit-23030.rs index af7ab865e32..e17025e9e88 100644 --- a/src/test/ui/structs-enums/discrim-explicit-23030.rs +++ b/src/test/ui/structs-enums/discrim-explicit-23030.rs @@ -2,7 +2,7 @@ // Issue 23030: Workaround overflowing discriminant // with explicit assignments. -// See also compile-fail/overflow-discrim.rs, which shows what +// See also ui/discrim/discrim-overflow.rs, which shows what // happens if you leave the OhNo explicit cases out here. fn f_i8() { diff --git a/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs b/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs index 1fc52ead48e..d3e92e16246 100644 --- a/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs +++ b/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs @@ -27,7 +27,7 @@ fn b<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) { ss.u = t; } -// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs +// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs fn d<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.u = t; diff --git a/src/test/ui/suggestions/suggest-move-lifetimes.stderr b/src/test/ui/suggestions/suggest-move-lifetimes.stderr index 1851c8deaa8..657914d1c8c 100644 --- a/src/test/ui/suggestions/suggest-move-lifetimes.stderr +++ b/src/test/ui/suggestions/suggest-move-lifetimes.stderr @@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:1:13 | LL | struct A<T, 'a> { - | ----^^- help: reorder the parameters: lifetimes, then types: `<'a, T>` + | ----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:5:13 | LL | struct B<T, 'a, U> { - | ----^^---- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` + | ----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:10:16 | LL | struct C<T, U, 'a> { - | -------^^- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` + | -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:15:16 | LL | struct D<T, U, 'a, 'b, V, 'c> { - | -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, 'c, T, U, V>` + | -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` error: aborting due to 4 previous errors diff --git a/src/test/ui/svh/auxiliary/svh-uta-base.rs b/src/test/ui/svh/auxiliary/svh-uta-base.rs index c138f1a5ba8..221a096e083 100644 --- a/src/test/ui/svh/auxiliary/svh-uta-base.rs +++ b/src/test/ui/svh/auxiliary/svh-uta-base.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "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/svh/auxiliary/svh-uta-change-use-trait.rs b/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs index 76a472b5b26..823d29571aa 100644 --- a/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs +++ b/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "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/svh/auxiliary/svh-utb.rs b/src/test/ui/svh/auxiliary/svh-utb.rs index 2f27e99a961..a03e29dcedc 100644 --- a/src/test/ui/svh/auxiliary/svh-utb.rs +++ b/src/test/ui/svh/auxiliary/svh-utb.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "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/svh/svh-use-trait.rs b/src/test/ui/svh/svh-use-trait.rs index 93daca034c0..e5c427e096a 100644 --- a/src/test/ui/svh/svh-use-trait.rs +++ b/src/test/ui/svh/svh-use-trait.rs @@ -6,7 +6,7 @@ // 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 +//! "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/symbol-names/const-generics-demangling.rs b/src/test/ui/symbol-names/const-generics-demangling.rs index e002124059f..55ab17fcd5a 100644 --- a/src/test/ui/symbol-names/const-generics-demangling.rs +++ b/src/test/ui/symbol-names/const-generics-demangling.rs @@ -1,7 +1,6 @@ // build-fail // compile-flags: -Z symbol-mangling-version=v0 - -#![feature(min_const_generics, rustc_attrs)] +#![feature(rustc_attrs)] pub struct Unsigned<const F: u8>; diff --git a/src/test/ui/symbol-names/const-generics-demangling.stderr b/src/test/ui/symbol-names/const-generics-demangling.stderr index 022b3188373..a9574cacea3 100644 --- a/src/test/ui/symbol-names/const-generics-demangling.stderr +++ b/src/test/ui/symbol-names/const-generics-demangling.stderr @@ -1,71 +1,71 @@ error: symbol-name(_RMCs4fqI2P2rA04_25const_generics_demanglingINtB0_8UnsignedKhb_E) - --> $DIR/const-generics-demangling.rs:8:1 + --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<const_generics_demangling[317d481089b8c8fe]::Unsigned<11: u8>>) - --> $DIR/const-generics-demangling.rs:8:1 + --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<const_generics_demangling::Unsigned<11>>) - --> $DIR/const-generics-demangling.rs:8:1 + --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs_Cs4fqI2P2rA04_25const_generics_demanglingINtB2_6SignedKsn98_E) - --> $DIR/const-generics-demangling.rs:16:1 + --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<const_generics_demangling[317d481089b8c8fe]::Signed<-152: i16>>) - --> $DIR/const-generics-demangling.rs:16:1 + --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<const_generics_demangling::Signed<-152>>) - --> $DIR/const-generics-demangling.rs:16:1 + --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs0_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4BoolKb1_E) - --> $DIR/const-generics-demangling.rs:24:1 + --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<const_generics_demangling[317d481089b8c8fe]::Bool<true: bool>>) - --> $DIR/const-generics-demangling.rs:24:1 + --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<const_generics_demangling::Bool<true>>) - --> $DIR/const-generics-demangling.rs:24:1 + --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs1_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4CharKc2202_E) - --> $DIR/const-generics-demangling.rs:32:1 + --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<const_generics_demangling[317d481089b8c8fe]::Char<'∂': char>>) - --> $DIR/const-generics-demangling.rs:32:1 + --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<const_generics_demangling::Char<'∂'>>) - --> $DIR/const-generics-demangling.rs:32:1 + --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/symbol-names/const-generics.rs b/src/test/ui/symbol-names/const-generics.rs index 823995e5be3..2d136e6a99a 100644 --- a/src/test/ui/symbol-names/const-generics.rs +++ b/src/test/ui/symbol-names/const-generics.rs @@ -1,87 +1,85 @@ // check-pass // revisions: legacy v0 //[legacy]compile-flags: -Z symbol-mangling-version=legacy --crate-type=lib - //[v0]compile-flags: -Z symbol-mangling-version=v0 --crate-type=lib +//[v0]compile-flags: -Z symbol-mangling-version=v0 --crate-type=lib - #![feature(min_const_generics)] +// `char` +pub struct Char<const F: char>; - // `char` - pub struct Char<const F: char>; +impl Char<'A'> { + pub fn foo() {} +} - impl Char<'A'> { - pub fn foo() {} - } +impl<const F: char> Char<F> { + pub fn bar() {} +} - impl<const F: char> Char<F> { - pub fn bar() {} - } +// `i8` +pub struct I8<const F: i8>; - // `i8` - pub struct I8<const F: i8>; +impl I8<{i8::MIN}> { + pub fn foo() {} +} - impl I8<{i8::MIN}> { - pub fn foo() {} - } +impl I8<{i8::MAX}> { + pub fn foo() {} +} - impl I8<{i8::MAX}> { - pub fn foo() {} - } +impl<const F: i8> I8<F> { + pub fn bar() {} +} - impl<const F: i8> I8<F> { - pub fn bar() {} - } +// `i16` +pub struct I16<const F: i16>; - // `i16` - pub struct I16<const F: i16>; +impl I16<{i16::MIN}> { + pub fn foo() {} +} - impl I16<{i16::MIN}> { - pub fn foo() {} - } +impl<const F: i16> I16<F> { + pub fn bar() {} +} - impl<const F: i16> I16<F> { - pub fn bar() {} - } +// `i32` +pub struct I32<const F: i32>; - // `i32` - pub struct I32<const F: i32>; +impl I32<{i32::MIN}> { + pub fn foo() {} +} - impl I32<{i32::MIN}> { - pub fn foo() {} - } +impl<const F: i32> I32<F> { + pub fn bar() {} +} - impl<const F: i32> I32<F> { - pub fn bar() {} - } +// `i64` +pub struct I64<const F: i64>; - // `i64` - pub struct I64<const F: i64>; +impl I64<{i64::MIN}> { + pub fn foo() {} +} - impl I64<{i64::MIN}> { - pub fn foo() {} - } +impl<const F: i64> I64<F> { + pub fn bar() {} +} - impl<const F: i64> I64<F> { - pub fn bar() {} - } +// `i128` +pub struct I128<const F: i128>; - // `i128` - pub struct I128<const F: i128>; +impl I128<{i128::MIN}> { + pub fn foo() {} +} - impl I128<{i128::MIN}> { - pub fn foo() {} - } +impl<const F: i128> I128<F> { + pub fn bar() {} +} - impl<const F: i128> I128<F> { - pub fn bar() {} - } +// `isize` +pub struct ISize<const F: isize>; - // `isize` - pub struct ISize<const F: isize>; +impl ISize<3> { + pub fn foo() {} +} - impl ISize<3> { - pub fn foo() {} - } - - impl<const F: isize> ISize<F> { - pub fn bar() {} - } +impl<const F: isize> ISize<F> { + pub fn bar() {} +} diff --git a/src/test/ui/symbol-names/issue-76365.rs b/src/test/ui/symbol-names/issue-76365.rs index 61ba255dac0..c2e9f92f7b5 100644 --- a/src/test/ui/symbol-names/issue-76365.rs +++ b/src/test/ui/symbol-names/issue-76365.rs @@ -1,9 +1,8 @@ // check-pass // revisions: legacy v0 //[legacy]compile-flags: -Z symbol-mangling-version=legacy --crate-type=lib - //[v0]compile-flags: -Z symbol-mangling-version=v0 --crate-type=lib +//[v0]compile-flags: -Z symbol-mangling-version=v0 --crate-type=lib -#![feature(min_const_generics)] pub struct Bar<const F: bool>; diff --git a/src/test/compile-fail/issue-43733-2.rs b/src/test/ui/threads-sendsync/issue-43733-2.rs index 61dd3a923f2..21ea8e9a209 100644 --- a/src/test/compile-fail/issue-43733-2.rs +++ b/src/test/ui/threads-sendsync/issue-43733-2.rs @@ -1,3 +1,5 @@ +// dont-check-compiler-stderr + #![feature(cfg_target_thread_local, thread_local_internals)] // On platforms *without* `#[thread_local]`, use diff --git a/src/test/ui/issues/issue-43733.rs b/src/test/ui/threads-sendsync/issue-43733.rs index a602d7667c4..a602d7667c4 100644 --- a/src/test/ui/issues/issue-43733.rs +++ b/src/test/ui/threads-sendsync/issue-43733.rs diff --git a/src/test/ui/issues/issue-43733.stderr b/src/test/ui/threads-sendsync/issue-43733.stderr index ee6a3b065d6..ee6a3b065d6 100644 --- a/src/test/ui/issues/issue-43733.stderr +++ b/src/test/ui/threads-sendsync/issue-43733.stderr diff --git a/src/test/ui/traits/traits-repeated-supertrait.rs b/src/test/ui/traits/traits-repeated-supertrait.rs index 391d19c4385..339f9c37eea 100644 --- a/src/test/ui/traits/traits-repeated-supertrait.rs +++ b/src/test/ui/traits/traits-repeated-supertrait.rs @@ -2,7 +2,7 @@ // Test a case of a trait which extends the same supertrait twice, but // with difference type parameters. Test that we can invoke the // various methods in various ways successfully. -// See also `compile-fail/trait-repeated-supertrait-ambig.rs`. +// See also `ui/traits/trait-repeated-supertrait-ambig.rs`. trait CompareTo<T> { diff --git a/src/test/ui/try-block/try-block-in-edition2015.stderr b/src/test/ui/try-block/try-block-in-edition2015.stderr index 78cdfb2cc7f..0f3c14b1386 100644 --- a/src/test/ui/try-block/try-block-in-edition2015.stderr +++ b/src/test/ui/try-block/try-block-in-edition2015.stderr @@ -13,7 +13,7 @@ error[E0574]: expected struct, variant or union type, found macro `try` LL | let try_result: Option<_> = try { | ^^^ not a struct, variant or union type | - = note: if you want the `try` keyword, you need to be in the 2018 edition + = note: if you want the `try` keyword, you need Rust 2018 or later help: use `!` to invoke the macro | LL | let try_result: Option<_> = try! { diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr b/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr index c5b22f0026d..e0c1b023861 100644 --- a/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr +++ b/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr @@ -6,7 +6,6 @@ LL | #![feature(const_generics)] | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - = help: consider using `min_const_generics` instead, which is more stable and complete warning: 1 warning emitted diff --git a/src/test/ui/type/type-dependent-def-issue-49241.stderr b/src/test/ui/type/type-dependent-def-issue-49241.stderr index c5dcfa7a431..df791435e88 100644 --- a/src/test/ui/type/type-dependent-def-issue-49241.stderr +++ b/src/test/ui/type/type-dependent-def-issue-49241.stderr @@ -2,7 +2,9 @@ error[E0435]: attempt to use a non-constant value in a constant --> $DIR/type-dependent-def-issue-49241.rs:3:22 | LL | const l: usize = v.count(); - | ^ non-constant value + | - ^ non-constant value + | | + | help: consider using `let` instead of `const` error: aborting due to previous error diff --git a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr index 960c4792e65..7b999f50773 100644 --- a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -23,6 +23,7 @@ LL | let _ = match x {}; | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&Void` + = note: references are always considered inhabited error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty --> $DIR/uninhabited-matches-feature-gated.rs:18:19 diff --git a/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs b/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs index 38271cc3c78..3713a7065f5 100644 --- a/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs +++ b/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // -// See also: compile-fail/unsafe-fn-called-from-safe.rs +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs // pretty-expanded FIXME #23616 diff --git a/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs b/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs index 26acc913e87..5e953107686 100644 --- a/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs +++ b/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // -// See also: compile-fail/unsafe-fn-called-from-safe.rs +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs // pretty-expanded FIXME #23616 diff --git a/src/test/ui/unsafe/ranged_ints3_const.rs b/src/test/ui/unsafe/ranged_ints3_const.rs index 7b03d8eda93..c069ae7da02 100644 --- a/src/test/ui/unsafe/ranged_ints3_const.rs +++ b/src/test/ui/unsafe/ranged_ints3_const.rs @@ -9,13 +9,13 @@ fn main() {} const fn foo() -> NonZero<Cell<u32>> { let mut x = unsafe { NonZero(Cell::new(1)) }; - let y = &x.0; //~ ERROR cannot borrow a constant which may contain interior mutability + let y = &x.0; //~ ERROR the borrowed element may contain interior mutability //~^ ERROR borrow of layout constrained field with interior mutability unsafe { NonZero(Cell::new(1)) } } const fn bar() -> NonZero<Cell<u32>> { let mut x = unsafe { NonZero(Cell::new(1)) }; - let y = unsafe { &x.0 }; //~ ERROR cannot borrow a constant which may contain interior mut + let y = unsafe { &x.0 }; //~ ERROR the borrowed element may contain interior mutability unsafe { NonZero(Cell::new(1)) } } diff --git a/src/test/ui/unsafe/ranged_ints3_const.stderr b/src/test/ui/unsafe/ranged_ints3_const.stderr index d2eb3bc5360..215005571f6 100644 --- a/src/test/ui/unsafe/ranged_ints3_const.stderr +++ b/src/test/ui/unsafe/ranged_ints3_const.stderr @@ -1,14 +1,20 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/ranged_ints3_const.rs:12:13 | LL | let y = &x.0; | ^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability --> $DIR/ranged_ints3_const.rs:19:22 | LL | let y = unsafe { &x.0 }; | ^^^^ + | + = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information + = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable error[E0133]: borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block --> $DIR/ranged_ints3_const.rs:12:13 @@ -20,5 +26,5 @@ LL | let y = &x.0; error: aborting due to 3 previous errors -Some errors have detailed explanations: E0133, E0492. +Some errors have detailed explanations: E0133, E0658. For more information about an error, try `rustc --explain E0133`. diff --git a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs new file mode 100644 index 00000000000..8386959cfb3 --- /dev/null +++ b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs @@ -0,0 +1,17 @@ +// Regression test for #80468. + +#![crate_type = "lib"] + +pub trait Trait {} + +#[repr(transparent)] +pub struct Wrapper<T: Trait>(T); + +#[repr(transparent)] +pub struct Ref<'a>(&'a u8); + +impl Trait for Ref {} //~ ERROR: implicit elided lifetime not allowed here + +extern "C" { + pub fn repro(_: Wrapper<Ref>); //~ ERROR: mismatched types +} diff --git a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr new file mode 100644 index 00000000000..bb839d0a5ec --- /dev/null +++ b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr @@ -0,0 +1,24 @@ +error[E0726]: implicit elided lifetime not allowed here + --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:16 + | +LL | impl Trait for Ref {} + | ^^^- help: indicate the anonymous lifetime: `<'_>` + +error[E0308]: mismatched types + --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21 + | +LL | pub fn repro(_: Wrapper<Ref>); + | ^^^^^^^^^^^^ lifetime mismatch + | + = note: expected trait `Trait` + found trait `Trait` +note: the anonymous lifetime #1 defined on the method body at 16:5... + --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:5 + | +LL | pub fn repro(_: Wrapper<Ref>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/tools/cargo b/src/tools/cargo -Subproject a3c2627fbc2f5391c65ba45ab53b81bf71fa323 +Subproject 75d5d8cffe3464631f82dcd3c470b78dc1dda8b diff --git a/src/tools/clippy/.github/ISSUE_TEMPLATE/false_negative.md b/src/tools/clippy/.github/ISSUE_TEMPLATE/false_negative.md new file mode 100644 index 00000000000..f46828fec91 --- /dev/null +++ b/src/tools/clippy/.github/ISSUE_TEMPLATE/false_negative.md @@ -0,0 +1,35 @@ +--- +name: Bug Report (False Negative) +about: Create a bug report about missing warnings from a lint +labels: L-bug, L-false-negative +--- +<!-- +Thank you for filing a bug report! 🐛 Please provide a short summary of the bug, +along with any information you feel relevant to replicating the bug. +--> +Lint name: + + +I tried this code: + +```rust +<code> +``` + +I expected to see this happen: *explanation* + +Instead, this happened: *explanation* + +### Meta + +- `cargo clippy -V`: e.g. clippy 0.0.212 (f455e46 2020-06-20) +- `rustc -Vv`: + ``` + rustc 1.46.0-nightly (f455e46ea 2020-06-20) + binary: rustc + commit-hash: f455e46eae1a227d735091091144601b467e1565 + commit-date: 2020-06-20 + host: x86_64-unknown-linux-gnu + release: 1.46.0-nightly + LLVM version: 10.0 + ``` diff --git a/src/tools/clippy/.github/ISSUE_TEMPLATE/false_positive.md b/src/tools/clippy/.github/ISSUE_TEMPLATE/false_positive.md new file mode 100644 index 00000000000..92a7373fc27 --- /dev/null +++ b/src/tools/clippy/.github/ISSUE_TEMPLATE/false_positive.md @@ -0,0 +1,35 @@ +--- +name: Bug Report (False Positive) +about: Create a bug report about a wrongly emitted lint warning +labels: L-bug, L-false-positive +--- +<!-- +Thank you for filing a bug report! 🐛 Please provide a short summary of the bug, +along with any information you feel relevant to replicating the bug. +--> +Lint name: + + +I tried this code: + +```rust +<code> +``` + +I expected to see this happen: *explanation* + +Instead, this happened: *explanation* + +### Meta + +- `cargo clippy -V`: e.g. clippy 0.0.212 (f455e46 2020-06-20) +- `rustc -Vv`: + ``` + rustc 1.46.0-nightly (f455e46ea 2020-06-20) + binary: rustc + commit-hash: f455e46eae1a227d735091091144601b467e1565 + commit-date: 2020-06-20 + host: x86_64-unknown-linux-gnu + release: 1.46.0-nightly + LLVM version: 10.0 + ``` diff --git a/src/tools/clippy/.github/workflows/clippy.yml b/src/tools/clippy/.github/workflows/clippy.yml index 530e60001f7..9d5e12aac5f 100644 --- a/src/tools/clippy/.github/workflows/clippy.yml +++ b/src/tools/clippy/.github/workflows/clippy.yml @@ -50,6 +50,9 @@ jobs: - name: Build run: cargo build --features deny-warnings,internal-lints + - name: Test "--fix -Zunstable-options" + run: cargo run --features deny-warnings,internal-lints --bin cargo-clippy -- clippy --fix -Zunstable-options + - name: Test run: cargo test --features deny-warnings,internal-lints diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index af3b1c1db2a..de8da99cdee 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -1841,6 +1841,7 @@ Released 2018-09-13 [`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy [`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref [`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect +[`from_over_into`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into [`future_not_send`]: https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send [`get_last_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_last_with_len [`get_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_unwrap diff --git a/src/tools/clippy/Cargo.toml b/src/tools/clippy/Cargo.toml index 7f9d22e594b..e60aa472846 100644 --- a/src/tools/clippy/Cargo.toml +++ b/src/tools/clippy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.212" +version = "0.1.51" authors = [ "Manish Goregaokar <manishsmail@gmail.com>", "Andre Bogus <bogusandre@gmail.com>", @@ -20,6 +20,7 @@ publish = false [[bin]] name = "cargo-clippy" +test = false path = "src/main.rs" [[bin]] @@ -28,7 +29,7 @@ path = "src/driver.rs" [dependencies] # begin automatic update -clippy_lints = { version = "0.0.212", path = "clippy_lints" } +clippy_lints = { version = "0.1.50", path = "clippy_lints" } # end automatic update semver = "0.11" rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" } diff --git a/src/tools/clippy/README.md b/src/tools/clippy/README.md index dc931963726..a4928e17e6a 100644 --- a/src/tools/clippy/README.md +++ b/src/tools/clippy/README.md @@ -10,16 +10,16 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category. -Category | Description | Default level --- | -- | -- -`clippy::all` | all lints that are on by default (correctness, style, complexity, perf) | **warn/deny** -`clippy::correctness` | code that is outright wrong or very useless | **deny** -`clippy::style` | code that should be written in a more idiomatic way | **warn** -`clippy::complexity` | code that does something simple but in a complex way | **warn** -`clippy::perf` | code that can be written to run faster | **warn** -`clippy::pedantic` | lints which are rather strict or might have false positives | allow -`clippy::nursery` | new lints that are still under development | allow -`clippy::cargo` | lints for the cargo manifest | allow +| Category | Description | Default level | +| --------------------- | ----------------------------------------------------------------------- | ------------- | +| `clippy::all` | all lints that are on by default (correctness, style, complexity, perf) | **warn/deny** | +| `clippy::correctness` | code that is outright wrong or very useless | **deny** | +| `clippy::style` | code that should be written in a more idiomatic way | **warn** | +| `clippy::complexity` | code that does something simple but in a complex way | **warn** | +| `clippy::perf` | code that can be written to run faster | **warn** | +| `clippy::pedantic` | lints which are rather strict or might have false positives | allow | +| `clippy::nursery` | new lints that are still under development | allow | +| `clippy::cargo` | lints for the cargo manifest | allow | More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas! @@ -98,17 +98,6 @@ If you want to run Clippy **only** on the given crate, use the `--no-deps` optio cargo clippy -p example -- --no-deps ``` -### Running Clippy from the command line without installing it - -To have cargo compile your crate with Clippy without Clippy installation -in your code, you can use: - -```terminal -cargo run --bin cargo-clippy --manifest-path=path_to_clippys_Cargo.toml -``` - -*Note:* Be sure that Clippy was compiled with the same version of rustc that cargo invokes here! - ### Travis CI You can add Clippy to Travis CI in the same way you use it locally: @@ -130,18 +119,6 @@ script: # etc. ``` -If you are on nightly, It might happen that Clippy is not available for a certain nightly release. -In this case you can try to conditionally install Clippy from the Git repo. - -```yaml -language: rust -rust: - - nightly -before_script: - - rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy - # etc. -``` - Note that adding `-D warnings` will cause your build to fail if **any** warnings are found in your code. That includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to avoid this and only cause an error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command @@ -208,6 +185,7 @@ the lint(s) you are interested in: ```terminal cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::... ``` +Note that if you've run clippy before, this may only take effect after you've modified a file or ran `cargo clean`. ### Specifying the minimum supported Rust version diff --git a/src/tools/clippy/clippy_dev/src/ra_setup.rs b/src/tools/clippy/clippy_dev/src/ra_setup.rs index 40bf4a9505a..5f5048e79e7 100644 --- a/src/tools/clippy/clippy_dev/src/ra_setup.rs +++ b/src/tools/clippy/clippy_dev/src/ra_setup.rs @@ -3,7 +3,7 @@ use std::fs; use std::fs::File; use std::io::prelude::*; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; // This module takes an absolute path to a rustc repo and alters the dependencies to point towards // the respective rustc subcrates instead of using extern crate xyz. @@ -44,7 +44,7 @@ pub fn run(rustc_path: Option<&str>) { } fn inject_deps_into_manifest( - rustc_source_dir: &PathBuf, + rustc_source_dir: &Path, manifest_path: &str, cargo_toml: &str, lib_rs: &str, diff --git a/src/tools/clippy/clippy_lints/Cargo.toml b/src/tools/clippy/clippy_lints/Cargo.toml index 7697eba650a..a9516560a61 100644 --- a/src/tools/clippy/clippy_lints/Cargo.toml +++ b/src/tools/clippy/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.212" +version = "0.1.51" # end automatic update authors = [ "Manish Goregaokar <manishsmail@gmail.com>", diff --git a/src/tools/clippy/clippy_lints/src/default.rs b/src/tools/clippy/clippy_lints/src/default.rs index f69f6f1412a..b0d7c7b3baa 100644 --- a/src/tools/clippy/clippy_lints/src/default.rs +++ b/src/tools/clippy/clippy_lints/src/default.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::{Block, Expr, ExprKind, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::{self, Adt, Ty}; +use rustc_middle::ty; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -103,18 +103,41 @@ impl LateLintPass<'_> for Default { } fn check_block<'tcx>(&mut self, cx: &LateContext<'tcx>, block: &Block<'tcx>) { - // find all binding statements like `let mut _ = T::default()` where `T::default()` is the - // `default` method of the `Default` trait, and store statement index in current block being - // checked and the name of the bound variable - let binding_statements_using_default = enumerate_bindings_using_default(cx, block); - // start from the `let mut _ = _::default();` and look at all the following // statements, see if they re-assign the fields of the binding - for (stmt_idx, binding_name, binding_type, span) in binding_statements_using_default { - // the last statement of a block cannot trigger the lint - if stmt_idx == block.stmts.len() - 1 { - break; - } + let stmts_head = match block.stmts { + // Skip the last statement since there cannot possibly be any following statements that re-assign fields. + [head @ .., _] if !head.is_empty() => head, + _ => return, + }; + for (stmt_idx, stmt) in stmts_head.iter().enumerate() { + // find all binding statements like `let mut _ = T::default()` where `T::default()` is the + // `default` method of the `Default` trait, and store statement index in current block being + // checked and the name of the bound variable + let (local, variant, binding_name, binding_type, span) = if_chain! { + // only take `let ...` statements + if let StmtKind::Local(local) = stmt.kind; + if let Some(expr) = local.init; + // only take bindings to identifiers + if let PatKind::Binding(_, binding_id, ident, _) = local.pat.kind; + // only when assigning `... = Default::default()` + if is_expr_default(expr, cx); + let binding_type = cx.typeck_results().node_type(binding_id); + if let Some(adt) = binding_type.ty_adt_def(); + if adt.is_struct(); + let variant = adt.non_enum_variant(); + if adt.did.is_local() || !variant.is_field_list_non_exhaustive(); + let module_did = cx.tcx.parent_module(stmt.hir_id).to_def_id(); + if variant + .fields + .iter() + .all(|field| field.vis.is_accessible_from(module_did, cx.tcx)); + then { + (local, variant, ident.name, binding_type, expr.span) + } else { + continue; + } + }; // find all "later statement"'s where the fields of the binding set as // Default::default() get reassigned, unless the reassignment refers to the original binding @@ -122,15 +145,8 @@ impl LateLintPass<'_> for Default { let mut assigned_fields = Vec::new(); let mut cancel_lint = false; for consecutive_statement in &block.stmts[stmt_idx + 1..] { - // interrupt if the statement is a let binding (`Local`) that shadows the original - // binding - if stmt_shadows_binding(consecutive_statement, binding_name) { - break; - } // find out if and which field was set by this `consecutive_statement` - else if let Some((field_ident, assign_rhs)) = - field_reassigned_by_stmt(consecutive_statement, binding_name) - { + if let Some((field_ident, assign_rhs)) = field_reassigned_by_stmt(consecutive_statement, binding_name) { // interrupt and cancel lint if assign_rhs references the original binding if contains_name(binding_name, assign_rhs) { cancel_lint = true; @@ -152,7 +168,7 @@ impl LateLintPass<'_> for Default { first_assign = Some(consecutive_statement); } } - // interrupt also if no field was assigned, since we only want to look at consecutive statements + // interrupt if no field was assigned, since we only want to look at consecutive statements else { break; } @@ -161,55 +177,45 @@ impl LateLintPass<'_> for Default { // if there are incorrectly assigned fields, do a span_lint_and_note to suggest // construction using `Ty { fields, ..Default::default() }` if !assigned_fields.is_empty() && !cancel_lint { - // take the original assignment as span - let stmt = &block.stmts[stmt_idx]; - - if let StmtKind::Local(preceding_local) = &stmt.kind { - // filter out fields like `= Default::default()`, because the FRU already covers them - let assigned_fields = assigned_fields - .into_iter() - .filter(|(_, rhs)| !is_expr_default(rhs, cx)) - .collect::<Vec<(Symbol, &Expr<'_>)>>(); + // if all fields of the struct are not assigned, add `.. Default::default()` to the suggestion. + let ext_with_default = !variant + .fields + .iter() + .all(|field| assigned_fields.iter().any(|(a, _)| a == &field.ident.name)); - // if all fields of the struct are not assigned, add `.. Default::default()` to the suggestion. - let ext_with_default = !fields_of_type(binding_type) - .iter() - .all(|field| assigned_fields.iter().any(|(a, _)| a == &field.name)); + let field_list = assigned_fields + .into_iter() + .map(|(field, rhs)| { + // extract and store the assigned value for help message + let value_snippet = snippet(cx, rhs.span, ".."); + format!("{}: {}", field, value_snippet) + }) + .collect::<Vec<String>>() + .join(", "); - let field_list = assigned_fields - .into_iter() - .map(|(field, rhs)| { - // extract and store the assigned value for help message - let value_snippet = snippet(cx, rhs.span, ".."); - format!("{}: {}", field, value_snippet) - }) - .collect::<Vec<String>>() - .join(", "); - - let sugg = if ext_with_default { - if field_list.is_empty() { - format!("{}::default()", binding_type) - } else { - format!("{} {{ {}, ..Default::default() }}", binding_type, field_list) - } + let sugg = if ext_with_default { + if field_list.is_empty() { + format!("{}::default()", binding_type) } else { - format!("{} {{ {} }}", binding_type, field_list) - }; + format!("{} {{ {}, ..Default::default() }}", binding_type, field_list) + } + } else { + format!("{} {{ {} }}", binding_type, field_list) + }; - // span lint once per statement that binds default - span_lint_and_note( - cx, - FIELD_REASSIGN_WITH_DEFAULT, - first_assign.unwrap().span, - "field assignment outside of initializer for an instance created with Default::default()", - Some(preceding_local.span), - &format!( - "consider initializing the variable with `{}` and removing relevant reassignments", - sugg - ), - ); - self.reassigned_linted.insert(span); - } + // span lint once per statement that binds default + span_lint_and_note( + cx, + FIELD_REASSIGN_WITH_DEFAULT, + first_assign.unwrap().span, + "field assignment outside of initializer for an instance created with Default::default()", + Some(local.span), + &format!( + "consider initializing the variable with `{}` and removing relevant reassignments", + sugg + ), + ); + self.reassigned_linted.insert(span); } } } @@ -230,47 +236,6 @@ fn is_expr_default<'tcx>(expr: &'tcx Expr<'tcx>, cx: &LateContext<'tcx>) -> bool } } -/// Returns the block indices, identifiers and types of bindings set as `Default::default()`, except -/// for when the pattern type is a tuple. -fn enumerate_bindings_using_default<'tcx>( - cx: &LateContext<'tcx>, - block: &Block<'tcx>, -) -> Vec<(usize, Symbol, Ty<'tcx>, Span)> { - block - .stmts - .iter() - .enumerate() - .filter_map(|(idx, stmt)| { - if_chain! { - // only take `let ...` statements - if let StmtKind::Local(ref local) = stmt.kind; - // only take bindings to identifiers - if let PatKind::Binding(_, _, ident, _) = local.pat.kind; - // that are not tuples - let ty = cx.typeck_results().pat_ty(local.pat); - if !matches!(ty.kind(), ty::Tuple(_)); - // only when assigning `... = Default::default()` - if let Some(ref expr) = local.init; - if is_expr_default(expr, cx); - then { - Some((idx, ident.name, ty, expr.span)) - } else { - None - } - } - }) - .collect() -} - -fn stmt_shadows_binding(this: &Stmt<'_>, shadowed: Symbol) -> bool { - if let StmtKind::Local(local) = &this.kind { - if let PatKind::Binding(_, _, ident, _) = local.pat.kind { - return ident.name == shadowed; - } - } - false -} - /// Returns the reassigned field and the assigning expression (right-hand side of assign). fn field_reassigned_by_stmt<'tcx>(this: &Stmt<'tcx>, binding_name: Symbol) -> Option<(Ident, &'tcx Expr<'tcx>)> { if_chain! { @@ -290,14 +255,3 @@ fn field_reassigned_by_stmt<'tcx>(this: &Stmt<'tcx>, binding_name: Symbol) -> Op } } } - -/// Returns the vec of fields for a struct and an empty vec for non-struct ADTs. -fn fields_of_type(ty: Ty<'_>) -> Vec<Ident> { - if let Adt(adt, _) = ty.kind() { - if adt.is_struct() { - let variant = &adt.non_enum_variant(); - return variant.fields.iter().map(|f| f.ident).collect(); - } - } - vec![] -} diff --git a/src/tools/clippy/clippy_lints/src/from_over_into.rs b/src/tools/clippy/clippy_lints/src/from_over_into.rs new file mode 100644 index 00000000000..1e7e5f53cc2 --- /dev/null +++ b/src/tools/clippy/clippy_lints/src/from_over_into.rs @@ -0,0 +1,83 @@ +use crate::utils::paths::INTO; +use crate::utils::{match_def_path, meets_msrv, span_lint_and_help}; +use if_chain::if_chain; +use rustc_hir as hir; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_semver::RustcVersion; +use rustc_session::{declare_tool_lint, impl_lint_pass}; + +const FROM_OVER_INTO_MSRV: RustcVersion = RustcVersion::new(1, 41, 0); + +declare_clippy_lint! { + /// **What it does:** Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead. + /// + /// **Why is this bad?** According the std docs implementing `From<..>` is preferred since it gives you `Into<..>` for free where the reverse isn't true. + /// + /// **Known problems:** None. + /// + /// **Example:** + /// + /// ```rust + /// struct StringWrapper(String); + /// + /// impl Into<StringWrapper> for String { + /// fn into(self) -> StringWrapper { + /// StringWrapper(self) + /// } + /// } + /// ``` + /// Use instead: + /// ```rust + /// struct StringWrapper(String); + /// + /// impl From<String> for StringWrapper { + /// fn from(s: String) -> StringWrapper { + /// StringWrapper(s) + /// } + /// } + /// ``` + pub FROM_OVER_INTO, + style, + "Warns on implementations of `Into<..>` to use `From<..>`" +} + +pub struct FromOverInto { + msrv: Option<RustcVersion>, +} + +impl FromOverInto { + #[must_use] + pub fn new(msrv: Option<RustcVersion>) -> Self { + FromOverInto { msrv } + } +} + +impl_lint_pass!(FromOverInto => [FROM_OVER_INTO]); + +impl LateLintPass<'_> for FromOverInto { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { + if !meets_msrv(self.msrv.as_ref(), &FROM_OVER_INTO_MSRV) { + return; + } + + let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id); + if_chain! { + if let hir::ItemKind::Impl{ .. } = &item.kind; + if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id); + if match_def_path(cx, impl_trait_ref.def_id, &INTO); + + then { + span_lint_and_help( + cx, + FROM_OVER_INTO, + item.span, + "an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true", + None, + "consider to implement `From` instead", + ); + } + } + } + + extract_msrv_attr!(LateContext); +} diff --git a/src/tools/clippy/clippy_lints/src/large_enum_variant.rs b/src/tools/clippy/clippy_lints/src/large_enum_variant.rs index 3c7880d74ee..ad9b4f357a7 100644 --- a/src/tools/clippy/clippy_lints/src/large_enum_variant.rs +++ b/src/tools/clippy/clippy_lints/src/large_enum_variant.rs @@ -4,6 +4,7 @@ use crate::utils::{snippet_opt, span_lint_and_then}; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind, VariantData}; use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::lint::in_external_macro; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_target::abi::LayoutOf; @@ -58,6 +59,9 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]); impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant { fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { + if in_external_macro(cx.tcx.sess, item.span) { + return; + } let did = cx.tcx.hir().local_def_id(item.hir_id); if let ItemKind::Enum(ref def, _) = item.kind { let ty = cx.tcx.type_of(did); diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 02ba422a2f5..35b057d7b6a 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -207,6 +207,7 @@ mod float_literal; mod floating_point_arithmetic; mod format; mod formatting; +mod from_over_into; mod functions; mod future_not_send; mod get_last_with_len; @@ -614,6 +615,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING, &formatting::SUSPICIOUS_ELSE_FORMATTING, &formatting::SUSPICIOUS_UNARY_OP_FORMATTING, + &from_over_into::FROM_OVER_INTO, &functions::DOUBLE_MUST_USE, &functions::MUST_USE_CANDIDATE, &functions::MUST_USE_UNIT, @@ -1014,6 +1016,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_late_pass(move || box checked_conversions::CheckedConversions::new(msrv)); store.register_late_pass(move || box mem_replace::MemReplace::new(msrv)); store.register_late_pass(move || box ranges::Ranges::new(msrv)); + store.register_late_pass(move || box from_over_into::FromOverInto::new(msrv)); store.register_late_pass(move || box use_self::UseSelf::new(msrv)); store.register_late_pass(move || box missing_const_for_fn::MissingConstForFn::new(msrv)); @@ -1417,6 +1420,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING), LintId::of(&formatting::SUSPICIOUS_ELSE_FORMATTING), LintId::of(&formatting::SUSPICIOUS_UNARY_OP_FORMATTING), + LintId::of(&from_over_into::FROM_OVER_INTO), LintId::of(&functions::DOUBLE_MUST_USE), LintId::of(&functions::MUST_USE_UNIT), LintId::of(&functions::NOT_UNSAFE_PTR_ARG_DEREF), @@ -1663,6 +1667,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING), LintId::of(&formatting::SUSPICIOUS_ELSE_FORMATTING), LintId::of(&formatting::SUSPICIOUS_UNARY_OP_FORMATTING), + LintId::of(&from_over_into::FROM_OVER_INTO), LintId::of(&functions::DOUBLE_MUST_USE), LintId::of(&functions::MUST_USE_UNIT), LintId::of(&functions::RESULT_UNIT_ERR), diff --git a/src/tools/clippy/clippy_lints/src/lifetimes.rs b/src/tools/clippy/clippy_lints/src/lifetimes.rs index 4d737b3f49b..e84c8b4e5b3 100644 --- a/src/tools/clippy/clippy_lints/src/lifetimes.rs +++ b/src/tools/clippy/clippy_lints/src/lifetimes.rs @@ -501,7 +501,7 @@ impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker { // for lifetimes as parameters of generics fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) { - if lifetime.name.ident().name != kw::Invalid && lifetime.name.ident().name != kw::StaticLifetime { + if lifetime.name.ident().name != kw::Empty && lifetime.name.ident().name != kw::StaticLifetime { self.lifetimes_used_in_body = true; } } diff --git a/src/tools/clippy/clippy_lints/src/macro_use.rs b/src/tools/clippy/clippy_lints/src/macro_use.rs index b4b4b3dc18d..bb52888883a 100644 --- a/src/tools/clippy/clippy_lints/src/macro_use.rs +++ b/src/tools/clippy/clippy_lints/src/macro_use.rs @@ -105,7 +105,7 @@ impl MacroUseImports { impl<'tcx> LateLintPass<'tcx> for MacroUseImports { fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) { if_chain! { - if cx.sess().opts.edition == Edition::Edition2018; + if cx.sess().opts.edition >= Edition::Edition2018; if let hir::ItemKind::Use(path, _kind) = &item.kind; if let Some(mac_attr) = item .attrs diff --git a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs index 7b3b450ef93..29439e52c48 100644 --- a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs +++ b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs @@ -69,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn { |diag| { if_chain! { if let Some(header_snip) = snippet_opt(cx, header_span); - if let Some(ret_pos) = position_before_rarrow(header_snip.clone()); + if let Some(ret_pos) = position_before_rarrow(&header_snip); if let Some((ret_sugg, ret_snip)) = suggested_ret(cx, output); then { let help = format!("make the function `async` and {}", ret_sugg); diff --git a/src/tools/clippy/clippy_lints/src/map_err_ignore.rs b/src/tools/clippy/clippy_lints/src/map_err_ignore.rs index f3c0515b9bc..76fe8e776ea 100644 --- a/src/tools/clippy/clippy_lints/src/map_err_ignore.rs +++ b/src/tools/clippy/clippy_lints/src/map_err_ignore.rs @@ -7,7 +7,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { /// **What it does:** Checks for instances of `map_err(|_| Some::Enum)` /// - /// **Why is this bad?** This map_err throws away the original error rather than allowing the enum to contain and report the cause of the error + /// **Why is this bad?** This `map_err` throws away the original error rather than allowing the enum to contain and report the cause of the error /// /// **Known problems:** None. /// @@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for MapErrIgnore { body_span, "`map_err(|_|...` wildcard pattern discards the original error", None, - "Consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`)", + "consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`)", ); } } diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index dcb643a28ae..c494a713631 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -182,20 +182,6 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id: if let ty::Ref(_, ty, Mutability::Not) = ty.kind() { if is_type_diagnostic_item(cx, ty, sym::vec_type) { - let mut ty_snippet = None; - if_chain! { - if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).kind; - if let Some(&PathSegment{args: Some(ref parameters), ..}) = path.segments.last(); - then { - let types: Vec<_> = parameters.args.iter().filter_map(|arg| match arg { - GenericArg::Type(ty) => Some(ty), - _ => None, - }).collect(); - if types.len() == 1 { - ty_snippet = snippet_opt(cx, types[0].span); - } - } - }; if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_owned()")]) { span_lint_and_then( cx, @@ -204,7 +190,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id: "writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used \ with non-Vec-based slices.", |diag| { - if let Some(ref snippet) = ty_snippet { + if let Some(ref snippet) = get_only_generic_arg_snippet(cx, arg) { diag.span_suggestion( arg.span, "change this to", @@ -247,6 +233,33 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id: }, ); } + } else if match_type(cx, ty, &paths::PATH_BUF) { + if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_path_buf()"), ("as_path", "")]) { + span_lint_and_then( + cx, + PTR_ARG, + arg.span, + "writing `&PathBuf` instead of `&Path` involves a new object where a slice will do.", + |diag| { + diag.span_suggestion( + arg.span, + "change this to", + "&Path".into(), + Applicability::Unspecified, + ); + for (clonespan, suggestion) in spans { + diag.span_suggestion_short( + clonespan, + &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| { + Cow::Owned(format!("change `{}` to", x)) + }), + suggestion.into(), + Applicability::Unspecified, + ); + } + }, + ); + } } else if match_type(cx, ty, &paths::COW) { if_chain! { if let TyKind::Rptr(_, MutTy { ref ty, ..} ) = arg.kind; @@ -309,6 +322,23 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id: } } +fn get_only_generic_arg_snippet(cx: &LateContext<'_>, arg: &Ty<'_>) -> Option<String> { + if_chain! { + if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).kind; + if let Some(&PathSegment{args: Some(ref parameters), ..}) = path.segments.last(); + let types: Vec<_> = parameters.args.iter().filter_map(|arg| match arg { + GenericArg::Type(ty) => Some(ty), + _ => None, + }).collect(); + if types.len() == 1; + then { + snippet_opt(cx, types[0].span) + } else { + None + } + } +} + fn get_rptr_lm<'tcx>(ty: &'tcx Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> { if let TyKind::Rptr(ref lt, ref m) = ty.kind { Some((lt, m.mutbl, ty.span)) diff --git a/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs b/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs index 35b38eca14d..1fc4ff5c2e6 100644 --- a/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs +++ b/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs @@ -40,7 +40,7 @@ impl EarlyLintPass for SingleComponentPathImports { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { if_chain! { if !in_macro(item.span); - if cx.sess.opts.edition == Edition::Edition2018; + if cx.sess.opts.edition >= Edition::Edition2018; if !item.vis.kind.is_pub(); if let ItemKind::Use(use_tree) = &item.kind; if let segments = &use_tree.prefix.segments; diff --git a/src/tools/clippy/clippy_lints/src/unused_unit.rs b/src/tools/clippy/clippy_lints/src/unused_unit.rs index f61fd2ecd73..a31cd5fda84 100644 --- a/src/tools/clippy/clippy_lints/src/unused_unit.rs +++ b/src/tools/clippy/clippy_lints/src/unused_unit.rs @@ -120,7 +120,7 @@ fn is_unit_expr(expr: &ast::Expr) -> bool { fn lint_unneeded_unit_return(cx: &EarlyContext<'_>, ty: &ast::Ty, span: Span) { let (ret_span, appl) = if let Ok(fn_source) = cx.sess().source_map().span_to_snippet(span.with_hi(ty.span.hi())) { - position_before_rarrow(fn_source).map_or((ty.span, Applicability::MaybeIncorrect), |rpos| { + position_before_rarrow(&fn_source).map_or((ty.span, Applicability::MaybeIncorrect), |rpos| { ( #[allow(clippy::cast_possible_truncation)] ty.span.with_lo(BytePos(span.lo().0 + rpos as u32)), diff --git a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs index f0267e4c792..5aed676fceb 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs @@ -407,6 +407,10 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool { } } +pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool { + eq_expr(&l.value, &r.value) +} + pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool { matches!( (l, r), @@ -497,7 +501,18 @@ pub fn eq_generic_param(l: &GenericParam, r: &GenericParam) -> bool { && match (&l.kind, &r.kind) { (Lifetime, Lifetime) => true, (Type { default: l }, Type { default: r }) => both(l, r, |l, r| eq_ty(l, r)), - (Const { ty: l, kw_span: _ }, Const { ty: r, kw_span: _ }) => eq_ty(l, r), + ( + Const { + ty: lt, + kw_span: _, + default: ld, + }, + Const { + ty: rt, + kw_span: _, + default: rd, + }, + ) => eq_ty(lt, rt) && both(ld, rd, |ld, rd| eq_anon_const(ld, rd)), _ => false, } && over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r)) diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 424856090f2..1c68e837c4a 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -788,8 +788,7 @@ pub fn indent_of<T: LintContext>(cx: &T, span: Span) -> Option<usize> { /// fn into3(self) -> () {} /// ^ /// ``` -#[allow(clippy::needless_pass_by_value)] -pub fn position_before_rarrow(s: String) -> Option<usize> { +pub fn position_before_rarrow(s: &str) -> Option<usize> { s.rfind("->").map(|rpos| { let mut rpos = rpos; let chars: Vec<char> = s.chars().collect(); diff --git a/src/tools/clippy/clippy_lints/src/utils/ptr.rs b/src/tools/clippy/clippy_lints/src/utils/ptr.rs index bd2c619f000..b330f3d890e 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ptr.rs @@ -72,7 +72,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> { } } } - return; } walk_expr(self, expr); } diff --git a/src/tools/clippy/rust-toolchain b/src/tools/clippy/rust-toolchain index d2e84132f4e..c579beeae89 100644 --- a/src/tools/clippy/rust-toolchain +++ b/src/tools/clippy/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2020-12-20" +channel = "nightly-2021-01-02" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 40f1b802e60..e490ee54c0b 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -1,6 +1,5 @@ #![feature(rustc_private)] #![feature(once_cell)] -#![feature(bool_to_option)] #![cfg_attr(feature = "deny-warnings", deny(warnings))] // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] @@ -20,7 +19,6 @@ use rustc_tools_util::VersionInfo; use std::borrow::Cow; use std::env; -use std::iter; use std::lazy::SyncLazy; use std::ops::Deref; use std::panic; @@ -49,6 +47,20 @@ fn arg_value<'a, T: Deref<Target = str>>( None } +#[test] +fn test_arg_value() { + let args = &["--bar=bar", "--foobar", "123", "--foo"]; + + assert_eq!(arg_value(&[] as &[&str], "--foobar", |_| true), None); + assert_eq!(arg_value(args, "--bar", |_| false), None); + assert_eq!(arg_value(args, "--bar", |_| true), Some("bar")); + assert_eq!(arg_value(args, "--bar", |p| p == "bar"), Some("bar")); + assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None); + assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None); + assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123")); + assert_eq!(arg_value(args, "--foo", |_| true), None); +} + struct DefaultCallbacks; impl rustc_driver::Callbacks for DefaultCallbacks {} @@ -170,28 +182,6 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat }) } -fn remove_clippy_args<'a, T, U, I>(args: &mut Vec<T>, clippy_args: I) -where - T: AsRef<str>, - U: AsRef<str> + ?Sized + 'a, - I: Iterator<Item = &'a U> + Clone, -{ - let args_iter = clippy_args.map(AsRef::as_ref); - let args_count = args_iter.clone().count(); - - if args_count > 0 { - if let Some(start) = args.windows(args_count).enumerate().find_map(|(current, window)| { - window - .iter() - .map(AsRef::as_ref) - .eq(args_iter.clone()) - .then_some(current) - }) { - args.drain(start..start + args_count); - } - } -} - #[allow(clippy::too_many_lines)] pub fn main() { rustc_driver::init_rustc_env_logger(); @@ -288,9 +278,20 @@ pub fn main() { args.extend(vec!["--sysroot".into(), sys_root]); }; - let clippy_args = env::var("CLIPPY_ARGS").unwrap_or_default(); - let clippy_args = clippy_args.split_whitespace(); - let no_deps = clippy_args.clone().any(|flag| flag == "--no-deps"); + let mut no_deps = false; + let clippy_args = env::var("CLIPPY_ARGS") + .unwrap_or_default() + .split("__CLIPPY_HACKERY__") + .filter_map(|s| match s { + "" => None, + "--no-deps" => { + no_deps = true; + None + }, + _ => Some(s.to_string()), + }) + .chain(vec!["--cfg".into(), r#"feature="cargo-clippy""#.into()]) + .collect::<Vec<String>>(); // We enable Clippy if one of the following conditions is met // - IF Clippy is run on its test suite OR @@ -303,11 +304,7 @@ pub fn main() { let clippy_enabled = clippy_tests_set || (!cap_lints_allow && (!no_deps || in_primary_package)); if clippy_enabled { - remove_clippy_args(&mut args, iter::once("--no-deps")); - args.extend(vec!["--cfg".into(), r#"feature="cargo-clippy""#.into()]); - } else { - // Remove all flags passed through RUSTFLAGS if Clippy is not enabled. - remove_clippy_args(&mut args, clippy_args); + args.extend(clippy_args); } let mut clippy = ClippyCallbacks; @@ -318,58 +315,3 @@ pub fn main() { rustc_driver::RunCompiler::new(&args, callbacks).run() })) } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_arg_value() { - let args = &["--bar=bar", "--foobar", "123", "--foo"]; - - assert_eq!(arg_value(&[] as &[&str], "--foobar", |_| true), None); - assert_eq!(arg_value(args, "--bar", |_| false), None); - assert_eq!(arg_value(args, "--bar", |_| true), Some("bar")); - assert_eq!(arg_value(args, "--bar", |p| p == "bar"), Some("bar")); - assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None); - assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None); - assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123")); - assert_eq!(arg_value(args, "--foo", |_| true), None); - } - - #[test] - fn removes_clippy_args_from_start() { - let mut args = vec!["-D", "clippy::await_holding_lock", "--cfg", r#"feature="some_feat""#]; - let clippy_args = ["-D", "clippy::await_holding_lock"].iter(); - - remove_clippy_args(&mut args, clippy_args); - assert_eq!(args, &["--cfg", r#"feature="some_feat""#]); - } - - #[test] - fn removes_clippy_args_from_end() { - let mut args = vec!["-Zui-testing", "-A", "clippy::empty_loop", "--no-deps"]; - let clippy_args = ["-A", "clippy::empty_loop", "--no-deps"].iter(); - - remove_clippy_args(&mut args, clippy_args); - assert_eq!(args, &["-Zui-testing"]); - } - - #[test] - fn removes_clippy_args_from_middle() { - let mut args = vec!["-Zui-testing", "-W", "clippy::filter_map", "-L", "serde"]; - let clippy_args = ["-W", "clippy::filter_map"].iter(); - - remove_clippy_args(&mut args, clippy_args); - assert_eq!(args, &["-Zui-testing", "-L", "serde"]); - } - - #[test] - fn no_clippy_args_to_remove() { - let mut args = vec!["-Zui-testing", "-L", "serde"]; - let clippy_args: [&str; 0] = []; - - remove_clippy_args(&mut args, clippy_args.iter()); - assert_eq!(args, &["-Zui-testing", "-L", "serde"]); - } -} diff --git a/src/tools/clippy/src/main.rs b/src/tools/clippy/src/main.rs index 1c0e04689a9..ea06743394d 100644 --- a/src/tools/clippy/src/main.rs +++ b/src/tools/clippy/src/main.rs @@ -1,5 +1,3 @@ -#![feature(bool_to_option)] -#![feature(command_access)] #![cfg_attr(feature = "deny-warnings", deny(warnings))] // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] @@ -64,7 +62,7 @@ struct ClippyCmd { unstable_options: bool, cargo_subcommand: &'static str, args: Vec<String>, - clippy_args: Option<String>, + clippy_args: Vec<String>, } impl ClippyCmd { @@ -101,17 +99,16 @@ impl ClippyCmd { args.insert(0, "+nightly".to_string()); } - let mut clippy_args = old_args.collect::<Vec<String>>().join(" "); - if cargo_subcommand == "fix" && !clippy_args.contains("--no-deps") { - clippy_args = format!("{} --no-deps", clippy_args); + let mut clippy_args: Vec<String> = old_args.collect(); + if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") { + clippy_args.push("--no-deps".into()); } - let has_args = !clippy_args.is_empty(); ClippyCmd { unstable_options, cargo_subcommand, args, - clippy_args: has_args.then_some(clippy_args), + clippy_args, } } @@ -151,24 +148,20 @@ impl ClippyCmd { .map(|p| ("CARGO_TARGET_DIR", p)) } - fn into_std_cmd(self, rustflags: Option<String>) -> Command { + fn into_std_cmd(self) -> Command { let mut cmd = Command::new("cargo"); + let clippy_args: String = self + .clippy_args + .iter() + .map(|arg| format!("{}__CLIPPY_HACKERY__", arg)) + .collect(); cmd.env(self.path_env(), Self::path()) .envs(ClippyCmd::target_dir()) + .env("CLIPPY_ARGS", clippy_args) .arg(self.cargo_subcommand) .args(&self.args); - // HACK: pass Clippy args to the driver *also* through RUSTFLAGS. - // This guarantees that new builds will be triggered when Clippy flags change. - if let Some(clippy_args) = self.clippy_args { - cmd.env( - "RUSTFLAGS", - rustflags.map_or(clippy_args.clone(), |flags| format!("{} {}", clippy_args, flags)), - ); - cmd.env("CLIPPY_ARGS", clippy_args); - } - cmd } } @@ -179,7 +172,7 @@ where { let cmd = ClippyCmd::new(old_args); - let mut cmd = cmd.into_std_cmd(env::var("RUSTFLAGS").ok()); + let mut cmd = cmd.into_std_cmd(); let exit_status = cmd .spawn() @@ -197,7 +190,6 @@ where #[cfg(test)] mod tests { use super::ClippyCmd; - use std::ffi::OsStr; #[test] #[should_panic] @@ -212,7 +204,6 @@ mod tests { .split_whitespace() .map(ToString::to_string); let cmd = ClippyCmd::new(args); - assert_eq!("fix", cmd.cargo_subcommand); assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env()); assert!(cmd.args.iter().any(|arg| arg.ends_with("unstable-options"))); @@ -224,8 +215,7 @@ mod tests { .split_whitespace() .map(ToString::to_string); let cmd = ClippyCmd::new(args); - - assert!(cmd.clippy_args.unwrap().contains("--no-deps")); + assert!(cmd.clippy_args.iter().any(|arg| arg == "--no-deps")); } #[test] @@ -234,15 +224,13 @@ mod tests { .split_whitespace() .map(ToString::to_string); let cmd = ClippyCmd::new(args); - - assert_eq!(1, cmd.clippy_args.unwrap().matches("--no-deps").count()); + assert_eq!(cmd.clippy_args.iter().filter(|arg| *arg == "--no-deps").count(), 1); } #[test] fn check() { let args = "cargo clippy".split_whitespace().map(ToString::to_string); let cmd = ClippyCmd::new(args); - assert_eq!("check", cmd.cargo_subcommand); assert_eq!("RUSTC_WRAPPER", cmd.path_env()); } @@ -253,63 +241,7 @@ mod tests { .split_whitespace() .map(ToString::to_string); let cmd = ClippyCmd::new(args); - assert_eq!("check", cmd.cargo_subcommand); assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env()); } - - #[test] - fn clippy_args_into_rustflags() { - let args = "cargo clippy -- -W clippy::as_conversions" - .split_whitespace() - .map(ToString::to_string); - let cmd = ClippyCmd::new(args); - - let rustflags = None; - let cmd = cmd.into_std_cmd(rustflags); - - assert!(cmd - .get_envs() - .any(|(key, val)| key == "RUSTFLAGS" && val == Some(OsStr::new("-W clippy::as_conversions")))); - } - - #[test] - fn clippy_args_respect_existing_rustflags() { - let args = "cargo clippy -- -D clippy::await_holding_lock" - .split_whitespace() - .map(ToString::to_string); - let cmd = ClippyCmd::new(args); - - let rustflags = Some(r#"--cfg feature="some_feat""#.into()); - let cmd = cmd.into_std_cmd(rustflags); - - assert!(cmd.get_envs().any(|(key, val)| key == "RUSTFLAGS" - && val == Some(OsStr::new(r#"-D clippy::await_holding_lock --cfg feature="some_feat""#)))); - } - - #[test] - fn no_env_change_if_no_clippy_args() { - let args = "cargo clippy".split_whitespace().map(ToString::to_string); - let cmd = ClippyCmd::new(args); - - let rustflags = Some(r#"--cfg feature="some_feat""#.into()); - let cmd = cmd.into_std_cmd(rustflags); - - assert!(!cmd - .get_envs() - .any(|(key, _)| key == "RUSTFLAGS" || key == "CLIPPY_ARGS")); - } - - #[test] - fn no_env_change_if_no_clippy_args_nor_rustflags() { - let args = "cargo clippy".split_whitespace().map(ToString::to_string); - let cmd = ClippyCmd::new(args); - - let rustflags = None; - let cmd = cmd.into_std_cmd(rustflags); - - assert!(!cmd - .get_envs() - .any(|(key, _)| key == "RUSTFLAGS" || key == "CLIPPY_ARGS")) - } } diff --git a/src/tools/clippy/tests/dogfood.rs b/src/tools/clippy/tests/dogfood.rs index fda1413868e..052223d6d6f 100644 --- a/src/tools/clippy/tests/dogfood.rs +++ b/src/tools/clippy/tests/dogfood.rs @@ -23,7 +23,7 @@ fn dogfood_clippy() { .current_dir(root_dir) .env("CLIPPY_DOGFOOD", "1") .env("CARGO_INCREMENTAL", "0") - .arg("clippy") + .arg("clippy-preview") .arg("--all-targets") .arg("--all-features") .arg("--") diff --git a/src/tools/clippy/tests/ui/auxiliary/macro_rules.rs b/src/tools/clippy/tests/ui/auxiliary/macro_rules.rs index f985a15eda2..18324823468 100644 --- a/src/tools/clippy/tests/ui/auxiliary/macro_rules.rs +++ b/src/tools/clippy/tests/ui/auxiliary/macro_rules.rs @@ -84,3 +84,13 @@ macro_rules! as_conv { 0u32 as u64 }; } + +#[macro_export] +macro_rules! large_enum_variant { + () => { + enum LargeEnumInMacro { + A(i32), + B([i32; 8000]), + } + }; +} diff --git a/src/tools/clippy/tests/ui/field_reassign_with_default.rs b/src/tools/clippy/tests/ui/field_reassign_with_default.rs index 79a30c22f95..3e0921022b4 100644 --- a/src/tools/clippy/tests/ui/field_reassign_with_default.rs +++ b/src/tools/clippy/tests/ui/field_reassign_with_default.rs @@ -107,4 +107,16 @@ fn main() { x.i = side_effect.next(); x.j = 2; x.i = side_effect.next(); + + // don't lint - some private fields + let mut x = m::F::default(); + x.a = 1; +} + +mod m { + #[derive(Default)] + pub struct F { + pub a: u64, + b: u64, + } } diff --git a/src/tools/clippy/tests/ui/field_reassign_with_default.stderr b/src/tools/clippy/tests/ui/field_reassign_with_default.stderr index c788ebae552..9a2bc778c3f 100644 --- a/src/tools/clippy/tests/ui/field_reassign_with_default.stderr +++ b/src/tools/clippy/tests/ui/field_reassign_with_default.stderr @@ -53,7 +53,7 @@ error: field assignment outside of initializer for an instance created with Defa LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: consider initializing the variable with `A::default()` and removing relevant reassignments +note: consider initializing the variable with `A { i: Default::default(), ..Default::default() }` and removing relevant reassignments --> $DIR/field_reassign_with_default.rs:90:5 | LL | let mut a: A = Default::default(); @@ -65,7 +65,7 @@ error: field assignment outside of initializer for an instance created with Defa LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: consider initializing the variable with `A { j: 45, ..Default::default() }` and removing relevant reassignments +note: consider initializing the variable with `A { i: Default::default(), j: 45 }` and removing relevant reassignments --> $DIR/field_reassign_with_default.rs:94:5 | LL | let mut a: A = Default::default(); diff --git a/src/tools/clippy/tests/ui/from_over_into.rs b/src/tools/clippy/tests/ui/from_over_into.rs new file mode 100644 index 00000000000..292d0924fb1 --- /dev/null +++ b/src/tools/clippy/tests/ui/from_over_into.rs @@ -0,0 +1,21 @@ +#![warn(clippy::from_over_into)] + +// this should throw an error +struct StringWrapper(String); + +impl Into<StringWrapper> for String { + fn into(self) -> StringWrapper { + StringWrapper(self) + } +} + +// this is fine +struct A(String); + +impl From<String> for A { + fn from(s: String) -> A { + A(s) + } +} + +fn main() {} diff --git a/src/tools/clippy/tests/ui/from_over_into.stderr b/src/tools/clippy/tests/ui/from_over_into.stderr new file mode 100644 index 00000000000..18f56f85432 --- /dev/null +++ b/src/tools/clippy/tests/ui/from_over_into.stderr @@ -0,0 +1,15 @@ +error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true + --> $DIR/from_over_into.rs:6:1 + | +LL | / impl Into<StringWrapper> for String { +LL | | fn into(self) -> StringWrapper { +LL | | StringWrapper(self) +LL | | } +LL | | } + | |_^ + | + = note: `-D clippy::from-over-into` implied by `-D warnings` + = help: consider to implement `From` instead + +error: aborting due to previous error + diff --git a/src/tools/clippy/tests/ui/large_enum_variant.rs b/src/tools/clippy/tests/ui/large_enum_variant.rs index 852ef5fec0e..d22fee3f27b 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.rs +++ b/src/tools/clippy/tests/ui/large_enum_variant.rs @@ -1,7 +1,12 @@ +// aux-build:macro_rules.rs + #![allow(dead_code)] #![allow(unused_variables)] #![warn(clippy::large_enum_variant)] +#[macro_use] +extern crate macro_rules; + enum LargeEnum { A(i32), B([i32; 8000]), @@ -51,4 +56,6 @@ enum LargeEnumOk { LargeB([i32; 8001]), } -fn main() {} +fn main() { + large_enum_variant!(); +} diff --git a/src/tools/clippy/tests/ui/large_enum_variant.stderr b/src/tools/clippy/tests/ui/large_enum_variant.stderr index 8ce641a81f2..d39a4d462aa 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.stderr +++ b/src/tools/clippy/tests/ui/large_enum_variant.stderr @@ -1,12 +1,12 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:7:5 + --> $DIR/large_enum_variant.rs:12:5 | LL | B([i32; 8000]), | ^^^^^^^^^^^^^^ this variant is 32000 bytes | = note: `-D clippy::large-enum-variant` implied by `-D warnings` note: and the second-largest variant is 4 bytes: - --> $DIR/large_enum_variant.rs:6:5 + --> $DIR/large_enum_variant.rs:11:5 | LL | A(i32), | ^^^^^^ @@ -16,13 +16,13 @@ LL | B(Box<[i32; 8000]>), | ^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:31:5 + --> $DIR/large_enum_variant.rs:36:5 | LL | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this variant is 32004 bytes | note: and the second-largest variant is 8 bytes: - --> $DIR/large_enum_variant.rs:30:5 + --> $DIR/large_enum_variant.rs:35:5 | LL | VariantOk(i32, u32), | ^^^^^^^^^^^^^^^^^^^ @@ -32,30 +32,30 @@ LL | ContainingLargeEnum(Box<LargeEnum>), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:41:5 + --> $DIR/large_enum_variant.rs:46:5 | LL | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this variant is 32004 bytes | note: and the second-largest variant is 8 bytes: - --> $DIR/large_enum_variant.rs:40:5 + --> $DIR/large_enum_variant.rs:45:5 | LL | VariantOk(i32, u32), | ^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:41:5 + --> $DIR/large_enum_variant.rs:46:5 | LL | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:46:5 + --> $DIR/large_enum_variant.rs:51:5 | LL | StructLikeLarge2 { x: [i32; 8000] }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this variant is 32000 bytes | note: and the second-largest variant is 8 bytes: - --> $DIR/large_enum_variant.rs:45:5 + --> $DIR/large_enum_variant.rs:50:5 | LL | VariantOk(i32, u32), | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/map_err.stderr b/src/tools/clippy/tests/ui/map_err.stderr index 8ee2941790d..37e87e64de2 100644 --- a/src/tools/clippy/tests/ui/map_err.stderr +++ b/src/tools/clippy/tests/ui/map_err.stderr @@ -5,7 +5,7 @@ LL | println!("{:?}", x.map_err(|_| Errors::Ignored)); | ^^^ | = note: `-D clippy::map-err-ignore` implied by `-D warnings` - = help: Consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`) + = help: consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`) error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed index 7f4ebf56673..84981a52597 100644 --- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed +++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed @@ -39,7 +39,7 @@ fn main() { B(i32), C, D, - }; + } let x = E::A(2); { // lint diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs index aee56dd4a5e..94c7c3cadac 100644 --- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs +++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs @@ -51,7 +51,7 @@ fn main() { B(i32), C, D, - }; + } let x = E::A(2); { // lint diff --git a/src/tools/clippy/tests/ui/min_rust_version_attr.rs b/src/tools/clippy/tests/ui/min_rust_version_attr.rs index 3848bca3207..0f47f1cbc40 100644 --- a/src/tools/clippy/tests/ui/min_rust_version_attr.rs +++ b/src/tools/clippy/tests/ui/min_rust_version_attr.rs @@ -57,6 +57,14 @@ pub fn checked_conversion() { let _ = value <= (u32::MAX as i64) && value >= 0; } +pub struct FromOverInto(String); + +impl Into<FromOverInto> for String { + fn into(self) -> FromOverInto { + FromOverInto(self) + } +} + pub fn filter_map_next() { let a = ["1", "lol", "3", "NaN", "5"]; diff --git a/src/tools/clippy/tests/ui/min_rust_version_attr.stderr b/src/tools/clippy/tests/ui/min_rust_version_attr.stderr index 34805263104..e3e3b335cbe 100644 --- a/src/tools/clippy/tests/ui/min_rust_version_attr.stderr +++ b/src/tools/clippy/tests/ui/min_rust_version_attr.stderr @@ -1,12 +1,12 @@ error: stripping a prefix manually - --> $DIR/min_rust_version_attr.rs:142:24 + --> $DIR/min_rust_version_attr.rs:150:24 | LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!"); | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::manual-strip` implied by `-D warnings` note: the prefix was tested here - --> $DIR/min_rust_version_attr.rs:141:9 + --> $DIR/min_rust_version_attr.rs:149:9 | LL | if s.starts_with("hello, ") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,13 +17,13 @@ LL | assert_eq!(<stripped>.to_uppercase(), "WORLD!"); | error: stripping a prefix manually - --> $DIR/min_rust_version_attr.rs:154:24 + --> $DIR/min_rust_version_attr.rs:162:24 | LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!"); | ^^^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/min_rust_version_attr.rs:153:9 + --> $DIR/min_rust_version_attr.rs:161:9 | LL | if s.starts_with("hello, ") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/ptr_arg.rs b/src/tools/clippy/tests/ui/ptr_arg.rs index 541225e6351..06370dfce65 100644 --- a/src/tools/clippy/tests/ui/ptr_arg.rs +++ b/src/tools/clippy/tests/ui/ptr_arg.rs @@ -2,6 +2,7 @@ #![warn(clippy::ptr_arg)] use std::borrow::Cow; +use std::path::PathBuf; fn do_vec(x: &Vec<i64>) { //Nothing here @@ -21,6 +22,15 @@ fn do_str_mut(x: &mut String) { //Nothing here either } +fn do_path(x: &PathBuf) { + //Nothing here either +} + +fn do_path_mut(x: &mut PathBuf) { + // no error here + //Nothing here either +} + fn main() {} trait Foo { @@ -55,6 +65,14 @@ fn str_cloned(x: &String) -> String { x.clone() } +fn path_cloned(x: &PathBuf) -> PathBuf { + let a = x.clone(); + let b = x.clone(); + let c = b.clone(); + let d = a.clone().clone().clone(); + x.clone() +} + fn false_positive_capacity(x: &Vec<u8>, y: &String) { let a = x.capacity(); let b = y.clone(); @@ -87,10 +105,12 @@ impl Foo2 for String { // Check that the allow attribute on parameters is honored mod issue_5644 { use std::borrow::Cow; + use std::path::PathBuf; fn allowed( #[allow(clippy::ptr_arg)] _v: &Vec<u32>, #[allow(clippy::ptr_arg)] _s: &String, + #[allow(clippy::ptr_arg)] _p: &PathBuf, #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>, ) { } @@ -100,6 +120,7 @@ mod issue_5644 { fn allowed( #[allow(clippy::ptr_arg)] _v: &Vec<u32>, #[allow(clippy::ptr_arg)] _s: &String, + #[allow(clippy::ptr_arg)] _p: &PathBuf, #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>, ) { } @@ -109,8 +130,28 @@ mod issue_5644 { fn allowed( #[allow(clippy::ptr_arg)] _v: &Vec<u32>, #[allow(clippy::ptr_arg)] _s: &String, + #[allow(clippy::ptr_arg)] _p: &PathBuf, #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>, ) { } } } + +mod issue6509 { + use std::path::PathBuf; + + fn foo_vec(vec: &Vec<u8>) { + let _ = vec.clone().pop(); + let _ = vec.clone().clone(); + } + + fn foo_path(path: &PathBuf) { + let _ = path.clone().pop(); + let _ = path.clone().clone(); + } + + fn foo_str(str: &PathBuf) { + let _ = str.clone().pop(); + let _ = str.clone().clone(); + } +} diff --git a/src/tools/clippy/tests/ui/ptr_arg.stderr b/src/tools/clippy/tests/ui/ptr_arg.stderr index 314f23497f9..708318bbe29 100644 --- a/src/tools/clippy/tests/ui/ptr_arg.stderr +++ b/src/tools/clippy/tests/ui/ptr_arg.stderr @@ -1,5 +1,5 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:6:14 + --> $DIR/ptr_arg.rs:7:14 | LL | fn do_vec(x: &Vec<i64>) { | ^^^^^^^^^ help: change this to: `&[i64]` @@ -7,19 +7,25 @@ LL | fn do_vec(x: &Vec<i64>) { = note: `-D clippy::ptr-arg` implied by `-D warnings` error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:15:14 + --> $DIR/ptr_arg.rs:16:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. + --> $DIR/ptr_arg.rs:25:15 + | +LL | fn do_path(x: &PathBuf) { + | ^^^^^^^^ help: change this to: `&Path` + error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:28:18 + --> $DIR/ptr_arg.rs:38:18 | LL | fn do_vec(x: &Vec<i64>); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:41:14 + --> $DIR/ptr_arg.rs:51:14 | LL | fn cloned(x: &Vec<u8>) -> Vec<u8> { | ^^^^^^^^ @@ -38,7 +44,7 @@ LL | x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:50:18 + --> $DIR/ptr_arg.rs:60:18 | LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ @@ -60,8 +66,31 @@ help: change `x.clone()` to LL | x.to_string() | +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. + --> $DIR/ptr_arg.rs:68:19 + | +LL | fn path_cloned(x: &PathBuf) -> PathBuf { + | ^^^^^^^^ + | +help: change this to + | +LL | fn path_cloned(x: &Path) -> PathBuf { + | ^^^^^ +help: change `x.clone()` to + | +LL | let a = x.to_path_buf(); + | ^^^^^^^^^^^^^^^ +help: change `x.clone()` to + | +LL | let b = x.to_path_buf(); + | ^^^^^^^^^^^^^^^ +help: change `x.clone()` to + | +LL | x.to_path_buf() + | + error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:58:44 + --> $DIR/ptr_arg.rs:76:44 | LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) { | ^^^^^^^ @@ -80,10 +109,67 @@ LL | let c = y; | ^ error: using a reference to `Cow` is not recommended. - --> $DIR/ptr_arg.rs:72:25 + --> $DIR/ptr_arg.rs:90:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` -error: aborting due to 7 previous errors +error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. + --> $DIR/ptr_arg.rs:143:21 + | +LL | fn foo_vec(vec: &Vec<u8>) { + | ^^^^^^^^ + | +help: change this to + | +LL | fn foo_vec(vec: &[u8]) { + | ^^^^^ +help: change `vec.clone()` to + | +LL | let _ = vec.to_owned().pop(); + | ^^^^^^^^^^^^^^ +help: change `vec.clone()` to + | +LL | let _ = vec.to_owned().clone(); + | ^^^^^^^^^^^^^^ + +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. + --> $DIR/ptr_arg.rs:148:23 + | +LL | fn foo_path(path: &PathBuf) { + | ^^^^^^^^ + | +help: change this to + | +LL | fn foo_path(path: &Path) { + | ^^^^^ +help: change `path.clone()` to + | +LL | let _ = path.to_path_buf().pop(); + | ^^^^^^^^^^^^^^^^^^ +help: change `path.clone()` to + | +LL | let _ = path.to_path_buf().clone(); + | ^^^^^^^^^^^^^^^^^^ + +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. + --> $DIR/ptr_arg.rs:153:21 + | +LL | fn foo_str(str: &PathBuf) { + | ^^^^^^^^ + | +help: change this to + | +LL | fn foo_str(str: &Path) { + | ^^^^^ +help: change `str.clone()` to + | +LL | let _ = str.to_path_buf().pop(); + | ^^^^^^^^^^^^^^^^^ +help: change `str.clone()` to + | +LL | let _ = str.to_path_buf().clone(); + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors diff --git a/src/tools/clippy/tests/ui/unused_unit.fixed b/src/tools/clippy/tests/ui/unused_unit.fixed index 7afc5361356..a192ebde3eb 100644 --- a/src/tools/clippy/tests/ui/unused_unit.fixed +++ b/src/tools/clippy/tests/ui/unused_unit.fixed @@ -11,6 +11,7 @@ #![deny(clippy::unused_unit)] #![allow(dead_code)] +#![allow(clippy::from_over_into)] struct Unitter; impl Unitter { diff --git a/src/tools/clippy/tests/ui/unused_unit.rs b/src/tools/clippy/tests/ui/unused_unit.rs index 96cef1ed5a5..96041a7dd85 100644 --- a/src/tools/clippy/tests/ui/unused_unit.rs +++ b/src/tools/clippy/tests/ui/unused_unit.rs @@ -11,6 +11,7 @@ #![deny(clippy::unused_unit)] #![allow(dead_code)] +#![allow(clippy::from_over_into)] struct Unitter; impl Unitter { diff --git a/src/tools/clippy/tests/ui/unused_unit.stderr b/src/tools/clippy/tests/ui/unused_unit.stderr index c45634c2b6d..02038b5fb6b 100644 --- a/src/tools/clippy/tests/ui/unused_unit.stderr +++ b/src/tools/clippy/tests/ui/unused_unit.stderr @@ -1,5 +1,5 @@ error: unneeded unit return type - --> $DIR/unused_unit.rs:18:28 + --> $DIR/unused_unit.rs:19:28 | LL | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` @@ -11,109 +11,109 @@ LL | #![deny(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ error: unneeded unit return type - --> $DIR/unused_unit.rs:19:18 + --> $DIR/unused_unit.rs:20:18 | LL | where G: Fn() -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:18:58 + --> $DIR/unused_unit.rs:19:58 | LL | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:20:26 + --> $DIR/unused_unit.rs:21:26 | LL | let _y: &dyn Fn() -> () = &f; | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:27:18 + --> $DIR/unused_unit.rs:28:18 | LL | fn into(self) -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:28:9 + --> $DIR/unused_unit.rs:29:9 | LL | () | ^^ help: remove the final `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:33:29 + --> $DIR/unused_unit.rs:34:29 | LL | fn redundant<F: FnOnce() -> (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:35:19 + --> $DIR/unused_unit.rs:36:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:36:16 + --> $DIR/unused_unit.rs:37:16 | LL | H: Fn() -> (); | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:40:29 + --> $DIR/unused_unit.rs:41:29 | LL | fn redundant<F: FnOnce() -> (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:42:19 + --> $DIR/unused_unit.rs:43:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:43:16 + --> $DIR/unused_unit.rs:44:16 | LL | H: Fn() -> () {} | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:46:17 + --> $DIR/unused_unit.rs:47:17 | LL | fn return_unit() -> () { () } | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:46:26 + --> $DIR/unused_unit.rs:47:26 | LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` error: unneeded `()` - --> $DIR/unused_unit.rs:56:14 + --> $DIR/unused_unit.rs:57:14 | LL | break(); | ^^ help: remove the `()` error: unneeded `()` - --> $DIR/unused_unit.rs:58:11 + --> $DIR/unused_unit.rs:59:11 | LL | return(); | ^^ help: remove the `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:75:10 + --> $DIR/unused_unit.rs:76:10 | LL | fn test()->(){} | ^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:78:11 + --> $DIR/unused_unit.rs:79:11 | LL | fn test2() ->(){} | ^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:81:11 + --> $DIR/unused_unit.rs:82:11 | LL | fn test3()-> (){} | ^^^^^ help: remove the `-> ()` diff --git a/src/tools/clippy/tests/versioncheck.rs b/src/tools/clippy/tests/versioncheck.rs index f5d03c645df..76b6126c76c 100644 --- a/src/tools/clippy/tests/versioncheck.rs +++ b/src/tools/clippy/tests/versioncheck.rs @@ -1,3 +1,6 @@ +#![allow(clippy::single_match_else)] +use rustc_tools_util::VersionInfo; + #[test] fn check_that_clippy_lints_has_the_same_version_as_clippy() { let clippy_meta = cargo_metadata::MetadataCommand::new() @@ -17,3 +20,54 @@ fn check_that_clippy_lints_has_the_same_version_as_clippy() { } } } + +#[test] +fn check_that_clippy_has_the_same_major_version_as_rustc() { + let clippy_version = rustc_tools_util::get_version_info!(); + let clippy_major = clippy_version.major; + let clippy_minor = clippy_version.minor; + let clippy_patch = clippy_version.patch; + + // get the rustc version either from the rustc installed with the toolchain file or from + // `RUSTC_REAL` if Clippy is build in the Rust repo with `./x.py`. + let rustc = std::env::var("RUSTC_REAL").unwrap_or_else(|_| "rustc".to_string()); + let rustc_version = String::from_utf8( + std::process::Command::new(&rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`") + .stdout, + ) + .unwrap(); + // extract "1 XX 0" from "rustc 1.XX.0-nightly (<commit> <date>)" + let vsplit: Vec<&str> = rustc_version + .split(' ') + .nth(1) + .unwrap() + .split('-') + .next() + .unwrap() + .split('.') + .collect(); + match vsplit.as_slice() { + [rustc_major, rustc_minor, _rustc_patch] => { + // clippy 0.1.XX should correspond to rustc 1.XX.0 + assert_eq!(clippy_major, 0); // this will probably stay the same for a long time + assert_eq!( + clippy_minor.to_string(), + *rustc_major, + "clippy minor version does not equal rustc major version" + ); + assert_eq!( + clippy_patch.to_string(), + *rustc_minor, + "clippy patch version does not equal rustc minor version" + ); + // do not check rustc_patch because when a stable-patch-release is made (like 1.50.2), + // we don't want our tests failing suddenly + }, + _ => { + panic!("Failed to parse rustc version: {:?}", vsplit); + }, + }; +} diff --git a/src/tools/clippy/util/gh-pages/index.html b/src/tools/clippy/util/gh-pages/index.html index 428708136cb..1852fb6640e 100644 --- a/src/tools/clippy/util/gh-pages/index.html +++ b/src/tools/clippy/util/gh-pages/index.html @@ -77,7 +77,7 @@ <div class="col-md-12 form-horizontal"> <div class="input-group"> <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label> - <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" /> + <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/> <span class="input-group-btn"> <button class="btn btn-default" type="button" ng-click="search = ''"> Clear @@ -119,6 +119,7 @@ {{title}} </h4> <div class="list-group-item-text" ng-bind-html="text | markdown"></div> + <a ng-if="title == 'Known problems'" href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+{{lint.id}}">Search on GitHub</a> </li> </ul> </article> @@ -180,6 +181,22 @@ } } + function searchLint(lint, term) { + for (const field in lint.docs) { + // Continue if it's not a property + if (!lint.docs.hasOwnProperty(field)) { + continue; + } + + // Return if not found + if (lint.docs[field].toLowerCase().indexOf(term) !== -1) { + return true; + } + } + + return false; + } + angular.module("clippy", []) .filter('markdown', function ($sce) { return function (text) { @@ -216,40 +233,31 @@ }; $scope.bySearch = function (lint, index, array) { - let search_str = $scope.search; + let searchStr = $scope.search; // It can be `null` I haven't missed this value - if (search_str == null || search_str.length == 0) { + if (searchStr == null || searchStr.length < 3) { return true; } - search_str = search_str.toLowerCase(); + searchStr = searchStr.toLowerCase(); // Search by id - let id_search = search_str.trim().replace(/(\-| )/g, "_"); - if (lint.id.includes(id_search)) { + if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) { return true; } // Search the description // The use of `for`-loops instead of `foreach` enables us to return early - let search_lint = (lint, therm) => { - for (const field in lint.docs) { - // Continue if it's not a property - if (!lint.docs.hasOwnProperty(field)) { - continue; - } - - // Return if not found - if (lint.docs[field].toLowerCase().includes(therm)) { - return true; - } + let terms = searchStr.split(" "); + for (index = 0; index < terms.length; index++) { + if (lint.id.indexOf(terms[index]) !== -1) { + continue; } - return false; - }; - let therms = search_str.split(" "); - for (index = 0; index < therms.length; index++) { - if (!search_lint(lint, therms[index])) { - return false; + + if (searchLint(lint, terms[index])) { + continue; } + + return false; } return true; diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 80fbb06b946..43dbaeb4655 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -10,8 +10,6 @@ use test::ColorConfig; #[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { - CompileFail, - RunFail, RunPassValgrind, Pretty, DebugInfo, @@ -42,8 +40,6 @@ impl FromStr for Mode { type Err = (); fn from_str(s: &str) -> Result<Mode, ()> { match s { - "compile-fail" => Ok(CompileFail), - "run-fail" => Ok(RunFail), "run-pass-valgrind" => Ok(RunPassValgrind), "pretty" => Ok(Pretty), "debuginfo" => Ok(DebugInfo), @@ -65,8 +61,6 @@ impl FromStr for Mode { impl fmt::Display for Mode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = match *self { - CompileFail => "compile-fail", - RunFail => "run-fail", RunPassValgrind => "run-pass-valgrind", Pretty => "pretty", DebugInfo => "debuginfo", @@ -230,7 +224,7 @@ pub struct Config { /// The name of the stage being built (stage1, etc) pub stage_id: String, - /// The test mode, compile-fail, run-fail, ui + /// The test mode, e.g. ui or debuginfo. pub mode: Mode, /// The test suite (essentially which directory is running, but without the diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index a1be0a19f68..2eba91fd1f4 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -542,10 +542,7 @@ impl TestProps { } if self.failure_status == -1 { - self.failure_status = match config.mode { - Mode::RunFail => 101, - _ => 1, - }; + self.failure_status = 1; } if self.should_ice { self.failure_status = 101; diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index c63bbaf70d3..aefcfe222e5 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -71,7 +71,7 @@ pub fn parse_config(args: Vec<String>) -> Config { "", "mode", "which sort of compile tests to run", - "compile-fail | run-fail | run-pass-valgrind | pretty | debug-info | codegen | rustdoc \ + "run-pass-valgrind | pretty | debug-info | codegen | rustdoc \ | rustdoc-json | codegen-units | incremental | run-make | ui | js-doc-test | mir-opt | assembly", ) .reqopt( diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 828c4e89f0b..9f31b3ae1b1 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -5,8 +5,8 @@ use crate::common::{output_base_dir, output_base_name, output_testname_unique}; use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui}; use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc}; use crate::common::{CompareMode, FailMode, PassMode}; -use crate::common::{CompileFail, Pretty, RunFail, RunPassValgrind}; use crate::common::{Config, TestPaths}; +use crate::common::{Pretty, RunPassValgrind}; use crate::common::{UI_RUN_STDERR, UI_RUN_STDOUT}; use crate::errors::{self, Error, ErrorKind}; use crate::header::TestProps; @@ -330,13 +330,11 @@ impl<'test> TestCx<'test> { /// revisions, exactly once, with revision == None). fn run_revision(&self) { if self.props.should_ice { - if self.config.mode != CompileFail && self.config.mode != Incremental { + if self.config.mode != Incremental { self.fatal("cannot use should-ice in a test that is not cfail"); } } match self.config.mode { - CompileFail => self.run_cfail_test(), - RunFail => self.run_rfail_test(), RunPassValgrind => self.run_valgrind_test(), Pretty => self.run_pretty_test(), DebugInfo => self.run_debuginfo_test(), @@ -377,7 +375,6 @@ impl<'test> TestCx<'test> { fn should_compile_successfully(&self, pm: Option<PassMode>) -> bool { match self.config.mode { - CompileFail => false, JsDocTest => true, Ui => pm.is_some() || self.props.fail_mode > Some(FailMode::Build), Incremental => { @@ -1537,8 +1534,8 @@ impl<'test> TestCx<'test> { }; let allow_unused = match self.config.mode { - CompileFail | Ui => { - // compile-fail and ui tests tend to have tons of unused code as + Ui => { + // UI tests tend to have tons of unused code as // it's just testing various pieces of the compile, but we don't // want to actually assert warnings about all this code. Instead // let's just ignore unused code warnings by defaults and tests @@ -1940,7 +1937,7 @@ impl<'test> TestCx<'test> { } match self.config.mode { - CompileFail | Incremental => { + Incremental => { // If we are extracting and matching errors in the new // fashion, then you want JSON mode. Old-skool error // patterns still match the raw compiler output. @@ -1975,8 +1972,8 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } - RunFail | RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson - | RunMake | CodegenUnits | JsDocTest | Assembly => { + RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake + | CodegenUnits | JsDocTest | Assembly => { // do not use JSON output } } diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 4f77e719fba..1647df8044c 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -82,6 +82,7 @@ const ARCH_TABLE: &[(&str, &str)] = &[ ]; pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ + "aarch64-apple-darwin", "aarch64-fuchsia", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", @@ -90,13 +91,18 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ "x86_64-unknown-linux-gnu", ]; -pub const LSAN_SUPPORTED_TARGETS: &[&str] = - &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; +pub const LSAN_SUPPORTED_TARGETS: &[&str] = &[ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", +]; pub const MSAN_SUPPORTED_TARGETS: &[&str] = &["aarch64-unknown-linux-gnu", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"]; pub const TSAN_SUPPORTED_TARGETS: &[&str] = &[ + "aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-freebsd", diff --git a/src/tools/lint-docs/src/groups.rs b/src/tools/lint-docs/src/groups.rs index 0a69b18a332..e8fd19a6381 100644 --- a/src/tools/lint-docs/src/groups.rs +++ b/src/tools/lint-docs/src/groups.rs @@ -116,13 +116,23 @@ impl<'a> LintExtractor<'a> { result.push('\n'); result.push_str("[warn-by-default]: listing/warn-by-default.md\n"); for lint_name in to_link { - let lint_def = - lints.iter().find(|l| l.name == lint_name.replace("-", "_")).ok_or_else(|| { - format!( - "`rustc -W help` defined lint `{}` but that lint does not appear to exist", + let lint_def = match lints.iter().find(|l| l.name == lint_name.replace("-", "_")) { + Some(def) => def, + None => { + let msg = format!( + "`rustc -W help` defined lint `{}` but that lint does not \ + appear to exist\n\ + Check that the lint definition includes the appropriate doc comments.", lint_name - ) - })?; + ); + if self.validate { + return Err(msg.into()); + } else { + eprintln!("warning: {}", msg); + continue; + } + } + }; write!( result, "[{}]: listing/{}#{}\n", diff --git a/src/tools/miri b/src/tools/miri -Subproject 2065b52dfef3cd5a5216e65c21a056a69574bdd +Subproject a09f8b0c06c6bb051bd1e104c6be56fbe51f3d8 diff --git a/src/tools/rust-installer b/src/tools/rust-installer -Subproject d66f476b4d5e7fdf1ec215c9ac16c923dc29232 +Subproject 5254dbfd25d5284728ab624dca1969d61427a0d diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 99310157a64..8e17f291908 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -10,6 +10,6 @@ clap = "2.25.0" env_logger = "0.7.1" [dependencies.mdbook] -version = "0.4.3" +version = "0.4.5" default-features = false features = ["search"] diff --git a/src/tools/rustc-workspace-hack/Cargo.toml b/src/tools/rustc-workspace-hack/Cargo.toml index 11b175f9e80..1cde0e25ced 100644 --- a/src/tools/rustc-workspace-hack/Cargo.toml +++ b/src/tools/rustc-workspace-hack/Cargo.toml @@ -65,6 +65,8 @@ byteorder = { version = "1", features = ['default', 'std'] } curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true } crossbeam-utils = { version = "0.7.2", features = ["nightly"] } libc = { version = "0.2.79", features = ["align"] } +# Ensure default features of libz-sys, which are disabled in some scenarios. +libz-sys = { version = "1.1.2" } proc-macro2 = { version = "1", features = ["default"] } quote = { version = "1", features = ["default"] } serde = { version = "1.0.82", features = ['derive'] } diff --git a/src/tools/rustfmt b/src/tools/rustfmt -Subproject 70ce18255f429caf0d75ecfed8c1464535ee779 +Subproject acd94866fd0ff5eacb7e184ae21c19e5440fc5f diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index d78af2cd616..384a291a777 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -85,11 +85,7 @@ pub fn check( assert!(!lib_features.is_empty()); super::walk_many( - &[ - &src_path.join("test/ui"), - &src_path.join("test/ui-fulldeps"), - &src_path.join("test/compile-fail"), - ], + &[&src_path.join("test/ui"), &src_path.join("test/ui-fulldeps")], &mut |path| super::filter_dirs(path), &mut |entry, contents| { let file = entry.path(); diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index d8d2b449fee..bc5e43d8f0a 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,7 +7,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 1580; +const ROOT_ENTRY_LIMIT: usize = 1500; const ISSUES_ENTRY_LIMIT: usize = 2830; fn check_entries(path: &Path, bad: &mut bool) { diff --git a/src/tools/x/README.md b/src/tools/x/README.md index 3b3cf2847c2..80bf02e8a0e 100644 --- a/src/tools/x/README.md +++ b/src/tools/x/README.md @@ -1,3 +1,10 @@ # x `x` invokes `x.py` from any subdirectory. + +To install, run the following commands: + +``` +$ cd rust/src/tools/x/ +$ cargo install --path . +``` diff --git a/src/version b/src/version index 5a5c7211dc6..ba0a719118c 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.50.0 +1.51.0 |
