From a03d19ef63d342c408d7ec8208bda5b4eb0bacf5 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Wed, 14 Feb 2024 23:43:00 +0000 Subject: [PATCH 01/35] Allow targets to override default codegen backend --- compiler/rustc_driver_impl/src/lib.rs | 19 +++++- compiler/rustc_interface/src/interface.rs | 76 +++++++++++++++++++---- compiler/rustc_interface/src/tests.rs | 14 ++++- compiler/rustc_interface/src/util.rs | 47 +++++++------- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_session/src/session.rs | 9 +-- compiler/rustc_target/src/spec/mod.rs | 9 +++ 7 files changed, 130 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 60f11b1bdd4..bc485b05223 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -35,7 +35,7 @@ use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS}; use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType}; use rustc_session::getopts::{self, Matches}; use rustc_session::lint::{Lint, LintId}; -use rustc_session::{config, EarlyDiagCtxt, Session}; +use rustc_session::{config, filesearch, EarlyDiagCtxt, Session}; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::source_map::FileLoader; use rustc_span::symbol::sym; @@ -887,7 +887,13 @@ pub fn version_at_macro_invocation( let debug_flags = matches.opt_strs("Z"); let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); - get_codegen_backend(early_dcx, &None, backend_name).print_version(); + let opts = config::Options::default(); + let sysroot = opts.maybe_sysroot.clone().unwrap_or_else(|| { + filesearch::get_or_default_sysroot().expect("Failed finding sysroot") + }); + let target = config::build_target_config(early_dcx, &opts, None, &sysroot); + + get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_version(); } } @@ -1092,7 +1098,14 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> if cg_flags.iter().any(|x| *x == "passes=list") { let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); - get_codegen_backend(early_dcx, &None, backend_name).print_passes(); + + let opts = config::Options::default(); + let sysroot = opts.maybe_sysroot.clone().unwrap_or_else(|| { + filesearch::get_or_default_sysroot().expect("Failed finding sysroot") + }); + let target = config::build_target_config(early_dcx, &opts, None, &sysroot); + + get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_passes(); return true; } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 8a4705e0056..f53b320f2e0 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -16,7 +16,7 @@ use rustc_parse::maybe_new_parser_from_source_str; use rustc_query_impl::QueryCtxt; use rustc_query_system::query::print_query_stack; use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName}; -use rustc_session::filesearch::sysroot_candidates; +use rustc_session::filesearch::{self, sysroot_candidates}; use rustc_session::parse::ParseSess; use rustc_session::{lint, CompilerIO, EarlyDiagCtxt, Session}; use rustc_span::source_map::FileLoader; @@ -336,14 +336,66 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let early_dcx = EarlyDiagCtxt::new(config.opts.error_format); - let codegen_backend = if let Some(make_codegen_backend) = config.make_codegen_backend { - make_codegen_backend(&config.opts) - } else { - util::get_codegen_backend( - &early_dcx, - &config.opts.maybe_sysroot, - config.opts.unstable_opts.codegen_backend.as_deref(), - ) + let sysroot = match &config.opts.maybe_sysroot { + Some(sysroot) => sysroot.clone(), + None => filesearch::get_or_default_sysroot().expect("Failed finding sysroot"), + }; + + let (codegen_backend, target_cfg) = match config.make_codegen_backend { + None => { + // Build a target without override, so that it can override the backend if needed + let target = + config::build_target_config(&early_dcx, &config.opts, None, &sysroot); + + let backend = util::get_codegen_backend( + &early_dcx, + &sysroot, + config.opts.unstable_opts.codegen_backend.as_deref(), + &target, + ); + + // target_override is documented to be called before init(), so this is okay + let target_override = backend.target_override(&config.opts); + + // Assert that we don't use target's override of the backend and + // backend's override of the target at the same time + if config.opts.unstable_opts.codegen_backend.is_none() + && target.default_codegen_backend.is_some() + && target_override.is_some() + { + rustc_middle::bug!( + "Codegen backend requested target override even though the target requested the backend" + ); + } + + // Re-build target with the (potential) override + let target = config::build_target_config( + &early_dcx, + &config.opts, + target_override, + &sysroot, + ); + + (backend, target) + } + Some(make_codegen_backend) => { + // N.B. `make_codegen_backend` takes precedence over `target.default_codegen_backend`, + // which is ignored in this case. + + let backend = make_codegen_backend(&config.opts); + + // target_override is documented to be called before init(), so this is okay + let target_override = backend.target_override(&config.opts); + + let target = config::build_target_config( + &early_dcx, + &config.opts, + target_override, + &sysroot, + ); + + (backend, target) + } }; let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from); @@ -364,9 +416,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let mut locale_resources = Vec::from(config.locale_resources); locale_resources.push(codegen_backend.locale_resource()); - // target_override is documented to be called before init(), so this is okay - let target_override = codegen_backend.target_override(&config.opts); - let mut sess = rustc_session::build_session( early_dcx, config.opts, @@ -381,7 +430,8 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se locale_resources, config.lint_caps, config.file_loader, - target_override, + target_cfg, + sysroot, util::rustc_version_str().unwrap_or("unknown"), config.ice_file, config.using_internal_features, diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index bfc4fc07d4c..b1d874d7204 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -37,6 +37,17 @@ fn mk_session(matches: getopts::Matches) -> (Session, Cfg) { output_file: None, temps_dir, }; + + let sysroot = match &sessopts.maybe_sysroot { + Some(sysroot) => sysroot.clone(), + None => { + rustc_session::filesearch::get_or_default_sysroot().expect("Failed finding sysroot") + } + }; + + let target_cfg = + rustc_session::config::build_target_config(&early_dcx, &sessopts, None, &sysroot); + let sess = build_session( early_dcx, sessopts, @@ -46,7 +57,8 @@ fn mk_session(matches: getopts::Matches) -> (Session, Cfg) { vec![], Default::default(), None, - None, + target_cfg, + sysroot, "", None, Arc::default(), diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 76b9e8de75f..38c5157d450 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -14,14 +14,15 @@ use rustc_session::{filesearch, output, Session}; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edition::Edition; use rustc_span::symbol::{sym, Symbol}; +use rustc_target::spec::Target; use session::EarlyDiagCtxt; -use std::env; use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; use std::mem; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::OnceLock; use std::thread; +use std::{env, iter}; /// Function pointer type that constructs a new CodegenBackend. pub type MakeBackendFn = fn() -> Box; @@ -192,21 +193,25 @@ fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBacken /// A name of `None` indicates that the default backend should be used. pub fn get_codegen_backend( early_dcx: &EarlyDiagCtxt, - maybe_sysroot: &Option, + sysroot: &Path, backend_name: Option<&str>, + target: &Target, ) -> Box { static LOAD: OnceLock Box> = OnceLock::new(); let load = LOAD.get_or_init(|| { - let default_codegen_backend = option_env!("CFG_DEFAULT_CODEGEN_BACKEND").unwrap_or("llvm"); + let backend = backend_name + .or(target.default_codegen_backend.as_deref()) + .or(option_env!("CFG_DEFAULT_CODEGEN_BACKEND")) + .unwrap_or("llvm"); - match backend_name.unwrap_or(default_codegen_backend) { + match backend { filename if filename.contains('.') => { load_backend_from_dylib(early_dcx, filename.as_ref()) } #[cfg(feature = "llvm")] "llvm" => rustc_codegen_llvm::LlvmCodegenBackend::new, - backend_name => get_codegen_sysroot(early_dcx, maybe_sysroot, backend_name), + backend_name => get_codegen_sysroot(early_dcx, sysroot, backend_name), } }); @@ -240,7 +245,7 @@ fn get_rustc_path_inner(bin_path: &str) -> Option { fn get_codegen_sysroot( early_dcx: &EarlyDiagCtxt, - maybe_sysroot: &Option, + sysroot: &Path, backend_name: &str, ) -> MakeBackendFn { // For now we only allow this function to be called once as it'll dlopen a @@ -257,28 +262,28 @@ fn get_codegen_sysroot( let target = session::config::host_triple(); let sysroot_candidates = sysroot_candidates(); - let sysroot = maybe_sysroot - .iter() - .chain(sysroot_candidates.iter()) + let sysroot = iter::once(sysroot) + .chain(sysroot_candidates.iter().map(<_>::as_ref)) .map(|sysroot| { filesearch::make_target_lib_path(sysroot, target).with_file_name("codegen-backends") }) .find(|f| { info!("codegen backend candidate: {}", f.display()); f.exists() - }); - let sysroot = sysroot.unwrap_or_else(|| { - let candidates = sysroot_candidates - .iter() - .map(|p| p.display().to_string()) - .collect::>() - .join("\n* "); - let err = format!( - "failed to find a `codegen-backends` folder \ + }) + .unwrap_or_else(|| { + let candidates = sysroot_candidates + .iter() + .map(|p| p.display().to_string()) + .collect::>() + .join("\n* "); + let err = format!( + "failed to find a `codegen-backends` folder \ in the sysroot candidates:\n* {candidates}" - ); - early_dcx.early_fatal(err); - }); + ); + early_dcx.early_fatal(err); + }); + info!("probing {} for a codegen backend", sysroot.display()); let d = sysroot.read_dir().unwrap_or_else(|e| { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d35f951e2ae..63bc902c813 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1558,7 +1558,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg { user_cfg } -pub(super) fn build_target_config( +pub fn build_target_config( early_dcx: &EarlyDiagCtxt, opts: &Options, target_override: Option, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 25c20be8e62..2a8b507a227 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1034,7 +1034,8 @@ pub fn build_session( fluent_resources: Vec<&'static str>, driver_lint_caps: FxHashMap, file_loader: Option>, - target_override: Option, + target_cfg: Target, + sysroot: PathBuf, cfg_version: &'static str, ice_file: Option, using_internal_features: Arc, @@ -1051,12 +1052,6 @@ pub fn build_session( let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow); - let sysroot = match &sopts.maybe_sysroot { - Some(sysroot) => sysroot.clone(), - None => filesearch::get_or_default_sysroot().expect("Failed finding sysroot"), - }; - - let target_cfg = config::build_target_config(&early_dcx, &sopts, target_override, &sysroot); let host_triple = TargetTriple::from_triple(config::host_triple()); let (host, target_warnings) = Target::search(&host_triple, &sysroot).unwrap_or_else(|e| { early_dcx.early_fatal(format!("Error loading host specification: {e}")) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d04bcb2d78a..ec48930b20b 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2044,6 +2044,14 @@ pub struct TargetOptions { /// Default number of codegen units to use in debug mode pub default_codegen_units: Option, + /// Default codegen backend used for this target. Defaults to `None`. + /// + /// If `None`, then `CFG_DEFAULT_CODEGEN_BACKEND` environmental variable captured when + /// compiling `rustc` will be used instead (or llvm if it is not set). + /// + /// N.B. when *using* the compiler, backend can always be overriden with `-Zcodegen-backend`. + pub default_codegen_backend: Option>, + /// Whether to generate trap instructions in places where optimization would /// otherwise produce control flow that falls through into unrelated memory. pub trap_unreachable: bool, @@ -2350,6 +2358,7 @@ impl Default for TargetOptions { stack_probes: StackProbeType::None, min_global_align: None, default_codegen_units: None, + default_codegen_backend: None, trap_unreachable: true, requires_lto: false, singlethread: false, From 5441523f0727639040fdd134abff1e298d88733e Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 15 Feb 2024 00:03:34 +0000 Subject: [PATCH 02/35] Refactor out a repeating pattern with `get_or_default_sysroot` --- compiler/rustc_driver_impl/src/lib.rs | 8 ++------ compiler/rustc_interface/src/interface.rs | 5 +---- compiler/rustc_interface/src/tests.rs | 9 ++------- compiler/rustc_session/src/config.rs | 16 ++++------------ compiler/rustc_session/src/filesearch.rs | 6 ++++++ 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index bc485b05223..0920505d86e 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -888,9 +888,7 @@ pub fn version_at_macro_invocation( let debug_flags = matches.opt_strs("Z"); let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); let opts = config::Options::default(); - let sysroot = opts.maybe_sysroot.clone().unwrap_or_else(|| { - filesearch::get_or_default_sysroot().expect("Failed finding sysroot") - }); + let sysroot = filesearch::materialize_sysroot(opts.maybe_sysroot.clone()); let target = config::build_target_config(early_dcx, &opts, None, &sysroot); get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_version(); @@ -1100,9 +1098,7 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); let opts = config::Options::default(); - let sysroot = opts.maybe_sysroot.clone().unwrap_or_else(|| { - filesearch::get_or_default_sysroot().expect("Failed finding sysroot") - }); + let sysroot = filesearch::materialize_sysroot(opts.maybe_sysroot.clone()); let target = config::build_target_config(early_dcx, &opts, None, &sysroot); get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_passes(); diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index f53b320f2e0..a45762b2ce7 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -336,10 +336,7 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let early_dcx = EarlyDiagCtxt::new(config.opts.error_format); - let sysroot = match &config.opts.maybe_sysroot { - Some(sysroot) => sysroot.clone(), - None => filesearch::get_or_default_sysroot().expect("Failed finding sysroot"), - }; + let sysroot = filesearch::materialize_sysroot(config.opts.maybe_sysroot.clone()); let (codegen_backend, target_cfg) = match config.make_codegen_backend { None => { diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index b1d874d7204..0651950b967 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -13,7 +13,7 @@ use rustc_session::config::{ use rustc_session::lint::Level; use rustc_session::search_paths::SearchPath; use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; -use rustc_session::{build_session, getopts, CompilerIO, EarlyDiagCtxt, Session}; +use rustc_session::{build_session, filesearch, getopts, CompilerIO, EarlyDiagCtxt, Session}; use rustc_span::edition::{Edition, DEFAULT_EDITION}; use rustc_span::symbol::sym; use rustc_span::{FileName, SourceFileHashAlgorithm}; @@ -38,12 +38,7 @@ fn mk_session(matches: getopts::Matches) -> (Session, Cfg) { temps_dir, }; - let sysroot = match &sessopts.maybe_sysroot { - Some(sysroot) => sysroot.clone(), - None => { - rustc_session::filesearch::get_or_default_sysroot().expect("Failed finding sysroot") - } - }; + let sysroot = filesearch::materialize_sysroot(sessopts.maybe_sysroot.clone()); let target_cfg = rustc_session::config::build_target_config(&early_dcx, &sessopts, None, &sysroot); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 63bc902c813..2ad959d3832 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -6,7 +6,7 @@ pub use crate::options::*; use crate::errors::FileWriteFail; use crate::search_paths::SearchPath; use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; -use crate::{lint, HashStableContext}; +use crate::{filesearch, lint, HashStableContext}; use crate::{EarlyDiagCtxt, Session}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; @@ -2856,16 +2856,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M let logical_env = parse_logical_env(early_dcx, matches); - // Try to find a directory containing the Rust `src`, for more details see - // the doc comment on the `real_rust_source_base_dir` field. - let tmp_buf; - let sysroot = match &sysroot_opt { - Some(s) => s, - None => { - tmp_buf = crate::filesearch::get_or_default_sysroot().expect("Failed finding sysroot"); - &tmp_buf - } - }; + let sysroot = filesearch::materialize_sysroot(sysroot_opt); + let real_rust_source_base_dir = { // This is the location used by the `rust-src` `rustup` component. let mut candidate = sysroot.join("lib/rustlib/src/rust"); @@ -2909,7 +2901,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M describe_lints, output_types, search_paths, - maybe_sysroot: sysroot_opt, + maybe_sysroot: Some(sysroot), target_triple, test, incremental, diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index 6e459ac45d3..668acc0f761 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -194,6 +194,12 @@ pub fn sysroot_candidates() -> SmallVec<[PathBuf; 2]> { return sysroot_candidates; } +/// Returns the provided sysroot or calls [`get_or_default_sysroot`] if it's none. +/// Panics if [`get_or_default_sysroot`] returns an error. +pub fn materialize_sysroot(maybe_sysroot: Option) -> PathBuf { + maybe_sysroot.unwrap_or_else(|| get_or_default_sysroot().expect("Failed finding sysroot")) +} + /// This function checks if sysroot is found using env::args().next(), and if it /// is not found, finds sysroot from current rustc_driver dll. pub fn get_or_default_sysroot() -> Result { From 9a77ec98b801e0fbd2b249d4f8edbb081c3d1e85 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 15 Feb 2024 00:14:44 +0000 Subject: [PATCH 03/35] Rename `-Zno_parallel_llvm` -> `-Zno_parallel_backend` --- compiler/rustc_codegen_ssa/src/back/write.rs | 4 ++-- compiler/rustc_interface/src/tests.rs | 2 +- compiler/rustc_session/src/options.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index a63642d76b9..4a59e8faea7 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1399,7 +1399,7 @@ fn start_executing_work( .binary_search_by_key(&cost, |&(_, cost)| cost) .unwrap_or_else(|e| e); work_items.insert(insertion_index, (work, cost)); - if !cgcx.opts.unstable_opts.no_parallel_llvm { + if !cgcx.opts.unstable_opts.no_parallel_backend { helper.request_token(); } } @@ -1522,7 +1522,7 @@ fn start_executing_work( }; work_items.insert(insertion_index, (llvm_work_item, cost)); - if !cgcx.opts.unstable_opts.no_parallel_llvm { + if !cgcx.opts.unstable_opts.no_parallel_backend { helper.request_token(); } assert_eq!(main_thread_state, MainThreadState::Codegenning); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index bfc4fc07d4c..d1fe2b3b5cd 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -685,7 +685,7 @@ fn test_unstable_options_tracking_hash() { untracked!(nll_facts, true); untracked!(no_analysis, true); untracked!(no_leak_check, true); - untracked!(no_parallel_llvm, true); + untracked!(no_parallel_backend, true); untracked!(parse_only, true); // `pre_link_arg` is omitted because it just forwards to `pre_link_args`. untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index ea93ac5841f..923757eea82 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1753,7 +1753,7 @@ options! { "disable the 'leak check' for subtyping; unsound, but useful for tests"), no_link: bool = (false, parse_no_flag, [TRACKED], "compile without linking"), - no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED], + no_parallel_backend: bool = (false, parse_no_flag, [UNTRACKED], "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"), no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED], "prevent automatic injection of the profiler_builtins crate"), From f368922cfa58d2ebc98b6153e62bcb65e27fcf67 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 15 Feb 2024 00:23:56 +0000 Subject: [PATCH 04/35] Allow codegen backends to opt-out of parallel codegen --- compiler/rustc_codegen_ssa/src/back/write.rs | 9 +++++++-- compiler/rustc_codegen_ssa/src/traits/backend.rs | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 4a59e8faea7..5f6d3c9aafc 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -369,6 +369,10 @@ pub struct CodegenContext { pub incr_comp_session_dir: Option, /// Channel back to the main control thread to send messages to pub coordinator_send: Sender>, + /// `true` if the codegen should be run in parallel. + /// + /// Depends on [`CodegenBackend::supports_parallel()`] and `-Zno_parallel_backend`. + pub parallel: bool, } impl CodegenContext { @@ -1129,6 +1133,7 @@ fn start_executing_work( target_arch: tcx.sess.target.arch.to_string(), split_debuginfo: tcx.sess.split_debuginfo(), split_dwarf_kind: tcx.sess.opts.unstable_opts.split_dwarf_kind, + parallel: backend.supports_parallel() && !sess.opts.unstable_opts.no_parallel_backend, }; // This is the "main loop" of parallel work happening for parallel codegen. @@ -1399,7 +1404,7 @@ fn start_executing_work( .binary_search_by_key(&cost, |&(_, cost)| cost) .unwrap_or_else(|e| e); work_items.insert(insertion_index, (work, cost)); - if !cgcx.opts.unstable_opts.no_parallel_backend { + if cgcx.parallel { helper.request_token(); } } @@ -1522,7 +1527,7 @@ fn start_executing_work( }; work_items.insert(insertion_index, (llvm_work_item, cost)); - if !cgcx.opts.unstable_opts.no_parallel_backend { + if cgcx.parallel { helper.request_token(); } assert_eq!(main_thread_state, MainThreadState::Codegenning); diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 8e9907ed8bb..e8412a9b6eb 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -111,6 +111,13 @@ pub trait CodegenBackend { codegen_results: CodegenResults, outputs: &OutputFilenames, ) -> Result<(), ErrorGuaranteed>; + + /// Returns `true` if this backend can be safely called from multiple threads. + /// + /// Defaults to `true`. + fn supports_parallel(&self) -> bool { + true + } } pub trait ExtraBackendMethods: From 8bb49e22b550b9ccdca3a1f9bc1e52532ec39635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sun, 31 Dec 2023 05:06:53 +0100 Subject: [PATCH 05/35] Propagate the resolved type of assoc const bindings via query feeding --- .../rustc_hir_analysis/src/astconv/bounds.rs | 15 ++++++- compiler/rustc_hir_analysis/src/collect.rs | 1 + .../rustc_hir_analysis/src/collect/type_of.rs | 45 +++++++------------ compiler/rustc_middle/src/query/erase.rs | 4 ++ compiler/rustc_middle/src/query/mod.rs | 5 +++ compiler/rustc_middle/src/ty/context.rs | 17 +++++++ .../assoc-const-eq-supertraits.rs | 16 +++++++ .../assoc-const-eq-ty-alias-noninteracting.rs | 16 ++++--- .../associated-const-equality.rs | 11 ++++- 9 files changed, 92 insertions(+), 38 deletions(-) create mode 100644 tests/ui/associated-consts/assoc-const-eq-supertraits.rs diff --git a/compiler/rustc_hir_analysis/src/astconv/bounds.rs b/compiler/rustc_hir_analysis/src/astconv/bounds.rs index 6940b4a5045..a9b4dca08d4 100644 --- a/compiler/rustc_hir_analysis/src/astconv/bounds.rs +++ b/compiler/rustc_hir_analysis/src/astconv/bounds.rs @@ -408,7 +408,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ { // Create the generic arguments for the associated type or constant by joining the // parent arguments (the arguments of the trait) and the own arguments (the ones of // the associated item itself) and construct an alias type using them. - candidate.map_bound(|trait_ref| { + let alias_ty = candidate.map_bound(|trait_ref| { let ident = Ident::new(assoc_item.name, binding.ident.span); let item_segment = hir::PathSegment { ident, @@ -430,7 +430,18 @@ impl<'tcx> dyn AstConv<'tcx> + '_ { // *constants* to represent *const projections*. Alias *term* would be a more // appropriate name but alas. ty::AliasTy::new(tcx, assoc_item.def_id, alias_args) - }) + }); + + // Provide the resolved type of the associated constant to `type_of(AnonConst)`. + if !speculative && let ty::AssocKind::Const = assoc_kind { + let ty = alias_ty.map_bound(|ty| tcx.type_of(ty.def_id).instantiate(tcx, ty.args)); + // Since the arguments passed to the alias type above may contain early-bound + // generic parameters, the instantiated type may contain some as well. + // Therefore wrap it in `EarlyBinder`. + tcx.feed_type_of_assoc_const_binding(binding.hir_id, ty::EarlyBinder::bind(ty)); + } + + alias_ty }; match binding.kind { diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index a5ef1490bce..d82d3eccfc6 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -63,6 +63,7 @@ pub fn provide(providers: &mut Providers) { *providers = Providers { type_of: type_of::type_of, type_of_opaque: type_of::type_of_opaque, + type_of_assoc_const_binding: type_of::type_of_assoc_const_binding, type_alias_is_lazy: type_of::type_alias_is_lazy, item_bounds: item_bounds::item_bounds, explicit_item_bounds: item_bounds::explicit_item_bounds, diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index c0128afe2bf..57bcf7602ea 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -78,35 +78,10 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { .expect("const parameter types cannot be generic"); } - Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. }) - if let Node::TraitRef(trait_ref) = tcx.parent_hir_node(binding_id) => - { - let Some(trait_def_id) = trait_ref.trait_def_id() else { - return Ty::new_error_with_message( - tcx, - tcx.def_span(def_id), - "Could not find trait", - ); - }; - let assoc_items = tcx.associated_items(trait_def_id); - let assoc_item = assoc_items.find_by_name_and_kind( - tcx, - binding.ident, - ty::AssocKind::Const, - def_id.to_def_id(), - ); - return if let Some(assoc_item) = assoc_item { - tcx.type_of(assoc_item.def_id) - .no_bound_vars() - .expect("const parameter types cannot be generic") - } else { - // FIXME(associated_const_equality): add a useful error message here. - Ty::new_error_with_message( - tcx, - tcx.def_span(def_id), - "Could not find associated const on trait", - ) - }; + Node::TypeBinding(&TypeBinding { hir_id, .. }) => { + // FIXME(fmease): Reject “escaping” early-bound generic parameters. + // FIXME(fmease): Reject escaping late-bound vars. + return tcx.type_of_assoc_const_binding(hir_id).skip_binder().skip_binder(); } // This match arm is for when the def_id appears in a GAT whose @@ -315,6 +290,18 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { } } +pub(super) fn type_of_assoc_const_binding<'tcx>( + tcx: TyCtxt<'tcx>, + hir_id: HirId, +) -> ty::EarlyBinder>> { + let reported = tcx.dcx().delayed_bug(format!( + "attempt to obtain type of assoc const binding `{hir_id}` before \ + it was resolved by `add_predicates_for_ast_type_binding`" + )); + + ty::EarlyBinder::bind(ty::Binder::dummy(Ty::new_error(tcx, reported))) +} + fn get_path_containing_arg_in_pat<'hir>( pat: &'hir hir::Pat<'hir>, arg_id: HirId, diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 2cdcdcb1492..82e0844a85c 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -193,6 +193,10 @@ impl EraseType for ty::EarlyBinder { type Result = T::Result; } +impl EraseType for ty::Binder<'_, Ty<'_>> { + type Result = [u8; size_of::>>()]; +} + impl EraseType for ty::Binder<'_, ty::FnSig<'_>> { type Result = [u8; size_of::>>()]; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 5be45c33e11..ce1e3484d69 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -248,6 +248,11 @@ rustc_queries! { cycle_stash } + query type_of_assoc_const_binding(key: hir::HirId) -> ty::EarlyBinder>> { + desc { |tcx| "getting type of associated constant binding `{key:?}`" } + feedable + } + query type_alias_is_lazy(key: DefId) -> bool { desc { |tcx| "computing whether `{path}` is a lazy type alias", diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cc734e7157f..acd68a5bd87 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -71,6 +71,7 @@ use rustc_type_ir::TyKind::*; use rustc_type_ir::WithCachedTypeInfo; use rustc_type_ir::{CollectAndApply, Interner, TypeFlags}; +use std::assert_matches::debug_assert_matches; use std::borrow::Borrow; use std::cmp::Ordering; use std::fmt; @@ -540,6 +541,22 @@ impl<'tcx> TyCtxt<'tcx> { debug_assert_eq!(self.def_kind(key), DefKind::AnonConst); TyCtxtFeed { tcx: self, key }.type_of(value) } + + pub fn feed_type_of_assoc_const_binding( + self, + key: hir::HirId, + value: ty::EarlyBinder>>, + ) { + debug_assert_matches!( + self.hir_node(key), + hir::Node::TypeBinding(hir::TypeBinding { + kind: hir::TypeBindingKind::Equality { term: hir::Term::Const(_) }, + .. + }) + ); + + TyCtxtFeed { tcx: self, key }.type_of_assoc_const_binding(value) + } } impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> { diff --git a/tests/ui/associated-consts/assoc-const-eq-supertraits.rs b/tests/ui/associated-consts/assoc-const-eq-supertraits.rs new file mode 100644 index 00000000000..d5d724c9b15 --- /dev/null +++ b/tests/ui/associated-consts/assoc-const-eq-supertraits.rs @@ -0,0 +1,16 @@ +// Regression test for issue #118040. +// Ensure that we support assoc const eq bounds where the assoc const comes from a supertrait. + +//@ check-pass + +#![feature(associated_const_equality)] + +trait Trait: SuperTrait {} +trait SuperTrait: SuperSuperTrait {} +trait SuperSuperTrait { + const K: T; +} + +fn take(_: impl Trait) {} + +fn main() {} diff --git a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs index 4ff05112897..76df014ccd9 100644 --- a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs +++ b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs @@ -1,21 +1,25 @@ // Regression test for issue #112560. // Respect the fact that (associated) types and constants live in different namespaces and // therefore equality bounds involving identically named associated items don't conflict if -// their kind (type vs. const) differs. - -// FIXME(fmease): Extend this test to cover supertraits again -// once #118040 is fixed. See initial version of PR #118360. +// their kind (type vs. const) differs. This obviously extends to supertraits. //@ check-pass #![feature(associated_const_equality)] -trait Trait { +trait Trait: SuperTrait { type N; + type Q; const N: usize; } -fn take(_: impl Trait) {} +trait SuperTrait { + const Q: &'static str; +} + +fn take0(_: impl Trait) {} + +fn take1(_: impl Trait) {} fn main() {} diff --git a/tests/ui/generic-const-items/associated-const-equality.rs b/tests/ui/generic-const-items/associated-const-equality.rs index 3c727097e2b..c0179f02fd2 100644 --- a/tests/ui/generic-const-items/associated-const-equality.rs +++ b/tests/ui/generic-const-items/associated-const-equality.rs @@ -1,22 +1,31 @@ //@ check-pass -#![feature(generic_const_items, associated_const_equality)] +#![feature(generic_const_items, associated_const_equality, adt_const_params)] #![allow(incomplete_features)] trait Owner { const C: u32; const K: u32; + const Q: Maybe; } impl Owner for () { const C: u32 = N; const K: u32 = N + 1; + const Q: Maybe = Maybe::Nothing; } fn take0(_: impl Owner = { N }>) {} fn take1(_: impl Owner = 100>) {} +fn take2(_: impl Owner = { Maybe::Just(()) }>) {} fn main() { take0::<128>(()); take1(()); } + +#[derive(PartialEq, Eq, std::marker::ConstParamTy)] +enum Maybe { + Nothing, + Just(T), +} From 6d115f5d9a05380b983dd53d747150c8afbd48d8 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 18 Feb 2024 19:26:45 +0000 Subject: [PATCH 06/35] Refactor out another repeating pattern --- compiler/rustc_interface/src/interface.rs | 26 ++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index a45762b2ce7..9783327efd3 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -338,7 +338,7 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let sysroot = filesearch::materialize_sysroot(config.opts.maybe_sysroot.clone()); - let (codegen_backend, target_cfg) = match config.make_codegen_backend { + let (codegen_backend, target_override) = match config.make_codegen_backend { None => { // Build a target without override, so that it can override the backend if needed let target = @@ -365,36 +365,24 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se ); } - // Re-build target with the (potential) override - let target = config::build_target_config( - &early_dcx, - &config.opts, - target_override, - &sysroot, - ); - - (backend, target) + (backend, target_override) } Some(make_codegen_backend) => { // N.B. `make_codegen_backend` takes precedence over `target.default_codegen_backend`, // which is ignored in this case. - let backend = make_codegen_backend(&config.opts); // target_override is documented to be called before init(), so this is okay let target_override = backend.target_override(&config.opts); - let target = config::build_target_config( - &early_dcx, - &config.opts, - target_override, - &sysroot, - ); - - (backend, target) + (backend, target_override) } }; + // Re-build target with the (potential) override + let target_cfg = + config::build_target_config(&early_dcx, &config.opts, target_override, &sysroot); + let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from); let bundle = match rustc_errors::fluent_bundle( From b94498a3788699f839ee690d96d3288148c756d5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 21 Feb 2024 10:28:20 +0000 Subject: [PATCH 07/35] Use existing query feeding workarounds --- .../rustc_hir_analysis/src/astconv/bounds.rs | 11 ++++++++++- compiler/rustc_hir_analysis/src/collect.rs | 1 - .../rustc_hir_analysis/src/collect/type_of.rs | 18 ------------------ compiler/rustc_middle/src/query/erase.rs | 4 ---- compiler/rustc_middle/src/query/mod.rs | 5 ----- compiler/rustc_middle/src/ty/context.rs | 17 ----------------- 6 files changed, 10 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/bounds.rs b/compiler/rustc_hir_analysis/src/astconv/bounds.rs index a9b4dca08d4..117df5482e6 100644 --- a/compiler/rustc_hir_analysis/src/astconv/bounds.rs +++ b/compiler/rustc_hir_analysis/src/astconv/bounds.rs @@ -434,11 +434,20 @@ impl<'tcx> dyn AstConv<'tcx> + '_ { // Provide the resolved type of the associated constant to `type_of(AnonConst)`. if !speculative && let ty::AssocKind::Const = assoc_kind { + let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } = + binding.kind + else { + bug!() + }; let ty = alias_ty.map_bound(|ty| tcx.type_of(ty.def_id).instantiate(tcx, ty.args)); // Since the arguments passed to the alias type above may contain early-bound // generic parameters, the instantiated type may contain some as well. // Therefore wrap it in `EarlyBinder`. - tcx.feed_type_of_assoc_const_binding(binding.hir_id, ty::EarlyBinder::bind(ty)); + // FIXME(fmease): Reject escaping late-bound vars. + tcx.feed_anon_const_type( + anon_const.def_id, + ty::EarlyBinder::bind(ty.skip_binder()), + ); } alias_ty diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index d82d3eccfc6..a5ef1490bce 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -63,7 +63,6 @@ pub fn provide(providers: &mut Providers) { *providers = Providers { type_of: type_of::type_of, type_of_opaque: type_of::type_of_opaque, - type_of_assoc_const_binding: type_of::type_of_assoc_const_binding, type_alias_is_lazy: type_of::type_alias_is_lazy, item_bounds: item_bounds::item_bounds, explicit_item_bounds: item_bounds::explicit_item_bounds, diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 57bcf7602ea..ddb02247d16 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -78,12 +78,6 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { .expect("const parameter types cannot be generic"); } - Node::TypeBinding(&TypeBinding { hir_id, .. }) => { - // FIXME(fmease): Reject “escaping” early-bound generic parameters. - // FIXME(fmease): Reject escaping late-bound vars. - return tcx.type_of_assoc_const_binding(hir_id).skip_binder().skip_binder(); - } - // This match arm is for when the def_id appears in a GAT whose // path can't be resolved without typechecking e.g. // @@ -290,18 +284,6 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { } } -pub(super) fn type_of_assoc_const_binding<'tcx>( - tcx: TyCtxt<'tcx>, - hir_id: HirId, -) -> ty::EarlyBinder>> { - let reported = tcx.dcx().delayed_bug(format!( - "attempt to obtain type of assoc const binding `{hir_id}` before \ - it was resolved by `add_predicates_for_ast_type_binding`" - )); - - ty::EarlyBinder::bind(ty::Binder::dummy(Ty::new_error(tcx, reported))) -} - fn get_path_containing_arg_in_pat<'hir>( pat: &'hir hir::Pat<'hir>, arg_id: HirId, diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 82e0844a85c..2cdcdcb1492 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -193,10 +193,6 @@ impl EraseType for ty::EarlyBinder { type Result = T::Result; } -impl EraseType for ty::Binder<'_, Ty<'_>> { - type Result = [u8; size_of::>>()]; -} - impl EraseType for ty::Binder<'_, ty::FnSig<'_>> { type Result = [u8; size_of::>>()]; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index ce1e3484d69..5be45c33e11 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -248,11 +248,6 @@ rustc_queries! { cycle_stash } - query type_of_assoc_const_binding(key: hir::HirId) -> ty::EarlyBinder>> { - desc { |tcx| "getting type of associated constant binding `{key:?}`" } - feedable - } - query type_alias_is_lazy(key: DefId) -> bool { desc { |tcx| "computing whether `{path}` is a lazy type alias", diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index acd68a5bd87..cc734e7157f 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -71,7 +71,6 @@ use rustc_type_ir::TyKind::*; use rustc_type_ir::WithCachedTypeInfo; use rustc_type_ir::{CollectAndApply, Interner, TypeFlags}; -use std::assert_matches::debug_assert_matches; use std::borrow::Borrow; use std::cmp::Ordering; use std::fmt; @@ -541,22 +540,6 @@ impl<'tcx> TyCtxt<'tcx> { debug_assert_eq!(self.def_kind(key), DefKind::AnonConst); TyCtxtFeed { tcx: self, key }.type_of(value) } - - pub fn feed_type_of_assoc_const_binding( - self, - key: hir::HirId, - value: ty::EarlyBinder>>, - ) { - debug_assert_matches!( - self.hir_node(key), - hir::Node::TypeBinding(hir::TypeBinding { - kind: hir::TypeBindingKind::Equality { term: hir::Term::Const(_) }, - .. - }) - ); - - TyCtxtFeed { tcx: self, key }.type_of_assoc_const_binding(value) - } } impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> { From 3908a935ef821c2828a7d825eac859f8ff54702a Mon Sep 17 00:00:00 2001 From: Noa Date: Wed, 21 Feb 2024 17:32:58 -0600 Subject: [PATCH 08/35] std support for wasm32 panic=unwind --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 13 ++++++-- library/panic_unwind/src/lib.rs | 13 +++++++- library/panic_unwind/src/wasm.rs | 32 ++++++++++++++++++++ library/std/src/sys/personality/mod.rs | 8 ++--- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 library/panic_unwind/src/wasm.rs diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 54e8ed85e32..e383673e1d4 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -5,6 +5,7 @@ use crate::errors::{ }; use crate::llvm; use libc::c_int; +use rustc_codegen_ssa::base::wants_wasm_eh; use rustc_codegen_ssa::traits::PrintBackendInfo; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::small_c_str::SmallCStr; @@ -98,8 +99,12 @@ unsafe fn configure_llvm(sess: &Session) { } } - if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind { - add("-enable-emscripten-cxx-exceptions", false); + if sess.panic_strategy() == PanicStrategy::Unwind { + if sess.target.os == "emscripten" { + add("-enable-emscripten-cxx-exceptions", false); + } else if wants_wasm_eh(sess) { + add("-wasm-enable-eh", false); + } } // HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes @@ -520,6 +525,10 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec>; + +extern "C" { + /// LLVM lowers this intrinsic to the `throw` instruction. + #[link_name = "llvm.wasm.throw"] + fn wasm_throw(tag: i32, ptr: *mut u8) -> !; +} + +pub unsafe fn panic(payload: Box) -> u32 { + // The payload we pass to `wasm_throw` will be exactly the argument we get + // in `cleanup` below. So we just box it up once, to get something pointer-sized. + let payload_box: Payload = Box::new(payload); + // The wasm `throw` instruction takes a "tag", which differentiates certain + // types of exceptions from others. LLVM currently just identifies these + // via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp(). + // Ideally, we'd be able to choose something unique for Rust, such that we + // don't try to treat a C++ exception payload as a `Box>`, but + // otherwise, pretending to be C++ works for now. + wasm_throw(0, Box::into_raw(payload_box) as *mut u8) +} + +pub unsafe fn cleanup(payload_box: *mut u8) -> Box { + // Recover the underlying `Box`. + let payload_box: Payload = Box::from_raw(payload_box as *mut _); + *payload_box +} diff --git a/library/std/src/sys/personality/mod.rs b/library/std/src/sys/personality/mod.rs index d37b8ce6346..1a6ea1dafcb 100644 --- a/library/std/src/sys/personality/mod.rs +++ b/library/std/src/sys/personality/mod.rs @@ -16,11 +16,12 @@ mod dwarf; cfg_if::cfg_if! { if #[cfg(target_os = "emscripten")] { mod emcc; - } else if #[cfg(target_env = "msvc")] { + } else if #[cfg(any(target_env = "msvc", target_family = "wasm"))] { // This is required by the compiler to exist (e.g., it's a lang item), // but it's never actually called by the compiler because - // _CxxFrameHandler3 is the personality function that is always used. - // Hence this is just an aborting stub. + // __CxxFrameHandler3 (msvc) / __gxx_wasm_personality_v0 (wasm) is the + // personality function that is always used. Hence this is just an + // aborting stub. #[lang = "eh_personality"] fn rust_eh_personality() { core::intrinsics::abort() @@ -36,7 +37,6 @@ cfg_if::cfg_if! { mod gcc; } else { // Targets that don't support unwinding. - // - family=wasm // - os=none ("bare metal" targets) // - os=uefi // - os=espidf From 861c7e74c8bbc49082dcd38ef7169d99c69cd104 Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 22 Feb 2024 00:34:54 -0600 Subject: [PATCH 09/35] Fix llvm hang --- compiler/rustc_codegen_ssa/src/mir/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 75d413dedad..4a4ac60d59e 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1539,7 +1539,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let funclet; let llbb; let mut bx; - if base::wants_msvc_seh(self.cx.sess()) { + if base::wants_new_eh_instructions(self.cx.sess()) { // This is a basic block that we're aborting the program for, // notably in an `extern` function. These basic blocks are inserted // so that we assert that `extern` functions do indeed not panic, From 658a0a20eac4341e31c57cf08e019b53f09b93b4 Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 22 Feb 2024 16:52:48 -0600 Subject: [PATCH 10/35] Unconditionally pass -wasm-enable-eh --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 12 ++++++------ library/panic_unwind/src/lib.rs | 7 +------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index e383673e1d4..51e1f408a69 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -99,12 +99,12 @@ unsafe fn configure_llvm(sess: &Session) { } } - if sess.panic_strategy() == PanicStrategy::Unwind { - if sess.target.os == "emscripten" { - add("-enable-emscripten-cxx-exceptions", false); - } else if wants_wasm_eh(sess) { - add("-wasm-enable-eh", false); - } + if wants_wasm_eh(sess) { + add("-wasm-enable-eh", false); + } + + if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind { + add("-enable-emscripten-cxx-exceptions", false); } // HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index bc3c9363d8a..37e1d2cf6d1 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -60,12 +60,7 @@ cfg_if::cfg_if! { ))] { #[path = "gcc.rs"] mod real_imp; - } else if #[cfg(all(target_family = "wasm", panic = "unwind"))] { - // for now, PanicStrategy::Unwind is not the default for wasm targets, - // so we need the panic = "unwind" in the cfg above. to use llvm.wasm.throw, - // we need to pass -wasm-enable-eh to LLVM, but that only happens if rustc - // is compiling with -C panic=unwind. So, this lets us -Zbuild-std with - // panic=unwind, while keeping the default panic=abort working. + } else if #[cfg(target_family = "wasm")] { #[path = "wasm.rs"] mod real_imp; } else { From 125b26acf6f3127ecdd344c372691cefe0e9243e Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 22 Feb 2024 17:32:06 -0600 Subject: [PATCH 11/35] Use Itanium ABI for thrown exceptions --- library/panic_unwind/src/gcc.rs | 2 +- library/panic_unwind/src/lib.rs | 8 +---- library/panic_unwind/src/wasm.rs | 32 ------------------ library/unwind/src/lib.rs | 8 ++++- library/unwind/src/libunwind.rs | 2 +- library/unwind/src/unwinding.rs | 2 +- library/unwind/src/wasm.rs | 56 ++++++++++++++++++++++++++++++++ 7 files changed, 67 insertions(+), 43 deletions(-) delete mode 100644 library/panic_unwind/src/wasm.rs create mode 100644 library/unwind/src/wasm.rs diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 54eb6627c01..589d3c1b4d2 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -62,7 +62,7 @@ pub unsafe fn panic(data: Box) -> u32 { let exception = Box::new(Exception { _uwe: uw::_Unwind_Exception { exception_class: rust_exception_class(), - exception_cleanup, + exception_cleanup: Some(exception_cleanup), private: [core::ptr::null(); uw::unwinder_private_data_size], }, canary: &CANARY, diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 37e1d2cf6d1..dde1c64c6f1 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -16,10 +16,6 @@ #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![feature(core_intrinsics)] #![feature(lang_items)] -#![cfg_attr( - all(target_family = "wasm", not(target_os = "emscripten")), - feature(link_llvm_intrinsics) -)] #![feature(panic_unwind)] #![feature(staged_api)] #![feature(std_internals)] @@ -57,12 +53,10 @@ cfg_if::cfg_if! { target_os = "solid_asp3", all(target_family = "unix", not(target_os = "espidf")), all(target_vendor = "fortanix", target_env = "sgx"), + target_family = "wasm", ))] { #[path = "gcc.rs"] mod real_imp; - } else if #[cfg(target_family = "wasm")] { - #[path = "wasm.rs"] - mod real_imp; } else { // Targets that don't support unwinding. // - os=none ("bare metal" targets) diff --git a/library/panic_unwind/src/wasm.rs b/library/panic_unwind/src/wasm.rs deleted file mode 100644 index b11fb912b63..00000000000 --- a/library/panic_unwind/src/wasm.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Unwinding panics for wasm32. -use alloc::boxed::Box; -use core::any::Any; - -// The type of the exception payload that the wasm engine propagates -// through unwinding for us. LLVM requires that it be a thin pointer. -type Payload = Box>; - -extern "C" { - /// LLVM lowers this intrinsic to the `throw` instruction. - #[link_name = "llvm.wasm.throw"] - fn wasm_throw(tag: i32, ptr: *mut u8) -> !; -} - -pub unsafe fn panic(payload: Box) -> u32 { - // The payload we pass to `wasm_throw` will be exactly the argument we get - // in `cleanup` below. So we just box it up once, to get something pointer-sized. - let payload_box: Payload = Box::new(payload); - // The wasm `throw` instruction takes a "tag", which differentiates certain - // types of exceptions from others. LLVM currently just identifies these - // via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp(). - // Ideally, we'd be able to choose something unique for Rust, such that we - // don't try to treat a C++ exception payload as a `Box>`, but - // otherwise, pretending to be C++ works for now. - wasm_throw(0, Box::into_raw(payload_box) as *mut u8) -} - -pub unsafe fn cleanup(payload_box: *mut u8) -> Box { - // Recover the underlying `Box`. - let payload_box: Payload = Box::from_raw(payload_box as *mut _); - *payload_box -} diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index f5988a4df13..c25c949b942 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -6,6 +6,10 @@ #![feature(cfg_target_abi)] #![feature(strict_provenance)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] +#![cfg_attr( + all(target_family = "wasm", not(target_os = "emscripten")), + feature(link_llvm_intrinsics) +)] #![allow(internal_features)] cfg_if::cfg_if! { @@ -29,9 +33,11 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "xous")] { mod unwinding; pub use unwinding::*; + } else if #[cfg(target_family = "wasm")] { + mod wasm; + pub use wasm::*; } else { // no unwinder on the system! - // - wasm32 (not emscripten, which is "unix" family) // - os=none ("bare metal" targets) // - os=hermit // - os=uefi diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 1b5f6f9dde3..617a2ad7ebc 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -91,7 +91,7 @@ pub struct _Unwind_Exception { pub enum _Unwind_Context {} pub type _Unwind_Exception_Cleanup_Fn = - extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); + Option; // FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in // the block are reexported in dylib build of std. This is needed when build rustc with diff --git a/library/unwind/src/unwinding.rs b/library/unwind/src/unwinding.rs index 1a4187b2220..95e2eb000cc 100644 --- a/library/unwind/src/unwinding.rs +++ b/library/unwind/src/unwinding.rs @@ -46,7 +46,7 @@ pub const unwinder_private_data_size: usize = core::mem::size_of::(); pub type _Unwind_Exception_Cleanup_Fn = - extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); + Option; #[repr(C)] pub struct _Unwind_Exception { diff --git a/library/unwind/src/wasm.rs b/library/unwind/src/wasm.rs new file mode 100644 index 00000000000..1de12905f89 --- /dev/null +++ b/library/unwind/src/wasm.rs @@ -0,0 +1,56 @@ +//! A shim for libunwind implemented in terms of the native wasm `throw` instruction. + +#![allow(nonstandard_style)] + +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub enum _Unwind_Reason_Code { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8, + _URC_FAILURE = 9, // used only by ARM EHABI +} +pub use _Unwind_Reason_Code::*; + +pub type _Unwind_Exception_Class = u64; +pub type _Unwind_Word = *const u8; + +pub const unwinder_private_data_size: usize = 2; + +#[repr(C)] +pub struct _Unwind_Exception { + pub exception_class: _Unwind_Exception_Class, + pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, + pub private: [_Unwind_Word; unwinder_private_data_size], +} + +pub type _Unwind_Exception_Cleanup_Fn = + Option; + +pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) { + if let Some(exception_cleanup) = unsafe { (*exception).exception_cleanup } { + exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, exception); + } +} + +pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { + extern "C" { + /// LLVM lowers this intrinsic to the `throw` instruction. + // FIXME(coolreader18): move to stdarch + #[link_name = "llvm.wasm.throw"] + fn wasm_throw(tag: i32, ptr: *mut u8) -> !; + } + + // The wasm `throw` instruction takes a "tag", which differentiates certain + // types of exceptions from others. LLVM currently just identifies these + // via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp(). + // Ideally, we'd be able to choose something unique for Rust, but for now, + // we pretend to be C++ and implement the Itanium exception-handling ABI. + wasm_throw(0, exception.cast()) +} From c7fcf437f1cde4e7f45dcdaf57e80f178d47bd65 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 26 Feb 2024 11:56:48 -0600 Subject: [PATCH 12/35] Don't codegen wasm.throw unless with -Zbuild-std --- library/unwind/src/wasm.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/unwind/src/wasm.rs b/library/unwind/src/wasm.rs index 1de12905f89..b06671bcb83 100644 --- a/library/unwind/src/wasm.rs +++ b/library/unwind/src/wasm.rs @@ -40,6 +40,7 @@ pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) { } pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { + #[cfg(panic = "unwind")] extern "C" { /// LLVM lowers this intrinsic to the `throw` instruction. // FIXME(coolreader18): move to stdarch @@ -52,5 +53,13 @@ pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwi // via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp(). // Ideally, we'd be able to choose something unique for Rust, but for now, // we pretend to be C++ and implement the Itanium exception-handling ABI. - wasm_throw(0, exception.cast()) + cfg_if::cfg_if! { + // for now, unless we're -Zbuild-std with panic=unwind, never codegen a throw. + if #[cfg(panic = "unwind")] { + wasm_throw(0, exception.cast()) + } else { + let _ = exception; + core::arch::wasm32::unreachable() + } + } } From 858d3362095851bde4f9cc3c132542f2ce9e9a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Fri, 23 Feb 2024 06:47:09 +0100 Subject: [PATCH 13/35] Slightly simplify feeding of assoc const eq bounds --- compiler/rustc_hir_analysis/src/astconv/bounds.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/bounds.rs b/compiler/rustc_hir_analysis/src/astconv/bounds.rs index 117df5482e6..c72096ea465 100644 --- a/compiler/rustc_hir_analysis/src/astconv/bounds.rs +++ b/compiler/rustc_hir_analysis/src/astconv/bounds.rs @@ -433,12 +433,10 @@ impl<'tcx> dyn AstConv<'tcx> + '_ { }); // Provide the resolved type of the associated constant to `type_of(AnonConst)`. - if !speculative && let ty::AssocKind::Const = assoc_kind { - let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } = + if !speculative + && let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } = binding.kind - else { - bug!() - }; + { let ty = alias_ty.map_bound(|ty| tcx.type_of(ty.def_id).instantiate(tcx, ty.args)); // Since the arguments passed to the alias type above may contain early-bound // generic parameters, the instantiated type may contain some as well. From d9a2886ef8ba8716abbaad338d1e7278d66d25b8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 29 Feb 2024 10:14:16 +0100 Subject: [PATCH 14/35] add comment and test: we do not do value-based reasoning for promotion of unions --- .../src/transform/check_consts/qualifs.rs | 1 + tests/ui/consts/promote-not.rs | 9 +++ tests/ui/consts/promote-not.stderr | 61 +++++++++++-------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 7eb3c181d69..1847847d9d2 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -284,6 +284,7 @@ where if Q::in_adt_inherently(cx, def, args) { return true; } + // Don't do any value-based reasoning for unions. if def.is_union() && Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)) { return true; } diff --git a/tests/ui/consts/promote-not.rs b/tests/ui/consts/promote-not.rs index 47a06e8a72b..e0f02354354 100644 --- a/tests/ui/consts/promote-not.rs +++ b/tests/ui/consts/promote-not.rs @@ -3,6 +3,7 @@ #![allow(unconditional_panic)] use std::cell::Cell; +use std::mem::ManuallyDrop; // We do not promote mutable references. static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); //~ ERROR temporary value dropped while borrowed @@ -69,4 +70,12 @@ fn main() { let _val: &'static _ = &[&TEST_DROP; 1]; //~^ ERROR temporary value dropped while borrowed //~| ERROR temporary value dropped while borrowed + + // Make sure there is no value-based reasoning for unions. + union UnionWithCell { + f1: i32, + f2: ManuallyDrop>, + } + let x: &'static _ = &UnionWithCell { f1: 0 }; + //~^ ERROR temporary value dropped while borrowed } diff --git a/tests/ui/consts/promote-not.stderr b/tests/ui/consts/promote-not.stderr index 67ac5922efd..9dbd703d489 100644 --- a/tests/ui/consts/promote-not.stderr +++ b/tests/ui/consts/promote-not.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:8:50 + --> $DIR/promote-not.rs:9:50 | LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); | ----------^^^^^^^^^- @@ -9,7 +9,7 @@ LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:11:18 + --> $DIR/promote-not.rs:12:18 | LL | let x = &mut [1,2,3]; | ^^^^^^^ creates a temporary value which is freed while still in use @@ -19,7 +19,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:33:29 + --> $DIR/promote-not.rs:34:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -29,7 +29,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:39:29 + --> $DIR/promote-not.rs:40:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -39,7 +39,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:20:32 + --> $DIR/promote-not.rs:21:32 | LL | let _x: &'static () = &foo(); | ----------- ^^^^^ creates a temporary value which is freed while still in use @@ -49,7 +49,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:28:29 + --> $DIR/promote-not.rs:29:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -59,7 +59,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:46:29 + --> $DIR/promote-not.rs:47:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).0; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -70,7 +70,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:47:29 + --> $DIR/promote-not.rs:48:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -81,7 +81,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:50:29 + --> $DIR/promote-not.rs:51:29 | LL | let _val: &'static _ = &(1/0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -92,7 +92,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:51:29 + --> $DIR/promote-not.rs:52:29 | LL | let _val: &'static _ = &(1/(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -103,7 +103,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:52:29 + --> $DIR/promote-not.rs:53:29 | LL | let _val: &'static _ = &((1+1)/(1-1)); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -114,7 +114,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:53:29 + --> $DIR/promote-not.rs:54:29 | LL | let _val: &'static _ = &(i32::MIN/-1); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -125,7 +125,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:54:29 + --> $DIR/promote-not.rs:55:29 | LL | let _val: &'static _ = &(i32::MIN/(0-1)); | ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -136,7 +136,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:55:29 + --> $DIR/promote-not.rs:56:29 | LL | let _val: &'static _ = &(-128i8/-1); | ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -147,7 +147,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:56:29 + --> $DIR/promote-not.rs:57:29 | LL | let _val: &'static _ = &(1%0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -158,7 +158,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:57:29 + --> $DIR/promote-not.rs:58:29 | LL | let _val: &'static _ = &(1%(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -169,7 +169,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:58:29 + --> $DIR/promote-not.rs:59:29 | LL | let _val: &'static _ = &([1,2,3][4]+1); | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -180,7 +180,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:61:29 + --> $DIR/promote-not.rs:62:29 | LL | let _val: &'static _ = &TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -191,7 +191,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:63:29 + --> $DIR/promote-not.rs:64:29 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -202,7 +202,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:63:30 + --> $DIR/promote-not.rs:64:30 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -213,7 +213,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:66:29 + --> $DIR/promote-not.rs:67:29 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -224,7 +224,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:66:31 + --> $DIR/promote-not.rs:67:31 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -235,7 +235,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:69:29 + --> $DIR/promote-not.rs:70:29 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -246,7 +246,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:69:31 + --> $DIR/promote-not.rs:70:31 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement @@ -254,6 +254,17 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1]; | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` -error: aborting due to 24 previous errors +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:79:26 + | +LL | let x: &'static _ = &UnionWithCell { f1: 0 }; + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 25 previous errors For more information about this error, try `rustc --explain E0716`. From 30fa6a8b50f899d45f78c0596397d18b718782b0 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 6 Mar 2024 21:13:43 +1100 Subject: [PATCH 15/35] Rename `DropTreeBuilder::add_entry` to `link_entry_point` --- compiler/rustc_mir_build/src/build/scope.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 04740a96291..a27c43928eb 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -247,7 +247,7 @@ trait DropTreeBuilder<'tcx> { /// Links a block outside the drop tree, `from`, to the block `to` inside /// the drop tree. - fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock); + fn link_entry_point(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock); } impl DropTree { @@ -332,7 +332,7 @@ impl DropTree { needs_block[drop_idx] = Block::Own; while entry_points.last().is_some_and(|entry_point| entry_point.0 == drop_idx) { let entry_block = entry_points.pop().unwrap().1; - T::add_entry(cfg, entry_block, block); + T::link_entry_point(cfg, entry_block, block); } } match needs_block[drop_idx] { @@ -1439,7 +1439,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for ExitScopes { fn make_block(cfg: &mut CFG<'tcx>) -> BasicBlock { cfg.start_new_block() } - fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { + fn link_entry_point(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { cfg.block_data_mut(from).terminator_mut().kind = TerminatorKind::Goto { target: to }; } } @@ -1450,7 +1450,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for CoroutineDrop { fn make_block(cfg: &mut CFG<'tcx>) -> BasicBlock { cfg.start_new_block() } - fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { + fn link_entry_point(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { let term = cfg.block_data_mut(from).terminator_mut(); if let TerminatorKind::Yield { ref mut drop, .. } = term.kind { *drop = Some(to); @@ -1470,7 +1470,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind { fn make_block(cfg: &mut CFG<'tcx>) -> BasicBlock { cfg.start_new_cleanup_block() } - fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { + fn link_entry_point(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { let term = &mut cfg.block_data_mut(from).terminator_mut(); match &mut term.kind { TerminatorKind::Drop { unwind, .. } => { From 3bd8df96e12d22793cd8dc694f07becb1f6f4f3d Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 6 Mar 2024 21:27:41 +1100 Subject: [PATCH 16/35] Assert that `link_entry_point` sees the expected dummy terminator --- compiler/rustc_mir_build/src/build/scope.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index a27c43928eb..7ed493ec9c7 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -678,6 +678,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // `build_drop_trees` doesn't have access to our source_info, so we // create a dummy terminator now. `TerminatorKind::UnwindResume` is used // because MIR type checking will panic if it hasn't been overwritten. + // (See `::link_entry_point`.) self.cfg.terminate(block, source_info, TerminatorKind::UnwindResume); self.cfg.start_new_block().unit() @@ -710,6 +711,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // `build_drop_trees` doesn't have access to our source_info, so we // create a dummy terminator now. `TerminatorKind::UnwindResume` is used // because MIR type checking will panic if it hasn't been overwritten. + // (See `::link_entry_point`.) self.cfg.terminate(block, source_info, TerminatorKind::UnwindResume); } @@ -1440,7 +1442,15 @@ impl<'tcx> DropTreeBuilder<'tcx> for ExitScopes { cfg.start_new_block() } fn link_entry_point(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { - cfg.block_data_mut(from).terminator_mut().kind = TerminatorKind::Goto { target: to }; + // There should be an existing terminator with real source info and a + // dummy TerminatorKind. Replace it with a proper goto. + // (The dummy is added by `break_scope` and `break_for_else`.) + let term = cfg.block_data_mut(from).terminator_mut(); + if let TerminatorKind::UnwindResume = term.kind { + term.kind = TerminatorKind::Goto { target: to }; + } else { + span_bug!(term.source_info.span, "unexpected dummy terminator kind: {:?}", term.kind); + } } } From fbdac30427822da7ad2b11d93e4fe40a5279a1e6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 6 Mar 2024 22:24:16 +1100 Subject: [PATCH 17/35] Rename `DropTree::add_entry` to `add_entry_point` This clarifies that we're adding an "entry point", not just adding an "entry" of some kind. --- compiler/rustc_mir_build/src/build/scope.rs | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 7ed493ec9c7..f9c53e068c8 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -271,7 +271,11 @@ impl DropTree { .or_insert_with(|| drops.push((drop, next))) } - fn add_entry(&mut self, from: BasicBlock, to: DropIdx) { + /// Registers `from` as an entry point to this drop tree, at `to`. + /// + /// During [`Self::build_mir`], `from` will be linked to the corresponding + /// block within the drop tree. + fn add_entry_point(&mut self, from: BasicBlock, to: DropIdx) { debug_assert!(to < self.drops.next_index()); self.entry_points.push((to, from)); } @@ -673,7 +677,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .flat_map(|scope| &scope.drops) .fold(ROOT_NODE, |drop_idx, &drop| drops.add_drop(drop, drop_idx)); - drops.add_entry(block, drop_idx); + drops.add_entry_point(block, drop_idx); // `build_drop_trees` doesn't have access to our source_info, so we // create a dummy terminator now. `TerminatorKind::UnwindResume` is used @@ -706,7 +710,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { drop_idx = drops.add_drop(*drop, drop_idx); } } - drops.add_entry(block, drop_idx); + drops.add_entry_point(block, drop_idx); // `build_drop_trees` doesn't have access to our source_info, so we // create a dummy terminator now. `TerminatorKind::UnwindResume` is used @@ -1118,7 +1122,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ); let next_drop = self.diverge_cleanup(); - self.scopes.unwind_drops.add_entry(start, next_drop); + self.scopes.unwind_drops.add_entry_point(start, next_drop); } /// Sets up a path that performs all required cleanup for dropping a @@ -1152,7 +1156,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope.cached_coroutine_drop_block = Some(cached_drop); } - self.scopes.coroutine_drops.add_entry(yield_block, cached_drop); + self.scopes.coroutine_drops.add_entry_point(yield_block, cached_drop); } /// Utility function for *non*-scope code to build their own drops @@ -1285,7 +1289,7 @@ fn build_scope_drops<'tcx>( continue; } - unwind_drops.add_entry(block, unwind_to); + unwind_drops.add_entry_point(block, unwind_to); let next = cfg.start_new_block(); cfg.terminate( @@ -1355,9 +1359,10 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { .scopes .unwind_drops .add_drop(drop_data.0, unwind_indices[drop_data.1]); - self.scopes - .unwind_drops - .add_entry(blocks[drop_idx].unwrap(), unwind_indices[drop_data.1]); + self.scopes.unwind_drops.add_entry_point( + blocks[drop_idx].unwrap(), + unwind_indices[drop_data.1], + ); unwind_indices.push(unwind_drop); } } From 5ba70bd3ec6cedfe49332226dc9dbfe427698ad3 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 6 Mar 2024 22:22:05 +1100 Subject: [PATCH 18/35] Replace tuples in `DropTree` with named structs This allows us to use real field names instead of tuple element numbers. Renaming `previous_drops` to `existing_drops_map` clarifies that "previous" was unrelated to drop order. --- compiler/rustc_mir_build/src/build/scope.rs | 107 ++++++++++++-------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index f9c53e068c8..d5d0d425137 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -203,16 +203,31 @@ const ROOT_NODE: DropIdx = DropIdx::from_u32(0); /// in `build_mir`. #[derive(Debug)] struct DropTree { - /// Drops in the tree. - drops: IndexVec, - /// Map for finding the inverse of the `next_drop` relation: - /// - /// `previous_drops[(drops[i].1, drops[i].0.local, drops[i].0.kind)] == i` - previous_drops: FxHashMap<(DropIdx, Local, DropKind), DropIdx>, + /// Nodes in the drop tree, containing drop data and a link to the next node. + drops: IndexVec, + /// Map for finding the index of an existing node, given its contents. + existing_drops_map: FxHashMap, /// Edges into the `DropTree` that need to be added once it's lowered. entry_points: Vec<(DropIdx, BasicBlock)>, } +/// A single node in the drop tree. +#[derive(Debug)] +struct DropNode { + /// Info about the drop to be performed at this node in the drop tree. + data: DropData, + /// Index of the "next" drop to perform (in drop order, not declaration order). + next: DropIdx, +} + +/// Subset of [`DropNode`] used for reverse lookup in a hash table. +#[derive(Debug, PartialEq, Eq, Hash)] +struct DropNodeKey { + next: DropIdx, + local: Local, + kind: DropKind, +} + impl Scope { /// Whether there's anything to do for the cleanup path, that is, /// when unwinding through this scope. This includes destructors, @@ -258,17 +273,22 @@ impl DropTree { let fake_source_info = SourceInfo::outermost(DUMMY_SP); let fake_data = DropData { source_info: fake_source_info, local: Local::MAX, kind: DropKind::Storage }; - let drop_idx = DropIdx::MAX; - let drops = IndexVec::from_elem_n((fake_data, drop_idx), 1); - Self { drops, entry_points: Vec::new(), previous_drops: FxHashMap::default() } + let drops = IndexVec::from_raw(vec![DropNode { data: fake_data, next: DropIdx::MAX }]); + Self { drops, entry_points: Vec::new(), existing_drops_map: FxHashMap::default() } } - fn add_drop(&mut self, drop: DropData, next: DropIdx) -> DropIdx { + /// Adds a node to the drop tree, consisting of drop data and the index of + /// the "next" drop (in drop order), which could be the sentinel [`ROOT_NODE`]. + /// + /// If there is already an equivalent node in the tree, nothing is added, and + /// that node's index is returned. Otherwise, the new node's index is returned. + fn add_drop(&mut self, data: DropData, next: DropIdx) -> DropIdx { let drops = &mut self.drops; *self - .previous_drops - .entry((next, drop.local, drop.kind)) - .or_insert_with(|| drops.push((drop, next))) + .existing_drops_map + .entry(DropNodeKey { next, local: data.local, kind: data.kind }) + // Create a new node, and also add its index to the map. + .or_insert_with(|| drops.push(DropNode { data, next })) } /// Registers `from` as an entry point to this drop tree, at `to`. @@ -330,7 +350,7 @@ impl DropTree { let entry_points = &mut self.entry_points; entry_points.sort(); - for (drop_idx, drop_data) in self.drops.iter_enumerated().rev() { + for (drop_idx, drop_node) in self.drops.iter_enumerated().rev() { if entry_points.last().is_some_and(|entry_point| entry_point.0 == drop_idx) { let block = *blocks[drop_idx].get_or_insert_with(|| T::make_block(cfg)); needs_block[drop_idx] = Block::Own; @@ -348,10 +368,10 @@ impl DropTree { blocks[drop_idx] = blocks[pred]; } } - if let DropKind::Value = drop_data.0.kind { - needs_block[drop_data.1] = Block::Own; + if let DropKind::Value = drop_node.data.kind { + needs_block[drop_node.next] = Block::Own; } else if drop_idx != ROOT_NODE { - match &mut needs_block[drop_data.1] { + match &mut needs_block[drop_node.next] { pred @ Block::None => *pred = Block::Shares(drop_idx), pred @ Block::Shares(_) => *pred = Block::Own, Block::Own => (), @@ -368,34 +388,35 @@ impl DropTree { cfg: &mut CFG<'tcx>, blocks: &IndexSlice>, ) { - for (drop_idx, drop_data) in self.drops.iter_enumerated().rev() { + for (drop_idx, drop_node) in self.drops.iter_enumerated().rev() { let Some(block) = blocks[drop_idx] else { continue }; - match drop_data.0.kind { + match drop_node.data.kind { DropKind::Value => { let terminator = TerminatorKind::Drop { - target: blocks[drop_data.1].unwrap(), + target: blocks[drop_node.next].unwrap(), // The caller will handle this if needed. unwind: UnwindAction::Terminate(UnwindTerminateReason::InCleanup), - place: drop_data.0.local.into(), + place: drop_node.data.local.into(), replace: false, }; - cfg.terminate(block, drop_data.0.source_info, terminator); + cfg.terminate(block, drop_node.data.source_info, terminator); } // Root nodes don't correspond to a drop. DropKind::Storage if drop_idx == ROOT_NODE => {} DropKind::Storage => { let stmt = Statement { - source_info: drop_data.0.source_info, - kind: StatementKind::StorageDead(drop_data.0.local), + source_info: drop_node.data.source_info, + kind: StatementKind::StorageDead(drop_node.data.local), }; cfg.push(block, stmt); - let target = blocks[drop_data.1].unwrap(); + let target = blocks[drop_node.next].unwrap(); if target != block { // Diagnostics don't use this `Span` but debuginfo // might. Since we don't want breakpoints to be placed // here, especially when this is on an unwind path, we // use `DUMMY_SP`. - let source_info = SourceInfo { span: DUMMY_SP, ..drop_data.0.source_info }; + let source_info = + SourceInfo { span: DUMMY_SP, ..drop_node.data.source_info }; let terminator = TerminatorKind::Goto { target }; cfg.terminate(block, source_info, terminator); } @@ -1277,9 +1298,9 @@ fn build_scope_drops<'tcx>( // `unwind_to` should drop the value that we're about to // schedule. If dropping this value panics, then we continue // with the *next* value on the unwind path. - debug_assert_eq!(unwind_drops.drops[unwind_to].0.local, drop_data.local); - debug_assert_eq!(unwind_drops.drops[unwind_to].0.kind, drop_data.kind); - unwind_to = unwind_drops.drops[unwind_to].1; + debug_assert_eq!(unwind_drops.drops[unwind_to].data.local, drop_data.local); + debug_assert_eq!(unwind_drops.drops[unwind_to].data.kind, drop_data.kind); + unwind_to = unwind_drops.drops[unwind_to].next; // If the operand has been moved, and we are not on an unwind // path, then don't generate the drop. (We only take this into @@ -1306,9 +1327,9 @@ fn build_scope_drops<'tcx>( } DropKind::Storage => { if storage_dead_on_unwind { - debug_assert_eq!(unwind_drops.drops[unwind_to].0.local, drop_data.local); - debug_assert_eq!(unwind_drops.drops[unwind_to].0.kind, drop_data.kind); - unwind_to = unwind_drops.drops[unwind_to].1; + debug_assert_eq!(unwind_drops.drops[unwind_to].data.local, drop_data.local); + debug_assert_eq!(unwind_drops.drops[unwind_to].data.kind, drop_data.kind); + unwind_to = unwind_drops.drops[unwind_to].next; } // Only temps and vars need their storage dead. assert!(local.index() > arg_count); @@ -1338,30 +1359,30 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { let is_coroutine = self.coroutine.is_some(); // Link the exit drop tree to unwind drop tree. - if drops.drops.iter().any(|(drop, _)| drop.kind == DropKind::Value) { + if drops.drops.iter().any(|drop_node| drop_node.data.kind == DropKind::Value) { let unwind_target = self.diverge_cleanup_target(else_scope, span); let mut unwind_indices = IndexVec::from_elem_n(unwind_target, 1); - for (drop_idx, drop_data) in drops.drops.iter_enumerated().skip(1) { - match drop_data.0.kind { + for (drop_idx, drop_node) in drops.drops.iter_enumerated().skip(1) { + match drop_node.data.kind { DropKind::Storage => { if is_coroutine { let unwind_drop = self .scopes .unwind_drops - .add_drop(drop_data.0, unwind_indices[drop_data.1]); + .add_drop(drop_node.data, unwind_indices[drop_node.next]); unwind_indices.push(unwind_drop); } else { - unwind_indices.push(unwind_indices[drop_data.1]); + unwind_indices.push(unwind_indices[drop_node.next]); } } DropKind::Value => { let unwind_drop = self .scopes .unwind_drops - .add_drop(drop_data.0, unwind_indices[drop_data.1]); + .add_drop(drop_node.data, unwind_indices[drop_node.next]); self.scopes.unwind_drops.add_entry_point( blocks[drop_idx].unwrap(), - unwind_indices[drop_data.1], + unwind_indices[drop_node.next], ); unwind_indices.push(unwind_drop); } @@ -1412,10 +1433,10 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { // prevent drop elaboration from creating drop flags that would have // to be captured by the coroutine. I'm not sure how important this // optimization is, but it is here. - for (drop_idx, drop_data) in drops.drops.iter_enumerated() { - if let DropKind::Value = drop_data.0.kind { - debug_assert!(drop_data.1 < drops.drops.next_index()); - drops.entry_points.push((drop_data.1, blocks[drop_idx].unwrap())); + for (drop_idx, drop_node) in drops.drops.iter_enumerated() { + if let DropKind::Value = drop_node.data.kind { + debug_assert!(drop_node.next < drops.drops.next_index()); + drops.entry_points.push((drop_node.next, blocks[drop_idx].unwrap())); } } Self::build_unwind_tree(cfg, drops, fn_span, resume_block); From d673fd8589e639060377b282f6248c98a4855502 Mon Sep 17 00:00:00 2001 From: beetrees Date: Fri, 8 Mar 2024 01:40:24 +0000 Subject: [PATCH 19/35] Remove the unused `field_remapping` field from `TypeLowering` --- compiler/rustc_codegen_llvm/src/context.rs | 13 ++-------- compiler/rustc_codegen_llvm/src/type_of.rs | 30 +++++----------------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 16122e5557e..10eb55a4dd7 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -77,8 +77,8 @@ pub struct CodegenCx<'ll, 'tcx> { /// See for details pub compiler_used_statics: RefCell>, - /// Mapping of non-scalar types to llvm types and field remapping if needed. - pub type_lowering: RefCell, Option), TypeLowering<'ll>>>, + /// Mapping of non-scalar types to llvm types. + pub type_lowering: RefCell, Option), &'ll Type>>, /// Mapping of scalar types to llvm types. pub scalar_lltypes: RefCell, &'ll Type>>, @@ -105,15 +105,6 @@ pub struct CodegenCx<'ll, 'tcx> { pub renamed_statics: RefCell>, } -pub struct TypeLowering<'ll> { - /// Associated LLVM type - pub lltype: &'ll Type, - - /// If padding is used the slice maps fields from source order - /// to llvm order. - pub field_remapping: Option>, -} - fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode { match tls_model { TlsModel::GeneralDynamic => llvm::ThreadLocalMode::GeneralDynamic, diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 587adefe1d2..d10a083765b 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -1,5 +1,4 @@ use crate::common::*; -use crate::context::TypeLowering; use crate::type_::Type; use rustc_codegen_ssa::traits::*; use rustc_middle::bug; @@ -10,7 +9,6 @@ use rustc_target::abi::HasDataLayout; use rustc_target::abi::{Abi, Align, FieldsShape}; use rustc_target::abi::{Int, Pointer, F128, F16, F32, F64}; use rustc_target::abi::{Scalar, Size, Variants}; -use smallvec::{smallvec, SmallVec}; use std::fmt::Write; @@ -18,7 +16,6 @@ fn uncached_llvm_type<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, layout: TyAndLayout<'tcx>, defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>, - field_remapping: &mut Option>, ) -> &'a Type { match layout.abi { Abi::Scalar(_) => bug!("handled elsewhere"), @@ -71,8 +68,7 @@ fn uncached_llvm_type<'a, 'tcx>( FieldsShape::Array { count, .. } => cx.type_array(layout.field(cx, 0).llvm_type(cx), count), FieldsShape::Arbitrary { .. } => match name { None => { - let (llfields, packed, new_field_remapping) = struct_llfields(cx, layout); - *field_remapping = new_field_remapping; + let (llfields, packed) = struct_llfields(cx, layout); cx.type_struct(&llfields, packed) } Some(ref name) => { @@ -87,7 +83,7 @@ fn uncached_llvm_type<'a, 'tcx>( fn struct_llfields<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, layout: TyAndLayout<'tcx>, -) -> (Vec<&'a Type>, bool, Option>) { +) -> (Vec<&'a Type>, bool) { debug!("struct_llfields: {:#?}", layout); let field_count = layout.fields.count(); @@ -95,7 +91,6 @@ fn struct_llfields<'a, 'tcx>( let mut offset = Size::ZERO; let mut prev_effective_align = layout.align.abi; let mut result: Vec<_> = Vec::with_capacity(1 + field_count * 2); - let mut field_remapping = smallvec![0; field_count]; for i in layout.fields.index_by_increasing_offset() { let target_offset = layout.fields.offset(i as usize); let field = layout.field(cx, i); @@ -120,12 +115,10 @@ fn struct_llfields<'a, 'tcx>( result.push(cx.type_padding_filler(padding, padding_align)); debug!(" padding before: {:?}", padding); } - field_remapping[i] = result.len() as u32; result.push(field.llvm_type(cx)); offset = target_offset + field.size; prev_effective_align = effective_field_align; } - let padding_used = result.len() > field_count; if layout.is_sized() && field_count > 0 { if offset > layout.size { bug!("layout: {:#?} stride: {:?} offset: {:?}", layout, layout.size, offset); @@ -143,8 +136,7 @@ fn struct_llfields<'a, 'tcx>( } else { debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size); } - let field_remapping = padding_used.then_some(field_remapping); - (result, packed, field_remapping) + (result, packed) } impl<'a, 'tcx> CodegenCx<'a, 'tcx> { @@ -224,7 +216,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { _ => None, }; if let Some(llty) = cx.type_lowering.borrow().get(&(self.ty, variant_index)) { - return llty.lltype; + return llty; } debug!("llvm_type({:#?})", self); @@ -236,7 +228,6 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { let normal_ty = cx.tcx.erase_regions(self.ty); let mut defer = None; - let mut field_remapping = None; let llty = if self.ty != normal_ty { let mut layout = cx.layout_of(normal_ty); if let Some(v) = variant_index { @@ -244,22 +235,15 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { } layout.llvm_type(cx) } else { - uncached_llvm_type(cx, *self, &mut defer, &mut field_remapping) + uncached_llvm_type(cx, *self, &mut defer) }; debug!("--> mapped {:#?} to llty={:?}", self, llty); - cx.type_lowering - .borrow_mut() - .insert((self.ty, variant_index), TypeLowering { lltype: llty, field_remapping }); + cx.type_lowering.borrow_mut().insert((self.ty, variant_index), llty); if let Some((llty, layout)) = defer { - let (llfields, packed, new_field_remapping) = struct_llfields(cx, layout); + let (llfields, packed) = struct_llfields(cx, layout); cx.set_struct_body(llty, &llfields, packed); - cx.type_lowering - .borrow_mut() - .get_mut(&(self.ty, variant_index)) - .unwrap() - .field_remapping = new_field_remapping; } llty } From bf47df8b0be83dde623a1057e63fd728c0ae5dec Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 Mar 2024 19:13:18 +0100 Subject: [PATCH 20/35] interpret: do not call machine read hooks during validation --- .../src/const_eval/eval_queries.rs | 8 +--- .../rustc_const_eval/src/interpret/machine.rs | 4 ++ .../rustc_const_eval/src/interpret/memory.rs | 43 ++++++++++++++++--- .../src/interpret/validity.rs | 2 +- .../miri/tests/pass/alloc-access-tracking.rs | 25 +++++++++++ .../tests/pass/alloc-access-tracking.stderr | 37 ++++++++++++++++ 6 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 src/tools/miri/tests/pass/alloc-access-tracking.rs create mode 100644 src/tools/miri/tests/pass/alloc-access-tracking.stderr diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 9e4e7911c3a..6dd53151a4e 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -380,16 +380,12 @@ pub fn eval_in_interpreter<'mir, 'tcx>( } Ok(mplace) => { // Since evaluation had no errors, validate the resulting constant. - - // Temporarily allow access to the static_root_alloc_id for the purpose of validation. - let static_root_alloc_id = ecx.machine.static_root_alloc_id.take(); - let validation = const_validate_mplace(&ecx, &mplace, cid); - ecx.machine.static_root_alloc_id = static_root_alloc_id; + let res = const_validate_mplace(&ecx, &mplace, cid); let alloc_id = mplace.ptr().provenance.unwrap().alloc_id(); // Validation failed, report an error. - if let Err(error) = validation { + if let Err(error) = res { Err(const_report_error(&ecx, error, alloc_id)) } else { // Convert to raw constant diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 90a654a1229..305f7ade101 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -391,6 +391,8 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized { /// Hook for performing extra checks on a memory read access. /// + /// This will *not* be called during validation! + /// /// Takes read-only access to the allocation so we can keep all the memory read /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you /// need to mutate. @@ -410,6 +412,8 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized { /// Hook for performing extra checks on any memory read access, /// that involves an allocation, even ZST reads. /// + /// This will *not* be called during validation! + /// /// Used to prevent statics from self-initializing by reading from their own memory /// as it is being initialized. fn before_alloc_read( diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 3b2208b8caa..cf7f165b87c 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -8,6 +8,7 @@ use std::assert_matches::assert_matches; use std::borrow::Cow; +use std::cell::Cell; use std::collections::VecDeque; use std::fmt; use std::ptr; @@ -111,6 +112,11 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> { /// that do not exist any more. // FIXME: this should not be public, but interning currently needs access to it pub(super) dead_alloc_map: FxIndexMap, + + /// This stores whether we are currently doing reads purely for the purpose of validation. + /// Those reads do not trigger the machine's hooks for memory reads. + /// Needless to say, this must only be set with great care! + validation_in_progress: Cell, } /// A reference to some allocation that was already bounds-checked for the given region @@ -137,6 +143,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { alloc_map: M::MemoryMap::default(), extra_fn_ptr_map: FxIndexMap::default(), dead_alloc_map: FxIndexMap::default(), + validation_in_progress: Cell::new(false), } } @@ -624,10 +631,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { size, CheckInAllocMsg::MemoryAccessTest, |alloc_id, offset, prov| { - // We want to call the hook on *all* accesses that involve an AllocId, - // including zero-sized accesses. That means we have to do it here - // rather than below in the `Some` branch. - M::before_alloc_read(self, alloc_id)?; + if !self.memory.validation_in_progress.get() { + // We want to call the hook on *all* accesses that involve an AllocId, + // including zero-sized accesses. That means we have to do it here + // rather than below in the `Some` branch. + M::before_alloc_read(self, alloc_id)?; + } let alloc = self.get_alloc_raw(alloc_id)?; Ok((alloc.size(), alloc.align, (alloc_id, offset, prov, alloc))) }, @@ -635,7 +644,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { if let Some((alloc_id, offset, prov, alloc)) = ptr_and_alloc { let range = alloc_range(offset, size); - M::before_memory_read(self.tcx, &self.machine, &alloc.extra, (alloc_id, prov), range)?; + if !self.memory.validation_in_progress.get() { + M::before_memory_read( + self.tcx, + &self.machine, + &alloc.extra, + (alloc_id, prov), + range, + )?; + } Ok(Some(AllocRef { alloc, range, tcx: *self.tcx, alloc_id })) } else { Ok(None) @@ -909,6 +926,21 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } }) } + + /// Runs the close in "validation" mode, which means the machine's memory read hooks will be + /// suppressed. Needless to say, this must only be set with great care! Cannot be nested. + pub(super) fn run_for_validation(&self, f: impl FnOnce() -> R) -> R { + assert!( + self.memory.validation_in_progress.replace(true) == false, + "`validation_in_progress` was already set" + ); + let res = f(); + assert!( + self.memory.validation_in_progress.replace(false) == true, + "`validation_in_progress` was unset by someone else" + ); + res + } } #[doc(hidden)] @@ -1154,6 +1186,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { }; let src_alloc = self.get_alloc_raw(src_alloc_id)?; let src_range = alloc_range(src_offset, size); + assert!(!self.memory.validation_in_progress.get(), "we can't be copying during validation"); M::before_memory_read( tcx, &self.machine, diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index ff1cb43db86..eebbc10c47e 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -967,7 +967,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let mut visitor = ValidityVisitor { path, ref_tracking, ctfe_mode, ecx: self }; // Run it. - match visitor.visit_value(op) { + match self.run_for_validation(|| visitor.visit_value(op)) { Ok(()) => Ok(()), // Pass through validation failures and "invalid program" issues. Err(err) diff --git a/src/tools/miri/tests/pass/alloc-access-tracking.rs b/src/tools/miri/tests/pass/alloc-access-tracking.rs new file mode 100644 index 00000000000..5c782fca2df --- /dev/null +++ b/src/tools/miri/tests/pass/alloc-access-tracking.rs @@ -0,0 +1,25 @@ +#![feature(start)] +#![no_std] +//@compile-flags: -Zmiri-track-alloc-id=17 -Zmiri-track-alloc-accesses -Cpanic=abort +//@only-target-linux: alloc IDs differ between OSes for some reason + +extern "Rust" { + fn miri_alloc(size: usize, align: usize) -> *mut u8; + fn miri_dealloc(ptr: *mut u8, size: usize, align: usize); +} + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + unsafe { + let ptr = miri_alloc(123, 1); + *ptr = 42; // Crucially, only a write is printed here, no read! + assert_eq!(*ptr, 42); + miri_dealloc(ptr, 123, 1); + } + 0 +} + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo) -> ! { + loop {} +} diff --git a/src/tools/miri/tests/pass/alloc-access-tracking.stderr b/src/tools/miri/tests/pass/alloc-access-tracking.stderr new file mode 100644 index 00000000000..5e219fa1bed --- /dev/null +++ b/src/tools/miri/tests/pass/alloc-access-tracking.stderr @@ -0,0 +1,37 @@ +note: tracking was triggered + --> $DIR/alloc-access-tracking.rs:LL:CC + | +LL | let ptr = miri_alloc(123, 1); + | ^^^^^^^^^^^^^^^^^^ created Miri bare-metal heap allocation of 123 bytes (alignment ALIGN bytes) with id 17 + | + = note: BACKTRACE: + = note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC + +note: tracking was triggered + --> $DIR/alloc-access-tracking.rs:LL:CC + | +LL | *ptr = 42; // Crucially, only a write is printed here, no read! + | ^^^^^^^^^ write access to allocation with id 17 + | + = note: BACKTRACE: + = note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC + +note: tracking was triggered + --> $DIR/alloc-access-tracking.rs:LL:CC + | +LL | assert_eq!(*ptr, 42); + | ^^^^^^^^^^^^^^^^^^^^ read access to allocation with id 17 + | + = note: BACKTRACE: + = note: inside `start` at RUSTLIB/core/src/macros/mod.rs:LL:CC + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: tracking was triggered + --> $DIR/alloc-access-tracking.rs:LL:CC + | +LL | miri_dealloc(ptr, 123, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ freed allocation with id 17 + | + = note: BACKTRACE: + = note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC + From 58f6aaa710916865253482ff99ef9c87e52d763a Mon Sep 17 00:00:00 2001 From: Daniel Sedlak Date: Thu, 7 Mar 2024 19:06:09 +0100 Subject: [PATCH 21/35] Improve diagnostics for parenthesized type arguments --- compiler/rustc_parse/src/parser/path.rs | 86 ++++++++++++++++++- ...nthesized-type-arguments-issue-120892-1.rs | 14 +++ ...sized-type-arguments-issue-120892-1.stderr | 17 ++++ ...nthesized-type-arguments-issue-120892-2.rs | 5 ++ ...sized-type-arguments-issue-120892-2.stderr | 10 +++ ...nthesized-type-arguments-issue-120892-3.rs | 14 +++ ...sized-type-arguments-issue-120892-3.stderr | 16 ++++ 7 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs create mode 100644 tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 545db5138a3..2edf2111de7 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -1,6 +1,7 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; use crate::errors::PathSingleColon; +use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; use crate::{errors, maybe_whole}; use ast::token::IdentIsRaw; use rustc_ast::ptr::P; @@ -10,7 +11,7 @@ use rustc_ast::{ AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs, Path, PathSegment, QSelf, }; -use rustc_errors::{Applicability, PResult}; +use rustc_errors::{Applicability, Diag, PResult}; use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{BytePos, Span}; use std::mem; @@ -373,7 +374,38 @@ impl<'a> Parser<'a> { .into() } else { // `(T, U) -> R` - let (inputs, _) = self.parse_paren_comma_seq(|p| p.parse_ty())?; + + let prev_token_before_parsing = self.prev_token.clone(); + let token_before_parsing = self.token.clone(); + let mut snapshot = None; + if self.may_recover() + && prev_token_before_parsing.kind == token::ModSep + && (style == PathStyle::Expr && self.token.can_begin_expr() + || style == PathStyle::Pat && self.token.can_begin_pattern()) + { + snapshot = Some(self.create_snapshot_for_diagnostic()); + } + + let (inputs, _) = match self.parse_paren_comma_seq(|p| p.parse_ty()) { + Ok(output) => output, + Err(mut error) if prev_token_before_parsing.kind == token::ModSep => { + error.span_label( + prev_token_before_parsing.span.to(token_before_parsing.span), + "while parsing this parenthesized list of type arguments starting here", + ); + + if let Some(mut snapshot) = snapshot { + snapshot.recover_fn_call_leading_path_sep( + style, + prev_token_before_parsing, + &mut error, + ) + } + + return Err(error); + } + Err(error) => return Err(error), + }; let inputs_span = lo.to(self.prev_token.span); let output = self.parse_ret_ty(AllowPlus::No, RecoverQPath::No, RecoverReturnSign::No)?; @@ -399,6 +431,56 @@ impl<'a> Parser<'a> { } } + /// Recover `$path::(...)` as `$path(...)`. + /// + /// ```ignore (diagnostics) + /// foo::(420, "bar") + /// ^^ remove extra separator to make the function call + /// // or + /// match x { + /// Foo::(420, "bar") => { ... }, + /// ^^ remove extra separator to turn this into tuple struct pattern + /// _ => { ... }, + /// } + /// ``` + fn recover_fn_call_leading_path_sep( + &mut self, + style: PathStyle, + prev_token_before_parsing: Token, + error: &mut Diag<'_>, + ) { + if ((style == PathStyle::Expr && self.parse_paren_comma_seq(|p| p.parse_expr()).is_ok()) + || (style == PathStyle::Pat + && self + .parse_paren_comma_seq(|p| { + p.parse_pat_allow_top_alt( + None, + RecoverComma::No, + RecoverColon::No, + CommaRecoveryMode::LikelyTuple, + ) + }) + .is_ok())) + && !matches!(self.token.kind, token::ModSep | token::RArrow) + { + error.span_suggestion_verbose( + prev_token_before_parsing.span, + format!( + "consider removing the `::` here to {}", + match style { + PathStyle::Expr => "call the expression", + PathStyle::Pat => "turn this into a tuple struct pattern", + _ => { + return; + } + } + ), + "", + Applicability::MaybeIncorrect, + ); + } + } + /// Parses generic args (within a path segment) with recovery for extra leading angle brackets. /// For the purposes of understanding the parsing logic of generic arguments, this function /// can be thought of being the same as just calling `self.parse_angle_args()` if the source diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs new file mode 100644 index 00000000000..5de3b401ab4 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs @@ -0,0 +1,14 @@ +fn main() { + foo::( //~ HELP: consider removing the `::` here to call the expression + //~^ NOTE: while parsing this parenthesized list of type arguments starting + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + baz("test"), //~ ERROR: expected type, found `"test"` + //~^ NOTE: expected type + ) +} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr new file mode 100644 index 00000000000..60e57a3629c --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr @@ -0,0 +1,17 @@ +error: expected type, found `"test"` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-1.rs:11:9 + | +LL | foo::( + | --- while parsing this parenthesized list of type arguments starting here +... +LL | baz("test"), + | ^^^^^^ expected type + | +help: consider removing the `::` here to call the expression + | +LL - foo::( +LL + foo( + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs new file mode 100644 index 00000000000..2876a9afe00 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs @@ -0,0 +1,5 @@ +fn main() { + foo::/* definitely not harmful comment */(123, "foo") -> (u32); //~ ERROR: expected type, found `123` + //~^ NOTE: while parsing this parenthesized list of type arguments starting + //~^^ NOTE: expected type +} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr new file mode 100644 index 00000000000..7fd2b6b18e3 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr @@ -0,0 +1,10 @@ +error: expected type, found `123` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-2.rs:2:45 + | +LL | foo::/* definitely not harmful comment */(123, "foo") -> (u32); + | ---------------------------------------^^^ expected type + | | + | while parsing this parenthesized list of type arguments starting here + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs new file mode 100644 index 00000000000..402afac46de --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs @@ -0,0 +1,14 @@ +struct Foo(u32, u32); +impl Foo { + fn foo(&self) { + match *self { + Foo::(1, 2) => {}, //~ HELP: consider removing the `::` here to turn this into a tuple struct pattern + //~^ NOTE: while parsing this parenthesized list of type arguments starting + //~^^ ERROR: expected type, found `1` + //~^^^ NOTE: expected type + _ => {}, + } + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr new file mode 100644 index 00000000000..72770ca265d --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr @@ -0,0 +1,16 @@ +error: expected type, found `1` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-3.rs:5:19 + | +LL | Foo::(1, 2) => {}, + | ---^ expected type + | | + | while parsing this parenthesized list of type arguments starting here + | +help: consider removing the `::` here to turn this into a tuple struct pattern + | +LL - Foo::(1, 2) => {}, +LL + Foo(1, 2) => {}, + | + +error: aborting due to 1 previous error + From 383051092f02c2eb2b99e50a38da7a04f28bbb65 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 10 Mar 2024 21:18:41 -0400 Subject: [PATCH 22/35] Ignore tests w/ current/next revisions from compare-mode=next-solver --- .../ui/associated-inherent-types/inference.rs | 1 + tests/ui/async-await/async-closures/is-fn.rs | 1 + tests/ui/async-await/async-closures/once.rs | 1 + .../async-fn/higher-ranked-async-fn.rs | 1 + tests/ui/async-await/async-fn/project.rs | 1 + ...normalize-output-in-signature-deduction.rs | 1 + ...elf-auto-trait-issue-109924.current.stderr | 2 +- ...g-self-auto-trait-issue-109924.next.stderr | 2 +- ...ormalizing-self-auto-trait-issue-109924.rs | 1 + .../auto-traits/issue-23080-2.current.stderr | 2 +- .../ui/auto-traits/issue-23080-2.next.stderr | 2 +- tests/ui/auto-traits/issue-23080-2.rs | 1 + .../infer-signature-from-impl.next.stderr | 2 +- .../ui/closures/infer-signature-from-impl.rs | 1 + .../normalize-for-errors.current.stderr | 2 +- .../normalize-for-errors.next.stderr | 2 +- tests/ui/coherence/normalize-for-errors.rs | 1 + tests/ui/coroutine/clone-rpit.next.stderr | 18 +- tests/ui/coroutine/clone-rpit.rs | 1 + tests/ui/coroutine/non-static-is-unpin.rs | 1 + .../coroutine/static-not-unpin.current.stderr | 8 +- .../ui/coroutine/static-not-unpin.next.stderr | 8 +- tests/ui/coroutine/static-not-unpin.rs | 1 + tests/ui/dyn-star/box.rs | 1 + ...ize-at-cast-polymorphic-bad.current.stderr | 2 +- ...k-size-at-cast-polymorphic-bad.next.stderr | 2 +- .../check-size-at-cast-polymorphic-bad.rs | 1 + tests/ui/for/issue-20605.current.stderr | 2 +- tests/ui/for/issue-20605.next.stderr | 10 +- tests/ui/for/issue-20605.rs | 1 + .../issue-102114.current.stderr | 2 +- .../issue-102114.next.stderr | 2 +- .../generic-associated-types/issue-102114.rs | 1 + .../trait-bounds/fn-ptr.current.stderr | 19 ++ tests/ui/higher-ranked/trait-bounds/fn-ptr.rs | 5 +- .../trait-bounds/future.current.stderr | 6 + tests/ui/higher-ranked/trait-bounds/future.rs | 17 +- tests/ui/impl-trait/autoderef.rs | 1 + ...erased-regions-in-hidden-ty.current.stderr | 4 +- .../erased-regions-in-hidden-ty.next.stderr | 4 +- .../impl-trait/erased-regions-in-hidden-ty.rs | 1 + .../in-trait/object-safety-sized.rs | 1 + .../impl-trait/in-trait/refine-normalize.rs | 1 + .../impl-trait/issue-103181-1.current.stderr | 2 +- .../ui/impl-trait/issue-103181-1.next.stderr | 2 +- tests/ui/impl-trait/issue-103181-1.rs | 1 + .../recursive-coroutine-boxed.next.stderr | 4 +- .../impl-trait/recursive-coroutine-boxed.rs | 1 + ...ecursive-coroutine-indirect.current.stderr | 2 +- .../recursive-coroutine-indirect.next.stderr | 2 +- .../recursive-coroutine-indirect.rs | 1 + tests/ui/impl-trait/reveal-during-codegen.rs | 1 + ...wo_tait_defining_each_other.current.stderr | 6 +- .../two_tait_defining_each_other.rs | 1 + ...o_tait_defining_each_other2.current.stderr | 8 +- .../two_tait_defining_each_other2.next.stderr | 2 +- .../two_tait_defining_each_other2.rs | 1 + ...o_tait_defining_each_other3.current.stderr | 6 +- .../two_tait_defining_each_other3.rs | 1 + .../inference/type-infer-generalize-ty-var.rs | 1 + tests/ui/issues/issue-13167.rs | 1 + tests/ui/issues/issue-15734.rs | 1 + .../coerce-behind-lazy.current.stderr | 2 +- .../coerce-behind-lazy.next.stderr | 2 +- .../ui/lazy-type-alias/coerce-behind-lazy.rs | 1 + .../inherent-impls-overflow.current.stderr | 43 ++++ .../inherent-impls-overflow.next.stderr | 8 +- .../inherent-impls-overflow.rs | 13 +- ...never-from-impl-is-reserved.current.stderr | 2 +- .../never-from-impl-is-reserved.next.stderr | 2 +- .../never_type/never-from-impl-is-reserved.rs | 1 + tests/ui/nll/issue-53119.rs | 1 + .../call-when-assoc-ty-is-sized.rs | 1 + tests/ui/panics/abort-on-panic.rs | 1 + ...al-self-impl-for-unsafe-obj.current.stderr | 2 +- ...anual-self-impl-for-unsafe-obj.next.stderr | 2 +- .../manual-self-impl-for-unsafe-obj.rs | 1 + .../deny-builtin-object-impl.current.stderr | 6 +- .../deny-builtin-object-impl.next.stderr | 6 +- tests/ui/traits/deny-builtin-object-impl.rs | 1 + tests/ui/traits/issue-24010.rs | 3 +- .../negative-impl-normalizes-to.rs | 1 + .../discard-impls-shadowed-by-env-2.rs | 3 +- .../normalize-param-env-4.next.stderr | 8 +- .../next-solver/normalize-param-env-4.rs | 1 + ...on-lifetime-via-dyn-builtin.current.stderr | 2 +- .../non-lifetime-via-dyn-builtin.next.stderr | 2 +- .../ui/traits/non-lifetime-via-dyn-builtin.rs | 1 + ...holders-in-query-response-2.current.stderr | 2 +- ...aceholders-in-query-response-2.next.stderr | 2 +- ...ifying-placeholders-in-query-response-2.rs | 1 + ...ceholders-in-query-response.current.stderr | 2 +- ...placeholders-in-query-response.next.stderr | 2 +- ...unifying-placeholders-in-query-response.rs | 1 + .../add-supertrait-auto-traits.rs | 1 + .../trait-upcasting/fewer-associated.rs | 1 + .../illegal-upcast-from-impl.current.stderr | 2 +- .../illegal-upcast-from-impl.next.stderr | 2 +- .../illegal-upcast-from-impl.rs | 1 + .../issue-11515.current.stderr | 2 +- .../trait-upcasting/issue-11515.next.stderr | 2 +- .../ui/traits/trait-upcasting/issue-11515.rs | 1 + .../traits/trait-upcasting/normalization.rs | 1 + .../type-checking-test-1.current.stderr | 2 +- .../type-checking-test-1.next.stderr | 2 +- .../trait-upcasting/type-checking-test-1.rs | 1 + .../upcast-through-struct-tail.current.stderr | 2 +- .../upcast-through-struct-tail.next.stderr | 2 +- .../upcast-through-struct-tail.rs | 1 + .../primitives/bool.current.stderr | 4 +- .../primitives/bool.next.stderr | 4 +- tests/ui/transmutability/primitives/bool.rs | 1 + .../primitives/numbers.current.stderr | 228 +++++++++--------- .../primitives/numbers.next.stderr | 228 +++++++++--------- .../ui/transmutability/primitives/numbers.rs | 1 + .../primitives/unit.current.stderr | 4 +- .../primitives/unit.next.stderr | 4 +- tests/ui/transmutability/primitives/unit.rs | 1 + .../type-alias-impl-trait/assoc-type-const.rs | 1 + .../type-alias-impl-trait/cross_inference.rs | 1 + .../issue-76202-trait-impl-for-tait.rs | 1 + tests/ui/type-alias-impl-trait/issue-78450.rs | 1 + .../nested_inference_failure.rs | 5 +- .../normalize-hidden-types.current.stderr | 14 +- .../normalize-hidden-types.rs | 1 + ...equality_in_canonical_query.current.stderr | 4 +- .../rpit_tait_equality_in_canonical_query.rs | 1 + .../self-referential-2.current.stderr | 2 +- .../self-referential-2.rs | 1 + .../type-alias-impl-trait-tuple.next.stderr | 4 +- .../type-alias-impl-trait-tuple.rs | 1 + .../type_of_a_let.current.stderr | 4 +- .../ui/type-alias-impl-trait/type_of_a_let.rs | 1 + tests/ui/unsized/issue-71659.current.stderr | 4 +- tests/ui/unsized/issue-71659.next.stderr | 4 +- tests/ui/unsized/issue-71659.rs | 1 + tests/ui/unsized/issue-75899.rs | 1 + 137 files changed, 501 insertions(+), 363 deletions(-) create mode 100644 tests/ui/higher-ranked/trait-bounds/fn-ptr.current.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/future.current.stderr create mode 100644 tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr diff --git a/tests/ui/associated-inherent-types/inference.rs b/tests/ui/associated-inherent-types/inference.rs index f520c610685..31016f1091b 100644 --- a/tests/ui/associated-inherent-types/inference.rs +++ b/tests/ui/associated-inherent-types/inference.rs @@ -1,6 +1,7 @@ // Testing inference capabilities. //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(inherent_associated_types)] diff --git a/tests/ui/async-await/async-closures/is-fn.rs b/tests/ui/async-await/async-closures/is-fn.rs index 64cc28e425f..89c3a96bbbe 100644 --- a/tests/ui/async-await/async-closures/is-fn.rs +++ b/tests/ui/async-await/async-closures/is-fn.rs @@ -2,6 +2,7 @@ //@ edition:2021 //@ build-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(async_closure)] diff --git a/tests/ui/async-await/async-closures/once.rs b/tests/ui/async-await/async-closures/once.rs index 761df3de444..7009e0d132f 100644 --- a/tests/ui/async-await/async-closures/once.rs +++ b/tests/ui/async-await/async-closures/once.rs @@ -2,6 +2,7 @@ //@ edition:2021 //@ build-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(async_closure)] diff --git a/tests/ui/async-await/async-fn/higher-ranked-async-fn.rs b/tests/ui/async-await/async-fn/higher-ranked-async-fn.rs index 5680c057737..be338ddeb7d 100644 --- a/tests/ui/async-await/async-fn/higher-ranked-async-fn.rs +++ b/tests/ui/async-await/async-fn/higher-ranked-async-fn.rs @@ -1,6 +1,7 @@ //@ aux-build:block-on.rs //@ edition:2018 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ build-pass (since it ICEs during mono) diff --git a/tests/ui/async-await/async-fn/project.rs b/tests/ui/async-await/async-fn/project.rs index 302564bb951..5cbdc378dda 100644 --- a/tests/ui/async-await/async-fn/project.rs +++ b/tests/ui/async-await/async-fn/project.rs @@ -1,5 +1,6 @@ //@ edition:2018 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/async-await/normalize-output-in-signature-deduction.rs b/tests/ui/async-await/normalize-output-in-signature-deduction.rs index 177e8625531..19d70c2c6ee 100644 --- a/tests/ui/async-await/normalize-output-in-signature-deduction.rs +++ b/tests/ui/async-await/normalize-output-in-signature-deduction.rs @@ -1,5 +1,6 @@ //@ edition:2021 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr index 2e82a3fcdb4..4837815fad4 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:6:12 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:7:12 | LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr index 2e82a3fcdb4..4837815fad4 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.next.stderr @@ -1,5 +1,5 @@ warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/normalizing-self-auto-trait-issue-109924.rs:6:12 + --> $DIR/normalizing-self-auto-trait-issue-109924.rs:7:12 | LL | #![feature(return_type_notation)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs index 0e167b149f3..bee9ad2516e 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ edition:2021 diff --git a/tests/ui/auto-traits/issue-23080-2.current.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr index 178bfff97d2..62c7b37041f 100644 --- a/tests/ui/auto-traits/issue-23080-2.current.stderr +++ b/tests/ui/auto-traits/issue-23080-2.current.stderr @@ -1,5 +1,5 @@ error[E0380]: auto traits cannot have associated items - --> $DIR/issue-23080-2.rs:8:10 + --> $DIR/issue-23080-2.rs:9:10 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr index 178bfff97d2..62c7b37041f 100644 --- a/tests/ui/auto-traits/issue-23080-2.next.stderr +++ b/tests/ui/auto-traits/issue-23080-2.next.stderr @@ -1,5 +1,5 @@ error[E0380]: auto traits cannot have associated items - --> $DIR/issue-23080-2.rs:8:10 + --> $DIR/issue-23080-2.rs:9:10 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs index 2bfddd449b9..f1e7599959d 100644 --- a/tests/ui/auto-traits/issue-23080-2.rs +++ b/tests/ui/auto-traits/issue-23080-2.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(auto_traits)] diff --git a/tests/ui/closures/infer-signature-from-impl.next.stderr b/tests/ui/closures/infer-signature-from-impl.next.stderr index 0866265cf04..332917eaaff 100644 --- a/tests/ui/closures/infer-signature-from-impl.next.stderr +++ b/tests/ui/closures/infer-signature-from-impl.next.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/infer-signature-from-impl.rs:17:16 + --> $DIR/infer-signature-from-impl.rs:18:16 | LL | needs_foo(|x| { | ^ diff --git a/tests/ui/closures/infer-signature-from-impl.rs b/tests/ui/closures/infer-signature-from-impl.rs index 910e004ba31..fa455c15ec7 100644 --- a/tests/ui/closures/infer-signature-from-impl.rs +++ b/tests/ui/closures/infer-signature-from-impl.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] known-bug: trait-system-refactor-initiative#71 //@[current] check-pass diff --git a/tests/ui/coherence/normalize-for-errors.current.stderr b/tests/ui/coherence/normalize-for-errors.current.stderr index 0e48aaed879..dcbb73bd1ff 100644 --- a/tests/ui/coherence/normalize-for-errors.current.stderr +++ b/tests/ui/coherence/normalize-for-errors.current.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, _)` - --> $DIR/normalize-for-errors.rs:16:1 + --> $DIR/normalize-for-errors.rs:17:1 | LL | impl MyTrait for (T, S::Item) {} | ------------------------------------------------------ first implementation here diff --git a/tests/ui/coherence/normalize-for-errors.next.stderr b/tests/ui/coherence/normalize-for-errors.next.stderr index a8a7d437b32..6c56a917741 100644 --- a/tests/ui/coherence/normalize-for-errors.next.stderr +++ b/tests/ui/coherence/normalize-for-errors.next.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, <_ as Iterator>::Item)` - --> $DIR/normalize-for-errors.rs:16:1 + --> $DIR/normalize-for-errors.rs:17:1 | LL | impl MyTrait for (T, S::Item) {} | ------------------------------------------------------ first implementation here diff --git a/tests/ui/coherence/normalize-for-errors.rs b/tests/ui/coherence/normalize-for-errors.rs index 4d98ea609e9..2288118676a 100644 --- a/tests/ui/coherence/normalize-for-errors.rs +++ b/tests/ui/coherence/normalize-for-errors.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver struct MyType; diff --git a/tests/ui/coroutine/clone-rpit.next.stderr b/tests/ui/coroutine/clone-rpit.next.stderr index 2dbdbcc7b05..02d3390496a 100644 --- a/tests/ui/coroutine/clone-rpit.next.stderr +++ b/tests/ui/coroutine/clone-rpit.next.stderr @@ -1,47 +1,47 @@ error[E0391]: cycle detected when type-checking `foo` - --> $DIR/clone-rpit.rs:12:1 + --> $DIR/clone-rpit.rs:13:1 | LL | pub fn foo<'a, 'b>() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires coroutine witness types for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires promoting constants in MIR for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires preparing `foo::{closure#0}` for borrow checking... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires checking if `foo::{closure#0}` contains FFI-unwind calls... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires building MIR for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires match-checking `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ note: ...which requires type-checking `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:13:5 + --> $DIR/clone-rpit.rs:14:5 | LL | move |_: ()| { | ^^^^^^^^^^^^ = note: ...which again requires type-checking `foo`, completing the cycle note: cycle used when computing type of opaque `foo::{opaque#0}` - --> $DIR/clone-rpit.rs:12:25 + --> $DIR/clone-rpit.rs:13:25 | LL | pub fn foo<'a, 'b>() -> impl Clone { | ^^^^^^^^^^ diff --git a/tests/ui/coroutine/clone-rpit.rs b/tests/ui/coroutine/clone-rpit.rs index 445d155afa9..0df9bf61601 100644 --- a/tests/ui/coroutine/clone-rpit.rs +++ b/tests/ui/coroutine/clone-rpit.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[current] check-pass //@[next] known-bug: trait-system-refactor-initiative#82 diff --git a/tests/ui/coroutine/non-static-is-unpin.rs b/tests/ui/coroutine/non-static-is-unpin.rs index 0a108d52897..616a78d5fe2 100644 --- a/tests/ui/coroutine/non-static-is-unpin.rs +++ b/tests/ui/coroutine/non-static-is-unpin.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ run-pass diff --git a/tests/ui/coroutine/static-not-unpin.current.stderr b/tests/ui/coroutine/static-not-unpin.current.stderr index 8ef54298431..518abdd62c7 100644 --- a/tests/ui/coroutine/static-not-unpin.current.stderr +++ b/tests/ui/coroutine/static-not-unpin.current.stderr @@ -1,15 +1,15 @@ -error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned - --> $DIR/static-not-unpin.rs:17:18 +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:25: 15:34}` cannot be unpinned + --> $DIR/static-not-unpin.rs:18:18 | LL | assert_unpin(coroutine); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:25: 15:34}` | | | required by a bound introduced by this call | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:10:20 + --> $DIR/static-not-unpin.rs:11:20 | LL | fn assert_unpin(_: T) { | ^^^^^ required by this bound in `assert_unpin` diff --git a/tests/ui/coroutine/static-not-unpin.next.stderr b/tests/ui/coroutine/static-not-unpin.next.stderr index 8ef54298431..518abdd62c7 100644 --- a/tests/ui/coroutine/static-not-unpin.next.stderr +++ b/tests/ui/coroutine/static-not-unpin.next.stderr @@ -1,15 +1,15 @@ -error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` cannot be unpinned - --> $DIR/static-not-unpin.rs:17:18 +error[E0277]: `{static coroutine@$DIR/static-not-unpin.rs:15:25: 15:34}` cannot be unpinned + --> $DIR/static-not-unpin.rs:18:18 | LL | assert_unpin(coroutine); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:14:25: 14:34}` + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/static-not-unpin.rs:15:25: 15:34}` | | | required by a bound introduced by this call | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:10:20 + --> $DIR/static-not-unpin.rs:11:20 | LL | fn assert_unpin(_: T) { | ^^^^^ required by this bound in `assert_unpin` diff --git a/tests/ui/coroutine/static-not-unpin.rs b/tests/ui/coroutine/static-not-unpin.rs index 63a2b35ef7a..3704cca7729 100644 --- a/tests/ui/coroutine/static-not-unpin.rs +++ b/tests/ui/coroutine/static-not-unpin.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(coroutines)] diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs index a7e8e81b654..f1c9fd1a01e 100644 --- a/tests/ui/dyn-star/box.rs +++ b/tests/ui/dyn-star/box.rs @@ -1,5 +1,6 @@ //@ run-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[current] compile-flags: -C opt-level=0 //@[next] compile-flags: -Znext-solver -C opt-level=0 diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr index f291b1e2ca3..7b5ea7bb707 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr @@ -1,5 +1,5 @@ error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 + --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 | LL | dyn_debug(t); | ^ `&T` needs to be a pointer-like type diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr index f291b1e2ca3..7b5ea7bb707 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr @@ -1,5 +1,5 @@ error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 + --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 | LL | dyn_debug(t); | ^ `&T` needs to be a pointer-like type diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs index ad3391a7ad7..acc293a5956 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(dyn_star)] diff --git a/tests/ui/for/issue-20605.current.stderr b/tests/ui/for/issue-20605.current.stderr index 9e706601ef5..1a66cb41464 100644 --- a/tests/ui/for/issue-20605.current.stderr +++ b/tests/ui/for/issue-20605.current.stderr @@ -1,5 +1,5 @@ error[E0277]: `dyn Iterator` is not an iterator - --> $DIR/issue-20605.rs:5:17 + --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr index f9c3848476c..0669999cb82 100644 --- a/tests/ui/for/issue-20605.next.stderr +++ b/tests/ui/for/issue-20605.next.stderr @@ -1,5 +1,5 @@ error[E0277]: `dyn Iterator` is not an iterator - --> $DIR/issue-20605.rs:5:17 + --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } | ^^^^^^^ `dyn Iterator` is not an iterator @@ -7,25 +7,25 @@ LL | for item in *things { *item = 0 } = help: the trait `IntoIterator` is not implemented for `dyn Iterator` error: the type ` as IntoIterator>::IntoIter` is not well-formed - --> $DIR/issue-20605.rs:5:17 + --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } | ^^^^^^^ error: the type `&mut as IntoIterator>::IntoIter` is not well-formed - --> $DIR/issue-20605.rs:5:17 + --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } | ^^^^^^^ error: the type `Option<< as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed - --> $DIR/issue-20605.rs:5:17 + --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } | ^^^^^^^ error[E0614]: type ` as IntoIterator>::Item` cannot be dereferenced - --> $DIR/issue-20605.rs:5:27 + --> $DIR/issue-20605.rs:6:27 | LL | for item in *things { *item = 0 } | ^^^^^ diff --git a/tests/ui/for/issue-20605.rs b/tests/ui/for/issue-20605.rs index 1c01de967cc..b923a7088fe 100644 --- a/tests/ui/for/issue-20605.rs +++ b/tests/ui/for/issue-20605.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver fn changer<'a>(mut things: Box>) { diff --git a/tests/ui/generic-associated-types/issue-102114.current.stderr b/tests/ui/generic-associated-types/issue-102114.current.stderr index 69ae5676ee0..03471d08d74 100644 --- a/tests/ui/generic-associated-types/issue-102114.current.stderr +++ b/tests/ui/generic-associated-types/issue-102114.current.stderr @@ -1,5 +1,5 @@ error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/issue-102114.rs:14:12 + --> $DIR/issue-102114.rs:15:12 | LL | type B<'b>; | -- expected 0 type parameters diff --git a/tests/ui/generic-associated-types/issue-102114.next.stderr b/tests/ui/generic-associated-types/issue-102114.next.stderr index 69ae5676ee0..03471d08d74 100644 --- a/tests/ui/generic-associated-types/issue-102114.next.stderr +++ b/tests/ui/generic-associated-types/issue-102114.next.stderr @@ -1,5 +1,5 @@ error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/issue-102114.rs:14:12 + --> $DIR/issue-102114.rs:15:12 | LL | type B<'b>; | -- expected 0 type parameters diff --git a/tests/ui/generic-associated-types/issue-102114.rs b/tests/ui/generic-associated-types/issue-102114.rs index 58518f3f59a..3d63e5c8aca 100644 --- a/tests/ui/generic-associated-types/issue-102114.rs +++ b/tests/ui/generic-associated-types/issue-102114.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver trait A { diff --git a/tests/ui/higher-ranked/trait-bounds/fn-ptr.current.stderr b/tests/ui/higher-ranked/trait-bounds/fn-ptr.current.stderr new file mode 100644 index 00000000000..f3583cd218b --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/fn-ptr.current.stderr @@ -0,0 +1,19 @@ +error[E0277]: expected a `Fn(&'w ())` closure, found `fn(&'w ())` + --> $DIR/fn-ptr.rs:13:5 + | +LL | ice(); + | ^^^^^ expected an `Fn(&'w ())` closure, found `fn(&'w ())` + | + = help: the trait `for<'w> Fn<(&'w (),)>` is not implemented for `fn(&'w ())` +note: required by a bound in `ice` + --> $DIR/fn-ptr.rs:8:25 + | +LL | fn ice() + | --- required by a bound in this function +LL | where +LL | for<'w> fn(&'w ()): Fn(&'w ()), + | ^^^^^^^^^^ required by this bound in `ice` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs index e015db1eb64..9298c10c341 100644 --- a/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs +++ b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs @@ -1,4 +1,5 @@ -//@ revisions: classic next +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass @@ -10,5 +11,5 @@ where fn main() { ice(); - //[classic]~^ ERROR expected a `Fn(&'w ())` closure, found `fn(&'w ())` + //[current]~^ ERROR expected a `Fn(&'w ())` closure, found `fn(&'w ())` } diff --git a/tests/ui/higher-ranked/trait-bounds/future.current.stderr b/tests/ui/higher-ranked/trait-bounds/future.current.stderr new file mode 100644 index 00000000000..5a6381ad28e --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/future.current.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [evaluate_obligation] evaluating trait selection obligation `for<'a> {async fn body@$DIR/future.rs:33:35: 35:2}: core::future::future::Future` +#1 [codegen_select_candidate] computing candidate for `` +end of query stack diff --git a/tests/ui/higher-ranked/trait-bounds/future.rs b/tests/ui/higher-ranked/trait-bounds/future.rs index 9ee012c05d9..4b52f04dbe0 100644 --- a/tests/ui/higher-ranked/trait-bounds/future.rs +++ b/tests/ui/higher-ranked/trait-bounds/future.rs @@ -1,15 +1,16 @@ // ignore-tidy-linelength //@ edition:2021 -//@ revisions: classic next +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass -//@[classic] known-bug: #112347 -//@[classic] build-fail -//@[classic] failure-status: 101 -//@[classic] normalize-stderr-test "note: .*\n\n" -> "" -//@[classic] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" -//@[classic] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@[classic] rustc-env:RUST_BACKTRACE=0 +//@[current] known-bug: #112347 +//@[current] build-fail +//@[current] failure-status: 101 +//@[current] normalize-stderr-test "note: .*\n\n" -> "" +//@[current] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" +//@[current] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//@[current] rustc-env:RUST_BACKTRACE=0 #![feature(unboxed_closures)] diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs index afab4e980a8..7802f725d6f 100644 --- a/tests/ui/impl-trait/autoderef.rs +++ b/tests/ui/impl-trait/autoderef.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr b/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr index 4cd4febc4f0..5fea5353ba5 100644 --- a/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr +++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr @@ -1,11 +1,11 @@ error: {foo::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()} - --> $DIR/erased-regions-in-hidden-ty.rs:11:36 + --> $DIR/erased-regions-in-hidden-ty.rs:12:36 | LL | fn foo<'a: 'a>(x: &'a Vec) -> impl Fn() + 'static { | ^^^^^^^^^^^^^^^^^^^ error: Opaque(DefId(..), [ReErased]) - --> $DIR/erased-regions-in-hidden-ty.rs:17:13 + --> $DIR/erased-regions-in-hidden-ty.rs:18:13 | LL | fn bar() -> impl Fn() + 'static { | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr b/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr index 4cd4febc4f0..5fea5353ba5 100644 --- a/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr +++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr @@ -1,11 +1,11 @@ error: {foo::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()} - --> $DIR/erased-regions-in-hidden-ty.rs:11:36 + --> $DIR/erased-regions-in-hidden-ty.rs:12:36 | LL | fn foo<'a: 'a>(x: &'a Vec) -> impl Fn() + 'static { | ^^^^^^^^^^^^^^^^^^^ error: Opaque(DefId(..), [ReErased]) - --> $DIR/erased-regions-in-hidden-ty.rs:17:13 + --> $DIR/erased-regions-in-hidden-ty.rs:18:13 | LL | fn bar() -> impl Fn() + 'static { | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs index c73f4fc1f65..c18df16bd6c 100644 --- a/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs +++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@ compile-flags: -Zverbose-internals //@[next] compile-flags: -Znext-solver //@ normalize-stderr-test "DefId\([^\)]+\)" -> "DefId(..)" diff --git a/tests/ui/impl-trait/in-trait/object-safety-sized.rs b/tests/ui/impl-trait/in-trait/object-safety-sized.rs index 2bd8ea646a1..b5b7a6ed9bf 100644 --- a/tests/ui/impl-trait/in-trait/object-safety-sized.rs +++ b/tests/ui/impl-trait/in-trait/object-safety-sized.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver diff --git a/tests/ui/impl-trait/in-trait/refine-normalize.rs b/tests/ui/impl-trait/in-trait/refine-normalize.rs index 95f2cda6a74..490e7bf8923 100644 --- a/tests/ui/impl-trait/in-trait/refine-normalize.rs +++ b/tests/ui/impl-trait/in-trait/refine-normalize.rs @@ -1,6 +1,7 @@ //@ check-pass //@ edition: 2021 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![deny(refining_impl_trait)] diff --git a/tests/ui/impl-trait/issue-103181-1.current.stderr b/tests/ui/impl-trait/issue-103181-1.current.stderr index 83410dfc6ea..c15b7e04c26 100644 --- a/tests/ui/impl-trait/issue-103181-1.current.stderr +++ b/tests/ui/impl-trait/issue-103181-1.current.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `Error` - --> $DIR/issue-103181-1.rs:11:5 + --> $DIR/issue-103181-1.rs:12:5 | LL | type Error; | ---------- `Error` from trait diff --git a/tests/ui/impl-trait/issue-103181-1.next.stderr b/tests/ui/impl-trait/issue-103181-1.next.stderr index 83410dfc6ea..c15b7e04c26 100644 --- a/tests/ui/impl-trait/issue-103181-1.next.stderr +++ b/tests/ui/impl-trait/issue-103181-1.next.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `Error` - --> $DIR/issue-103181-1.rs:11:5 + --> $DIR/issue-103181-1.rs:12:5 | LL | type Error; | ---------- `Error` from trait diff --git a/tests/ui/impl-trait/issue-103181-1.rs b/tests/ui/impl-trait/issue-103181-1.rs index 75333af58ec..fd8b72c1c75 100644 --- a/tests/ui/impl-trait/issue-103181-1.rs +++ b/tests/ui/impl-trait/issue-103181-1.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ edition:2021 diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr index 4a5e4bfe94b..755d12d7448 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/recursive-coroutine-boxed.rs:11:23 + --> $DIR/recursive-coroutine-boxed.rs:12:23 | LL | let mut gen = Box::pin(foo()); | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Box` @@ -13,7 +13,7 @@ LL | let mut gen = Box::::pin(foo()); | +++++ error[E0282]: type annotations needed - --> $DIR/recursive-coroutine-boxed.rs:8:13 + --> $DIR/recursive-coroutine-boxed.rs:9:13 | LL | fn foo() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for opaque type `impl Coroutine` diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs index 8f0bbb400cf..3b8ffb92090 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[current] check-pass //@[next] compile-flags: -Znext-solver #![feature(coroutines, coroutine_trait)] diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr index df457c13e70..ee87c483d0d 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:10:5 + --> $DIR/recursive-coroutine-indirect.rs:11:5 | LL | move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr index df457c13e70..ee87c483d0d 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:10:5 + --> $DIR/recursive-coroutine-indirect.rs:11:5 | LL | move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.rs b/tests/ui/impl-trait/recursive-coroutine-indirect.rs index 31d22970e04..bba9792fe3c 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.rs +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] build-fail diff --git a/tests/ui/impl-trait/reveal-during-codegen.rs b/tests/ui/impl-trait/reveal-during-codegen.rs index 996f0bb8bbf..d3ec746d9a9 100644 --- a/tests/ui/impl-trait/reveal-during-codegen.rs +++ b/tests/ui/impl-trait/reveal-during-codegen.rs @@ -1,5 +1,6 @@ //@ build-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver fn test() -> Option { diff --git a/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr index b60529ed002..bf194f997b4 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr @@ -1,16 +1,16 @@ error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other.rs:16:5 + --> $DIR/two_tait_defining_each_other.rs:17:5 | LL | x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other | ^ one of the two opaque types used here has to be outside its defining scope | note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other.rs:8:10 + --> $DIR/two_tait_defining_each_other.rs:9:10 | LL | type B = impl Foo; | ^^^^^^^^ note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other.rs:7:10 + --> $DIR/two_tait_defining_each_other.rs:8:10 | LL | type A = impl Foo; | ^^^^^^^^ diff --git a/tests/ui/impl-trait/two_tait_defining_each_other.rs b/tests/ui/impl-trait/two_tait_defining_each_other.rs index 0c3376b413f..ebfe7f674be 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr index c5c9ae33f4d..6f2b2d9ca04 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr @@ -1,5 +1,5 @@ error: unconstrained opaque type - --> $DIR/two_tait_defining_each_other2.rs:5:10 + --> $DIR/two_tait_defining_each_other2.rs:6:10 | LL | type A = impl Foo; | ^^^^^^^^ @@ -7,18 +7,18 @@ LL | type A = impl Foo; = note: `A` must be used in combination with a concrete type within the same module error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other2.rs:12:5 + --> $DIR/two_tait_defining_each_other2.rs:13:5 | LL | x // B's hidden type is A (opaquely) | ^ one of the two opaque types used here has to be outside its defining scope | note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other2.rs:6:10 + --> $DIR/two_tait_defining_each_other2.rs:7:10 | LL | type B = impl Foo; | ^^^^^^^^ note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other2.rs:5:10 + --> $DIR/two_tait_defining_each_other2.rs:6:10 | LL | type A = impl Foo; | ^^^^^^^^ diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr index 7e2b05618c4..5316160125b 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr @@ -1,5 +1,5 @@ error[E0284]: type annotations needed: cannot satisfy `_ == A` - --> $DIR/two_tait_defining_each_other2.rs:10:8 + --> $DIR/two_tait_defining_each_other2.rs:11:8 | LL | fn muh(x: A) -> B { | ^ cannot satisfy `_ == A` diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index faa1fed22d3..e850736fdfa 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(type_alias_impl_trait)] diff --git a/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr index 1dccfd17a70..fa353a77536 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr @@ -1,16 +1,16 @@ error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other3.rs:13:16 + --> $DIR/two_tait_defining_each_other3.rs:14:16 | LL | return x; // B's hidden type is A (opaquely) | ^ one of the two opaque types used here has to be outside its defining scope | note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other3.rs:7:10 + --> $DIR/two_tait_defining_each_other3.rs:8:10 | LL | type B = impl Foo; | ^^^^^^^^ note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other3.rs:6:10 + --> $DIR/two_tait_defining_each_other3.rs:7:10 | LL | type A = impl Foo; | ^^^^^^^^ diff --git a/tests/ui/impl-trait/two_tait_defining_each_other3.rs b/tests/ui/impl-trait/two_tait_defining_each_other3.rs index a596860e176..33695d8ed80 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other3.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other3.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/inference/type-infer-generalize-ty-var.rs b/tests/ui/inference/type-infer-generalize-ty-var.rs index 8dae835a9db..d623aeff47d 100644 --- a/tests/ui/inference/type-infer-generalize-ty-var.rs +++ b/tests/ui/inference/type-infer-generalize-ty-var.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![allow(non_upper_case_globals)] diff --git a/tests/ui/issues/issue-13167.rs b/tests/ui/issues/issue-13167.rs index 3cf8367a678..15ee02b9cd4 100644 --- a/tests/ui/issues/issue-13167.rs +++ b/tests/ui/issues/issue-13167.rs @@ -1,6 +1,7 @@ //@ check-pass //@ pretty-expanded FIXME #23616 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver use std::slice; diff --git a/tests/ui/issues/issue-15734.rs b/tests/ui/issues/issue-15734.rs index b8d0b088a89..26fb7061664 100644 --- a/tests/ui/issues/issue-15734.rs +++ b/tests/ui/issues/issue-15734.rs @@ -1,5 +1,6 @@ //@ run-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver use std::ops::Index; diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr index 98b3921dec4..78dd05b78af 100644 --- a/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr @@ -1,5 +1,5 @@ warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/coerce-behind-lazy.rs:5:12 + --> $DIR/coerce-behind-lazy.rs:6:12 | LL | #![feature(lazy_type_alias)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr index 98b3921dec4..78dd05b78af 100644 --- a/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr @@ -1,5 +1,5 @@ warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/coerce-behind-lazy.rs:5:12 + --> $DIR/coerce-behind-lazy.rs:6:12 | LL | #![feature(lazy_type_alias)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs index 42adfd274a3..7873ff46b66 100644 --- a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(lazy_type_alias)] diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr new file mode 100644 index 00000000000..05f5449dbc8 --- /dev/null +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr @@ -0,0 +1,43 @@ +error[E0275]: overflow normalizing the type alias `Loop` + --> $DIR/inherent-impls-overflow.rs:8:13 + | +LL | type Loop = Loop; + | ^^^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `Loop` + --> $DIR/inherent-impls-overflow.rs:10:1 + | +LL | impl Loop {} + | ^^^^^^^^^^^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` + --> $DIR/inherent-impls-overflow.rs:14:17 + | +LL | type Poly0 = Poly1<(T,)>; + | ^^^^^^^^^^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` + --> $DIR/inherent-impls-overflow.rs:17:17 + | +LL | type Poly1 = Poly0<(T,)>; + | ^^^^^^^^^^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` + --> $DIR/inherent-impls-overflow.rs:21:1 + | +LL | impl Poly0<()> {} + | ^^^^^^^^^^^^^^^^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr index 80377bf6c20..944fe8aa8e5 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr @@ -1,11 +1,11 @@ error[E0275]: overflow evaluating the requirement `Loop == _` - --> $DIR/inherent-impls-overflow.rs:9:6 + --> $DIR/inherent-impls-overflow.rs:10:6 | LL | impl Loop {} | ^^^^ error[E0392]: type parameter `T` is never used - --> $DIR/inherent-impls-overflow.rs:13:12 + --> $DIR/inherent-impls-overflow.rs:14:12 | LL | type Poly0 = Poly1<(T,)>; | ^ unused type parameter @@ -14,7 +14,7 @@ LL | type Poly0 = Poly1<(T,)>; = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error[E0392]: type parameter `T` is never used - --> $DIR/inherent-impls-overflow.rs:16:12 + --> $DIR/inherent-impls-overflow.rs:17:12 | LL | type Poly1 = Poly0<(T,)>; | ^ unused type parameter @@ -23,7 +23,7 @@ LL | type Poly1 = Poly0<(T,)>; = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error[E0275]: overflow evaluating the requirement `Poly0<()> == _` - --> $DIR/inherent-impls-overflow.rs:20:6 + --> $DIR/inherent-impls-overflow.rs:21:6 | LL | impl Poly0<()> {} | ^^^^^^^^^ diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs index dbf5c3743e8..98f0d811a47 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs @@ -1,24 +1,25 @@ -//@ revisions: classic next +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(lazy_type_alias)] #![allow(incomplete_features)] -type Loop = Loop; //[classic]~ ERROR overflow normalizing the type alias `Loop` +type Loop = Loop; //[current]~ ERROR overflow normalizing the type alias `Loop` impl Loop {} -//[classic]~^ ERROR overflow normalizing the type alias `Loop` +//[current]~^ ERROR overflow normalizing the type alias `Loop` //[next]~^^ ERROR overflow evaluating the requirement `Loop == _` type Poly0 = Poly1<(T,)>; -//[classic]~^ ERROR overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` +//[current]~^ ERROR overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` //[next]~^^ ERROR type parameter `T` is never used type Poly1 = Poly0<(T,)>; -//[classic]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` +//[current]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` //[next]~^^ ERROR type parameter `T` is never used impl Poly0<()> {} -//[classic]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` +//[current]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` //[next]~^^ ERROR overflow evaluating the requirement `Poly0<()> == _` fn main() {} diff --git a/tests/ui/never_type/never-from-impl-is-reserved.current.stderr b/tests/ui/never_type/never-from-impl-is-reserved.current.stderr index d008f88c188..7868206950c 100644 --- a/tests/ui/never_type/never-from-impl-is-reserved.current.stderr +++ b/tests/ui/never_type/never-from-impl-is-reserved.current.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFoo` - --> $DIR/never-from-impl-is-reserved.rs:13:1 + --> $DIR/never-from-impl-is-reserved.rs:14:1 | LL | impl MyTrait for MyFoo {} | ---------------------- first implementation here diff --git a/tests/ui/never_type/never-from-impl-is-reserved.next.stderr b/tests/ui/never_type/never-from-impl-is-reserved.next.stderr index d008f88c188..7868206950c 100644 --- a/tests/ui/never_type/never-from-impl-is-reserved.next.stderr +++ b/tests/ui/never_type/never-from-impl-is-reserved.next.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFoo` - --> $DIR/never-from-impl-is-reserved.rs:13:1 + --> $DIR/never-from-impl-is-reserved.rs:14:1 | LL | impl MyTrait for MyFoo {} | ---------------------- first implementation here diff --git a/tests/ui/never_type/never-from-impl-is-reserved.rs b/tests/ui/never_type/never-from-impl-is-reserved.rs index 26d194144f6..c673462f296 100644 --- a/tests/ui/never_type/never-from-impl-is-reserved.rs +++ b/tests/ui/never_type/never-from-impl-is-reserved.rs @@ -1,6 +1,7 @@ // check that the `for T: From` impl is reserved //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver=coherence #![feature(never_type)] diff --git a/tests/ui/nll/issue-53119.rs b/tests/ui/nll/issue-53119.rs index e7c97c854af..e699a6f9fd7 100644 --- a/tests/ui/nll/issue-53119.rs +++ b/tests/ui/nll/issue-53119.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver use std::ops::Deref; diff --git a/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs index b8445849169..7a3a7f3ca2f 100644 --- a/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs +++ b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver trait Foo { diff --git a/tests/ui/panics/abort-on-panic.rs b/tests/ui/panics/abort-on-panic.rs index 4929cdab1c2..36f103490fe 100644 --- a/tests/ui/panics/abort-on-panic.rs +++ b/tests/ui/panics/abort-on-panic.rs @@ -1,5 +1,6 @@ //@ run-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![allow(unused_must_use)] diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr index 4a219ff8b55..1489791b20d 100644 --- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr @@ -1,5 +1,5 @@ warning: methods `good_virt` and `good_indirect` are never used - --> $DIR/manual-self-impl-for-unsafe-obj.rs:22:8 + --> $DIR/manual-self-impl-for-unsafe-obj.rs:23:8 | LL | trait Good { | ---- methods in this trait diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr index 4a219ff8b55..1489791b20d 100644 --- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr @@ -1,5 +1,5 @@ warning: methods `good_virt` and `good_indirect` are never used - --> $DIR/manual-self-impl-for-unsafe-obj.rs:22:8 + --> $DIR/manual-self-impl-for-unsafe-obj.rs:23:8 | LL | trait Good { | ---- methods in this trait diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs index ba09550aad5..a020d91fb14 100644 --- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs @@ -1,6 +1,7 @@ // Check that we can manually implement an object-unsafe trait for its trait object. //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ run-pass diff --git a/tests/ui/traits/deny-builtin-object-impl.current.stderr b/tests/ui/traits/deny-builtin-object-impl.current.stderr index 0dbf8f0e668..8423a2519b2 100644 --- a/tests/ui/traits/deny-builtin-object-impl.current.stderr +++ b/tests/ui/traits/deny-builtin-object-impl.current.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied - --> $DIR/deny-builtin-object-impl.rs:18:23 + --> $DIR/deny-builtin-object-impl.rs:19:23 | LL | test_not_object::(); | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject` | help: this trait has no implementations, consider adding one - --> $DIR/deny-builtin-object-impl.rs:10:1 + --> $DIR/deny-builtin-object-impl.rs:11:1 | LL | trait NotObject {} | ^^^^^^^^^^^^^^^ note: required by a bound in `test_not_object` - --> $DIR/deny-builtin-object-impl.rs:14:23 + --> $DIR/deny-builtin-object-impl.rs:15:23 | LL | fn test_not_object() {} | ^^^^^^^^^ required by this bound in `test_not_object` diff --git a/tests/ui/traits/deny-builtin-object-impl.next.stderr b/tests/ui/traits/deny-builtin-object-impl.next.stderr index 0dbf8f0e668..8423a2519b2 100644 --- a/tests/ui/traits/deny-builtin-object-impl.next.stderr +++ b/tests/ui/traits/deny-builtin-object-impl.next.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied - --> $DIR/deny-builtin-object-impl.rs:18:23 + --> $DIR/deny-builtin-object-impl.rs:19:23 | LL | test_not_object::(); | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject` | help: this trait has no implementations, consider adding one - --> $DIR/deny-builtin-object-impl.rs:10:1 + --> $DIR/deny-builtin-object-impl.rs:11:1 | LL | trait NotObject {} | ^^^^^^^^^^^^^^^ note: required by a bound in `test_not_object` - --> $DIR/deny-builtin-object-impl.rs:14:23 + --> $DIR/deny-builtin-object-impl.rs:15:23 | LL | fn test_not_object() {} | ^^^^^^^^^ required by this bound in `test_not_object` diff --git a/tests/ui/traits/deny-builtin-object-impl.rs b/tests/ui/traits/deny-builtin-object-impl.rs index 8e4e44f6a67..c16dcca8fbc 100644 --- a/tests/ui/traits/deny-builtin-object-impl.rs +++ b/tests/ui/traits/deny-builtin-object-impl.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(rustc_attrs)] diff --git a/tests/ui/traits/issue-24010.rs b/tests/ui/traits/issue-24010.rs index a42a747b2d3..a3168fa4956 100644 --- a/tests/ui/traits/issue-24010.rs +++ b/tests/ui/traits/issue-24010.rs @@ -1,5 +1,6 @@ //@ run-pass -//@ revisions: classic next +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver trait Foo: Fn(i32) -> i32 + Send {} diff --git a/tests/ui/traits/negative-impls/negative-impl-normalizes-to.rs b/tests/ui/traits/negative-impls/negative-impl-normalizes-to.rs index 998b0d0c458..3316c5478a4 100644 --- a/tests/ui/traits/negative-impls/negative-impl-normalizes-to.rs +++ b/tests/ui/traits/negative-impls/negative-impl-normalizes-to.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/traits/next-solver/env-shadows-impls/discard-impls-shadowed-by-env-2.rs b/tests/ui/traits/next-solver/env-shadows-impls/discard-impls-shadowed-by-env-2.rs index 583d3c18faf..20329f467db 100644 --- a/tests/ui/traits/next-solver/env-shadows-impls/discard-impls-shadowed-by-env-2.rs +++ b/tests/ui/traits/next-solver/env-shadows-impls/discard-impls-shadowed-by-env-2.rs @@ -1,4 +1,5 @@ -//@ revisions: next current +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/traits/next-solver/normalize-param-env-4.next.stderr b/tests/ui/traits/next-solver/normalize-param-env-4.next.stderr index 1bee8ee88ff..e91a48f62ae 100644 --- a/tests/ui/traits/next-solver/normalize-param-env-4.next.stderr +++ b/tests/ui/traits/next-solver/normalize-param-env-4.next.stderr @@ -1,23 +1,23 @@ error[E0275]: overflow evaluating the requirement `::Assoc: Trait` - --> $DIR/normalize-param-env-4.rs:18:26 + --> $DIR/normalize-param-env-4.rs:19:26 | LL | ::Assoc: Trait, | ^^^^^ error[E0275]: overflow evaluating the requirement `::Assoc well-formed` - --> $DIR/normalize-param-env-4.rs:18:26 + --> $DIR/normalize-param-env-4.rs:19:26 | LL | ::Assoc: Trait, | ^^^^^ error[E0275]: overflow evaluating the requirement `T: Trait` - --> $DIR/normalize-param-env-4.rs:31:19 + --> $DIR/normalize-param-env-4.rs:32:19 | LL | impls_trait::(); | ^ | note: required by a bound in `impls_trait` - --> $DIR/normalize-param-env-4.rs:14:19 + --> $DIR/normalize-param-env-4.rs:15:19 | LL | fn impls_trait() {} | ^^^^^ required by this bound in `impls_trait` diff --git a/tests/ui/traits/next-solver/normalize-param-env-4.rs b/tests/ui/traits/next-solver/normalize-param-env-4.rs index b28fe5c3bd8..ed7f6899bde 100644 --- a/tests/ui/traits/next-solver/normalize-param-env-4.rs +++ b/tests/ui/traits/next-solver/normalize-param-env-4.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] known-bug: #92505 //@[current] check-pass diff --git a/tests/ui/traits/non-lifetime-via-dyn-builtin.current.stderr b/tests/ui/traits/non-lifetime-via-dyn-builtin.current.stderr index 9f373cc50f0..5393db6b105 100644 --- a/tests/ui/traits/non-lifetime-via-dyn-builtin.current.stderr +++ b/tests/ui/traits/non-lifetime-via-dyn-builtin.current.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/non-lifetime-via-dyn-builtin.rs:5:12 + --> $DIR/non-lifetime-via-dyn-builtin.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non-lifetime-via-dyn-builtin.next.stderr b/tests/ui/traits/non-lifetime-via-dyn-builtin.next.stderr index 9f373cc50f0..5393db6b105 100644 --- a/tests/ui/traits/non-lifetime-via-dyn-builtin.next.stderr +++ b/tests/ui/traits/non-lifetime-via-dyn-builtin.next.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/non-lifetime-via-dyn-builtin.rs:5:12 + --> $DIR/non-lifetime-via-dyn-builtin.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non-lifetime-via-dyn-builtin.rs b/tests/ui/traits/non-lifetime-via-dyn-builtin.rs index 26cf6105c50..ac61f8b614c 100644 --- a/tests/ui/traits/non-lifetime-via-dyn-builtin.rs +++ b/tests/ui/traits/non-lifetime-via-dyn-builtin.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr index 4082d6d47e7..3e5854ea1c8 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unifying-placeholders-in-query-response-2.rs:5:12 + --> $DIR/unifying-placeholders-in-query-response-2.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr index 4082d6d47e7..3e5854ea1c8 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unifying-placeholders-in-query-response-2.rs:5:12 + --> $DIR/unifying-placeholders-in-query-response-2.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs index 0749cbe1140..2066887ea59 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr index 040009efbde..0224e5763e0 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unifying-placeholders-in-query-response.rs:5:12 + --> $DIR/unifying-placeholders-in-query-response.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr index 040009efbde..0224e5763e0 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr @@ -1,5 +1,5 @@ warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unifying-placeholders-in-query-response.rs:5:12 + --> $DIR/unifying-placeholders-in-query-response.rs:6:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs index 333f4f80386..5334118e9ac 100644 --- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs b/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs index 5983b13185f..ffc21a4a9ea 100644 --- a/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs +++ b/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(trait_upcasting)] diff --git a/tests/ui/traits/trait-upcasting/fewer-associated.rs b/tests/ui/traits/trait-upcasting/fewer-associated.rs index 214293b0840..45e8673b859 100644 --- a/tests/ui/traits/trait-upcasting/fewer-associated.rs +++ b/tests/ui/traits/trait-upcasting/fewer-associated.rs @@ -1,6 +1,7 @@ //@ check-pass // issue: 114035 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(trait_upcasting)] diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr index 1538e2f3fd7..28be189ff1e 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/illegal-upcast-from-impl.rs:16:66 + --> $DIR/illegal-upcast-from-impl.rs:17:66 | LL | fn illegal(x: &dyn Sub) -> &dyn Super { x } | ----------------------- ^ expected trait `Super`, found trait `Sub` diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr index 1538e2f3fd7..28be189ff1e 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/illegal-upcast-from-impl.rs:16:66 + --> $DIR/illegal-upcast-from-impl.rs:17:66 | LL | fn illegal(x: &dyn Sub) -> &dyn Super { x } | ----------------------- ^ expected trait `Super`, found trait `Sub` diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs index 2f15d343f9f..0c771db4121 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(trait_upcasting)] diff --git a/tests/ui/traits/trait-upcasting/issue-11515.current.stderr b/tests/ui/traits/trait-upcasting/issue-11515.current.stderr index ce799dcb7ef..8ce7d46012f 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515.current.stderr +++ b/tests/ui/traits/trait-upcasting/issue-11515.current.stderr @@ -1,5 +1,5 @@ error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:10:38 + --> $DIR/issue-11515.rs:11:38 | LL | let test = Box::new(Test { func: closure }); | ^^^^^^^ diff --git a/tests/ui/traits/trait-upcasting/issue-11515.next.stderr b/tests/ui/traits/trait-upcasting/issue-11515.next.stderr index ce799dcb7ef..8ce7d46012f 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515.next.stderr +++ b/tests/ui/traits/trait-upcasting/issue-11515.next.stderr @@ -1,5 +1,5 @@ error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:10:38 + --> $DIR/issue-11515.rs:11:38 | LL | let test = Box::new(Test { func: closure }); | ^^^^^^^ diff --git a/tests/ui/traits/trait-upcasting/issue-11515.rs b/tests/ui/traits/trait-upcasting/issue-11515.rs index 174be31d139..d251e804c3e 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515.rs +++ b/tests/ui/traits/trait-upcasting/issue-11515.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver struct Test { diff --git a/tests/ui/traits/trait-upcasting/normalization.rs b/tests/ui/traits/trait-upcasting/normalization.rs index e4b65740ca4..ae5a6a5243c 100644 --- a/tests/ui/traits/trait-upcasting/normalization.rs +++ b/tests/ui/traits/trait-upcasting/normalization.rs @@ -1,6 +1,7 @@ //@ check-pass // issue: 114113 //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(trait_upcasting)] diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr index 10c22440a83..9a9ad9bbf77 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` - --> $DIR/type-checking-test-1.rs:19:13 + --> $DIR/type-checking-test-1.rs:20:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr index 10c22440a83..9a9ad9bbf77 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` - --> $DIR/type-checking-test-1.rs:19:13 + --> $DIR/type-checking-test-1.rs:20:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs index 0246b7d0566..fd902fd87e0 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(trait_upcasting)] diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr index 86de78f858c..239f8279194 100644 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr +++ b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr @@ -1,5 +1,5 @@ error[E0658]: cannot cast `dyn A` to `dyn B`, trait upcasting coercion is experimental - --> $DIR/upcast-through-struct-tail.rs:10:5 + --> $DIR/upcast-through-struct-tail.rs:11:5 | LL | x | ^ diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr index 86de78f858c..239f8279194 100644 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr +++ b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr @@ -1,5 +1,5 @@ error[E0658]: cannot cast `dyn A` to `dyn B`, trait upcasting coercion is experimental - --> $DIR/upcast-through-struct-tail.rs:10:5 + --> $DIR/upcast-through-struct-tail.rs:11:5 | LL | x | ^ diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs index 40850b45a00..e40cca4e0a8 100644 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs +++ b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver struct Wrapper(T); diff --git a/tests/ui/transmutability/primitives/bool.current.stderr b/tests/ui/transmutability/primitives/bool.current.stderr index d6376342c9c..98e4a1029c9 100644 --- a/tests/ui/transmutability/primitives/bool.current.stderr +++ b/tests/ui/transmutability/primitives/bool.current.stderr @@ -1,11 +1,11 @@ error[E0277]: `u8` cannot be safely transmuted into `bool` - --> $DIR/bool.rs:20:35 + --> $DIR/bool.rs:21:35 | LL | assert::is_transmutable::(); | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` | note: required by a bound in `is_transmutable` - --> $DIR/bool.rs:10:14 + --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr index d6376342c9c..98e4a1029c9 100644 --- a/tests/ui/transmutability/primitives/bool.next.stderr +++ b/tests/ui/transmutability/primitives/bool.next.stderr @@ -1,11 +1,11 @@ error[E0277]: `u8` cannot be safely transmuted into `bool` - --> $DIR/bool.rs:20:35 + --> $DIR/bool.rs:21:35 | LL | assert::is_transmutable::(); | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` | note: required by a bound in `is_transmutable` - --> $DIR/bool.rs:10:14 + --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs index 1be3b28b643..19236a1ae2e 100644 --- a/tests/ui/transmutability/primitives/bool.rs +++ b/tests/ui/transmutability/primitives/bool.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(transmutability)] diff --git a/tests/ui/transmutability/primitives/numbers.current.stderr b/tests/ui/transmutability/primitives/numbers.current.stderr index 7a80e444149..009e377af99 100644 --- a/tests/ui/transmutability/primitives/numbers.current.stderr +++ b/tests/ui/transmutability/primitives/numbers.current.stderr @@ -1,11 +1,11 @@ error[E0277]: `i8` cannot be safely transmuted into `i16` - --> $DIR/numbers.rs:64:40 + --> $DIR/numbers.rs:65:40 | LL | assert::is_transmutable::< i8, i16>(); | ^^^ The size of `i8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -14,13 +14,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u16` - --> $DIR/numbers.rs:65:40 + --> $DIR/numbers.rs:66:40 | LL | assert::is_transmutable::< i8, u16>(); | ^^^ The size of `i8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -29,13 +29,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:66:40 + --> $DIR/numbers.rs:67:40 | LL | assert::is_transmutable::< i8, i32>(); | ^^^ The size of `i8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -44,13 +44,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:67:40 + --> $DIR/numbers.rs:68:40 | LL | assert::is_transmutable::< i8, f32>(); | ^^^ The size of `i8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -59,13 +59,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:68:40 + --> $DIR/numbers.rs:69:40 | LL | assert::is_transmutable::< i8, u32>(); | ^^^ The size of `i8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -74,13 +74,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:69:40 + --> $DIR/numbers.rs:70:40 | LL | assert::is_transmutable::< i8, u64>(); | ^^^ The size of `i8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -89,13 +89,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:70:40 + --> $DIR/numbers.rs:71:40 | LL | assert::is_transmutable::< i8, i64>(); | ^^^ The size of `i8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -104,13 +104,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:71:40 + --> $DIR/numbers.rs:72:40 | LL | assert::is_transmutable::< i8, f64>(); | ^^^ The size of `i8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -119,13 +119,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:72:39 + --> $DIR/numbers.rs:73:39 | LL | assert::is_transmutable::< i8, u128>(); | ^^^^ The size of `i8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -134,13 +134,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:73:39 + --> $DIR/numbers.rs:74:39 | LL | assert::is_transmutable::< i8, i128>(); | ^^^^ The size of `i8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -149,13 +149,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i16` - --> $DIR/numbers.rs:75:40 + --> $DIR/numbers.rs:76:40 | LL | assert::is_transmutable::< u8, i16>(); | ^^^ The size of `u8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -164,13 +164,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u16` - --> $DIR/numbers.rs:76:40 + --> $DIR/numbers.rs:77:40 | LL | assert::is_transmutable::< u8, u16>(); | ^^^ The size of `u8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -179,13 +179,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:77:40 + --> $DIR/numbers.rs:78:40 | LL | assert::is_transmutable::< u8, i32>(); | ^^^ The size of `u8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -194,13 +194,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:78:40 + --> $DIR/numbers.rs:79:40 | LL | assert::is_transmutable::< u8, f32>(); | ^^^ The size of `u8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -209,13 +209,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:79:40 + --> $DIR/numbers.rs:80:40 | LL | assert::is_transmutable::< u8, u32>(); | ^^^ The size of `u8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -224,13 +224,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:80:40 + --> $DIR/numbers.rs:81:40 | LL | assert::is_transmutable::< u8, u64>(); | ^^^ The size of `u8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -239,13 +239,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:81:40 + --> $DIR/numbers.rs:82:40 | LL | assert::is_transmutable::< u8, i64>(); | ^^^ The size of `u8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -254,13 +254,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:82:40 + --> $DIR/numbers.rs:83:40 | LL | assert::is_transmutable::< u8, f64>(); | ^^^ The size of `u8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -269,13 +269,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:83:39 + --> $DIR/numbers.rs:84:39 | LL | assert::is_transmutable::< u8, u128>(); | ^^^^ The size of `u8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -284,13 +284,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:84:39 + --> $DIR/numbers.rs:85:39 | LL | assert::is_transmutable::< u8, i128>(); | ^^^^ The size of `u8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -299,13 +299,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:86:40 + --> $DIR/numbers.rs:87:40 | LL | assert::is_transmutable::< i16, i32>(); | ^^^ The size of `i16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -314,13 +314,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:87:40 + --> $DIR/numbers.rs:88:40 | LL | assert::is_transmutable::< i16, f32>(); | ^^^ The size of `i16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -329,13 +329,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:88:40 + --> $DIR/numbers.rs:89:40 | LL | assert::is_transmutable::< i16, u32>(); | ^^^ The size of `i16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -344,13 +344,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:89:40 + --> $DIR/numbers.rs:90:40 | LL | assert::is_transmutable::< i16, u64>(); | ^^^ The size of `i16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -359,13 +359,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:90:40 + --> $DIR/numbers.rs:91:40 | LL | assert::is_transmutable::< i16, i64>(); | ^^^ The size of `i16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -374,13 +374,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:91:40 + --> $DIR/numbers.rs:92:40 | LL | assert::is_transmutable::< i16, f64>(); | ^^^ The size of `i16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -389,13 +389,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:92:39 + --> $DIR/numbers.rs:93:39 | LL | assert::is_transmutable::< i16, u128>(); | ^^^^ The size of `i16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -404,13 +404,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:93:39 + --> $DIR/numbers.rs:94:39 | LL | assert::is_transmutable::< i16, i128>(); | ^^^^ The size of `i16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -419,13 +419,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:95:40 + --> $DIR/numbers.rs:96:40 | LL | assert::is_transmutable::< u16, i32>(); | ^^^ The size of `u16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -434,13 +434,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:96:40 + --> $DIR/numbers.rs:97:40 | LL | assert::is_transmutable::< u16, f32>(); | ^^^ The size of `u16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -449,13 +449,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:97:40 + --> $DIR/numbers.rs:98:40 | LL | assert::is_transmutable::< u16, u32>(); | ^^^ The size of `u16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -464,13 +464,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:98:40 + --> $DIR/numbers.rs:99:40 | LL | assert::is_transmutable::< u16, u64>(); | ^^^ The size of `u16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -479,13 +479,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:99:40 + --> $DIR/numbers.rs:100:40 | LL | assert::is_transmutable::< u16, i64>(); | ^^^ The size of `u16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -494,13 +494,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:100:40 + --> $DIR/numbers.rs:101:40 | LL | assert::is_transmutable::< u16, f64>(); | ^^^ The size of `u16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -509,13 +509,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:101:39 + --> $DIR/numbers.rs:102:39 | LL | assert::is_transmutable::< u16, u128>(); | ^^^^ The size of `u16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -524,13 +524,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:102:39 + --> $DIR/numbers.rs:103:39 | LL | assert::is_transmutable::< u16, i128>(); | ^^^^ The size of `u16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -539,13 +539,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:104:40 + --> $DIR/numbers.rs:105:40 | LL | assert::is_transmutable::< i32, u64>(); | ^^^ The size of `i32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -554,13 +554,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:105:40 + --> $DIR/numbers.rs:106:40 | LL | assert::is_transmutable::< i32, i64>(); | ^^^ The size of `i32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -569,13 +569,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:106:40 + --> $DIR/numbers.rs:107:40 | LL | assert::is_transmutable::< i32, f64>(); | ^^^ The size of `i32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -584,13 +584,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:107:39 + --> $DIR/numbers.rs:108:39 | LL | assert::is_transmutable::< i32, u128>(); | ^^^^ The size of `i32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -599,13 +599,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:108:39 + --> $DIR/numbers.rs:109:39 | LL | assert::is_transmutable::< i32, i128>(); | ^^^^ The size of `i32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -614,13 +614,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:110:40 + --> $DIR/numbers.rs:111:40 | LL | assert::is_transmutable::< f32, u64>(); | ^^^ The size of `f32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -629,13 +629,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:111:40 + --> $DIR/numbers.rs:112:40 | LL | assert::is_transmutable::< f32, i64>(); | ^^^ The size of `f32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -644,13 +644,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:112:40 + --> $DIR/numbers.rs:113:40 | LL | assert::is_transmutable::< f32, f64>(); | ^^^ The size of `f32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -659,13 +659,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:113:39 + --> $DIR/numbers.rs:114:39 | LL | assert::is_transmutable::< f32, u128>(); | ^^^^ The size of `f32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -674,13 +674,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:114:39 + --> $DIR/numbers.rs:115:39 | LL | assert::is_transmutable::< f32, i128>(); | ^^^^ The size of `f32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -689,13 +689,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:116:40 + --> $DIR/numbers.rs:117:40 | LL | assert::is_transmutable::< u32, u64>(); | ^^^ The size of `u32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -704,13 +704,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:117:40 + --> $DIR/numbers.rs:118:40 | LL | assert::is_transmutable::< u32, i64>(); | ^^^ The size of `u32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -719,13 +719,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:118:40 + --> $DIR/numbers.rs:119:40 | LL | assert::is_transmutable::< u32, f64>(); | ^^^ The size of `u32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -734,13 +734,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:119:39 + --> $DIR/numbers.rs:120:39 | LL | assert::is_transmutable::< u32, u128>(); | ^^^^ The size of `u32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -749,13 +749,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:120:39 + --> $DIR/numbers.rs:121:39 | LL | assert::is_transmutable::< u32, i128>(); | ^^^^ The size of `u32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -764,13 +764,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:122:39 + --> $DIR/numbers.rs:123:39 | LL | assert::is_transmutable::< u64, u128>(); | ^^^^ The size of `u64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -779,13 +779,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:123:39 + --> $DIR/numbers.rs:124:39 | LL | assert::is_transmutable::< u64, i128>(); | ^^^^ The size of `u64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -794,13 +794,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:125:39 + --> $DIR/numbers.rs:126:39 | LL | assert::is_transmutable::< i64, u128>(); | ^^^^ The size of `i64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -809,13 +809,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:126:39 + --> $DIR/numbers.rs:127:39 | LL | assert::is_transmutable::< i64, i128>(); | ^^^^ The size of `i64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -824,13 +824,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:128:39 + --> $DIR/numbers.rs:129:39 | LL | assert::is_transmutable::< f64, u128>(); | ^^^^ The size of `f64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -839,13 +839,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:129:39 + --> $DIR/numbers.rs:130:39 | LL | assert::is_transmutable::< f64, i128>(); | ^^^^ The size of `f64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/numbers.next.stderr b/tests/ui/transmutability/primitives/numbers.next.stderr index 7a80e444149..009e377af99 100644 --- a/tests/ui/transmutability/primitives/numbers.next.stderr +++ b/tests/ui/transmutability/primitives/numbers.next.stderr @@ -1,11 +1,11 @@ error[E0277]: `i8` cannot be safely transmuted into `i16` - --> $DIR/numbers.rs:64:40 + --> $DIR/numbers.rs:65:40 | LL | assert::is_transmutable::< i8, i16>(); | ^^^ The size of `i8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -14,13 +14,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u16` - --> $DIR/numbers.rs:65:40 + --> $DIR/numbers.rs:66:40 | LL | assert::is_transmutable::< i8, u16>(); | ^^^ The size of `i8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -29,13 +29,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:66:40 + --> $DIR/numbers.rs:67:40 | LL | assert::is_transmutable::< i8, i32>(); | ^^^ The size of `i8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -44,13 +44,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:67:40 + --> $DIR/numbers.rs:68:40 | LL | assert::is_transmutable::< i8, f32>(); | ^^^ The size of `i8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -59,13 +59,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:68:40 + --> $DIR/numbers.rs:69:40 | LL | assert::is_transmutable::< i8, u32>(); | ^^^ The size of `i8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -74,13 +74,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:69:40 + --> $DIR/numbers.rs:70:40 | LL | assert::is_transmutable::< i8, u64>(); | ^^^ The size of `i8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -89,13 +89,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:70:40 + --> $DIR/numbers.rs:71:40 | LL | assert::is_transmutable::< i8, i64>(); | ^^^ The size of `i8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -104,13 +104,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:71:40 + --> $DIR/numbers.rs:72:40 | LL | assert::is_transmutable::< i8, f64>(); | ^^^ The size of `i8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -119,13 +119,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:72:39 + --> $DIR/numbers.rs:73:39 | LL | assert::is_transmutable::< i8, u128>(); | ^^^^ The size of `i8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -134,13 +134,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:73:39 + --> $DIR/numbers.rs:74:39 | LL | assert::is_transmutable::< i8, i128>(); | ^^^^ The size of `i8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -149,13 +149,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i16` - --> $DIR/numbers.rs:75:40 + --> $DIR/numbers.rs:76:40 | LL | assert::is_transmutable::< u8, i16>(); | ^^^ The size of `u8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -164,13 +164,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u16` - --> $DIR/numbers.rs:76:40 + --> $DIR/numbers.rs:77:40 | LL | assert::is_transmutable::< u8, u16>(); | ^^^ The size of `u8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -179,13 +179,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:77:40 + --> $DIR/numbers.rs:78:40 | LL | assert::is_transmutable::< u8, i32>(); | ^^^ The size of `u8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -194,13 +194,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:78:40 + --> $DIR/numbers.rs:79:40 | LL | assert::is_transmutable::< u8, f32>(); | ^^^ The size of `u8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -209,13 +209,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:79:40 + --> $DIR/numbers.rs:80:40 | LL | assert::is_transmutable::< u8, u32>(); | ^^^ The size of `u8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -224,13 +224,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:80:40 + --> $DIR/numbers.rs:81:40 | LL | assert::is_transmutable::< u8, u64>(); | ^^^ The size of `u8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -239,13 +239,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:81:40 + --> $DIR/numbers.rs:82:40 | LL | assert::is_transmutable::< u8, i64>(); | ^^^ The size of `u8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -254,13 +254,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:82:40 + --> $DIR/numbers.rs:83:40 | LL | assert::is_transmutable::< u8, f64>(); | ^^^ The size of `u8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -269,13 +269,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:83:39 + --> $DIR/numbers.rs:84:39 | LL | assert::is_transmutable::< u8, u128>(); | ^^^^ The size of `u8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -284,13 +284,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:84:39 + --> $DIR/numbers.rs:85:39 | LL | assert::is_transmutable::< u8, i128>(); | ^^^^ The size of `u8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -299,13 +299,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:86:40 + --> $DIR/numbers.rs:87:40 | LL | assert::is_transmutable::< i16, i32>(); | ^^^ The size of `i16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -314,13 +314,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:87:40 + --> $DIR/numbers.rs:88:40 | LL | assert::is_transmutable::< i16, f32>(); | ^^^ The size of `i16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -329,13 +329,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:88:40 + --> $DIR/numbers.rs:89:40 | LL | assert::is_transmutable::< i16, u32>(); | ^^^ The size of `i16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -344,13 +344,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:89:40 + --> $DIR/numbers.rs:90:40 | LL | assert::is_transmutable::< i16, u64>(); | ^^^ The size of `i16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -359,13 +359,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:90:40 + --> $DIR/numbers.rs:91:40 | LL | assert::is_transmutable::< i16, i64>(); | ^^^ The size of `i16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -374,13 +374,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:91:40 + --> $DIR/numbers.rs:92:40 | LL | assert::is_transmutable::< i16, f64>(); | ^^^ The size of `i16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -389,13 +389,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:92:39 + --> $DIR/numbers.rs:93:39 | LL | assert::is_transmutable::< i16, u128>(); | ^^^^ The size of `i16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -404,13 +404,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:93:39 + --> $DIR/numbers.rs:94:39 | LL | assert::is_transmutable::< i16, i128>(); | ^^^^ The size of `i16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -419,13 +419,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i32` - --> $DIR/numbers.rs:95:40 + --> $DIR/numbers.rs:96:40 | LL | assert::is_transmutable::< u16, i32>(); | ^^^ The size of `u16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -434,13 +434,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f32` - --> $DIR/numbers.rs:96:40 + --> $DIR/numbers.rs:97:40 | LL | assert::is_transmutable::< u16, f32>(); | ^^^ The size of `u16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -449,13 +449,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u32` - --> $DIR/numbers.rs:97:40 + --> $DIR/numbers.rs:98:40 | LL | assert::is_transmutable::< u16, u32>(); | ^^^ The size of `u16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -464,13 +464,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:98:40 + --> $DIR/numbers.rs:99:40 | LL | assert::is_transmutable::< u16, u64>(); | ^^^ The size of `u16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -479,13 +479,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:99:40 + --> $DIR/numbers.rs:100:40 | LL | assert::is_transmutable::< u16, i64>(); | ^^^ The size of `u16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -494,13 +494,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:100:40 + --> $DIR/numbers.rs:101:40 | LL | assert::is_transmutable::< u16, f64>(); | ^^^ The size of `u16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -509,13 +509,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:101:39 + --> $DIR/numbers.rs:102:39 | LL | assert::is_transmutable::< u16, u128>(); | ^^^^ The size of `u16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -524,13 +524,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:102:39 + --> $DIR/numbers.rs:103:39 | LL | assert::is_transmutable::< u16, i128>(); | ^^^^ The size of `u16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -539,13 +539,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:104:40 + --> $DIR/numbers.rs:105:40 | LL | assert::is_transmutable::< i32, u64>(); | ^^^ The size of `i32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -554,13 +554,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:105:40 + --> $DIR/numbers.rs:106:40 | LL | assert::is_transmutable::< i32, i64>(); | ^^^ The size of `i32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -569,13 +569,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:106:40 + --> $DIR/numbers.rs:107:40 | LL | assert::is_transmutable::< i32, f64>(); | ^^^ The size of `i32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -584,13 +584,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:107:39 + --> $DIR/numbers.rs:108:39 | LL | assert::is_transmutable::< i32, u128>(); | ^^^^ The size of `i32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -599,13 +599,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:108:39 + --> $DIR/numbers.rs:109:39 | LL | assert::is_transmutable::< i32, i128>(); | ^^^^ The size of `i32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -614,13 +614,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:110:40 + --> $DIR/numbers.rs:111:40 | LL | assert::is_transmutable::< f32, u64>(); | ^^^ The size of `f32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -629,13 +629,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:111:40 + --> $DIR/numbers.rs:112:40 | LL | assert::is_transmutable::< f32, i64>(); | ^^^ The size of `f32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -644,13 +644,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:112:40 + --> $DIR/numbers.rs:113:40 | LL | assert::is_transmutable::< f32, f64>(); | ^^^ The size of `f32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -659,13 +659,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:113:39 + --> $DIR/numbers.rs:114:39 | LL | assert::is_transmutable::< f32, u128>(); | ^^^^ The size of `f32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -674,13 +674,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:114:39 + --> $DIR/numbers.rs:115:39 | LL | assert::is_transmutable::< f32, i128>(); | ^^^^ The size of `f32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -689,13 +689,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u64` - --> $DIR/numbers.rs:116:40 + --> $DIR/numbers.rs:117:40 | LL | assert::is_transmutable::< u32, u64>(); | ^^^ The size of `u32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -704,13 +704,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i64` - --> $DIR/numbers.rs:117:40 + --> $DIR/numbers.rs:118:40 | LL | assert::is_transmutable::< u32, i64>(); | ^^^ The size of `u32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -719,13 +719,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `f64` - --> $DIR/numbers.rs:118:40 + --> $DIR/numbers.rs:119:40 | LL | assert::is_transmutable::< u32, f64>(); | ^^^ The size of `u32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -734,13 +734,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:119:39 + --> $DIR/numbers.rs:120:39 | LL | assert::is_transmutable::< u32, u128>(); | ^^^^ The size of `u32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -749,13 +749,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:120:39 + --> $DIR/numbers.rs:121:39 | LL | assert::is_transmutable::< u32, i128>(); | ^^^^ The size of `u32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -764,13 +764,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:122:39 + --> $DIR/numbers.rs:123:39 | LL | assert::is_transmutable::< u64, u128>(); | ^^^^ The size of `u64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -779,13 +779,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:123:39 + --> $DIR/numbers.rs:124:39 | LL | assert::is_transmutable::< u64, i128>(); | ^^^^ The size of `u64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -794,13 +794,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:125:39 + --> $DIR/numbers.rs:126:39 | LL | assert::is_transmutable::< i64, u128>(); | ^^^^ The size of `i64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -809,13 +809,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:126:39 + --> $DIR/numbers.rs:127:39 | LL | assert::is_transmutable::< i64, i128>(); | ^^^^ The size of `i64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -824,13 +824,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `u128` - --> $DIR/numbers.rs:128:39 + --> $DIR/numbers.rs:129:39 | LL | assert::is_transmutable::< f64, u128>(); | ^^^^ The size of `f64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function @@ -839,13 +839,13 @@ LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `i128` - --> $DIR/numbers.rs:129:39 + --> $DIR/numbers.rs:130:39 | LL | assert::is_transmutable::< f64, i128>(); | ^^^^ The size of `f64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:14:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/numbers.rs b/tests/ui/transmutability/primitives/numbers.rs index 2b7d8a79860..896f5f49f67 100644 --- a/tests/ui/transmutability/primitives/numbers.rs +++ b/tests/ui/transmutability/primitives/numbers.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![crate_type = "lib"] diff --git a/tests/ui/transmutability/primitives/unit.current.stderr b/tests/ui/transmutability/primitives/unit.current.stderr index 37088a69698..b2831dbf842 100644 --- a/tests/ui/transmutability/primitives/unit.current.stderr +++ b/tests/ui/transmutability/primitives/unit.current.stderr @@ -1,11 +1,11 @@ error[E0277]: `()` cannot be safely transmuted into `u8` - --> $DIR/unit.rs:30:35 + --> $DIR/unit.rs:31:35 | LL | assert::is_transmutable::<(), u8>(); | ^^ The size of `()` is smaller than the size of `u8` | note: required by a bound in `is_transmutable` - --> $DIR/unit.rs:15:14 + --> $DIR/unit.rs:16:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/unit.next.stderr b/tests/ui/transmutability/primitives/unit.next.stderr index 37088a69698..b2831dbf842 100644 --- a/tests/ui/transmutability/primitives/unit.next.stderr +++ b/tests/ui/transmutability/primitives/unit.next.stderr @@ -1,11 +1,11 @@ error[E0277]: `()` cannot be safely transmuted into `u8` - --> $DIR/unit.rs:30:35 + --> $DIR/unit.rs:31:35 | LL | assert::is_transmutable::<(), u8>(); | ^^ The size of `()` is smaller than the size of `u8` | note: required by a bound in `is_transmutable` - --> $DIR/unit.rs:15:14 + --> $DIR/unit.rs:16:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/unit.rs b/tests/ui/transmutability/primitives/unit.rs index 24649443565..44216950f55 100644 --- a/tests/ui/transmutability/primitives/unit.rs +++ b/tests/ui/transmutability/primitives/unit.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //! The unit type, `()`, should be one byte. diff --git a/tests/ui/type-alias-impl-trait/assoc-type-const.rs b/tests/ui/type-alias-impl-trait/assoc-type-const.rs index 3591773209a..cc55fc2a41f 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-const.rs +++ b/tests/ui/type-alias-impl-trait/assoc-type-const.rs @@ -3,6 +3,7 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/cross_inference.rs b/tests/ui/type-alias-impl-trait/cross_inference.rs index 50777e57112..2f0d1e89d47 100644 --- a/tests/ui/type-alias-impl-trait/cross_inference.rs +++ b/tests/ui/type-alias-impl-trait/cross_inference.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass diff --git a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs index f072bb88792..9ceef0139f0 100644 --- a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs +++ b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs @@ -2,6 +2,7 @@ // Tests that we don't ICE when we have a trait impl on a TAIT. //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/issue-78450.rs b/tests/ui/type-alias-impl-trait/issue-78450.rs index d1328be8475..7d749b1a349 100644 --- a/tests/ui/type-alias-impl-trait/issue-78450.rs +++ b/tests/ui/type-alias-impl-trait/issue-78450.rs @@ -1,5 +1,6 @@ //@ check-pass //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/nested_inference_failure.rs b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs index 08acfea0004..004e79d6738 100644 --- a/tests/ui/type-alias-impl-trait/nested_inference_failure.rs +++ b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs @@ -1,6 +1,7 @@ //@ check-pass -//@ revisions: new old -//@[new] compile-flags: -Znext-solver +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver //! This test checks that we can successfully infer //! the hidden type of `FooImpl` to be `Foo` diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr index d9d5dd4ece3..a40dac06a01 100644 --- a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr @@ -1,29 +1,29 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:25:20 + --> $DIR/normalize-hidden-types.rs:26:20 | LL | fn define() -> Opaque { | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` | note: previous use here - --> $DIR/normalize-hidden-types.rs:26:9 + --> $DIR/normalize-hidden-types.rs:27:9 | LL | dyn_hoops::<_>(0) | ^^^^^^^^^^^^^^^^^ error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:33:22 + --> $DIR/normalize-hidden-types.rs:34:22 | LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` | note: previous use here - --> $DIR/normalize-hidden-types.rs:33:31 + --> $DIR/normalize-hidden-types.rs:34:31 | LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/normalize-hidden-types.rs:42:25 + --> $DIR/normalize-hidden-types.rs:43:25 | LL | type Opaque = impl Sized; | ---------- the expected opaque type @@ -39,13 +39,13 @@ LL | let _: Opaque = dyn_hoops::(0); = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: concrete type differs from previous defining opaque type use - --> $DIR/normalize-hidden-types.rs:51:25 + --> $DIR/normalize-hidden-types.rs:52:25 | LL | let _: Opaque = dyn_hoops::<_>(0); | ^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` | note: previous use here - --> $DIR/normalize-hidden-types.rs:52:9 + --> $DIR/normalize-hidden-types.rs:53:9 | LL | None | ^^^^ diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs index d6800694e51..4028dba82bf 100644 --- a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs @@ -1,6 +1,7 @@ // Regression test for #112691 // //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@ [next] compile-flags: -Znext-solver //@ [next] check-pass //@ [current] known-bug: #112691 diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr index 069292239bc..1c36fda4ae1 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr @@ -8,13 +8,13 @@ error: internal compiler error: {OpaqueTypeKey { def_id: DefId(get_rpit::{opaque error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } - --> $DIR/rpit_tait_equality_in_canonical_query.rs:31:5 + --> $DIR/rpit_tait_equality_in_canonical_query.rs:32:5 | LL | query(get_rpit); | ^^^^^^^^^^^^^^^ | - --> $DIR/rpit_tait_equality_in_canonical_query.rs:31:5 + --> $DIR/rpit_tait_equality_in_canonical_query.rs:32:5 | LL | query(get_rpit); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs index 88a8f6e11a5..7524cebf9e6 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs @@ -6,6 +6,7 @@ //! have a situation where the RPIT gets constrained outside its anchor. //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr index 019e01a07d3..3ae3590ca7f 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `i32` with `Foo` - --> $DIR/self-referential-2.rs:9:13 + --> $DIR/self-referential-2.rs:10:13 | LL | fn bar() -> Bar { | ^^^ no implementation for `i32 == Foo` diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.rs b/tests/ui/type-alias-impl-trait/self-referential-2.rs index abba5b3a203..f96364ccfcd 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-2.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-2.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr index b380dc66f03..036ab66f79d 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr @@ -1,11 +1,11 @@ error[E0284]: type annotations needed: cannot satisfy `Foo == _` - --> $DIR/type-alias-impl-trait-tuple.rs:21:24 + --> $DIR/type-alias-impl-trait-tuple.rs:22:24 | LL | Blah { my_foo: make_foo(), my_u8: 12 } | ^^^^^^^^^^ cannot satisfy `Foo == _` error[E0284]: type annotations needed: cannot satisfy `Foo == _` - --> $DIR/type-alias-impl-trait-tuple.rs:25:10 + --> $DIR/type-alias-impl-trait-tuple.rs:26:10 | LL | (self.my_foo, self.my_u8, make_foo()) | ^^^^^^^^^^^ cannot satisfy `Foo == _` diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs index 8d0456e587c..fadb92ab440 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[current] check-pass diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr b/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr index 22a3d7bd32f..7cf2fe42da8 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/type_of_a_let.rs:20:16 + --> $DIR/type_of_a_let.rs:21:16 | LL | let x: Foo = 22_u32; | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | same_type((x, y)); | ^ value used here after move error[E0382]: use of moved value: `y` - --> $DIR/type_of_a_let.rs:21:6 + --> $DIR/type_of_a_let.rs:22:6 | LL | let y: Foo = x; | - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.rs b/tests/ui/type-alias-impl-trait/type_of_a_let.rs index 48fcac92bec..cc8caf886cf 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.rs +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@[next] check-pass diff --git a/tests/ui/unsized/issue-71659.current.stderr b/tests/ui/unsized/issue-71659.current.stderr index df0b998fd88..f7de668ba3a 100644 --- a/tests/ui/unsized/issue-71659.current.stderr +++ b/tests/ui/unsized/issue-71659.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied - --> $DIR/issue-71659.rs:33:15 + --> $DIR/issue-71659.rs:34:15 | LL | let x = x.cast::<[i32]>(); | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` | note: required by a bound in `Cast::cast` - --> $DIR/issue-71659.rs:22:15 + --> $DIR/issue-71659.rs:23:15 | LL | fn cast(&self) -> &T | ---- required by a bound in this associated function diff --git a/tests/ui/unsized/issue-71659.next.stderr b/tests/ui/unsized/issue-71659.next.stderr index df0b998fd88..f7de668ba3a 100644 --- a/tests/ui/unsized/issue-71659.next.stderr +++ b/tests/ui/unsized/issue-71659.next.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied - --> $DIR/issue-71659.rs:33:15 + --> $DIR/issue-71659.rs:34:15 | LL | let x = x.cast::<[i32]>(); | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` | note: required by a bound in `Cast::cast` - --> $DIR/issue-71659.rs:22:15 + --> $DIR/issue-71659.rs:23:15 | LL | fn cast(&self) -> &T | ---- required by a bound in this associated function diff --git a/tests/ui/unsized/issue-71659.rs b/tests/ui/unsized/issue-71659.rs index fd0b799d889..c463ed125bb 100644 --- a/tests/ui/unsized/issue-71659.rs +++ b/tests/ui/unsized/issue-71659.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(unsize)] diff --git a/tests/ui/unsized/issue-75899.rs b/tests/ui/unsized/issue-75899.rs index 9cfcf0aa13e..2cc3c0dd51d 100644 --- a/tests/ui/unsized/issue-75899.rs +++ b/tests/ui/unsized/issue-75899.rs @@ -1,4 +1,5 @@ //@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver //@ check-pass From a7cd803d029d71ab4d111fca43ce33ba55fe9841 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 10 Mar 2024 22:38:53 -0400 Subject: [PATCH 23/35] use ptradd for vtable indexing Like field offsets, these are always constant. --- compiler/rustc_codegen_ssa/src/base.rs | 13 ++-- compiler/rustc_codegen_ssa/src/meth.rs | 19 +++--- tests/codegen/dst-offset.rs | 4 +- tests/codegen/vtable-upcast.rs | 85 ++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 tests/codegen/vtable-upcast.rs diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 5cba14a5dda..c316d19e041 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -165,14 +165,11 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx.tcx().vtable_trait_upcasting_coercion_new_vptr_slot((source, target)); if let Some(entry_idx) = vptr_entry_idx { - let ptr_ty = cx.type_ptr(); - let ptr_align = cx.tcx().data_layout.pointer_align.abi; - let gep = bx.inbounds_gep( - ptr_ty, - old_info, - &[bx.const_usize(u64::try_from(entry_idx).unwrap())], - ); - let new_vptr = bx.load(ptr_ty, gep, ptr_align); + let ptr_size = bx.data_layout().pointer_size; + let ptr_align = bx.data_layout().pointer_align.abi; + let vtable_byte_offset = u64::try_from(entry_idx).unwrap() * ptr_size.bytes(); + let gep = bx.inbounds_ptradd(old_info, bx.const_usize(vtable_byte_offset)); + let new_vptr = bx.load(bx.type_ptr(), gep, ptr_align); bx.nonnull_metadata(new_vptr); // VTable loads are invariant. bx.set_invariant_load(new_vptr); diff --git a/compiler/rustc_codegen_ssa/src/meth.rs b/compiler/rustc_codegen_ssa/src/meth.rs index 12146a54d3b..4f7dc9968a1 100644 --- a/compiler/rustc_codegen_ssa/src/meth.rs +++ b/compiler/rustc_codegen_ssa/src/meth.rs @@ -20,9 +20,13 @@ impl<'a, 'tcx> VirtualIndex { ty: Ty<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, ) -> Bx::Value { - // Load the data pointer from the object. + // Load the function pointer from the object. debug!("get_fn({llvtable:?}, {ty:?}, {self:?})"); + let llty = bx.fn_ptr_backend_type(fn_abi); + let ptr_size = bx.data_layout().pointer_size; + let ptr_align = bx.data_layout().pointer_align.abi; + let vtable_byte_offset = self.0 * ptr_size.bytes(); if bx.cx().sess().opts.unstable_opts.virtual_function_elimination && bx.cx().sess().lto() == Lto::Fat @@ -30,12 +34,10 @@ impl<'a, 'tcx> VirtualIndex { let typeid = bx .typeid_metadata(typeid_for_trait_ref(bx.tcx(), expect_dyn_trait_in_self(ty))) .unwrap(); - let vtable_byte_offset = self.0 * bx.data_layout().pointer_size.bytes(); let func = bx.type_checked_load(llvtable, vtable_byte_offset, typeid); func } else { - let ptr_align = bx.tcx().data_layout.pointer_align.abi; - let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]); + let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); let ptr = bx.load(llty, gep, ptr_align); bx.nonnull_metadata(ptr); // VTable loads are invariant. @@ -53,9 +55,12 @@ impl<'a, 'tcx> VirtualIndex { debug!("get_int({:?}, {:?})", llvtable, self); let llty = bx.type_isize(); - let usize_align = bx.tcx().data_layout.pointer_align.abi; - let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]); - let ptr = bx.load(llty, gep, usize_align); + let ptr_size = bx.data_layout().pointer_size; + let ptr_align = bx.data_layout().pointer_align.abi; + let vtable_byte_offset = self.0 * ptr_size.bytes(); + + let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); + let ptr = bx.load(llty, gep, ptr_align); // VTable loads are invariant. bx.set_invariant_load(ptr); ptr diff --git a/tests/codegen/dst-offset.rs b/tests/codegen/dst-offset.rs index f0157e5a106..ce735baeb6a 100644 --- a/tests/codegen/dst-offset.rs +++ b/tests/codegen/dst-offset.rs @@ -25,9 +25,9 @@ struct Dst { pub fn dst_dyn_trait_offset(s: &Dst) -> &dyn Drop { // The alignment of dyn trait is unknown, so we compute the offset based on align from the vtable. -// CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds {{.+}} [[VTABLE_PTR]] +// CHECK: [[SIZE_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]] // CHECK: load [[USIZE]], ptr [[SIZE_PTR]] -// CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds {{.+}} [[VTABLE_PTR]] +// CHECK: [[ALIGN_PTR:%[0-9]+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]] // CHECK: load [[USIZE]], ptr [[ALIGN_PTR]] // CHECK: getelementptr inbounds i8, ptr [[DATA_PTR]] diff --git a/tests/codegen/vtable-upcast.rs b/tests/codegen/vtable-upcast.rs new file mode 100644 index 00000000000..41a4be26cb4 --- /dev/null +++ b/tests/codegen/vtable-upcast.rs @@ -0,0 +1,85 @@ +//! This file tests that we correctly generate GEP instructions for vtable upcasting. +//@ compile-flags: -C no-prepopulate-passes -Copt-level=0 + +#![crate_type = "lib"] +#![feature(trait_upcasting)] + +pub trait Base { + fn base(&self); +} + +pub trait A : Base { + fn a(&self); +} + +pub trait B : Base { + fn b(&self); +} + +pub trait Diamond : A + B { + fn diamond(&self); +} + +// CHECK-LABEL: upcast_a_to_base +#[no_mangle] +pub fn upcast_a_to_base(x: &dyn A) -> &dyn Base { + // Requires no adjustment, since its vtable is extended from `Base`. + + // CHECK: start: + // CHECK-NEXT: insertvalue + // CHECK-NEXT: insertvalue + // CHECK-NEXT: ret + x as &dyn Base +} + +// CHECK-LABEL: upcast_b_to_base +#[no_mangle] +pub fn upcast_b_to_base(x: &dyn B) -> &dyn Base { + // Requires no adjustment, since its vtable is extended from `Base`. + + // CHECK: start: + // CHECK-NEXT: insertvalue + // CHECK-NEXT: insertvalue + // CHECK-NEXT: ret + x as &dyn Base +} + +// CHECK-LABEL: upcast_diamond_to_a +#[no_mangle] +pub fn upcast_diamond_to_a(x: &dyn Diamond) -> &dyn A { + // Requires no adjustment, since its vtable is extended from `A` (as the first supertrait). + + // CHECK: start: + // CHECK-NEXT: insertvalue + // CHECK-NEXT: insertvalue + // CHECK-NEXT: ret + x as &dyn A +} + +// CHECK-LABEL: upcast_diamond_to_b +// CHECK-SAME: (ptr align {{[0-9]+}} [[DATA_PTR:%.+]], ptr align {{[0-9]+}} [[VTABLE_PTR:%.+]]) +#[no_mangle] +pub fn upcast_diamond_to_b(x: &dyn Diamond) -> &dyn B { + // Requires adjustment, since it's a non-first supertrait. + + // CHECK: start: + // CHECK-NEXT: [[UPCAST_SLOT_PTR:%.+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]] + // CHECK-NEXT: [[UPCAST_VTABLE_PTR:%.+]] = load ptr, ptr [[UPCAST_SLOT_PTR]] + // CHECK-NEXT: [[FAT_PTR_1:%.+]] = insertvalue { ptr, ptr } poison, ptr [[DATA_PTR]], 0 + // CHECK-NEXT: [[FAT_PTR_2:%.+]] = insertvalue { ptr, ptr } [[FAT_PTR_1]], ptr [[UPCAST_VTABLE_PTR]], 1 + // CHECK-NEXT: ret { ptr, ptr } [[FAT_PTR_2]] + x as &dyn B +} + +// CHECK-LABEL: upcast_diamond_to_b +#[no_mangle] +pub fn upcast_diamond_to_base(x: &dyn Diamond) -> &dyn Base { + // Requires no adjustment, since `Base` is the first supertrait of `A`, + // which is the first supertrait of `Diamond`. + + // CHECK: start: + // CHECK-NEXT: insertvalue + // CHECK-NEXT: insertvalue + // CHECK-NEXT: ret + x as &dyn Base +} From 73fc17054490b246ee3e3c2cf515a1c850a3a4a5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 10 Mar 2024 16:24:48 +0000 Subject: [PATCH 24/35] Store backtrace for must_produce_diag --- compiler/rustc_errors/src/lib.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 76b44f73f47..3d7a8e1ed7d 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -442,8 +442,8 @@ struct DiagCtxtInner { emitter: Box, /// Must we produce a diagnostic to justify the use of the expensive - /// `trimmed_def_paths` function? - must_produce_diag: bool, + /// `trimmed_def_paths` function? Backtrace is the location of the call. + must_produce_diag: Option, /// Has this diagnostic context printed any diagnostics? (I.e. has /// `self.emitter.emit_diagnostic()` been called? @@ -572,10 +572,11 @@ impl Drop for DiagCtxtInner { } if !self.has_printed && !self.suppressed_expected_diag && !std::thread::panicking() { - if self.must_produce_diag { + if let Some(backtrace) = &self.must_produce_diag { panic!( - "must_produce_diag: trimmed_def_paths called but no diagnostics emitted; \ - use `DelayDm` for lints or `with_no_trimmed_paths` for debugging" + "must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \ + use `DelayDm` for lints or `with_no_trimmed_paths` for debugging. \ + called at: {backtrace}" ); } } @@ -721,7 +722,7 @@ impl DiagCtxt { *delayed_bugs = Default::default(); *deduplicated_err_count = 0; *deduplicated_warn_count = 0; - *must_produce_diag = false; + *must_produce_diag = None; *has_printed = false; *suppressed_expected_diag = false; *taught_diagnostics = Default::default(); @@ -1091,8 +1092,13 @@ impl DiagCtxt { /// Used when trimmed_def_paths is called and we must produce a diagnostic /// to justify its cost. + #[track_caller] pub fn set_must_produce_diag(&self) { - self.inner.borrow_mut().must_produce_diag = true; + assert!( + self.inner.borrow().must_produce_diag.is_none(), + "should only need to collect a backtrace once" + ); + self.inner.borrow_mut().must_produce_diag = Some(Backtrace::capture()); } } @@ -1387,7 +1393,7 @@ impl DiagCtxtInner { deduplicated_err_count: 0, deduplicated_warn_count: 0, emitter, - must_produce_diag: false, + must_produce_diag: None, has_printed: false, suppressed_expected_diag: false, taught_diagnostics: Default::default(), From 01e6b43a0735aaff7c127a39984ecd9638232edf Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 10 Mar 2024 22:25:32 -0400 Subject: [PATCH 25/35] Mark some next-solver-behavior tests explicitly with revisions --- .../bugs/wf-check-skipped.next.stderr | 8 +++++ .../bugs/wf-check-skipped.rs | 11 ++++--- ...> defaults-unsound-62211-1.current.stderr} | 16 +++++----- .../defaults-unsound-62211-1.next.stderr | 13 ++++++++ .../defaults-unsound-62211-1.rs | 14 ++++++--- ...> defaults-unsound-62211-2.current.stderr} | 16 +++++----- .../defaults-unsound-62211-2.next.stderr | 13 ++++++++ .../defaults-unsound-62211-2.rs | 14 ++++++--- ...t-impl-for-trait-obj-coherence.next.stderr | 9 ++++++ .../indirect-impl-for-trait-obj-coherence.rs | 8 +++-- ...alization-for-nested-goals.current.stderr} | 6 ++-- ...sume-gat-normalization-for-nested-goals.rs | 6 +++- .../issue-90014-tait2.next-solver.stderr | 15 ++++++++++ tests/ui/traits/pointee-tail-is-generic.rs | 10 ++++--- tests/ui/typeck/issue-103899.rs | 12 +++++--- .../ui/wf/wf-normalization-sized.next.stderr | 30 +++++++++++++++++++ tests/ui/wf/wf-normalization-sized.rs | 11 +++++-- 17 files changed, 168 insertions(+), 44 deletions(-) create mode 100644 tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr rename tests/ui/associated-types/{defaults-unsound-62211-1.stderr => defaults-unsound-62211-1.current.stderr} (89%) create mode 100644 tests/ui/associated-types/defaults-unsound-62211-1.next.stderr rename tests/ui/associated-types/{defaults-unsound-62211-2.stderr => defaults-unsound-62211-2.current.stderr} (89%) create mode 100644 tests/ui/associated-types/defaults-unsound-62211-2.next.stderr create mode 100644 tests/ui/coherence/indirect-impl-for-trait-obj-coherence.next.stderr rename tests/ui/generic-associated-types/{assume-gat-normalization-for-nested-goals.stderr => assume-gat-normalization-for-nested-goals.current.stderr} (83%) create mode 100644 tests/ui/generic-associated-types/issue-90014-tait2.next-solver.stderr create mode 100644 tests/ui/wf/wf-normalization-sized.next.stderr diff --git a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr new file mode 100644 index 00000000000..77fbaf52934 --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr @@ -0,0 +1,8 @@ +error: the type `Foo::Bar>` is not well-formed + --> $DIR/wf-check-skipped.rs:17:14 + | +LL | fn main() -> Foo::Bar::> {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs index 3159500393e..5b812a2295e 100644 --- a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs +++ b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs @@ -1,11 +1,13 @@ -//@ known-bug: #100041 -//@ check-pass +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] known-bug: #100041 +//@[current] check-pass +// FIXME(inherent_associated_types): This should fail. #![feature(inherent_associated_types)] #![allow(incomplete_features)] -// FIXME(inherent_associated_types): This should fail. - struct Foo; impl Foo { @@ -13,3 +15,4 @@ impl Foo { } fn main() -> Foo::Bar::> {} +//[next]~^ ERROR the type `Foo::Bar>` is not well-formed diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr similarity index 89% rename from tests/ui/associated-types/defaults-unsound-62211-1.stderr rename to tests/ui/associated-types/defaults-unsound-62211-1.current.stderr index 5cd1cb4a1a7..9d52e923ade 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr @@ -1,12 +1,12 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-1.rs:20:96 + --> $DIR/defaults-unsound-62211-1.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ `Self` cannot be formatted with the default formatter | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-1.rs:20:86 + --> $DIR/defaults-unsound-62211-1.rs:26:86 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -16,13 +16,13 @@ LL | trait UncheckedCopy: Sized + std::fmt::Display { | +++++++++++++++++++ error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-1.rs:20:96 + --> $DIR/defaults-unsound-62211-1.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ no implementation for `Self += &'static str` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-1.rs:20:47 + --> $DIR/defaults-unsound-62211-1.rs:26:47 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -32,13 +32,13 @@ LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { | +++++++++++++++++++++++++ error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:20:96 + --> $DIR/defaults-unsound-62211-1.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ the trait `Deref` is not implemented for `Self` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-1.rs:20:25 + --> $DIR/defaults-unsound-62211-1.rs:26:25 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -48,13 +48,13 @@ LL | trait UncheckedCopy: Sized + Deref { | +++++++ error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:20:96 + --> $DIR/defaults-unsound-62211-1.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ the trait `Copy` is not implemented for `Self` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-1.rs:20:18 + --> $DIR/defaults-unsound-62211-1.rs:26:18 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr new file mode 100644 index 00000000000..834ae00a8d8 --- /dev/null +++ b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr @@ -0,0 +1,13 @@ +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/defaults-unsound-62211-1.rs:52:5 + | +LL | drop(origin); + | ^^^^^------^ + | | + | argument has type `::Output` + | + = note: use `let _ = ...` to ignore the expression or result + = note: `#[warn(dropping_copy_types)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.rs b/tests/ui/associated-types/defaults-unsound-62211-1.rs index fa6a208b4f1..d9cf5aa97ac 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.rs +++ b/tests/ui/associated-types/defaults-unsound-62211-1.rs @@ -1,3 +1,9 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] known-bug: rust-lang/trait-system-refactor-initiative#46 +//@[next] check-pass + //! Regression test for https://github.com/rust-lang/rust/issues/62211 //! //! The old implementation of defaults did not check whether the provided @@ -18,10 +24,10 @@ trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; - //~^ ERROR the trait bound `Self: Copy` is not satisfied - //~| ERROR the trait bound `Self: Deref` is not satisfied - //~| ERROR cannot add-assign `&'static str` to `Self` - //~| ERROR `Self` doesn't implement `std::fmt::Display` + //[current]~^ ERROR the trait bound `Self: Copy` is not satisfied + //[current]~| ERROR the trait bound `Self: Deref` is not satisfied + //[current]~| ERROR cannot add-assign `&'static str` to `Self` + //[current]~| ERROR `Self` doesn't implement `std::fmt::Display` // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr similarity index 89% rename from tests/ui/associated-types/defaults-unsound-62211-2.stderr rename to tests/ui/associated-types/defaults-unsound-62211-2.current.stderr index 89319bb7563..4fd2ca6408a 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr @@ -1,12 +1,12 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-2.rs:20:96 + --> $DIR/defaults-unsound-62211-2.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ `Self` cannot be formatted with the default formatter | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-2.rs:20:86 + --> $DIR/defaults-unsound-62211-2.rs:26:86 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -16,13 +16,13 @@ LL | trait UncheckedCopy: Sized + std::fmt::Display { | +++++++++++++++++++ error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-2.rs:20:96 + --> $DIR/defaults-unsound-62211-2.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ no implementation for `Self += &'static str` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-2.rs:20:47 + --> $DIR/defaults-unsound-62211-2.rs:26:47 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -32,13 +32,13 @@ LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { | +++++++++++++++++++++++++ error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:20:96 + --> $DIR/defaults-unsound-62211-2.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ the trait `Deref` is not implemented for `Self` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-2.rs:20:25 + --> $DIR/defaults-unsound-62211-2.rs:26:25 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` @@ -48,13 +48,13 @@ LL | trait UncheckedCopy: Sized + Deref { | +++++++ error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:20:96 + --> $DIR/defaults-unsound-62211-2.rs:26:96 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ the trait `Copy` is not implemented for `Self` | note: required by a bound in `UncheckedCopy::Output` - --> $DIR/defaults-unsound-62211-2.rs:20:18 + --> $DIR/defaults-unsound-62211-2.rs:26:18 | LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr new file mode 100644 index 00000000000..0f944a18ed5 --- /dev/null +++ b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr @@ -0,0 +1,13 @@ +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/defaults-unsound-62211-2.rs:52:5 + | +LL | drop(origin); + | ^^^^^------^ + | | + | argument has type `::Output` + | + = note: use `let _ = ...` to ignore the expression or result + = note: `#[warn(dropping_copy_types)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.rs b/tests/ui/associated-types/defaults-unsound-62211-2.rs index c13ec776afe..6cbac1bf236 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.rs +++ b/tests/ui/associated-types/defaults-unsound-62211-2.rs @@ -1,3 +1,9 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] known-bug: rust-lang/trait-system-refactor-initiative#46 +//@[next] check-pass + //! Regression test for https://github.com/rust-lang/rust/issues/62211 //! //! The old implementation of defaults did not check whether the provided @@ -18,10 +24,10 @@ trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; - //~^ ERROR the trait bound `Self: Copy` is not satisfied - //~| ERROR the trait bound `Self: Deref` is not satisfied - //~| ERROR cannot add-assign `&'static str` to `Self` - //~| ERROR `Self` doesn't implement `std::fmt::Display` + //[current]~^ ERROR the trait bound `Self: Copy` is not satisfied + //[current]~| ERROR the trait bound `Self: Deref` is not satisfied + //[current]~| ERROR cannot add-assign `&'static str` to `Self` + //[current]~| ERROR `Self` doesn't implement `std::fmt::Display` // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { diff --git a/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.next.stderr b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.next.stderr new file mode 100644 index 00000000000..6e41561f1a7 --- /dev/null +++ b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.next.stderr @@ -0,0 +1,9 @@ +error[E0284]: type annotations needed: cannot satisfy ` as Object>::Output == T` + --> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41 + | +LL | foo::, U>(x) + | ^ cannot satisfy ` as Object>::Output == T` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs index 201a46a166a..0b66a6e7830 100644 --- a/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs +++ b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs @@ -1,5 +1,8 @@ -//@ check-pass -//@ known-bug: #57893 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-pass +//@[current] known-bug: #57893 // Should fail. Because we see an impl that uses a certain associated type, we // type-check assuming that impl is used. However, this conflicts with the @@ -20,6 +23,7 @@ fn foo(x: >::Output) -> U { #[allow(dead_code)] fn transmute(x: T) -> U { foo::, U>(x) + //[next]~^ ERROR type annotations needed: cannot satisfy ` as Object>::Output == T` } fn main() {} diff --git a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.stderr b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr similarity index 83% rename from tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.stderr rename to tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr index 314a5509da8..2097115af00 100644 --- a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.stderr +++ b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `::Bar<()>: Eq` is not satisfied - --> $DIR/assume-gat-normalization-for-nested-goals.rs:6:30 + --> $DIR/assume-gat-normalization-for-nested-goals.rs:10:30 | LL | type Bar: Baz = i32; | ^^^ the trait `Eq` is not implemented for `::Bar<()>`, which is required by `i32: Baz` | note: required for `i32` to implement `Baz` - --> $DIR/assume-gat-normalization-for-nested-goals.rs:13:23 + --> $DIR/assume-gat-normalization-for-nested-goals.rs:17:23 | LL | impl Baz for i32 where T::Bar<()>: Eq {} | ^^^^^^ ^^^ ------- unsatisfied trait bound introduced here note: required by a bound in `Foo::Bar` - --> $DIR/assume-gat-normalization-for-nested-goals.rs:6:18 + --> $DIR/assume-gat-normalization-for-nested-goals.rs:10:18 | LL | type Bar: Baz = i32; | ^^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.rs b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.rs index fade3c441ab..56b50594e52 100644 --- a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.rs +++ b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.rs @@ -1,4 +1,8 @@ -//@ known-bug: #117606 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] known-bug: #117606 +//@[next] check-pass #![feature(associated_type_defaults)] diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.next-solver.stderr b/tests/ui/generic-associated-types/issue-90014-tait2.next-solver.stderr new file mode 100644 index 00000000000..85c5dad7fc0 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-90014-tait2.next-solver.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-90014-tait2.rs:27:9 + | +LL | fn make_fut(&self) -> Box Trait<'a, Thing = Fut<'a>>> { + | ------------------------------------------- expected `Box<(dyn for<'a> Trait<'a, Thing = Fut<'a>> + 'static)>` because of return type +LL | Box::new((async { () },)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box>>`, found `Box<(...,)>` + | + = note: expected struct `Box<(dyn for<'a> Trait<'a, Thing = Fut<'a>> + 'static)>` + found struct `Box<({async block@$DIR/issue-90014-tait2.rs:27:19: 27:31},)>` + = help: `({async block@$DIR/issue-90014-tait2.rs:27:19: 27:31},)` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/pointee-tail-is-generic.rs b/tests/ui/traits/pointee-tail-is-generic.rs index e33b2b2f2bc..14bdf0880c7 100644 --- a/tests/ui/traits/pointee-tail-is-generic.rs +++ b/tests/ui/traits/pointee-tail-is-generic.rs @@ -4,10 +4,12 @@ #![feature(ptr_metadata)] #![feature(type_alias_impl_trait)] -type Opaque = impl std::future::Future; +mod opaque { + pub type Opaque = impl std::future::Future; -fn opaque() -> Opaque { - async {} + fn opaque() -> Opaque { + async {} + } } fn a() { @@ -16,7 +18,7 @@ fn a() { // tail of ADT (which is a type param) is known to be sized is_thin::>(); // opaque type is known to be sized - is_thin::(); + is_thin::(); } fn a2() { diff --git a/tests/ui/typeck/issue-103899.rs b/tests/ui/typeck/issue-103899.rs index 5876a34ef55..38882e9dc54 100644 --- a/tests/ui/typeck/issue-103899.rs +++ b/tests/ui/typeck/issue-103899.rs @@ -1,7 +1,11 @@ -//@ check-fail -//@ failure-status: 101 -//@ dont-check-compiler-stderr -//@ known-bug: #103899 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@[next] check-pass +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-fail +//@[current] failure-status: 101 +//@[current] dont-check-compiler-stderr +//@[current] known-bug: #103899 trait BaseWithAssoc { type Assoc; diff --git a/tests/ui/wf/wf-normalization-sized.next.stderr b/tests/ui/wf/wf-normalization-sized.next.stderr new file mode 100644 index 00000000000..599b1f3d45e --- /dev/null +++ b/tests/ui/wf/wf-normalization-sized.next.stderr @@ -0,0 +1,30 @@ +error: the type `<[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize` is not well-formed + --> $DIR/wf-normalization-sized.rs:19:10 + | +LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the type `<[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize` is not well-formed + --> $DIR/wf-normalization-sized.rs:19:10 + | +LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: the type ` as WellUnformed>::RequestNormalize` is not well-formed + --> $DIR/wf-normalization-sized.rs:22:10 + | +LL | const _: as WellUnformed>::RequestNormalize = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the type ` as WellUnformed>::RequestNormalize` is not well-formed + --> $DIR/wf-normalization-sized.rs:22:10 + | +LL | const _: as WellUnformed>::RequestNormalize = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors + diff --git a/tests/ui/wf/wf-normalization-sized.rs b/tests/ui/wf/wf-normalization-sized.rs index e14be6b62bb..e6e24ff9e85 100644 --- a/tests/ui/wf/wf-normalization-sized.rs +++ b/tests/ui/wf/wf-normalization-sized.rs @@ -1,5 +1,8 @@ -//@ check-pass -//@ known-bug: #100041 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-pass +//@[current] known-bug: #100041 // Should fail. Normalization can bypass well-formedness checking. // `[[[[[[u8]]]]]]` is not a well-formed type since size of type `[u8]` cannot @@ -14,6 +17,10 @@ impl WellUnformed for T { } const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); +//[next]~^ the type +//[next]~| the type const _: as WellUnformed>::RequestNormalize = (); +//[next]~^ the type +//[next]~| the type fn main() {} From aea60b0cc78cf7b0d189c52f79563f1e4e82dfb8 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 9 Feb 2024 08:05:32 +0100 Subject: [PATCH 26/35] unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places. --- tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr | 6 +++--- tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr | 2 +- .../ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs | 2 +- .../attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr | 2 +- .../attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs | 2 +- .../unix_sigpipe/unix_sigpipe-non-root-main.stderr | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs | 2 +- tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs index d6d020c52b2..f5fa177f29c 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs @@ -1,4 +1,4 @@ #![feature(unix_sigpipe)] -#![unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute cannot be used at crate level +#![unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute cannot be used at crate level fn main() {} diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr index 1666f4a3ee8..fdfa3018086 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr @@ -1,7 +1,7 @@ error: `unix_sigpipe` attribute cannot be used at crate level --> $DIR/unix_sigpipe-crate.rs:2:1 | -LL | #![unix_sigpipe = "inherit"] +LL | #![unix_sigpipe = "sig_dfl"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | fn main() {} @@ -9,8 +9,8 @@ LL | fn main() {} | help: perhaps you meant to use an outer attribute | -LL - #![unix_sigpipe = "inherit"] -LL + #[unix_sigpipe = "inherit"] +LL - #![unix_sigpipe = "sig_dfl"] +LL + #[unix_sigpipe = "sig_dfl"] | error: aborting due to 1 previous error diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs index b5ebc07a043..462ae24a884 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs @@ -1,4 +1,4 @@ #![feature(unix_sigpipe)] -#[unix_sigpipe(inherit)] //~ error: malformed `unix_sigpipe` attribute input +#[unix_sigpipe(sig_dfl)] //~ error: malformed `unix_sigpipe` attribute input fn main() {} diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr index 17507243f7a..66902f3ca9a 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr @@ -1,7 +1,7 @@ error: malformed `unix_sigpipe` attribute input --> $DIR/unix_sigpipe-list.rs:3:1 | -LL | #[unix_sigpipe(inherit)] +LL | #[unix_sigpipe(sig_dfl)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[unix_sigpipe = "inherit|sig_ign|sig_dfl"]` error: aborting due to 1 previous error diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs index cde6719fc9c..16731a4ba2c 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs @@ -1,6 +1,6 @@ #![feature(unix_sigpipe)] -#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` fn f() {} fn main() {} diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr index 124141b6552..fcdd5db8f29 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr @@ -1,7 +1,7 @@ error: `unix_sigpipe` attribute can only be used on `fn main()` --> $DIR/unix_sigpipe-non-main-fn.rs:3:1 | -LL | #[unix_sigpipe = "inherit"] +LL | #[unix_sigpipe = "sig_dfl"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs index 16f7276398e..a2435258620 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs @@ -1,7 +1,7 @@ #![feature(unix_sigpipe)] mod m { - #[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on root `fn main()` + #[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on root `fn main()` fn main() {} } diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr index 346d83fa664..98afb62fdb4 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr @@ -1,7 +1,7 @@ error: `unix_sigpipe` attribute can only be used on root `fn main()` --> $DIR/unix_sigpipe-non-root-main.rs:4:5 | -LL | #[unix_sigpipe = "inherit"] +LL | #[unix_sigpipe = "sig_dfl"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs index 64fd5ec4f0e..945b820f9e0 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs @@ -2,5 +2,5 @@ #![feature(unix_sigpipe)] #[start] -#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` fn custom_start(argc: isize, argv: *const *const u8) -> isize { 0 } diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr index 9f691e396bd..3d56b3655c9 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr @@ -1,7 +1,7 @@ error: `unix_sigpipe` attribute can only be used on `fn main()` --> $DIR/unix_sigpipe-start.rs:5:1 | -LL | #[unix_sigpipe = "inherit"] +LL | #[unix_sigpipe = "sig_dfl"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs index a5e47cfebc8..662779c0821 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs @@ -1,6 +1,6 @@ #![feature(unix_sigpipe)] -#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` struct S; fn main() {} diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr index d5eec9424c8..a8fc51bdbc4 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr @@ -1,7 +1,7 @@ error: `unix_sigpipe` attribute can only be used on `fn main()` --> $DIR/unix_sigpipe-struct.rs:3:1 | -LL | #[unix_sigpipe = "inherit"] +LL | #[unix_sigpipe = "sig_dfl"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error From 816dc96b3dd6be166575b54f78623ef7cbd685dd Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 11 Mar 2024 09:27:00 +0200 Subject: [PATCH 27/35] bootstrap readme: fix, improve, update --- src/bootstrap/README.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index d0a069f45e1..077db44ae54 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -1,7 +1,7 @@ # rustbuild - Bootstrapping Rust -This README is aimed at helping to explain how Rust is bootstrapped and in general, -some of the technical details of the build system. +This README is aimed at helping to explain how Rust is bootstrapped, +and some of the technical details of the build system. Note that this README only covers internal information, not how to use the tool. Please check [bootstrapping dev guide][bootstrapping-dev-guide] for further information. @@ -10,12 +10,12 @@ Please check [bootstrapping dev guide][bootstrapping-dev-guide] for further info ## Introduction -The build system defers most of the complicated logic managing invocations +The build system defers most of the complicated logic of managing invocations of rustc and rustdoc to Cargo itself. However, moving through various stages and copying artifacts is still necessary for it to do. Each time rustbuild is invoked, it will iterate through the list of predefined steps and execute each serially in turn if it matches the paths passed or is a default rule. -For each step rustbuild relies on the step internally being incremental and +For each step, rustbuild relies on the step internally being incremental and parallel. Note, though, that the `-j` parameter to rustbuild gets forwarded to appropriate test harnesses and such. @@ -24,7 +24,7 @@ to appropriate test harnesses and such. The rustbuild build system goes through a few phases to actually build the compiler. What actually happens when you invoke rustbuild is: -1. The entry point script(`x` for unix like systems, `x.ps1` for windows systems, +1. The entry point script (`x` for unix like systems, `x.ps1` for windows systems, `x.py` cross-platform) is run. This script is responsible for downloading the stage0 compiler/Cargo binaries, and it then compiles the build system itself (this folder). Finally, it then invokes the actual `bootstrap` binary build system. @@ -107,12 +107,13 @@ build/ # Location where the stage0 Cargo and Rust compiler are unpacked. This # directory is purely an extracted and overlaid tarball of these two (done - # by the bootstrap python script). In theory, the build system does not + # by the bootstrap Python script). In theory, the build system does not # modify anything under this directory afterwards. stage0/ # These to-build directories are the cargo output directories for builds of - # the standard library and compiler, respectively. Internally, these may also + # the standard library, the test system, the compiler, and various tools, + # respectively. Internally, these may also # have other target directories, which represent artifacts being compiled # from the host to the specified target. # @@ -169,17 +170,17 @@ read by the other. Some general areas that you may be interested in modifying are: -* Adding a new build tool? Take a look at `bootstrap/tool.rs` for examples of - other tools. +* Adding a new build tool? Take a look at `bootstrap/src/core/build_steps/tool.rs` + for examples of other tools. * Adding a new compiler crate? Look no further! Adding crates can be done by - adding a new directory with `Cargo.toml` followed by configuring all + adding a new directory with `Cargo.toml`, followed by configuring all `Cargo.toml` files accordingly. * Adding a new dependency from crates.io? This should just work inside the compiler artifacts stage (everything other than libtest and libstd). -* Adding a new configuration option? You'll want to modify `bootstrap/flags.rs` - for command line flags and then `bootstrap/config.rs` to copy the flags to the +* Adding a new configuration option? You'll want to modify `bootstrap/src/core/config/flags.rs` + for command line flags and then `bootstrap/src/core/config/config.rs` to copy the flags to the `Config` struct. -* Adding a sanity check? Take a look at `bootstrap/sanity.rs`. +* Adding a sanity check? Take a look at `bootstrap/src/core/sanity.rs`. If you make a major change on bootstrap configuration, please remember to: From ed252e931e11759e163c2f63ff8054c12edf1899 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Thu, 26 Oct 2023 21:48:00 +0200 Subject: [PATCH 28/35] LLVM_TOOLS: Include llvm-link as a llvm tool --- src/bootstrap/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 938b95cc60e..6520b7ed089 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -64,6 +64,7 @@ const LLVM_TOOLS: &[&str] = &[ "llvm-ar", // used for creating and modifying archive files "llvm-as", // used to convert LLVM assembly to LLVM bitcode "llvm-dis", // used to disassemble LLVM bitcode + "llvm-link", // Used to link LLVM bitcode "llc", // used to compile LLVM bytecode "opt", // used to optimize LLVM bytecode ]; From 222ce4fdb8fb5fbff8047014c3ffb73df0ef2693 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 6 Feb 2024 19:15:38 +0100 Subject: [PATCH 29/35] LLVM Bitcode Linker: Added crate --- Cargo.lock | 11 ++ Cargo.toml | 1 + src/bootstrap/src/core/build_steps/tool.rs | 1 + src/bootstrap/src/core/builder.rs | 1 + src/tools/llvm-bitcode-linker/Cargo.toml | 14 ++ src/tools/llvm-bitcode-linker/README.md | 5 + .../src/bin/llvm-bitcode-linker.rs | 62 +++++++ src/tools/llvm-bitcode-linker/src/lib.rs | 7 + src/tools/llvm-bitcode-linker/src/linker.rs | 163 ++++++++++++++++++ src/tools/llvm-bitcode-linker/src/opt.rs | 53 ++++++ src/tools/llvm-bitcode-linker/src/target.rs | 20 +++ 11 files changed, 338 insertions(+) create mode 100644 src/tools/llvm-bitcode-linker/Cargo.toml create mode 100644 src/tools/llvm-bitcode-linker/README.md create mode 100644 src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs create mode 100644 src/tools/llvm-bitcode-linker/src/lib.rs create mode 100644 src/tools/llvm-bitcode-linker/src/linker.rs create mode 100644 src/tools/llvm-bitcode-linker/src/opt.rs create mode 100644 src/tools/llvm-bitcode-linker/src/target.rs diff --git a/Cargo.lock b/Cargo.lock index 3290741f128..53bd088b557 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2265,6 +2265,17 @@ checksum = "f9d642685b028806386b2b6e75685faadd3eb65a85fff7df711ce18446a422da" name = "lld-wrapper" version = "0.1.0" +[[package]] +name = "llvm-bitcode-linker" +version = "0.0.1" +dependencies = [ + "anyhow", + "clap", + "thiserror", + "tracing", + "tracing-subscriber", +] + [[package]] name = "lock_api" version = "0.4.11" diff --git a/Cargo.toml b/Cargo.toml index 5847a817e76..5dd315ef2f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ members = [ "src/tools/expand-yaml-anchors", "src/tools/jsondocck", "src/tools/jsondoclint", + "src/tools/llvm-bitcode-linker", "src/tools/html-checker", "src/tools/bump-stage0", "src/tools/replace-version-placeholder", diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 889876f461d..53dc1cff0ae 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -795,6 +795,7 @@ tool_extended!((self, builder), Rls, "src/tools/rls", "rls", stable=true, tool_std=true; RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true; Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"]; + LlvmBitcodeLinker, "src/tools/llvm-bitcode-linker", "llvm-bitcode-linker", stable=false, add_bins_to_sysroot = ["llvm-bitcode-linker"]; ); impl<'a> Builder<'a> { diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 4927c837608..5e5d6d024ee 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -763,6 +763,7 @@ impl<'a> Builder<'a> { tool::RustdocGUITest, tool::OptimizedDist, tool::CoverageDump, + tool::LlvmBitcodeLinker ), Kind::Check | Kind::Clippy | Kind::Fix => describe!( check::Std, diff --git a/src/tools/llvm-bitcode-linker/Cargo.toml b/src/tools/llvm-bitcode-linker/Cargo.toml new file mode 100644 index 00000000000..a9210b562f3 --- /dev/null +++ b/src/tools/llvm-bitcode-linker/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "llvm-bitcode-linker" +version = "0.0.1" +description = "A self-contained linker for llvm bitcode" +license = "MIT OR Apache-2.0" +edition = "2021" +publish = false + +[dependencies] +anyhow = "1.0" +tracing = "0.1" +tracing-subscriber = {version = "0.3.0", features = ["std"] } +clap = { version = "4.3", features = ["derive"] } +thiserror = "1.0.24" diff --git a/src/tools/llvm-bitcode-linker/README.md b/src/tools/llvm-bitcode-linker/README.md new file mode 100644 index 00000000000..9b8719e3a77 --- /dev/null +++ b/src/tools/llvm-bitcode-linker/README.md @@ -0,0 +1,5 @@ +# LLVM Bitcode Linker +The LLVM bitcode linker can be used to link targets without any dependency on system libraries. +The code will be linked in llvm-bc before compiling to native code. For some of these targets +(e.g. ptx) there does not exist a sensible way to link the native format at all. A bitcode linker +is required to link code compiled for such targets. diff --git a/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs b/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs new file mode 100644 index 00000000000..a92af71a36e --- /dev/null +++ b/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs @@ -0,0 +1,62 @@ +use std::path::PathBuf; + +use clap::Parser; + +use llvm_bitcode_linker::{Optimization, Session, Target}; + +#[derive(Debug, Parser)] +/// Linker for embedded code without any system dependencies +pub struct Args { + /// Input files - objects, archives and static libraries. + /// + /// An archive can be, but not required to be, a Rust rlib. + files: Vec, + + /// A symbol that should be exported + #[arg(long)] + export_symbol: Vec, + + /// Input files directory + #[arg(short = 'L')] + input_dir: Vec, + + /// Target triple for which the code is compiled + #[arg(long)] + target: Target, + + /// The target cpu + #[arg(long)] + target_cpu: Option, + + /// Write output to the filename + #[arg(short, long)] + output: PathBuf, + + // Enable link time optimization + #[arg(long)] + lto: bool, + + /// Emit debug information + #[arg(long)] + debug: bool, + + /// The optimization level + #[arg(short = 'O', value_enum, default_value = "0")] + optimization: Optimization, +} + +fn main() -> anyhow::Result<()> { + tracing_subscriber::FmtSubscriber::builder().with_max_level(tracing::Level::DEBUG).init(); + + let args = Args::parse(); + + let mut linker = Session::new(args.target, args.target_cpu, args.output); + + linker.add_exported_symbols(args.export_symbol); + + for rlib in args.files { + linker.add_file(rlib); + } + + linker.lto(args.optimization, args.debug) +} diff --git a/src/tools/llvm-bitcode-linker/src/lib.rs b/src/tools/llvm-bitcode-linker/src/lib.rs new file mode 100644 index 00000000000..48f918f631c --- /dev/null +++ b/src/tools/llvm-bitcode-linker/src/lib.rs @@ -0,0 +1,7 @@ +mod linker; +mod opt; +mod target; + +pub use linker::Session; +pub use opt::Optimization; +pub use target::Target; diff --git a/src/tools/llvm-bitcode-linker/src/linker.rs b/src/tools/llvm-bitcode-linker/src/linker.rs new file mode 100644 index 00000000000..aa6b6443e4d --- /dev/null +++ b/src/tools/llvm-bitcode-linker/src/linker.rs @@ -0,0 +1,163 @@ +use std::path::PathBuf; + +use anyhow::Context; + +use crate::Optimization; +use crate::Target; + +#[derive(Debug)] +pub struct Session { + target: Target, + cpu: Option, + symbols: Vec, + + /// A file that `llvm-link` supports, like a bitcode file or an archive. + files: Vec, + + // Output files + link_path: PathBuf, + opt_path: PathBuf, + sym_path: PathBuf, + out_path: PathBuf, +} + +impl Session { + pub fn new(target: crate::Target, cpu: Option, out_path: PathBuf) -> Self { + let link_path = out_path.with_extension("o"); + let opt_path = out_path.with_extension("optimized.o"); + let sym_path = out_path.with_extension("symbols.txt"); + + Session { + target, + cpu, + symbols: Vec::new(), + files: Vec::new(), + link_path, + opt_path, + sym_path, + out_path, + } + } + + /// Add a file, like an rlib or bitcode file that should be linked + pub fn add_file(&mut self, path: PathBuf) { + self.files.push(path); + } + + /// Add a Vec of symbols to the list of exported symbols + pub fn add_exported_symbols(&mut self, symbols: Vec) { + self.symbols.extend(symbols); + } + + /// Reads every file that was added to the session and link them without optimization. + /// + /// The resulting artifact will be written to a file that can later be read to perform + /// optimizations and/or compilation from bitcode to the final artifact. + fn link(&mut self) -> anyhow::Result<()> { + tracing::info!("Linking {} files using llvm-link", self.files.len()); + + let llvm_link_output = std::process::Command::new("llvm-link") + .arg("--ignore-non-bitcode") + .args(&self.files) + .arg("-o") + .arg(&self.link_path) + .output() + .unwrap(); + + if !llvm_link_output.status.success() { + tracing::error!( + "llvm-link returned with Exit status: {}\n stdout: {}\n stderr: {}", + llvm_link_output.status, + String::from_utf8(llvm_link_output.stdout).unwrap(), + String::from_utf8(llvm_link_output.stderr).unwrap(), + ); + anyhow::bail!("llvm-link failed to link files {:?}", self.files); + } + + Ok(()) + } + + /// Optimize and compile to native format using `opt` and `llc` + /// + /// Before this can be called `link` needs to be called + fn optimize(&mut self, optimization: Optimization, mut debug: bool) -> anyhow::Result<()> { + let mut passes = format!("default<{}>", optimization); + + // FIXME(@kjetilkjeka) Debug symbol generation is broken for nvptx64 so we must remove them even in debug mode + if debug && self.target == crate::Target::Nvptx64NvidiaCuda { + tracing::warn!("nvptx64 target detected - stripping debug symbols"); + debug = false; + } + + // We add an internalize pass as the rust compiler as we require exported symbols to be explicitly marked + passes.push_str(",internalize,globaldce"); + let symbol_file_content = self.symbols.iter().fold(String::new(), |s, x| s + &x + "\n"); + std::fs::write(&self.sym_path, symbol_file_content) + .context(format!("Failed to write symbol file: {}", self.sym_path.display()))?; + + tracing::info!("optimizing bitcode with passes: {}", passes); + let mut opt_cmd = std::process::Command::new("opt"); + opt_cmd + .arg(&self.link_path) + .arg("-o") + .arg(&self.opt_path) + .arg(format!("--internalize-public-api-file={}", self.sym_path.display())) + .arg(format!("--passes={}", passes)); + + if !debug { + opt_cmd.arg("--strip-debug"); + } + + let opt_output = opt_cmd.output().unwrap(); + + if !opt_output.status.success() { + tracing::error!( + "opt returned with Exit status: {}\n stdout: {}\n stderr: {}", + opt_output.status, + String::from_utf8(opt_output.stdout).unwrap(), + String::from_utf8(opt_output.stderr).unwrap(), + ); + anyhow::bail!("opt failed optimize bitcode: {}", self.link_path.display()); + }; + + Ok(()) + } + + /// Compile the optimized bitcode file to native format using `llc` + /// + /// Before this can be called `optimize` needs to be called + fn compile(&mut self) -> anyhow::Result<()> { + let mut lcc_command = std::process::Command::new("llc"); + + if let Some(mcpu) = &self.cpu { + lcc_command.arg("--mcpu").arg(mcpu); + } + + let lcc_output = + lcc_command.arg(&self.opt_path).arg("-o").arg(&self.out_path).output().unwrap(); + + if !lcc_output.status.success() { + tracing::error!( + "llc returned with Exit status: {}\n stdout: {}\n stderr: {}", + lcc_output.status, + String::from_utf8(lcc_output.stdout).unwrap(), + String::from_utf8(lcc_output.stderr).unwrap(), + ); + + anyhow::bail!( + "llc failed to compile {} into {}", + self.opt_path.display(), + self.out_path.display() + ); + } + + Ok(()) + } + + /// Links, optimizes and compiles to the native format + pub fn lto(&mut self, optimization: crate::Optimization, debug: bool) -> anyhow::Result<()> { + self.link()?; + self.optimize(optimization, debug)?; + self.compile() + } +} diff --git a/src/tools/llvm-bitcode-linker/src/opt.rs b/src/tools/llvm-bitcode-linker/src/opt.rs new file mode 100644 index 00000000000..93f0ec7e2d6 --- /dev/null +++ b/src/tools/llvm-bitcode-linker/src/opt.rs @@ -0,0 +1,53 @@ +use std::fmt::Display; +use std::fmt::Formatter; + +#[derive(Debug, Clone, Copy, Default, Hash, Eq, PartialEq, clap::ValueEnum)] +pub enum Optimization { + #[default] + #[value(name = "0")] + O0, + #[value(name = "1")] + O1, + #[value(name = "2")] + O2, + #[value(name = "3")] + O3, + #[value(name = "s")] + Os, + #[value(name = "z")] + Oz, +} + +#[derive(Debug, Clone, Copy, thiserror::Error)] +/// An invalid optimization level +#[error("invalid optimization level")] +pub struct InvalidOptimizationLevel; + +impl std::str::FromStr for Optimization { + type Err = InvalidOptimizationLevel; + + fn from_str(s: &str) -> Result { + match s { + "0" | "O0" => Ok(Optimization::O0), + "1" | "O1" => Ok(Optimization::O1), + "2" | "O2" => Ok(Optimization::O2), + "3" | "O3" => Ok(Optimization::O3), + "s" | "Os" => Ok(Optimization::Os), + "z" | "Oz" => Ok(Optimization::Oz), + _ => Err(InvalidOptimizationLevel), + } + } +} + +impl Display for Optimization { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match *self { + Optimization::O0 => write!(f, "O0"), + Optimization::O1 => write!(f, "O1"), + Optimization::O2 => write!(f, "O2"), + Optimization::O3 => write!(f, "O3"), + Optimization::Os => write!(f, "Os"), + Optimization::Oz => write!(f, "Oz"), + } + } +} diff --git a/src/tools/llvm-bitcode-linker/src/target.rs b/src/tools/llvm-bitcode-linker/src/target.rs new file mode 100644 index 00000000000..d9f8ff3852b --- /dev/null +++ b/src/tools/llvm-bitcode-linker/src/target.rs @@ -0,0 +1,20 @@ +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, clap::ValueEnum)] +pub enum Target { + Nvptx64NvidiaCuda, +} + +#[derive(Debug, Clone, Copy, thiserror::Error)] +/// The target is not supported by this linker +#[error("unsupported target")] +pub struct UnsupportedTarget; + +impl std::str::FromStr for Target { + type Err = UnsupportedTarget; + + fn from_str(s: &str) -> Result { + match s { + "nvptx64-nvidia-cuda" => Ok(Target::Nvptx64NvidiaCuda), + _ => Err(UnsupportedTarget), + } + } +} From af42d2a4b286acfdaf98da2ad6fcb46978463c84 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Fri, 1 Dec 2023 16:39:09 +0100 Subject: [PATCH 30/35] NVPTX: Enable self-contained for the nvptx target --- compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index 33b79a13359..47d6ef0c622 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -1,3 +1,4 @@ +use crate::spec::LinkSelfContainedDefault; use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions}; pub fn target() -> Target { @@ -47,6 +48,9 @@ pub fn target() -> Target { // The LLVM backend does not support stack canaries for this target supports_stack_protector: false, + // Support using `self-contained` linkers like the llvm-bitcode-linker + link_self_contained: LinkSelfContainedDefault::True, + ..Default::default() }, } From 43f2055af5a0897876f25b6bdfa821dea8d5e4aa Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 6 Feb 2024 19:46:12 +0100 Subject: [PATCH 31/35] LLVM Bitcode Linker: Add as a linker known to the compiler --- compiler/rustc_codegen_ssa/src/back/link.rs | 23 +++- compiler/rustc_codegen_ssa/src/back/linker.rs | 101 +++++++++++++++++- compiler/rustc_target/src/spec/mod.rs | 22 +++- .../rustc_target/src/spec/tests/tests_impl.rs | 5 +- 4 files changed, 142 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index fcb3602b734..e70cc9b6216 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -24,6 +24,7 @@ use rustc_span::symbol::Symbol; use rustc_target::spec::crt_objects::CrtObjects; use rustc_target::spec::LinkSelfContainedComponents; use rustc_target::spec::LinkSelfContainedDefault; +use rustc_target::spec::LinkerFlavorCli; use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld, PanicStrategy}; use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo}; @@ -1350,6 +1351,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } } LinkerFlavor::Bpf => "bpf-linker", + LinkerFlavor::Llbc => "llvm-bitcode-linker", LinkerFlavor::Ptx => "rust-ptx-linker", }), flavor, @@ -1367,8 +1369,17 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { // linker and linker flavor specified via command line have precedence over what the target // specification specifies - let linker_flavor = - sess.opts.cg.linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor)); + let linker_flavor = match sess.opts.cg.linker_flavor { + // The linker flavors that are non-target specific can be directly translated to LinkerFlavor + Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc), + Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx), + // The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor + _ => sess + .opts + .cg + .linker_flavor + .map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor)), + }; if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), linker_flavor) { return ret; } @@ -2338,8 +2349,12 @@ fn add_order_independent_options( }); } - if flavor == LinkerFlavor::Ptx { - // Provide the linker with fallback to internal `target-cpu`. + if flavor == LinkerFlavor::Llbc { + cmd.arg("--target"); + cmd.arg(sess.target.llvm_target.as_ref()); + cmd.arg("--target-cpu"); + cmd.arg(&codegen_results.crate_info.target_cpu); + } else if flavor == LinkerFlavor::Ptx { cmd.arg("--fallback-arch"); cmd.arg(&codegen_results.crate_info.target_cpu); } else if flavor == LinkerFlavor::Bpf { diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index e52efd86955..b4e054417f3 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -153,6 +153,7 @@ pub fn get_linker<'a>( LinkerFlavor::Msvc(..) => Box::new(MsvcLinker { cmd, sess }) as Box, LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box, LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box, + LinkerFlavor::Llbc => Box::new(LlbcLinker { cmd, sess }) as Box, LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box, } } @@ -1824,7 +1825,7 @@ impl<'a> Linker for PtxLinker<'a> { } Lto::No => {} - }; + } } fn output_filename(&mut self, path: &Path) { @@ -1862,6 +1863,104 @@ impl<'a> Linker for PtxLinker<'a> { fn linker_plugin_lto(&mut self) {} } +/// The `self-contained` LLVM bitcode linker +pub struct LlbcLinker<'a> { + cmd: Command, + sess: &'a Session, +} + +impl<'a> Linker for LlbcLinker<'a> { + fn cmd(&mut self) -> &mut Command { + &mut self.cmd + } + + fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {} + + fn link_dylib_by_name(&mut self, _name: &str, _verbatim: bool, _as_needed: bool) { + panic!("external dylibs not supported") + } + + fn link_staticlib_by_name( + &mut self, + _name: &str, + _verbatim: bool, + _whole_archive: bool, + _search_paths: &SearchPaths, + ) { + panic!("staticlibs not supported") + } + + fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) { + self.cmd.arg(path); + } + + fn include_path(&mut self, path: &Path) { + self.cmd.arg("-L").arg(path); + } + + fn debuginfo(&mut self, _strip: Strip, _: &[PathBuf]) { + self.cmd.arg("--debug"); + } + + fn add_object(&mut self, path: &Path) { + self.cmd.arg(path); + } + + fn optimize(&mut self) { + match self.sess.opts.optimize { + OptLevel::No => "-O0", + OptLevel::Less => "-O1", + OptLevel::Default => "-O2", + OptLevel::Aggressive => "-O3", + OptLevel::Size => "-Os", + OptLevel::SizeMin => "-Oz", + }; + } + + fn output_filename(&mut self, path: &Path) { + self.cmd.arg("-o").arg(path); + } + + fn framework_path(&mut self, _path: &Path) { + panic!("frameworks not supported") + } + + fn full_relro(&mut self) {} + + fn partial_relro(&mut self) {} + + fn no_relro(&mut self) {} + + fn gc_sections(&mut self, _keep_metadata: bool) {} + + fn no_gc_sections(&mut self) {} + + fn pgo_gen(&mut self) {} + + fn no_crt_objects(&mut self) {} + + fn no_default_libraries(&mut self) {} + + fn control_flow_guard(&mut self) {} + + fn ehcont_guard(&mut self) {} + + fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) { + match _crate_type { + CrateType::Cdylib => { + for sym in symbols { + self.cmd.arg("--export-symbol").arg(sym); + } + } + _ => (), + } + } + + fn subsystem(&mut self, _subsystem: &str) {} + + fn linker_plugin_lto(&mut self) {} +} + pub struct BpfLinker<'a> { cmd: Command, sess: &'a Session, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 3b6e15fad46..7d2a6d3d861 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -123,6 +123,8 @@ pub enum LinkerFlavor { Bpf, /// Linker tool for Nvidia PTX. Ptx, + /// LLVM bitcode linker that can be used as a `self-contained` linker + Llbc, } /// Linker flavors available externally through command line (`-Clinker-flavor`) @@ -141,6 +143,7 @@ pub enum LinkerFlavorCli { EmCc, Bpf, Ptx, + Llbc, // Legacy stable values Gcc, @@ -160,6 +163,7 @@ impl LinkerFlavorCli { | LinkerFlavorCli::Msvc(Lld::Yes) | LinkerFlavorCli::EmCc | LinkerFlavorCli::Bpf + | LinkerFlavorCli::Llbc | LinkerFlavorCli::Ptx => true, LinkerFlavorCli::Gcc | LinkerFlavorCli::Ld @@ -219,6 +223,7 @@ impl LinkerFlavor { LinkerFlavorCli::Msvc(lld) => LinkerFlavor::Msvc(lld), LinkerFlavorCli::EmCc => LinkerFlavor::EmCc, LinkerFlavorCli::Bpf => LinkerFlavor::Bpf, + LinkerFlavorCli::Llbc => LinkerFlavor::Llbc, LinkerFlavorCli::Ptx => LinkerFlavor::Ptx, // Below: legacy stable values @@ -258,6 +263,7 @@ impl LinkerFlavor { LinkerFlavor::Msvc(..) => LinkerFlavorCli::Msvc(Lld::No), LinkerFlavor::EmCc => LinkerFlavorCli::Em, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, + LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -272,6 +278,7 @@ impl LinkerFlavor { LinkerFlavor::Msvc(lld) => LinkerFlavorCli::Msvc(lld), LinkerFlavor::EmCc => LinkerFlavorCli::EmCc, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, + LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -286,6 +293,7 @@ impl LinkerFlavor { LinkerFlavorCli::Msvc(lld) => (Some(Cc::No), Some(lld)), LinkerFlavorCli::EmCc => (Some(Cc::Yes), Some(Lld::Yes)), LinkerFlavorCli::Bpf | LinkerFlavorCli::Ptx => (None, None), + LinkerFlavorCli::Llbc => (None, None), // Below: legacy stable values LinkerFlavorCli::Gcc => (Some(Cc::Yes), None), @@ -340,7 +348,7 @@ impl LinkerFlavor { LinkerFlavor::WasmLld(cc) => LinkerFlavor::WasmLld(cc_hint.unwrap_or(cc)), LinkerFlavor::Unix(cc) => LinkerFlavor::Unix(cc_hint.unwrap_or(cc)), LinkerFlavor::Msvc(lld) => LinkerFlavor::Msvc(lld_hint.unwrap_or(lld)), - LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => self, + LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc | LinkerFlavor::Ptx => self, } } @@ -355,8 +363,8 @@ impl LinkerFlavor { pub fn check_compatibility(self, cli: LinkerFlavorCli) -> Option { let compatible = |cli| { // The CLI flavor should be compatible with the target if: - // 1. they are counterparts: they have the same principal flavor. match (self, cli) { + // 1. they are counterparts: they have the same principal flavor. (LinkerFlavor::Gnu(..), LinkerFlavorCli::Gnu(..)) | (LinkerFlavor::Darwin(..), LinkerFlavorCli::Darwin(..)) | (LinkerFlavor::WasmLld(..), LinkerFlavorCli::WasmLld(..)) @@ -364,11 +372,14 @@ impl LinkerFlavor { | (LinkerFlavor::Msvc(..), LinkerFlavorCli::Msvc(..)) | (LinkerFlavor::EmCc, LinkerFlavorCli::EmCc) | (LinkerFlavor::Bpf, LinkerFlavorCli::Bpf) + | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) | (LinkerFlavor::Ptx, LinkerFlavorCli::Ptx) => return true, + // 2. The linker flavor is independent of target and compatible + (LinkerFlavor::Ptx, LinkerFlavorCli::Llbc) => return true, _ => {} } - // 2. or, the flavor is legacy and survives this roundtrip. + // 3. or, the flavor is legacy and survives this roundtrip. cli == self.with_cli_hints(cli).to_cli() }; (!compatible(cli)).then(|| { @@ -387,6 +398,7 @@ impl LinkerFlavor { | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf + | LinkerFlavor::Llbc | LinkerFlavor::Ptx => LldFlavor::Ld, LinkerFlavor::Darwin(..) => LldFlavor::Ld64, LinkerFlavor::WasmLld(..) => LldFlavor::Wasm, @@ -412,6 +424,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf + | LinkerFlavor::Llbc | LinkerFlavor::Ptx => false, } } @@ -431,6 +444,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf + | LinkerFlavor::Llbc | LinkerFlavor::Ptx => false, } } @@ -480,6 +494,7 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::Msvc(Lld::No)) "msvc" (LinkerFlavorCli::EmCc) "em-cc" (LinkerFlavorCli::Bpf) "bpf" + (LinkerFlavorCli::Llbc) "llbc" (LinkerFlavorCli::Ptx) "ptx" // Legacy stable flavors @@ -2205,6 +2220,7 @@ fn add_link_args_iter( | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf + | LinkerFlavor::Llbc | LinkerFlavor::Ptx => {} } } diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs index 3fefd60f7cd..3be18ef3127 100644 --- a/compiler/rustc_target/src/spec/tests/tests_impl.rs +++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs @@ -56,7 +56,10 @@ impl Target { LinkerFlavor::Msvc(..) => { assert_matches!(flavor, LinkerFlavor::Msvc(..)) } - LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => { + LinkerFlavor::EmCc + | LinkerFlavor::Bpf + | LinkerFlavor::Ptx + | LinkerFlavor::Llbc => { assert_eq!(flavor, self.linker_flavor) } } From 6a50d059a594f35d70af30a33a4b395616663f68 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 6 Feb 2024 20:09:55 +0100 Subject: [PATCH 32/35] Bootstrap: Add argument for building llvm bitcode linker --- config.example.toml | 4 ++++ src/bootstrap/configure.py | 2 ++ src/bootstrap/defaults/config.compiler.toml | 2 ++ src/bootstrap/defaults/config.dist.toml | 2 ++ src/bootstrap/defaults/config.library.toml | 2 ++ src/bootstrap/defaults/config.tools.toml | 2 ++ src/bootstrap/src/core/build_steps/compile.rs | 10 ++++++++++ src/bootstrap/src/core/config/config.rs | 4 ++++ src/bootstrap/src/utils/change_tracker.rs | 5 +++++ src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 2 +- 10 files changed, 34 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 4fbdccba911..ddcd0ec02e0 100644 --- a/config.example.toml +++ b/config.example.toml @@ -679,6 +679,10 @@ # sysroot. #llvm-tools = true +# Indicates whether the `self-contained` llvm-bitcode-linker, will be made available +# in the sysroot +#llvm-bitcode-linker = false + # Whether to deny warnings in crates #deny-warnings = true diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 4257c0f7991..9c43160d455 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -54,6 +54,7 @@ o("cargo-native-static", "build.cargo-native-static", "static native libraries i o("profiler", "build.profiler", "build the profiler runtime") o("full-tools", None, "enable all tools") o("lld", "rust.lld", "build lld") +o("llvm-bitcode-linker", "rust.llvm-bitcode-linker", "build llvm bitcode linker") o("clang", "llvm.clang", "build clang") o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++") o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard") @@ -366,6 +367,7 @@ def apply_args(known_args, option_checking, config): set('rust.codegen-backends', ['llvm'], config) set('rust.lld', True, config) set('rust.llvm-tools', True, config) + set('rust.llvm-bitcode-linker', True, config) set('build.extended', True, config) elif option.name in ['option-checking', 'verbose-configure']: # this was handled above diff --git a/src/bootstrap/defaults/config.compiler.toml b/src/bootstrap/defaults/config.compiler.toml index e276f126211..d93c5fd25a1 100644 --- a/src/bootstrap/defaults/config.compiler.toml +++ b/src/bootstrap/defaults/config.compiler.toml @@ -17,6 +17,8 @@ lto = "off" # Forces frame pointers to be used with `-Cforce-frame-pointers`. # This can be helpful for profiling at a small performance cost. frame-pointers = true +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [llvm] # Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true` diff --git a/src/bootstrap/defaults/config.dist.toml b/src/bootstrap/defaults/config.dist.toml index 44efdf50b96..f3c6ffc9bd5 100644 --- a/src/bootstrap/defaults/config.dist.toml +++ b/src/bootstrap/defaults/config.dist.toml @@ -16,6 +16,8 @@ download-ci-llvm = false # Make sure they don't get set when installing from source. channel = "nightly" download-rustc = false +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [dist] # Use better compression when preparing tarballs. diff --git a/src/bootstrap/defaults/config.library.toml b/src/bootstrap/defaults/config.library.toml index 087544397f5..4a1a49b7275 100644 --- a/src/bootstrap/defaults/config.library.toml +++ b/src/bootstrap/defaults/config.library.toml @@ -10,6 +10,8 @@ bench-stage = 0 incremental = true # Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown. lto = "off" +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [llvm] # Will download LLVM from CI if available on your platform. diff --git a/src/bootstrap/defaults/config.tools.toml b/src/bootstrap/defaults/config.tools.toml index 6e6c3660027..94c8b724cbf 100644 --- a/src/bootstrap/defaults/config.tools.toml +++ b/src/bootstrap/defaults/config.tools.toml @@ -12,6 +12,8 @@ incremental = true # Using these defaults will download the stage2 compiler (see `download-rustc` # setting) and the stage2 toolchain should therefore be used for these defaults. download-rustc = "if-unchanged" +# Build the llvm-bitcode-linker as it is required for running nvptx tests +llvm-bitcode-linker = true [build] # Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile. diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6a2bff5970f..242fe3c12b9 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1843,6 +1843,16 @@ impl Step for Assemble { } } + if builder.config.llvm_bitcode_linker_enabled { + let src_path = builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker { + compiler: build_compiler, + target: target_compiler.host, + extra_features: vec![], + }); + let tool_exe = exe("llvm-bitcode-linker", target_compiler.host); + builder.copy(&src_path, &libdir_bin.join(&tool_exe)); + } + // Ensure that `libLLVM.so` ends up in the newly build compiler directory, // so that it can be found when the newly built `rustc` is run. dist::maybe_install_llvm_runtime(builder, target_compiler.host, &sysroot); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 683e0a4302f..ae5169e9383 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -236,6 +236,7 @@ pub struct Config { pub lld_mode: LldMode, pub lld_enabled: bool, pub llvm_tools_enabled: bool, + pub llvm_bitcode_linker_enabled: bool, pub llvm_cflags: Option, pub llvm_cxxflags: Option, @@ -1099,6 +1100,7 @@ define_config! { dist_src: Option = "dist-src", save_toolstates: Option = "save-toolstates", codegen_backends: Option> = "codegen-backends", + llvm_bitcode_linker: Option = "llvm-bitcode-linker", lld: Option = "lld", lld_mode: Option = "use-lld", llvm_tools: Option = "llvm-tools", @@ -1571,6 +1573,7 @@ impl Config { codegen_backends, lld, llvm_tools, + llvm_bitcode_linker, deny_warnings, backtrace_on_ice, verify_llvm_ir, @@ -1650,6 +1653,7 @@ impl Config { } set(&mut config.lld_mode, lld_mode); set(&mut config.lld_enabled, lld); + set(&mut config.llvm_bitcode_linker_enabled, llvm_bitcode_linker); if matches!(config.lld_mode, LldMode::SelfContained) && !config.lld_enabled diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index a348fa35841..85dfe45111f 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -146,4 +146,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "a new `target.*.runner` option is available to specify a wrapper executable required to run tests for a target", }, + ChangeInfo { + change_id: 117458, + severity: ChangeSeverity::Info, + summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.", + }, ]; diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index e90141bb9a9..abd109a6ea3 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -135,7 +135,7 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi # Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm -ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \ +ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \ --set target.wasm32-wasi.wasi-root=/wasm32-wasip1 \ --set target.wasm32-wasip1.wasi-root=/wasm32-wasip1 \ --set target.wasm32-wasi-preview1-threads.wasi-root=/wasm32-wasi-preview1-threads \ From 843dd28d21d410d540515cf44172ad74ab5976c9 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 4 Mar 2024 19:22:05 +0100 Subject: [PATCH 33/35] NVPTX: Enable previously disabled tests --- tests/assembly/nvptx-arch-default.rs | 3 +-- tests/assembly/nvptx-arch-emit-asm.rs | 1 - tests/assembly/nvptx-arch-target-cpu.rs | 3 +-- .../nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs | 13 ++++++------- tests/assembly/nvptx-safe-naming.rs | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/assembly/nvptx-arch-default.rs b/tests/assembly/nvptx-arch-default.rs index bac09574f17..a621fd6dcb2 100644 --- a/tests/assembly/nvptx-arch-default.rs +++ b/tests/assembly/nvptx-arch-default.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib +//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-arch-emit-asm.rs b/tests/assembly/nvptx-arch-emit-asm.rs index d24035cc831..e47f8e78e36 100644 --- a/tests/assembly/nvptx-arch-emit-asm.rs +++ b/tests/assembly/nvptx-arch-emit-asm.rs @@ -1,7 +1,6 @@ //@ assembly-output: emit-asm //@ compile-flags: --crate-type rlib //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-arch-target-cpu.rs b/tests/assembly/nvptx-arch-target-cpu.rs index 212af20f4de..609ab297e63 100644 --- a/tests/assembly/nvptx-arch-target-cpu.rs +++ b/tests/assembly/nvptx-arch-target-cpu.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index a42d5dd3569..ce1d732f367 100644 --- a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 // The following ABI tests are made with nvcc 11.6 does. // @@ -226,10 +225,11 @@ pub unsafe extern "ptx-kernel" fn f_byte_array_arg(_a: [u8; 5]) {} #[no_mangle] pub unsafe extern "ptx-kernel" fn f_float_array_arg(_a: [f32; 5]) {} -// CHECK: .visible .entry f_u128_array_arg( -// CHECK: .param .align 16 .b8 f_u128_array_arg_param_0[80] -#[no_mangle] -pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {} +// FIXME: u128 started to break compilation with disabled CI +// NO_CHECK: .visible .entry f_u128_array_arg( +// NO_CHECK: .param .align 16 .b8 f_u128_array_arg_param_0[80] +//#[no_mangle] +//pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {} // CHECK: .visible .entry f_u32_slice_arg( // CHECK: .param .u64 f_u32_slice_arg_param_0 @@ -247,7 +247,6 @@ pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_arg(_a: (u8, u8)) {} #[no_mangle] pub unsafe extern "ptx-kernel" fn f_tuple_u32_u32_arg(_a: (u32, u32)) {} - // CHECK: .visible .entry f_tuple_u8_u8_u32_arg( // CHECK: .param .align 4 .b8 f_tuple_u8_u8_u32_arg_param_0[8] #[no_mangle] diff --git a/tests/assembly/nvptx-safe-naming.rs b/tests/assembly/nvptx-safe-naming.rs index 59fd527be3c..d7b46aadd9c 100644 --- a/tests/assembly/nvptx-safe-naming.rs +++ b/tests/assembly/nvptx-safe-naming.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib +//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![feature(abi_ptx)] #![no_std] @@ -10,7 +9,7 @@ extern crate breakpoint_panic_handler; // Verify function name doesn't contain unacceaptable characters. -// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]]( +// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]] // CHECK-LABEL: .visible .entry top_kernel( #[no_mangle] From 279465b5e884da308a8d0b866cade7bdbfb9f19f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 2 Mar 2024 10:54:37 +0100 Subject: [PATCH 34/35] const-checking: add some corner case tests, and fix some nits --- .../src/const_eval/eval_queries.rs | 8 +++---- .../src/transform/check_consts/check.rs | 2 +- tests/ui/consts/enclosing-scope-rule.rs | 16 +++++++++++++ tests/ui/consts/refs-to-cell-in-final.rs | 23 +++++++++++++++++++ tests/ui/consts/refs-to-cell-in-final.stderr | 8 ++++++- 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 tests/ui/consts/enclosing-scope-rule.rs diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 9e4e7911c3a..c18b5b795d4 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -412,10 +412,10 @@ pub fn const_validate_mplace<'mir, 'tcx>( _ if cid.promoted.is_some() => CtfeValidationMode::Promoted, Some(mutbl) => CtfeValidationMode::Static { mutbl }, // a `static` None => { - // In normal `const` (not promoted), the outermost allocation is always only copied, - // so having `UnsafeCell` in there is okay despite them being in immutable memory. - let allow_immutable_unsafe_cell = cid.promoted.is_none() && !inner; - CtfeValidationMode::Const { allow_immutable_unsafe_cell } + // This is a normal `const` (not promoted). + // The outermost allocation is always only copied, so having `UnsafeCell` in there + // is okay despite them being in immutable memory. + CtfeValidationMode::Const { allow_immutable_unsafe_cell: !inner } } }; ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode)?; diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index c98dc4deb75..7e8e38a9653 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -30,7 +30,7 @@ type QualifResults<'mir, 'tcx, Q> = rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>; #[derive(Default)] -pub struct Qualifs<'mir, 'tcx> { +pub(crate) struct Qualifs<'mir, 'tcx> { has_mut_interior: Option>, needs_drop: Option>, needs_non_const_drop: Option>, diff --git a/tests/ui/consts/enclosing-scope-rule.rs b/tests/ui/consts/enclosing-scope-rule.rs new file mode 100644 index 00000000000..7041ad9af34 --- /dev/null +++ b/tests/ui/consts/enclosing-scope-rule.rs @@ -0,0 +1,16 @@ +//@build-pass +// Some code that looks like it might be relying on promotion, but actually this is using the +// enclosing-scope rule, meaning the reference is "extended" to outlive its block and live as long +// as the surrounding block (which in this case is the entire program). There are multiple +// allocations being interned at once. + +struct Gen(T); +impl<'a, T> Gen<&'a T> { + // Can't be promoted because `T` might not be `'static`. + const C: &'a [T] = &[]; +} + +// Can't be promoted because of `Drop`. +const V: &Vec = &Vec::new(); + +fn main() {} diff --git a/tests/ui/consts/refs-to-cell-in-final.rs b/tests/ui/consts/refs-to-cell-in-final.rs index 6a849ff0df9..ada56a82a5d 100644 --- a/tests/ui/consts/refs-to-cell-in-final.rs +++ b/tests/ui/consts/refs-to-cell-in-final.rs @@ -15,4 +15,27 @@ static RAW_SYNC_S: SyncPtr> = SyncPtr { x: &Cell::new(42) }; const RAW_SYNC_C: SyncPtr> = SyncPtr { x: &Cell::new(42) }; //~^ ERROR: cannot refer to interior mutable data +// This one does not get promoted because of `Drop`, and then enters interesting codepaths because +// as a value it has no interior mutability, but as a type it does. See +// . Value-based reasoning for interior mutability +// is questionable (https://github.com/rust-lang/unsafe-code-guidelines/issues/493) so for now we +// reject this, though not with a great error message. +pub enum JsValue { + Undefined, + Object(Cell), +} +impl Drop for JsValue { + fn drop(&mut self) {} +} +const UNDEFINED: &JsValue = &JsValue::Undefined; +//~^ERROR: mutable pointer in final value of constant + +// In contrast, this one works since it is being promoted. +const NONE: &'static Option> = &None; +// Making it clear that this is promotion, not "outer scope". +const NONE_EXPLICIT_PROMOTED: &'static Option> = { + let x = &None; + x +}; + fn main() {} diff --git a/tests/ui/consts/refs-to-cell-in-final.stderr b/tests/ui/consts/refs-to-cell-in-final.stderr index fae16fa0125..b06db3e116c 100644 --- a/tests/ui/consts/refs-to-cell-in-final.stderr +++ b/tests/ui/consts/refs-to-cell-in-final.stderr @@ -12,6 +12,12 @@ error[E0492]: constants cannot refer to interior mutable data LL | const RAW_SYNC_C: SyncPtr> = SyncPtr { x: &Cell::new(42) }; | ^^^^^^^^^^^^^^ this borrow of an interior mutable value may end up in the final value -error: aborting due to 2 previous errors +error: encountered mutable pointer in final value of constant + --> $DIR/refs-to-cell-in-final.rs:30:1 + | +LL | const UNDEFINED: &JsValue = &JsValue::Undefined; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0492`. From fb802f2e6ed7ef10cc429022aca06e85c25159dd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 11 Mar 2024 14:15:46 +0100 Subject: [PATCH 35/35] promote-not: add test that distinguishes promotion from outer scope rule --- tests/ui/consts/promote-not.rs | 12 ++++++- tests/ui/consts/promote-not.stderr | 52 ++++++++++++++++++------------ 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/tests/ui/consts/promote-not.rs b/tests/ui/consts/promote-not.rs index e0f02354354..9b16f32532a 100644 --- a/tests/ui/consts/promote-not.rs +++ b/tests/ui/consts/promote-not.rs @@ -40,7 +40,16 @@ const TEST_INTERIOR_MUT: () = { let _val: &'static _ = &(Cell::new(1), 2).1; //~ ERROR temporary value dropped while borrowed }; -const TEST_DROP: String = String::new(); +// This gets accepted by the "outer scope" rule, not promotion. +const TEST_DROP_OUTER_SCOPE: &String = &String::new(); +// To demonstrate that, we can rewrite it as follows. If this was promotion it would still work. +const TEST_DROP_NOT_PROMOTE: &String = { + let x = &String::new(); //~ ERROR destructor of `String` cannot be evaluated at compile-time + // The "dropped while borrowed" error seems to be suppressed, but the key point is that this + // fails to compile. + x +}; + fn main() { // We must not promote things with interior mutability. Not even if we "project it away". @@ -59,6 +68,7 @@ fn main() { let _val: &'static _ = &([1,2,3][4]+1); //~ ERROR temporary value dropped while borrowed // No promotion of temporaries that need to be dropped. + const TEST_DROP: String = String::new(); let _val: &'static _ = &TEST_DROP; //~^ ERROR temporary value dropped while borrowed let _val: &'static _ = &&TEST_DROP; diff --git a/tests/ui/consts/promote-not.stderr b/tests/ui/consts/promote-not.stderr index 9dbd703d489..07d4a135ed4 100644 --- a/tests/ui/consts/promote-not.stderr +++ b/tests/ui/consts/promote-not.stderr @@ -38,6 +38,15 @@ LL | let _val: &'static _ = &(Cell::new(1), 2).1; LL | }; | - temporary value is freed at the end of this statement +error[E0493]: destructor of `String` cannot be evaluated at compile-time + --> $DIR/promote-not.rs:47:14 + | +LL | let x = &String::new(); + | ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants +... +LL | }; + | - value is dropped here + error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:21:32 | @@ -59,7 +68,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:47:29 + --> $DIR/promote-not.rs:56:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).0; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -70,7 +79,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:48:29 + --> $DIR/promote-not.rs:57:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -81,7 +90,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:51:29 + --> $DIR/promote-not.rs:60:29 | LL | let _val: &'static _ = &(1/0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -92,7 +101,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:52:29 + --> $DIR/promote-not.rs:61:29 | LL | let _val: &'static _ = &(1/(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -103,7 +112,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:53:29 + --> $DIR/promote-not.rs:62:29 | LL | let _val: &'static _ = &((1+1)/(1-1)); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -114,7 +123,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:54:29 + --> $DIR/promote-not.rs:63:29 | LL | let _val: &'static _ = &(i32::MIN/-1); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -125,7 +134,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:55:29 + --> $DIR/promote-not.rs:64:29 | LL | let _val: &'static _ = &(i32::MIN/(0-1)); | ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -136,7 +145,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:56:29 + --> $DIR/promote-not.rs:65:29 | LL | let _val: &'static _ = &(-128i8/-1); | ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -147,7 +156,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:57:29 + --> $DIR/promote-not.rs:66:29 | LL | let _val: &'static _ = &(1%0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -158,7 +167,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:58:29 + --> $DIR/promote-not.rs:67:29 | LL | let _val: &'static _ = &(1%(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -169,7 +178,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:59:29 + --> $DIR/promote-not.rs:68:29 | LL | let _val: &'static _ = &([1,2,3][4]+1); | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -180,7 +189,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:62:29 + --> $DIR/promote-not.rs:72:29 | LL | let _val: &'static _ = &TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -191,7 +200,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:64:29 + --> $DIR/promote-not.rs:74:29 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -202,7 +211,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:64:30 + --> $DIR/promote-not.rs:74:30 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -213,7 +222,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:67:29 + --> $DIR/promote-not.rs:77:29 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -224,7 +233,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:67:31 + --> $DIR/promote-not.rs:77:31 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -235,7 +244,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:70:29 + --> $DIR/promote-not.rs:80:29 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -246,7 +255,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:70:31 + --> $DIR/promote-not.rs:80:31 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement @@ -255,7 +264,7 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1]; | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:79:26 + --> $DIR/promote-not.rs:89:26 | LL | let x: &'static _ = &UnionWithCell { f1: 0 }; | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -265,6 +274,7 @@ LL | LL | } | - temporary value is freed at the end of this statement -error: aborting due to 25 previous errors +error: aborting due to 26 previous errors -For more information about this error, try `rustc --explain E0716`. +Some errors have detailed explanations: E0493, E0716. +For more information about an error, try `rustc --explain E0493`.