diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 7a747a9cdee4e..3f5957bdb6e8f 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -625,7 +625,7 @@ pub(crate) fn run_pass_manager( if thin { llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm); } else { - llvm::LLVMPassManagerBuilderPopulateLTOPassManager( + llvm::LLVMRustPassManagerBuilderPopulateLTOPassManager( b, pm, /* Internalize = */ False, /* RunInliner = */ True, ); } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 7ef3b12cd08da..99e30531c226f 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -523,6 +523,12 @@ pub(crate) unsafe fn optimize( let module_name = module.name.clone(); let module_name = Some(&module_name[..]); + if let Some(false) = config.new_llvm_pass_manager && llvm_util::get_version() >= (15, 0, 0) { + diag_handler.warn( + "ignoring `-Z new-llvm-pass-manager=no`, which is no longer supported with LLVM 15", + ); + } + if config.emit_no_opt_bc { let out = cgcx.output_filenames.temp_path_ext("no-opt.bc", module_name); let out = path_to_c_string(&out); @@ -628,8 +634,8 @@ pub(crate) unsafe fn optimize( extra_passes.as_ptr(), extra_passes.len() as size_t, ); - llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm); - llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm); + llvm::LLVMRustPassManagerBuilderPopulateFunctionPassManager(b, fpm); + llvm::LLVMRustPassManagerBuilderPopulateModulePassManager(b, mpm); }); have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto; @@ -1085,7 +1091,7 @@ pub unsafe fn with_llvm_pmb( // Create the PassManagerBuilder for LLVM. We configure it with // reasonable defaults and prepare it to actually populate the pass // manager. - let builder = llvm::LLVMPassManagerBuilderCreate(); + let builder = llvm::LLVMRustPassManagerBuilderCreate(); let opt_size = config.opt_size.map_or(llvm::CodeGenOptSizeNone, |x| to_llvm_opt_settings(x).1); let inline_threshold = config.inline_threshold; let pgo_gen_path = get_pgo_gen_path(config); @@ -1102,14 +1108,9 @@ pub unsafe fn with_llvm_pmb( pgo_gen_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()), pgo_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()), pgo_sample_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()), + opt_size as c_int, ); - llvm::LLVMPassManagerBuilderSetSizeLevel(builder, opt_size as u32); - - if opt_size != llvm::CodeGenOptSizeNone { - llvm::LLVMPassManagerBuilderSetDisableUnrollLoops(builder, 1); - } - llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, config.no_builtins); // Here we match what clang does (kinda). For O0 we only inline @@ -1118,16 +1119,16 @@ pub unsafe fn with_llvm_pmb( // thresholds copied from clang. match (opt_level, opt_size, inline_threshold) { (.., Some(t)) => { - llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, t); + llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, t); } (llvm::CodeGenOptLevel::Aggressive, ..) => { - llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 275); + llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 275); } (_, llvm::CodeGenOptSizeDefault, _) => { - llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 75); + llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 75); } (_, llvm::CodeGenOptSizeAggressive, _) => { - llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 25); + llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 25); } (llvm::CodeGenOptLevel::None, ..) => { llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers); @@ -1136,12 +1137,12 @@ pub unsafe fn with_llvm_pmb( llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers); } (llvm::CodeGenOptLevel::Default, ..) => { - llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 225); + llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 225); } } f(builder); - llvm::LLVMPassManagerBuilderDispose(builder); + llvm::LLVMRustPassManagerBuilderDispose(builder); } // Create a `__imp_ = &symbol` global for every public static `symbol`. diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 7f533b0552a5d..13baaddccd4df 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1825,24 +1825,22 @@ extern "C" { pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>); - pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder; - pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder); - pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool); - pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool); - pub fn LLVMPassManagerBuilderUseInlinerWithThreshold( + pub fn LLVMRustPassManagerBuilderCreate() -> &'static mut PassManagerBuilder; + pub fn LLVMRustPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder); + pub fn LLVMRustPassManagerBuilderUseInlinerWithThreshold( PMB: &PassManagerBuilder, threshold: c_uint, ); - pub fn LLVMPassManagerBuilderPopulateModulePassManager( + pub fn LLVMRustPassManagerBuilderPopulateModulePassManager( PMB: &PassManagerBuilder, PM: &PassManager<'_>, ); - pub fn LLVMPassManagerBuilderPopulateFunctionPassManager( + pub fn LLVMRustPassManagerBuilderPopulateFunctionPassManager( PMB: &PassManagerBuilder, PM: &PassManager<'_>, ); - pub fn LLVMPassManagerBuilderPopulateLTOPassManager( + pub fn LLVMRustPassManagerBuilderPopulateLTOPassManager( PMB: &PassManagerBuilder, PM: &PassManager<'_>, Internalize: Bool, @@ -2308,6 +2306,7 @@ extern "C" { PGOGenPath: *const c_char, PGOUsePath: *const c_char, PGOSampleUsePath: *const c_char, + SizeLevel: c_int, ); pub fn LLVMRustAddLibraryInfo<'a>( PM: &PassManager<'a>, diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index c24e369ae7284..7b407c94e7b06 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -542,6 +542,11 @@ pub(crate) fn should_use_new_llvm_pass_manager(user_opt: &Option, target_a // The new pass manager is enabled by default for LLVM >= 13. // This matches Clang, which also enables it since Clang 13. + // Since LLVM 15, the legacy pass manager is no longer supported. + if llvm_util::get_version() >= (15, 0, 0) { + return true; + } + // There are some perf issues with the new pass manager when targeting // s390x with LLVM 13, so enable the new pass manager only with LLVM 14. // See https://github.com/rust-lang/rust/issues/89609. diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 6caa1032ba3cd..1327bf6fcd427 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -752,6 +752,7 @@ fn test_debugging_options_tracking_hash() { tracked!(location_detail, LocationDetail { file: true, line: false, column: false }); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); + tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]); tracked!(mir_opt_level, Some(4)); tracked!(move_size_limit, Some(4096)); tracked!(mutable_noalias, Some(true)); diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 71f21dc666686..38fddbdba54dd 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -107,6 +107,7 @@ static LLVMRustPassKind toRust(PassKind Kind) { } extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) { +#if LLVM_VERSION_LT(15, 0) StringRef SR(PassName); PassRegistry *PR = PassRegistry::getPassRegistry(); @@ -115,36 +116,59 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) { return wrap(PI->createPass()); } return nullptr; +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover) { +#if LLVM_VERSION_LT(15, 0) const bool CompileKernel = false; const bool UseAfterScope = true; return wrap(createAddressSanitizerFunctionPass(CompileKernel, Recover, UseAfterScope)); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) { +#if LLVM_VERSION_LT(15, 0) const bool CompileKernel = false; return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover)); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) { +#if LLVM_VERSION_LT(15, 0) const bool CompileKernel = false; return wrap(createMemorySanitizerLegacyPassPass( MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel})); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() { +#if LLVM_VERSION_LT(15, 0) return wrap(createThreadSanitizerLegacyPassPass()); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) { +#if LLVM_VERSION_LT(15, 0) const bool CompileKernel = false; return wrap(createHWAddressSanitizerLegacyPassPass(CompileKernel, Recover)); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) { @@ -154,10 +178,57 @@ extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) { } extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) { +#if LLVM_VERSION_LT(15, 0) assert(RustPass); Pass *Pass = unwrap(RustPass); PassManagerBase *PMB = unwrap(PMR); PMB->add(Pass); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" LLVMPassManagerBuilderRef LLVMRustPassManagerBuilderCreate() { +#if LLVM_VERSION_LT(15, 0) + return LLVMPassManagerBuilderCreate(); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" void LLVMRustPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) { +#if LLVM_VERSION_LT(15, 0) + LLVMPassManagerBuilderDispose(PMB); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" void LLVMRustPassManagerBuilderPopulateFunctionPassManager( + LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM) { +#if LLVM_VERSION_LT(15, 0) + LLVMPassManagerBuilderPopulateFunctionPassManager(PMB, PM); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" void LLVMRustPassManagerBuilderPopulateModulePassManager( + LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM) { +#if LLVM_VERSION_LT(15, 0) + LLVMPassManagerBuilderPopulateModulePassManager(PMB, PM); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" void LLVMRustPassManagerBuilderPopulateLTOPassManager( + LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM, bool Internalize, bool RunInliner) { +#if LLVM_VERSION_LT(15, 0) + LLVMPassManagerBuilderPopulateLTOPassManager(PMB, PM, Internalize, RunInliner); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" @@ -165,12 +236,26 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager( LLVMPassManagerBuilderRef PMBR, LLVMPassManagerRef PMR ) { +#if LLVM_VERSION_LT(15, 0) unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR)); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif +} + +extern "C" void LLVMRustPassManagerBuilderUseInlinerWithThreshold( + LLVMPassManagerBuilderRef PMB, unsigned Threshold) { +#if LLVM_VERSION_LT(15, 0) + LLVMPassManagerBuilderUseInlinerWithThreshold(PMB, Threshold); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } extern "C" void LLVMRustAddLastExtensionPasses( LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) { +#if LLVM_VERSION_LT(15, 0) auto AddExtensionPasses = [Passes, NumPasses]( const PassManagerBuilder &Builder, PassManagerBase &PM) { for (size_t I = 0; I < NumPasses; I++) { @@ -183,6 +268,9 @@ void LLVMRustAddLastExtensionPasses( AddExtensionPasses); unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, AddExtensionPasses); +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } #ifdef LLVM_COMPONENT_X86 @@ -533,12 +621,16 @@ extern "C" void LLVMRustDisposeTargetMachine(LLVMTargetMachineRef TM) { extern "C" void LLVMRustConfigurePassManagerBuilder( LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel, bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO, - const char* PGOGenPath, const char* PGOUsePath, const char* PGOSampleUsePath) { + const char* PGOGenPath, const char* PGOUsePath, const char* PGOSampleUsePath, + int SizeLevel) { +#if LLVM_VERSION_LT(15, 0) unwrap(PMBR)->MergeFunctions = MergeFunctions; unwrap(PMBR)->SLPVectorize = SLPVectorize; unwrap(PMBR)->OptLevel = fromRust(OptLevel); unwrap(PMBR)->LoopVectorize = LoopVectorize; unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO; + unwrap(PMBR)->SizeLevel = SizeLevel; + unwrap(PMBR)->DisableUnrollLoops = SizeLevel != 0; if (PGOGenPath) { assert(!PGOUsePath && !PGOSampleUsePath); @@ -550,6 +642,9 @@ extern "C" void LLVMRustConfigurePassManagerBuilder( } else if (PGOSampleUsePath) { unwrap(PMBR)->PGOSampleUse = PGOSampleUsePath; } +#else + report_fatal_error("Legacy PM not supported with LLVM 15"); +#endif } // Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo` diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 3ed4396d1e955..850b80e42801b 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -6,6 +6,7 @@ #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" +#include "llvm/IR/Mangler.h" #include "llvm/Object/Archive.h" #include "llvm/Object/COFFImportFile.h" #include "llvm/Object/ObjectFile.h" diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index 740a2168b41cc..2380391d09a91 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -77,17 +77,30 @@ pub fn run_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, passes: &[&dyn let mut cnt = 0; let validate = tcx.sess.opts.debugging_opts.validate_mir; + let overridden_passes = &tcx.sess.opts.debugging_opts.mir_enable_passes; + trace!(?overridden_passes); if validate { validate_body(tcx, body, format!("start of phase transition from {:?}", start_phase)); } for pass in passes { - if !pass.is_enabled(&tcx.sess) { - continue; - } - let name = pass.name(); + + if let Some((_, polarity)) = overridden_passes.iter().rev().find(|(s, _)| s == &*name) { + trace!( + pass = %name, + "{} as requested by flag", + if *polarity { "Running" } else { "Not running" }, + ); + if !polarity { + continue; + } + } else { + if !pass.is_enabled(&tcx.sess) { + continue; + } + } let dump_enabled = pass.is_mir_dump_enabled(); if dump_enabled { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index df65409a8a063..96f50e57ac4d0 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -368,6 +368,8 @@ mod desc { pub const parse_opt_langid: &str = "a language identifier"; pub const parse_opt_pathbuf: &str = "a path"; pub const parse_list: &str = "a space-separated list of strings"; + pub const parse_list_with_polarity: &str = + "a comma-separated list of strings, with elements beginning with + or -"; pub const parse_opt_comma_list: &str = "a comma-separated list of strings"; pub const parse_number: &str = "a number"; pub const parse_opt_number: &str = parse_number; @@ -529,6 +531,19 @@ mod parse { } } + crate fn parse_list_with_polarity(slot: &mut Vec<(String, bool)>, v: Option<&str>) -> bool { + match v { + Some(s) => { + for s in s.split(",") { + let Some(pass_name) = s.strip_prefix(&['+', '-'][..]) else { return false }; + slot.push((pass_name.to_string(), &s[..1] == "+")); + } + true + } + None => false, + } + } + crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool { if let Some(v) = v { ld.line = false; @@ -1318,6 +1333,10 @@ options! { mir_emit_retag: bool = (false, parse_bool, [TRACKED], "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \ (default: no)"), + mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED], + "use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be \ + enabled, overriding all other checks. Passes that are not specified are enabled or \ + disabled by other flags as usual."), mir_opt_level: Option = (None, parse_opt_number, [TRACKED], "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"), move_size_limit: Option = (None, parse_opt_number, [TRACKED], diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 6bae0f2eac954..1cd0ace8adb05 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -2563,40 +2563,77 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // We proactively collect all the inferred type params to emit a single error per fn def. let mut visitor = HirPlaceholderCollector::default(); - for ty in decl.inputs { - visitor.visit_ty(ty); - } + let mut infer_replacements = vec![]; + walk_generics(&mut visitor, generics); - let input_tys = decl.inputs.iter().map(|a| self.ty_of_arg(a, None)); + let input_tys: Vec<_> = decl + .inputs + .iter() + .enumerate() + .map(|(i, a)| { + if let hir::TyKind::Infer = a.kind && !self.allow_ty_infer() { + if let Some(suggested_ty) = + self.suggest_trait_fn_ty_for_impl_fn_infer(hir_id, Some(i)) + { + infer_replacements.push((a.span, suggested_ty.to_string())); + return suggested_ty; + } + } + + // Only visit the type looking for `_` if we didn't fix the type above + visitor.visit_ty(a); + self.ty_of_arg(a, None) + }) + .collect(); + let output_ty = match decl.output { hir::FnRetTy::Return(output) => { - visitor.visit_ty(output); - self.ast_ty_to_ty(output) + if let hir::TyKind::Infer = output.kind + && !self.allow_ty_infer() + && let Some(suggested_ty) = + self.suggest_trait_fn_ty_for_impl_fn_infer(hir_id, None) + { + infer_replacements.push((output.span, suggested_ty.to_string())); + suggested_ty + } else { + visitor.visit_ty(output); + self.ast_ty_to_ty(output) + } } hir::FnRetTy::DefaultReturn(..) => tcx.mk_unit(), }; debug!("ty_of_fn: output_ty={:?}", output_ty); - let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, unsafety, abi); + let fn_ty = tcx.mk_fn_sig(input_tys.into_iter(), output_ty, decl.c_variadic, unsafety, abi); let bare_fn_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars); - if !self.allow_ty_infer() { + if !self.allow_ty_infer() && !(visitor.0.is_empty() && infer_replacements.is_empty()) { // We always collect the spans for placeholder types when evaluating `fn`s, but we // only want to emit an error complaining about them if infer types (`_`) are not // allowed. `allow_ty_infer` gates this behavior. We check for the presence of // `ident_span` to not emit an error twice when we have `fn foo(_: fn() -> _)`. - crate::collect::placeholder_type_error( + let mut diag = crate::collect::placeholder_type_error_diag( tcx, ident_span.map(|sp| sp.shrink_to_hi()), generics.params, visitor.0, + infer_replacements.iter().map(|(s, _)| *s).collect(), true, hir_ty, "function", ); + + if !infer_replacements.is_empty() { + diag.multipart_suggestion(&format!( + "try replacing `_` with the type{} in the corresponding trait method signature", + rustc_errors::pluralize!(infer_replacements.len()), + ), infer_replacements, Applicability::MachineApplicable); + } + + diag.emit(); } // Find any late-bound regions declared in return type that do @@ -2624,6 +2661,43 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { bare_fn_ty } + /// Given a fn_hir_id for a impl function, suggest the type that is found on the + /// corresponding function in the trait that the impl implements, if it exists. + /// If arg_idx is Some, then it corresponds to an input type index, otherwise it + /// corresponds to the return type. + fn suggest_trait_fn_ty_for_impl_fn_infer( + &self, + fn_hir_id: hir::HirId, + arg_idx: Option, + ) -> Option> { + let tcx = self.tcx(); + let hir = tcx.hir(); + + let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) = + hir.get(fn_hir_id) else { return None }; + let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(i), .. }) = + hir.get(hir.get_parent_node(fn_hir_id)) else { bug!("ImplItem should have Impl parent") }; + + let trait_ref = + self.instantiate_mono_trait_ref(i.of_trait.as_ref()?, self.ast_ty_to_ty(i.self_ty)); + + let x: &ty::AssocItem = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind( + tcx, + *ident, + ty::AssocKind::Fn, + trait_ref.def_id, + )?; + + let fn_sig = tcx.fn_sig(x.def_id).subst( + tcx, + trait_ref.substs.extend_to(tcx, x.def_id, |param, _| tcx.mk_param_from_def(param)), + ); + + let ty = if let Some(arg_idx) = arg_idx { fn_sig.input(arg_idx) } else { fn_sig.output() }; + + Some(tcx.erase_late_bound_regions(ty)) + } + fn validate_late_bound_regions( &self, constrained_regions: FxHashSet, diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 153ab8d95fd4b..be77bdb0bf5f0 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -160,6 +160,33 @@ crate fn placeholder_type_error<'tcx>( return; } + placeholder_type_error_diag( + tcx, + span, + generics, + placeholder_types, + vec![], + suggest, + hir_ty, + kind, + ) + .emit(); +} + +crate fn placeholder_type_error_diag<'tcx>( + tcx: TyCtxt<'tcx>, + span: Option, + generics: &[hir::GenericParam<'_>], + placeholder_types: Vec, + additional_spans: Vec, + suggest: bool, + hir_ty: Option<&hir::Ty<'_>>, + kind: &'static str, +) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + if placeholder_types.is_empty() { + return bad_placeholder(tcx, additional_spans, kind); + } + let type_name = generics.next_type_param_name(None); let mut sugg: Vec<_> = placeholder_types.iter().map(|sp| (*sp, (*type_name).to_string())).collect(); @@ -182,7 +209,8 @@ crate fn placeholder_type_error<'tcx>( sugg.push((span, format!(", {}", type_name))); } - let mut err = bad_placeholder(tcx, placeholder_types, kind); + let mut err = + bad_placeholder(tcx, placeholder_types.into_iter().chain(additional_spans).collect(), kind); // Suggest, but only if it is not a function in const or static if suggest { @@ -218,7 +246,8 @@ crate fn placeholder_type_error<'tcx>( ); } } - err.emit(); + + err } fn reject_placeholder_type_signatures_in_item<'tcx>( @@ -1868,50 +1897,17 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { generics, .. }) - | ImplItem(hir::ImplItem { kind: ImplItemKind::Fn(sig, _), ident, generics, .. }) | Item(hir::Item { kind: ItemKind::Fn(sig, generics, _), ident, .. }) => { - match get_infer_ret_ty(&sig.decl.output) { - Some(ty) => { - let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id]; - // Typeck doesn't expect erased regions to be returned from `type_of`. - let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match *r { - ty::ReErased => tcx.lifetimes.re_static, - _ => r, - }); - let fn_sig = ty::Binder::dummy(fn_sig); - - let mut visitor = HirPlaceholderCollector::default(); - visitor.visit_ty(ty); - let mut diag = bad_placeholder(tcx, visitor.0, "return type"); - let ret_ty = fn_sig.skip_binder().output(); - if !ret_ty.references_error() { - if !ret_ty.is_closure() { - let ret_ty_str = match ret_ty.kind() { - // Suggest a function pointer return type instead of a unique function definition - // (e.g. `fn() -> i32` instead of `fn() -> i32 { f }`, the latter of which is invalid - // syntax) - ty::FnDef(..) => ret_ty.fn_sig(tcx).to_string(), - _ => ret_ty.to_string(), - }; - diag.span_suggestion( - ty.span, - "replace with the correct return type", - ret_ty_str, - Applicability::MaybeIncorrect, - ); - } else { - // We're dealing with a closure, so we should suggest using `impl Fn` or trait bounds - // to prevent the user from getting a papercut while trying to use the unique closure - // syntax (e.g. `[closure@src/lib.rs:2:5: 2:9]`). - diag.help("consider using an `Fn`, `FnMut`, or `FnOnce` trait bound"); - diag.note("for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html"); - } - } - diag.emit(); + infer_return_ty_for_fn_sig(tcx, sig, *ident, generics, def_id, &icx) + } - fn_sig - } - None => >::ty_of_fn( + ImplItem(hir::ImplItem { kind: ImplItemKind::Fn(sig, _), ident, generics, .. }) => { + // Do not try to inference the return type for a impl method coming from a trait + if let Item(hir::Item { kind: ItemKind::Impl(i), .. }) = + tcx.hir().get(tcx.hir().get_parent_node(hir_id)) + && i.of_trait.is_some() + { + >::ty_of_fn( &icx, hir_id, sig.header.unsafety, @@ -1920,7 +1916,9 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { generics, Some(ident.span), None, - ), + ) + } else { + infer_return_ty_for_fn_sig(tcx, sig, *ident, generics, def_id, &icx) } } @@ -1982,6 +1980,70 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { } } +fn infer_return_ty_for_fn_sig<'tcx>( + tcx: TyCtxt<'tcx>, + sig: &hir::FnSig<'_>, + ident: Ident, + generics: &hir::Generics<'_>, + def_id: LocalDefId, + icx: &ItemCtxt<'tcx>, +) -> ty::PolyFnSig<'tcx> { + let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); + + match get_infer_ret_ty(&sig.decl.output) { + Some(ty) => { + let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id]; + // Typeck doesn't expect erased regions to be returned from `type_of`. + let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match *r { + ty::ReErased => tcx.lifetimes.re_static, + _ => r, + }); + let fn_sig = ty::Binder::dummy(fn_sig); + + let mut visitor = HirPlaceholderCollector::default(); + visitor.visit_ty(ty); + let mut diag = bad_placeholder(tcx, visitor.0, "return type"); + let ret_ty = fn_sig.skip_binder().output(); + if !ret_ty.references_error() { + if !ret_ty.is_closure() { + let ret_ty_str = match ret_ty.kind() { + // Suggest a function pointer return type instead of a unique function definition + // (e.g. `fn() -> i32` instead of `fn() -> i32 { f }`, the latter of which is invalid + // syntax) + ty::FnDef(..) => ret_ty.fn_sig(tcx).to_string(), + _ => ret_ty.to_string(), + }; + diag.span_suggestion( + ty.span, + "replace with the correct return type", + ret_ty_str, + Applicability::MaybeIncorrect, + ); + } else { + // We're dealing with a closure, so we should suggest using `impl Fn` or trait bounds + // to prevent the user from getting a papercut while trying to use the unique closure + // syntax (e.g. `[closure@src/lib.rs:2:5: 2:9]`). + diag.help("consider using an `Fn`, `FnMut`, or `FnOnce` trait bound"); + diag.note("for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html"); + } + } + diag.emit(); + + fn_sig + } + None => >::ty_of_fn( + icx, + hir_id, + sig.header.unsafety, + sig.header.abi, + sig.decl, + generics, + Some(ident.span), + None, + ), + } +} + fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { let icx = ItemCtxt::new(tcx, def_id); match tcx.hir().expect_item(def_id.expect_local()).kind { diff --git a/library/alloc/src/collections/vec_deque/tests.rs b/library/alloc/src/collections/vec_deque/tests.rs index 2be83f68f017f..f2869a54713d2 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -162,6 +162,300 @@ fn test_insert() { } } +#[test] +fn test_get() { + let mut tester = VecDeque::new(); + tester.push_back(1); + tester.push_back(2); + tester.push_back(3); + + assert_eq!(tester.len(), 3); + + assert_eq!(tester.get(1), Some(&2)); + assert_eq!(tester.get(2), Some(&3)); + assert_eq!(tester.get(0), Some(&1)); + assert_eq!(tester.get(3), None); + + tester.remove(0); + + assert_eq!(tester.len(), 2); + assert_eq!(tester.get(0), Some(&2)); + assert_eq!(tester.get(1), Some(&3)); + assert_eq!(tester.get(2), None); +} + +#[test] +fn test_get_mut() { + let mut tester = VecDeque::new(); + tester.push_back(1); + tester.push_back(2); + tester.push_back(3); + + assert_eq!(tester.len(), 3); + + if let Some(elem) = tester.get_mut(0) { + assert_eq!(*elem, 1); + *elem = 10; + } + + if let Some(elem) = tester.get_mut(2) { + assert_eq!(*elem, 3); + *elem = 30; + } + + assert_eq!(tester.get(0), Some(&10)); + assert_eq!(tester.get(2), Some(&30)); + assert_eq!(tester.get_mut(3), None); + + tester.remove(2); + + assert_eq!(tester.len(), 2); + assert_eq!(tester.get(0), Some(&10)); + assert_eq!(tester.get(1), Some(&2)); + assert_eq!(tester.get(2), None); +} + +#[test] +fn test_swap() { + let mut tester = VecDeque::new(); + tester.push_back(1); + tester.push_back(2); + tester.push_back(3); + + assert_eq!(tester, [1, 2, 3]); + + tester.swap(0, 0); + assert_eq!(tester, [1, 2, 3]); + tester.swap(0, 1); + assert_eq!(tester, [2, 1, 3]); + tester.swap(2, 1); + assert_eq!(tester, [2, 3, 1]); + tester.swap(1, 2); + assert_eq!(tester, [2, 1, 3]); + tester.swap(0, 2); + assert_eq!(tester, [3, 1, 2]); + tester.swap(2, 2); + assert_eq!(tester, [3, 1, 2]); +} + +#[test] +#[should_panic = "assertion failed: j < self.len()"] +fn test_swap_panic() { + let mut tester = VecDeque::new(); + tester.push_back(1); + tester.push_back(2); + tester.push_back(3); + tester.swap(2, 3); +} + +#[test] +fn test_reserve_exact() { + let mut tester: VecDeque = VecDeque::with_capacity(1); + assert!(tester.capacity() == 1); + tester.reserve_exact(50); + assert!(tester.capacity() >= 51); + tester.reserve_exact(40); + assert!(tester.capacity() >= 51); + tester.reserve_exact(200); + assert!(tester.capacity() >= 200); +} + +#[test] +#[should_panic = "capacity overflow"] +fn test_reserve_exact_panic() { + let mut tester: VecDeque = VecDeque::new(); + tester.reserve_exact(usize::MAX); +} + +#[test] +fn test_try_reserve_exact() { + let mut tester: VecDeque = VecDeque::with_capacity(1); + assert!(tester.capacity() == 1); + assert_eq!(tester.try_reserve_exact(100), Ok(())); + assert!(tester.capacity() >= 100); + assert_eq!(tester.try_reserve_exact(50), Ok(())); + assert!(tester.capacity() >= 100); + assert_eq!(tester.try_reserve_exact(200), Ok(())); + assert!(tester.capacity() >= 200); + assert_eq!(tester.try_reserve_exact(0), Ok(())); + assert!(tester.capacity() >= 200); + assert!(tester.try_reserve_exact(usize::MAX).is_err()); +} + +#[test] +fn test_try_reserve() { + let mut tester: VecDeque = VecDeque::with_capacity(1); + assert!(tester.capacity() == 1); + assert_eq!(tester.try_reserve(100), Ok(())); + assert!(tester.capacity() >= 100); + assert_eq!(tester.try_reserve(50), Ok(())); + assert!(tester.capacity() >= 100); + assert_eq!(tester.try_reserve(200), Ok(())); + assert!(tester.capacity() >= 200); + assert_eq!(tester.try_reserve(0), Ok(())); + assert!(tester.capacity() >= 200); + assert!(tester.try_reserve(usize::MAX).is_err()); +} + +#[test] +fn test_contains() { + let mut tester = VecDeque::new(); + tester.push_back(1); + tester.push_back(2); + tester.push_back(3); + + assert!(tester.contains(&1)); + assert!(tester.contains(&3)); + assert!(!tester.contains(&0)); + assert!(!tester.contains(&4)); + tester.remove(0); + assert!(!tester.contains(&1)); + assert!(tester.contains(&2)); + assert!(tester.contains(&3)); +} + +#[test] +fn test_rotate_left_right() { + let mut tester: VecDeque<_> = (1..=10).collect(); + + assert_eq!(tester.len(), 10); + + tester.rotate_left(0); + assert_eq!(tester, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + + tester.rotate_right(0); + assert_eq!(tester, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + + tester.rotate_left(3); + assert_eq!(tester, [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]); + + tester.rotate_right(5); + assert_eq!(tester, [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]); + + tester.rotate_left(tester.len()); + assert_eq!(tester, [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]); + + tester.rotate_right(tester.len()); + assert_eq!(tester, [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]); + + tester.rotate_left(1); + assert_eq!(tester, [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +} + +#[test] +#[should_panic = "assertion failed: mid <= self.len()"] +fn test_rotate_left_panic() { + let mut tester: VecDeque<_> = (1..=10).collect(); + tester.rotate_left(tester.len() + 1); +} + +#[test] +#[should_panic = "assertion failed: k <= self.len()"] +fn test_rotate_right_panic() { + let mut tester: VecDeque<_> = (1..=10).collect(); + tester.rotate_right(tester.len() + 1); +} + +#[test] +fn test_binary_search() { + // If the givin VecDeque is not sorted, the returned result is unspecified and meaningless, + // as this method performs a binary search. + + let tester: VecDeque<_> = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into(); + + assert_eq!(tester.binary_search(&0), Ok(0)); + assert_eq!(tester.binary_search(&5), Ok(5)); + assert_eq!(tester.binary_search(&55), Ok(10)); + assert_eq!(tester.binary_search(&4), Err(5)); + assert_eq!(tester.binary_search(&-1), Err(0)); + assert!(matches!(tester.binary_search(&1), Ok(1..=2))); + + let tester: VecDeque<_> = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3].into(); + assert_eq!(tester.binary_search(&1), Ok(0)); + assert!(matches!(tester.binary_search(&2), Ok(1..=4))); + assert!(matches!(tester.binary_search(&3), Ok(5..=13))); + assert_eq!(tester.binary_search(&-2), Err(0)); + assert_eq!(tester.binary_search(&0), Err(0)); + assert_eq!(tester.binary_search(&4), Err(14)); + assert_eq!(tester.binary_search(&5), Err(14)); +} + +#[test] +fn test_binary_search_by() { + // If the givin VecDeque is not sorted, the returned result is unspecified and meaningless, + // as this method performs a binary search. + + let tester: VecDeque<_> = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into(); + + assert_eq!(tester.binary_search_by(|x| x.cmp(&0)), Ok(0)); + assert_eq!(tester.binary_search_by(|x| x.cmp(&5)), Ok(5)); + assert_eq!(tester.binary_search_by(|x| x.cmp(&55)), Ok(10)); + assert_eq!(tester.binary_search_by(|x| x.cmp(&4)), Err(5)); + assert_eq!(tester.binary_search_by(|x| x.cmp(&-1)), Err(0)); + assert!(matches!(tester.binary_search_by(|x| x.cmp(&1)), Ok(1..=2))); +} + +#[test] +fn test_binary_search_key() { + // If the givin VecDeque is not sorted, the returned result is unspecified and meaningless, + // as this method performs a binary search. + + let tester: VecDeque<_> = [ + (-1, 0), + (2, 10), + (6, 5), + (7, 1), + (8, 10), + (10, 2), + (20, 3), + (24, 5), + (25, 18), + (28, 13), + (31, 21), + (32, 4), + (54, 25), + ] + .into(); + + assert_eq!(tester.binary_search_by_key(&-1, |&(a, _b)| a), Ok(0)); + assert_eq!(tester.binary_search_by_key(&8, |&(a, _b)| a), Ok(4)); + assert_eq!(tester.binary_search_by_key(&25, |&(a, _b)| a), Ok(8)); + assert_eq!(tester.binary_search_by_key(&54, |&(a, _b)| a), Ok(12)); + assert_eq!(tester.binary_search_by_key(&-2, |&(a, _b)| a), Err(0)); + assert_eq!(tester.binary_search_by_key(&1, |&(a, _b)| a), Err(1)); + assert_eq!(tester.binary_search_by_key(&4, |&(a, _b)| a), Err(2)); + assert_eq!(tester.binary_search_by_key(&13, |&(a, _b)| a), Err(6)); + assert_eq!(tester.binary_search_by_key(&55, |&(a, _b)| a), Err(13)); + assert_eq!(tester.binary_search_by_key(&100, |&(a, _b)| a), Err(13)); + + let tester: VecDeque<_> = [ + (0, 0), + (2, 1), + (6, 1), + (5, 1), + (3, 1), + (1, 2), + (2, 3), + (4, 5), + (5, 8), + (8, 13), + (1, 21), + (2, 34), + (4, 55), + ] + .into(); + + assert_eq!(tester.binary_search_by_key(&0, |&(_a, b)| b), Ok(0)); + assert!(matches!(tester.binary_search_by_key(&1, |&(_a, b)| b), Ok(1..=4))); + assert_eq!(tester.binary_search_by_key(&8, |&(_a, b)| b), Ok(8)); + assert_eq!(tester.binary_search_by_key(&13, |&(_a, b)| b), Ok(9)); + assert_eq!(tester.binary_search_by_key(&55, |&(_a, b)| b), Ok(12)); + assert_eq!(tester.binary_search_by_key(&-1, |&(_a, b)| b), Err(0)); + assert_eq!(tester.binary_search_by_key(&4, |&(_a, b)| b), Err(7)); + assert_eq!(tester.binary_search_by_key(&56, |&(_a, b)| b), Err(13)); + assert_eq!(tester.binary_search_by_key(&100, |&(_a, b)| b), Err(13)); +} + #[test] fn make_contiguous_big_tail() { let mut tester = VecDeque::with_capacity(15); diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index 0349277a36b90..5f85fc5aa5903 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -31,8 +31,8 @@ fn main() { let mut cmd = Command::new(rustdoc); - // I am not actually sure why it's necessary to pass the sysroot for `--test`, - // but `test --doc --stage 0` is broken without it :( + // cfg(bootstrap) + // NOTE: the `--test` special-casing can be removed when https://github.com/rust-lang/cargo/pull/10594 lands on beta. if target.is_some() || args.iter().any(|x| x == "--test") { // The stage0 compiler has a special sysroot distinct from what we // actually downloaded, so we just always pass the `--sysroot` option, @@ -65,13 +65,6 @@ fn main() { } } - // Needed to be able to run all rustdoc tests. - if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") { - // This "unstable-options" can be removed when `--resource-suffix` is stabilized - cmd.arg("-Z").arg("unstable-options"); - cmd.arg("--resource-suffix").arg(x); - } - if verbose > 1 { eprintln!( "rustdoc command: {:?}={:?} {:?}", diff --git a/src/test/codegen/panic-in-drop-abort.rs b/src/test/codegen/panic-in-drop-abort.rs index 39f73c4e3967e..7a84484c41996 100644 --- a/src/test/codegen/panic-in-drop-abort.rs +++ b/src/test/codegen/panic-in-drop-abort.rs @@ -1,14 +1,12 @@ -// compile-flags: -Z panic-in-drop=abort -O -Z new-llvm-pass-manager=no +// compile-flags: -Z panic-in-drop=abort -O +// ignore-msvc // Ensure that unwinding code paths are eliminated from the output after // optimization. -// This test uses -Z new-llvm-pass-manager=no, because the expected optimization does not happen -// on targets using SEH exceptions (i.e. MSVC) anymore. The core issue is that Rust promises that -// the drop_in_place() function can't unwind, but implements it in a way that *can*, because we -// currently go out of our way to allow longjmps, which also use the unwinding mechanism on MSVC -// targets. We should either forbid longjmps, or not assume nounwind, making this optimization -// incompatible with the current behavior of running cleanuppads on longjmp unwinding. +// This test uses ignore-msvc, because the expected optimization does not happen on targets using +// SEH exceptions with the new LLVM pass manager anymore, see +// https://github.com/llvm/llvm-project/issues/51311. // CHECK-NOT: {{(call|invoke).*}}should_not_appear_in_output diff --git a/src/test/mir-opt/combine_clone_of_primitives.rs b/src/test/mir-opt/combine_clone_of_primitives.rs index 0972d2d68a115..7cc50a86e21e1 100644 --- a/src/test/mir-opt/combine_clone_of_primitives.rs +++ b/src/test/mir-opt/combine_clone_of_primitives.rs @@ -1,4 +1,4 @@ -// compile-flags: -C opt-level=0 -Z inline_mir=no +// unit-test: InstCombine // ignore-wasm32 compiled with panic=abort by default // EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff diff --git a/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff b/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff index 678e965cd67f2..fdc016a95d58e 100644 --- a/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +++ b/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff @@ -23,9 +23,15 @@ } bb0: { + StorageLive(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 _2 = &((*_1).0: T); // scope 0 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 + StorageLive(_3); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 _3 = &((*_1).1: u64); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + StorageLive(_4); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 _4 = &((*_1).2: [f32; 3]); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + StorageLive(_5); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 + StorageLive(_6); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 + StorageLive(_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 - _7 = &(*_2); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 - _6 = &(*_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 + _7 = _2; // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 @@ -37,6 +43,10 @@ } bb1: { + StorageDead(_6); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:8: 8:9 + StorageLive(_8); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + StorageLive(_9); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + StorageLive(_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 - _10 = &(*_3); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 - _9 = &(*_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 - _8 = ::clone(move _9) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 @@ -50,6 +60,10 @@ } bb2: { + StorageDead(_9); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:10: 9:11 + StorageLive(_11); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + StorageLive(_12); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + StorageLive(_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 - _13 = &(*_4); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 - _12 = &(*_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 - _11 = <[f32; 3] as Clone>::clone(move _12) -> [return: bb3, unwind: bb4]; // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 @@ -63,10 +77,20 @@ } bb3: { + StorageDead(_12); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:15: 10:16 Deinit(_0); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15 (_0.0: T) = move _5; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15 (_0.1: u64) = move _8; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15 (_0.2: [f32; 3]) = move _11; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15 + StorageDead(_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_11); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_8); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_5); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_4); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_3); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 + StorageDead(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15 return; // scope 0 at $DIR/combine_clone_of_primitives.rs:6:15: 6:15 } diff --git a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff index e40274dc39340..038a1afc58bb6 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff @@ -68,8 +68,10 @@ + bb3: { StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch.rs:8:1: 8:2 return; // scope 0 at $DIR/early_otherwise_branch.rs:8:2: 8:2 -+ } -+ + } + +- bb5 (cleanup): { +- resume; // scope 0 at $DIR/early_otherwise_branch.rs:3:1: 8:2 + bb4: { + StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 4:17 + switchInt(_7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 4:17 diff --git a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index 4f2b9696f8c82..75549c1b3ddf2 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -32,7 +32,7 @@ StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:12:16: 12:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:12:16: 12:17 _8 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch.rs:12:11: 12:17 -- switchInt(move _8) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb7]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 +- switchInt(move _8) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 + StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 + _11 = discriminant((_3.1: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 + StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 @@ -84,8 +84,8 @@ return; // scope 0 at $DIR/early_otherwise_branch.rs:17:2: 17:2 } -- bb7: { -- unreachable; // scope 0 at $DIR/early_otherwise_branch.rs:15:14: 15:15 +- bb7 (cleanup): { +- resume; // scope 0 at $DIR/early_otherwise_branch.rs:11:1: 17:2 + bb5: { + StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 + switchInt(_8) -> [0_isize: bb3, 1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17 diff --git a/src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff index 96c7e46853f14..30726d8621e1f 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff @@ -68,8 +68,10 @@ + bb3: { StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch.rs:26:1: 26:2 return; // scope 0 at $DIR/early_otherwise_branch.rs:26:2: 26:2 -+ } -+ + } + +- bb5 (cleanup): { +- resume; // scope 0 at $DIR/early_otherwise_branch.rs:21:1: 26:2 + bb4: { + StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 + switchInt(_7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 diff --git a/src/test/mir-opt/early_otherwise_branch.rs b/src/test/mir-opt/early_otherwise_branch.rs index e0ebcfeebfcc7..7be9fbd0326f6 100644 --- a/src/test/mir-opt/early_otherwise_branch.rs +++ b/src/test/mir-opt/early_otherwise_branch.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts +// unit-test: EarlyOtherwiseBranch // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option, y: Option) -> u32 { match (x, y) { diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff index 379d0e9ea48b3..ddf26ad8ab323 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff @@ -90,8 +90,10 @@ + bb4: { StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:9:1: 9:2 return; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:9:2: 9:2 -+ } -+ + } + +- bb6 (cleanup): { +- resume; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:4:1: 9:2 + bb5: { + StorageDead(_15); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 5:20 + switchInt(_10) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 5:20 diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs index 8527c01d75658..76055e1330fa7 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts +// unit-test: EarlyOtherwiseBranch // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option, y: Option, z: Option) -> u32 { diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index 6adc5194aec75..4d2db490836d8 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -38,25 +38,29 @@ StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:16: 8:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:16: 8:17 _8 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17 - switchInt(move _8) -> [0_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 + switchInt(move _8) -> [0_isize: bb1, 1_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 } bb1: { _6 = discriminant((_3.1: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17 - switchInt(move _6) -> [0_isize: bb2, otherwise: bb6]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 + switchInt(move _6) -> [0_isize: bb2, 1_isize: bb7, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 } bb2: { _0 = const 3_u32; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26 - goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26 + goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26 } bb3: { - _7 = discriminant((_3.1: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17 - switchInt(move _7) -> [0_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 + unreachable; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17 } bb4: { + _7 = discriminant((_3.1: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17 + switchInt(move _7) -> [0_isize: bb6, 1_isize: bb5, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17 + } + + bb5: { StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 @@ -64,28 +68,32 @@ _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 - goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 + goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 } - bb5: { + bb6: { StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:15: 10:16 _11 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:15: 10:16 _0 = const 1_u32; // scope 2 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29 StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29 - goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29 + goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29 } - bb6: { + bb7: { StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:21: 11:22 _12 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:21: 11:22 _0 = const 2_u32; // scope 3 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29 StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29 - goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29 + goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29 } - bb7: { + bb8: { StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:14:1: 14:2 return; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:14:2: 14:2 } + + bb9 (cleanup): { + resume; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:7:1: 14:2 + } } diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.rs b/src/test/mir-opt/early_otherwise_branch_noopt.rs index 1f8c59df35fff..ef766bbd4a651 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.rs +++ b/src/test/mir-opt/early_otherwise_branch_noopt.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts +// unit-test: EarlyOtherwiseBranch // must not optimize as it does not follow the pattern of // left and right hand side being the same variant diff --git a/src/test/mir-opt/early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff index a272266066246..92a719d997d6b 100644 --- a/src/test/mir-opt/early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff @@ -19,7 +19,7 @@ bb1: { _0 = const 0_i32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15 - return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15 + goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15 } bb2: { @@ -29,7 +29,7 @@ bb3: { _0 = const 0_i32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19 - return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19 + goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19 } bb4: { @@ -37,7 +37,15 @@ _5 = (((*_2) as Some).0: i32); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:18: 22:19 _0 = _5; // scope 1 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25 - return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25 + goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25 + } + + bb5: { + return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:27:2: 27:2 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:18:1: 27:2 } } diff --git a/src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff index 56b7c9a2db478..c43b32c7fc6e3 100644 --- a/src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff @@ -19,12 +19,20 @@ bb2: { _0 = const 1_u32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:38: 13:39 - return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52 } bb3: { _0 = const 2_u32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:49: 13:50 - return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52 + } + + bb4: { + return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:14:2: 14:2 + } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:12:1: 14:2 } } diff --git a/src/test/mir-opt/early_otherwise_branch_soundness.rs b/src/test/mir-opt/early_otherwise_branch_soundness.rs index d2513213d796f..cd45892324534 100644 --- a/src/test/mir-opt/early_otherwise_branch_soundness.rs +++ b/src/test/mir-opt/early_otherwise_branch_soundness.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts +// unit-test: EarlyOtherwiseBranch // Tests various cases that the `early_otherwise_branch` opt should *not* optimize diff --git a/src/test/mir-opt/if-condition-int.rs b/src/test/mir-opt/if-condition-int.rs index b34389a0ab527..398311e6bb8e2 100644 --- a/src/test/mir-opt/if-condition-int.rs +++ b/src/test/mir-opt/if-condition-int.rs @@ -1,4 +1,4 @@ -// compile-flags: -O +// unit-test: SimplifyComparisonIntegral // EMIT_MIR if_condition_int.opt_u32.SimplifyComparisonIntegral.diff // EMIT_MIR if_condition_int.opt_negative.SimplifyComparisonIntegral.diff // EMIT_MIR if_condition_int.opt_char.SimplifyComparisonIntegral.diff diff --git a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff index dddb7acae2b2c..319a47367b3ab 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff @@ -26,5 +26,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:17:25: 17:26 return; // scope 0 at $DIR/if-condition-int.rs:18:2: 18:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:16:1: 18:2 + } } diff --git a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff index 2ff8386b205bd..98a6c83cbffae 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff @@ -30,5 +30,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:53:34: 53:35 return; // scope 0 at $DIR/if-condition-int.rs:54:2: 54:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:52:1: 54:2 + } } diff --git a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff index fd4dcb2265e61..4019021ede8d5 100644 --- a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff @@ -54,5 +54,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:49:1: 49:2 return; // scope 0 at $DIR/if-condition-int.rs:49:2: 49:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:43:1: 49:2 + } } diff --git a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff index 40de48385f02e..d4f100e289f06 100644 --- a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff @@ -35,5 +35,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:21:32: 21:33 return; // scope 0 at $DIR/if-condition-int.rs:22:2: 22:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:20:1: 22:2 + } } diff --git a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff index 28c36aed84c38..06d2c666aeca6 100644 --- a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff @@ -35,5 +35,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:25:31: 25:32 return; // scope 0 at $DIR/if-condition-int.rs:26:2: 26:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:24:1: 26:2 + } } diff --git a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff index 55932fee9600c..a7e4edf40a8d6 100644 --- a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff @@ -61,5 +61,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:39:5: 39:6 return; // scope 0 at $DIR/if-condition-int.rs:40:2: 40:2 } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:32:1: 40:2 + } } diff --git a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff index c4574b32a5999..47f69b85e898c 100644 --- a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff @@ -35,5 +35,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:29:32: 29:33 return; // scope 0 at $DIR/if-condition-int.rs:30:2: 30:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:28:1: 30:2 + } } diff --git a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff index 88d9d5622b8ec..3920627d52487 100644 --- a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff @@ -35,5 +35,9 @@ StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:12:31: 12:32 return; // scope 0 at $DIR/if-condition-int.rs:13:2: 13:2 } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/if-condition-int.rs:11:1: 13:2 + } } diff --git a/src/test/mir-opt/lower_slice_len.rs b/src/test/mir-opt/lower_slice_len.rs index f2438e6974990..12955aed1fbbe 100644 --- a/src/test/mir-opt/lower_slice_len.rs +++ b/src/test/mir-opt/lower_slice_len.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=3 +// unit-test: LowerSliceLenCalls // EMIT_MIR lower_slice_len.bound.LowerSliceLenCalls.diff pub fn bound(index: usize, slice: &[u8]) -> u8 { diff --git a/src/test/mir-opt/nrvo-simple.rs b/src/test/mir-opt/nrvo-simple.rs index ab46d7b94c72c..5786ae6212705 100644 --- a/src/test/mir-opt/nrvo-simple.rs +++ b/src/test/mir-opt/nrvo-simple.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmir-opt-level=1 +// unit-test: RenameReturnPlace // EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { diff --git a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff index f438eaa002780..e07af6d598311 100644 --- a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff +++ b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff @@ -39,5 +39,9 @@ - StorageDead(_2); // scope 0 at $DIR/nrvo-simple.rs:8:1: 8:2 return; // scope 0 at $DIR/nrvo-simple.rs:8:2: 8:2 } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/nrvo-simple.rs:4:1: 8:2 + } } diff --git a/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed new file mode 100644 index 0000000000000..4963790c35de2 --- /dev/null +++ b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed @@ -0,0 +1,15 @@ +// run-rustfix +#![allow(unused)] + +trait Foo: Sized { + fn bar(i: i32, t: T, s: &Self) -> (T, i32); +} + +impl Foo for () { + fn bar(i: i32, t: usize, s: &()) -> (usize, i32) { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + (1, 2) + } +} + +fn main() {} diff --git a/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs new file mode 100644 index 0000000000000..ddf39c9c86197 --- /dev/null +++ b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs @@ -0,0 +1,15 @@ +// run-rustfix +#![allow(unused)] + +trait Foo: Sized { + fn bar(i: i32, t: T, s: &Self) -> (T, i32); +} + +impl Foo for () { + fn bar(i: _, t: _, s: _) -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + (1, 2) + } +} + +fn main() {} diff --git a/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr new file mode 100644 index 0000000000000..730836a40c26a --- /dev/null +++ b/src/test/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr @@ -0,0 +1,18 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/replace-impl-infer-ty-from-trait.rs:9:15 + | +LL | fn bar(i: _, t: _, s: _) -> _ { + | ^ ^ ^ ^ not allowed in type signatures + | | | | + | | | not allowed in type signatures + | | not allowed in type signatures + | not allowed in type signatures + | +help: try replacing `_` with the types in the corresponding trait method signature + | +LL | fn bar(i: i32, t: usize, s: &()) -> (usize, i32) { + | ~~~ ~~~~~ ~~~ ~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/regions/issue-28848.stderr b/src/test/ui/regions/issue-28848.base.stderr similarity index 84% rename from src/test/ui/regions/issue-28848.stderr rename to src/test/ui/regions/issue-28848.base.stderr index afa0c9c76b2c5..f10b19738c423 100644 --- a/src/test/ui/regions/issue-28848.stderr +++ b/src/test/ui/regions/issue-28848.base.stderr @@ -1,16 +1,16 @@ error[E0478]: lifetime bound not satisfied - --> $DIR/issue-28848.rs:10:5 + --> $DIR/issue-28848.rs:14:5 | LL | Foo::<'a, 'b>::xmute(u) | ^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'b` as defined here - --> $DIR/issue-28848.rs:9:16 + --> $DIR/issue-28848.rs:13:16 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | ^^ note: but lifetime parameter must outlive the lifetime `'a` as defined here - --> $DIR/issue-28848.rs:9:12 + --> $DIR/issue-28848.rs:13:12 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | ^^ diff --git a/src/test/ui/regions/issue-28848.nll.stderr b/src/test/ui/regions/issue-28848.nll.stderr index a29dac4c9c87c..f9de8948272af 100644 --- a/src/test/ui/regions/issue-28848.nll.stderr +++ b/src/test/ui/regions/issue-28848.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-28848.rs:10:5 + --> $DIR/issue-28848.rs:14:5 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/issue-28848.rs b/src/test/ui/regions/issue-28848.rs index a62502390302b..d8ab42a08d448 100644 --- a/src/test/ui/regions/issue-28848.rs +++ b/src/test/ui/regions/issue-28848.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo<'a, 'b: 'a>(&'a &'b ()); impl<'a, 'b> Foo<'a, 'b> { @@ -7,7 +11,9 @@ impl<'a, 'b> Foo<'a, 'b> { } pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { - Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied + Foo::<'a, 'b>::xmute(u) + //[base]~^ ERROR lifetime bound not satisfied + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.base.stderr similarity index 86% rename from src/test/ui/regions/region-invariant-static-error-reporting.stderr rename to src/test/ui/regions/region-invariant-static-error-reporting.base.stderr index 34287070eec77..ce21751a95a26 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.stderr +++ b/src/test/ui/regions/region-invariant-static-error-reporting.base.stderr @@ -1,5 +1,5 @@ error[E0308]: `if` and `else` have incompatible types - --> $DIR/region-invariant-static-error-reporting.rs:17:9 + --> $DIR/region-invariant-static-error-reporting.rs:21:9 | LL | let bad = if x.is_some() { | _______________- @@ -14,7 +14,7 @@ LL | | }; = note: expected struct `Invariant<'a>` found struct `Invariant<'static>` note: the lifetime `'a` as defined here... - --> $DIR/region-invariant-static-error-reporting.rs:13:10 + --> $DIR/region-invariant-static-error-reporting.rs:17:10 | LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { | ^^ diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr index 6e7eb734a50ea..6905fd008c525 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr +++ b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/region-invariant-static-error-reporting.rs:15:9 + --> $DIR/region-invariant-static-error-reporting.rs:19:9 | LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.rs b/src/test/ui/regions/region-invariant-static-error-reporting.rs index 911904813d0eb..b81022ca4b40b 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.rs +++ b/src/test/ui/regions/region-invariant-static-error-reporting.rs @@ -3,8 +3,12 @@ // over time, but this test used to exhibit some pretty bogus messages // that were not remotely helpful. -// error-pattern:the lifetime `'a` -// error-pattern:the static lifetime +// revisions: base nll +// ignore-compare-mode-nll +//[base] error-pattern:the lifetime `'a` +//[base] error-pattern:the static lifetime +//[nll] compile-flags: -Z borrowck=mir +//[nll] error-pattern:argument requires that `'a` must outlive `'static` struct Invariant<'a>(Option<&'a mut &'a mut ()>); @@ -12,9 +16,9 @@ fn mk_static() -> Invariant<'static> { Invariant(None) } fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { let bad = if x.is_some() { - x.unwrap() + x.unwrap() //[nll]~ ERROR borrowed data escapes outside of function [E0521] } else { - mk_static() + mk_static() //[base]~ ERROR `if` and `else` have incompatible types [E0308] }; f(bad); } diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr similarity index 85% rename from src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr rename to src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr index b83e07663faba..2ba4f4f5d9f46 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:10 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:10 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -8,7 +8,7 @@ LL | *x = *y; | ^^ ...but data from `y` flows into `x` here error[E0623]: lifetime mismatch - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:7 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:7 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -17,7 +17,7 @@ LL | a(x, y); | ^ ...but data from `y` flows into `x` here error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr index 233a040491c66..c64309743346d 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:5 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:5 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:5 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs index ab4c6d9cf9198..ec91d1798083c 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -5,19 +9,25 @@ fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y); //~ ERROR lifetime mismatch [E0623] + a(x, y); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + let _: fn(&mut &isize, &mut &isize) = a; + //~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr similarity index 98% rename from src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr rename to src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr index c93f2890f1110..537a1fb98a50f 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:10 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:10 | LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | --------- --------- these two types are declared with different lifetimes... @@ -8,7 +8,7 @@ LL | *x = *y; | ^^ ...but data from `y` flows into `x` here error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:10 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:10 | LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | --------- --------- @@ -19,7 +19,7 @@ LL | *z = *y; | ^^ ...but data from `y` flows into `z` here error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:7 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:7 | LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | --------- --------- these two types are declared with different lifetimes... @@ -28,7 +28,7 @@ LL | a(x, y, z); | ^ ...but data from `y` flows into `x` here error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:56 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^ one type is more general than the other diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr index 00119743acd78..053078f58df93 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:5 | LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:5 | LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y, z); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -46,7 +46,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr deleted file mode 100644 index 13741664ef227..0000000000000 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr +++ /dev/null @@ -1,82 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // Illegal now because there is no `'b:'a` declaration. -LL | *x = *y; - | ^^^^^^^ assignment requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:5 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | *z = *y; - | ^^^^^^^ assignment requires that `'b` must outlive `'c` - | - = help: consider adding the following bound: `'b: 'c` - -help: add bound `'b: 'a + 'c` - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 - | -LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | a(x, y, z); - | ^^^^^^^^^^ argument requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - = note: requirement occurs because of a mutable reference to &isize - = note: mutable references are invariant over their type parameter - = help: see for more information about variance - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 - | -LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | a(x, y, z); - | ^^^^^^^^^^ argument requires that `'b` must outlive `'c` - | - = help: consider adding the following bound: `'b: 'c` - = note: requirement occurs because of a mutable reference to &isize - = note: mutable references are invariant over their type parameter - = help: see for more information about variance - -help: add bound `'b: 'a + 'c` - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs index 066522548ad45..8b5c1d47ec61b 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -6,20 +10,27 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 - *z = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough + *z = *y; //[base]~ ERROR E0623 } fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y, z); //~ ERROR lifetime mismatch [E0623] + a(x, y, z); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308 + let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + //~^ ERROR E0308 + //[nll]~^^ ERROR mismatched types [E0308] + //[nll]~| ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/region-object-lifetime-2.stderr b/src/test/ui/regions/region-object-lifetime-2.base.stderr similarity index 80% rename from src/test/ui/regions/region-object-lifetime-2.stderr rename to src/test/ui/regions/region-object-lifetime-2.base.stderr index 380e27ab0e011..118fe47650048 100644 --- a/src/test/ui/regions/region-object-lifetime-2.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/region-object-lifetime-2.rs:10:7 + --> $DIR/region-object-lifetime-2.rs:14:7 | LL | x.borrowed() | ^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-2.rs:9:42 + --> $DIR/region-object-lifetime-2.rs:13:42 | LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-2.rs:10:5 + --> $DIR/region-object-lifetime-2.rs:14:5 | LL | x.borrowed() | ^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-2.rs:9:45 + --> $DIR/region-object-lifetime-2.rs:13:45 | LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-2.rs:10:5 + --> $DIR/region-object-lifetime-2.rs:14:5 | LL | x.borrowed() | ^^^^^^^^^^^^ diff --git a/src/test/ui/regions/region-object-lifetime-2.nll.stderr b/src/test/ui/regions/region-object-lifetime-2.nll.stderr index d95289f3f9def..c0b09ebb6f58b 100644 --- a/src/test/ui/regions/region-object-lifetime-2.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-2.rs:10:5 + --> $DIR/region-object-lifetime-2.rs:14:5 | LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-2.rs b/src/test/ui/regions/region-object-lifetime-2.rs index 4279848789338..e12b9822f6084 100644 --- a/src/test/ui/regions/region-object-lifetime-2.rs +++ b/src/test/ui/regions/region-object-lifetime-2.rs @@ -1,13 +1,19 @@ // Various tests related to testing how region inference works // with respect to the object receivers. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } // Borrowed receiver but two distinct lifetimes, we get an error. fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { - x.borrowed() //~ ERROR cannot infer + x.borrowed() + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-4.stderr b/src/test/ui/regions/region-object-lifetime-4.base.stderr similarity index 80% rename from src/test/ui/regions/region-object-lifetime-4.stderr rename to src/test/ui/regions/region-object-lifetime-4.base.stderr index b59163ef13b31..3765076a9c5cf 100644 --- a/src/test/ui/regions/region-object-lifetime-4.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/region-object-lifetime-4.rs:12:7 + --> $DIR/region-object-lifetime-4.rs:16:7 | LL | x.borrowed() | ^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-4.rs:11:41 + --> $DIR/region-object-lifetime-4.rs:15:41 | LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-4.rs:12:5 + --> $DIR/region-object-lifetime-4.rs:16:5 | LL | x.borrowed() | ^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-4.rs:11:44 + --> $DIR/region-object-lifetime-4.rs:15:44 | LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-4.rs:12:5 + --> $DIR/region-object-lifetime-4.rs:16:5 | LL | x.borrowed() | ^^^^^^^^^^^^ diff --git a/src/test/ui/regions/region-object-lifetime-4.nll.stderr b/src/test/ui/regions/region-object-lifetime-4.nll.stderr index fda66a2412ccb..a2a958f90b234 100644 --- a/src/test/ui/regions/region-object-lifetime-4.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-4.rs:12:5 + --> $DIR/region-object-lifetime-4.rs:16:5 | LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-4.rs b/src/test/ui/regions/region-object-lifetime-4.rs index 4fe12b2acfc69..aad9c2c95217b 100644 --- a/src/test/ui/regions/region-object-lifetime-4.rs +++ b/src/test/ui/regions/region-object-lifetime-4.rs @@ -1,6 +1,10 @@ // Various tests related to testing how region inference works // with respect to the object receivers. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } @@ -9,7 +13,9 @@ trait Foo { // with the longer lifetime when (from the signature) we only know // that it lives as long as the shorter lifetime. Therefore, error. fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { - x.borrowed() //~ ERROR cannot infer + x.borrowed() + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr similarity index 87% rename from src/test/ui/regions/region-object-lifetime-in-coercion.stderr rename to src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr index d8932c067acd8..85bfa16b3d37d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:8:46 + --> $DIR/region-object-lifetime-in-coercion.rs:12:46 | LL | fn a(v: &[u8]) -> Box { | ----- this data with an anonymous lifetime `'_`... @@ -16,7 +16,7 @@ LL | fn a(v: &'static [u8]) -> Box { | ~~~~~~~~~~~~~ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:13:14 + --> $DIR/region-object-lifetime-in-coercion.rs:19:14 | LL | fn b(v: &[u8]) -> Box { | ----- this data with an anonymous lifetime `'_`... @@ -24,7 +24,7 @@ LL | Box::new(v) | ^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/region-object-lifetime-in-coercion.rs:12:33 + --> $DIR/region-object-lifetime-in-coercion.rs:18:33 | LL | fn b(v: &[u8]) -> Box { | ^^^^^^^ `'static` requirement introduced here @@ -40,7 +40,7 @@ LL | fn b(v: &'static [u8]) -> Box { | ~~~~~~~~~~~~~ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:19:14 + --> $DIR/region-object-lifetime-in-coercion.rs:27:14 | LL | fn c(v: &[u8]) -> Box { | ----- this data with an anonymous lifetime `'_`... @@ -49,7 +49,7 @@ LL | Box::new(v) | ^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/region-object-lifetime-in-coercion.rs:16:23 + --> $DIR/region-object-lifetime-in-coercion.rs:24:23 | LL | fn c(v: &[u8]) -> Box { | ^^^^^^^ `'static` requirement introduced here @@ -62,30 +62,30 @@ LL | fn c(v: &[u8]) -> Box { | ++++ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/region-object-lifetime-in-coercion.rs:23:14 + --> $DIR/region-object-lifetime-in-coercion.rs:33:14 | LL | Box::new(v) | ^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-in-coercion.rs:22:6 + --> $DIR/region-object-lifetime-in-coercion.rs:32:6 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ note: ...so that the expression is assignable - --> $DIR/region-object-lifetime-in-coercion.rs:23:14 + --> $DIR/region-object-lifetime-in-coercion.rs:33:14 | LL | Box::new(v) | ^ = note: expected `&[u8]` found `&'a [u8]` note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-in-coercion.rs:22:9 + --> $DIR/region-object-lifetime-in-coercion.rs:32:9 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ note: ...so that the types are compatible - --> $DIR/region-object-lifetime-in-coercion.rs:23:5 + --> $DIR/region-object-lifetime-in-coercion.rs:33:5 | LL | Box::new(v) | ^^^^^^^^^^^ diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index 92588819076d3..4d72724586e9a 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:8:12 + --> $DIR/region-object-lifetime-in-coercion.rs:12:12 | LL | fn a(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -7,7 +7,7 @@ LL | let x: Box = Box::new(v); | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:13:5 + --> $DIR/region-object-lifetime-in-coercion.rs:19:5 | LL | fn b(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -15,7 +15,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:19:5 + --> $DIR/region-object-lifetime-in-coercion.rs:27:5 | LL | fn c(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -24,7 +24,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:23:5 + --> $DIR/region-object-lifetime-in-coercion.rs:33:5 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.rs b/src/test/ui/regions/region-object-lifetime-in-coercion.rs index 9d3f485e31438..ed28d6c0ff1ae 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.rs +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.rs @@ -1,26 +1,38 @@ // Test that attempts to implicitly coerce a value into an // object respect the lifetime bound on the object type. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<'a> Foo for &'a [u8] {} fn a(v: &[u8]) -> Box { - let x: Box = Box::new(v); //~ ERROR E0759 + let x: Box = Box::new(v); + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough x } fn b(v: &[u8]) -> Box { - Box::new(v) //~ ERROR E0759 + Box::new(v) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn c(v: &[u8]) -> Box { // same as previous case due to RFC 599 - Box::new(v) //~ ERROR E0759 + Box::new(v) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn d<'a,'b>(v: &'a [u8]) -> Box { - Box::new(v) //~ ERROR cannot infer an appropriate lifetime due to conflicting + Box::new(v) + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting + //[nll]~^^ ERROR lifetime may not live long enough } fn e<'a:'b,'b>(v: &'a [u8]) -> Box { diff --git a/src/test/ui/regions/regions-addr-of-self.stderr b/src/test/ui/regions/regions-addr-of-self.base.stderr similarity index 92% rename from src/test/ui/regions/regions-addr-of-self.stderr rename to src/test/ui/regions/regions-addr-of-self.base.stderr index 3453c6458f1da..3167c2f210784 100644 --- a/src/test/ui/regions/regions-addr-of-self.stderr +++ b/src/test/ui/regions/regions-addr-of-self.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-addr-of-self.rs:7:37 + --> $DIR/regions-addr-of-self.rs:11:37 | LL | pub fn chase_cat(&mut self) { | --------- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/regions/regions-addr-of-self.nll.stderr b/src/test/ui/regions/regions-addr-of-self.nll.stderr index 3d7aac74bd4f7..1f720520f6ba6 100644 --- a/src/test/ui/regions/regions-addr-of-self.nll.stderr +++ b/src/test/ui/regions/regions-addr-of-self.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-addr-of-self.rs:7:16 + --> $DIR/regions-addr-of-self.rs:11:16 | LL | pub fn chase_cat(&mut self) { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/regions/regions-addr-of-self.rs b/src/test/ui/regions/regions-addr-of-self.rs index 4eb1b275f163e..698433c71b380 100644 --- a/src/test/ui/regions/regions-addr-of-self.rs +++ b/src/test/ui/regions/regions-addr-of-self.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Dog { cats_chased: usize, } impl Dog { pub fn chase_cat(&mut self) { - let p: &'static mut usize = &mut self.cats_chased; //~ ERROR E0759 + let p: &'static mut usize = &mut self.cats_chased; + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough *p += 1; } diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.base.stderr similarity index 82% rename from src/test/ui/regions/regions-addr-of-upvar-self.stderr rename to src/test/ui/regions/regions-addr-of-upvar-self.base.stderr index f638064ef8378..42d0638e8b74c 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.stderr +++ b/src/test/ui/regions/regions-addr-of-upvar-self.base.stderr @@ -1,22 +1,22 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/regions-addr-of-upvar-self.rs:8:41 + --> $DIR/regions-addr-of-upvar-self.rs:12:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'_` as defined here... - --> $DIR/regions-addr-of-upvar-self.rs:7:18 + --> $DIR/regions-addr-of-upvar-self.rs:11:18 | LL | let _f = || { | ^^ note: ...so that closure can access `self` - --> $DIR/regions-addr-of-upvar-self.rs:8:41 + --> $DIR/regions-addr-of-upvar-self.rs:12:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that reference does not outlive borrowed content - --> $DIR/regions-addr-of-upvar-self.rs:8:41 + --> $DIR/regions-addr-of-upvar-self.rs:12:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr index c16a6f8585b69..b8e37e92316db 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr +++ b/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:20 + --> $DIR/regions-addr-of-upvar-self.rs:12:20 | LL | let _f = || { | -- lifetime `'1` represents this closure's body @@ -9,7 +9,7 @@ LL | let p: &'static mut usize = &mut self.food; = note: closure implements `FnMut`, so references to captured variables can't escape the closure error: lifetime may not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:20 + --> $DIR/regions-addr-of-upvar-self.rs:12:20 | LL | pub fn chase_cat(&mut self) { | - let's call the lifetime of this reference `'1` @@ -18,7 +18,7 @@ LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static` error[E0597]: `self` does not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:46 + --> $DIR/regions-addr-of-upvar-self.rs:12:46 | LL | let _f = || { | -- value captured here diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.rs b/src/test/ui/regions/regions-addr-of-upvar-self.rs index 6159ab02d3d95..36cc592d47c93 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.rs +++ b/src/test/ui/regions/regions-addr-of-upvar-self.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Dog { food: usize, } @@ -5,7 +9,11 @@ struct Dog { impl Dog { pub fn chase_cat(&mut self) { let _f = || { - let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + let p: &'static mut usize = &mut self.food; + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~^^^^ ERROR E0597 *p = 3; }; } diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr similarity index 74% rename from src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr rename to src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr index 68b90eee72d6d..9b45dcfd95a7a 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr @@ -1,71 +1,71 @@ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 | LL | assert_send::<&'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ error[E0477]: the type `&'a str` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 | LL | assert_send::<&'a str>(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5 | LL | assert_send::<&'a [isize]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 | LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5 | LL | assert_send::<*const &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5 | LL | assert_send::<*mut &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 | LL | fn assert_send() { } | ^^^^^^^ diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr index 86bd100538d70..558a77516bbf7 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 | LL | fn param_not_ok<'a>(x: &'a isize) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | assert_send::<&'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 | LL | fn param_not_ok1<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | assert_send::<&'a str>(); | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5 | LL | fn param_not_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -23,7 +23,7 @@ LL | assert_send::<&'a [isize]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 | LL | fn box_with_region_not_ok<'a>() { | -- lifetime `'a` defined here @@ -31,7 +31,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5 | LL | fn unsafe_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -39,7 +39,7 @@ LL | assert_send::<*const &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5 | LL | fn unsafe_ok3<'a>(_: &'a isize) { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs index c583f43638af3..37dc1300d3983 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs @@ -2,6 +2,10 @@ // in this file all test region bound and lifetime violations that are // detected during type check. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Dummy : 'static { } fn assert_send() { } @@ -19,15 +23,21 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) { // otherwise lifetime pointers are not ok fn param_not_ok<'a>(x: &'a isize) { - assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn param_not_ok1<'a>(_: &'a isize) { - assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a str>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn param_not_ok2<'a>(_: &'a isize) { - assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a [isize]>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } // boxes are ok @@ -41,7 +51,9 @@ fn box_ok() { // but not if they own a bad thing fn box_with_region_not_ok<'a>() { - assert_send::>(); //~ ERROR does not fulfill the required lifetime + assert_send::>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } // raw pointers are ok unless they point at unsendable things @@ -52,11 +64,15 @@ fn unsafe_ok1<'a>(_: &'a isize) { } fn unsafe_ok2<'a>(_: &'a isize) { - assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<*const &'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn unsafe_ok3<'a>(_: &'a isize) { - assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<*mut &'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr similarity index 98% rename from src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr rename to src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr index eb205a303dbdf..e031f0db4124c 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:7 + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:7 | LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr index 6193bf02f6d0d..4f5d747be711b 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:5 + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:5 | LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs index a7987d0e1feb0..e0965613f1dbe 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs @@ -1,4 +1,7 @@ // aux-build:rbmtp_cross_crate_lib.rs +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir // Check explicit region bounds on methods in the cross crate case. @@ -17,7 +20,9 @@ fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) { fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. - a.bigger_region(b) //~ ERROR lifetime mismatch [E0623] + a.bigger_region(b) + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr similarity index 98% rename from src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr rename to src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr index de1073cd1d9da..0a213e3f77998 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:7 + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:7 | LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr index 0e0086be9ea8d..1c2f46a5fc1b2 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:5 + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:5 | LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs index 8adf496b2304d..8a52a1549abf2 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs @@ -2,6 +2,10 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } @@ -17,7 +21,9 @@ fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. - f.method(b); //~ ERROR lifetime mismatch [E0623] + f.method(b); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr similarity index 77% rename from src/test/ui/regions/regions-bounded-method-type-parameters.stderr rename to src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr index 318e9d006a148..3d37a1ba47b14 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-method-type-parameters.rs:12:9 + --> $DIR/regions-bounded-method-type-parameters.rs:16:9 | LL | Foo.some_method::<&'a isize>(); | ^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-method-type-parameters.rs:8:22 + --> $DIR/regions-bounded-method-type-parameters.rs:12:22 | LL | fn some_method(self) { } | ^^^^^^^ diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr index b6d7b8aac5f19..05c3fa58ea363 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters.rs:12:9 + --> $DIR/regions-bounded-method-type-parameters.rs:16:9 | LL | fn caller<'a>(x: &isize) { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.rs b/src/test/ui/regions/regions-bounded-method-type-parameters.rs index 90af120f052b0..06bc1544a3807 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.rs @@ -2,6 +2,10 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo; impl Foo { @@ -10,7 +14,8 @@ impl Foo { fn caller<'a>(x: &isize) { Foo.some_method::<&'a isize>(); - //~^ ERROR does not fulfill the required lifetime + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-bounds.stderr b/src/test/ui/regions/regions-bounds.base.stderr similarity index 91% rename from src/test/ui/regions/regions-bounds.stderr rename to src/test/ui/regions/regions-bounds.base.stderr index 90227e574ad47..d853cdde336df 100644 --- a/src/test/ui/regions/regions-bounds.stderr +++ b/src/test/ui/regions/regions-bounds.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-bounds.rs:9:12 + --> $DIR/regions-bounds.rs:13:12 | LL | return e; | ^ lifetime mismatch @@ -7,18 +7,18 @@ LL | return e; = note: expected struct `TupleStruct<'b>` found struct `TupleStruct<'a>` note: the lifetime `'a` as defined here... - --> $DIR/regions-bounds.rs:8:10 + --> $DIR/regions-bounds.rs:12:10 | LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-bounds.rs:8:13 + --> $DIR/regions-bounds.rs:12:13 | LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { | ^^ error[E0308]: mismatched types - --> $DIR/regions-bounds.rs:13:12 + --> $DIR/regions-bounds.rs:19:12 | LL | return e; | ^ lifetime mismatch @@ -26,12 +26,12 @@ LL | return e; = note: expected struct `Struct<'b>` found struct `Struct<'a>` note: the lifetime `'a` as defined here... - --> $DIR/regions-bounds.rs:12:10 + --> $DIR/regions-bounds.rs:18:10 | LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-bounds.rs:12:13 + --> $DIR/regions-bounds.rs:18:13 | LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { | ^^ diff --git a/src/test/ui/regions/regions-bounds.nll.stderr b/src/test/ui/regions/regions-bounds.nll.stderr index 84226a5755319..7109220165f12 100644 --- a/src/test/ui/regions/regions-bounds.nll.stderr +++ b/src/test/ui/regions/regions-bounds.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounds.rs:9:12 + --> $DIR/regions-bounds.rs:13:12 | LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { | -- -- lifetime `'b` defined here @@ -11,7 +11,7 @@ LL | return e; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-bounds.rs:13:12 + --> $DIR/regions-bounds.rs:19:12 | LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-bounds.rs b/src/test/ui/regions/regions-bounds.rs index d3e4e6e8712bf..b13dac49f8c85 100644 --- a/src/test/ui/regions/regions-bounds.rs +++ b/src/test/ui/regions/regions-bounds.rs @@ -2,15 +2,23 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct TupleStruct<'a>(&'a isize); struct Struct<'a> { x:&'a isize } fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { - return e; //~ ERROR mismatched types + return e; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { - return e; //~ ERROR mismatched types + return e; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.stderr b/src/test/ui/regions/regions-close-associated-type-into-object.base.stderr similarity index 85% rename from src/test/ui/regions/regions-close-associated-type-into-object.stderr rename to src/test/ui/regions/regions-close-associated-type-into-object.base.stderr index 536a1b5e359cf..fbbb598040172 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.stderr +++ b/src/test/ui/regions/regions-close-associated-type-into-object.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:15:5 + --> $DIR/regions-close-associated-type-into-object.rs:19:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:22:5 + --> $DIR/regions-close-associated-type-into-object.rs:26:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | Box::new(item) = note: ...so that the type `Box<::Item>` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:28:5 + --> $DIR/regions-close-associated-type-into-object.rs:32:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:35:5 + --> $DIR/regions-close-associated-type-into-object.rs:39:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr b/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr index f7dcaa9d97e7c..dd4b97aa5628a 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr +++ b/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:15:5 + --> $DIR/regions-close-associated-type-into-object.rs:19:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:22:5 + --> $DIR/regions-close-associated-type-into-object.rs:26:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:28:5 + --> $DIR/regions-close-associated-type-into-object.rs:32:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:35:5 + --> $DIR/regions-close-associated-type-into-object.rs:39:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.rs b/src/test/ui/regions/regions-close-associated-type-into-object.rs index 428477e24899a..94199f5621228 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.rs +++ b/src/test/ui/regions/regions-close-associated-type-into-object.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait X {} diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.base.stderr similarity index 92% rename from src/test/ui/regions/regions-close-object-into-object-2.stderr rename to src/test/ui/regions/regions-close-object-into-object-2.base.stderr index 4153f4f29bc28..ddf168ffd106b 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-close-object-into-object-2.rs:9:16 + --> $DIR/regions-close-object-into-object-2.rs:13:16 | LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | ------------------ this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-close-object-into-object-2.rs:8:60 + --> $DIR/regions-close-object-into-object-2.rs:12:60 | LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr index 6a0e958616101..1a79da2776b0a 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-close-object-into-object-2.rs:9:5 + --> $DIR/regions-close-object-into-object-2.rs:13:5 | LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-2.rs:9:5 + --> $DIR/regions-close-object-into-object-2.rs:13:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-object-into-object-2.rs b/src/test/ui/regions/regions-close-object-into-object-2.rs index 9c41174e24d8d..33ea03f061e09 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.rs +++ b/src/test/ui/regions/regions-close-object-into-object-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait A { } struct B<'a, T:'a>(&'a (dyn A + 'a)); @@ -6,7 +10,10 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - Box::new(B(&*v)) as Box //~ ERROR E0759 + Box::new(B(&*v)) as Box + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] } fn main() { } diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.base.stderr similarity index 91% rename from src/test/ui/regions/regions-close-object-into-object-4.stderr rename to src/test/ui/regions/regions-close-object-into-object-4.base.stderr index 2ea4b431b38da..33d4df3d19450 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-close-object-into-object-4.rs:9:16 + --> $DIR/regions-close-object-into-object-4.rs:13:16 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | ---------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-close-object-into-object-4.rs:8:52 + --> $DIR/regions-close-object-into-object-4.rs:12:52 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 6a2429e51ecda..993b13ddbf803 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -15,7 +15,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -23,7 +23,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error: lifetime may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | -- lifetime `'a` defined here @@ -31,7 +31,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | Box::new(B(&*v)) as Box | returns a value referencing data owned by the current function error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:14 + --> $DIR/regions-close-object-into-object-4.rs:13:14 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` diff --git a/src/test/ui/regions/regions-close-object-into-object-4.rs b/src/test/ui/regions/regions-close-object-into-object-4.rs index 2a06a2b7c0513..5a852b7329a0f 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.rs +++ b/src/test/ui/regions/regions-close-object-into-object-4.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait A { } struct B<'a, T:'a>(&'a (dyn A + 'a)); @@ -6,7 +10,15 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box+'a>) -> Box { - Box::new(B(&*v)) as Box //~ ERROR E0759 + Box::new(B(&*v)) as Box + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR lifetime may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-5.stderr b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr similarity index 84% rename from src/test/ui/regions/regions-close-object-into-object-5.stderr rename to src/test/ui/regions/regions-close-object-into-object-5.base.stderr index 512a7ab35fbfd..8b5a06bab7156 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,13 +8,13 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 + --> $DIR/regions-close-object-into-object-5.rs:13:17 | LL | struct B<'a, T: 'a>(&'a (A + 'a)); | ^^ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -23,7 +23,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `B<'_, T>` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 + --> $DIR/regions-close-object-into-object-5.rs:21:14 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -32,13 +32,13 @@ LL | Box::new(B(&*v)) as Box | ^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 + --> $DIR/regions-close-object-into-object-5.rs:13:17 | LL | struct B<'a, T: 'a>(&'a (A + 'a)); | ^^ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 + --> $DIR/regions-close-object-into-object-5.rs:21:14 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -47,13 +47,13 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 + --> $DIR/regions-close-object-into-object-5.rs:13:17 | LL | struct B<'a, T: 'a>(&'a (A + 'a)); | ^^ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 + --> $DIR/regions-close-object-into-object-5.rs:21:16 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -62,7 +62,7 @@ LL | Box::new(B(&*v)) as Box | ^^^ ...so that the reference type `&dyn A` does not outlive the data it points at error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 + --> $DIR/regions-close-object-into-object-5.rs:21:16 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -71,7 +71,7 @@ LL | Box::new(B(&*v)) as Box | ^^^ ...so that the type `(dyn A + 'static)` is not borrowed for too long error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 + --> $DIR/regions-close-object-into-object-5.rs:21:16 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` diff --git a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr index 54302cc6dca22..f4e3809e91613 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,7 +8,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -17,7 +17,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -26,7 +26,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | Box::new(B(&*v)) as Box | returns a value referencing data owned by the current function error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 + --> $DIR/regions-close-object-into-object-5.rs:21:14 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` diff --git a/src/test/ui/regions/regions-close-object-into-object-5.rs b/src/test/ui/regions/regions-close-object-into-object-5.rs index 5471c375b4990..0e5fec28d19b0 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.rs +++ b/src/test/ui/regions/regions-close-object-into-object-5.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(warnings)] @@ -19,9 +23,10 @@ fn f<'a, T, U>(v: Box + 'static>) -> Box { //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] } fn main() {} diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr similarity index 89% rename from src/test/ui/regions/regions-close-over-type-parameter-1.stderr rename to src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr index 063c3b19a19cc..41dc03e86dd85 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:12:5 + --> $DIR/regions-close-over-type-parameter-1.rs:15:5 | LL | fn make_object1(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'static +` @@ -7,7 +7,7 @@ LL | Box::new(v) as Box | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:21:5 + --> $DIR/regions-close-over-type-parameter-1.rs:24:5 | LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'b +` diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr index 063c3b19a19cc..41dc03e86dd85 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:12:5 + --> $DIR/regions-close-over-type-parameter-1.rs:15:5 | LL | fn make_object1(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'static +` @@ -7,7 +7,7 @@ LL | Box::new(v) as Box | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:21:5 + --> $DIR/regions-close-over-type-parameter-1.rs:24:5 | LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'b +` diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.rs b/src/test/ui/regions/regions-close-over-type-parameter-1.rs index 52d18c5d7a6fa..cf425bcd4f342 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.rs @@ -2,6 +2,9 @@ // an object. This should yield errors unless `A` (and the object) // both have suitable bounds. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir trait SomeTrait { fn get(&self) -> isize; diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr similarity index 77% rename from src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr rename to src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr index aa22fd96deb64..171203897d7d6 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 | LL | Box::new(v) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-close-over-type-parameter-multiple.rs:18:20 + --> $DIR/regions-close-over-type-parameter-multiple.rs:21:20 | LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 | LL | Box::new(v) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: but, the lifetime must be valid for the lifetime `'c` as defined here... - --> $DIR/regions-close-over-type-parameter-multiple.rs:18:26 + --> $DIR/regions-close-over-type-parameter-multiple.rs:21:26 | LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | ^^ note: ...so that the types are compatible - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 | LL | Box::new(v) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr index 25566742099c2..66459957ed466 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 | LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs index fc7696e7e0320..3d5f4e12665b8 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs @@ -1,6 +1,9 @@ // Various tests where we over type parameters with multiple lifetime // bounds. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir trait SomeTrait { fn get(&self) -> isize; } @@ -17,7 +20,9 @@ fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { // A outlives 'a AND 'b...but not 'c. - Box::new(v) as Box //~ ERROR cannot infer an appropriate lifetime + Box::new(v) as Box + //[base]~^ ERROR cannot infer an appropriate lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-close-param-into-object.stderr b/src/test/ui/regions/regions-close-param-into-object.base.stderr similarity index 87% rename from src/test/ui/regions/regions-close-param-into-object.stderr rename to src/test/ui/regions/regions-close-param-into-object.base.stderr index 5c355bbb734b7..7e135c654505b 100644 --- a/src/test/ui/regions/regions-close-param-into-object.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:6:5 + --> $DIR/regions-close-param-into-object.rs:10:5 | LL | fn p1(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,7 +8,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:12:5 + --> $DIR/regions-close-param-into-object.rs:16:5 | LL | fn p2(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -17,7 +17,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `Box` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:18:5 + --> $DIR/regions-close-param-into-object.rs:22:5 | LL | fn p3<'a,T>(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` @@ -26,7 +26,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:24:5 + --> $DIR/regions-close-param-into-object.rs:28:5 | LL | fn p4<'a,T>(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` diff --git a/src/test/ui/regions/regions-close-param-into-object.nll.stderr b/src/test/ui/regions/regions-close-param-into-object.nll.stderr index f0464e299bbec..3fbc102263115 100644 --- a/src/test/ui/regions/regions-close-param-into-object.nll.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:6:5 + --> $DIR/regions-close-param-into-object.rs:10:5 | LL | fn p1(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,7 +8,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:12:5 + --> $DIR/regions-close-param-into-object.rs:16:5 | LL | fn p2(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -17,7 +17,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:18:5 + --> $DIR/regions-close-param-into-object.rs:22:5 | LL | fn p3<'a,T>(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` @@ -26,7 +26,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:24:5 + --> $DIR/regions-close-param-into-object.rs:28:5 | LL | fn p4<'a,T>(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` diff --git a/src/test/ui/regions/regions-close-param-into-object.rs b/src/test/ui/regions/regions-close-param-into-object.rs index 2760e5eed9595..aab3ad202e6c0 100644 --- a/src/test/ui/regions/regions-close-param-into-object.rs +++ b/src/test/ui/regions/regions-close-param-into-object.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait X { fn foo(&self) {} } fn p1(v: T) -> Box diff --git a/src/test/ui/regions/regions-creating-enums3.stderr b/src/test/ui/regions/regions-creating-enums3.base.stderr similarity index 92% rename from src/test/ui/regions/regions-creating-enums3.stderr rename to src/test/ui/regions/regions-creating-enums3.base.stderr index 2fc1fc3f68128..68a7b473695cf 100644 --- a/src/test/ui/regions/regions-creating-enums3.stderr +++ b/src/test/ui/regions/regions-creating-enums3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-creating-enums3.rs:7:5 + --> $DIR/regions-creating-enums3.rs:11:5 | LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { | ----------- ------- diff --git a/src/test/ui/regions/regions-creating-enums3.nll.stderr b/src/test/ui/regions/regions-creating-enums3.nll.stderr index 41d609b56d233..8334dc7768701 100644 --- a/src/test/ui/regions/regions-creating-enums3.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-creating-enums3.rs:7:5 + --> $DIR/regions-creating-enums3.rs:11:5 | LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-creating-enums3.rs b/src/test/ui/regions/regions-creating-enums3.rs index 3da0cb4cb8197..dcea761d33fd6 100644 --- a/src/test/ui/regions/regions-creating-enums3.rs +++ b/src/test/ui/regions/regions-creating-enums3.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + enum Ast<'a> { Num(usize), Add(&'a Ast<'a>, &'a Ast<'a>) } fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { - Ast::Add(x, y) //~ ERROR lifetime mismatch [E0623] + Ast::Add(x, y) + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-creating-enums4.stderr b/src/test/ui/regions/regions-creating-enums4.base.stderr similarity index 81% rename from src/test/ui/regions/regions-creating-enums4.stderr rename to src/test/ui/regions/regions-creating-enums4.base.stderr index 8b1b90f5b1a84..445a4291f27bb 100644 --- a/src/test/ui/regions/regions-creating-enums4.stderr +++ b/src/test/ui/regions/regions-creating-enums4.base.stderr @@ -1,28 +1,28 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-creating-enums4.rs:7:5 + --> $DIR/regions-creating-enums4.rs:11:5 | LL | Ast::Add(x, y) | ^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-creating-enums4.rs:6:16 + --> $DIR/regions-creating-enums4.rs:10:16 | LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { | ^^ note: ...so that the expression is assignable - --> $DIR/regions-creating-enums4.rs:7:14 + --> $DIR/regions-creating-enums4.rs:11:14 | LL | Ast::Add(x, y) | ^ = note: expected `&Ast<'_>` found `&Ast<'a>` note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-creating-enums4.rs:6:19 + --> $DIR/regions-creating-enums4.rs:10:19 | LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { | ^^ note: ...so that the types are compatible - --> $DIR/regions-creating-enums4.rs:7:5 + --> $DIR/regions-creating-enums4.rs:11:5 | LL | Ast::Add(x, y) | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-creating-enums4.nll.stderr b/src/test/ui/regions/regions-creating-enums4.nll.stderr index 91cf57e099df9..e215c63d39d5a 100644 --- a/src/test/ui/regions/regions-creating-enums4.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-creating-enums4.rs:7:5 + --> $DIR/regions-creating-enums4.rs:11:5 | LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-creating-enums4.rs b/src/test/ui/regions/regions-creating-enums4.rs index 11d3d83115121..18bd592b1c3eb 100644 --- a/src/test/ui/regions/regions-creating-enums4.rs +++ b/src/test/ui/regions/regions-creating-enums4.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + enum Ast<'a> { Num(usize), Add(&'a Ast<'a>, &'a Ast<'a>) } fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { - Ast::Add(x, y) //~ ERROR cannot infer + Ast::Add(x, y) + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-early-bound-error-method.stderr b/src/test/ui/regions/regions-early-bound-error-method.base.stderr similarity index 76% rename from src/test/ui/regions/regions-early-bound-error-method.stderr rename to src/test/ui/regions/regions-early-bound-error-method.base.stderr index 99a5f0ce4cd80..9e1f2b0e5bd1a 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.stderr +++ b/src/test/ui/regions/regions-early-bound-error-method.base.stderr @@ -1,16 +1,16 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-early-bound-error-method.rs:20:9 + --> $DIR/regions-early-bound-error-method.rs:24:9 | LL | g2.get() | ^^^^^^^^ | note: ...the reference is valid for the lifetime `'a` as defined here... - --> $DIR/regions-early-bound-error-method.rs:18:6 + --> $DIR/regions-early-bound-error-method.rs:22:6 | LL | impl<'a> Box<'a> { | ^^ note: ...but the borrowed content is only valid for the lifetime `'b` as defined here - --> $DIR/regions-early-bound-error-method.rs:19:11 + --> $DIR/regions-early-bound-error-method.rs:23:11 | LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { | ^^ diff --git a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr index 7f10c051f2998..98389ed0ca5b6 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-early-bound-error-method.rs:20:9 + --> $DIR/regions-early-bound-error-method.rs:24:9 | LL | impl<'a> Box<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-early-bound-error-method.rs b/src/test/ui/regions/regions-early-bound-error-method.rs index 32428143ef9d9..44ee19fa898b8 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.rs +++ b/src/test/ui/regions/regions-early-bound-error-method.rs @@ -1,6 +1,10 @@ // Tests that you can use a fn lifetime parameter as part of // the value for a type parameter in a bound. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait GetRef<'a> { fn get(&self) -> &'a isize; } @@ -18,7 +22,8 @@ impl<'a> GetRef<'a> for Box<'a> { impl<'a> Box<'a> { fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { g2.get() - //~^ ERROR E0312 + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/regions/regions-early-bound-error.stderr b/src/test/ui/regions/regions-early-bound-error.base.stderr similarity index 81% rename from src/test/ui/regions/regions-early-bound-error.stderr rename to src/test/ui/regions/regions-early-bound-error.base.stderr index df9e979eacf0f..e1b60536d296f 100644 --- a/src/test/ui/regions/regions-early-bound-error.stderr +++ b/src/test/ui/regions/regions-early-bound-error.base.stderr @@ -1,16 +1,16 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-early-bound-error.rs:19:5 + --> $DIR/regions-early-bound-error.rs:23:5 | LL | g1.get() | ^^^^^^^^ | note: ...the reference is valid for the lifetime `'b` as defined here... - --> $DIR/regions-early-bound-error.rs:18:11 + --> $DIR/regions-early-bound-error.rs:22:11 | LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { | ^^ note: ...but the borrowed content is only valid for the lifetime `'a` as defined here - --> $DIR/regions-early-bound-error.rs:18:8 + --> $DIR/regions-early-bound-error.rs:22:8 | LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { | ^^ diff --git a/src/test/ui/regions/regions-early-bound-error.nll.stderr b/src/test/ui/regions/regions-early-bound-error.nll.stderr index eb4cd5ca72ea1..f57249e4e8f77 100644 --- a/src/test/ui/regions/regions-early-bound-error.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-early-bound-error.rs:19:5 + --> $DIR/regions-early-bound-error.rs:23:5 | LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-early-bound-error.rs b/src/test/ui/regions/regions-early-bound-error.rs index 78dad4f2649d1..372596cd5f4b1 100644 --- a/src/test/ui/regions/regions-early-bound-error.rs +++ b/src/test/ui/regions/regions-early-bound-error.rs @@ -1,6 +1,10 @@ // Tests that you can use a fn lifetime parameter as part of // the value for a type parameter in a bound. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait GetRef<'a, T> { fn get(&self) -> &'a T; } @@ -17,7 +21,8 @@ impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { g1.get() - //~^ ERROR E0312 + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr similarity index 85% rename from src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr rename to src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr index c9ce936c7d43f..2182d8f661ff8 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12 + --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:12 | LL | want_G(baz); | ^^^ one type is more general than the other diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr index c2956cd89580f..0bca2cfbefd9f 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5 + --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:5 | LL | want_G(baz); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs index 539221b5a046c..05c6ac0cb1ae4 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs @@ -6,6 +6,10 @@ // This can safely be considered to be an instance of `F` because all // lifetimes are sublifetimes of 'static. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(dead_code)] #![allow(unused_variables)] diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.base.stderr similarity index 90% rename from src/test/ui/regions/regions-free-region-ordering-callee.stderr rename to src/test/ui/regions/regions-free-region-ordering-callee.base.stderr index 4648bf046bc77..ae6d95dd4691d 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-callee.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-callee.rs:13:5 + --> $DIR/regions-free-region-ordering-callee.rs:17:5 | LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { | ------------- --------- @@ -10,7 +10,7 @@ LL | &*y | ^^^ ...but data from `x` is returned here error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-callee.rs:18:24 + --> $DIR/regions-free-region-ordering-callee.rs:24:24 | LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { | --------- ------------- diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr index f61f068a4861b..7dfff2bb060d3 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-callee.rs:13:5 + --> $DIR/regions-free-region-ordering-callee.rs:17:5 | LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | &*y = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-callee.rs:18:12 + --> $DIR/regions-free-region-ordering-callee.rs:24:12 | LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.rs b/src/test/ui/regions/regions-free-region-ordering-callee.rs index ee9a977a74f2d..eca863f2e7958 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.rs +++ b/src/test/ui/regions/regions-free-region-ordering-callee.rs @@ -2,6 +2,10 @@ // that appear in their parameter list. See also // regions-free-region-ordering-caller.rs +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { // It is safe to assume that 'a <= 'b due to the type of x let y: &'b usize = &**x; @@ -10,13 +14,16 @@ fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { // However, it is not safe to assume that 'b <= 'a - &*y //~ ERROR lifetime mismatch [E0623] + &*y + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { // Do not infer an ordering from the return value. let z: &'b usize = &*x; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough panic!(); } diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr similarity index 75% rename from src/test/ui/regions/regions-free-region-ordering-incorrect.stderr rename to src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr index b0a8f4af3973d..eb4ffce89a325 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/regions-free-region-ordering-incorrect.rs:17:21 + --> $DIR/regions-free-region-ordering-incorrect.rs:21:21 | LL | None => &self.val | ^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-free-region-ordering-incorrect.rs:14:12 + --> $DIR/regions-free-region-ordering-incorrect.rs:18:12 | LL | fn get<'a>(&'a self) -> &'b T { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-free-region-ordering-incorrect.rs:17:21 + --> $DIR/regions-free-region-ordering-incorrect.rs:21:21 | LL | None => &self.val | ^^^^^^^^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-free-region-ordering-incorrect.rs:13:6 + --> $DIR/regions-free-region-ordering-incorrect.rs:17:6 | LL | impl<'b, T> Node<'b, T> { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-free-region-ordering-incorrect.rs:15:9 + --> $DIR/regions-free-region-ordering-incorrect.rs:19:9 | LL | / match self.next { LL | | Some(ref next) => next.get(), diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr index f7c75033c0486..336cfd3e6c529 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-incorrect.rs:15:9 + --> $DIR/regions-free-region-ordering-incorrect.rs:19:9 | LL | impl<'b, T> Node<'b, T> { | -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.rs b/src/test/ui/regions/regions-free-region-ordering-incorrect.rs index 65e3f52609eeb..43427d13ffa71 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.rs +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.rs @@ -5,6 +5,10 @@ // // This test began its life as a test for issue #4325. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Node<'b, T: 'b> { val: T, next: Option<&'b Node<'b, T>> @@ -12,9 +16,9 @@ struct Node<'b, T: 'b> { impl<'b, T> Node<'b, T> { fn get<'a>(&'a self) -> &'b T { - match self.next { + match self.next { //[nll]~ ERROR lifetime may not live long enough Some(ref next) => next.get(), - None => &self.val //~ ERROR cannot infer + None => &self.val //[base]~ ERROR cannot infer } } } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr similarity index 87% rename from src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr rename to src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr index ea59ea11a143c..ef68674a18f5e 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-implied-bounds-projection-gap-1.rs:16:10 + --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:10 | LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) | -- help: consider adding an explicit lifetime bound...: `T: 'x +` diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr index 0e1db8acf1fae..6d63de6d6bd95 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-implied-bounds-projection-gap-1.rs:16:5 + --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:5 | LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) | -- help: consider adding an explicit lifetime bound...: `T: 'x +` diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs index 38fc9c462da4e..f11fc207b91c6 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs @@ -3,6 +3,10 @@ // there might be other ways for the caller of `func` to show that // `T::Foo: 'x` holds (e.g., where-clause). +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Trait1<'x> { type Foo; } diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.stderr b/src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr similarity index 82% rename from src/test/ui/regions/regions-infer-bound-from-trait-self.stderr rename to src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr index 97a3947bc0a2a..faa638aa28119 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/regions-infer-bound-from-trait-self.rs:46:9 + --> $DIR/regions-infer-bound-from-trait-self.rs:50:9 | LL | check_bound(x, self) | ^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | check_bound(x, self) = help: consider adding an explicit lifetime bound `Self: 'a`... = note: ...so that the type `Self` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait-self.rs:12:21 + --> $DIR/regions-infer-bound-from-trait-self.rs:16:21 | LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } | ^^ diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr b/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr index e88f79a3a8c54..9c886c42c72ac 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/regions-infer-bound-from-trait-self.rs:46:9 + --> $DIR/regions-infer-bound-from-trait-self.rs:50:9 | LL | check_bound(x, self) | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.rs b/src/test/ui/regions/regions-infer-bound-from-trait-self.rs index d15bfffe9d926..ef8be05b2d26a 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.rs +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.rs @@ -1,6 +1,10 @@ // Test that we can derive lifetime bounds on `Self` from trait // inheritance. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Static : 'static { } trait Is<'a> : 'a { } diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr similarity index 87% rename from src/test/ui/regions/regions-infer-bound-from-trait.stderr rename to src/test/ui/regions/regions-infer-bound-from-trait.base.stderr index fd1090d2dbd17..6a7e8ba134753 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:33:5 + --> $DIR/regions-infer-bound-from-trait.rs:37:5 | LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { | - help: consider adding an explicit lifetime bound...: `A: 'a` @@ -7,13 +7,13 @@ LL | check_bound(x, a) | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait.rs:12:21 + --> $DIR/regions-infer-bound-from-trait.rs:16:21 | LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } | ^^ error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:37:5 + --> $DIR/regions-infer-bound-from-trait.rs:41:5 | LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { | -- help: consider adding an explicit lifetime bound...: `A: 'a +` @@ -21,7 +21,7 @@ LL | check_bound(x, a) | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait.rs:12:21 + --> $DIR/regions-infer-bound-from-trait.rs:16:21 | LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } | ^^ diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr index fe07749954404..4aa4b468eaa72 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:33:5 + --> $DIR/regions-infer-bound-from-trait.rs:37:5 | LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { | - help: consider adding an explicit lifetime bound...: `A: 'a` @@ -7,7 +7,7 @@ LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:37:5 + --> $DIR/regions-infer-bound-from-trait.rs:41:5 | LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { | -- help: consider adding an explicit lifetime bound...: `A: 'a +` diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.rs b/src/test/ui/regions/regions-infer-bound-from-trait.rs index 610452182f885..96f9125313bf9 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.rs +++ b/src/test/ui/regions/regions-infer-bound-from-trait.rs @@ -1,6 +1,10 @@ // Test that we can derive lifetime bounds on type parameters // from trait inheritance. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Static : 'static { } trait Is<'a> : 'a { } diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr similarity index 90% rename from src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr rename to src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr index f3a0358b90fb0..fbe2c0da6e262 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-infer-contravariance-due-to-decl.rs:25:35 + --> $DIR/regions-infer-contravariance-due-to-decl.rs:29:35 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | --------------------- these two types are declared with different lifetimes... diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr index 94b80852d0124..0b1bf5271a779 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-contravariance-due-to-decl.rs:25:12 + --> $DIR/regions-infer-contravariance-due-to-decl.rs:29:12 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs index 84161388a6e61..233f72fd29649 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; // This is contravariant with respect to 'a, meaning that @@ -22,7 +26,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR E0623 + let _: Contravariant<'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr similarity index 89% rename from src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr rename to src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr index c3e2075fbc37e..bb22e15af6991 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-infer-covariance-due-to-decl.rs:22:32 + --> $DIR/regions-infer-covariance-due-to-decl.rs:26:32 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ---------------- diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr index f44a0fad59b2e..4d72b8471dcb2 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-covariance-due-to-decl.rs:22:12 + --> $DIR/regions-infer-covariance-due-to-decl.rs:26:12 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs index b5079206578dc..c4225e76967ef 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; struct Covariant<'a> { @@ -19,7 +23,9 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR E0623 + let _: Covariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr similarity index 81% rename from src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr rename to src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr index afd522aa00316..dc7d0005ca268 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-decl.rs:12:5 + --> $DIR/regions-infer-invariance-due-to-decl.rs:16:5 | LL | b_isize | ^^^^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | b_isize = note: expected struct `Invariant<'static>` found struct `Invariant<'r>` note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-decl.rs:11:23 + --> $DIR/regions-infer-invariance-due-to-decl.rs:15:23 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | ^^ diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr index c8c7808e06c5f..d7b7f9883a763 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-decl.rs:12:5 + --> $DIR/regions-infer-invariance-due-to-decl.rs:16:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs index e0fa904e8fe37..6433773b2d186 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; struct Invariant<'a> { @@ -9,7 +13,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr similarity index 79% rename from src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr rename to src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr index 04d11b5b7c71c..b2530d7b6cd0b 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:14:5 | LL | b_isize | ^^^^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | b_isize = note: expected struct `Invariant<'static>` found struct `Invariant<'r>` note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:9:23 + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:13:23 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | ^^ diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr index 1165011c1f4fc..37fa5e3bf4477 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:14:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs index 5843598ab48e4..4690f9d8b08fc 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: Box, } @@ -7,7 +11,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr similarity index 79% rename from src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr rename to src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr index bb594f3676e37..12774ca92e232 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:14:5 | LL | b_isize | ^^^^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | b_isize = note: expected struct `Invariant<'static>` found struct `Invariant<'r>` note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:9:23 + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:13:23 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | ^^ diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr index f3973a93bad84..1b3ef7bc02894 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:14:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs index f0af18cf61804..8e257c4fd0ebe 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: Box *mut &'a isize + 'static>, } @@ -7,7 +11,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-not-param.stderr b/src/test/ui/regions/regions-infer-not-param.base.stderr similarity index 84% rename from src/test/ui/regions/regions-infer-not-param.stderr rename to src/test/ui/regions/regions-infer-not-param.base.stderr index a23bdeb834fad..f43274163d046 100644 --- a/src/test/ui/regions/regions-infer-not-param.stderr +++ b/src/test/ui/regions/regions-infer-not-param.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:15:54 + --> $DIR/regions-infer-not-param.rs:19:54 | LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | ^ lifetime mismatch @@ -7,18 +7,18 @@ LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } = note: expected struct `Direct<'b>` found struct `Direct<'a>` note: the lifetime `'a` as defined here... - --> $DIR/regions-infer-not-param.rs:15:16 + --> $DIR/regions-infer-not-param.rs:19:16 | LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-infer-not-param.rs:15:19 + --> $DIR/regions-infer-not-param.rs:19:19 | LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | ^^ error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^ lifetime mismatch @@ -26,18 +26,18 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } = note: expected struct `Indirect2<'b>` found struct `Indirect2<'a>` note: the lifetime `'a` as defined here... - --> $DIR/regions-infer-not-param.rs:19:19 + --> $DIR/regions-infer-not-param.rs:25:19 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-infer-not-param.rs:19:22 + --> $DIR/regions-infer-not-param.rs:25:22 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^ lifetime mismatch @@ -45,12 +45,12 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } = note: expected struct `Indirect2<'b>` found struct `Indirect2<'a>` note: the lifetime `'b` as defined here... - --> $DIR/regions-infer-not-param.rs:19:22 + --> $DIR/regions-infer-not-param.rs:25:22 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-infer-not-param.rs:19:19 + --> $DIR/regions-infer-not-param.rs:25:19 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ diff --git a/src/test/ui/regions/regions-infer-not-param.nll.stderr b/src/test/ui/regions/regions-infer-not-param.nll.stderr index f4875e49c3da4..95e6b03c350a3 100644 --- a/src/test/ui/regions/regions-infer-not-param.nll.stderr +++ b/src/test/ui/regions/regions-infer-not-param.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:15:54 + --> $DIR/regions-infer-not-param.rs:19:54 | LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` @@ -9,7 +9,7 @@ LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` @@ -22,7 +22,7 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` diff --git a/src/test/ui/regions/regions-infer-not-param.rs b/src/test/ui/regions/regions-infer-not-param.rs index 7643be64d5b23..0b8af5bc152ba 100644 --- a/src/test/ui/regions/regions-infer-not-param.rs +++ b/src/test/ui/regions/regions-infer-not-param.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Direct<'a> { f: &'a isize } @@ -12,15 +16,20 @@ struct Indirect2<'a> { g: Box) + 'static> } -fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } //~ ERROR mismatched types +fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } +//[base]~^ ERROR mismatched types +//[nll]~^^ ERROR lifetime may not live long enough fn take_indirect1(p: Indirect1) -> Indirect1 { p } -fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } //~ ERROR mismatched types -//~| expected struct `Indirect2<'b>` -//~| found struct `Indirect2<'a>` -//~| ERROR mismatched types -//~| expected struct `Indirect2<'b>` -//~| found struct `Indirect2<'a>` +fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } +//[base]~^ ERROR mismatched types +//[base]~| expected struct `Indirect2<'b>` +//[base]~| found struct `Indirect2<'a>` +//[base]~| ERROR mismatched types +//[base]~| expected struct `Indirect2<'b>` +//[base]~| found struct `Indirect2<'a>` +//[nll]~^^^^^^^ ERROR lifetime may not live long enough +//[nll]~| ERROR lifetime may not live long enough fn main() {} diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.base.stderr similarity index 79% rename from src/test/ui/regions/regions-infer-paramd-indirect.stderr rename to src/test/ui/regions/regions-infer-paramd-indirect.base.stderr index d2b369fb07b9c..1d4471f910d30 100644 --- a/src/test/ui/regions/regions-infer-paramd-indirect.stderr +++ b/src/test/ui/regions/regions-infer-paramd-indirect.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-infer-paramd-indirect.rs:22:18 + --> $DIR/regions-infer-paramd-indirect.rs:26:18 | LL | self.f = b; | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | self.f = b; = note: expected struct `Box>` found struct `Box>` note: the anonymous lifetime defined here... - --> $DIR/regions-infer-paramd-indirect.rs:21:36 + --> $DIR/regions-infer-paramd-indirect.rs:25:36 | LL | fn set_f_bad(&mut self, b: Box) { | ^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-infer-paramd-indirect.rs:16:6 + --> $DIR/regions-infer-paramd-indirect.rs:20:6 | LL | impl<'a> SetF<'a> for C<'a> { | ^^ diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr index afabdc1de1c7d..96377cbdab4ae 100644 --- a/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr +++ b/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-paramd-indirect.rs:22:9 + --> $DIR/regions-infer-paramd-indirect.rs:26:9 | LL | impl<'a> SetF<'a> for C<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.rs b/src/test/ui/regions/regions-infer-paramd-indirect.rs index 3b18bbf1df3d0..060306f611e1d 100644 --- a/src/test/ui/regions/regions-infer-paramd-indirect.rs +++ b/src/test/ui/regions/regions-infer-paramd-indirect.rs @@ -1,6 +1,10 @@ // Check that we correctly infer that b and c must be region // parameterized because they reference a which requires a region. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + type A<'a> = &'a isize; type B<'a> = Box>; @@ -20,10 +24,11 @@ impl<'a> SetF<'a> for C<'a> { fn set_f_bad(&mut self, b: Box) { self.f = b; - //~^ ERROR mismatched types - //~| expected struct `Box>` - //~| found struct `Box>` - //~| lifetime mismatch + //[base]~^ ERROR mismatched types + //[base]~| expected struct `Box>` + //[base]~| found struct `Box>` + //[base]~| lifetime mismatch + //[nll]~^^^^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr similarity index 88% rename from src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr rename to src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr index 2b2dd0dbbf250..e57b06aac3927 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-lifetime-bounds-on-fns.rs:8:10 + --> $DIR/regions-lifetime-bounds-on-fns.rs:12:10 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -8,7 +8,7 @@ LL | *x = *y; | ^^ ...but data from `y` flows into `x` here error[E0623]: lifetime mismatch - --> $DIR/regions-lifetime-bounds-on-fns.rs:14:7 + --> $DIR/regions-lifetime-bounds-on-fns.rs:20:7 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -17,7 +17,7 @@ LL | a(x, y); | ^ ...but data from `y` flows into `x` here error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:43 + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr index ee3dcef1cb5c4..7fe8b4bf57fc1 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-lifetime-bounds-on-fns.rs:8:5 + --> $DIR/regions-lifetime-bounds-on-fns.rs:12:5 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-lifetime-bounds-on-fns.rs:14:5 + --> $DIR/regions-lifetime-bounds-on-fns.rs:20:5 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:12 + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:12 + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs index 7d7f62e19792f..97c08d8ab0e3c 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -5,19 +9,25 @@ fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y); //~ ERROR lifetime mismatch [E0623] + a(x, y); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR E0308 + let _: fn(&mut &isize, &mut &isize) = a; + //~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.base.stderr similarity index 85% rename from src/test/ui/regions/regions-nested-fns.stderr rename to src/test/ui/regions/regions-nested-fns.base.stderr index 11affcaaa79ca..37ce569e761ba 100644 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ b/src/test/ui/regions/regions-nested-fns.base.stderr @@ -1,40 +1,46 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-nested-fns.rs:5:18 + --> $DIR/regions-nested-fns.rs:9:18 | LL | let mut ay = &y; | ^^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:7:58 + --> $DIR/regions-nested-fns.rs:13:58 | LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { | __________________________________________________________^ LL | | ay = x; LL | | ay = &y; +LL | | LL | | ay = z; +LL | | LL | | })); | |_____^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-nested-fns.rs:10:14 + --> $DIR/regions-nested-fns.rs:17:14 | LL | ay = z; | ^ note: but, the lifetime must be valid for the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:13:72 + --> $DIR/regions-nested-fns.rs:21:72 | LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { | ________________________________________________________________________^ LL | | if false { return x; } +LL | | +LL | | LL | | if false { return ay; } LL | | return z; LL | | })); | |_____^ note: ...so that the types are compatible - --> $DIR/regions-nested-fns.rs:13:76 + --> $DIR/regions-nested-fns.rs:21:76 | LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { | ____________________________________________________________________________^ LL | | if false { return x; } +LL | | +LL | | LL | | if false { return ay; } LL | | return z; LL | | })); @@ -43,23 +49,25 @@ LL | | })); found `&isize` error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-nested-fns.rs:14:27 + --> $DIR/regions-nested-fns.rs:22:27 | LL | if false { return x; } | ^ | note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:13:72 + --> $DIR/regions-nested-fns.rs:21:72 | LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { | ________________________________________________________________________^ LL | | if false { return x; } +LL | | +LL | | LL | | if false { return ay; } LL | | return z; LL | | })); | |_____^ note: ...but the borrowed content is only valid for the lifetime `'x` as defined here - --> $DIR/regions-nested-fns.rs:3:11 + --> $DIR/regions-nested-fns.rs:7:11 | LL | fn nested<'x>(x: &'x isize) { | ^^ diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index a0cfa36247228..6f2a89994b047 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -1,9 +1,9 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/regions-nested-fns.rs:10:9 + --> $DIR/regions-nested-fns.rs:17:9 | LL | let mut ay = &y; | ------ `ay` declared here, outside of the closure body -LL | +... LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { | - `z` is a reference that is only valid in the closure body ... @@ -11,7 +11,7 @@ LL | ay = z; | ^^^^^^ `z` escapes the closure body here error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:5:18 + --> $DIR/regions-nested-fns.rs:9:18 | LL | let mut ay = &y; | ^^ borrowed value does not live long enough @@ -23,7 +23,7 @@ LL | } | - `y` dropped here while still borrowed error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:9:15 + --> $DIR/regions-nested-fns.rs:15:15 | LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { | --- value captured here @@ -38,7 +38,7 @@ LL | } | - `y` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/regions-nested-fns.rs:14:27 + --> $DIR/regions-nested-fns.rs:22:27 | LL | fn nested<'x>(x: &'x isize) { | -- lifetime `'x` defined here diff --git a/src/test/ui/regions/regions-nested-fns.rs b/src/test/ui/regions/regions-nested-fns.rs index c02d4e0ce453b..8cc39792bd978 100644 --- a/src/test/ui/regions/regions-nested-fns.rs +++ b/src/test/ui/regions/regions-nested-fns.rs @@ -1,17 +1,27 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn ignore(t: T) {} fn nested<'x>(x: &'x isize) { let y = 3; - let mut ay = &y; //~ ERROR E0495 + let mut ay = &y; + //[base]~^ ERROR E0495 + //[nll]~^^ ERROR `y` does not live long enough [E0597] ignore:: FnMut(&'z isize)>>(Box::new(|z| { ay = x; ay = &y; + //[nll]~^ ERROR `y` does not live long enough ay = z; + //[nll]~^ ERROR borrowed data escapes outside of closure [E0521] })); ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - if false { return x; } //~ ERROR E0312 + if false { return x; } + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough if false { return ay; } return z; })); diff --git a/src/test/ui/regions/regions-outlives-projection-container.stderr b/src/test/ui/regions/regions-outlives-projection-container.base.stderr similarity index 75% rename from src/test/ui/regions/regions-outlives-projection-container.stderr rename to src/test/ui/regions/regions-outlives-projection-container.base.stderr index 8c2b2c1e24ae1..9a66f67ea6ec4 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container.base.stderr @@ -1,67 +1,67 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:36:13 + --> $DIR/regions-outlives-projection-container.rs:40:13 | LL | let _x: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:28:15 + --> $DIR/regions-outlives-projection-container.rs:32:15 | LL | fn with_assoc<'a,'b>() { | ^^ note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:28:18 + --> $DIR/regions-outlives-projection-container.rs:32:18 | LL | fn with_assoc<'a,'b>() { | ^^ error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:54:13 + --> $DIR/regions-outlives-projection-container.rs:59:13 | LL | let _x: &'a WithoutAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:50:18 + --> $DIR/regions-outlives-projection-container.rs:55:18 | LL | fn without_assoc<'a,'b>() { | ^^ note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:50:21 + --> $DIR/regions-outlives-projection-container.rs:55:21 | LL | fn without_assoc<'a,'b>() { | ^^ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:63:12 + --> $DIR/regions-outlives-projection-container.rs:69:12 | LL | call::<&'a WithAssoc>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:58:20 + --> $DIR/regions-outlives-projection-container.rs:64:20 | LL | fn call_with_assoc<'a,'b>() { | ^^ note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:58:23 + --> $DIR/regions-outlives-projection-container.rs:64:23 | LL | fn call_with_assoc<'a,'b>() { | ^^ error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:70:12 + --> $DIR/regions-outlives-projection-container.rs:77:12 | LL | call::<&'a WithoutAssoc>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:67:23 + --> $DIR/regions-outlives-projection-container.rs:74:23 | LL | fn call_without_assoc<'a,'b>() { | ^^ note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:67:26 + --> $DIR/regions-outlives-projection-container.rs:74:26 | LL | fn call_without_assoc<'a,'b>() { | ^^ diff --git a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr index 073a31900227e..d93eef9ce0b5c 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:36:13 + --> $DIR/regions-outlives-projection-container.rs:40:13 | LL | fn with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let _x: &'a WithAssoc> = loop { }; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:54:13 + --> $DIR/regions-outlives-projection-container.rs:59:13 | LL | fn without_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -25,7 +25,7 @@ LL | let _x: &'a WithoutAssoc> = loop { }; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:63:5 + --> $DIR/regions-outlives-projection-container.rs:69:5 | LL | fn call_with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -38,7 +38,7 @@ LL | call::<&'a WithAssoc>>(); = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:70:5 + --> $DIR/regions-outlives-projection-container.rs:77:5 | LL | fn call_without_assoc<'a,'b>() { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-outlives-projection-container.rs b/src/test/ui/regions/regions-outlives-projection-container.rs index 3afc600becb6e..ccfd2213b6f33 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.rs +++ b/src/test/ui/regions/regions-outlives-projection-container.rs @@ -2,6 +2,10 @@ // type of a bound that appears in the where clause on a struct must // outlive the location in which the type appears. Issue #22246. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(dead_code)] #![feature(rustc_attrs)] @@ -34,7 +38,8 @@ fn with_assoc<'a,'b>() { // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if // `_x` is changed to `_` let _x: &'a WithAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn with_assoc1<'a,'b>() where 'b : 'a { @@ -52,7 +57,8 @@ fn without_assoc<'a,'b>() { // that `'b:'a` holds because the `'b` appears in `TheType<'b>`. let _x: &'a WithoutAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call_with_assoc<'a,'b>() { @@ -61,13 +67,16 @@ fn call_with_assoc<'a,'b>() { // no data. call::<&'a WithAssoc>>(); - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call_without_assoc<'a,'b>() { // As `without_assoc`, but in a distinct scenario. - call::<&'a WithoutAssoc>>(); //~ ERROR reference has a longer lifetime + call::<&'a WithoutAssoc>>(); + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call() { } diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.base.stderr similarity index 93% rename from src/test/ui/regions/regions-proc-bound-capture.stderr rename to src/test/ui/regions/regions-proc-bound-capture.base.stderr index 2ebe874da9350..427c6f4ec8c3c 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-proc-bound-capture.rs:9:14 + --> $DIR/regions-proc-bound-capture.rs:13:14 | LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { | ------ this data with an anonymous lifetime `'_`... @@ -8,7 +8,7 @@ LL | Box::new(move || { *x }) | ^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-proc-bound-capture.rs:7:59 + --> $DIR/regions-proc-bound-capture.rs:11:59 | LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/regions/regions-proc-bound-capture.nll.stderr b/src/test/ui/regions/regions-proc-bound-capture.nll.stderr index 75890b8581537..6120a53eb0955 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.nll.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-proc-bound-capture.rs:9:5 + --> $DIR/regions-proc-bound-capture.rs:13:5 | LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs index 55d964ac53405..1033163c8dd9c 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.rs +++ b/src/test/ui/regions/regions-proc-bound-capture.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. @@ -6,7 +10,9 @@ fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { fn static_proc(x: &isize) -> Box (isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. - Box::new(move || { *x }) //~ ERROR E0759 + Box::new(move || { *x }) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr similarity index 89% rename from src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr rename to src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr index aca3a1ed05728..7ecdb0cd15e9e 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:4:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:8:5 | LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { | ----------------------------- ------------- diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr index dc905d076bb7d..519ada7bdfc96 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:4:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:8:5 | LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs index 35aca8be25beb..c4ad05010fb6d 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs @@ -1,7 +1,13 @@ // Issue #8624. Test for reborrowing with 3 levels, not just two. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { - &mut ***p //~ ERROR lifetime mismatch [E0623] + &mut ***p + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr similarity index 90% rename from src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr rename to src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr index a9916dbe4f5ef..3cb7de1585090 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:6:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:10:5 | LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { | --------------------- ------------- diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr index c98ec477417bd..4dd2a83739ca7 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:6:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:10:5 | LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs index 77041ab4f05cb..c41e76e4d2a11 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs @@ -2,8 +2,14 @@ // pointer which is backed by another `&'a mut` can only be done // for `'a` (which must be a sublifetime of `'b`). +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { - &mut **p //~ ERROR lifetime mismatch [E0623] + &mut **p + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-ret-borrowed-1.stderr b/src/test/ui/regions/regions-ret-borrowed-1.base.stderr similarity index 78% rename from src/test/ui/regions/regions-ret-borrowed-1.stderr rename to src/test/ui/regions/regions-ret-borrowed-1.base.stderr index 86df7bfeb7062..d102f93a64771 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.stderr +++ b/src/test/ui/regions/regions-ret-borrowed-1.base.stderr @@ -1,28 +1,28 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-ret-borrowed-1.rs:10:14 + --> $DIR/regions-ret-borrowed-1.rs:14:14 | LL | with(|o| o) | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-ret-borrowed-1.rs:10:10 + --> $DIR/regions-ret-borrowed-1.rs:14:10 | LL | with(|o| o) | ^^^^^ note: ...so that the types are compatible - --> $DIR/regions-ret-borrowed-1.rs:10:14 + --> $DIR/regions-ret-borrowed-1.rs:14:14 | LL | with(|o| o) | ^ = note: expected `&isize` found `&isize` note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/regions-ret-borrowed-1.rs:9:14 + --> $DIR/regions-ret-borrowed-1.rs:13:14 | LL | fn return_it<'a>() -> &'a isize { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-ret-borrowed-1.rs:10:5 + --> $DIR/regions-ret-borrowed-1.rs:14:5 | LL | with(|o| o) | ^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr b/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr index 0784e894ea920..4fdadccab15f9 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr +++ b/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-ret-borrowed-1.rs:10:14 + --> $DIR/regions-ret-borrowed-1.rs:14:14 | LL | with(|o| o) | -- ^ returning this value requires that `'1` must outlive `'2` diff --git a/src/test/ui/regions/regions-ret-borrowed-1.rs b/src/test/ui/regions/regions-ret-borrowed-1.rs index 1be5edee599c4..fed631320b442 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.rs +++ b/src/test/ui/regions/regions-ret-borrowed-1.rs @@ -2,13 +2,18 @@ // some point regions-ret-borrowed reported an error but this file did // not, due to special hardcoding around the anonymous region. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R { f(&3) } fn return_it<'a>() -> &'a isize { with(|o| o) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements [E0495] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-ret-borrowed.stderr b/src/test/ui/regions/regions-ret-borrowed.base.stderr similarity index 79% rename from src/test/ui/regions/regions-ret-borrowed.stderr rename to src/test/ui/regions/regions-ret-borrowed.base.stderr index b9a06d974334c..62b42b5dd1171 100644 --- a/src/test/ui/regions/regions-ret-borrowed.stderr +++ b/src/test/ui/regions/regions-ret-borrowed.base.stderr @@ -1,28 +1,28 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-ret-borrowed.rs:13:14 + --> $DIR/regions-ret-borrowed.rs:17:14 | LL | with(|o| o) | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-ret-borrowed.rs:13:10 + --> $DIR/regions-ret-borrowed.rs:17:10 | LL | with(|o| o) | ^^^^^ note: ...so that the types are compatible - --> $DIR/regions-ret-borrowed.rs:13:14 + --> $DIR/regions-ret-borrowed.rs:17:14 | LL | with(|o| o) | ^ = note: expected `&isize` found `&isize` note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/regions-ret-borrowed.rs:12:14 + --> $DIR/regions-ret-borrowed.rs:16:14 | LL | fn return_it<'a>() -> &'a isize { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-ret-borrowed.rs:13:5 + --> $DIR/regions-ret-borrowed.rs:17:5 | LL | with(|o| o) | ^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-ret-borrowed.nll.stderr b/src/test/ui/regions/regions-ret-borrowed.nll.stderr index d9be5ef89cceb..d3ea5bd875f9b 100644 --- a/src/test/ui/regions/regions-ret-borrowed.nll.stderr +++ b/src/test/ui/regions/regions-ret-borrowed.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-ret-borrowed.rs:13:14 + --> $DIR/regions-ret-borrowed.rs:17:14 | LL | with(|o| o) | -- ^ returning this value requires that `'1` must outlive `'2` diff --git a/src/test/ui/regions/regions-ret-borrowed.rs b/src/test/ui/regions/regions-ret-borrowed.rs index 5fca92d68b65c..2b6855d1c71ef 100644 --- a/src/test/ui/regions/regions-ret-borrowed.rs +++ b/src/test/ui/regions/regions-ret-borrowed.rs @@ -5,13 +5,18 @@ // used to successfully compile because we failed to account for the // fact that fn(x: &isize) rebound the region &. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with(f: F) -> R where F: FnOnce(&isize) -> R { f(&3) } fn return_it<'a>() -> &'a isize { with(|o| o) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements [E0495] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-static-bound.stderr b/src/test/ui/regions/regions-static-bound.base.stderr similarity index 86% rename from src/test/ui/regions/regions-static-bound.stderr rename to src/test/ui/regions/regions-static-bound.base.stderr index b8e69e02609d6..b37ce1e76bdfd 100644 --- a/src/test/ui/regions/regions-static-bound.stderr +++ b/src/test/ui/regions/regions-static-bound.base.stderr @@ -1,18 +1,18 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-static-bound.rs:6:5 + --> $DIR/regions-static-bound.rs:10:5 | LL | t | ^ | = note: ...the reference is valid for the static lifetime... note: ...but the borrowed content is only valid for the lifetime `'a` as defined here - --> $DIR/regions-static-bound.rs:5:24 + --> $DIR/regions-static-bound.rs:9:24 | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | ^^ error[E0759]: `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:16:5 | LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... @@ -20,22 +20,22 @@ LL | static_id(&u); | ^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:16:5 | LL | static_id(&u); | ^^^^^^^^^ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:11:5 + --> $DIR/regions-static-bound.rs:19:5 | LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... -LL | static_id(&u); +... LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:11:5 + --> $DIR/regions-static-bound.rs:19:5 | LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index 699638c7ef9b2..d228c42f99579 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-static-bound.rs:6:5 + --> $DIR/regions-static-bound.rs:10:5 | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | t | ^ returning this value requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:16:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'1` @@ -20,13 +20,13 @@ LL | static_id(&u); | argument requires that `'1` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:11:5 + --> $DIR/regions-static-bound.rs:19:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'2` | | | `v` is a reference that is only valid in the function body -LL | static_id(&u); +... LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^^^^^ | | diff --git a/src/test/ui/regions/regions-static-bound.rs b/src/test/ui/regions/regions-static-bound.rs index a977a8b36d056..058b717c95daa 100644 --- a/src/test/ui/regions/regions-static-bound.rs +++ b/src/test/ui/regions/regions-static-bound.rs @@ -1,14 +1,24 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t } fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - t //~ ERROR E0312 + t + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } fn error(u: &(), v: &()) { - static_id(&u); //~ ERROR `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] - static_id_indirect(&v); //~ ERROR `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + static_id(&u); + //[base]~^ ERROR `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes outside of function [E0521] + static_id_indirect(&v); + //[base]~^ ERROR `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes outside of function [E0521] } fn main() {} diff --git a/src/test/ui/regions/regions-trait-object-subtyping.stderr b/src/test/ui/regions/regions-trait-object-subtyping.base.stderr similarity index 76% rename from src/test/ui/regions/regions-trait-object-subtyping.stderr rename to src/test/ui/regions/regions-trait-object-subtyping.base.stderr index d45ca94ad27fa..9f52136f0c08b 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.base.stderr @@ -1,43 +1,43 @@ error[E0478]: lifetime bound not satisfied - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | x | ^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/regions-trait-object-subtyping.rs:13:9 + --> $DIR/regions-trait-object-subtyping.rs:17:9 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: but lifetime parameter must outlive the lifetime `'b` as defined here - --> $DIR/regions-trait-object-subtyping.rs:13:12 + --> $DIR/regions-trait-object-subtyping.rs:17:12 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | x | ^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:13:9 + --> $DIR/regions-trait-object-subtyping.rs:17:9 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | x | ^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:13:12 + --> $DIR/regions-trait-object-subtyping.rs:17:12 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: ...so that the types are compatible - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | x | ^ @@ -45,7 +45,7 @@ LL | x found `&mut (dyn Dummy + 'b)` error[E0308]: mismatched types - --> $DIR/regions-trait-object-subtyping.rs:22:5 + --> $DIR/regions-trait-object-subtyping.rs:28:5 | LL | x | ^ lifetime mismatch @@ -53,12 +53,12 @@ LL | x = note: expected struct `Wrapper<&'b mut (dyn Dummy + 'b)>` found struct `Wrapper<&'a mut (dyn Dummy + 'a)>` note: the lifetime `'b` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:20:15 + --> $DIR/regions-trait-object-subtyping.rs:26:15 | LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-trait-object-subtyping.rs:20:9 + --> $DIR/regions-trait-object-subtyping.rs:26:9 | LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ diff --git a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr index 1b3a116d508fa..c8cec3bd37797 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | x = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/regions-trait-object-subtyping.rs:22:5 + --> $DIR/regions-trait-object-subtyping.rs:28:5 | LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-trait-object-subtyping.rs b/src/test/ui/regions/regions-trait-object-subtyping.rs index 5b36194870ef6..f108fc81cea4f 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.rs +++ b/src/test/ui/regions/regions-trait-object-subtyping.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Dummy { fn dummy(&self); } fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { @@ -12,14 +16,18 @@ fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { // Without knowing 'a:'b, we can't coerce - x //~ ERROR lifetime bound not satisfied - //~^ ERROR cannot infer an appropriate lifetime + x + //[base]~^ ERROR lifetime bound not satisfied + //[base]~| ERROR cannot infer an appropriate lifetime + //[nll]~^^^ ERROR lifetime may not live long enough } struct Wrapper(T); fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { // We can't coerce because it is packed in `Wrapper` - x //~ ERROR mismatched types + x + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr similarity index 96% rename from src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr rename to src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr index 98f7a8136da91..23b3dea885d79 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:30 + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:29:30 | LL | fn use_<'short,'long>(c: S<'long, 'short>, | ---------------- this type is declared with multiple lifetimes... diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr index 5352be430fbc5..f364f423f4ecf 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:12 + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:29:12 | LL | fn use_<'short,'long>(c: S<'long, 'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs index 8ddd041d45731..4bf32ec308247 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // `S` is contravariant with respect to both parameters. struct S<'a, 'b> { f: &'a isize, @@ -22,7 +26,9 @@ fn use_<'short,'long>(c: S<'long, 'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: S<'long, 'long> = c; //~ ERROR E0623 + let _: S<'long, 'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr similarity index 89% rename from src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr rename to src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr index e7c106cbbe3d1..8eca0d4d12125 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant.rs:23:35 + --> $DIR/regions-variance-contravariant-use-covariant.rs:27:35 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | --------------------- these two types are declared with different lifetimes... diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr index 22c9b915bb9ee..bc6dd6e69ed08 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-contravariant-use-covariant.rs:23:12 + --> $DIR/regions-variance-contravariant-use-covariant.rs:27:12 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs index cbdf62ecb613f..ea08a7092305e 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // This is contravariant with respect to 'a, meaning that // Contravariant<'long> <: Contravariant<'short> iff // 'short <= 'long @@ -20,7 +24,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR E0623 + let _: Contravariant<'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr similarity index 88% rename from src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr rename to src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr index e5e5261ba993f..565de38ee11df 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-covariant-use-contravariant.rs:23:32 + --> $DIR/regions-variance-covariant-use-contravariant.rs:27:32 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ---------------- diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr index a07181ad553e6..9d3cebc9a4d56 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-covariant-use-contravariant.rs:23:12 + --> $DIR/regions-variance-covariant-use-contravariant.rs:27:12 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs index 9aa0c81927197..748ad84840a07 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // This is covariant with respect to 'a, meaning that // Covariant<'foo> <: Covariant<'static> because // 'foo <= 'static @@ -20,7 +24,9 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR E0623 + let _: Covariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr similarity index 88% rename from src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr rename to src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr index 2a2d5d019a129..e2e8958f53eca 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-invariant-use-contravariant.rs:20:32 + --> $DIR/regions-variance-invariant-use-contravariant.rs:24:32 | LL | fn use_<'short,'long>(c: Invariant<'long>, | ---------------- diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr index b35a2cb905dc3..b4ccb1693a753 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-invariant-use-contravariant.rs:20:12 + --> $DIR/regions-variance-invariant-use-contravariant.rs:24:12 | LL | fn use_<'short,'long>(c: Invariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs index 663b23b37d46a..788f9b1b4d0f3 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: &'a mut &'a isize } @@ -17,7 +21,9 @@ fn use_<'short,'long>(c: Invariant<'long>, // 'short <= 'long, this would be true if the Invariant type were // contravariant with respect to its parameter 'a. - let _: Invariant<'short> = c; //~ ERROR E0623 + let _: Invariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr similarity index 80% rename from src/test/ui/regions/regions-variance-invariant-use-covariant.stderr rename to src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr index 7801517595d33..da91db1b91862 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-variance-invariant-use-covariant.rs:17:33 + --> $DIR/regions-variance-invariant-use-covariant.rs:21:33 | LL | let _: Invariant<'static> = c; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | let _: Invariant<'static> = c; = note: expected struct `Invariant<'static>` found struct `Invariant<'b>` note: the lifetime `'b` as defined here... - --> $DIR/regions-variance-invariant-use-covariant.rs:11:9 + --> $DIR/regions-variance-invariant-use-covariant.rs:15:9 | LL | fn use_<'b>(c: Invariant<'b>) { | ^^ diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr index 761e78d179e41..7b05c357589e9 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-invariant-use-covariant.rs:17:12 + --> $DIR/regions-variance-invariant-use-covariant.rs:21:12 | LL | fn use_<'b>(c: Invariant<'b>) { | -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.rs b/src/test/ui/regions/regions-variance-invariant-use-covariant.rs index 07482e6fd19e1..4b7da4493acff 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: &'a mut &'a isize } @@ -14,7 +18,9 @@ fn use_<'b>(c: Invariant<'b>) { // Since 'b <= 'static, this would be true if Invariant were covariant // with respect to its parameter 'a. - let _: Invariant<'static> = c; //~ ERROR mismatched types + let _: Invariant<'static> = c; + //[base]~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.rs b/src/test/ui/typeck/typeck_type_placeholder_item.rs index ca0876be58df9..22fedb22d66c6 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.rs +++ b/src/test/ui/typeck/typeck_type_placeholder_item.rs @@ -57,7 +57,7 @@ unsafe fn test12(x: *const usize) -> *const *const _ { impl Clone for Test9 { fn clone(&self) -> _ { Test9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn clone_from(&mut self, other: _) { *self = Test9; } //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions @@ -113,7 +113,7 @@ pub fn main() { impl Clone for FnTest9 { fn clone(&self) -> _ { FnTest9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn clone_from(&mut self, other: _) { *self = FnTest9; } //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index c07b96f9a977a..3ea317dfb1a5d 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -545,14 +545,16 @@ help: use type parameters instead LL | fn test10(&self, _x : T) { } | +++ ~ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:59:24 | LL | fn clone(&self) -> _ { Test9 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `Test9` + | ^ not allowed in type signatures + | +help: try replacing `_` with the type in the corresponding trait method signature + | +LL | fn clone(&self) -> Test9 { Test9 } + | ~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:62:37 @@ -560,10 +562,10 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | fn clone_from(&mut self, other: _) { *self = Test9; } | ^ not allowed in type signatures | -help: use type parameters instead +help: try replacing `_` with the type in the corresponding trait method signature | -LL | fn clone_from(&mut self, other: T) { *self = Test9; } - | +++ ~ +LL | fn clone_from(&mut self, other: &Test9) { *self = Test9; } + | ~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:107:31 @@ -585,14 +587,16 @@ help: use type parameters instead LL | fn fn_test10(&self, _x : T) { } | +++ ~ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:115:28 | LL | fn clone(&self) -> _ { FnTest9 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `FnTest9` + | ^ not allowed in type signatures + | +help: try replacing `_` with the type in the corresponding trait method signature + | +LL | fn clone(&self) -> FnTest9 { FnTest9 } + | ~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:118:41 @@ -600,10 +604,10 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | fn clone_from(&mut self, other: _) { *self = FnTest9; } | ^ not allowed in type signatures | -help: use type parameters instead +help: try replacing `_` with the type in the corresponding trait method signature | -LL | fn clone_from(&mut self, other: T) { *self = FnTest9; } - | +++ ~ +LL | fn clone_from(&mut self, other: &FnTest9) { *self = FnTest9; } + | ~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/typeck_type_placeholder_item.rs:201:14 diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 858a576dcb474..e6f058569dbd8 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -157,6 +157,8 @@ pub struct TestProps { pub should_ice: bool, // If true, the stderr is expected to be different across bit-widths. pub stderr_per_bitwidth: bool, + // The MIR opt to unit test, if any + pub mir_unit_test: Option, } mod directives { @@ -189,6 +191,7 @@ mod directives { pub const STDERR_PER_BITWIDTH: &'static str = "stderr-per-bitwidth"; pub const INCREMENTAL: &'static str = "incremental"; pub const KNOWN_BUG: &'static str = "known-bug"; + pub const MIR_UNIT_TEST: &'static str = "unit-test"; // This isn't a real directive, just one that is probably mistyped often pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags"; } @@ -232,6 +235,7 @@ impl TestProps { assembly_output: None, should_ice: false, stderr_per_bitwidth: false, + mir_unit_test: None, } } @@ -392,6 +396,9 @@ impl TestProps { config.set_name_directive(ln, STDERR_PER_BITWIDTH, &mut self.stderr_per_bitwidth); config.set_name_directive(ln, INCREMENTAL, &mut self.incremental); config.set_name_directive(ln, KNOWN_BUG, &mut self.known_bug); + config.set_name_value_directive(ln, MIR_UNIT_TEST, &mut self.mir_unit_test, |s| { + s.trim().to_string() + }); }); } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index aedddedac6184..6d94fe3ebb9cb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1856,10 +1856,14 @@ impl<'test> TestCx<'test> { rustc.args(&[ "-Copt-level=1", "-Zdump-mir=all", - "-Zmir-opt-level=4", "-Zvalidate-mir", "-Zdump-mir-exclude-pass-number", ]); + if let Some(pass) = &self.props.mir_unit_test { + rustc.args(&["-Zmir-opt-level=0", &format!("-Zmir-enable-passes=+{}", pass)]); + } else { + rustc.arg("-Zmir-opt-level=4"); + } let mir_dump_dir = self.get_mir_dump_dir(); let _ = fs::remove_dir_all(&mir_dump_dir);