diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f6060ac14e75e..a8161c9bfb859 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -16,6 +16,7 @@ use build_helper::{output, t}; use crate::cache::{Cache, Interned, INTERNER}; use crate::check; use crate::compile; +use crate::config::TargetSelection; use crate::dist; use crate::doc; use crate::flags::Subcommand; @@ -86,8 +87,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { pub struct RunConfig<'a> { pub builder: &'a Builder<'a>, - pub host: Interned, - pub target: Interned, + pub host: TargetSelection, + pub target: TargetSelection, pub path: PathBuf, } @@ -576,7 +577,7 @@ impl<'a> Builder<'a> { /// not take `Compiler` since all `Compiler` instances are meant to be /// obtained through this function, since it ensures that they are valid /// (i.e., built and assembled). - pub fn compiler(&self, stage: u32, host: Interned) -> Compiler { + pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler { self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } }) } @@ -594,8 +595,8 @@ impl<'a> Builder<'a> { pub fn compiler_for( &self, stage: u32, - host: Interned, - target: Interned, + host: TargetSelection, + target: TargetSelection, ) -> Compiler { if self.build.force_use_stage1(Compiler { stage, host }, target) { self.compiler(1, self.config.build) @@ -610,15 +611,11 @@ impl<'a> Builder<'a> { /// Returns the libdir where the standard library and other artifacts are /// found for a compiler's sysroot. - pub fn sysroot_libdir( - &self, - compiler: Compiler, - target: Interned, - ) -> Interned { + pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> Interned { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] struct Libdir { compiler: Compiler, - target: Interned, + target: TargetSelection, } impl Step for Libdir { type Output = Interned; @@ -633,7 +630,7 @@ impl<'a> Builder<'a> { .sysroot(self.compiler) .join(lib) .join("rustlib") - .join(self.target) + .join(self.target.triple) .join("lib"); let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); @@ -656,7 +653,7 @@ impl<'a> Builder<'a> { Some(relative_libdir) if compiler.stage >= 1 => { self.sysroot(compiler).join(relative_libdir) } - _ => self.sysroot(compiler).join(libdir(&compiler.host)), + _ => self.sysroot(compiler).join(libdir(compiler.host)), } } } @@ -668,11 +665,11 @@ impl<'a> Builder<'a> { /// Windows. pub fn libdir_relative(&self, compiler: Compiler) -> &Path { if compiler.is_snapshot(self) { - libdir(&self.config.build).as_ref() + libdir(self.config.build).as_ref() } else { match self.config.libdir_relative() { Some(relative_libdir) if compiler.stage >= 1 => relative_libdir, - _ => libdir(&compiler.host).as_ref(), + _ => libdir(compiler.host).as_ref(), } } } @@ -707,7 +704,7 @@ impl<'a> Builder<'a> { if compiler.is_snapshot(self) { self.initial_rustc.clone() } else { - self.sysroot(compiler).join("bin").join(exe("rustc", &compiler.host)) + self.sysroot(compiler).join("bin").join(exe("rustc", compiler.host)) } } @@ -725,7 +722,11 @@ impl<'a> Builder<'a> { .env("CFG_RELEASE_CHANNEL", &self.config.channel) .env("RUSTDOC_REAL", self.rustdoc(compiler)) .env("RUSTDOC_CRATE_VERSION", self.rust_version()) - .env("RUSTC_BOOTSTRAP", "1"); + .env("RUSTC_BOOTSTRAP", "1") + .arg("-Winvalid_codeblock_attributes"); + if self.config.deny_warnings { + cmd.arg("-Dwarnings"); + } // Remove make-related flags that can cause jobserver problems. cmd.env_remove("MAKEFLAGS"); @@ -741,7 +742,7 @@ impl<'a> Builder<'a> { /// /// Note that this returns `None` if LLVM is disabled, or if we're in a /// check build or dry-run, where there's no need to build all of LLVM. - fn llvm_config(&self, target: Interned) -> Option { + fn llvm_config(&self, target: TargetSelection) -> Option { if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run { let llvm_config = self.ensure(native::Llvm { target }); if llvm_config.is_file() { @@ -763,7 +764,7 @@ impl<'a> Builder<'a> { compiler: Compiler, mode: Mode, source_type: SourceType, - target: Interned, + target: TargetSelection, cmd: &str, ) -> Cargo { let mut cargo = Command::new(&self.initial_cargo); @@ -773,7 +774,7 @@ impl<'a> Builder<'a> { let my_out = match mode { // This is the intended out directory for compiler documentation. Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target), - Mode::Std => out_dir.join(target).join("doc"), + Mode::Std => out_dir.join(target.triple).join("doc"), _ => panic!("doc mode {:?} not expected", mode), }; let rustdoc = self.rustdoc(compiler); @@ -795,7 +796,7 @@ impl<'a> Builder<'a> { } if cmd != "install" { - cargo.arg("--target").arg(target); + cargo.arg("--target").arg(target.rustc_target_arg()); } else { assert_eq!(target, compiler.host); } @@ -821,7 +822,7 @@ impl<'a> Builder<'a> { compiler.stage }; - let mut rustflags = Rustflags::new(&target); + let mut rustflags = Rustflags::new(target); if stage != 0 { if let Ok(s) = env::var("CARGOFLAGS_NOT_BOOTSTRAP") { cargo.args(s.split_whitespace()); @@ -838,7 +839,7 @@ impl<'a> Builder<'a> { // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`, // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See // #71458. - let rustdocflags = rustflags.clone(); + let mut rustdocflags = rustflags.clone(); if let Ok(s) = env::var("CARGOFLAGS") { cargo.args(s.split_whitespace()); @@ -994,7 +995,7 @@ impl<'a> Builder<'a> { // argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it // fun to pass a flag to a tool to pass a flag to pass a flag to a tool // to change a flag in a binary? - if self.config.rust_rpath && util::use_host_linker(&target) { + if self.config.rust_rpath && util::use_host_linker(target) { let rpath = if target.contains("apple") { // Note that we need to take one extra step on macOS to also pass // `-Wl,-instal_name,@rpath/...` to get things to work right. To @@ -1022,7 +1023,7 @@ impl<'a> Builder<'a> { } if let Some(target_linker) = self.linker(target, can_use_lld) { - let target = crate::envify(&target); + let target = crate::envify(&target.triple); cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker); } if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc { @@ -1140,6 +1141,7 @@ impl<'a> Builder<'a> { if self.config.deny_warnings { lint_flags.push("-Dwarnings"); + rustdocflags.arg("-Dwarnings"); } // FIXME(#58633) hide "unused attribute" errors in incremental @@ -1157,6 +1159,8 @@ impl<'a> Builder<'a> { // are always ignored in dependencies. Eventually this should be // fixed via better support from Cargo. cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" ")); + + rustdocflags.arg("-Winvalid_codeblock_attributes"); } if let Mode::Rustc | Mode::Codegen = mode { @@ -1193,21 +1197,23 @@ impl<'a> Builder<'a> { } }; let cc = ccacheify(&self.cc(target)); - cargo.env(format!("CC_{}", target), &cc); + cargo.env(format!("CC_{}", target.triple), &cc); let cflags = self.cflags(target, GitRepo::Rustc).join(" "); - cargo.env(format!("CFLAGS_{}", target), cflags.clone()); + cargo.env(format!("CFLAGS_{}", target.triple), cflags.clone()); if let Some(ar) = self.ar(target) { let ranlib = format!("{} s", ar.display()); - cargo.env(format!("AR_{}", target), ar).env(format!("RANLIB_{}", target), ranlib); + cargo + .env(format!("AR_{}", target.triple), ar) + .env(format!("RANLIB_{}", target.triple), ranlib); } if let Ok(cxx) = self.cxx(target) { let cxx = ccacheify(&cxx); cargo - .env(format!("CXX_{}", target), &cxx) - .env(format!("CXXFLAGS_{}", target), cflags); + .env(format!("CXX_{}", target.triple), &cxx) + .env(format!("CXXFLAGS_{}", target.triple), cflags); } } @@ -1241,7 +1247,7 @@ impl<'a> Builder<'a> { // Environment variables *required* throughout the build // // FIXME: should update code to not require this env var - cargo.env("CFG_COMPILER_HOST_TRIPLE", target); + cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple); // Set this for all builds to make sure doc builds also get it. cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel); @@ -1397,7 +1403,7 @@ mod tests; struct Rustflags(String); impl Rustflags { - fn new(target: &str) -> Rustflags { + fn new(target: TargetSelection) -> Rustflags { let mut ret = Rustflags(String::new()); // Inherit `RUSTFLAGS` by default ... @@ -1405,7 +1411,7 @@ impl Rustflags { // ... and also handle target-specific env RUSTFLAGS if they're // configured. - let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(target)); + let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(&target.triple)); ret.env(&target_specific); ret diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index 1e75e67af0c9e..69a54bec33b67 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -1,5 +1,5 @@ use super::*; -use crate::config::Config; +use crate::config::{Config, TargetSelection}; use std::thread; use pretty_assertions::assert_eq; @@ -17,16 +17,16 @@ fn configure(host: &[&str], target: &[&str]) -> Config { .join(&thread::current().name().unwrap_or("unknown").replace(":", "-")); t!(fs::create_dir_all(&dir)); config.out = dir; - config.build = INTERNER.intern_str("A"); + config.build = TargetSelection::from_user("A"); config.hosts = vec![config.build] .into_iter() - .chain(host.iter().map(|s| INTERNER.intern_str(s))) + .chain(host.iter().map(|s| TargetSelection::from_user(s))) .collect::>(); config.targets = config .hosts .clone() .into_iter() - .chain(target.iter().map(|s| INTERNER.intern_str(s))) + .chain(target.iter().map(|s| TargetSelection::from_user(s))) .collect::>(); config } @@ -41,7 +41,7 @@ fn dist_baseline() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); + let a = TargetSelection::from_user("A"); assert_eq!(first(builder.cache.all::()), &[dist::Docs { host: a },]); assert_eq!(first(builder.cache.all::()), &[dist::Mingw { host: a },]); @@ -67,8 +67,8 @@ fn dist_with_targets() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); assert_eq!( first(builder.cache.all::()), @@ -98,8 +98,8 @@ fn dist_with_hosts() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); assert_eq!( first(builder.cache.all::()), @@ -128,8 +128,8 @@ fn dist_with_hosts() { #[test] fn dist_only_cross_host() { - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); let mut build = Build::new(configure(&["B"], &[])); build.config.docs = false; build.config.extended = true; @@ -156,9 +156,9 @@ fn dist_with_targets_and_hosts() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); - let c = INTERNER.intern_str("C"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); + let c = TargetSelection::from_user("C"); assert_eq!( first(builder.cache.all::()), @@ -194,9 +194,9 @@ fn dist_with_target_flag() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); - let c = INTERNER.intern_str("C"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); + let c = TargetSelection::from_user("C"); assert_eq!( first(builder.cache.all::()), @@ -224,8 +224,8 @@ fn dist_with_same_targets_and_hosts() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); assert_eq!( first(builder.cache.all::()), @@ -277,9 +277,9 @@ fn build_default() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); - let c = INTERNER.intern_str("C"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); + let c = TargetSelection::from_user("C"); assert_eq!( first(builder.cache.all::()), @@ -318,9 +318,9 @@ fn build_with_target_flag() { let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]); - let a = INTERNER.intern_str("A"); - let b = INTERNER.intern_str("B"); - let c = INTERNER.intern_str("C"); + let a = TargetSelection::from_user("A"); + let b = TargetSelection::from_user("B"); + let c = TargetSelection::from_user("C"); assert_eq!( first(builder.cache.all::()), @@ -374,7 +374,7 @@ fn test_with_no_doc_stage0() { let build = Build::new(config); let mut builder = Builder::new(&build); - let host = INTERNER.intern_str("A"); + let host = TargetSelection::from_user("A"); builder .run_step_descriptions(&[StepDescription::from::()], &["src/libstd".into()]); @@ -428,7 +428,7 @@ fn doc_default() { let build = Build::new(config); let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), &[]); - let a = INTERNER.intern_str("A"); + let a = TargetSelection::from_user("A"); // error_index_generator uses stage 1 to share rustdoc artifacts with the // rustdoc tool. @@ -466,7 +466,7 @@ fn test_docs() { let build = Build::new(config); let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]); - let a = INTERNER.intern_str("A"); + let a = TargetSelection::from_user("A"); // error_index_generator uses stage 1 to share rustdoc artifacts with the // rustdoc tool. diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs index ab16ca3732c1f..7ff00d85dd2f2 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs @@ -28,16 +28,15 @@ use std::{env, iter}; use build_helper::output; -use crate::cache::Interned; -use crate::config::Target; +use crate::config::{Target, TargetSelection}; use crate::{Build, GitRepo}; // The `cc` crate doesn't provide a way to obtain a path to the detected archiver, // so use some simplified logic here. First we respect the environment variable `AR`, then // try to infer the archiver path from the C compiler path. // In the future this logic should be replaced by calling into the `cc` crate. -fn cc2ar(cc: &Path, target: &str) -> Option { - if let Some(ar) = env::var_os(format!("AR_{}", target.replace("-", "_"))) { +fn cc2ar(cc: &Path, target: TargetSelection) -> Option { + if let Some(ar) = env::var_os(format!("AR_{}", target.triple.replace("-", "_"))) { Some(PathBuf::from(ar)) } else if let Some(ar) = env::var_os("AR") { Some(PathBuf::from(ar)) @@ -79,8 +78,8 @@ pub fn find(build: &mut Build) { .opt_level(2) .warnings(false) .debug(false) - .target(&target) - .host(&build.build); + .target(&target.triple) + .host(&build.build.triple); match build.crt_static(target) { Some(a) => { cfg.static_crt(a); @@ -106,10 +105,10 @@ pub fn find(build: &mut Build) { let ar = if let ar @ Some(..) = config.and_then(|c| c.ar.clone()) { ar } else { - cc2ar(compiler.path(), &target) + cc2ar(compiler.path(), target) }; - build.cc.insert(target, compiler); + build.cc.insert(target, compiler.clone()); let cflags = build.cflags(target, GitRepo::Rustc); // If we use llvm-libunwind, we will need a C++ compiler as well for all targets @@ -120,8 +119,8 @@ pub fn find(build: &mut Build) { .warnings(false) .debug(false) .cpp(true) - .target(&target) - .host(&build.build); + .target(&target.triple) + .host(&build.build.triple); let cxx_configured = if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) { cfg.compiler(cxx); @@ -138,14 +137,14 @@ pub fn find(build: &mut Build) { build.cxx.insert(target, compiler); } - build.verbose(&format!("CC_{} = {:?}", &target, build.cc(target))); - build.verbose(&format!("CFLAGS_{} = {:?}", &target, cflags)); + build.verbose(&format!("CC_{} = {:?}", &target.triple, build.cc(target))); + build.verbose(&format!("CFLAGS_{} = {:?}", &target.triple, cflags)); if let Ok(cxx) = build.cxx(target) { - build.verbose(&format!("CXX_{} = {:?}", &target, cxx)); - build.verbose(&format!("CXXFLAGS_{} = {:?}", &target, cflags)); + build.verbose(&format!("CXX_{} = {:?}", &target.triple, cxx)); + build.verbose(&format!("CXXFLAGS_{} = {:?}", &target.triple, cflags)); } if let Some(ar) = ar { - build.verbose(&format!("AR_{} = {:?}", &target, ar)); + build.verbose(&format!("AR_{} = {:?}", &target.triple, ar)); build.ar.insert(target, ar); } } @@ -154,17 +153,18 @@ pub fn find(build: &mut Build) { fn set_compiler( cfg: &mut cc::Build, compiler: Language, - target: Interned, + target: TargetSelection, config: Option<&Target>, build: &Build, ) { - match &*target { + match &*target.triple { // When compiling for android we may have the NDK configured in the // config.toml in which case we look there. Otherwise the default // compiler already takes into account the triple in question. t if t.contains("android") => { if let Some(ndk) = config.and_then(|c| c.ndk.as_ref()) { let target = target + .triple .replace("armv7neon", "arm") .replace("armv7", "arm") .replace("thumbv7neon", "arm") diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 0d38d2eebe793..9f34bb4e6ccd7 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -1,15 +1,15 @@ //! Implementation of compiling the compiler and standard library, in "check"-based modes. use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; -use crate::cache::Interned; use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, std_cargo}; +use crate::config::TargetSelection; use crate::tool::{prepare_tool_cargo, SourceType}; use crate::{Compiler, Mode}; use std::path::PathBuf; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Std { - pub target: Interned, + pub target: TargetSelection, } fn args(kind: Kind) -> Vec { @@ -71,7 +71,7 @@ impl Step for Std { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rustc { - pub target: Interned, + pub target: TargetSelection, } impl Step for Rustc { @@ -127,7 +127,7 @@ macro_rules! tool_check_step { ($name:ident, $path:expr, $source_type:expr) => { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct $name { - pub target: Interned, + pub target: TargetSelection, } impl Step for $name { @@ -163,8 +163,8 @@ macro_rules! tool_check_step { println!( "Checking {} artifacts ({} -> {})", stringify!($name).to_lowercase(), - &compiler.host, - target + &compiler.host.triple, + target.triple ); run_cargo( builder, @@ -184,7 +184,7 @@ macro_rules! tool_check_step { fn stamp( builder: &Builder<'_>, compiler: Compiler, - target: Interned, + target: TargetSelection, ) -> PathBuf { builder .cargo_out(compiler, Mode::ToolRustc, target) @@ -204,12 +204,12 @@ tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree); /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned) -> PathBuf { +fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf { builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp") } /// Cargo's output path for librustc in a given stage, compiled by a particular /// compiler for the specified target. -fn librustc_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned) -> PathBuf { +fn librustc_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf { builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp") } diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs index b4e58c06fdea9..f83dfe8e635e3 100644 --- a/src/bootstrap/clean.rs +++ b/src/bootstrap/clean.rs @@ -23,7 +23,7 @@ pub fn clean(build: &Build, all: bool) { rm_rf(&build.out.join("dist")); for host in &build.hosts { - let entries = match build.out.join(host).read_dir() { + let entries = match build.out.join(host.triple).read_dir() { Ok(iter) => iter, Err(_) => continue, }; diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 68a3f369d16eb..89b070e15e286 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -22,6 +22,7 @@ use serde::Deserialize; use crate::builder::Cargo; use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; use crate::cache::{Interned, INTERNER}; +use crate::config::TargetSelection; use crate::dist; use crate::native; use crate::tool::SourceType; @@ -30,7 +31,7 @@ use crate::{Compiler, DependencyType, GitRepo, Mode}; #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)] pub struct Std { - pub target: Interned, + pub target: TargetSelection, pub compiler: Compiler, } @@ -129,7 +130,7 @@ fn copy_and_stamp( fn copy_third_party_objects( builder: &Builder<'_>, compiler: &Compiler, - target: Interned, + target: TargetSelection, ) -> Vec<(PathBuf, DependencyType)> { let mut target_deps = vec![]; @@ -157,7 +158,7 @@ fn copy_third_party_objects( fn copy_self_contained_objects( builder: &Builder<'_>, compiler: &Compiler, - target: Interned, + target: TargetSelection, ) -> Vec<(PathBuf, DependencyType)> { let libdir_self_contained = builder.sysroot_libdir(*compiler, target).join("self-contained"); t!(fs::create_dir_all(&libdir_self_contained)); @@ -206,7 +207,7 @@ fn copy_self_contained_objects( /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. -pub fn std_cargo(builder: &Builder<'_>, target: Interned, stage: u32, cargo: &mut Cargo) { +pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, cargo: &mut Cargo) { if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") { cargo.env("MACOSX_DEPLOYMENT_TARGET", target); } @@ -301,7 +302,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: Interned, stage: u32, ca struct StdLink { pub compiler: Compiler, pub target_compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for StdLink { @@ -337,7 +338,7 @@ impl Step for StdLink { fn copy_sanitizers( builder: &Builder<'_>, compiler: &Compiler, - target: Interned, + target: TargetSelection, ) -> Vec { let runtimes: Vec = builder.ensure(native::Sanitizers { target }); @@ -372,7 +373,7 @@ fn copy_sanitizers( #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct StartupObjects { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for StartupObjects { @@ -419,7 +420,7 @@ impl Step for StartupObjects { .arg("--cfg") .arg("bootstrap") .arg("--target") - .arg(target) + .arg(target.rustc_target_arg()) .arg("--emit=obj") .arg("-o") .arg(dst_file) @@ -438,7 +439,7 @@ impl Step for StartupObjects { #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rustc { - pub target: Interned, + pub target: TargetSelection, pub compiler: Compiler, } @@ -518,7 +519,7 @@ impl Step for Rustc { } } -pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: Interned) { +pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) { cargo .arg("--features") .arg(builder.rustc_features()) @@ -527,7 +528,7 @@ pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: Interned, cargo: &mut Cargo, target: Interned) { +pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) { // Set some configuration variables picked up by build scripts and // the compiler alike cargo @@ -608,7 +609,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne struct RustcLink { pub compiler: Compiler, pub target_compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for RustcLink { @@ -638,11 +639,7 @@ impl Step for RustcLink { /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -pub fn libstd_stamp( - builder: &Builder<'_>, - compiler: Compiler, - target: Interned, -) -> PathBuf { +pub fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf { builder.cargo_out(compiler, Mode::Std, target).join(".libstd.stamp") } @@ -651,7 +648,7 @@ pub fn libstd_stamp( pub fn librustc_stamp( builder: &Builder<'_>, compiler: Compiler, - target: Interned, + target: TargetSelection, ) -> PathBuf { builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc.stamp") } @@ -659,7 +656,7 @@ pub fn librustc_stamp( pub fn compiler_file( builder: &Builder<'_>, compiler: &Path, - target: Interned, + target: TargetSelection, file: &str, ) -> PathBuf { let mut cmd = Command::new(compiler); @@ -690,9 +687,9 @@ impl Step for Sysroot { fn run(self, builder: &Builder<'_>) -> Interned { let compiler = self.compiler; let sysroot = if compiler.stage == 0 { - builder.out.join(&compiler.host).join("stage0-sysroot") + builder.out.join(&compiler.host.triple).join("stage0-sysroot") } else { - builder.out.join(&compiler.host).join(format!("stage{}", compiler.stage)) + builder.out.join(&compiler.host.triple).join(format!("stage{}", compiler.stage)) }; let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); @@ -806,8 +803,8 @@ impl Step for Assemble { let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host); if let Some(lld_install) = lld_install { - let src_exe = exe("lld", &target_compiler.host); - let dst_exe = exe("rust-lld", &target_compiler.host); + let src_exe = exe("lld", target_compiler.host); + let dst_exe = exe("rust-lld", target_compiler.host); // we prepend this bin directory to the user PATH when linking Rust binaries. To // avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`. let dst = libdir.parent().unwrap().join("bin"); @@ -822,7 +819,7 @@ impl Step for Assemble { // Link the compiler binary itself into place let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host); - let rustc = out_dir.join(exe("rustc_binary", &*host)); + let rustc = out_dir.join(exe("rustc_binary", host)); let bindir = sysroot.join("bin"); t!(fs::create_dir_all(&bindir)); let compiler = builder.rustc(target_compiler); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index ff545a6ddcf47..d71f31704209e 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -7,6 +7,7 @@ use std::cmp; use std::collections::{HashMap, HashSet}; use std::env; use std::ffi::OsString; +use std::fmt; use std::fs; use std::path::{Path, PathBuf}; use std::process; @@ -39,7 +40,7 @@ pub struct Config { pub docs: bool, pub locked_deps: bool, pub vendor: bool, - pub target_config: HashMap, Target>, + pub target_config: HashMap, pub full_bootstrap: bool, pub extended: bool, pub tools: Option>, @@ -112,9 +113,9 @@ pub struct Config { pub rust_thin_lto_import_instr_limit: Option, pub rust_remap_debuginfo: bool, - pub build: Interned, - pub hosts: Vec>, - pub targets: Vec>, + pub build: TargetSelection, + pub hosts: Vec, + pub targets: Vec, pub local_rebuild: bool, pub jemalloc: bool, pub control_flow_guard: bool, @@ -158,6 +159,67 @@ pub struct Config { pub out: PathBuf, } +#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct TargetSelection { + pub triple: Interned, + file: Option>, +} + +impl TargetSelection { + pub fn from_user(selection: &str) -> Self { + let path = Path::new(selection); + + let (triple, file) = if path.exists() { + let triple = path + .file_stem() + .expect("Target specification file has no file stem") + .to_str() + .expect("Target specification file stem is not UTF-8"); + + (triple, Some(selection)) + } else { + (selection, None) + }; + + let triple = INTERNER.intern_str(triple); + let file = file.map(|f| INTERNER.intern_str(f)); + + Self { triple, file } + } + + pub fn rustc_target_arg(&self) -> &str { + self.file.as_ref().unwrap_or(&self.triple) + } + + pub fn contains(&self, needle: &str) -> bool { + self.triple.contains(needle) + } + + pub fn starts_with(&self, needle: &str) -> bool { + self.triple.starts_with(needle) + } + + pub fn ends_with(&self, needle: &str) -> bool { + self.triple.ends_with(needle) + } +} + +impl fmt::Display for TargetSelection { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.triple)?; + if let Some(file) = self.file { + write!(f, "({})", file)?; + } + Ok(()) + } +} + +impl PartialEq<&str> for TargetSelection { + fn eq(&self, other: &&str) -> bool { + self.triple == *other + } +} + /// Per-target configuration stored in the global configuration structure. #[derive(Default)] pub struct Target { @@ -403,7 +465,7 @@ impl Config { config.missing_tools = false; // set by bootstrap.py - config.build = INTERNER.intern_str(&env::var("BUILD").expect("'BUILD' to be set")); + config.build = TargetSelection::from_user(&env::var("BUILD").expect("'BUILD' to be set")); config.src = Config::path_from_python("SRC"); config.out = Config::path_from_python("BUILD_DIR"); @@ -464,14 +526,16 @@ impl Config { let build = toml.build.clone().unwrap_or_default(); // set by bootstrap.py config.hosts.push(config.build.clone()); - for host in build.host.iter() { - let host = INTERNER.intern_str(host); + for host in build.host.iter().map(|h| TargetSelection::from_user(h)) { if !config.hosts.contains(&host) { config.hosts.push(host); } } - for target in - config.hosts.iter().cloned().chain(build.target.iter().map(|s| INTERNER.intern_str(s))) + for target in config + .hosts + .iter() + .copied() + .chain(build.target.iter().map(|h| TargetSelection::from_user(h))) { if !config.targets.contains(&target) { config.targets.push(target); @@ -637,7 +701,7 @@ impl Config { target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from); target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from); - config.target_config.insert(INTERNER.intern_string(triple.clone()), target); + config.target_config.insert(TargetSelection::from_user(triple), target); } } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 5d2fcba7feaba..af30747a9592e 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -20,6 +20,7 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::cache::{Interned, INTERNER}; use crate::channel; use crate::compile; +use crate::config::TargetSelection; use crate::tool::{self, Tool}; use crate::util::{exe, is_dylib, timeit}; use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; @@ -68,7 +69,7 @@ fn missing_tool(tool_name: &str, skip: bool) { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Docs { - pub host: Interned, + pub host: TargetSelection, } impl Step for Docs { @@ -131,7 +132,7 @@ impl Step for Docs { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustcDocs { - pub host: Interned, + pub host: TargetSelection, } impl Step for RustcDocs { @@ -210,11 +211,11 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec { fn make_win_dist( rust_root: &Path, plat_root: &Path, - target_triple: Interned, + target: TargetSelection, builder: &Builder<'_>, ) { //Ask gcc where it keeps its stuff - let mut cmd = Command::new(builder.cc(target_triple)); + let mut cmd = Command::new(builder.cc(target)); cmd.arg("-print-search-dirs"); let gcc_out = output(&mut cmd); @@ -234,16 +235,16 @@ fn make_win_dist( } } - let compiler = if target_triple == "i686-pc-windows-gnu" { + let compiler = if target == "i686-pc-windows-gnu" { "i686-w64-mingw32-gcc.exe" - } else if target_triple == "x86_64-pc-windows-gnu" { + } else if target == "x86_64-pc-windows-gnu" { "x86_64-w64-mingw32-gcc.exe" } else { "gcc.exe" }; let target_tools = [compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"]; let mut rustc_dlls = vec!["libwinpthread-1.dll"]; - if target_triple.starts_with("i686-") { + if target.starts_with("i686-") { rustc_dlls.push("libgcc_s_dw2-1.dll"); } else { rustc_dlls.push("libgcc_s_seh-1.dll"); @@ -311,7 +312,7 @@ fn make_win_dist( let target_bin_dir = plat_root .join("lib") .join("rustlib") - .join(target_triple) + .join(target.triple) .join("bin") .join("self-contained"); fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed"); @@ -331,7 +332,7 @@ fn make_win_dist( let target_lib_dir = plat_root .join("lib") .join("rustlib") - .join(target_triple) + .join(target.triple) .join("lib") .join("self-contained"); fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed"); @@ -342,7 +343,7 @@ fn make_win_dist( #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Mingw { - pub host: Interned, + pub host: TargetSelection, } impl Step for Mingw { @@ -530,11 +531,11 @@ impl Step for Rustc { // Copy over lld if it's there if builder.config.lld_enabled { - let exe = exe("rust-lld", &compiler.host); + let exe = exe("rust-lld", compiler.host); let src = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin").join(&exe); // for the rationale about this rename check `compile::copy_lld_to_sysroot` - let dst = image.join("lib/rustlib").join(&*host).join("bin").join(&exe); + let dst = image.join("lib/rustlib").join(&*host.triple).join("bin").join(&exe); t!(fs::create_dir_all(&dst.parent().unwrap())); builder.copy(&src, &dst); } @@ -592,7 +593,7 @@ impl Step for Rustc { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct DebuggerScripts { pub sysroot: Interned, - pub host: Interned, + pub host: TargetSelection, } impl Step for DebuggerScripts { @@ -662,8 +663,8 @@ fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool { } /// Copy stamped files into an image's `target/lib` directory. -fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &Path) { - let dst = image.join("lib/rustlib").join(target).join("lib"); +fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path, stamp: &Path) { + let dst = image.join("lib/rustlib").join(target.triple).join("lib"); let self_contained_dst = dst.join("self-contained"); t!(fs::create_dir_all(&dst)); t!(fs::create_dir_all(&self_contained_dst)); @@ -679,7 +680,7 @@ fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &P #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Std { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Std { @@ -718,7 +719,7 @@ impl Step for Std { 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); + copy_target_libs(builder, target, &image, &stamp); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -747,7 +748,7 @@ impl Step for Std { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustcDev { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for RustcDev { @@ -787,7 +788,7 @@ impl Step for RustcDev { 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_target_libs(builder, target, &image, &stamp); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -818,7 +819,7 @@ impl Step for RustcDev { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Analysis { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Analysis { @@ -861,12 +862,12 @@ impl Step for Analysis { let src = builder .stage_out(compiler, Mode::Std) - .join(target) + .join(target.triple) .join(builder.cargo_dir()) .join("deps"); let image_src = src.join("save-analysis"); - let dst = image.join("lib/rustlib").join(target).join("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); @@ -1163,7 +1164,7 @@ pub fn sanitize_sh(path: &Path) -> String { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Cargo { @@ -1255,7 +1256,7 @@ impl Step for Cargo { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rls { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Rls { @@ -1345,7 +1346,7 @@ impl Step for Rls { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for RustAnalyzer { @@ -1432,7 +1433,7 @@ impl Step for RustAnalyzer { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Clippy { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Clippy { @@ -1523,7 +1524,7 @@ impl Step for Clippy { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Miri { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Miri { @@ -1620,7 +1621,7 @@ impl Step for Miri { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rustfmt { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Rustfmt { @@ -1714,8 +1715,8 @@ impl Step for Rustfmt { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Extended { stage: u32, - host: Interned, - target: Interned, + host: TargetSelection, + target: TargetSelection, } impl Step for Extended { @@ -2255,7 +2256,7 @@ impl Step for Extended { } } -fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: Interned) { +fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: TargetSelection) { let mut parts = channel::CFG_RELEASE_NUM.split('.'); cmd.env("CFG_RELEASE_INFO", builder.rust_version()) .env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM) @@ -2266,7 +2267,7 @@ fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: Interned) { .env("CFG_VER_BUILD", "0") // just needed to build .env("CFG_PACKAGE_VERS", builder.rust_package_vers()) .env("CFG_PACKAGE_NAME", pkgname(builder, "rust")) - .env("CFG_BUILD", target) + .env("CFG_BUILD", target.triple) .env("CFG_CHANNEL", &builder.config.channel); if target.contains("windows-gnu") { @@ -2348,7 +2349,7 @@ impl Step for HashSign { /// /// Note: This function does not yet support Windows, but we also don't support /// linking LLVM tools dynamically on Windows yet. -fn maybe_install_llvm(builder: &Builder<'_>, target: Interned, dst_libdir: &Path) { +fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path) { let src_libdir = builder.llvm_out(target).join("lib"); if target.contains("apple-darwin") { @@ -2373,13 +2374,13 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: Interned, dst_libdi } /// Maybe add libLLVM.so to the target lib-dir for linking. -pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: Interned, sysroot: &Path) { - let dst_libdir = sysroot.join("lib/rustlib").join(&*target).join("lib"); +pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { + let dst_libdir = sysroot.join("lib/rustlib").join(&*target.triple).join("lib"); maybe_install_llvm(builder, target, &dst_libdir); } /// Maybe add libLLVM.so to the runtime lib-dir for rustc itself. -pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: Interned, sysroot: &Path) { +pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler { stage: 1, host: target })); maybe_install_llvm(builder, target, &dst_libdir); @@ -2387,7 +2388,7 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: Interned, + pub target: TargetSelection, } impl Step for LlvmTools { @@ -2425,10 +2426,10 @@ impl Step for LlvmTools { // Prepare the image directory let src_bindir = builder.llvm_out(target).join("bin"); - let dst_bindir = image.join("lib/rustlib").join(&*target).join("bin"); + let dst_bindir = image.join("lib/rustlib").join(&*target.triple).join("bin"); t!(fs::create_dir_all(&dst_bindir)); for tool in LLVM_TOOLS { - let exe = src_bindir.join(exe(tool, &target)); + let exe = src_bindir.join(exe(tool, target)); builder.install(&exe, &dst_bindir, 0o755); } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3121690285868..b051390fc2671 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -18,7 +18,7 @@ use build_helper::{t, up_to_date}; use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; use crate::cache::{Interned, INTERNER}; use crate::compile; -use crate::config::Config; +use crate::config::{Config, TargetSelection}; use crate::tool::{self, prepare_tool_cargo, SourceType, Tool}; use crate::util::symlink_dir; @@ -27,7 +27,7 @@ macro_rules! book { $( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $name { - target: Interned, + target: TargetSelection, } impl Step for $name { @@ -101,7 +101,7 @@ fn is_explicit_request(builder: &Builder<'_>, path: &str) -> bool { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct UnstableBook { - target: Interned, + target: TargetSelection, } impl Step for UnstableBook { @@ -129,7 +129,7 @@ impl Step for UnstableBook { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] struct RustbookSrc { - target: Interned, + target: TargetSelection, name: Interned, src: Interned, } @@ -169,7 +169,7 @@ impl Step for RustbookSrc { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct TheBook { compiler: Compiler, - target: Interned, + target: TargetSelection, } impl Step for TheBook { @@ -241,7 +241,7 @@ impl Step for TheBook { fn invoke_rustdoc( builder: &Builder<'_>, compiler: Compiler, - target: Interned, + target: TargetSelection, markdown: &str, ) { let out = builder.doc_out(target); @@ -277,7 +277,7 @@ fn invoke_rustdoc( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Standalone { compiler: Compiler, - target: Interned, + target: TargetSelection, } impl Step for Standalone { @@ -386,7 +386,7 @@ impl Step for Standalone { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Std { pub stage: u32, - pub target: Interned, + pub target: TargetSelection, } impl Step for Std { @@ -415,7 +415,7 @@ impl Step for Std { let compiler = builder.compiler(stage, builder.config.build); builder.ensure(compile::Std { compiler, target }); - let out_dir = builder.stage_out(compiler, Mode::Std).join(target).join("doc"); + let out_dir = builder.stage_out(compiler, Mode::Std).join(target.triple).join("doc"); t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css"))); @@ -475,7 +475,7 @@ impl Step for Std { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rustc { stage: u32, - target: Interned, + target: TargetSelection, } impl Step for Rustc { @@ -522,7 +522,7 @@ impl Step for Rustc { // needed because rustdoc is built in a different directory from // rustc. rustdoc needs to be able to see everything, for example when // merging the search index, or generating local (relative) links. - let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc"); + let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target.triple).join("doc"); t!(symlink_dir_force(&builder.config, &out, &out_dir)); // Build cargo command. @@ -559,7 +559,7 @@ impl Step for Rustc { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rustdoc { stage: u32, - target: Interned, + target: TargetSelection, } impl Step for Rustdoc { @@ -604,7 +604,7 @@ impl Step for Rustdoc { builder.ensure(tool::Rustdoc { compiler }); // Symlink compiler docs to the output directory of rustdoc documentation. - let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc"); + let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc"); t!(fs::create_dir_all(&out_dir)); t!(symlink_dir_force(&builder.config, &out, &out_dir)); @@ -632,7 +632,7 @@ impl Step for Rustdoc { #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for ErrorIndex { @@ -672,7 +672,7 @@ impl Step for ErrorIndex { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct UnstableBookGen { - target: Interned, + target: TargetSelection, } impl Step for UnstableBookGen { diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index f477c75293385..1055689c81e6a 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -10,8 +10,7 @@ use std::process; use getopts::Options; use crate::builder::Builder; -use crate::cache::{Interned, INTERNER}; -use crate::config::Config; +use crate::config::{Config, TargetSelection}; use crate::{Build, DocTests}; /// Deserialized version of all flags for this compile. @@ -21,8 +20,8 @@ pub struct Flags { pub stage: Option, pub keep_stage: Vec, - pub host: Vec>, - pub target: Vec>, + pub host: Vec, + pub target: Vec, pub config: Option, pub jobs: Option, pub cmd: Subcommand, @@ -532,11 +531,11 @@ Arguments: .collect(), host: split(&matches.opt_strs("host")) .into_iter() - .map(|x| INTERNER.intern_string(x)) + .map(|x| TargetSelection::from_user(&x)) .collect::>(), target: split(&matches.opt_strs("target")) .into_iter() - .map(|x| INTERNER.intern_string(x)) + .map(|x| TargetSelection::from_user(&x)) .collect::>(), config: cfg_file, jobs: matches.opt_str("jobs").map(|j| j.parse().expect("`jobs` should be a number")), diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 7026b25d1b984..7266625ff39f8 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -14,46 +14,47 @@ use crate::dist::{self, pkgname, sanitize_sh, tmpdir}; use crate::Compiler; use crate::builder::{Builder, RunConfig, ShouldRun, Step}; -use crate::cache::Interned; -use crate::config::Config; +use crate::config::{Config, TargetSelection}; -pub fn install_docs(builder: &Builder<'_>, stage: u32, host: Interned) { +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: Interned) { +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: Interned) { +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: Interned) { +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: Interned) { + +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: Interned) { + +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: Interned) { +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: Interned) { +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: Interned) { +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: Interned) { +pub fn install_rustc(builder: &Builder<'_>, stage: u32, host: TargetSelection) { install_sh(builder, "rustc", "rustc", stage, Some(host)); } @@ -62,7 +63,7 @@ fn install_sh( package: &str, name: &str, stage: u32, - host: Option>, + host: Option, ) { builder.info(&format!("Install {} stage{} ({:?})", package, stage, host)); @@ -150,7 +151,7 @@ macro_rules! install { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl $name { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 9ca9e338d55c5..77820ef87e3b4 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -123,6 +123,7 @@ use std::os::windows::fs::symlink_file; use build_helper::{mtime, output, run, run_suppressed, t, try_run, try_run_suppressed}; use filetime::FileTime; +use crate::config::TargetSelection; use crate::util::{exe, libdir, CiEnv}; mod builder; @@ -187,7 +188,7 @@ const LLVM_TOOLS: &[&str] = &[ #[derive(Eq, PartialOrd, Ord, PartialEq, Clone, Copy, Hash, Debug)] pub struct Compiler { stage: u32, - host: Interned, + host: TargetSelection, } #[derive(PartialEq, Eq, Copy, Clone, Debug)] @@ -236,9 +237,9 @@ pub struct Build { verbosity: usize, // Targets for which to build - build: Interned, - hosts: Vec>, - targets: Vec>, + build: TargetSelection, + hosts: Vec, + targets: Vec, // Stage 0 (downloaded) compiler, lld and cargo or their local rust equivalents initial_rustc: PathBuf, @@ -248,10 +249,10 @@ pub struct Build { // Runtime state filled in later on // C/C++ compilers and archiver for all targets - cc: HashMap, cc::Tool>, - cxx: HashMap, cc::Tool>, - ar: HashMap, PathBuf>, - ranlib: HashMap, PathBuf>, + cc: HashMap, + cxx: HashMap, + ar: HashMap, + ranlib: HashMap, // Miscellaneous crates: HashMap, Crate>, is_sudo: bool, @@ -259,7 +260,7 @@ pub struct Build { delayed_failures: RefCell>, prerelease_version: Cell>, tool_artifacts: - RefCell, HashMap)>>>, + RefCell)>>>, } #[derive(Debug)] @@ -365,7 +366,7 @@ impl Build { output( Command::new(&config.initial_rustc) .arg("--target") - .arg(config.build) + .arg(config.build.rustc_target_arg()) .arg("--print") .arg("target-libdir"), ) @@ -453,7 +454,7 @@ impl Build { } pub fn build_triple(&self) -> &[Interned] { - unsafe { slice::from_raw_parts(&self.build, 1) } + slice::from_ref(&self.build.triple) } /// Executes the entire build, as configured by the flags and configuration. @@ -558,7 +559,10 @@ impl Build { } fn tools_dir(&self, compiler: Compiler) -> PathBuf { - let out = self.out.join(&*compiler.host).join(format!("stage{}-tools-bin", compiler.stage)); + let out = self + .out + .join(&*compiler.host.triple) + .join(format!("stage{}-tools-bin", compiler.stage)); t!(fs::create_dir_all(&out)); out } @@ -575,47 +579,47 @@ impl Build { Mode::ToolBootstrap => "-bootstrap-tools", Mode::ToolStd | Mode::ToolRustc => "-tools", }; - self.out.join(&*compiler.host).join(format!("stage{}{}", compiler.stage, suffix)) + self.out.join(&*compiler.host.triple).join(format!("stage{}{}", compiler.stage, suffix)) } /// Returns the root output directory for all Cargo output in a given stage, /// running a particular compiler, whether or not we're building the /// standard library, and targeting the specified architecture. - fn cargo_out(&self, compiler: Compiler, mode: Mode, target: Interned) -> PathBuf { - self.stage_out(compiler, mode).join(&*target).join(self.cargo_dir()) + fn cargo_out(&self, compiler: Compiler, mode: Mode, target: TargetSelection) -> PathBuf { + self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir()) } /// Root output directory for LLVM compiled for `target` /// /// Note that if LLVM is configured externally then the directory returned /// will likely be empty. - fn llvm_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("llvm") + fn llvm_out(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("llvm") } - fn lld_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("lld") + fn lld_out(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("lld") } /// Output directory for all documentation for a target - fn doc_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("doc") + fn doc_out(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("doc") } /// Output directory for all documentation for a target - fn compiler_doc_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("compiler-doc") + fn compiler_doc_out(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("compiler-doc") } /// Output directory for some generated md crate documentation for a target (temporary) - fn md_doc_out(&self, target: Interned) -> Interned { - INTERNER.intern_path(self.out.join(&*target).join("md-doc")) + fn md_doc_out(&self, target: TargetSelection) -> Interned { + INTERNER.intern_path(self.out.join(&*target.triple).join("md-doc")) } /// Returns `true` if no custom `llvm-config` is set for the specified target. /// /// If no custom `llvm-config` was specified then Rust's llvm will be used. - fn is_rust_llvm(&self, target: Interned) -> bool { + fn is_rust_llvm(&self, target: TargetSelection) -> bool { match self.config.target_config.get(&target) { Some(ref c) => c.llvm_config.is_none(), None => true, @@ -623,13 +627,13 @@ impl Build { } /// Returns the path to `FileCheck` binary for the specified target - fn llvm_filecheck(&self, target: Interned) -> PathBuf { + fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf { let target_config = self.config.target_config.get(&target); if let Some(s) = target_config.and_then(|c| c.llvm_filecheck.as_ref()) { s.to_path_buf() } else if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { let llvm_bindir = output(Command::new(s).arg("--bindir")); - let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target)); + let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", target)); if filecheck.exists() { filecheck } else { @@ -637,7 +641,7 @@ impl Build { // llvm subdirectory of the libdir. let llvm_libdir = output(Command::new(s).arg("--libdir")); let lib_filecheck = - Path::new(llvm_libdir.trim()).join("llvm").join(exe("FileCheck", &*target)); + Path::new(llvm_libdir.trim()).join("llvm").join(exe("FileCheck", target)); if lib_filecheck.exists() { lib_filecheck } else { @@ -662,18 +666,18 @@ impl Build { } else { base }; - base.join("bin").join(exe("FileCheck", &*target)) + base.join("bin").join(exe("FileCheck", target)) } } /// Directory for libraries built from C/C++ code and shared between stages. - fn native_dir(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("native") + fn native_dir(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("native") } /// Root output directory for rust_test_helpers library compiled for /// `target` - fn test_helpers_out(&self, target: Interned) -> PathBuf { + fn test_helpers_out(&self, target: TargetSelection) -> PathBuf { self.native_dir(target).join("rust-test-helpers") } @@ -686,7 +690,7 @@ impl Build { /// Returns the libdir of the snapshot compiler. fn rustc_snapshot_libdir(&self) -> PathBuf { - self.rustc_snapshot_sysroot().join(libdir(&self.config.build)) + self.rustc_snapshot_sysroot().join(libdir(self.config.build)) } /// Returns the sysroot of the snapshot compiler. @@ -784,13 +788,13 @@ impl Build { } /// Returns the path to the C compiler for the target specified. - fn cc(&self, target: Interned) -> &Path { + fn cc(&self, target: TargetSelection) -> &Path { self.cc[&target].path() } /// Returns a list of flags to pass to the C compiler for the target /// specified. - fn cflags(&self, target: Interned, which: GitRepo) -> Vec { + fn cflags(&self, target: TargetSelection, which: GitRepo) -> Vec { // Filter out -O and /O (the optimization flags) that we picked up from // cc-rs because the build scripts will determine that for themselves. let mut base = self.cc[&target] @@ -811,7 +815,7 @@ impl Build { // Work around an apparently bad MinGW / GCC optimization, // See: http://lists.llvm.org/pipermail/cfe-dev/2016-December/051980.html // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78936 - if &*target == "i686-pc-windows-gnu" { + if &*target.triple == "i686-pc-windows-gnu" { base.push("-fno-omit-frame-pointer".into()); } @@ -829,17 +833,17 @@ impl Build { } /// Returns the path to the `ar` archive utility for the target specified. - fn ar(&self, target: Interned) -> Option<&Path> { + fn ar(&self, target: TargetSelection) -> Option<&Path> { self.ar.get(&target).map(|p| &**p) } /// Returns the path to the `ranlib` utility for the target specified. - fn ranlib(&self, target: Interned) -> Option<&Path> { + fn ranlib(&self, target: TargetSelection) -> Option<&Path> { self.ranlib.get(&target).map(|p| &**p) } /// Returns the path to the C++ compiler for the target specified. - fn cxx(&self, target: Interned) -> Result<&Path, String> { + fn cxx(&self, target: TargetSelection) -> Result<&Path, String> { match self.cxx.get(&target) { Some(p) => Ok(p.path()), None => { @@ -849,12 +853,12 @@ impl Build { } /// Returns the path to the linker for the given target if it needs to be overridden. - fn linker(&self, target: Interned, can_use_lld: bool) -> Option<&Path> { + fn linker(&self, target: TargetSelection, can_use_lld: bool) -> Option<&Path> { if let Some(linker) = self.config.target_config.get(&target).and_then(|c| c.linker.as_ref()) { Some(linker) } else if target != self.config.build - && util::use_host_linker(&target) + && util::use_host_linker(target) && !target.contains("msvc") { Some(self.cc(target)) @@ -866,7 +870,7 @@ impl Build { } /// Returns if this target should statically link the C runtime, if specified - fn crt_static(&self, target: Interned) -> Option { + fn crt_static(&self, target: TargetSelection) -> Option { if target.contains("pc-windows-msvc") { Some(true) } else { @@ -875,7 +879,7 @@ impl Build { } /// Returns the "musl root" for this `target`, if defined - fn musl_root(&self, target: Interned) -> Option<&Path> { + fn musl_root(&self, target: TargetSelection) -> Option<&Path> { self.config .target_config .get(&target) @@ -885,7 +889,7 @@ impl Build { } /// Returns the "musl libdir" for this `target`. - fn musl_libdir(&self, target: Interned) -> Option { + fn musl_libdir(&self, target: TargetSelection) -> Option { let t = self.config.target_config.get(&target)?; if let libdir @ Some(_) = &t.musl_libdir { return libdir.clone(); @@ -894,18 +898,18 @@ impl Build { } /// Returns the sysroot for the wasi target, if defined - fn wasi_root(&self, target: Interned) -> Option<&Path> { + fn wasi_root(&self, target: TargetSelection) -> Option<&Path> { self.config.target_config.get(&target).and_then(|t| t.wasi_root.as_ref()).map(|p| &**p) } /// Returns `true` if this is a no-std `target`, if defined - fn no_std(&self, target: Interned) -> Option { + fn no_std(&self, target: TargetSelection) -> Option { self.config.target_config.get(&target).map(|t| t.no_std) } /// Returns `true` if the target will be tested using the `remote-test-client` /// and `remote-test-server` binaries. - fn remote_tested(&self, target: Interned) -> bool { + fn remote_tested(&self, target: TargetSelection) -> bool { self.qemu_rootfs(target).is_some() || target.contains("android") || env::var_os("TEST_DEVICE_ADDR").is_some() @@ -916,7 +920,7 @@ impl Build { /// /// If `Some` is returned then that means that tests for this target are /// emulated with QEMU and binaries will need to be shipped to the emulator. - fn qemu_rootfs(&self, target: Interned) -> Option<&Path> { + fn qemu_rootfs(&self, target: TargetSelection) -> Option<&Path> { self.config.target_config.get(&target).and_then(|t| t.qemu_rootfs.as_ref()).map(|p| &**p) } @@ -948,7 +952,7 @@ impl Build { /// /// When all of these conditions are met the build will lift artifacts from /// the previous stage forward. - fn force_use_stage1(&self, compiler: Compiler, target: Interned) -> bool { + fn force_use_stage1(&self, compiler: Compiler, target: TargetSelection) -> bool { !self.config.full_bootstrap && compiler.stage >= 2 && (self.hosts.iter().any(|h| *h == target) || target == self.build) @@ -1058,7 +1062,7 @@ impl Build { self.rust_version() } - fn llvm_link_tools_dynamically(&self, target: Interned) -> bool { + fn llvm_link_tools_dynamically(&self, target: TargetSelection) -> bool { target.contains("linux-gnu") || target.contains("apple-darwin") } diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index b7c527f6712e1..48b2cc24d4cd8 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -19,8 +19,8 @@ use std::process::Command; use build_helper::{output, t}; use crate::builder::{Builder, RunConfig, ShouldRun, Step}; -use crate::cache::Interned; use crate::channel; +use crate::config::TargetSelection; use crate::util::{self, exe}; use crate::GitRepo; use build_helper::up_to_date; @@ -41,7 +41,7 @@ pub struct Meta { // if not). pub fn prebuilt_llvm_config( builder: &Builder<'_>, - target: Interned, + target: TargetSelection, ) -> Result { // If we're using a custom LLVM bail out here, but we can only use a // custom LLVM for the build triple. @@ -54,13 +54,14 @@ pub fn prebuilt_llvm_config( let root = "src/llvm-project/llvm"; let out_dir = builder.llvm_out(target); + let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build); if !builder.config.build.contains("msvc") || builder.config.ninja { llvm_config_ret_dir.push("build"); } llvm_config_ret_dir.push("bin"); - let build_llvm_config = llvm_config_ret_dir.join(exe("llvm-config", &*builder.config.build)); + let build_llvm_config = llvm_config_ret_dir.join(exe("llvm-config", builder.config.build)); let stamp = out_dir.join("llvm-finished-building"); let stamp = HashStamp::new(stamp, builder.in_tree_llvm_info.sha()); @@ -93,7 +94,7 @@ pub fn prebuilt_llvm_config( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Llvm { - pub target: Interned, + pub target: TargetSelection, } impl Step for Llvm { @@ -115,9 +116,9 @@ impl Step for Llvm { let target_native = if self.target.starts_with("riscv") { // RISC-V target triples in Rust is not named the same as C compiler target triples. // This converts Rust RISC-V target triples to C compiler triples. - let idx = target.find('-').unwrap(); + let idx = target.triple.find('-').unwrap(); - format!("riscv{}{}", &target[5..7], &target[idx..]) + format!("riscv{}{}", &target.triple[5..7], &target.triple[idx..]) } else { target.to_string() }; @@ -359,7 +360,7 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) { fn configure_cmake( builder: &Builder<'_>, - target: Interned, + target: TargetSelection, cfg: &mut cmake::Config, use_compiler_launcher: bool, ) { @@ -375,7 +376,7 @@ fn configure_cmake( if builder.config.ninja { cfg.generator("Ninja"); } - cfg.target(&target).host(&builder.config.build); + cfg.target(&target.triple).host(&builder.config.build.triple); let sanitize_cc = |cc: &Path| { if target.contains("msvc") { @@ -405,7 +406,7 @@ fn configure_cmake( cfg.define("CMAKE_C_COMPILER", sanitize_cc(&wrap_cc)) .define("CMAKE_CXX_COMPILER", sanitize_cc(&wrap_cc)); cfg.env("SCCACHE_PATH", builder.config.ccache.as_ref().unwrap()) - .env("SCCACHE_TARGET", target) + .env("SCCACHE_TARGET", target.triple) .env("SCCACHE_CC", &cc) .env("SCCACHE_CXX", &cxx); @@ -505,7 +506,7 @@ fn configure_cmake( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Lld { - pub target: Interned, + pub target: TargetSelection, } impl Step for Lld { @@ -578,8 +579,8 @@ impl Step for Lld { // brittle and will break over time. If anyone knows better how to // cross-compile LLD it would be much appreciated to fix this! if target != builder.config.build { - cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build) - .env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target) + cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build.triple) + .env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target.triple) .define( "LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION), @@ -599,7 +600,7 @@ impl Step for Lld { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct TestHelpers { - pub target: Interned, + pub target: TargetSelection, } impl Step for TestHelpers { @@ -646,8 +647,8 @@ impl Step for TestHelpers { cfg.cargo_metadata(false) .out_dir(&dst) - .target(&target) - .host(&builder.config.build) + .target(&target.triple) + .host(&builder.config.build.triple) .opt_level(0) .warnings(false) .debug(false) @@ -658,7 +659,7 @@ impl Step for TestHelpers { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Sanitizers { - pub target: Interned, + pub target: TargetSelection, } impl Step for Sanitizers { @@ -709,7 +710,7 @@ impl Step for Sanitizers { let mut cfg = cmake::Config::new(&compiler_rt_dir); cfg.profile("Release"); - cfg.define("CMAKE_C_COMPILER_TARGET", self.target); + cfg.define("CMAKE_C_COMPILER_TARGET", self.target.triple); cfg.define("COMPILER_RT_BUILD_BUILTINS", "OFF"); cfg.define("COMPILER_RT_BUILD_CRT", "OFF"); cfg.define("COMPILER_RT_BUILD_LIBFUZZER", "OFF"); @@ -752,7 +753,7 @@ pub struct SanitizerRuntime { /// Returns sanitizers available on a given target. fn supported_sanitizers( out_dir: &Path, - target: Interned, + target: TargetSelection, channel: &str, ) -> Vec { let darwin_libs = |os: &str, components: &[&str]| -> Vec { @@ -778,7 +779,7 @@ fn supported_sanitizers( .collect() }; - match &*target { + match &*target.triple { "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 3301d41cfeefa..f89bef50de982 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -183,7 +183,11 @@ pub fn check(build: &mut Build) { panic!("the iOS target is only supported on macOS"); } - build.config.target_config.entry(target.clone()).or_insert(Target::from_triple(target)); + build + .config + .target_config + .entry(target.clone()) + .or_insert(Target::from_triple(&target.triple)); if target.contains("-none-") || target.contains("nvptx") { if build.no_std(*target) == Some(false) { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 1916d96bed71d..b6641180c92c0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -16,6 +16,7 @@ use build_helper::{self, output, t}; use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; use crate::cache::{Interned, INTERNER}; use crate::compile; +use crate::config::TargetSelection; use crate::dist; use crate::flags::Subcommand; use crate::native; @@ -93,7 +94,7 @@ fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Linkcheck { - host: Interned, + host: TargetSelection, } impl Step for Linkcheck { @@ -115,7 +116,7 @@ impl Step for Linkcheck { let _time = util::timeit(&builder); try_run( builder, - builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host).join("doc")), + builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")), ); } @@ -132,7 +133,7 @@ impl Step for Linkcheck { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Cargotest { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Cargotest { @@ -177,7 +178,7 @@ impl Step for Cargotest { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Cargo { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Cargo { @@ -230,7 +231,7 @@ impl Step for Cargo { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rls { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Rls { @@ -281,7 +282,7 @@ impl Step for Rls { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Rustfmt { @@ -338,7 +339,7 @@ impl Step for Rustfmt { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Miri { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Miri { @@ -464,7 +465,7 @@ impl Step for Miri { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CompiletestTest { - host: Interned, + host: TargetSelection, } impl Step for CompiletestTest { @@ -501,7 +502,7 @@ impl Step for CompiletestTest { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Clippy { stage: u32, - host: Interned, + host: TargetSelection, } impl Step for Clippy { @@ -542,8 +543,10 @@ impl Step for Clippy { cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir()); - let target_libs = - builder.stage_out(compiler, Mode::ToolRustc).join(&self.host).join(builder.cargo_dir()); + let target_libs = builder + .stage_out(compiler, Mode::ToolRustc) + .join(&self.host.triple) + .join(builder.cargo_dir()); cargo.env("HOST_LIBS", host_libs); cargo.env("TARGET_LIBS", target_libs); // clippy tests need to find the driver @@ -607,7 +610,7 @@ impl Step for RustdocTheme { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSStd { - pub target: Interned, + pub target: TargetSelection, } impl Step for RustdocJSStd { @@ -646,8 +649,8 @@ impl Step for RustdocJSStd { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSNotStd { - pub host: Interned, - pub target: Interned, + pub host: TargetSelection, + pub target: TargetSelection, pub compiler: Compiler, } @@ -683,8 +686,8 @@ impl Step for RustdocJSNotStd { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocUi { - pub host: Interned, - pub target: Interned, + pub host: TargetSelection, + pub target: TargetSelection, pub compiler: Compiler, } @@ -785,8 +788,8 @@ impl Step for ExpandYamlAnchors { } } -fn testdir(builder: &Builder<'_>, host: Interned) -> PathBuf { - builder.out.join(host).join("test") +fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf { + builder.out.join(host.triple).join("test") } macro_rules! default_test { @@ -855,7 +858,7 @@ macro_rules! test_definitions { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct $name { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for $name { @@ -943,7 +946,7 @@ default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "as #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct Compiletest { compiler: Compiler, - target: Interned, + target: TargetSelection, mode: &'static str, suite: &'static str, path: &'static str, @@ -1023,8 +1026,8 @@ impl Step for Compiletest { cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target)); cmd.arg("--mode").arg(mode); - cmd.arg("--target").arg(target); - cmd.arg("--host").arg(&*compiler.host); + cmd.arg("--target").arg(target.rustc_target_arg()); + cmd.arg("--host").arg(&*compiler.host.triple); cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); if builder.config.cmd.bless() { @@ -1543,7 +1546,7 @@ impl Step for RustcGuide { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateLibrustc { compiler: Compiler, - target: Interned, + target: TargetSelection, test_kind: TestKind, krate: Interned, } @@ -1589,7 +1592,7 @@ impl Step for CrateLibrustc { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateNotDefault { compiler: Compiler, - target: Interned, + target: TargetSelection, test_kind: TestKind, krate: &'static str, } @@ -1638,7 +1641,7 @@ impl Step for CrateNotDefault { #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Crate { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, pub mode: Mode, pub test_kind: TestKind, pub krate: Interned, @@ -1750,17 +1753,17 @@ impl Step for Crate { if target.contains("emscripten") { cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target)), + format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), builder.config.nodejs.as_ref().expect("nodejs not configured"), ); } else if target.starts_with("wasm32") { let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); - cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner); + cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); } else if builder.remote_tested(target) { cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target)), + format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), ); } @@ -1776,7 +1779,7 @@ impl Step for Crate { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { - host: Interned, + host: TargetSelection, test_kind: TestKind, } @@ -1883,7 +1886,7 @@ impl Step for CrateRustdoc { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct RemoteCopyLibs { compiler: Compiler, - target: Interned, + target: TargetSelection, } impl Step for RemoteCopyLibs { @@ -1911,7 +1914,7 @@ impl Step for RemoteCopyLibs { // Spawn the emulator and wait for it to come online let tool = builder.tool_exe(Tool::RemoteTestClient); let mut cmd = Command::new(&tool); - cmd.arg("spawn-emulator").arg(target).arg(&server).arg(builder.out.join("tmp")); + cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.out.join("tmp")); if let Some(rootfs) = builder.qemu_rootfs(target) { cmd.arg(rootfs); } @@ -1966,7 +1969,9 @@ impl Step for Distcheck { .current_dir(&dir), ); builder.run( - Command::new(build_helper::make(&builder.config.build)).arg("check").current_dir(&dir), + Command::new(build_helper::make(&builder.config.build.triple)) + .arg("check") + .current_dir(&dir), ); // Now make sure that rust-src has all of libstd's dependencies diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 450b534d5dfdb..f66061975d64d 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -7,10 +7,10 @@ use std::process::{exit, Command}; use build_helper::t; use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step}; -use crate::cache::Interned; use crate::channel; use crate::channel::GitInfo; use crate::compile; +use crate::config::TargetSelection; use crate::toolstate::ToolState; use crate::util::{add_dylib_path, exe}; use crate::Compiler; @@ -25,7 +25,7 @@ pub enum SourceType { #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct ToolBuild { compiler: Compiler, - target: Interned, + target: TargetSelection, tool: &'static str, path: &'static str, mode: Mode, @@ -111,7 +111,7 @@ impl Step for ToolBuild { .and_then(|p| p.file_name()) .and_then(|p| p.to_str()) .unwrap(); - if maybe_target != &*target { + if maybe_target != &*target.triple { continue; } } @@ -208,8 +208,8 @@ impl Step for ToolBuild { } } else { let cargo_out = - builder.cargo_out(compiler, self.mode, target).join(exe(tool, &compiler.host)); - let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host)); + builder.cargo_out(compiler, self.mode, target).join(exe(tool, compiler.host)); + let bin = builder.tools_dir(compiler).join(exe(tool, compiler.host)); builder.copy(&cargo_out, &bin); Some(bin) } @@ -220,7 +220,7 @@ pub fn prepare_tool_cargo( builder: &Builder<'_>, compiler: Compiler, mode: Mode, - target: Interned, + target: TargetSelection, command: &'static str, path: &'static str, source_type: SourceType, @@ -303,7 +303,7 @@ macro_rules! bootstrap_tool { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for $name { @@ -416,7 +416,7 @@ impl Step for ErrorIndex { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RemoteTestServer { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for RemoteTestServer { @@ -476,7 +476,7 @@ impl Step for Rustdoc { if !target_compiler.is_snapshot(builder) { panic!("rustdoc in stage 0 must be snapshot rustdoc"); } - return builder.initial_rustc.with_file_name(exe("rustdoc", &target_compiler.host)); + return builder.initial_rustc.with_file_name(exe("rustdoc", target_compiler.host)); } let target = target_compiler.host; // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise @@ -514,14 +514,14 @@ impl Step for Rustdoc { // rustdoc a different name. let tool_rustdoc = builder .cargo_out(build_compiler, Mode::ToolRustc, target) - .join(exe("rustdoc_tool_binary", &target_compiler.host)); + .join(exe("rustdoc_tool_binary", target_compiler.host)); // don't create a stage0-sysroot/bin directory. if target_compiler.stage > 0 { let sysroot = builder.sysroot(target_compiler); let bindir = sysroot.join("bin"); t!(fs::create_dir_all(&bindir)); - let bin_rustdoc = bindir.join(exe("rustdoc", &*target_compiler.host)); + let bin_rustdoc = bindir.join(exe("rustdoc", target_compiler.host)); let _ = fs::remove_file(&bin_rustdoc); builder.copy(&tool_rustdoc, &bin_rustdoc); bin_rustdoc @@ -534,7 +534,7 @@ impl Step for Rustdoc { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, } impl Step for Cargo { @@ -583,7 +583,7 @@ macro_rules! tool_extended { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, - pub target: Interned, + pub target: TargetSelection, pub extra_features: Vec, } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 2bc6f1939d97b..a307ef39d03a8 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -14,17 +14,16 @@ use std::time::Instant; use build_helper::t; use crate::builder::Builder; -use crate::cache::Interned; -use crate::config::Config; +use crate::config::{Config, TargetSelection}; /// Returns the `name` as the filename of a static library for `target`. -pub fn staticlib(name: &str, target: &str) -> String { +pub fn staticlib(name: &str, target: TargetSelection) -> String { if target.contains("windows") { format!("{}.lib", name) } else { format!("lib{}.a", name) } } /// Given an executable called `name`, return the filename for the /// executable for a particular target. -pub fn exe(name: &str, target: &str) -> String { +pub fn exe(name: &str, target: TargetSelection) -> String { if target.contains("windows") { format!("{}.exe", name) } else { name.to_string() } } @@ -35,7 +34,7 @@ pub fn is_dylib(name: &str) -> bool { /// Returns the corresponding relative library directory that the compiler's /// dylibs will be found in. -pub fn libdir(target: &str) -> &'static str { +pub fn libdir(target: TargetSelection) -> &'static str { if target.contains("windows") { "bin" } else { "lib" } } @@ -294,7 +293,7 @@ pub fn forcing_clang_based_tests() -> bool { } } -pub fn use_host_linker(target: &Interned) -> bool { +pub fn use_host_linker(target: TargetSelection) -> bool { // FIXME: this information should be gotten by checking the linker flavor // of the rustc target !(target.contains("emscripten") diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 0053a54f20346..0cf250576f176 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -573,7 +573,7 @@ impl Arc { /// Provides a raw pointer to the data. /// - /// The counts are not affected in way and the `Arc` is not consumed. The pointer is valid for + /// The counts are not affected in any way and the `Arc` is not consumed. The pointer is valid for /// as long as there are strong counts in the `Arc`. /// /// # Examples diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 9c5dbb5e6f356..638e83c3b939d 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -324,7 +324,7 @@ impl<'a> Arguments<'a> { #[doc(hidden)] #[inline] #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")] - pub fn new_v1(pieces: &'a [&'a str], args: &'a [ArgumentV1<'a>]) -> Arguments<'a> { + pub fn new_v1(pieces: &'a [&'static str], args: &'a [ArgumentV1<'a>]) -> Arguments<'a> { Arguments { pieces, fmt: None, args } } @@ -338,7 +338,7 @@ impl<'a> Arguments<'a> { #[inline] #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")] pub fn new_v1_formatted( - pieces: &'a [&'a str], + pieces: &'a [&'static str], args: &'a [ArgumentV1<'a>], fmt: &'a [rt::v1::Argument], ) -> Arguments<'a> { @@ -399,7 +399,7 @@ impl<'a> Arguments<'a> { #[derive(Copy, Clone)] pub struct Arguments<'a> { // Format string pieces to print. - pieces: &'a [&'a str], + pieces: &'a [&'static str], // Placeholder specs, or `None` if all specs are default (as in "{}{}"). fmt: Option<&'a [rt::v1::Argument]>, @@ -409,6 +409,47 @@ pub struct Arguments<'a> { args: &'a [ArgumentV1<'a>], } +impl<'a> Arguments<'a> { + /// Get the formatted string, if it has no arguments to be formatted. + /// + /// This can be used to avoid allocations in the most trivial case. + /// + /// # Examples + /// + /// ```rust + /// #![feature(fmt_as_str)] + /// + /// use core::fmt::Arguments; + /// + /// fn write_str(_: &str) { /* ... */ } + /// + /// fn write_fmt(args: &Arguments) { + /// if let Some(s) = args.as_str() { + /// write_str(s) + /// } else { + /// write_str(&args.to_string()); + /// } + /// } + /// ``` + /// + /// ```rust + /// #![feature(fmt_as_str)] + /// + /// assert_eq!(format_args!("hello").as_str(), Some("hello")); + /// assert_eq!(format_args!("").as_str(), Some("")); + /// assert_eq!(format_args!("{}", 1).as_str(), None); + /// ``` + #[unstable(feature = "fmt_as_str", issue = "74442")] + #[inline] + pub fn as_str(&self) -> Option<&'static str> { + match (self.pieces, self.args) { + ([], []) => Some(""), + ([s], []) => Some(s), + _ => None, + } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Debug for Arguments<'_> { fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 080b70c6368b2..9b528cdbe30c4 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -39,11 +39,11 @@ //! ``` //! //! An iterator has a method, [`next`], which when called, returns an -//! [`Option`]``. [`next`] will return `Some(Item)` as long as there +//! [`Option`]``. [`next`] will return [`Some(Item)`] as long as there //! are elements, and once they've all been exhausted, will return `None` to //! indicate that iteration is finished. Individual iterators may choose to //! resume iteration, and so calling [`next`] again may or may not eventually -//! start returning `Some(Item)` again at some point (for example, see [`TryIter`]). +//! start returning [`Some(Item)`] again at some point (for example, see [`TryIter`]). //! //! [`Iterator`]'s full definition includes a number of other methods as well, //! but they are default methods, built on top of [`next`], and so you get @@ -53,9 +53,9 @@ //! more complex forms of processing. See the [Adapters](#adapters) section //! below for more details. //! +//! [`Some(Item)`]: Some //! [`Iterator`]: trait.Iterator.html //! [`next`]: trait.Iterator.html#tymethod.next -//! [`Option`]: ../../std/option/enum.Option.html //! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html //! //! # The three forms of iteration @@ -72,9 +72,9 @@ //! # Implementing Iterator //! //! Creating an iterator of your own involves two steps: creating a `struct` to -//! hold the iterator's state, and then `impl`ementing [`Iterator`] for that -//! `struct`. This is why there are so many `struct`s in this module: there is -//! one for each iterator and iterator adapter. +//! hold the iterator's state, and then implementing [`Iterator`] for that `struct`. +//! This is why there are so many `struct`s in this module: there is one for +//! each iterator and iterator adapter. //! //! Let's make an iterator named `Counter` which counts from `1` to `5`: //! diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs index 55f30794af652..494c75174ff83 100644 --- a/src/libcore/iter/traits/accum.rs +++ b/src/libcore/iter/traits/accum.rs @@ -9,9 +9,9 @@ use crate::ops::{Add, Mul}; /// [`FromIterator`] this trait should rarely be called directly and instead /// interacted with through [`Iterator::sum`]. /// -/// [`sum`]: ../../std/iter/trait.Sum.html#tymethod.sum -/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html -/// [`Iterator::sum`]: ../../std/iter/trait.Iterator.html#method.sum +/// [`sum`]: #tymethod.sum +/// [`FromIterator`]: crate::iter::FromIterator +/// [`Iterator::sum`]: crate::iter::Iterator::sum #[stable(feature = "iter_arith_traits", since = "1.12.0")] pub trait Sum: Sized { /// Method which takes an iterator and generates `Self` from the elements by @@ -28,9 +28,9 @@ pub trait Sum: Sized { /// [`FromIterator`] this trait should rarely be called directly and instead /// interacted with through [`Iterator::product`]. /// -/// [`product`]: ../../std/iter/trait.Product.html#tymethod.product -/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html -/// [`Iterator::product`]: ../../std/iter/trait.Iterator.html#method.product +/// [`product`]: #tymethod.product +/// [`FromIterator`]: crate::iter::FromIterator +/// [`Iterator::product`]: crate::iter::Iterator::product #[stable(feature = "iter_arith_traits", since = "1.12.0")] pub trait Product: Sized { /// Method which takes an iterator and generates `Self` from the elements by diff --git a/src/libcore/iter/traits/double_ended.rs b/src/libcore/iter/traits/double_ended.rs index f6329c6c593ed..851a1e49a493b 100644 --- a/src/libcore/iter/traits/double_ended.rs +++ b/src/libcore/iter/traits/double_ended.rs @@ -106,8 +106,7 @@ pub trait DoubleEndedIterator: Iterator { /// `nth_back()` will return [`None`] if `n` is greater than or equal to the length of the /// iterator. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`nth`]: ../../std/iter/trait.Iterator.html#method.nth + /// [`nth`]: crate::iter::Iterator::nth /// /// # Examples /// @@ -274,8 +273,7 @@ pub trait DoubleEndedIterator: Iterator { /// argument is a double reference. You can see this effect in the /// examples below, with `&&x`. /// - /// [`Some(element)`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`Some(element)`]: Some /// /// # Examples /// diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 692eed80c0252..b8faeb488e72d 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -106,8 +106,7 @@ pub trait Iterator { /// again may or may not eventually start returning [`Some(Item)`] again at some /// point. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`Some(Item)`]: ../../std/option/enum.Option.html#variant.Some + /// [`Some(Item)`]: Some /// /// # Examples /// @@ -160,9 +159,7 @@ pub trait Iterator { /// The default implementation returns `(0, `[`None`]`)` which is correct for any /// iterator. /// - /// [`usize`]: ../../std/primitive.usize.html - /// [`Option`]: ../../std/option/enum.Option.html - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`usize`]: type@usize /// /// # Examples /// @@ -214,8 +211,6 @@ pub trait Iterator { /// called at least once even if the iterator does not have any elements. /// /// [`next`]: #tymethod.next - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`Some`]: ../../std/option/enum.Option.html#variant.Some /// /// # Overflow Behavior /// @@ -229,7 +224,7 @@ pub trait Iterator { /// This function might panic if the iterator has more than [`usize::MAX`] /// elements. /// - /// [`usize::MAX`]: ../../std/usize/constant.MAX.html + /// [`usize::MAX`]: crate::usize::MAX /// /// # Examples /// @@ -263,8 +258,6 @@ pub trait Iterator { /// doing so, it keeps track of the current element. After [`None`] is /// returned, `last()` will then return the last element it saw. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// Basic usage: @@ -303,8 +296,6 @@ pub trait Iterator { /// `nth()` will return [`None`] if `n` is greater than or equal to the length of the /// iterator. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// Basic usage: @@ -537,9 +528,8 @@ pub trait Iterator { /// assert_eq!((2, 'o'), zipper[2]); /// ``` /// - /// [`enumerate`]: trait.Iterator.html#method.enumerate - /// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`enumerate`]: #method.enumerate + /// [`next`]: #tymethod.next #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn zip(self, other: U) -> Zip @@ -568,7 +558,7 @@ pub trait Iterator { /// more idiomatic to use [`for`] than `map()`. /// /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for - /// [`FnMut`]: ../../std/ops/trait.FnMut.html + /// [`FnMut`]: crate::ops::FnMut /// /// # Examples /// @@ -756,12 +746,11 @@ pub trait Iterator { /// Basic usage: /// /// ``` - /// let a = ["1", "lol", "3", "NaN", "5"]; + /// let a = ["1", "two", "NaN", "four", "5"]; /// /// let mut iter = a.iter().filter_map(|s| s.parse().ok()); /// /// assert_eq!(iter.next(), Some(1)); - /// assert_eq!(iter.next(), Some(3)); /// assert_eq!(iter.next(), Some(5)); /// assert_eq!(iter.next(), None); /// ``` @@ -769,17 +758,14 @@ pub trait Iterator { /// Here's the same example, but with [`filter`] and [`map`]: /// /// ``` - /// let a = ["1", "lol", "3", "NaN", "5"]; + /// let a = ["1", "two", "NaN", "four", "5"]; /// let mut iter = a.iter().map(|s| s.parse()).filter(|s| s.is_ok()).map(|s| s.unwrap()); /// assert_eq!(iter.next(), Some(1)); - /// assert_eq!(iter.next(), Some(3)); /// assert_eq!(iter.next(), Some(5)); /// assert_eq!(iter.next(), None); /// ``` /// - /// [`Option`]: ../../std/option/enum.Option.html - /// [`Some`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`Option`]: Option #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn filter_map(self, f: F) -> FilterMap @@ -812,8 +798,8 @@ pub trait Iterator { /// The returned iterator might panic if the to-be-returned index would /// overflow a [`usize`]. /// - /// [`usize::MAX`]: ../../std/usize/constant.MAX.html - /// [`usize`]: ../../std/primitive.usize.html + /// [`usize`]: type@usize + /// [`usize::MAX`]: crate::usize::MAX /// [`zip`]: #method.zip /// /// # Examples @@ -849,8 +835,8 @@ pub trait Iterator { /// anything other than fetching the next value) of the [`next`] method /// will occur. /// - /// [`peek`]: struct.Peekable.html#method.peek - /// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next + /// [`peek`]: crate::iter::Peekable::peek + /// [`next`]: #tymethod.next /// /// # Examples /// @@ -1116,8 +1102,6 @@ pub trait Iterator { /// It is also not specified what this iterator returns after the first` None` is returned. /// If you need fused iterator, use [`fuse`]. /// - /// [`Some`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`fuse`]: #method.fuse #[inline] #[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")] @@ -1216,8 +1200,6 @@ pub trait Iterator { /// iterator and the return value from the closure, an [`Option`], is /// yielded by the iterator. /// - /// [`Option`]: ../../std/option/enum.Option.html - /// /// # Examples /// /// Basic usage: @@ -1366,8 +1348,7 @@ pub trait Iterator { /// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a /// [`None`] is given, it will always return [`None`] forever. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`Some(T)`]: ../../std/option/enum.Option.html#variant.Some + /// [`Some(T)`]: Some /// /// # Examples /// @@ -1658,10 +1639,9 @@ pub trait Iterator { /// assert_eq!(Ok(vec![1, 3]), result); /// ``` /// - /// [`iter`]: ../../std/iter/trait.Iterator.html#tymethod.next + /// [`iter`]: #tymethod.next /// [`String`]: ../../std/string/struct.String.html - /// [`char`]: ../../std/primitive.char.html - /// [`Result`]: ../../std/result/enum.Result.html + /// [`char`]: type@char #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"] @@ -2184,8 +2164,7 @@ pub trait Iterator { /// argument is a double reference. You can see this effect in the /// examples below, with `&&x`. /// - /// [`Some(element)`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`Some(element)`]: Some /// /// # Examples /// @@ -2331,9 +2310,8 @@ pub trait Iterator { /// This function might panic if the iterator has more than `usize::MAX` /// non-matching elements. /// - /// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`usize::MAX`]: ../../std/usize/constant.MAX.html + /// [`Some(index)`]: Some + /// [`usize::MAX`]: crate::usize::MAX /// /// # Examples /// @@ -2394,8 +2372,7 @@ pub trait Iterator { /// `rposition()` is short-circuiting; in other words, it will stop /// processing as soon as it finds a `true`. /// - /// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`Some(index)`]: Some /// /// # Examples /// @@ -2449,8 +2426,6 @@ pub trait Iterator { /// If several elements are equally maximum, the last element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// Basic usage: @@ -2477,8 +2452,6 @@ pub trait Iterator { /// If several elements are equally minimum, the first element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// Basic usage: @@ -2506,8 +2479,6 @@ pub trait Iterator { /// If several elements are equally maximum, the last element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -2541,8 +2512,6 @@ pub trait Iterator { /// If several elements are equally maximum, the last element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -2570,8 +2539,6 @@ pub trait Iterator { /// If several elements are equally minimum, the first element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -2605,8 +2572,6 @@ pub trait Iterator { /// If several elements are equally minimum, the first element is /// returned. If the iterator is empty, [`None`] is returned. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -2747,7 +2712,7 @@ pub trait Iterator { /// This is useful when you have an iterator over `&T`, but you need an /// iterator over `T`. /// - /// [`clone`]: ../../std/clone/trait.Clone.html#tymethod.clone + /// [`clone`]: crate::clone::Clone::clone /// /// # Examples /// @@ -2779,8 +2744,6 @@ pub trait Iterator { /// from the beginning. After iterating again, it will start at the /// beginning again. And again. And again. Forever. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// Basic usage: @@ -3233,7 +3196,7 @@ pub trait Iterator { /// assert!(![0.0, 1.0, f32::NAN].iter().is_sorted_by(|a, b| a.partial_cmp(b))); /// ``` /// - /// [`is_sorted`]: trait.Iterator.html#method.is_sorted + /// [`is_sorted`]: #method.is_sorted #[unstable(feature = "is_sorted", reason = "new API", issue = "53485")] fn is_sorted_by(mut self, mut compare: F) -> bool where @@ -3262,7 +3225,7 @@ pub trait Iterator { /// the elements, as determined by `f`. Apart from that, it's equivalent to [`is_sorted`]; see /// its documentation for more information. /// - /// [`is_sorted`]: trait.Iterator.html#method.is_sorted + /// [`is_sorted`]: #method.is_sorted /// /// # Examples /// diff --git a/src/libcore/iter/traits/marker.rs b/src/libcore/iter/traits/marker.rs index a9ba3908c3898..3c893c039923e 100644 --- a/src/libcore/iter/traits/marker.rs +++ b/src/libcore/iter/traits/marker.rs @@ -9,9 +9,8 @@ /// on the iterator. If the iterator is already fused, the additional [`Fuse`] /// wrapper will be a no-op with no performance penalty. /// -/// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [`Iterator::fuse`]: ../../std/iter/trait.Iterator.html#method.fuse -/// [`Fuse`]: ../../std/iter/struct.Fuse.html +/// [`Iterator::fuse`]: crate::iter::Iterator::fuse +/// [`Fuse`]: crate::iter::Fuse #[stable(feature = "fused", since = "1.26.0")] #[rustc_unsafe_specialization_marker] pub trait FusedIterator: Iterator {} @@ -35,9 +34,8 @@ impl FusedIterator for &mut I {} /// This trait must only be implemented when the contract is upheld. /// Consumers of this trait must inspect [`.size_hint`]’s upper bound. /// -/// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [`usize::MAX`]: ../../std/usize/constant.MAX.html -/// [`.size_hint`]: ../../std/iter/trait.Iterator.html#method.size_hint +/// [`usize::MAX`]: crate::usize::MAX +/// [`.size_hint`]: crate::iter::Iterator::size_hint #[unstable(feature = "trusted_len", issue = "37572")] #[rustc_unsafe_specialization_marker] pub unsafe trait TrustedLen: Iterator {} diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 96436bb253df0..2f2206a117cf7 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -83,6 +83,7 @@ #![feature(const_panic)] #![feature(const_fn_union)] #![feature(const_generics)] +#![feature(const_option)] #![feature(const_ptr_offset)] #![feature(const_ptr_offset_from)] #![feature(const_raw_ptr_comparison)] @@ -150,6 +151,7 @@ #![feature(slice_ptr_get)] #![feature(no_niche)] // rust-lang/rust#68303 #![feature(unsafe_block_in_unsafe_fn)] +#![deny(intra_doc_link_resolution_failure)] #![deny(unsafe_op_in_unsafe_fn)] #[prelude_import] diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index 17f7349bac233..4ac366ab16408 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -6,9 +6,12 @@ macro_rules! panic { () => ( $crate::panic!("explicit panic") ); - ($msg:expr) => ( + ($msg:literal) => ( $crate::panicking::panic($msg) ); + ($msg:expr) => ( + $crate::panic!("{}", $crate::convert::identity::<&str>($msg)) + ); ($msg:expr,) => ( $crate::panic!($msg) ); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a27e8d2a72452..5932f8e5856a7 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -179,8 +179,9 @@ impl Option { /// [`Some`]: #variant.Some #[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"] #[inline] + #[rustc_const_unstable(feature = "const_option", issue = "67441")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_some(&self) -> bool { + pub const fn is_some(&self) -> bool { matches!(*self, Some(_)) } @@ -200,8 +201,9 @@ impl Option { #[must_use = "if you intended to assert that this doesn't have a value, consider \ `.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"] #[inline] + #[rustc_const_unstable(feature = "const_option", issue = "67441")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_none(&self) -> bool { + pub const fn is_none(&self) -> bool { !self.is_some() } @@ -259,8 +261,9 @@ impl Option { /// println!("still can print text: {:?}", text); /// ``` #[inline] + #[rustc_const_unstable(feature = "const_option", issue = "67441")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn as_ref(&self) -> Option<&T> { + pub const fn as_ref(&self) -> Option<&T> { match *self { Some(ref x) => Some(x), None => None, @@ -580,8 +583,9 @@ impl Option { /// assert_eq!(x.iter().next(), None); /// ``` #[inline] + #[rustc_const_unstable(feature = "const_option", issue = "67441")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter<'_, T> { + pub const fn iter(&self) -> Iter<'_, T> { Iter { inner: Item { opt: self.as_ref() } } } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 766c69a5f9420..15fd638bef8ad 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -36,7 +36,7 @@ use crate::panic::{Location, PanicInfo}; #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] #[track_caller] #[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators -pub fn panic(expr: &str) -> ! { +pub fn panic(expr: &'static str) -> ! { if cfg!(feature = "panic_immediate_abort") { super::intrinsics::abort() } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 309a4ddb00657..20b2c3d3c965a 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -6095,7 +6095,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `data` must be [valid] for writes for `len * mem::size_of::()` many bytes, +/// * `data` must be [valid] for boths reads and writes for `len * mem::size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index e64aafa599fd8..6f40aac83eb9c 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -28,7 +28,9 @@ use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor}; pub fn disable_localization(linker: &mut Command) { // No harm in setting both env vars simultaneously. // Unix-style linkers. - linker.env("LC_ALL", "C"); + // We use an UTF-8 locale, as the generic C locale disables support for non-ASCII + // bytes in filenames on some platforms. + linker.env("LC_ALL", "en_US.UTF-8"); // MSVC's `link.exe`. linker.env("VSLANG", "1033"); } diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 6160450d76676..295b6dccede0a 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -632,4 +632,5 @@ E0770: include_str!("./error_codes/E0770.md"), E0755, // `#[ffi_pure]` is only allowed on foreign functions E0756, // `#[ffi_const]` is only allowed on foreign functions E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]` + E0767, // `'static' obligation coming from `impl dyn Trait {}` or `impl Foo for dyn Bar {}`. } diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 9204f778a24b9..fff2d89f6971d 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -2198,7 +2198,17 @@ pub enum IsAsync { NotAsync, } -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] +#[derive( + Copy, + Clone, + PartialEq, + RustcEncodable, + RustcDecodable, + Debug, + HashStable_Generic, + Eq, + Hash +)] pub enum Defaultness { Default { has_value: bool }, Final, diff --git a/src/librustc_infer/infer/combine.rs b/src/librustc_infer/infer/combine.rs index 3b564e03d9a94..c63464e5baec9 100644 --- a/src/librustc_infer/infer/combine.rs +++ b/src/librustc_infer/infer/combine.rs @@ -36,12 +36,13 @@ use crate::traits::{Obligation, PredicateObligations}; use rustc_ast::ast; use rustc_hir::def_id::DefId; +use rustc_middle::traits::ObligationCause; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, InferConst, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rustc_middle::ty::{IntType, UintType}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::DUMMY_SP; #[derive(Clone)] pub struct CombineFields<'infcx, 'tcx> { @@ -367,10 +368,11 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { }; debug!("generalize: for_universe = {:?}", for_universe); + debug!("generalize: trace = {:?}", self.trace); let mut generalize = Generalizer { infcx: self.infcx, - span: self.trace.cause.span, + cause: &self.trace.cause, for_vid_sub_root: self.infcx.inner.borrow_mut().type_variables().sub_root_var(for_vid), for_universe, ambient_variance, @@ -414,7 +416,7 @@ struct Generalizer<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, /// The span, used when creating new type variables and things. - span: Span, + cause: &'cx ObligationCause<'tcx>, /// The vid of the type variable that is in the process of being /// instantiated; if we find this within the type we are folding, @@ -639,7 +641,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> { // FIXME: This is non-ideal because we don't give a // very descriptive origin for this region variable. - Ok(self.infcx.next_region_var_in_universe(MiscVariable(self.span), self.for_universe)) + Ok(self.infcx.next_region_var_in_universe(MiscVariable(self.cause.span), self.for_universe)) } fn consts( diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs index b1ea222370742..473128b7df80b 100644 --- a/src/librustc_infer/infer/error_reporting/mod.rs +++ b/src/librustc_infer/infer/error_reporting/mod.rs @@ -2007,7 +2007,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { infer::MiscVariable(_) => String::new(), infer::PatternRegion(_) => " for pattern".to_string(), infer::AddrOfRegion(_) => " for borrow expression".to_string(), - infer::Autoref(_) => " for autoref".to_string(), + infer::Autoref(_, _) => " for autoref".to_string(), infer::Coercion(_) => " for automatic coercion".to_string(), infer::LateBoundRegion(_, br, infer::FnCall) => { format!(" for lifetime parameter {}in function call", br_string(br)) diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs index b6e971feb0e5f..18466b00da971 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -2,227 +2,484 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::lexical_region_resolve::RegionResolutionError; -use rustc_errors::{struct_span_err, Applicability, ErrorReported}; -use rustc_hir::{GenericBound, ItemKind, Lifetime, LifetimeName, TyKind}; -use rustc_middle::ty::RegionKind; +use crate::infer::{SubregionOrigin, TypeTrace}; +use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; +use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{walk_ty, ErasedMap, NestedVisitorMap, Visitor}; +use rustc_hir::{ + self as hir, GenericBound, ImplItem, Item, ItemKind, Lifetime, LifetimeName, Node, TraitItem, + TyKind, +}; +use rustc_middle::ty::{self, AssocItemContainer, RegionKind, Ty, TypeFoldable, TypeVisitor}; +use rustc_span::{MultiSpan, Span}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { - /// Print the error message for lifetime errors when the return type is a static impl Trait. + /// Print the error message for lifetime errors when the return type is a static `impl Trait`, + /// `dyn Trait` or if a method call on a trait object introduces a static requirement. pub(super) fn try_report_static_impl_trait(&self) -> Option { debug!("try_report_static_impl_trait(error={:?})", self.error); - if let Some(RegionResolutionError::SubSupConflict( - _, - var_origin, - ref sub_origin, - sub_r, - ref sup_origin, - sup_r, - )) = self.error - { - debug!( - "try_report_static_impl_trait(var={:?}, sub={:?} {:?} sup={:?} {:?})", - var_origin, sub_origin, sub_r, sup_origin, sup_r - ); - let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?; - debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup); - let fn_returns = self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id); - if fn_returns.is_empty() { + let tcx = self.tcx(); + let (var_origin, sub_origin, sub_r, sup_origin, sup_r) = match self.error.as_ref()? { + RegionResolutionError::SubSupConflict( + _, + var_origin, + sub_origin, + sub_r, + sup_origin, + sup_r, + ) if **sub_r == RegionKind::ReStatic => { + (var_origin, sub_origin, sub_r, sup_origin, sup_r) + } + RegionResolutionError::ConcreteFailure( + SubregionOrigin::Subtype(box TypeTrace { cause, .. }), + sub_r, + sup_r, + ) if **sub_r == RegionKind::ReStatic => { + // This is for an implicit `'static` requirement coming from `impl dyn Trait {}`. + if let ObligationCauseCode::UnifyReceiver(ctxt) = &cause.code { + let param = self.find_param_with_region(sup_r, sub_r)?; + let lifetime = if sup_r.has_name() { + format!("lifetime `{}`", sup_r) + } else { + "an anonymous lifetime `'_`".to_string() + }; + let mut err = struct_span_err!( + tcx.sess, + cause.span, + E0767, + "{} has {} but calling `{}` introduces an implicit `'static` lifetime \ + requirement", + param + .param + .pat + .simple_ident() + .map(|s| format!("`{}`", s)) + .unwrap_or_else(|| "`fn` parameter".to_string()), + lifetime, + ctxt.assoc_item.ident, + ); + err.span_label(param.param_ty_span, &format!("this data with {}...", lifetime)); + err.span_label( + cause.span, + &format!( + "...is captured and required to live as long as `'static` here \ + because of an implicit lifetime bound on the {}", + match ctxt.assoc_item.container { + AssocItemContainer::TraitContainer(id) => + format!("`impl` of `{}`", tcx.def_path_str(id)), + AssocItemContainer::ImplContainer(_) => + "inherent `impl`".to_string(), + }, + ), + ); + if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) { + err.emit(); + return Some(ErrorReported); + } else { + err.cancel(); + } + } return None; } - debug!("try_report_static_impl_trait: fn_return={:?}", fn_returns); - if *sub_r == RegionKind::ReStatic { - let sp = var_origin.span(); - let return_sp = sub_origin.span(); - let param_info = self.find_param_with_region(sup_r, sub_r)?; - let (lifetime_name, lifetime) = if sup_r.has_name() { - (sup_r.to_string(), format!("lifetime `{}`", sup_r)) - } else { - ("'_".to_owned(), "an anonymous lifetime `'_`".to_string()) - }; - let mut err = struct_span_err!( - self.tcx().sess, - sp, - E0759, - "cannot infer an appropriate lifetime" - ); - err.span_label( - param_info.param_ty_span, - &format!("this data with {}...", lifetime), - ); - debug!("try_report_static_impl_trait: param_info={:?}", param_info); + _ => return None, + }; + debug!( + "try_report_static_impl_trait(var={:?}, sub={:?} {:?} sup={:?} {:?})", + var_origin, sub_origin, sub_r, sup_origin, sup_r + ); + let anon_reg_sup = tcx.is_suitable_region(sup_r)?; + debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup); + let sp = var_origin.span(); + let return_sp = sub_origin.span(); + let param = self.find_param_with_region(sup_r, sub_r)?; + let (lifetime_name, lifetime) = if sup_r.has_name() { + (sup_r.to_string(), format!("lifetime `{}`", sup_r)) + } else { + ("'_".to_owned(), "an anonymous lifetime `'_`".to_string()) + }; + let param_name = param + .param + .pat + .simple_ident() + .map(|s| format!("`{}`", s)) + .unwrap_or_else(|| "`fn` parameter".to_string()); + let mut err = struct_span_err!( + tcx.sess, + sp, + E0759, + "{} has {} but it needs to satisfy a `'static` lifetime requirement", + param_name, + lifetime, + ); + err.span_label(param.param_ty_span, &format!("this data with {}...", lifetime)); + debug!("try_report_static_impl_trait: param_info={:?}", param); + + let fn_returns = tcx.return_type_impl_or_dyn_traits(anon_reg_sup.def_id); - // We try to make the output have fewer overlapping spans if possible. - if (sp == sup_origin.span() || !return_sp.overlaps(sup_origin.span())) - && sup_origin.span() != return_sp + let mut postfix = String::new(); + if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sup_origin { + if let ObligationCauseCode::UnifyReceiver(ctxt) = &cause.code { + if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) + && fn_returns.is_empty() { - // FIXME: account for `async fn` like in `async-await/issues/issue-62097.rs` - - // Customize the spans and labels depending on their relative order so - // that split sentences flow correctly. - if sup_origin.span().overlaps(return_sp) && sp == sup_origin.span() { - // Avoid the following: - // - // error: cannot infer an appropriate lifetime - // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 - // | - // LL | fn foo(x: &i32) -> Box { Box::new(x) } - // | ---- ---------^- - // - // and instead show: - // - // error: cannot infer an appropriate lifetime - // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 - // | - // LL | fn foo(x: &i32) -> Box { Box::new(x) } - // | ---- ^ - err.span_label( - sup_origin.span(), - "...is captured here, requiring it to live as long as `'static`", - ); - } else { - err.span_label(sup_origin.span(), "...is captured here..."); - if return_sp < sup_origin.span() { - err.span_note( - return_sp, - "...and is required to live as long as `'static` here", - ); - } else { - err.span_label( - return_sp, - "...and is required to live as long as `'static` here", - ); - } - } + err.code(rustc_errors::error_code!(E0767)); + err.set_primary_message(&format!( + "{} has {} but calling `{}` introduces an implicit `'static` lifetime \ + requirement", + param_name, lifetime, ctxt.assoc_item.ident, + )); + postfix = format!( + " because of an implicit lifetime on the {}", + match ctxt.assoc_item.container { + AssocItemContainer::TraitContainer(id) => + format!("`impl` of `{}`", tcx.def_path_str(id)), + AssocItemContainer::ImplContainer(_) => "inherent `impl`".to_string(), + }, + ); + } + // } + } + } + + // We try to make the output have fewer overlapping spans if possible. + if (sp == sup_origin.span() || !return_sp.overlaps(sup_origin.span())) + && sup_origin.span() != return_sp + { + // FIXME: account for `async fn` like in `async-await/issues/issue-62097.rs` + + // Customize the spans and labels depending on their relative order so + // that split sentences flow correctly. + if sup_origin.span().overlaps(return_sp) && sp == sup_origin.span() { + // Avoid the following: + // + // error: cannot infer an appropriate lifetime + // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 + // | + // LL | fn foo(x: &i32) -> Box { Box::new(x) } + // | ---- ---------^- + // + // and instead show: + // + // error: cannot infer an appropriate lifetime + // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 + // | + // LL | fn foo(x: &i32) -> Box { Box::new(x) } + // | ---- ^ + err.span_label( + sup_origin.span(), + &format!( + "...is captured here, requiring it to live as long as `'static`{}", + postfix + ), + ); + } else { + err.span_label(sup_origin.span(), "...is captured here..."); + if return_sp < sup_origin.span() { + err.span_note( + return_sp, + &format!("...and is required to live as long as `'static` here{}", postfix), + ); } else { err.span_label( return_sp, - "...is captured and required to live as long as `'static` here", + &format!("...and is required to live as long as `'static` here{}", postfix), ); } + } + } else { + err.span_label( + return_sp, + &format!( + "...is captured and required to live as long as `'static` here{}", + postfix + ), + ); + } - // FIXME: account for the need of parens in `&(dyn Trait + '_)` - let consider = "consider changing the"; - let declare = "to declare that the"; - let arg = match param_info.param.pat.simple_ident() { - Some(simple_ident) => format!("argument `{}`", simple_ident), - None => "the argument".to_string(), - }; - let explicit = - format!("you can add an explicit `{}` lifetime bound", lifetime_name); - let explicit_static = - format!("explicit `'static` bound to the lifetime of {}", arg); - let captures = format!("captures data from {}", arg); - let add_static_bound = - "alternatively, add an explicit `'static` bound to this reference"; - let plus_lt = format!(" + {}", lifetime_name); - for fn_return in fn_returns { - if fn_return.span.desugaring_kind().is_some() { - // Skip `async` desugaring `impl Future`. - continue; + debug!("try_report_static_impl_trait: fn_return={:?}", fn_returns); + // FIXME: account for the need of parens in `&(dyn Trait + '_)` + let consider = "consider changing the"; + let declare = "to declare that the"; + let arg = match param.param.pat.simple_ident() { + Some(simple_ident) => format!("argument `{}`", simple_ident), + None => "the argument".to_string(), + }; + let explicit = format!("you can add an explicit `{}` lifetime bound", lifetime_name); + let explicit_static = format!("explicit `'static` bound to the lifetime of {}", arg); + let captures = format!("captures data from {}", arg); + let add_static_bound = "alternatively, add an explicit `'static` bound to this reference"; + let plus_lt = format!(" + {}", lifetime_name); + for fn_return in fn_returns { + if fn_return.span.desugaring_kind().is_some() { + // Skip `async` desugaring `impl Future`. + continue; + } + match fn_return.kind { + TyKind::OpaqueDef(item_id, _) => { + let item = tcx.hir().item(item_id.id); + let opaque = if let ItemKind::OpaqueTy(opaque) = &item.kind { + opaque + } else { + err.emit(); + return Some(ErrorReported); + }; + + if let Some(span) = opaque + .bounds + .iter() + .filter_map(|arg| match arg { + GenericBound::Outlives(Lifetime { + name: LifetimeName::Static, + span, + .. + }) => Some(*span), + _ => None, + }) + .next() + { + err.span_suggestion_verbose( + span, + &format!("{} `impl Trait`'s {}", consider, explicit_static), + lifetime_name.clone(), + Applicability::MaybeIncorrect, + ); + err.span_suggestion_verbose( + param.param_ty_span, + add_static_bound, + param.param_ty.to_string(), + Applicability::MaybeIncorrect, + ); + } else if let Some(_) = opaque + .bounds + .iter() + .filter_map(|arg| match arg { + GenericBound::Outlives(Lifetime { name, span, .. }) + if name.ident().to_string() == lifetime_name => + { + Some(*span) + } + _ => None, + }) + .next() + { + } else { + err.span_suggestion_verbose( + fn_return.span.shrink_to_hi(), + &format!( + "{declare} `impl Trait` {captures}, {explicit}", + declare = declare, + captures = captures, + explicit = explicit, + ), + plus_lt.clone(), + Applicability::MaybeIncorrect, + ); } - match fn_return.kind { - TyKind::OpaqueDef(item_id, _) => { - let item = self.tcx().hir().item(item_id.id); - let opaque = if let ItemKind::OpaqueTy(opaque) = &item.kind { - opaque - } else { - err.emit(); - return Some(ErrorReported); - }; - - if let Some(span) = opaque - .bounds - .iter() - .filter_map(|arg| match arg { - GenericBound::Outlives(Lifetime { - name: LifetimeName::Static, - span, + } + TyKind::TraitObject(_, lt) => match lt.name { + LifetimeName::ImplicitObjectLifetimeDefault => { + err.span_suggestion_verbose( + fn_return.span.shrink_to_hi(), + &format!( + "{declare} trait object {captures}, {explicit}", + declare = declare, + captures = captures, + explicit = explicit, + ), + plus_lt.clone(), + Applicability::MaybeIncorrect, + ); + } + name if name.ident().to_string() != lifetime_name => { + // With this check we avoid suggesting redundant bounds. This + // would happen if there are nested impl/dyn traits and only + // one of them has the bound we'd suggest already there, like + // in `impl Foo + '_`. + err.span_suggestion_verbose( + lt.span, + &format!("{} trait object's {}", consider, explicit_static), + lifetime_name.clone(), + Applicability::MaybeIncorrect, + ); + err.span_suggestion_verbose( + param.param_ty_span, + add_static_bound, + param.param_ty.to_string(), + Applicability::MaybeIncorrect, + ); + } + _ => {} + }, + _ => {} + } + } + err.emit(); + Some(ErrorReported) + } + + /// When we call a method coming from an `impl Foo for dyn Bar`, `dyn Bar` introduces a default + /// `'static` obligation. Suggest relaxing that implicit bound. + fn find_impl_on_dyn_trait( + &self, + err: &mut DiagnosticBuilder<'_>, + ty: Ty<'_>, + ctxt: &UnifyReceiverContext<'tcx>, + ) -> bool { + let tcx = self.tcx(); + let mut suggested = false; + + // Find the method being called. + let instance = match ty::Instance::resolve( + tcx, + ctxt.param_env, + ctxt.assoc_item.def_id, + self.infcx.resolve_vars_if_possible(&ctxt.substs), + ) { + Ok(Some(instance)) => instance, + _ => return false, + }; + + let mut v = TraitObjectVisitor(vec![]); + v.visit_ty(ty); + + // Get the `Ident` of the method being called and the corresponding `impl` (to point at + // `Bar` in `impl Foo for dyn Bar {}` and the definition of the method being called). + let (ident, self_ty) = match tcx.hir().get_if_local(instance.def_id()) { + Some(Node::ImplItem(ImplItem { ident, hir_id, .. })) => { + match tcx.hir().find(tcx.hir().get_parent_item(*hir_id)) { + Some(Node::Item(Item { kind: ItemKind::Impl { self_ty, .. }, .. })) => { + (ident, self_ty) + } + _ => return false, + } + } + Some(Node::TraitItem(TraitItem { ident, hir_id, .. })) => { + let parent_id = tcx.hir().get_parent_item(*hir_id); + match tcx.hir().find(parent_id) { + Some(Node::Item(Item { kind: ItemKind::Trait(..), .. })) => { + // The method being called is defined in the `trait`, but the `'static` + // obligation comes from the `impl`. Find that `impl` so that we can point + // at it in the suggestion. + let trait_did = tcx.hir().local_def_id(parent_id).to_def_id(); + match tcx + .hir() + .trait_impls(trait_did) + .iter() + .filter_map(|impl_node| { + let impl_did = tcx.hir().local_def_id(*impl_node); + match tcx.hir().get_if_local(impl_did.to_def_id()) { + Some(Node::Item(Item { + kind: ItemKind::Impl { self_ty, .. }, .. - }) => Some(*span), - _ => None, - }) - .next() - { - err.span_suggestion_verbose( - span, - &format!("{} `impl Trait`'s {}", consider, explicit_static), - lifetime_name.clone(), - Applicability::MaybeIncorrect, - ); - err.span_suggestion_verbose( - param_info.param_ty_span, - add_static_bound, - param_info.param_ty.to_string(), - Applicability::MaybeIncorrect, - ); - } else if let Some(_) = opaque - .bounds - .iter() - .filter_map(|arg| match arg { - GenericBound::Outlives(Lifetime { name, span, .. }) - if name.ident().to_string() == lifetime_name => + })) if v.0.iter().all(|did| { + // FIXME: we should check `self_ty` against the receiver + // type in the `UnifyReceiver` context, but for now, use + // this imperfect proxy. This will fail if there are + // multiple `impl`s for the same trait like + // `impl Foo for Box` and `impl Foo for dyn Bar`. + // In that case, only the first one will get suggestions. + let mut hir_v = HirTraitObjectVisitor(vec![], *did); + hir_v.visit_ty(self_ty); + !hir_v.0.is_empty() + }) => { - Some(*span) + Some(self_ty) } _ => None, - }) - .next() - { - } else { - err.span_suggestion_verbose( - fn_return.span.shrink_to_hi(), - &format!( - "{declare} `impl Trait` {captures}, {explicit}", - declare = declare, - captures = captures, - explicit = explicit, - ), - plus_lt.clone(), - Applicability::MaybeIncorrect, - ); - } + } + }) + .next() + { + Some(self_ty) => (ident, self_ty), + _ => return false, } - TyKind::TraitObject(_, lt) => match lt.name { - LifetimeName::ImplicitObjectLifetimeDefault => { - err.span_suggestion_verbose( - fn_return.span.shrink_to_hi(), - &format!( - "{declare} trait object {captures}, {explicit}", - declare = declare, - captures = captures, - explicit = explicit, - ), - plus_lt.clone(), - Applicability::MaybeIncorrect, - ); - } - name if name.ident().to_string() != lifetime_name => { - // With this check we avoid suggesting redundant bounds. This - // would happen if there are nested impl/dyn traits and only - // one of them has the bound we'd suggest already there, like - // in `impl Foo + '_`. - err.span_suggestion_verbose( - lt.span, - &format!("{} trait object's {}", consider, explicit_static), - lifetime_name.clone(), - Applicability::MaybeIncorrect, - ); - err.span_suggestion_verbose( - param_info.param_ty_span, - add_static_bound, - param_info.param_ty.to_string(), - Applicability::MaybeIncorrect, - ); - } - _ => {} + } + _ => return false, + } + } + _ => return false, + }; + + // Find the trait object types in the argument, so we point at *only* the trait object. + for found_did in &v.0 { + let mut hir_v = HirTraitObjectVisitor(vec![], *found_did); + hir_v.visit_ty(self_ty); + for span in &hir_v.0 { + let mut multi_span: MultiSpan = vec![*span].into(); + multi_span.push_span_label( + *span, + "this has an implicit `'static` lifetime requirement".to_string(), + ); + multi_span.push_span_label( + ident.span, + "calling this method introduces the `impl`'s 'static` requirement".to_string(), + ); + err.span_note( + multi_span, + &format!( + "{} has a `'static` requirement", + match ctxt.assoc_item.container { + AssocItemContainer::TraitContainer(id) => + format!("`impl` of `{}`", tcx.def_path_str(id)), + AssocItemContainer::ImplContainer(_) => "inherent `impl`".to_string(), }, - _ => {} + ), + ); + err.span_suggestion_verbose( + span.shrink_to_hi(), + "consider relaxing the implicit `'static` requirement", + " + '_".to_string(), + Applicability::MaybeIncorrect, + ); + suggested = true; + } + } + suggested + } +} + +/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime. +struct TraitObjectVisitor(Vec); + +impl TypeVisitor<'_> for TraitObjectVisitor { + fn visit_ty(&mut self, t: Ty<'_>) -> bool { + match t.kind { + ty::Dynamic(preds, RegionKind::ReStatic) => { + if let Some(def_id) = preds.principal_def_id() { + self.0.push(def_id); + } + false + } + _ => t.super_visit_with(self), + } + } +} + +/// Collect all `hir::Ty<'_>` `Span`s for trait objects with an implicit lifetime. +struct HirTraitObjectVisitor(Vec, DefId); + +impl<'tcx> Visitor<'tcx> for HirTraitObjectVisitor { + type Map = ErasedMap<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap { + NestedVisitorMap::None + } + + fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) { + match t.kind { + TyKind::TraitObject( + poly_trait_refs, + Lifetime { name: LifetimeName::ImplicitObjectLifetimeDefault, .. }, + ) => { + for ptr in poly_trait_refs { + if Some(self.1) == ptr.trait_ref.trait_def_id() { + self.0.push(ptr.span); } } - err.emit(); - return Some(ErrorReported); } + _ => {} } - None + walk_ty(self, t); } } diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs index fa999abb1a86c..28e9dd90cfd67 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs @@ -7,20 +7,18 @@ use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::{self, DefIdTree, Region, Ty}; use rustc_span::Span; -// The struct contains the information about the anonymous region -// we are searching for. +/// Information about the anonymous region we are searching for. #[derive(Debug)] pub(super) struct AnonymousParamInfo<'tcx> { - // the parameter corresponding to the anonymous region + /// The parameter corresponding to the anonymous region. pub param: &'tcx hir::Param<'tcx>, - // the type corresponding to the anonymopus region parameter + /// The type corresponding to the anonymous region parameter. pub param_ty: Ty<'tcx>, - // the ty::BoundRegion corresponding to the anonymous region + /// The ty::BoundRegion corresponding to the anonymous region. pub bound_region: ty::BoundRegion, - // param_ty_span contains span of parameter type + /// The `Span` of the parameter type. pub param_ty_span: Span, - // corresponds to id the argument is the first parameter - // in the declaration + /// Signals that the argument is the first parameter in the declaration. pub is_first: bool, } diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs index 00503a6992875..b76d8edd70839 100644 --- a/src/librustc_infer/infer/mod.rs +++ b/src/librustc_infer/infer/mod.rs @@ -463,7 +463,7 @@ pub enum RegionVariableOrigin { AddrOfRegion(Span), /// Regions created as part of an autoref of a method receiver - Autoref(Span), + Autoref(Span, ty::AssocItem), /// Regions created as part of an automatic coercion Coercion(Span), @@ -1798,15 +1798,15 @@ impl<'tcx> SubregionOrigin<'tcx> { impl RegionVariableOrigin { pub fn span(&self) -> Span { match *self { - MiscVariable(a) => a, - PatternRegion(a) => a, - AddrOfRegion(a) => a, - Autoref(a) => a, - Coercion(a) => a, - EarlyBoundRegion(a, ..) => a, - LateBoundRegion(a, ..) => a, + MiscVariable(a) + | PatternRegion(a) + | AddrOfRegion(a) + | Autoref(a, _) + | Coercion(a) + | EarlyBoundRegion(a, ..) + | LateBoundRegion(a, ..) + | UpvarRegion(_, a) => a, BoundRegionInCoherence(_) => rustc_span::DUMMY_SP, - UpvarRegion(_, a) => a, NLL(..) => bug!("NLL variable used with `span`"), } } diff --git a/src/librustc_infer/lib.rs b/src/librustc_infer/lib.rs index 0cd6585163c4e..bacb7fa153e43 100644 --- a/src/librustc_infer/lib.rs +++ b/src/librustc_infer/lib.rs @@ -13,6 +13,7 @@ //! This API is completely unstable and subject to change. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] +#![feature(bindings_after_at)] #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index c83f1171735ef..5b648608b6b43 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -235,13 +235,8 @@ pub fn get_codegen_backend(sess: &Session) -> Box { static mut LOAD: fn() -> Box = || unreachable!(); INIT.call_once(|| { - let codegen_name = sess - .opts - .debugging_opts - .codegen_backend - .as_ref() - .unwrap_or(&sess.target.target.options.codegen_backend); - let backend = match &codegen_name[..] { + let codegen_name = sess.opts.debugging_opts.codegen_backend.as_deref().unwrap_or("llvm"); + let backend = match codegen_name { filename if filename.contains('.') => load_backend_from_dylib(filename.as_ref()), codegen_name => get_builtin_codegen_backend(codegen_name), }; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 46741fcf2ba0c..7014722bab824 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -531,6 +531,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { match ty.kind { ty::FnPtr(_) => true, ty::Ref(..) => true, + ty::Adt(def, _) + if def.is_box() && matches!(self.mode, ImproperCTypesMode::Definitions) => + { + true + } ty::Adt(def, substs) if def.repr.transparent() && !def.is_union() => { let guaranteed_nonnull_optimization = self .cx @@ -558,7 +563,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } /// Check if this enum can be safely exported based on the "nullable pointer optimization". - /// Currently restricted to function pointers, references, `core::num::NonZero*`, + /// Currently restricted to function pointers, boxes, references, `core::num::NonZero*`, /// `core::ptr::NonNull`, and `#[repr(transparent)]` newtypes. fn is_repr_nullable_ptr( &self, @@ -692,6 +697,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } match ty.kind { + ty::Adt(def, _) + if def.is_box() && matches!(self.mode, ImproperCTypesMode::Definitions) => + { + FfiSafe + } + ty::Adt(def, substs) => { if def.is_phantom_data() { return FfiPhantom(ty); diff --git a/src/librustc_middle/traits/mod.rs b/src/librustc_middle/traits/mod.rs index c15c31a53f0c9..d2747e5fc659b 100644 --- a/src/librustc_middle/traits/mod.rs +++ b/src/librustc_middle/traits/mod.rs @@ -169,6 +169,13 @@ impl<'tcx> ObligationCause<'tcx> { } } +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct UnifyReceiverContext<'tcx> { + pub assoc_item: ty::AssocItem, + pub param_env: ty::ParamEnv<'tcx>, + pub substs: SubstsRef<'tcx>, +} + #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum ObligationCauseCode<'tcx> { /// Not well classified or should be obvious from the span. @@ -300,6 +307,8 @@ pub enum ObligationCauseCode<'tcx> { /// Method receiver MethodReceiver, + UnifyReceiver(Box>), + /// `return` with no expression ReturnNoExpression, diff --git a/src/librustc_middle/traits/structural_impls.rs b/src/librustc_middle/traits/structural_impls.rs index 334462790edbc..18b4371053a89 100644 --- a/src/librustc_middle/traits/structural_impls.rs +++ b/src/librustc_middle/traits/structural_impls.rs @@ -213,12 +213,26 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::StartFunctionType => Some(super::StartFunctionType), super::IntrinsicType => Some(super::IntrinsicType), super::MethodReceiver => Some(super::MethodReceiver), + super::UnifyReceiver(ref ctxt) => tcx.lift(ctxt).map(|ctxt| super::UnifyReceiver(ctxt)), super::BlockTailExpression(id) => Some(super::BlockTailExpression(id)), super::TrivialBound => Some(super::TrivialBound), } } } +impl<'a, 'tcx> Lift<'tcx> for traits::UnifyReceiverContext<'a> { + type Lifted = traits::UnifyReceiverContext<'tcx>; + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { + tcx.lift(&self.param_env).and_then(|param_env| { + tcx.lift(&self.substs).map(|substs| traits::UnifyReceiverContext { + assoc_item: self.assoc_item, + param_env, + substs, + }) + }) + } +} + impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> { type Lifted = traits::DerivedObligationCause<'tcx>; fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index b3cfcc0f4c2a8..0178f7b8d93ac 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -136,7 +136,7 @@ pub struct ResolverOutputs { pub extern_prelude: FxHashMap, } -#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Hash)] pub enum AssocItemContainer { TraitContainer(DefId), ImplContainer(DefId), @@ -184,7 +184,7 @@ pub enum ImplPolarity { Reservation, } -#[derive(Copy, Clone, Debug, PartialEq, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, HashStable, Eq, Hash)] pub struct AssocItem { pub def_id: DefId, #[stable_hasher(project(name))] @@ -199,7 +199,7 @@ pub struct AssocItem { pub fn_has_self_parameter: bool, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, HashStable, Eq, Hash)] pub enum AssocKind { Const, Fn, @@ -316,7 +316,7 @@ impl<'tcx> AssociatedItems<'tcx> { } } -#[derive(Clone, Debug, PartialEq, Eq, Copy, RustcEncodable, RustcDecodable, HashStable)] +#[derive(Clone, Debug, PartialEq, Eq, Copy, RustcEncodable, RustcDecodable, HashStable, Hash)] pub enum Visibility { /// Visible everywhere (including in other crates). Public, diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index 0d5bd4c7e61b9..eaef6bb37faa5 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -188,10 +188,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let ptr_ty = ptr.ty; // Create an *internal* temp for the pointer, so that unsafety // checking won't complain about the raw pointer assignment. - let ptr_temp = this.local_decls.push(LocalDecl::with_source_info( - ptr_ty, - source_info, - ).internal()); + let ptr_temp = this + .local_decls + .push(LocalDecl::with_source_info(ptr_ty, source_info).internal()); let ptr_temp = Place::from(ptr_temp); let block = unpack!(this.into(ptr_temp, block, ptr)); this.into(this.hir.tcx().mk_place_deref(ptr_temp), block, val) @@ -224,7 +223,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Some((destination, success)) }, from_hir_call, - fn_span + fn_span, }, ); success.unit() @@ -387,15 +386,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // These cases don't actually need a destination ExprKind::Assign { .. } | ExprKind::AssignOp { .. } - | ExprKind::Continue { .. } - | ExprKind::Break { .. } - | ExprKind::LlvmInlineAsm { .. } - | ExprKind::Return { .. } => { + | ExprKind::LlvmInlineAsm { .. } => { unpack!(block = this.stmt_expr(block, expr, None)); this.cfg.push_assign_unit(block, source_info, destination, this.hir.tcx()); block.unit() } + ExprKind::Continue { .. } | ExprKind::Break { .. } | ExprKind::Return { .. } => { + unpack!(block = this.stmt_expr(block, expr, None)); + // No assign, as these have type `!`. + block.unit() + } + // Avoid creating a temporary ExprKind::VarRef { .. } | ExprKind::SelfRef diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 4a2dd8913185f..231ab1ea68ded 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -938,9 +938,6 @@ pub struct TargetOptions { /// for this target unconditionally. pub no_builtins: bool, - /// The codegen backend to use for this target, typically "llvm" - pub codegen_backend: String, - /// The default visibility for symbols in this target should be "hidden" /// rather than "default" pub default_hidden_visibility: bool, @@ -1068,7 +1065,6 @@ impl Default for TargetOptions { requires_lto: false, singlethread: false, no_builtins: false, - codegen_backend: "llvm".to_string(), default_hidden_visibility: false, emit_debug_gdb_scripts: true, requires_uwtable: false, @@ -1461,7 +1457,6 @@ impl Target { key!(requires_lto, bool); key!(singlethread, bool); key!(no_builtins, bool); - key!(codegen_backend); key!(default_hidden_visibility, bool); key!(emit_debug_gdb_scripts, bool); key!(requires_uwtable, bool); @@ -1699,7 +1694,6 @@ impl ToJson for Target { target_option_val!(requires_lto); target_option_val!(singlethread); target_option_val!(no_builtins); - target_option_val!(codegen_backend); target_option_val!(default_hidden_visibility); target_option_val!(emit_debug_gdb_scripts); target_option_val!(requires_uwtable); diff --git a/src/librustc_trait_selection/traits/codegen/mod.rs b/src/librustc_trait_selection/traits/codegen/mod.rs index cf575d3eca9c2..dd7ea55cc1043 100644 --- a/src/librustc_trait_selection/traits/codegen/mod.rs +++ b/src/librustc_trait_selection/traits/codegen/mod.rs @@ -6,6 +6,7 @@ use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::traits::{ FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine, + Unimplemented, }; use rustc_errors::ErrorReported; use rustc_middle::ty::fold::TypeFoldable; @@ -58,6 +59,18 @@ pub fn codegen_fulfill_obligation<'tcx>( ); return Err(ErrorReported); } + Err(Unimplemented) => { + // This can trigger when we probe for the source of a `'static` lifetime requirement + // on a trait object: `impl Foo for dyn Trait {}` has an implicit `'static` bound. + infcx.tcx.sess.delay_span_bug( + rustc_span::DUMMY_SP, + &format!( + "Encountered error `Unimplemented` selecting `{:?}` during codegen", + trait_ref + ), + ); + return Err(ErrorReported); + } Err(e) => { bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref) } diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index 2c6589eb2bdf9..8ef15707f5f5a 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1706,6 +1706,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { | ObligationCauseCode::IntrinsicType | ObligationCauseCode::MethodReceiver | ObligationCauseCode::ReturnNoExpression + | ObligationCauseCode::UnifyReceiver(..) | ObligationCauseCode::MiscObligation => {} ObligationCauseCode::SliceOrArrayElem => { err.note("slice and array elements must have `Sized` type"); diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 0ca85b5165ea0..5f6cb830678da 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -6,6 +6,7 @@ use crate::hir::def_id::DefId; use crate::hir::GenericArg; use rustc_hir as hir; use rustc_infer::infer::{self, InferOk}; +use rustc_middle::traits::{ObligationCauseCode, UnifyReceiverContext}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast}; use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::fold::TypeFoldable; @@ -91,7 +92,11 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // signature (which is also done during probing). let method_sig_rcvr = self.normalize_associated_types_in(self.span, &method_sig.inputs()[0]); - self.unify_receivers(self_ty, method_sig_rcvr); + debug!( + "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_predicates={:?}", + self_ty, method_sig_rcvr, method_sig, method_predicates + ); + self.unify_receivers(self_ty, method_sig_rcvr, &pick, all_substs); let (method_sig, method_predicates) = self.normalize_associated_types_in(self.span, &(method_sig, method_predicates)); @@ -150,7 +155,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false)); if let Some(mutbl) = pick.autoref { - let region = self.next_region_var(infer::Autoref(self.span)); + let region = self.next_region_var(infer::Autoref(self.span, pick.item)); target = self.tcx.mk_ref(region, ty::TypeAndMut { mutbl, ty: target }); let mutbl = match mutbl { hir::Mutability::Not => AutoBorrowMutability::Not, @@ -334,8 +339,26 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ) } - fn unify_receivers(&mut self, self_ty: Ty<'tcx>, method_self_ty: Ty<'tcx>) { - match self.at(&self.misc(self.span), self.param_env).sup(method_self_ty, self_ty) { + fn unify_receivers( + &mut self, + self_ty: Ty<'tcx>, + method_self_ty: Ty<'tcx>, + pick: &probe::Pick<'tcx>, + substs: SubstsRef<'tcx>, + ) { + debug!( + "unify_receivers: self_ty={:?} method_self_ty={:?} span={:?} pick={:?}", + self_ty, method_self_ty, self.span, pick + ); + let cause = self.cause( + self.span, + ObligationCauseCode::UnifyReceiver(Box::new(UnifyReceiverContext { + assoc_item: pick.item, + param_env: self.param_env, + substs, + })), + ); + match self.at(&cause, self.param_env).sup(method_self_ty, self_ty) { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6a52974534f8b..7c4420cf1ddbc 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -320,7 +320,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name; let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name; - let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; + let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; // In addition to those specific lints, we also need to allow those given through // command line, otherwise they'll get ignored and we don't want that. @@ -330,12 +330,12 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt missing_doc_example.to_owned(), private_doc_tests.to_owned(), no_crate_level_docs.to_owned(), - invalid_codeblock_attribute_name.to_owned(), + invalid_codeblock_attributes_name.to_owned(), ]; let (lint_opts, lint_caps) = init_lints(allowed_lints, lint_opts, |lint| { if lint.name == intra_link_resolution_failure_name - || lint.name == invalid_codeblock_attribute_name + || lint.name == invalid_codeblock_attributes_name { None } else { diff --git a/src/librustdoc/html/static/normalize.css b/src/librustdoc/html/static/normalize.css index 2804c26a29662..0e0426279183f 100644 --- a/src/librustdoc/html/static/normalize.css +++ b/src/librustdoc/html/static/normalize.css @@ -1 +1,2 @@ +/* ignore-tidy-linelength */ /*! normalize.css v3.0.0 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index f5551446bf220..38709b445efae 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -49,9 +49,9 @@ } * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } /* This part handles the "default" theme being used depending on the system one. */ @@ -91,7 +91,8 @@ h2 { h3 { font-size: 1.3em; } -h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { +h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important), +h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { font-weight: 500; margin: 20px 0 15px 0; padding-bottom: 6px; @@ -103,7 +104,8 @@ h1.fqn { h1.fqn > .in-band > a:hover { text-decoration: underline; } -h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { +h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { border-bottom: 1px solid; } h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant { @@ -1123,7 +1125,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { /* The margin on the tooltip does not capture hover events, this extends the area of hover enough so that mouse hover is not lost when moving the mouse to the tooltip */ - content: "\00a0\00a0\00a0"; + content: "\00a0\00a0\00a0"; } .important-traits .important, .important-traits .docblock { @@ -1131,13 +1133,12 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { } .important-traits .docblock code.content{ - margin: 0; - padding: 0; - font-size: 20px; + margin: 0; + padding: 0; + font-size: 20px; } -/* Example code has the "Run" button that - needs to be positioned relative to the pre */ +/* Example code has the "Run" button that needs to be positioned relative to the pre */ pre.rust.rust-example-rendered { position: relative; } diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index 1326acec51ce1..e0ab7170ea877 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -10,7 +10,8 @@ body { color: #c5c5c5; } -h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod) { color: white; } h1.fqn { @@ -41,13 +42,13 @@ h3 > code, h4 > code, h5 > code { color: #e6e1cf; } pre > code { - color: #e6e1cf; + color: #e6e1cf; } span code { - color: #e6e1cf; + color: #e6e1cf; } .docblock a > code { - color: #39AFD7 !important; + color: #39AFD7 !important; } .docblock code, .docblock-short code { background-color: #191f26; @@ -100,11 +101,11 @@ pre { } .sidebar-elems .location { - color: #ff7733; + color: #ff7733; } .sidebar-elems .location a { - color: #fff; + color: #fff; } .sidebar .version { @@ -123,9 +124,9 @@ pre { .line-numbers span { color: #5c6773ab; } .line-numbers .line-highlighted { - background-color: rgba(255, 236, 164, 0.06) !important; - padding-right: 4px; - border-right: 1px solid #ffb44c; + background-color: rgba(255, 236, 164, 0.06) !important; + padding-right: 4px; + border-right: 1px solid #ffb44c; } .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { @@ -168,31 +169,31 @@ pre { .content span.keyword, .content a.keyword { color: #de5249; } .content span.externcrate, .content span.mod, .content a.mod { - color: #acccf9; + color: #acccf9; } .content span.struct, .content a.struct { - color: #ffa0a5; + color: #ffa0a5; } .content span.enum, .content a.enum { - color: #99e0c9; + color: #99e0c9; } .content span.trait, .content a.trait { - color: #39AFD7; + color: #39AFD7; } .content span.type, .content a.type { - color: #cfbcf5; + color: #cfbcf5; } .content span.fn, .content a.fn, .content span.method, .content a.method, .content span.tymethod, .content a.tymethod, .content .fnname { - color: #fdd687; + color: #fdd687; } .content span.attr, .content a.attr, .content span.derive, .content a.derive, .content span.macro, .content a.macro { - color: #a37acc; + color: #a37acc; } -pre.rust .comment, pre.rust .doccomment { +pre.rust .comment, pre.rust .doccomment { color: #788797; font-style: italic; } @@ -228,14 +229,24 @@ a { } .search-input { - color: #ffffff; - background-color: #141920; - box-shadow: 0 0 0 1px #424c57,0 0 0 2px transparent; - transition: box-shadow 150ms ease-in-out; + color: #ffffff; + background-color: #141920; + box-shadow: 0 0 0 1px #424c57,0 0 0 2px transparent; + transition: box-shadow 150ms ease-in-out; } #crate-search+.search-input:focus { - box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent; + box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent; + color: #ffffff; + background-color: #141920; + box-shadow: none; + transition: box-shadow 150ms ease-in-out; + border-radius: 4px; + margin-left: 8px; +} + +#crate-search+.search-input:focus { + box-shadow: 0px 6px 20px 0px black; } .search-focus:disabled { @@ -249,7 +260,7 @@ a { .stab.unstable, .stab.deprecated, .stab.portability { - color: #c5c5c5; + color: #c5c5c5; background: #314559 !important; border-style: none !important; border-radius: 4px; @@ -262,10 +273,10 @@ a { } #help > div { - background: #14191f; - box-shadow: 0px 6px 20px 0px black; - border: none; - border-radius: 4px; + background: #14191f; + box-shadow: 0px 6px 20px 0px black; + border: none; + border-radius: 4px; } .since { @@ -288,14 +299,14 @@ pre.rust .question-mark { color: #ff9011; } pre.rust .self { - color: #36a3d9; - font-style: italic; + color: #36a3d9; + font-style: italic; } pre.rust .attribute { - color: #e6e1cf; + color: #e6e1cf; } pre.rust .attribute .ident, pre.rust .attribute .op { - color: #e6e1cf; + color: #e6e1cf; } .example-wrap > pre.line-number { @@ -304,15 +315,15 @@ pre.rust .attribute .ident, pre.rust .attribute .op { } a.test-arrow { - font-size: 100%; - color: #788797; - border-radius: 4px; - background-color: rgba(255, 255, 255, 0); + font-size: 100%; + color: #788797; + border-radius: 4px; + background-color: rgba(255, 255, 255, 0); } a.test-arrow:hover { - background-color: rgba(242, 151, 24, 0.05); - color: #ffb44c; + background-color: rgba(242, 151, 24, 0.05); + color: #ffb44c; } .toggle-label { @@ -377,9 +388,9 @@ pre.ignore:hover, .information:hover + pre.ignore { } .tooltip .tooltiptext { - background-color: #314559; - color: #c5c5c5; - border: 1px solid #5c6773; + background-color: #314559; + color: #c5c5c5; + border: 1px solid #5c6773; } .tooltip .tooltiptext::after { @@ -387,12 +398,12 @@ pre.ignore:hover, .information:hover + pre.ignore { } .important-traits-tooltiptext { - background-color: #314559; - border-color: #5c6773; + background-color: #314559; + border-color: #5c6773; } #titles > div.selected { - background-color: #141920 !important; + background-color: #141920 !important; border-bottom: 1px solid #ffb44c !important; border-top: none; } @@ -403,7 +414,7 @@ pre.ignore:hover, .information:hover + pre.ignore { } #titles > div:hover { - border-bottom: 1px solid rgba(242, 151, 24, 0.3); + border-bottom: 1px solid rgba(242, 151, 24, 0.3); } #titles > div > div.count { @@ -413,12 +424,13 @@ pre.ignore:hover, .information:hover + pre.ignore { /* rules that this theme does not need to set, here to satisfy the rule checker */ /* note that a lot of these are partially set in some way (meaning they are set individually rather than as a group) */ -/* TODO: these rules should be at the bottom of the file but currently must be +/* FIXME: these rules should be at the bottom of the file but currently must be above the `@media (max-width: 700px)` rules due to a bug in the css checker */ /* see https://github.com/rust-lang/rust/pull/71237#issuecomment-618170143 */ .content .highlighted.mod, .content .highlighted.externcrate {} .search-input:focus {} -.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {} +.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive, +.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {} .content .highlighted.trait {} .content span.struct,.content a.struct,.block a.current.struct {} #titles>div:hover,#titles>div.selected {} @@ -433,16 +445,20 @@ pre.rust .lifetime {} .content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod {} h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod) {} .content span.enum,.content a.enum,.block a.current.enum {} -.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static {} +.content span.constant,.content a.constant,.block a.current.constant,.content span.static, +.content a.static,.block a.current.static {} .content span.keyword,.content a.keyword,.block a.current.keyword {} pre.rust .comment {} .content .highlighted.enum {} .content .highlighted.struct {} .content .highlighted.keyword {} .content span.traitalias,.content a.traitalias,.block a.current.traitalias {} -.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname {} +.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method, +.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod, +.content .fnname {} pre.rust .kw {} -pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident {} +pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute, +pre.rust .attribute .ident {} .content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype {} pre.rust .doccomment {} .stab.deprecated {} @@ -483,11 +499,11 @@ kbd { #theme-picker, #settings-menu { border-color: #5c6773; - background-color: #0f1419; + background-color: #0f1419; } #theme-picker > img, #settings-menu > img { - filter: invert(100); + filter: invert(100); } #theme-picker:hover, #theme-picker:focus, diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index dc15220aa0690..33c0f885fa95b 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -3,13 +3,15 @@ body { color: #ddd; } -h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod) { color: #ddd; } h1.fqn { border-bottom-color: #d2d2d2; } -h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod) { border-bottom-color: #d2d2d2; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 64d59ca411a87..569ce7da2091f 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -5,13 +5,15 @@ body { color: black; } -h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod) { color: black; } h1.fqn { border-bottom-color: #D5D5D5; } -h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), +h4:not(.method):not(.type):not(.tymethod) { border-bottom-color: #DDDDDD; } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index c2d644bdd05f1..e8ea71997109a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -45,14 +45,14 @@ pub struct TestOptions { pub fn run(options: Options) -> Result<(), String> { let input = config::Input::File(options.input.clone()); - let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; + let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; // In addition to those specific lints, we also need to allow those given through // command line, otherwise they'll get ignored and we don't want that. - let allowed_lints = vec![invalid_codeblock_attribute_name.to_owned()]; + let allowed_lints = vec![invalid_codeblock_attributes_name.to_owned()]; let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| { - if lint.name == invalid_codeblock_attribute_name { + if lint.name == invalid_codeblock_attributes_name { None } else { Some((lint.name_lower(), lint::Allow)) diff --git a/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir b/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir index f65b93a34da65..918dc5ec38701 100644 --- a/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir +++ b/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir @@ -79,13 +79,6 @@ fn main() -> () { } bb10: { - _4 = const (); // scope 0 at $DIR/issue-49232.rs:10:25: 10:30 - // ty::Const - // + ty: () - // + val: Value(Scalar()) - // mir::Constant - // + span: $DIR/issue-49232.rs:10:25: 10:30 - // + literal: Const { ty: (), val: Value(Scalar()) } unreachable; // scope 0 at $DIR/issue-49232.rs:10:25: 10:30 } diff --git a/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff index 91baac8611296..7739ef87fb9b7 100644 --- a/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff @@ -26,27 +26,21 @@ let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _26: [&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _27: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _28: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _29: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _30: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _31: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _32: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _33: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _34: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let _35: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let _36: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _37: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _38: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _39: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _40: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _41: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _44: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _45: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _47: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _48: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _49: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _27: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _28: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _29: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _30: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _31: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _32: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _33: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _34: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _35: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _38: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _39: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _40: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _41: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _42: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _43: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -54,39 +48,39 @@ debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 let _13: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _51: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _45: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _42: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _43: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _50: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _36: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _37: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _44: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _42; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - debug arg1 => _43; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg0 => _36; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _37; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 6 { - debug x => _45; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug f => _46; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _52: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _53: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _54: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _55: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL } scope 8 { - debug x => _48; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug f => _49; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _56: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _57: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _58: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _59: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL } } scope 10 { debug pieces => _23; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug args => _33; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _60: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _61: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _62: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL } } } @@ -150,14 +144,14 @@ StorageLive(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _10 = &_1; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _45 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) } - _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _11 = _45; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL @@ -217,53 +211,53 @@ StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_25); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _44 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) } - _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _25 = _44; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_35); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_38); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_39); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _39 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _38 = &_39; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_40); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_41); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _41 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _40 = &_41; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - (_37.0: &&i32) = move _38; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - (_37.1: &&i32) = move _40; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_40); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_38); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_42); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _42 = (_37.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_43); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _43 = (_37.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_45); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _45 = _42; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_46); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _46 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_27); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_28); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_29); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_30); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_31); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_33); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _33 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _32 = &_33; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_34); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_35); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _35 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _34 = &_35; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_31.0: &&i32) = move _32; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_32); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_36); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_38); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _39 = _36; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _40 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} // + val: Value(Scalar()) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _53 = _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _52 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _53) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _46 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} // + val: Value(Scalar()) @@ -273,11 +267,11 @@ } bb6: { - StorageDead(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _55 = _45; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _54 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _55) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _48 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} // + val: Value(Scalar()) @@ -287,28 +281,28 @@ } bb7: { - StorageDead(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_44.0: &core::fmt::Opaque) = move _54; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_44.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _52; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_45); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_48); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _48 = _43; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_49); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _49 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_41); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_42); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _42 = _37; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_43); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _43 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} // + val: Value(Scalar()) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _57 = _49; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _56 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _57) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _50 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} // + val: Value(Scalar()) @@ -318,11 +312,11 @@ } bb8: { - StorageDead(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _59 = _48; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _58 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _59) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _52 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} // + val: Value(Scalar()) @@ -332,35 +326,35 @@ } bb9: { - StorageDead(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_47.0: &core::fmt::Opaque) = move _58; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_47.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _56; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_49); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_48); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - _36 = [move _44, move _47]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_43); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_42); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _35 = &_36; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _34 = _35; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _33 = move _34 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _60 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - discriminant(_61) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _62 = _33; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _60; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _61; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _62; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_43); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_42); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_41); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_38); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _29 = &_30; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _28 = _29; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_28); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_27); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL _20 = _21; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL diff --git a/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff index 0da748d79ebdd..c4d0a6f4bc6aa 100644 --- a/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff @@ -26,27 +26,21 @@ let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _26: [&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _27: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _28: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _29: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _30: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _31: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _32: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _33: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _34: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let _35: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let _36: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _37: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _38: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _39: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _40: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _41: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _44: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _45: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _47: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _48: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _49: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _27: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _28: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _29: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _30: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _31: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _32: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _33: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _34: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _35: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _38: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _39: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _40: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _41: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _42: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _43: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -54,39 +48,39 @@ debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 let _13: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _51: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _45: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _42: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let _43: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - let mut _50: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _36: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _37: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _44: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _42; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - debug arg1 => _43; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg0 => _36; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _37; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL scope 6 { - debug x => _45; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug f => _46; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _52: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _53: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _54: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _55: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL } scope 8 { - debug x => _48; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug f => _49; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _56: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _57: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _58: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _59: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL } } scope 10 { debug pieces => _23; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - debug args => _33; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - let mut _60: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _61: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL - let mut _62: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL } } } @@ -150,14 +144,14 @@ StorageLive(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _10 = &_1; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _45 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) } - _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _11 = _45; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL @@ -217,53 +211,53 @@ StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_25); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _44 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) } - _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _25 = _44; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_35); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_38); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_39); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _39 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _38 = &_39; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_40); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_41); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _41 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _40 = &_41; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - (_37.0: &&i32) = move _38; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - (_37.1: &&i32) = move _40; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_40); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_38); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_42); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _42 = (_37.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_43); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _43 = (_37.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_45); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _45 = _42; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_46); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _46 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_27); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_28); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_29); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_30); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_31); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_33); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _33 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _32 = &_33; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_34); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_35); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _35 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _34 = &_35; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_31.0: &&i32) = move _32; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_32); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_36); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_38); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _39 = _36; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _40 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} // + val: Value(Scalar()) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _53 = _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _52 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _53) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _46 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} // + val: Value(Scalar()) @@ -273,11 +267,11 @@ } bb6: { - StorageDead(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _55 = _45; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _54 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _55) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _48 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} // + val: Value(Scalar()) @@ -287,28 +281,28 @@ } bb7: { - StorageDead(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_44.0: &core::fmt::Opaque) = move _54; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_44.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _52; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_45); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_48); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _48 = _43; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - StorageLive(_49); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL - _49 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_41); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_42); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _42 = _37; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_43); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _43 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL // ty::Const // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} // + val: Value(Scalar()) // mir::Constant // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _57 = _49; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _56 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _57) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _50 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} // + val: Value(Scalar()) @@ -318,11 +312,11 @@ } bb8: { - StorageDead(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _59 = _48; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _58 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _59) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _52 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL // ty::Const // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} // + val: Value(Scalar()) @@ -332,35 +326,35 @@ } bb9: { - StorageDead(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_47.0: &core::fmt::Opaque) = move _58; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_47.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _56; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_49); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_48); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - _36 = [move _44, move _47]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_43); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_42); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _35 = &_36; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _34 = _35; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - _33 = move _34 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL - StorageLive(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _60 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - discriminant(_61) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageLive(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - _62 = _33; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _60; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _61; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _62; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL - StorageDead(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_43); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_42); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_41); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_38); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _29 = &_30; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _28 = _29; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_28); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_27); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL _20 = _21; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index ee7586bae820a..0e45b6f04a8a4 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -34,27 +34,27 @@ ((::alloc::fmt::format as for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((::core::fmt::Arguments::new_v1 as - fn(&[&str], &[std::fmt::ArgumentV1]) -> std::fmt::Arguments {std::fmt::Arguments::new_v1})((&([("test" - as - &str)] - as - [&str; 1]) - as - &[&str; 1]), - (&(match (() - as - ()) - { - () - => - ([] - as - [std::fmt::ArgumentV1; 0]), - } - as - [std::fmt::ArgumentV1; 0]) - as - &[std::fmt::ArgumentV1; 0])) + fn(&[&'static str], &[std::fmt::ArgumentV1]) -> std::fmt::Arguments {std::fmt::Arguments::new_v1})((&([("test" + as + &str)] + as + [&str; 1]) + as + &[&str; 1]), + (&(match (() + as + ()) + { + () + => + ([] + as + [std::fmt::ArgumentV1; 0]), + } + as + [std::fmt::ArgumentV1; 0]) + as + &[std::fmt::ArgumentV1; 0])) as std::fmt::Arguments)) as std::string::String); diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile index d7d078e56b2e7..0cf5d1855212d 100644 --- a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# only-mingw +# only-windows-gnu all: $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o diff --git a/src/test/run-make-fulldeps/include_bytes_deps/Makefile b/src/test/run-make-fulldeps/include_bytes_deps/Makefile index ce79cec67dc37..f91af88efe1b7 100644 --- a/src/test/run-make-fulldeps/include_bytes_deps/Makefile +++ b/src/test/run-make-fulldeps/include_bytes_deps/Makefile @@ -1,10 +1,6 @@ -include ../tools.mk -# ignore-windows # ignore-freebsd -# FIXME: on windows `rustc --dep-info` produces Makefile dependency with -# windows native paths (e.g. `c:\path\to\libfoo.a`) -# but msys make seems to fail to recognize such paths, so test fails. all: $(RUSTC) --emit dep-info main.rs diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile index 483091ad4ee8b..2037728568e24 100644 --- a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# ignore-windows +# ignore-windows-msvc # # Because of Windows exception handling, the code is not necessarily any shorter. # https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466 diff --git a/src/test/run-make-fulldeps/issue-51671/Makefile b/src/test/run-make-fulldeps/issue-51671/Makefile index 3027ee578c79f..ba3d3b7100745 100644 --- a/src/test/run-make-fulldeps/issue-51671/Makefile +++ b/src/test/run-make-fulldeps/issue-51671/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# ignore-windows +# ignore-windows-msvc all: $(RUSTC) --emit=obj app.rs diff --git a/src/test/run-make-fulldeps/libs-search-path/Makefile b/src/test/run-make-fulldeps/libs-search-path/Makefile deleted file mode 100644 index f31036ffa1959..0000000000000 --- a/src/test/run-make-fulldeps/libs-search-path/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -# only-mingw - -all: empty.rs - cp -r $(shell cygpath -u $(shell $(RUSTC) --print sysroot)) $(TMPDIR)/sysroot - $(RUSTC) --target $(TARGET) --sysroot $(TMPDIR)/sysroot -L$(TMPDIR)/obj -Z print-link-args empty.rs | $(CGREP) 'lib\\crt2.o' - mkdir -p $(TMPDIR)/obj - mv $(TMPDIR)/sysroot/lib/rustlib/$(TARGET)/lib/crt2.o $(TMPDIR)/obj/crt2.o - $(RUSTC) --target $(TARGET) --sysroot $(TMPDIR)/sysroot -L$(TMPDIR)/obj -Z print-link-args empty.rs | $(CGREP) 'obj\\crt2.o' diff --git a/src/test/run-make-fulldeps/libs-search-path/empty.rs b/src/test/run-make-fulldeps/libs-search-path/empty.rs deleted file mode 100644 index f328e4d9d04c3..0000000000000 --- a/src/test/run-make-fulldeps/libs-search-path/empty.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} diff --git a/src/test/run-make-fulldeps/redundant-libs/Makefile b/src/test/run-make-fulldeps/redundant-libs/Makefile index 9486e07d21bf7..8468d102bec83 100644 --- a/src/test/run-make-fulldeps/redundant-libs/Makefile +++ b/src/test/run-make-fulldeps/redundant-libs/Makefile @@ -1,8 +1,6 @@ -include ../tools.mk -ifdef IS_WINDOWS -all: -else +# ignore-windows-msvc # rustc will remove one of the two redundant references to foo below. Depending # on which one gets removed, we'll get a linker error on SOME platforms (like @@ -23,5 +21,3 @@ RUSTC_FLAGS = \ all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz) $(RUSTC) $(RUSTC_FLAGS) main.rs $(call RUN,main) - -endif diff --git a/src/test/run-make-fulldeps/symbol-visibility/Makefile b/src/test/run-make-fulldeps/symbol-visibility/Makefile index 7901866015bf2..dc55c947d89a2 100644 --- a/src/test/run-make-fulldeps/symbol-visibility/Makefile +++ b/src/test/run-make-fulldeps/symbol-visibility/Makefile @@ -1,9 +1,6 @@ include ../tools.mk -# ignore-windows -# -# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't -# seem to work reliably. +# ignore-windows-msvc NM=nm -D CDYLIB_NAME=liba_cdylib.so @@ -19,6 +16,14 @@ EXE_NAME=an_executable COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib endif +ifdef IS_WINDOWS +NM=nm -g +CDYLIB_NAME=liba_cdylib.dll.a +RDYLIB_NAME=liba_rust_dylib.dll.a +EXE_NAME=an_executable.exe +COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dll.a +endif + # `grep` regex for symbols produced by either `legacy` or `v0` mangling RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+" @@ -30,38 +35,38 @@ all: $(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] # Check that a Rust dylib exports its monomorphic functions - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] # Check that a Rust dylib does not export generics if -Zshare-generics=no - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "0" ] # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ] # Check that a Rust dylib does not export generics if -Zshare-generics=no - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ] # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ] # Check the combined case, where we generate a cdylib and an rlib in the same # compilation session: # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] $(RUSTC) -Zshare-generics=yes an_rlib.rs @@ -70,22 +75,22 @@ all: $(RUSTC) -Zshare-generics=yes an_executable.rs # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] # Check that a Rust dylib exports its monomorphic functions, including generics this time - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "1" ] # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ] # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ] diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk index 04bf78ed2105b..1effa46e101eb 100644 --- a/src/test/run-make-fulldeps/tools.mk +++ b/src/test/run-make-fulldeps/tools.mk @@ -150,7 +150,7 @@ ifdef IS_MSVC $(CC) $< -link -dll -out:`cygpath -w $@` else %.dll: lib%.o - $(CC) -o $@ $< -shared + $(CC) -o $@ $< -shared -Wl,--out-implib=$@.a endif $(TMPDIR)/lib%.o: %.c diff --git a/src/test/run-make-fulldeps/used/Makefile b/src/test/run-make-fulldeps/used/Makefile index 8d913e3993502..4d904472931ec 100644 --- a/src/test/run-make-fulldeps/used/Makefile +++ b/src/test/run-make-fulldeps/used/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# ignore-windows +# ignore-windows-msvc all: $(RUSTC) -C opt-level=3 --emit=obj used.rs diff --git a/src/test/run-make/static-pie/test-aslr.rs b/src/test/run-make/static-pie/test-aslr.rs index f28e00f7f4cf9..96b17af46dfe9 100644 --- a/src/test/run-make/static-pie/test-aslr.rs +++ b/src/test/run-make/static-pie/test-aslr.rs @@ -29,7 +29,7 @@ fn main() { } Some(s) if s.eq("--test-aslr") => { let cnt = run_self(&arg0); - if cnt != NUM_RUNS { + if cnt == 1 { eprintln!("FAIL: {} most likely no ASLR", arg0); std::process::exit(1); } diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs index 8c6073e2f7a49..1eeb01ccc846e 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs @@ -35,7 +35,7 @@ fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { #[cfg(transmute)] // one instantiations: BAD fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - bar(foo, x) //[transmute]~ ERROR E0495 + bar(foo, x) //[transmute]~ ERROR E0759 } #[cfg(krisskross)] // two instantiations, mixing and matching: BAD diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr index 5ea98dcd4a972..0be9b37263a48 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr @@ -1,26 +1,11 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/project-fn-ret-contravariant.rs:38:8 | -LL | bar(foo, x) - | ^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 37:8... - --> $DIR/project-fn-ret-contravariant.rs:37:8 - | LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/project-fn-ret-contravariant.rs:38:13 - | -LL | bar(foo, x) - | ^ - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that reference does not outlive borrowed content - --> $DIR/project-fn-ret-contravariant.rs:38:4 - | + | ------- this data with lifetime `'a`... LL | bar(foo, x) - | ^^^^^^^^^^^ + | ----^^^---- ...is captured and required to live as long as `'static` here error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs index 0034d796826de..08d864f7836d2 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs @@ -46,7 +46,7 @@ fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { // Cannot instantiate `foo` with any lifetime other than `'a`, // since it is provided as input. - bar(foo, x) //[transmute]~ ERROR E0495 + bar(foo, x) //[transmute]~ ERROR E0759 } #[cfg(krisskross)] // two instantiations, mixing and matching: BAD diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr index ef57f9e0bc480..0a44864b24955 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -1,30 +1,12 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/project-fn-ret-invariant.rs:49:9 | -LL | bar(foo, x) - | ^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 45:8... - --> $DIR/project-fn-ret-invariant.rs:45:8 - | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { - | ^^ -note: ...so that the expression is assignable - --> $DIR/project-fn-ret-invariant.rs:49:14 - | -LL | bar(foo, x) - | ^ - = note: expected `Type<'_>` - found `Type<'a>` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the expression is assignable - --> $DIR/project-fn-ret-invariant.rs:49:5 - | + | -------- this data with lifetime `'a`... +... LL | bar(foo, x) - | ^^^^^^^^^^^ - = note: expected `Type<'static>` - found `Type<'_>` + | ----^^^---- ...is captured and required to live as long as `'static` here error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/async-await/issues/issue-62097.rs b/src/test/ui/async-await/issues/issue-62097.rs index ea482d3667e2b..66ebbd83ffa9e 100644 --- a/src/test/ui/async-await/issues/issue-62097.rs +++ b/src/test/ui/async-await/issues/issue-62097.rs @@ -9,7 +9,7 @@ where struct Struct; impl Struct { - pub async fn run_dummy_fn(&self) { //~ ERROR cannot infer + pub async fn run_dummy_fn(&self) { //~ ERROR E0759 foo(|| self.bar()).await; } diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.stderr index 0f58b158904db..56a28d904b91d 100644 --- a/src/test/ui/async-await/issues/issue-62097.stderr +++ b/src/test/ui/async-await/issues/issue-62097.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-62097.rs:12:31 | LL | pub async fn run_dummy_fn(&self) { diff --git a/src/test/ui/consts/const-option.rs b/src/test/ui/consts/const-option.rs new file mode 100644 index 0000000000000..fbf20b9db6741 --- /dev/null +++ b/src/test/ui/consts/const-option.rs @@ -0,0 +1,14 @@ +// run-pass + +#![feature(const_option)] + +const X: Option = Some(32); +const Y: Option<&i32> = X.as_ref(); + +const IS_SOME: bool = X.is_some(); +const IS_NONE: bool = Y.is_none(); + +fn main() { + assert!(IS_SOME); + assert!(!IS_NONE) +} diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs index d4ad706d01bc2..89210fdf137e0 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs @@ -17,7 +17,7 @@ fn static_val(_: T) { } fn with_dyn_debug_static<'a>(x: Box) { - static_val(x); //~ ERROR cannot infer + static_val(x); //~ ERROR E0759 } fn not_static_val(_: T) { diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr index 268008c211129..b3bef677d19c1 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr @@ -1,30 +1,17 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/dyn-trait.rs:20:16 | -LL | static_val(x); - | ^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 19:26... - --> $DIR/dyn-trait.rs:19:26 - | LL | fn with_dyn_debug_static<'a>(x: Box) { - | ^^ -note: ...so that the expression is assignable - --> $DIR/dyn-trait.rs:20:16 - | + | ------------------- this data with lifetime `'a`... LL | static_val(x); - | ^ - = note: expected `std::boxed::Box` - found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the types are compatible + | ^ ...is captured here... + | +note: ...and is required to live as long as `'static` here --> $DIR/dyn-trait.rs:20:5 | LL | static_val(x); | ^^^^^^^^^^ - = note: expected `StaticTrait` - found `StaticTrait` error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index 3b339c5c3d7fc..4372de245078f 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ^^^^^^^^^^^^^^ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:6:32 + --> $DIR/must_outlive_least_region_or_bound.rs:5:32 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- ^^^^^^^^^ opaque type requires that `'a` must outlive `'static` @@ -26,7 +26,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ^^^^^^^^^^^^^^ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 + --> $DIR/must_outlive_least_region_or_bound.rs:7:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | - ^ returning this value requires that `'1` must outlive `'static` @@ -36,7 +36,7 @@ LL | fn elided2(x: &i32) -> impl Copy + 'static { x } = help: consider replacing `'1` with `'static` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:12:55 + --> $DIR/must_outlive_least_region_or_bound.rs:9:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -45,7 +45,7 @@ LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } = help: consider replacing `'a` with `'static` error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:15:41 + --> $DIR/must_outlive_least_region_or_bound.rs:11:41 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^ lifetime `'a` required @@ -53,7 +53,7 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:30:24 + --> $DIR/must_outlive_least_region_or_bound.rs:22:24 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'1` must outlive `'static` @@ -61,7 +61,7 @@ LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | let's call the lifetime of this reference `'1` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:37:69 + --> $DIR/must_outlive_least_region_or_bound.rs:28:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -70,7 +70,7 @@ LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } = help: consider replacing `'a` with `'static` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:42:61 + --> $DIR/must_outlive_least_region_or_bound.rs:32:61 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- -- lifetime `'b` defined here ^^^^^^^^^^^^^^^^ opaque type requires that `'b` must outlive `'a` @@ -80,7 +80,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 = help: consider adding the following bound: `'b: 'a` error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:47:51 + --> $DIR/must_outlive_least_region_or_bound.rs:37:51 | LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index 9bf86fa66cded..51f488e45a6f3 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -1,41 +1,31 @@ use std::fmt::Debug; -fn elided(x: &i32) -> impl Copy { x } -//~^ ERROR cannot infer an appropriate lifetime +fn elided(x: &i32) -> impl Copy { x } //~ ERROR E0759 -fn explicit<'a>(x: &'a i32) -> impl Copy { x } -//~^ ERROR cannot infer an appropriate lifetime +fn explicit<'a>(x: &'a i32) -> impl Copy { x } //~ ERROR E0759 -fn elided2(x: &i32) -> impl Copy + 'static { x } -//~^ ERROR cannot infer an appropriate lifetime +fn elided2(x: &i32) -> impl Copy + 'static { x } //~ ERROR E0759 -fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } -//~^ ERROR cannot infer an appropriate lifetime +fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } //~ ERROR E0759 fn foo<'a>(x: &i32) -> impl Copy + 'a { x } //~^ ERROR explicit lifetime required in the type of `x` -fn elided3(x: &i32) -> Box { Box::new(x) } -//~^ ERROR cannot infer an appropriate lifetime +fn elided3(x: &i32) -> Box { Box::new(x) } //~ ERROR E0759 -fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } -//~^ ERROR cannot infer an appropriate lifetime +fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } //~ ERROR E0759 -fn elided4(x: &i32) -> Box { Box::new(x) } -//~^ ERROR cannot infer an appropriate lifetime +fn elided4(x: &i32) -> Box { Box::new(x) } //~ ERROR E0759 -fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } -//~^ ERROR cannot infer an appropriate lifetime +fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } //~ ERROR E0759 -fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } -//~^ ERROR cannot infer an appropriate lifetime -//~| ERROR cannot infer an appropriate lifetime +fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } //~ ERROR E0759 +//~^ ERROR E0759 trait LifetimeTrait<'a> {} impl<'a> LifetimeTrait<'a> for &'a i32 {} -fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } -//~^ ERROR cannot infer an appropriate lifetime +fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~ ERROR E0759 // Tests that a closure type containing 'b cannot be returned from a type where // only 'a was expected. diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index ffadcaae08e05..b040889217e47 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/must_outlive_least_region_or_bound.rs:3:35 | LL | fn elided(x: &i32) -> impl Copy { x } @@ -16,8 +16,8 @@ help: to declare that the `impl Trait` captures data from argument `x`, you can LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:5:44 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | ------- ^ ...is captured here... @@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | this data with lifetime `'a`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:6:32 + --> $DIR/must_outlive_least_region_or_bound.rs:5:32 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | ^^^^^^^^^ @@ -34,8 +34,8 @@ help: to declare that the `impl Trait` captures data from argument `x`, you can LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:7:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ---- ^ ...is captured here... @@ -43,7 +43,7 @@ LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | this data with an anonymous lifetime `'_`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:9:24 + --> $DIR/must_outlive_least_region_or_bound.rs:7:24 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -56,8 +56,8 @@ help: alternatively, add an explicit `'static` bound to this reference LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:12:55 +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:9:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ------- ^ ...is captured here... @@ -65,7 +65,7 @@ LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | this data with lifetime `'a`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:12:33 + --> $DIR/must_outlive_least_region_or_bound.rs:9:33 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -79,15 +79,15 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:15:24 + --> $DIR/must_outlive_least_region_or_bound.rs:11:24 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:30:65 +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:22:65 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | ---- this data with an anonymous lifetime `'_`... ^ ...is captured here, requiring it to live as long as `'static` @@ -101,14 +101,14 @@ help: to declare that the `impl Trait` captures data from argument `x`, you can LL | fn elided5(x: &i32) -> (Box, impl Debug + '_) { (Box::new(x), x) } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:30:69 +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:22:69 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | ---- this data with an anonymous lifetime `'_`... ^ ...is captured here... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:30:41 + --> $DIR/must_outlive_least_region_or_bound.rs:22:41 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | ^^^^^^^^^^ @@ -121,14 +121,14 @@ help: to declare that the `impl Trait` captures data from argument `x`, you can LL | fn elided5(x: &i32) -> (Box, impl Debug + '_) { (Box::new(x), x) } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:37:69 +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:28:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ------- this data with lifetime `'a`... ^ ...is captured here... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:37:34 + --> $DIR/must_outlive_least_region_or_bound.rs:28:34 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ^^^^^^^^^^^^ error[E0623]: lifetime mismatch - --> $DIR/must_outlive_least_region_or_bound.rs:42:61 + --> $DIR/must_outlive_least_region_or_bound.rs:32:61 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | ------- ^^^^^^^^^^^^^^^^ @@ -151,15 +151,15 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | this parameter and the return type are declared with different lifetimes... error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:47:51 + --> $DIR/must_outlive_least_region_or_bound.rs:37:51 | LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { | -- ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | | | help: consider adding an explicit lifetime bound...: `T: 'static +` -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:18:50 +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:14:50 | LL | fn elided3(x: &i32) -> Box { Box::new(x) } | ---- ^ ...is captured here, requiring it to live as long as `'static` @@ -171,8 +171,8 @@ help: to declare that the trait object captures data from argument `x`, you can LL | fn elided3(x: &i32) -> Box { Box::new(x) } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:21:59 +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:16:59 | LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | ------- ^ ...is captured here, requiring it to live as long as `'static` @@ -184,8 +184,8 @@ help: to declare that the trait object captures data from argument `x`, you can LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:24:60 +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:18:60 | LL | fn elided4(x: &i32) -> Box { Box::new(x) } | ---- ^ ...is captured here, requiring it to live as long as `'static` @@ -201,8 +201,8 @@ help: alternatively, add an explicit `'static` bound to this reference LL | fn elided4(x: &'static i32) -> Box { Box::new(x) } | ^^^^^^^^^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/must_outlive_least_region_or_bound.rs:27:69 +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/must_outlive_least_region_or_bound.rs:20:69 | LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } | ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static` diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr index 123ea6af6b019..65178cc9d24c2 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr @@ -12,7 +12,7 @@ LL | fn iter_values_anon(&self) -> impl Iterator + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lifetime may not live long enough - --> $DIR/static-return-lifetime-infered.rs:10:37 + --> $DIR/static-return-lifetime-infered.rs:9:37 | LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static` diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.rs b/src/test/ui/impl-trait/static-return-lifetime-infered.rs index 96f3652c226ea..518c52f5de4d7 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.rs +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.rs @@ -4,13 +4,11 @@ struct A { impl A { fn iter_values_anon(&self) -> impl Iterator { - self.x.iter().map(|a| a.0) + self.x.iter().map(|a| a.0) //~ ERROR E0759 } - //~^^ ERROR cannot infer an appropriate lifetime fn iter_values<'a>(&'a self) -> impl Iterator { - self.x.iter().map(|a| a.0) + self.x.iter().map(|a| a.0) //~ ERROR E0759 } - //~^^ ERROR cannot infer an appropriate lifetime } fn main() {} diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr index df0db6e4fc6df..7c289b388223a 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/static-return-lifetime-infered.rs:7:16 | LL | fn iter_values_anon(&self) -> impl Iterator { @@ -18,8 +18,8 @@ help: to declare that the `impl Trait` captures data from argument `self`, you c LL | fn iter_values_anon(&self) -> impl Iterator + '_ { | ^^^^ -error[E0759]: cannot infer an appropriate lifetime - --> $DIR/static-return-lifetime-infered.rs:11:16 +error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/static-return-lifetime-infered.rs:10:16 | LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -------- this data with lifetime `'a`... @@ -29,7 +29,7 @@ LL | self.x.iter().map(|a| a.0) | ...is captured here... | note: ...and is required to live as long as `'static` here - --> $DIR/static-return-lifetime-infered.rs:10:37 + --> $DIR/static-return-lifetime-infered.rs:9:37 | LL | fn iter_values<'a>(&'a self) -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-16922.rs b/src/test/ui/issues/issue-16922.rs index 827163ef83cf7..f048ccd2427cb 100644 --- a/src/test/ui/issues/issue-16922.rs +++ b/src/test/ui/issues/issue-16922.rs @@ -1,8 +1,7 @@ use std::any::Any; fn foo(value: &T) -> Box { - Box::new(value) as Box - //~^ ERROR cannot infer an appropriate lifetime + Box::new(value) as Box //~ ERROR E0759 } fn main() { diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.stderr index 919594fc9af4b..6decc751321f9 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-16922.rs:4:14 | LL | fn foo(value: &T) -> Box { diff --git a/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs b/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs new file mode 100644 index 0000000000000..df1c99e8671e8 --- /dev/null +++ b/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs @@ -0,0 +1,18 @@ +// check-pass + +trait Trait { + const ASSOC_CONST: usize = 0; +} + +impl Trait<()> for u8 {} + +// `u8::ASSOC_CONST` is resolved today, but will be ambiguous +// under lazy normalization. +fn foo() -> [(T, U); u8::ASSOC_CONST] +where + u8: Trait + Trait, +{ + todo!() +} + +fn main() {} diff --git a/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs b/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs new file mode 100644 index 0000000000000..3f90d22ae2d22 --- /dev/null +++ b/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs @@ -0,0 +1,18 @@ +// check-pass + +// If we allow the parent generics here without using lazy normalization +// this results in a cycle error. +struct Foo(T, U); + +impl From<[u8; 1 + 1]> for Foo { + fn from(value: [u8; 1 + 1]) -> Foo { + todo!(); + } +} + +fn break_me() +where + [u8; 1 + 1]: From<[u8; 1 + 1]> +{} + +fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-fn.rs b/src/test/ui/lint/lint-ctypes-fn.rs index 67dd7abcf79ef..aa02e57866328 100644 --- a/src/test/ui/lint/lint-ctypes-fn.rs +++ b/src/test/ui/lint/lint-ctypes-fn.rs @@ -71,7 +71,8 @@ pub extern "C" fn str_type(p: &str) { } //~^ ERROR: uses type `str` pub extern "C" fn box_type(p: Box) { } -//~^ ERROR uses type `std::boxed::Box` + +pub extern "C" fn opt_box_type(p: Option>) { } pub extern "C" fn char_type(p: char) { } //~^ ERROR uses type `char` @@ -106,7 +107,6 @@ pub extern "C" fn fn_type2(p: fn()) { } //~^ ERROR uses type `fn()` pub extern "C" fn fn_contained(p: RustBadRet) { } -//~^ ERROR: uses type `std::boxed::Box` pub extern "C" fn transparent_i128(p: TransparentI128) { } //~^ ERROR: uses type `i128` @@ -115,7 +115,6 @@ pub extern "C" fn transparent_str(p: TransparentStr) { } //~^ ERROR: uses type `str` pub extern "C" fn transparent_fn(p: TransparentBadFn) { } -//~^ ERROR: uses type `std::boxed::Box` pub extern "C" fn good3(fptr: Option) { } diff --git a/src/test/ui/lint/lint-ctypes-fn.stderr b/src/test/ui/lint/lint-ctypes-fn.stderr index 66cf195327890..d0a449514e50e 100644 --- a/src/test/ui/lint/lint-ctypes-fn.stderr +++ b/src/test/ui/lint/lint-ctypes-fn.stderr @@ -21,17 +21,8 @@ LL | pub extern "C" fn str_type(p: &str) { } = help: consider using `*const u8` and a length instead = note: string slices have no C equivalent -error: `extern` fn uses type `std::boxed::Box`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:73:31 - | -LL | pub extern "C" fn box_type(p: Box) { } - | ^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct - = note: this struct has unspecified layout - error: `extern` fn uses type `char`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:76:32 + --> $DIR/lint-ctypes-fn.rs:77:32 | LL | pub extern "C" fn char_type(p: char) { } | ^^^^ not FFI-safe @@ -40,7 +31,7 @@ LL | pub extern "C" fn char_type(p: char) { } = note: the `char` type has no C equivalent error: `extern` fn uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:79:32 + --> $DIR/lint-ctypes-fn.rs:80:32 | LL | pub extern "C" fn i128_type(p: i128) { } | ^^^^ not FFI-safe @@ -48,7 +39,7 @@ LL | pub extern "C" fn i128_type(p: i128) { } = note: 128-bit integers don't currently have a known stable ABI error: `extern` fn uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:82:32 + --> $DIR/lint-ctypes-fn.rs:83:32 | LL | pub extern "C" fn u128_type(p: u128) { } | ^^^^ not FFI-safe @@ -56,7 +47,7 @@ LL | pub extern "C" fn u128_type(p: u128) { } = note: 128-bit integers don't currently have a known stable ABI error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:85:33 + --> $DIR/lint-ctypes-fn.rs:86:33 | LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } | ^^^^^^^^^^ not FFI-safe @@ -65,7 +56,7 @@ LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } = note: tuples have unspecified layout error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:88:34 + --> $DIR/lint-ctypes-fn.rs:89:34 | LL | pub extern "C" fn tuple_type2(p: I32Pair) { } | ^^^^^^^ not FFI-safe @@ -74,7 +65,7 @@ LL | pub extern "C" fn tuple_type2(p: I32Pair) { } = note: tuples have unspecified layout error: `extern` fn uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:91:32 + --> $DIR/lint-ctypes-fn.rs:92:32 | LL | pub extern "C" fn zero_size(p: ZeroSize) { } | ^^^^^^^^ not FFI-safe @@ -88,7 +79,7 @@ LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:94:40 + --> $DIR/lint-ctypes-fn.rs:95:40 | LL | pub extern "C" fn zero_size_phantom(p: ZeroSizeWithPhantomData) { } | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -101,7 +92,7 @@ LL | pub struct ZeroSizeWithPhantomData(PhantomData); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `std::marker::PhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:97:51 + --> $DIR/lint-ctypes-fn.rs:98:51 | LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -109,7 +100,7 @@ LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData { = note: composed only of `PhantomData` error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:102:30 + --> $DIR/lint-ctypes-fn.rs:103:30 | LL | pub extern "C" fn fn_type(p: RustFn) { } | ^^^^^^ not FFI-safe @@ -118,7 +109,7 @@ LL | pub extern "C" fn fn_type(p: RustFn) { } = note: this function pointer has Rust-specific calling convention error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:105:31 + --> $DIR/lint-ctypes-fn.rs:106:31 | LL | pub extern "C" fn fn_type2(p: fn()) { } | ^^^^ not FFI-safe @@ -126,15 +117,6 @@ LL | pub extern "C" fn fn_type2(p: fn()) { } = help: consider using an `extern fn(...) -> ...` function pointer instead = note: this function pointer has Rust-specific calling convention -error: `extern` fn uses type `std::boxed::Box`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:108:35 - | -LL | pub extern "C" fn fn_contained(p: RustBadRet) { } - | ^^^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct - = note: this struct has unspecified layout - error: `extern` fn uses type `i128`, which is not FFI-safe --> $DIR/lint-ctypes-fn.rs:111:39 | @@ -152,17 +134,8 @@ LL | pub extern "C" fn transparent_str(p: TransparentStr) { } = help: consider using `*const u8` and a length instead = note: string slices have no C equivalent -error: `extern` fn uses type `std::boxed::Box`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:117:37 - | -LL | pub extern "C" fn transparent_fn(p: TransparentBadFn) { } - | ^^^^^^^^^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct - = note: this struct has unspecified layout - error: `extern` fn uses type `std::marker::PhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:161:43 + --> $DIR/lint-ctypes-fn.rs:160:43 | LL | pub extern "C" fn unused_generic2() -> PhantomData { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -170,7 +143,7 @@ LL | pub extern "C" fn unused_generic2() -> PhantomData { = note: composed only of `PhantomData` error: `extern` fn uses type `std::vec::Vec`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:174:39 + --> $DIR/lint-ctypes-fn.rs:173:39 | LL | pub extern "C" fn used_generic4(x: Vec) { } | ^^^^^^ not FFI-safe @@ -179,7 +152,7 @@ LL | pub extern "C" fn used_generic4(x: Vec) { } = note: this struct has unspecified layout error: `extern` fn uses type `std::vec::Vec`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:177:41 + --> $DIR/lint-ctypes-fn.rs:176:41 | LL | pub extern "C" fn used_generic5() -> Vec { | ^^^^^^ not FFI-safe @@ -187,5 +160,5 @@ LL | pub extern "C" fn used_generic5() -> Vec { = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout -error: aborting due to 20 previous errors +error: aborting due to 17 previous errors diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs index a439a1f339aea..bdf95350c7045 100644 --- a/src/test/ui/lint/lint-ctypes.rs +++ b/src/test/ui/lint/lint-ctypes.rs @@ -48,6 +48,8 @@ extern { pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` pub fn str_type(p: &str); //~ ERROR: uses type `str` pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box` + pub fn opt_box_type(p: Option>); + //~^ ERROR uses type `std::option::Option>` pub fn char_type(p: char); //~ ERROR uses type `char` pub fn i128_type(p: i128); //~ ERROR uses type `i128` pub fn u128_type(p: u128); //~ ERROR uses type `u128` diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr index 9821f858d9caf..13b9adca3f9f5 100644 --- a/src/test/ui/lint/lint-ctypes.stderr +++ b/src/test/ui/lint/lint-ctypes.stderr @@ -58,8 +58,17 @@ LL | pub fn box_type(p: Box); = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout +error: `extern` block uses type `std::option::Option>`, which is not FFI-safe + --> $DIR/lint-ctypes.rs:51:28 + | +LL | pub fn opt_box_type(p: Option>); + | ^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum + = note: enum has no representation hint + error: `extern` block uses type `char`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:51:25 + --> $DIR/lint-ctypes.rs:53:25 | LL | pub fn char_type(p: char); | ^^^^ not FFI-safe @@ -68,7 +77,7 @@ LL | pub fn char_type(p: char); = note: the `char` type has no C equivalent error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:52:25 + --> $DIR/lint-ctypes.rs:54:25 | LL | pub fn i128_type(p: i128); | ^^^^ not FFI-safe @@ -76,7 +85,7 @@ LL | pub fn i128_type(p: i128); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:53:25 + --> $DIR/lint-ctypes.rs:55:25 | LL | pub fn u128_type(p: u128); | ^^^^ not FFI-safe @@ -84,7 +93,7 @@ LL | pub fn u128_type(p: u128); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `dyn std::clone::Clone`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:54:26 + --> $DIR/lint-ctypes.rs:56:26 | LL | pub fn trait_type(p: &dyn Clone); | ^^^^^^^^^^ not FFI-safe @@ -92,7 +101,7 @@ LL | pub fn trait_type(p: &dyn Clone); = note: trait objects have no C equivalent error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:55:26 + --> $DIR/lint-ctypes.rs:57:26 | LL | pub fn tuple_type(p: (i32, i32)); | ^^^^^^^^^^ not FFI-safe @@ -101,7 +110,7 @@ LL | pub fn tuple_type(p: (i32, i32)); = note: tuples have unspecified layout error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:56:27 + --> $DIR/lint-ctypes.rs:58:27 | LL | pub fn tuple_type2(p: I32Pair); | ^^^^^^^ not FFI-safe @@ -110,7 +119,7 @@ LL | pub fn tuple_type2(p: I32Pair); = note: tuples have unspecified layout error: `extern` block uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:57:25 + --> $DIR/lint-ctypes.rs:59:25 | LL | pub fn zero_size(p: ZeroSize); | ^^^^^^^^ not FFI-safe @@ -124,7 +133,7 @@ LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:58:33 + --> $DIR/lint-ctypes.rs:60:33 | LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -137,7 +146,7 @@ LL | pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `std::marker::PhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:61:12 + --> $DIR/lint-ctypes.rs:63:12 | LL | -> ::std::marker::PhantomData; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -145,7 +154,7 @@ LL | -> ::std::marker::PhantomData; = note: composed only of `PhantomData` error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:62:23 + --> $DIR/lint-ctypes.rs:64:23 | LL | pub fn fn_type(p: RustFn); | ^^^^^^ not FFI-safe @@ -154,7 +163,7 @@ LL | pub fn fn_type(p: RustFn); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:63:24 + --> $DIR/lint-ctypes.rs:65:24 | LL | pub fn fn_type2(p: fn()); | ^^^^ not FFI-safe @@ -163,7 +172,7 @@ LL | pub fn fn_type2(p: fn()); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `std::boxed::Box`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:64:28 + --> $DIR/lint-ctypes.rs:66:28 | LL | pub fn fn_contained(p: RustBadRet); | ^^^^^^^^^^ not FFI-safe @@ -172,7 +181,7 @@ LL | pub fn fn_contained(p: RustBadRet); = note: this struct has unspecified layout error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:65:32 + --> $DIR/lint-ctypes.rs:67:32 | LL | pub fn transparent_i128(p: TransparentI128); | ^^^^^^^^^^^^^^^ not FFI-safe @@ -180,7 +189,7 @@ LL | pub fn transparent_i128(p: TransparentI128); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:66:31 + --> $DIR/lint-ctypes.rs:68:31 | LL | pub fn transparent_str(p: TransparentStr); | ^^^^^^^^^^^^^^ not FFI-safe @@ -189,7 +198,7 @@ LL | pub fn transparent_str(p: TransparentStr); = note: string slices have no C equivalent error: `extern` block uses type `std::boxed::Box`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:67:30 + --> $DIR/lint-ctypes.rs:69:30 | LL | pub fn transparent_fn(p: TransparentBadFn); | ^^^^^^^^^^^^^^^^ not FFI-safe @@ -198,7 +207,7 @@ LL | pub fn transparent_fn(p: TransparentBadFn); = note: this struct has unspecified layout error: `extern` block uses type `[u8; 8]`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:68:27 + --> $DIR/lint-ctypes.rs:70:27 | LL | pub fn raw_array(arr: [u8; 8]); | ^^^^^^^ not FFI-safe @@ -207,7 +216,7 @@ LL | pub fn raw_array(arr: [u8; 8]); = note: passing raw arrays by value is not FFI-safe error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:70:34 + --> $DIR/lint-ctypes.rs:72:34 | LL | pub static static_u128_type: u128; | ^^^^ not FFI-safe @@ -215,12 +224,12 @@ LL | pub static static_u128_type: u128; = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:71:40 + --> $DIR/lint-ctypes.rs:73:40 | LL | pub static static_u128_array_type: [u128; 16]; | ^^^^^^^^^^ not FFI-safe | = note: 128-bit integers don't currently have a known stable ABI -error: aborting due to 23 previous errors +error: aborting due to 24 previous errors diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr index 8421dc1d0c130..1931934a2112a 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr @@ -1,28 +1,11 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements +error[E0759]: `fn` parameter has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/constant-in-expr-inherent-1.rs:8:5 | -LL | >::C - | ^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 7:8... - --> $DIR/constant-in-expr-inherent-1.rs:7:8 - | LL | fn foo<'a>(_: &'a u32) -> &'static u32 { - | ^^ -note: ...so that the types are compatible - --> $DIR/constant-in-expr-inherent-1.rs:8:5 - | -LL | >::C - | ^^^^^^^^^^^^ - = note: expected `Foo<'_>` - found `Foo<'a>` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that reference does not outlive borrowed content - --> $DIR/constant-in-expr-inherent-1.rs:8:5 - | + | ------- this data with lifetime `'a`... LL | >::C - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ ...is captured and required to live as long as `'static` here error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index 708ab1cf38297..4a2665d8e1694 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -15,7 +15,7 @@ fn load(ss: &mut SomeStruct) -> Box { // `Box` defaults to a `'static` bound, so this return // is illegal. - ss.r //~ ERROR cannot infer an appropriate lifetime + ss.r //~ ERROR E0759 } fn store(ss: &mut SomeStruct, b: Box) { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr index 1b1e0d9610724..70b99ef7869ca 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `ss` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/object-lifetime-default-from-box-error.rs:18:5 | LL | fn load(ss: &mut SomeStruct) -> Box { diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.rs b/src/test/ui/regions/region-object-lifetime-in-coercion.rs index 5d199149c39b8..9d3f485e31438 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.rs +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.rs @@ -5,18 +5,18 @@ trait Foo {} impl<'a> Foo for &'a [u8] {} fn a(v: &[u8]) -> Box { - let x: Box = Box::new(v); //~ ERROR cannot infer an appropriate lifetime + let x: Box = Box::new(v); //~ ERROR E0759 x } fn b(v: &[u8]) -> Box { - Box::new(v) //~ ERROR cannot infer an appropriate lifetime + Box::new(v) //~ ERROR E0759 } fn c(v: &[u8]) -> Box { // same as previous case due to RFC 599 - Box::new(v) //~ ERROR cannot infer an appropriate lifetime + Box::new(v) //~ ERROR E0759 } fn d<'a,'b>(v: &'a [u8]) -> Box { diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr index 7f5a3a47976c7..63fea1f41626d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/region-object-lifetime-in-coercion.rs:8:46 | LL | fn a(v: &[u8]) -> Box { @@ -15,7 +15,7 @@ help: alternatively, add an explicit `'static` bound to this reference LL | fn a(v: &'static [u8]) -> Box { | ^^^^^^^^^^^^^ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/region-object-lifetime-in-coercion.rs:13:14 | LL | fn b(v: &[u8]) -> Box { @@ -32,7 +32,7 @@ help: alternatively, add an explicit `'static` bound to this reference LL | fn b(v: &'static [u8]) -> Box { | ^^^^^^^^^^^^^ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/region-object-lifetime-in-coercion.rs:19:14 | LL | fn c(v: &[u8]) -> Box { diff --git a/src/test/ui/regions/regions-addr-of-self.rs b/src/test/ui/regions/regions-addr-of-self.rs index 647212407fc8a..4eb1b275f163e 100644 --- a/src/test/ui/regions/regions-addr-of-self.rs +++ b/src/test/ui/regions/regions-addr-of-self.rs @@ -4,7 +4,7 @@ struct Dog { impl Dog { pub fn chase_cat(&mut self) { - let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + let p: &'static mut usize = &mut self.cats_chased; //~ ERROR E0759 *p += 1; } diff --git a/src/test/ui/regions/regions-addr-of-self.stderr b/src/test/ui/regions/regions-addr-of-self.stderr index a0b8b6b51e5a1..738691fd695eb 100644 --- a/src/test/ui/regions/regions-addr-of-self.stderr +++ b/src/test/ui/regions/regions-addr-of-self.stderr @@ -1,29 +1,11 @@ -error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/regions-addr-of-self.rs:7:37 | +LL | pub fn chase_cat(&mut self) { + | --------- this data with an anonymous lifetime `'_`... LL | let p: &'static mut usize = &mut self.cats_chased; - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 6:5... - --> $DIR/regions-addr-of-self.rs:6:5 - | -LL | / pub fn chase_cat(&mut self) { -LL | | let p: &'static mut usize = &mut self.cats_chased; -LL | | *p += 1; -LL | | } - | |_____^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-addr-of-self.rs:7:37 - | -LL | let p: &'static mut usize = &mut self.cats_chased; - | ^^^^^^^^^^^^^^^^^^^^^ - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-addr-of-self.rs:7:37 - | -LL | let p: &'static mut usize = &mut self.cats_chased; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ ...is captured and required to live as long as `'static` here error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-close-object-into-object-2.rs b/src/test/ui/regions/regions-close-object-into-object-2.rs index 2364ba2728600..7144ab5a24c51 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.rs +++ b/src/test/ui/regions/regions-close-object-into-object-2.rs @@ -7,7 +7,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer + box B(&*v) as Box //~ ERROR E0759 } fn main() { } diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr index 114e4052aae09..aab7ce993aa3c 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/regions-close-object-into-object-2.rs:10:11 | LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { diff --git a/src/test/ui/regions/regions-close-object-into-object-4.rs b/src/test/ui/regions/regions-close-object-into-object-4.rs index d531077043686..4c087f264f92b 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.rs +++ b/src/test/ui/regions/regions-close-object-into-object-4.rs @@ -7,7 +7,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box+'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer + box B(&*v) as Box //~ ERROR E0759 } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr index 850d81940791f..90f807a41c562 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/regions-close-object-into-object-4.rs:10:11 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs index 8617c0e9da8f7..55d964ac53405 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.rs +++ b/src/test/ui/regions/regions-proc-bound-capture.rs @@ -6,7 +6,7 @@ fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { fn static_proc(x: &isize) -> Box (isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. - Box::new(move || { *x }) //~ ERROR cannot infer an appropriate lifetime + Box::new(move || { *x }) //~ ERROR E0759 } fn main() { } diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr index 67eee3bb6e281..e76073f4f6b13 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/regions-proc-bound-capture.rs:9:14 | LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs index 0afe631f1e3fc..43998ca8c5784 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs @@ -6,7 +6,7 @@ struct Foo; impl Foo { async fn f(self: Pin<&Self>) -> impl Clone { self } - //~^ ERROR cannot infer an appropriate lifetime + //~^ ERROR E0759 } fn main() { diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index f2fbb0ba7d755..9cd0fd328ffa0 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:16 | LL | async fn f(self: Pin<&Self>) -> impl Clone { self } diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.rs index 5054568b18970..04935fc52ab9e 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.rs +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.rs @@ -3,7 +3,7 @@ use std::pin::Pin; struct Foo; impl Foo { - fn f(self: Pin<&Self>) -> impl Clone { self } //~ ERROR cannot infer an appropriate lifetime + fn f(self: Pin<&Self>) -> impl Clone { self } //~ ERROR E0759 } fn main() { diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr index 2e10ab3d3f9b8..cb9d5b56dbc5c 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44 | LL | fn f(self: Pin<&Self>) -> impl Clone { self } diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed new file mode 100644 index 0000000000000..45e6cfdb82131 --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed @@ -0,0 +1,91 @@ +// run-rustfix +#![allow(dead_code)] + +mod foo { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait + '_ { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self::() //~ ERROR E0759 + } +} + +mod bar { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait + '_ { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + val.use_self() //~ ERROR E0767 + } +} + +mod baz { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for Box { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for Box {} + + fn use_it<'a>(val: &'a Box) -> &'a () { + val.use_self() //~ ERROR E0767 + } +} + +mod bat { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + + impl dyn ObjectTrait + '_ { + fn use_self(&self) -> &() { panic!() } + } + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() //~ ERROR E0767 + } +} + +mod ban { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait + '_ {} + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() //~ ERROR E0759 + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr new file mode 100644 index 0000000000000..fb6e62e76da88 --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr @@ -0,0 +1,32 @@ +error[E0521]: borrowed data escapes outside of function + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:9 + | +LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + | --- `val` is a reference that is only valid in the function body +LL | val.use_self::() + | ^^^^^^^^^^^^^^^^^^^ `val` escapes the function body here + | + = help: consider replacing `'a` with `'static` + +error[E0521]: borrowed data escapes outside of function + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:9 + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + | --- `val` is a reference that is only valid in the function body +LL | val.use_self() + | ^^^^^^^^^^^^^^ `val` escapes the function body here + | + = help: consider replacing `'a` with `'static` + +error[E0521]: borrowed data escapes outside of function + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:9 + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + | --- `val` is a reference that is only valid in the function body +LL | val.use_self() + | ^^^^^^^^^^^^^^ `val` escapes the function body here + | + = help: consider replacing `'a` with `'static` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs new file mode 100644 index 0000000000000..7de11f4f8fc51 --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs @@ -0,0 +1,91 @@ +// run-rustfix +#![allow(dead_code)] + +mod foo { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self::() //~ ERROR E0759 + } +} + +mod bar { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + val.use_self() //~ ERROR E0767 + } +} + +mod baz { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for Box { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for Box {} + + fn use_it<'a>(val: &'a Box) -> &'a () { + val.use_self() //~ ERROR E0767 + } +} + +mod bat { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + + impl dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() //~ ERROR E0767 + } +} + +mod ban { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait {} + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + val.use_self() //~ ERROR E0759 + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr new file mode 100644 index 0000000000000..1375ac8db8ded --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -0,0 +1,108 @@ +error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13 + | +LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + | ---------------------- this data with lifetime `'a`... +LL | val.use_self::() + | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | +note: `impl` of `foo::MyTrait` has a `'static` requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32 + | +LL | impl MyTrait for dyn ObjectTrait { + | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement +LL | fn use_self(&self) -> &() { panic!() } + | -------- calling this method introduces the `impl`'s 'static` requirement +help: consider relaxing the implicit `'static` requirement + | +LL | impl MyTrait for dyn ObjectTrait + '_ { + | ^^^^ + +error[E0767]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13 + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + | ------------------- this data with lifetime `'a`... +LL | val.use_self() + | ^^^^^^^^ ...is captured and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` + | +note: inherent `impl` has a `'static` requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14 + | +LL | impl dyn ObjectTrait { + | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement +LL | fn use_self(&self) -> &() { panic!() } + | -------- calling this method introduces the `impl`'s 'static` requirement +help: consider relaxing the implicit `'static` requirement + | +LL | impl dyn ObjectTrait + '_ { + | ^^^^ + +error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:13 + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + | ------------------- this data with lifetime `'a`... +LL | val.use_self() + | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | +note: `impl` of `ban::MyTrait` has a `'static` requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:83:26 + | +LL | fn use_self(&self) -> &() { panic!() } + | -------- calling this method introduces the `impl`'s 'static` requirement +... +LL | impl MyTrait for dyn ObjectTrait {} + | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement +help: consider relaxing the implicit `'static` requirement + | +LL | impl MyTrait for dyn ObjectTrait + '_ {} + | ^^^^ +help: to declare that the `impl Trait` captures data from argument `val`, you can add an explicit `'a` lifetime bound + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + | ^^^^ + +error[E0767]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13 + | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + | ------------------- this data with lifetime `'a`... +LL | val.use_self() + | ^^^^^^^^ ...is captured and required to live as long as `'static` here because of an implicit lifetime on the `impl` of `bar::MyTrait` + | +note: `impl` of `bar::MyTrait` has a `'static` requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26 + | +LL | impl MyTrait for dyn ObjectTrait { + | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement +LL | fn use_self(&self) -> &() { panic!() } + | -------- calling this method introduces the `impl`'s 'static` requirement +help: consider relaxing the implicit `'static` requirement + | +LL | impl MyTrait for dyn ObjectTrait + '_ { + | ^^^^ + +error[E0767]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13 + | +LL | fn use_it<'a>(val: &'a Box) -> &'a () { + | ----------------------------- this data with lifetime `'a`... +LL | val.use_self() + | ^^^^^^^^ ...is captured and required to live as long as `'static` here because of an implicit lifetime on the `impl` of `baz::MyTrait` + | +note: `impl` of `baz::MyTrait` has a `'static` requirement + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30 + | +LL | impl MyTrait for Box { + | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement +LL | fn use_self(&self) -> &() { panic!() } + | -------- calling this method introduces the `impl`'s 'static` requirement +help: consider relaxing the implicit `'static` requirement + | +LL | impl MyTrait for Box { + | ^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index d3853445dfdfe..94dd826a15cae 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -16,7 +16,7 @@ fn foo(g: G, dest: &mut T) -> impl FnOnce() where G: Get { - move || { //~ ERROR cannot infer an appropriate lifetime + move || { //~ ERROR `dest` *dest = g.get(); } } diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 9ab060328537b..d7051515f1102 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -6,7 +6,7 @@ LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | | | help: consider introducing lifetime `'a` here: `'a,` -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `dest` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/missing-lifetimes-in-signature.rs:19:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs index f78edb1c83a4c..d8446e58dbb63 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs @@ -27,7 +27,7 @@ impl Bar { fn iter(&self) -> impl Iterator> { Iter { current: None, - remaining: self.0.iter(), //~ ERROR cannot infer an appropriate lifetime + remaining: self.0.iter(), //~ ERROR E0759 } } } @@ -38,7 +38,7 @@ impl Baz { fn iter(&self) -> impl Iterator> + '_ { Iter { current: None, - remaining: self.0.iter(), //~ ERROR cannot infer an appropriate lifetime + remaining: self.0.iter(), //~ ERROR E0759 } } } @@ -49,7 +49,7 @@ impl Bat { fn iter<'a>(&'a self) -> impl Iterator> + 'a { Iter { current: None, - remaining: self.0.iter(), //~ ERROR cannot infer an appropriate lifetime + remaining: self.0.iter(), //~ ERROR E0759 } } } @@ -60,7 +60,7 @@ impl Ban { fn iter<'a>(&'a self) -> impl Iterator> { Iter { current: None, - remaining: self.0.iter(), //~ ERROR cannot infer an appropriate lifetime + remaining: self.0.iter(), //~ ERROR E0759 } } } diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr index 1257e9b172cf7..9f30787f07cc6 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/trait-object-nested-in-impl-trait.rs:30:31 | LL | fn iter(&self) -> impl Iterator> { @@ -23,7 +23,7 @@ help: to declare that the trait object captures data from argument `self`, you c LL | fn iter(&self) -> impl Iterator> { | ^^^^ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/trait-object-nested-in-impl-trait.rs:41:31 | LL | fn iter(&self) -> impl Iterator> + '_ { @@ -44,7 +44,7 @@ help: to declare that the trait object captures data from argument `self`, you c LL | fn iter(&self) -> impl Iterator> + '_ { | ^^^^ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/trait-object-nested-in-impl-trait.rs:52:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { @@ -65,7 +65,7 @@ help: to declare that the trait object captures data from argument `self`, you c LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ^^^^ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement --> $DIR/trait-object-nested-in-impl-trait.rs:63:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> { diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs index d5aa18eb0f4e7..e951adf030f5c 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs @@ -5,7 +5,7 @@ fn a(items: &[T]) -> Box> { // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` - Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime + Box::new(items.iter()) //~ ERROR E0759 } fn b(items: &[T]) -> Box + '_> { diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr index dda5de431d309..dd804864dab4f 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr @@ -1,4 +1,4 @@ -error[E0759]: cannot infer an appropriate lifetime +error[E0759]: `items` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/dyn-trait-underscore.rs:8:20 | LL | fn a(items: &[T]) -> Box> { diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 571e7a59113ad..d6e28e93c9667 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -867,6 +867,7 @@ impl Config { &self.target == name || // triple util::matches_os(&self.target, name) || // target util::matches_env(&self.target, name) || // env + self.target.ends_with(name) || // target and env name == util::get_arch(&self.target) || // architecture name == util::get_pointer_width(&self.target) || // pointer width name == self.stage_id.split('-').next().unwrap() || // stage diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 396d6c0cfcdef..470fab496a442 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -119,6 +119,7 @@ fn contains_ignore_directive(can_contain: bool, contents: &str, check: &str) -> // Update `can_contain` when changing this if contents.contains(&format!("// ignore-tidy-{}", check)) || contents.contains(&format!("# ignore-tidy-{}", check)) + || contents.contains(&format!("/* ignore-tidy-{} */", check)) { Directive::Ignore(false) } else { @@ -136,15 +137,37 @@ macro_rules! suppressible_tidy_err { }; } +pub fn is_in(full_path: &Path, parent_folder_to_find: &str, folder_to_find: &str) -> bool { + if let Some(parent) = full_path.parent() { + if parent.file_name().map_or_else( + || false, + |f| { + f.to_string_lossy() == folder_to_find + && parent + .parent() + .and_then(|f| f.file_name()) + .map_or_else(|| false, |f| f == parent_folder_to_find) + }, + ) { + true + } else { + is_in(parent, parent_folder_to_find, folder_to_find) + } + } else { + false + } +} + pub fn check(path: &Path, bad: &mut bool) { super::walk(path, &mut super::filter_dirs, &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); - let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md"]; + let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css"]; if extensions.iter().all(|e| !filename.ends_with(e)) || filename.starts_with(".#") { return; } + let is_style_file = filename.ends_with(".css"); let under_rustfmt = filename.ends_with(".rs") && // This list should ideally be sourced from rustfmt.toml but we don't want to add a toml // parser to tidy. @@ -161,6 +184,10 @@ pub fn check(path: &Path, bad: &mut bool) { // currently), just the long error code explanation ones. return; } + if is_style_file && !is_in(file, "src", "librustdoc") { + // We only check CSS files in rustdoc. + return; + } if contents.is_empty() { tidy_error!(bad, "{}: empty file", file.display()); @@ -172,8 +199,9 @@ pub fn check(path: &Path, bad: &mut bool) { COLS }; - let can_contain = - contents.contains("// ignore-tidy-") || contents.contains("# ignore-tidy-"); + let can_contain = contents.contains("// ignore-tidy-") + || contents.contains("# ignore-tidy-") + || contents.contains("/* ignore-tidy-"); // Enable testing ICE's that require specific (untidy) // file formats easily eg. `issue-1234-ignore-tidy.rs` if filename.contains("ignore-tidy") { @@ -208,12 +236,15 @@ pub fn check(path: &Path, bad: &mut bool) { &format!("line longer than {} chars", max_columns) ); } - if line.contains('\t') { + if !is_style_file && line.contains('\t') { suppressible_tidy_err!(err, skip_tab, "tab character"); } if line.ends_with(' ') || line.ends_with('\t') { suppressible_tidy_err!(err, skip_end_whitespace, "trailing whitespace"); } + if is_style_file && line.starts_with(' ') { + err("CSS files use tabs for indent"); + } if line.contains('\r') { suppressible_tidy_err!(err, skip_cr, "CR character"); }