diff options
528 files changed, 3317 insertions, 1705 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 03dcc3c21b7..b81f7a24270 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2552,15 +2552,6 @@ impl PolyTraitRef { } } -#[derive(Copy, Clone, Encodable, Decodable, Debug, HashStable_Generic)] -pub enum CrateSugar { - /// Source is `pub(crate)`. - PubCrate, - - /// Source is (just) `crate`. - JustCrate, -} - #[derive(Clone, Encodable, Decodable, Debug)] pub struct Visibility { pub kind: VisibilityKind, @@ -2571,7 +2562,6 @@ pub struct Visibility { #[derive(Clone, Encodable, Decodable, Debug)] pub enum VisibilityKind { Public, - Crate(CrateSugar), Restricted { path: P<Path>, id: NodeId }, Inherited, } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 1a93da8788a..85bb5296486 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1469,7 +1469,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>( pub fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) { match &mut visibility.kind { - VisibilityKind::Public | VisibilityKind::Crate(_) | VisibilityKind::Inherited => {} + VisibilityKind::Public | VisibilityKind::Inherited => {} VisibilityKind::Restricted { path, id } => { vis.visit_path(path); vis.visit_id(id); diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 2774bda24f1..f0b94047ed9 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -697,18 +697,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } visit::walk_assoc_item(self, i, ctxt) } - - fn visit_vis(&mut self, vis: &'a ast::Visibility) { - if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.kind { - gate_feature_post!( - &self, - crate_visibility_modifier, - vis.span, - "`crate` visibility modifier is experimental" - ); - } - visit::walk_vis(self, vis) - } } pub fn check_crate(krate: &ast::Crate, sess: &Session) { @@ -770,7 +758,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) { gate_all!(trait_alias, "trait aliases are experimental"); gate_all!(associated_type_bounds, "associated type bounds are unstable"); - gate_all!(crate_visibility_modifier, "`crate` visibility modifier is experimental"); gate_all!(decl_macro, "`macro` is experimental"); gate_all!(box_patterns, "box pattern syntax is experimental"); gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental"); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 0de5e2099fd..67b539a7ad4 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -403,13 +403,9 @@ impl<'a> State<'a> { pub(crate) fn print_visibility(&mut self, vis: &ast::Visibility) { match vis.kind { ast::VisibilityKind::Public => self.word_nbsp("pub"), - ast::VisibilityKind::Crate(sugar) => match sugar { - ast::CrateSugar::PubCrate => self.word_nbsp("pub(crate)"), - ast::CrateSugar::JustCrate => self.word_nbsp("crate"), - }, ast::VisibilityKind::Restricted { ref path, .. } => { let path = Self::to_string(|s| s.print_path(path, false, 0)); - if path == "self" || path == "super" { + if path == "crate" || path == "self" || path == "super" { self.word_nbsp(format!("pub({})", path)) } else { self.word_nbsp(format!("pub(in {})", path)) diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index a3c9da30212..84ff33fe1d8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1,5 +1,6 @@ use either::Either; use rustc_const_eval::util::CallKind; +use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; @@ -1622,10 +1623,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, mpi: MovePathIndex, ) -> (Vec<MoveSite>, Vec<Location>) { - fn predecessor_locations<'a>( - body: &'a mir::Body<'_>, + fn predecessor_locations<'tcx, 'a>( + body: &'a mir::Body<'tcx>, location: Location, - ) -> impl Iterator<Item = Location> + 'a { + ) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a { if location.statement_index == 0 { let predecessors = body.predecessors()[location.block].to_vec(); Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb))) diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index 61838c41e39..e91fcf1472d 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,3 +1,4 @@ +use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_index::vec::IndexVec; use rustc_middle::infer::MemberConstraint; @@ -140,11 +141,13 @@ where } } -impl<R> MemberConstraintSet<'_, R> +impl<'tcx, R> MemberConstraintSet<'tcx, R> where R: Copy + Hash + Eq, { - pub(crate) fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> + '_ { + pub(crate) fn all_indices( + &self, + ) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ { self.constraints.indices() } @@ -154,7 +157,7 @@ where pub(crate) fn indices( &self, member_region_vid: R, - ) -> impl Iterator<Item = NllMemberConstraintIndex> + '_ { + ) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ { let mut next = self.first_constraints.get(&member_region_vid).cloned(); std::iter::from_fn(move || -> Option<NllMemberConstraintIndex> { if let Some(current) = next { diff --git a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs index ee067c4872f..8070f357919 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs @@ -10,17 +10,17 @@ use super::TypeChecker; type VarPointRelation = Vec<(Local, LocationIndex)>; type PathPointRelation = Vec<(MovePathIndex, LocationIndex)>; -struct UseFactsExtractor<'me> { +struct UseFactsExtractor<'me, 'tcx> { var_defined_at: &'me mut VarPointRelation, var_used_at: &'me mut VarPointRelation, location_table: &'me LocationTable, var_dropped_at: &'me mut VarPointRelation, - move_data: &'me MoveData<'me>, + move_data: &'me MoveData<'tcx>, path_accessed_at_base: &'me mut PathPointRelation, } // A Visitor to walk through the MIR and extract point-wise facts -impl UseFactsExtractor<'_> { +impl UseFactsExtractor<'_, '_> { fn location_to_index(&self, location: Location) -> LocationIndex { self.location_table.mid_index(location) } @@ -53,7 +53,7 @@ impl UseFactsExtractor<'_> { } } -impl Visitor<'_> for UseFactsExtractor<'_> { +impl<'a, 'tcx> Visitor<'tcx> for UseFactsExtractor<'a, 'tcx> { fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) { match def_use::categorize(context) { Some(DefUse::Def) => self.insert_def(local, location), @@ -63,7 +63,7 @@ impl Visitor<'_> for UseFactsExtractor<'_> { } } - fn visit_place(&mut self, place: &Place<'_>, context: PlaceContext, location: Location) { + fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { self.super_place(place, context, location); match context { PlaceContext::NonMutatingUse(_) => { @@ -82,11 +82,11 @@ impl Visitor<'_> for UseFactsExtractor<'_> { } } -pub(super) fn populate_access_facts<'tcx>( - typeck: &mut TypeChecker<'_, 'tcx>, +pub(super) fn populate_access_facts<'a, 'tcx>( + typeck: &mut TypeChecker<'a, 'tcx>, body: &Body<'tcx>, location_table: &LocationTable, - move_data: &MoveData<'_>, + move_data: &MoveData<'tcx>, dropped_at: &mut Vec<(Local, Location)>, ) { debug!("populate_access_facts()"); diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 721abff689a..977b55a0890 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -197,7 +197,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { size: Size, align: Align, kind: MemoryKind<M::MemoryKind>, - ) -> InterpResult<'static, Pointer<M::PointerTag>> { + ) -> InterpResult<'tcx, Pointer<M::PointerTag>> { let alloc = Allocation::uninit(size, align, M::PANIC_ON_ALLOC_FAIL)?; Ok(self.allocate_raw_ptr(alloc, kind)) } @@ -402,7 +402,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { msg: CheckInAllocMsg, alloc_size: impl FnOnce(AllocId, Size, M::TagExtra) -> InterpResult<'tcx, (Size, Align, T)>, ) -> InterpResult<'tcx, Option<T>> { - fn check_offset_align(offset: u64, align: Align) -> InterpResult<'static> { + fn check_offset_align<'tcx>(offset: u64, align: Align) -> InterpResult<'tcx> { if offset % align.bytes() == 0 { Ok(()) } else { @@ -654,7 +654,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { &self, id: AllocId, liveness: AllocCheck, - ) -> InterpResult<'static, (Size, Align)> { + ) -> InterpResult<'tcx, (Size, Align)> { // # Regular allocations // Don't use `self.get_raw` here as that will // a) cause cycles in case `id` refers to a static diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 62f9c8f990d..dc49a45fe73 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -1011,7 +1011,7 @@ where &mut self, layout: TyAndLayout<'tcx>, kind: MemoryKind<M::MemoryKind>, - ) -> InterpResult<'static, MPlaceTy<'tcx, M::PointerTag>> { + ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { let ptr = self.allocate_ptr(layout.size, layout.align.abi, kind)?; Ok(MPlaceTy::from_aligned_ptr(ptr.into(), layout)) } diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 520769d308e..1956327dfab 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -351,8 +351,6 @@ declare_features! ( (active, const_trait_impl, "1.42.0", Some(67792), None), /// Allows the `?` operator in const contexts. (active, const_try, "1.56.0", Some(74935), None), - /// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`. - (active, crate_visibility_modifier, "1.23.0", Some(53120), None), /// Allows non-builtin attributes in inner attribute position. (active, custom_inner_attributes, "1.30.0", Some(54726), None), /// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`. diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index fae9bd633af..b546662dc14 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -72,6 +72,8 @@ declare_features! ( /// Allows `T: ?const Trait` syntax in bounds. (removed, const_trait_bound_opt_out, "1.42.0", Some(67794), None, Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")), + /// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`. + (removed, crate_visibility_modifier, "1.63.0", Some(53120), None, Some("removed in favor of `pub(crate)`")), /// Allows using custom attributes (RFC 572). (removed, custom_attribute, "1.0.0", Some(29642), None, Some("removed in favor of `#![register_tool]` and `#![register_attr]`")), diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 02caae7a90a..11c893a7cb6 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1442,6 +1442,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// the message in `secondary_span` as the primary label, and apply the message that would /// otherwise be used for the primary label on the `secondary_span` `Span`. This applies on /// E0271, like `src/test/ui/issues/issue-39970.stderr`. + #[tracing::instrument( + level = "debug", + skip(self, diag, secondary_span, swap_secondary_and_primary, force_label) + )] pub fn note_type_err( &self, diag: &mut Diagnostic, @@ -1453,7 +1457,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { force_label: bool, ) { let span = cause.span(self.tcx); - debug!("note_type_err cause={:?} values={:?}, terr={:?}", cause, values, terr); // For some types of errors, expected-found does not make // sense, so just ignore the values we were given. @@ -1621,9 +1624,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } }; - // Ignore msg for object safe coercion - // since E0038 message will be printed match terr { + // Ignore msg for object safe coercion + // since E0038 message will be printed TypeError::ObjectUnsafeCoercion(_) => {} _ => { let mut label_or_note = |span: Span, msg: &str| { @@ -1774,6 +1777,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // It reads better to have the error origin as the final // thing. self.note_error_origin(diag, cause, exp_found, terr); + + debug!(?diag); } fn suggest_tuple_pattern( diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs index da03d944ceb..29b3807a514 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { &self, anon_region: Region<'tcx>, replace_region: Region<'tcx>, - ) -> Option<AnonymousParamInfo<'_>> { + ) -> Option<AnonymousParamInfo<'tcx>> { find_param_with_region(self.tcx(), anon_region, replace_region) } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 3d50ed2096e..9317858aed9 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1372,17 +1372,11 @@ impl UnreachablePub { let def_span = cx.tcx.sess.source_map().guess_head_span(span); cx.struct_span_lint(UNREACHABLE_PUB, def_span, |lint| { let mut err = lint.build(&format!("unreachable `pub` {}", what)); - let replacement = if cx.tcx.features().crate_visibility_modifier { - "crate" - } else { - "pub(crate)" - } - .to_owned(); err.span_suggestion( vis_span, "consider restricting its visibility", - replacement, + "pub(crate)".to_owned(), applicability, ); if exportable { diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index 760fe1edbdb..6252dc1670c 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -171,7 +171,7 @@ impl<Tag> Allocation<Tag> { /// Try to create an Allocation of `size` bytes, failing if there is not enough memory /// available to the compiler to do so. - pub fn uninit(size: Size, align: Align, panic_on_fail: bool) -> InterpResult<'static, Self> { + pub fn uninit<'tcx>(size: Size, align: Align, panic_on_fail: bool) -> InterpResult<'tcx, Self> { let bytes = Box::<[u8]>::try_new_zeroed_slice(size.bytes_usize()).map_err(|_| { // This results in an error that can happen non-deterministically, since the memory // available to the compiler can change between runs. Normally queries are always diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index eeee170f43f..d00dae85367 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -397,38 +397,38 @@ impl<'tcx, Tag: Provenance> Scalar<Tag> { /// Converts the scalar to produce an unsigned integer of the given size. /// Fails if the scalar is a pointer. #[inline] - pub fn to_uint(self, size: Size) -> InterpResult<'static, u128> { + pub fn to_uint(self, size: Size) -> InterpResult<'tcx, u128> { self.to_bits(size) } /// Converts the scalar to produce a `u8`. Fails if the scalar is a pointer. - pub fn to_u8(self) -> InterpResult<'static, u8> { + pub fn to_u8(self) -> InterpResult<'tcx, u8> { self.to_uint(Size::from_bits(8)).map(|v| u8::try_from(v).unwrap()) } /// Converts the scalar to produce a `u16`. Fails if the scalar is a pointer. - pub fn to_u16(self) -> InterpResult<'static, u16> { + pub fn to_u16(self) -> InterpResult<'tcx, u16> { self.to_uint(Size::from_bits(16)).map(|v| u16::try_from(v).unwrap()) } /// Converts the scalar to produce a `u32`. Fails if the scalar is a pointer. - pub fn to_u32(self) -> InterpResult<'static, u32> { + pub fn to_u32(self) -> InterpResult<'tcx, u32> { self.to_uint(Size::from_bits(32)).map(|v| u32::try_from(v).unwrap()) } /// Converts the scalar to produce a `u64`. Fails if the scalar is a pointer. - pub fn to_u64(self) -> InterpResult<'static, u64> { + pub fn to_u64(self) -> InterpResult<'tcx, u64> { self.to_uint(Size::from_bits(64)).map(|v| u64::try_from(v).unwrap()) } /// Converts the scalar to produce a `u128`. Fails if the scalar is a pointer. - pub fn to_u128(self) -> InterpResult<'static, u128> { + pub fn to_u128(self) -> InterpResult<'tcx, u128> { self.to_uint(Size::from_bits(128)) } /// Converts the scalar to produce a machine-pointer-sized unsigned integer. /// Fails if the scalar is a pointer. - pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> { + pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { let b = self.to_uint(cx.data_layout().pointer_size)?; Ok(u64::try_from(b).unwrap()) } @@ -436,51 +436,51 @@ impl<'tcx, Tag: Provenance> Scalar<Tag> { /// Converts the scalar to produce a signed integer of the given size. /// Fails if the scalar is a pointer. #[inline] - pub fn to_int(self, size: Size) -> InterpResult<'static, i128> { + pub fn to_int(self, size: Size) -> InterpResult<'tcx, i128> { let b = self.to_bits(size)?; Ok(size.sign_extend(b) as i128) } /// Converts the scalar to produce an `i8`. Fails if the scalar is a pointer. - pub fn to_i8(self) -> InterpResult<'static, i8> { + pub fn to_i8(self) -> InterpResult<'tcx, i8> { self.to_int(Size::from_bits(8)).map(|v| i8::try_from(v).unwrap()) } /// Converts the scalar to produce an `i16`. Fails if the scalar is a pointer. - pub fn to_i16(self) -> InterpResult<'static, i16> { + pub fn to_i16(self) -> InterpResult<'tcx, i16> { self.to_int(Size::from_bits(16)).map(|v| i16::try_from(v).unwrap()) } /// Converts the scalar to produce an `i32`. Fails if the scalar is a pointer. - pub fn to_i32(self) -> InterpResult<'static, i32> { + pub fn to_i32(self) -> InterpResult<'tcx, i32> { self.to_int(Size::from_bits(32)).map(|v| i32::try_from(v).unwrap()) } /// Converts the scalar to produce an `i64`. Fails if the scalar is a pointer. - pub fn to_i64(self) -> InterpResult<'static, i64> { + pub fn to_i64(self) -> InterpResult<'tcx, i64> { self.to_int(Size::from_bits(64)).map(|v| i64::try_from(v).unwrap()) } /// Converts the scalar to produce an `i128`. Fails if the scalar is a pointer. - pub fn to_i128(self) -> InterpResult<'static, i128> { + pub fn to_i128(self) -> InterpResult<'tcx, i128> { self.to_int(Size::from_bits(128)) } /// Converts the scalar to produce a machine-pointer-sized signed integer. /// Fails if the scalar is a pointer. - pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> { + pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> { let b = self.to_int(cx.data_layout().pointer_size)?; Ok(i64::try_from(b).unwrap()) } #[inline] - pub fn to_f32(self) -> InterpResult<'static, Single> { + pub fn to_f32(self) -> InterpResult<'tcx, Single> { // Going through `u32` to check size and truncation. Ok(Single::from_bits(self.to_u32()?.into())) } #[inline] - pub fn to_f64(self) -> InterpResult<'static, Double> { + pub fn to_f64(self) -> InterpResult<'tcx, Double> { // Going through `u64` to check size and truncation. Ok(Double::from_bits(self.to_u64()?.into())) } @@ -534,7 +534,7 @@ impl<Tag> ScalarMaybeUninit<Tag> { } #[inline] - pub fn check_init(self) -> InterpResult<'static, Scalar<Tag>> { + pub fn check_init<'tcx>(self) -> InterpResult<'tcx, Scalar<Tag>> { match self { ScalarMaybeUninit::Scalar(scalar) => Ok(scalar), ScalarMaybeUninit::Uninit => throw_ub!(InvalidUninitBytes(None)), diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 1eca22d3812..9f8b22c8afc 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -13,6 +13,7 @@ use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; use crate::ty::{self, List, Ty, TyCtxt}; use crate::ty::{AdtDef, InstanceDef, Region, ScalarInt, UserTypeAnnotationIndex}; +use rustc_data_structures::captures::Captures; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; @@ -484,7 +485,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable locals. #[inline] - pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a { + pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + Captures<'tcx> + 'a { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -498,7 +499,9 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a { + pub fn mut_vars_and_args_iter<'a>( + &'a self, + ) -> impl Iterator<Item = Local> + Captures<'tcx> + 'a { (1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; diff --git a/compiler/rustc_middle/src/mir/patch.rs b/compiler/rustc_middle/src/mir/patch.rs index 3bcb8f9c34c..1bc53d3c9f1 100644 --- a/compiler/rustc_middle/src/mir/patch.rs +++ b/compiler/rustc_middle/src/mir/patch.rs @@ -192,7 +192,7 @@ impl<'tcx> MirPatch<'tcx> { } } - pub fn source_info_for_location(&self, body: &Body<'_>, loc: Location) -> SourceInfo { + pub fn source_info_for_location(&self, body: &Body<'tcx>, loc: Location) -> SourceInfo { let data = match loc.block.index().checked_sub(body.basic_blocks().len()) { Some(new) => &self.new_blocks[new], None => &body[loc.block], diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 4d30c0e35e4..4006b2fcf17 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -115,8 +115,6 @@ impl Hash for ObligationCause<'_> { } } -const MISC_OBLIGATION_CAUSE_CODE: ObligationCauseCode<'static> = MiscObligation; - impl<'tcx> ObligationCause<'tcx> { #[inline] pub fn new( @@ -201,7 +199,7 @@ pub struct UnifyReceiverContext<'tcx> { #[derive(Clone, Debug, PartialEq, Eq, Hash, Lift, Default)] pub struct InternedObligationCauseCode<'tcx> { - /// `None` for `MISC_OBLIGATION_CAUSE_CODE` (a common case, occurs ~60% of + /// `None` for `ObligationCauseCode::MiscObligation` (a common case, occurs ~60% of /// the time). `Some` otherwise. code: Option<Lrc<ObligationCauseCode<'tcx>>>, } @@ -210,7 +208,11 @@ impl<'tcx> ObligationCauseCode<'tcx> { #[inline(always)] fn into(self) -> InternedObligationCauseCode<'tcx> { InternedObligationCauseCode { - code: if let MISC_OBLIGATION_CAUSE_CODE = self { None } else { Some(Lrc::new(self)) }, + code: if let ObligationCauseCode::MiscObligation = self { + None + } else { + Some(Lrc::new(self)) + }, } } } @@ -219,7 +221,7 @@ impl<'tcx> std::ops::Deref for InternedObligationCauseCode<'tcx> { type Target = ObligationCauseCode<'tcx>; fn deref(&self) -> &Self::Target { - self.code.as_deref().unwrap_or(&MISC_OBLIGATION_CAUSE_CODE) + self.code.as_deref().unwrap_or(&ObligationCauseCode::MiscObligation) } } diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index a0fe632f11a..a6c14ea0de3 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -135,11 +135,10 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { ArgCount => write!(f, "incorrect number of function parameters"), FieldMisMatch(adt, field) => write!(f, "field type mismatch: {}.{}", adt, field), RegionsDoesNotOutlive(..) => write!(f, "lifetime mismatch"), - RegionsInsufficientlyPolymorphic(br, _) => write!( - f, - "expected bound lifetime parameter{}, found concrete lifetime", - br_string(br) - ), + // Actually naming the region here is a bit confusing because context is lacking + RegionsInsufficientlyPolymorphic(..) => { + write!(f, "one type is more general than the other") + } RegionsOverlyPolymorphic(br, _) => write!( f, "expected concrete lifetime, found bound lifetime parameter{}", diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index a7488fd44cd..30552c685a3 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2163,7 +2163,7 @@ impl<'tcx> SizeSkeleton<'tcx> { } } - pub fn same_size(self, other: SizeSkeleton<'_>) -> bool { + pub fn same_size(self, other: SizeSkeleton<'tcx>) -> bool { match (self, other) { (SizeSkeleton::Known(a), SizeSkeleton::Known(b)) => a == b, (SizeSkeleton::Pointer { tail: a, .. }, SizeSkeleton::Pointer { tail: b, .. }) => { diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 48c71113d50..31a318cc68f 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -109,13 +109,13 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> { } impl<'tcx> Ord for GenericArg<'tcx> { - fn cmp(&self, other: &GenericArg<'_>) -> Ordering { + fn cmp(&self, other: &GenericArg<'tcx>) -> Ordering { self.unpack().cmp(&other.unpack()) } } impl<'tcx> PartialOrd for GenericArg<'tcx> { - fn partial_cmp(&self, other: &GenericArg<'_>) -> Option<Ordering> { + fn partial_cmp(&self, other: &GenericArg<'tcx>) -> Option<Ordering> { Some(self.cmp(&other)) } } @@ -233,7 +233,7 @@ pub type InternalSubsts<'tcx> = List<GenericArg<'tcx>>; pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; -impl<'a, 'tcx> InternalSubsts<'tcx> { +impl<'tcx> InternalSubsts<'tcx> { /// Checks whether all elements of this list are types, if so, transmute. pub fn try_as_type_list(&'tcx self) -> Option<&'tcx List<Ty<'tcx>>> { if self.iter().all(|arg| matches!(arg.unpack(), GenericArgKind::Type(_))) { @@ -249,7 +249,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { /// Closure substitutions have a particular structure controlled by the /// compiler that encodes information like the signature and closure kind; /// see `ty::ClosureSubsts` struct for more comments. - pub fn as_closure(&'a self) -> ClosureSubsts<'a> { + pub fn as_closure(&'tcx self) -> ClosureSubsts<'tcx> { ClosureSubsts { substs: self } } @@ -330,20 +330,20 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { } #[inline] - pub fn types(&'a self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'a { + pub fn types(&'tcx self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'tcx { self.iter() .filter_map(|k| if let GenericArgKind::Type(ty) = k.unpack() { Some(ty) } else { None }) } #[inline] - pub fn regions(&'a self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> + 'a { + pub fn regions(&'tcx self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> + 'tcx { self.iter().filter_map(|k| { if let GenericArgKind::Lifetime(lt) = k.unpack() { Some(lt) } else { None } }) } #[inline] - pub fn consts(&'a self) -> impl DoubleEndedIterator<Item = ty::Const<'tcx>> + 'a { + pub fn consts(&'tcx self) -> impl DoubleEndedIterator<Item = ty::Const<'tcx>> + 'tcx { self.iter().filter_map(|k| { if let GenericArgKind::Const(ct) = k.unpack() { Some(ct) } else { None } }) @@ -351,8 +351,8 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { #[inline] pub fn non_erasable_generics( - &'a self, - ) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'a { + &'tcx self, + ) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'tcx { self.iter().filter_map(|k| match k.unpack() { GenericArgKind::Lifetime(_) => None, generic => Some(generic), diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 56acf65d9c5..9df86c6ada1 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -151,6 +151,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// * From each pre-binding block to the next pre-binding block. /// * From each otherwise block to the next pre-binding block. + #[tracing::instrument(level = "debug", skip(self, arms))] pub(crate) fn match_expr( &mut self, destination: Place<'tcx>, diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index d0b18ce67c6..59750d5d0b8 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -75,6 +75,7 @@ impl<'tcx> Cx<'tcx> { }; let mut pattern = self.pattern_from_hir(local.pat); + debug!(?pattern); if let Some(ty) = &local.ty { if let Some(&user_ty) = diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 13b4e90ca09..bd17df60cd7 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -98,6 +98,7 @@ impl<'tcx> Cx<'tcx> { } } + #[tracing::instrument(level = "debug", skip(self))] pub(crate) fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { let p = match self.tcx.hir().get(p.hir_id) { Node::Pat(p) | Node::Binding(p) => p, diff --git a/compiler/rustc_mir_dataflow/src/framework/direction.rs b/compiler/rustc_mir_dataflow/src/framework/direction.rs index 18795128b85..d6bfde8f34c 100644 --- a/compiler/rustc_mir_dataflow/src/framework/direction.rs +++ b/compiler/rustc_mir_dataflow/src/framework/direction.rs @@ -304,8 +304,8 @@ impl Direction for Backward { } } -struct BackwardSwitchIntEdgeEffectsApplier<'a, D, F> { - body: &'a mir::Body<'a>, +struct BackwardSwitchIntEdgeEffectsApplier<'a, 'tcx, D, F> { + body: &'a mir::Body<'tcx>, pred: BasicBlock, exit_state: &'a mut D, bb: BasicBlock, @@ -314,7 +314,7 @@ struct BackwardSwitchIntEdgeEffectsApplier<'a, D, F> { effects_applied: bool, } -impl<D, F> super::SwitchIntEdgeEffects<D> for BackwardSwitchIntEdgeEffectsApplier<'_, D, F> +impl<D, F> super::SwitchIntEdgeEffects<D> for BackwardSwitchIntEdgeEffectsApplier<'_, '_, D, F> where D: Clone, F: FnMut(BasicBlock, &D), diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs index 3cc8d30259c..708a142581a 100644 --- a/compiler/rustc_mir_dataflow/src/framework/tests.rs +++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs @@ -14,7 +14,7 @@ use super::*; /// /// This is the `Body` that will be used by the `MockAnalysis` below. The shape of its CFG is not /// important. -fn mock_body() -> mir::Body<'static> { +fn mock_body<'tcx>() -> mir::Body<'tcx> { let source_info = mir::SourceInfo::outermost(DUMMY_SP); let mut blocks = IndexVec::new(); diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs index c1124a533bf..e4c130f0807 100644 --- a/compiler/rustc_mir_dataflow/src/lib.rs +++ b/compiler/rustc_mir_dataflow/src/lib.rs @@ -1,6 +1,5 @@ #![feature(associated_type_defaults)] #![feature(box_patterns)] -#![feature(box_syntax)] #![feature(exact_size_is_empty)] #![feature(let_else)] #![feature(min_specialization)] diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 47190fa0d1a..510f1e64ed1 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -481,8 +481,8 @@ impl std::fmt::Debug for BcbBranch { // FIXME(#78544): MIR InstrumentCoverage: Improve coverage of `#[should_panic]` tests and // `catch_unwind()` handlers. fn bcb_filtered_successors<'a, 'tcx>( - body: &'tcx &'a mir::Body<'tcx>, - term_kind: &'tcx TerminatorKind<'tcx>, + body: &'a mir::Body<'tcx>, + term_kind: &'a TerminatorKind<'tcx>, ) -> Box<dyn Iterator<Item = BasicBlock> + 'a> { Box::new( match &term_kind { @@ -691,12 +691,9 @@ pub(super) fn find_loop_backedges( pub struct ShortCircuitPreorder< 'a, 'tcx, - F: Fn( - &'tcx &'a mir::Body<'tcx>, - &'tcx TerminatorKind<'tcx>, - ) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, + F: Fn(&'a mir::Body<'tcx>, &'a TerminatorKind<'tcx>) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, > { - body: &'tcx &'a mir::Body<'tcx>, + body: &'a mir::Body<'tcx>, visited: BitSet<BasicBlock>, worklist: Vec<BasicBlock>, filtered_successors: F, @@ -705,14 +702,11 @@ pub struct ShortCircuitPreorder< impl< 'a, 'tcx, - F: Fn( - &'tcx &'a mir::Body<'tcx>, - &'tcx TerminatorKind<'tcx>, - ) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, + F: Fn(&'a mir::Body<'tcx>, &'a TerminatorKind<'tcx>) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, > ShortCircuitPreorder<'a, 'tcx, F> { pub fn new( - body: &'tcx &'a mir::Body<'tcx>, + body: &'a mir::Body<'tcx>, filtered_successors: F, ) -> ShortCircuitPreorder<'a, 'tcx, F> { let worklist = vec![mir::START_BLOCK]; @@ -727,12 +721,9 @@ impl< } impl< - 'a: 'tcx, + 'a, 'tcx, - F: Fn( - &'tcx &'a mir::Body<'tcx>, - &'tcx TerminatorKind<'tcx>, - ) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, + F: Fn(&'a mir::Body<'tcx>, &'a TerminatorKind<'tcx>) -> Box<dyn Iterator<Item = BasicBlock> + 'a>, > Iterator for ShortCircuitPreorder<'a, 'tcx, F> { type Item = (BasicBlock, &'a BasicBlockData<'tcx>); diff --git a/compiler/rustc_mir_transform/src/instcombine.rs b/compiler/rustc_mir_transform/src/instcombine.rs index d1c4a4b21d0..268ce1b2e8c 100644 --- a/compiler/rustc_mir_transform/src/instcombine.rs +++ b/compiler/rustc_mir_transform/src/instcombine.rs @@ -192,12 +192,12 @@ impl<'tcx> InstCombineContext<'tcx, '_> { statements.push(Statement { source_info: terminator.source_info, - kind: StatementKind::Assign(box ( + kind: StatementKind::Assign(Box::new(( destination_place, Rvalue::Use(Operand::Copy( arg_place.project_deeper(&[ProjectionElem::Deref], self.tcx), )), - )), + ))), }); terminator.kind = TerminatorKind::Goto { target: destination_block }; } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 1e8c373a411..571f541072a 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -1,6 +1,5 @@ #![allow(rustc::potential_query_instability)] #![feature(box_patterns)] -#![feature(box_syntax)] #![feature(let_chains)] #![feature(let_else)] #![feature(map_try_insert)] diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs index cdfd49ef478..0f45711baa3 100644 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ b/compiler/rustc_mir_transform/src/normalize_array_len.rs @@ -125,7 +125,7 @@ impl<'tcx> Patcher<'_, 'tcx> { let assign_to = Place::from(local); let rvalue = Rvalue::Use(operand); make_copy_statement.kind = - StatementKind::Assign(box (assign_to, rvalue)); + StatementKind::Assign(Box::new((assign_to, rvalue))); statements.push(make_copy_statement); // to reorder we have to copy and make NOP @@ -165,7 +165,8 @@ impl<'tcx> Patcher<'_, 'tcx> { if add_deref { place = self.tcx.mk_place_deref(place); } - len_statement.kind = StatementKind::Assign(box (*into, Rvalue::Len(place))); + len_statement.kind = + StatementKind::Assign(Box::new((*into, Rvalue::Len(place)))); statements.push(len_statement); // make temporary dead diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 0f940cffcc4..e99347206fe 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -302,8 +302,7 @@ impl<'a> Parser<'a> { /// When parsing a statement, would the start of a path be an item? pub(super) fn is_path_start_item(&mut self) -> bool { - self.is_crate_vis() // no: `crate::b`, yes: `crate $item` - || self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }` + self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }` || self.check_auto_or_unsafe_trait_item() // no: `auto::b`, yes: `auto trait X { .. }` || self.is_async_fn() // no(2015): `async::b`, yes: `async fn` || matches!(self.is_macro_rules_item(), IsMacroRulesItem::Yes{..}) // no: `macro_rules::b`, yes: `macro_rules! mac` diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 5bd07c31c0e..6e6c1ffe747 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -25,7 +25,7 @@ use rustc_ast::tokenstream::{self, DelimSpan, Spacing}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::AttrId; use rustc_ast::DUMMY_NODE_ID; -use rustc_ast::{self as ast, AnonConst, AttrStyle, AttrVec, Const, CrateSugar, Extern}; +use rustc_ast::{self as ast, AnonConst, AttrStyle, AttrVec, Const, Extern}; use rustc_ast::{Async, Expr, ExprKind, MacArgs, MacArgsEq, MacDelimiter, Mutability, StrLit}; use rustc_ast::{HasAttrs, HasTokens, Unsafe, Visibility, VisibilityKind}; use rustc_ast_pretty::pprust; @@ -1245,12 +1245,8 @@ impl<'a> Parser<'a> { res } - fn is_crate_vis(&self) -> bool { - self.token.is_keyword(kw::Crate) && self.look_ahead(1, |t| t != &token::ModSep) - } - - /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, - /// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`. + /// Parses `pub` and `pub(in path)` plus shortcuts `pub(crate)` for `pub(in crate)`, `pub(self)` + /// for `pub(in self)` and `pub(super)` for `pub(in super)`. /// If the following element can't be a tuple (i.e., it's a function definition), then /// it's not a tuple struct field), and the contents within the parentheses aren't valid, /// so emit a proper diagnostic. @@ -1258,17 +1254,6 @@ impl<'a> Parser<'a> { pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { maybe_whole!(self, NtVis, |x| x.into_inner()); - self.expected_tokens.push(TokenType::Keyword(kw::Crate)); - if self.is_crate_vis() { - self.bump(); // `crate` - self.sess.gated_spans.gate(sym::crate_visibility_modifier, self.prev_token.span); - return Ok(Visibility { - span: self.prev_token.span, - kind: VisibilityKind::Crate(CrateSugar::JustCrate), - tokens: None, - }); - } - if !self.eat_keyword(kw::Pub) { // We need a span for our `Spanned<VisibilityKind>`, but there's inherently no // keyword to grab a span from for inherited visibility; an empty span at the @@ -1286,20 +1271,7 @@ impl<'a> Parser<'a> { // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`. // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so // by the following tokens. - if self.is_keyword_ahead(1, &[kw::Crate]) && self.look_ahead(2, |t| t != &token::ModSep) - // account for `pub(crate::foo)` - { - // Parse `pub(crate)`. - self.bump(); // `(` - self.bump(); // `crate` - self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` - let vis = VisibilityKind::Crate(CrateSugar::PubCrate); - return Ok(Visibility { - span: lo.to(self.prev_token.span), - kind: vis, - tokens: None, - }); - } else if self.is_keyword_ahead(1, &[kw::In]) { + if self.is_keyword_ahead(1, &[kw::In]) { // Parse `pub(in path)`. self.bump(); // `(` self.bump(); // `in` @@ -1312,11 +1284,11 @@ impl<'a> Parser<'a> { tokens: None, }); } else if self.look_ahead(2, |t| t == &token::CloseDelim(Delimiter::Parenthesis)) - && self.is_keyword_ahead(1, &[kw::Super, kw::SelfLower]) + && self.is_keyword_ahead(1, &[kw::Crate, kw::Super, kw::SelfLower]) { - // Parse `pub(self)` or `pub(super)`. + // Parse `pub(crate)`, `pub(self)`, or `pub(super)`. self.bump(); // `(` - let path = self.parse_path(PathStyle::Mod)?; // `super`/`self` + let path = self.parse_path(PathStyle::Mod)?; // `crate`/`super`/`self` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let vis = VisibilityKind::Restricted { path: P(path), id: ast::DUMMY_NODE_ID }; return Ok(Visibility { diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 3879779635b..20d9123e411 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -249,9 +249,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { let parent_scope = &self.parent_scope; match vis.kind { ast::VisibilityKind::Public => Ok(ty::Visibility::Public), - ast::VisibilityKind::Crate(..) => { - Ok(ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id())) - } ast::VisibilityKind::Inherited => { Ok(match self.parent_scope.module.kind { // Any inherited visibility resolved directly inside an enum or trait diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index ff87baeef3e..73d6566e3cd 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -182,7 +182,7 @@ impl RibKind<'_> { /// stack. This may be, for example, a `let` statement (because it introduces variables), a macro, /// etc. /// -/// Different [rib kinds](enum.RibKind) are transparent for different names. +/// Different [rib kinds](enum@RibKind) are transparent for different names. /// /// The resolution keeps a separate stack of ribs as it traverses the AST for each namespace. When /// resolving, the name is looked up from inside out. diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 673b2e3a55a..a6a04ac9ea6 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -445,6 +445,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { ); } } + // Try Levenshtein algorithm. + let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected); if path.len() == 1 && self.self_type_is_available() { if let Some(candidate) = self.lookup_assoc_candidate(ident, ns, is_expected) { let self_is_available = self.self_value_is_available(path[0].ident.span); @@ -454,7 +456,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { err.span_suggestion( span, "you might have meant to use the available field", - format!("self.{}", path_str), + format!("self.{path_str}"), Applicability::MachineApplicable, ); } else { @@ -465,7 +467,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { err.span_suggestion( span, "you might have meant to call the method", - format!("self.{}", path_str), + format!("self.{path_str}"), Applicability::MachineApplicable, ); } @@ -476,11 +478,12 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { err.span_suggestion( span, &format!("you might have meant to {}", candidate.action()), - format!("Self::{}", path_str), + format!("Self::{path_str}"), Applicability::MachineApplicable, ); } } + self.r.add_typo_suggestion(&mut err, typo_sugg, ident_span); return (err, candidates); } @@ -495,16 +498,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { err.span_suggestion( call_span, - &format!("try calling `{}` as a method", ident), - format!("self.{}({})", path_str, args_snippet), + &format!("try calling `{ident}` as a method"), + format!("self.{path_str}({args_snippet})"), Applicability::MachineApplicable, ); return (err, candidates); } } - // Try Levenshtein algorithm. - let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected); // Try context-dependent help if relaxed lookup didn't work. if let Some(res) = res { if self.smart_resolve_context_dependent_help( diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index e3e384798d3..5c09e5d7be1 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -98,7 +98,7 @@ fn object_safety_violations_for_trait( span, ) = violation { - lint_object_unsafe_trait(tcx, *span, trait_def_id, violation); + lint_object_unsafe_trait(tcx, *span, trait_def_id, &violation); false } else { true @@ -278,7 +278,7 @@ fn predicate_references_self<'tcx>( (predicate, sp): (ty::Predicate<'tcx>, Span), ) -> Option<Span> { let self_ty = tcx.types.self_param; - let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into()); + let has_self_ty = |arg: &GenericArg<'tcx>| arg.walk().any(|arg| arg == self_ty.into()); match predicate.kind().skip_binder() { ty::PredicateKind::Trait(ref data) => { // In the case of a trait predicate, we can skip the "self" type. diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index 9aff854c803..3632e14385f 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -56,6 +56,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut all_arms_diverge = Diverges::WarnedAlways; let expected = orig_expected.adjust_for_branches(self); + debug!(?expected); let mut coercion = { let coerce_first = match expected { @@ -127,6 +128,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some(&arm.body), arm_ty, Some(&mut |err: &mut Diagnostic| { + let Some(ret) = self.ret_type_span else { + return; + }; + let Expectation::IsLast(stmt) = orig_expected else { + return + }; let can_coerce_to_return_ty = match self.ret_coercion.as_ref() { Some(ret_coercion) if self.in_tail_expr => { let ret_ty = ret_coercion.borrow().expected_ty(); @@ -138,38 +145,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => false, }; - if let (Expectation::IsLast(stmt), Some(ret), true) = - (orig_expected, self.ret_type_span, can_coerce_to_return_ty) - { - let semi_span = expr.span.shrink_to_hi().with_hi(stmt.hi()); - let mut ret_span: MultiSpan = semi_span.into(); - ret_span.push_span_label( - expr.span, - "this could be implicitly returned but it is a statement, not a \ - tail expression" - .to_owned(), - ); - ret_span.push_span_label( - ret, - "the `match` arms can conform to this return type".to_owned(), - ); - ret_span.push_span_label( - semi_span, - "the `match` is a statement because of this semicolon, consider \ - removing it" - .to_owned(), - ); - err.span_note( - ret_span, - "you might have meant to return the `match` expression", - ); - err.tool_only_span_suggestion( - semi_span, - "remove this semicolon", - String::new(), - Applicability::MaybeIncorrect, - ); + if !can_coerce_to_return_ty { + return; } + + let semi_span = expr.span.shrink_to_hi().with_hi(stmt.hi()); + let mut ret_span: MultiSpan = semi_span.into(); + ret_span.push_span_label( + expr.span, + "this could be implicitly returned but it is a statement, not a \ + tail expression" + .to_owned(), + ); + ret_span.push_span_label( + ret, + "the `match` arms can conform to this return type".to_owned(), + ); + ret_span.push_span_label( + semi_span, + "the `match` is a statement because of this semicolon, consider \ + removing it" + .to_owned(), + ); + err.span_note( + ret_span, + "you might have meant to return the `match` expression", + ); + err.tool_only_span_suggestion( + semi_span, + "remove this semicolon", + String::new(), + Applicability::MaybeIncorrect, + ); }), false, ); @@ -199,7 +206,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We won't diverge unless the scrutinee or all arms diverge. self.diverges.set(scrut_diverges | all_arms_diverge); - coercion.complete(self) + let match_ty = coercion.complete(self); + debug!(?match_ty); + match_ty } fn get_appropriate_arm_semicolon_removal_span( diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index d9aaf730efc..7d5d6849b3b 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -961,7 +961,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { } } - fn try_coercion_cast(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<(), ty::error::TypeError<'_>> { + fn try_coercion_cast(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<(), ty::error::TypeError<'tcx>> { match fcx.try_coerce(self.expr, self.expr_ty, self.cast_ty, AllowTwoPhase::No, None) { Ok(_) => Ok(()), Err(err) => Err(err), diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index a17b13d49fd..1af50191cb0 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -737,14 +737,27 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { F: FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>, G: FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>, { - if let ty::FnPtr(fn_ty_b) = b.kind() - && let (hir::Unsafety::Normal, hir::Unsafety::Unsafe) = - (fn_ty_a.unsafety(), fn_ty_b.unsafety()) - { - let unsafe_a = self.tcx.safe_to_unsafe_fn_ty(fn_ty_a); - return self.unify_and(unsafe_a, b, to_unsafe); - } - self.unify_and(a, b, normal) + self.commit_unconditionally(|snapshot| { + let result = if let ty::FnPtr(fn_ty_b) = b.kind() + && let (hir::Unsafety::Normal, hir::Unsafety::Unsafe) = + (fn_ty_a.unsafety(), fn_ty_b.unsafety()) + { + let unsafe_a = self.tcx.safe_to_unsafe_fn_ty(fn_ty_a); + self.unify_and(unsafe_a, b, to_unsafe) + } else { + self.unify_and(a, b, normal) + }; + + // FIXME(#73154): This is a hack. Currently LUB can generate + // unsolvable constraints. Additionally, it returns `a` + // unconditionally, even when the "LUB" is `b`. In the future, we + // want the coerced type to be the actual supertype of these two, + // but for now, we want to just error to ensure we don't lock + // ourselves into a specific behavior with NLL. + self.leak_check(false, snapshot)?; + + result + }) } fn coerce_from_fn_pointer( @@ -1023,7 +1036,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Special-case that coercion alone cannot handle: // Function items or non-capturing closures of differing IDs or InternalSubsts. let (a_sig, b_sig) = { - let is_capturing_closure = |ty| { + #[allow(rustc::usage_of_ty_tykind)] + let is_capturing_closure = |ty: &ty::TyKind<'tcx>| { if let &ty::Closure(closure_def_id, _substs) = ty { self.tcx.upvars_mentioned(closure_def_id.expect_local()).is_some() } else { @@ -1133,8 +1147,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (adjustments, target) = self.register_infer_ok_obligations(ok); self.apply_adjustments(new, adjustments); debug!( - "coercion::try_find_coercion_lub: was able to coerce from previous type {:?} to new type {:?}", - prev_ty, new_ty, + "coercion::try_find_coercion_lub: was able to coerce from new type {:?} to previous type {:?} ({:?})", + new_ty, prev_ty, target ); return Ok(target); } @@ -1190,15 +1204,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } Ok(ok) => { - debug!( - "coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?}", - prev_ty, new_ty, - ); let (adjustments, target) = self.register_infer_ok_obligations(ok); for expr in exprs { let expr = expr.as_coercion_site(); self.apply_adjustments(expr, adjustments.clone()); } + debug!( + "coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})", + prev_ty, new_ty, target + ); Ok(target) } } @@ -1430,6 +1444,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { }) }; + debug!(?result); match result { Ok(v) => { self.final_ty = Some(v); @@ -1520,7 +1535,10 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { augment_error(&mut err); } - if let Some(expr) = expression { + let is_insufficiently_polymorphic = + matches!(coercion_error, TypeError::RegionsInsufficientlyPolymorphic(..)); + + if !is_insufficiently_polymorphic && let Some(expr) = expression { fcx.emit_coerce_suggestions( &mut err, expr, diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index ceb57386e30..d0d2841209a 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -129,6 +129,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// N.B., this code relies on `self.diverges` to be accurate. In particular, assignments to `!` /// will be permitted if the diverges flag is currently "always". + #[tracing::instrument(level = "debug", skip(self, expr, expected_ty_expr, allow_two_phase))] pub fn demand_coerce_diag( &self, expr: &hir::Expr<'tcx>, @@ -150,7 +151,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expr_ty = self.resolve_vars_with_obligations(checked_ty); let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e.clone()); - self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e)); + let is_insufficiently_polymorphic = + matches!(e, TypeError::RegionsInsufficientlyPolymorphic(..)); + + // FIXME(#73154): For now, we do leak check when coercing function + // pointers in typeck, instead of only during borrowck. This can lead + // to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful. + if !is_insufficiently_polymorphic { + self.emit_coerce_suggestions( + &mut err, + expr, + expr_ty, + expected, + expected_ty_expr, + Some(e), + ); + } (expected, Some(err)) } diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 54003654db0..a02d8c89772 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -768,7 +768,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let second_input_ty = self.resolve_vars_if_possible(expected_input_tys[second_idx]); let third_input_ty = - self.resolve_vars_if_possible(expected_input_tys[second_idx]); + self.resolve_vars_if_possible(expected_input_tys[third_idx]); let span = if third_idx < provided_arg_count { let first_arg_span = provided_args[first_idx].span; let third_arg_span = provided_args[third_idx].span; @@ -809,16 +809,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } missing_idxs => { let first_idx = *missing_idxs.first().unwrap(); - let second_idx = *missing_idxs.last().unwrap(); + let last_idx = *missing_idxs.last().unwrap(); // NOTE: Because we might be re-arranging arguments, might have extra arguments, etc. // It's hard to *really* know where we should provide this error label, so this is a // decent heuristic - let span = if first_idx < provided_arg_count { + let span = if last_idx < provided_arg_count { let first_arg_span = provided_args[first_idx].span; - let second_arg_span = provided_args[second_idx].span; + let last_arg_span = provided_args[last_idx].span; Span::new( first_arg_span.lo(), - second_arg_span.hi(), + last_arg_span.hi(), first_arg_span.ctxt(), None, ) @@ -959,7 +959,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Ideally this would be folded into the above, for uniform style // but c-variadic is already a corner case if c_variadic { - fn variadic_error<'tcx>(sess: &Session, span: Span, ty: Ty<'tcx>, cast_ty: &str) { + fn variadic_error<'tcx>( + sess: &'tcx Session, + span: Span, + ty: Ty<'tcx>, + cast_ty: &str, + ) { use crate::structured_errors::MissingCastForVariadicArg; MissingCastForVariadicArg { sess, span, ty, cast_ty }.diagnostic().emit(); diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index c7823b444bf..4322440d685 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -2454,7 +2454,7 @@ fn trait_explicit_predicates_and_bounds( gather_explicit_predicates_of(tcx, def_id.to_def_id()) } -fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> { +fn explicit_predicates_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::GenericPredicates<'tcx> { let def_kind = tcx.def_kind(def_id); if let DefKind::Trait = def_kind { // Remove bounds on associated types from the predicates, they will be @@ -2462,7 +2462,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat let predicates_and_bounds = tcx.trait_explicit_predicates_and_bounds(def_id.expect_local()); let trait_identity_substs = InternalSubsts::identity_for_item(tcx, def_id); - let is_assoc_item_ty = |ty: Ty<'_>| { + let is_assoc_item_ty = |ty: Ty<'tcx>| { // For a predicate from a where clause to become a bound on an // associated type: // * It must use the identity substs of the item. diff --git a/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs b/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs index e2bd018cb20..bafc5a0b918 100644 --- a/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs +++ b/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs @@ -4,14 +4,14 @@ use rustc_middle::ty::{Ty, TypeFoldable}; use rustc_session::Session; use rustc_span::Span; -pub struct MissingCastForVariadicArg<'tcx> { +pub struct MissingCastForVariadicArg<'tcx, 's> { pub sess: &'tcx Session, pub span: Span, pub ty: Ty<'tcx>, - pub cast_ty: &'tcx str, + pub cast_ty: &'s str, } -impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx> { +impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx, '_> { fn session(&self) -> &Session { self.sess } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 62bc04cadee..c157aba83c2 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -2626,10 +2626,13 @@ impl<T, A: Allocator> IntoIterator for Vec<T, A> { /// /// ``` /// let v = vec!["a".to_string(), "b".to_string()]; - /// for s in v.into_iter() { - /// // s has type String, not &String - /// println!("{s}"); - /// } + /// let mut v_iter = v.into_iter(); + /// + /// let first_element: Option<String> = v_iter.next(); + /// + /// assert_eq!(first_element, Some("a".to_string())); + /// assert_eq!(v_iter.next(), Some("b".to_string())); + /// assert_eq!(v_iter.next(), None); /// ``` #[inline] fn into_iter(self) -> IntoIter<T, A> { diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index a231f533d19..dbc3d2923ed 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -496,9 +496,10 @@ macro_rules! r#try { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")] macro_rules! write { - ($dst:expr, $($arg:tt)*) => { - $dst.write_fmt($crate::format_args!($($arg)*)) - }; + ($dst:expr, $($arg:tt)*) => {{ + let result = $dst.write_fmt($crate::format_args!($($arg)*)); + result + }}; } /// Write formatted data into a buffer, with a newline appended. @@ -553,9 +554,10 @@ macro_rules! writeln { ($dst:expr $(,)?) => { $crate::write!($dst, "\n") }; - ($dst:expr, $($arg:tt)*) => { - $dst.write_fmt($crate::format_args_nl!($($arg)*)) - }; + ($dst:expr, $($arg:tt)*) => {{ + let result = $dst.write_fmt($crate::format_args_nl!($($arg)*)); + result + }}; } /// Indicates unreachable code. diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index 541adb69b8e..df0e7431f1f 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -143,8 +143,10 @@ macro_rules! from_str_float_impl { /// # Return value /// /// `Err(ParseFloatError)` if the string did not represent a valid - /// number. Otherwise, `Ok(n)` where `n` is the floating-point - /// number represented by `src`. + /// number. Otherwise, `Ok(n)` where `n` is the closest + /// representable floating-point number to the number represented + /// by `src` (following the same rules for rounding as for the + /// results of primitive operations). #[inline] fn from_str(src: &str) -> Result<Self, ParseFloatError> { dec2flt(src) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index ac4e668112b..631cc313fa0 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -994,6 +994,19 @@ mod prim_tuple {} /// surprising results upon inspecting the bit patterns, /// as the same calculations might produce NaNs with different bit patterns. /// +/// When the number resulting from a primitive operation (addition, +/// subtraction, multiplication, or division) on this type is not exactly +/// representable as `f32`, it is rounded according to the roundTiesToEven +/// direction defined in IEEE 754-2008. That means: +/// +/// - The result is the representable value closest to the true value, if there +/// is a unique closest representable value. +/// - If the true value is exactly half-way between two representable values, +/// the result is the one with an even least-significant binary digit. +/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` − +/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the +/// true value's sign). +/// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// /// *[See also the `std::f32::consts` module](crate::f32::consts).* diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 9946db67db9..f0455317175 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -125,7 +125,7 @@ impl<T: Sized> NonNull<T> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_ref<'a>(&self) -> &'a MaybeUninit<T> { + pub const unsafe fn as_uninit_ref<'a>(self) -> &'a MaybeUninit<T> { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &*self.cast().as_ptr() } @@ -159,7 +159,7 @@ impl<T: Sized> NonNull<T> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_mut<'a>(&mut self) -> &'a mut MaybeUninit<T> { + pub const unsafe fn as_uninit_mut<'a>(self) -> &'a mut MaybeUninit<T> { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &mut *self.cast().as_ptr() } @@ -593,7 +593,7 @@ impl<T> NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice<'a>(&self) -> &'a [MaybeUninit<T>] { + pub const unsafe fn as_uninit_slice<'a>(self) -> &'a [MaybeUninit<T>] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice`. unsafe { slice::from_raw_parts(self.cast().as_ptr(), self.len()) } } @@ -656,7 +656,7 @@ impl<T> NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice_mut<'a>(&self) -> &'a mut [MaybeUninit<T>] { + pub const unsafe fn as_uninit_slice_mut<'a>(self) -> &'a mut [MaybeUninit<T>] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice_mut`. unsafe { slice::from_raw_parts_mut(self.cast().as_ptr(), self.len()) } } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 7ac7573b43c..f5a90cb3d7a 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -716,6 +716,8 @@ impl<T> [T] { /// Returns an iterator over the slice. /// + /// The iterator yields all items from start to end. + /// /// # Examples /// /// ``` @@ -735,6 +737,8 @@ impl<T> [T] { /// Returns an iterator that allows modifying each value. /// + /// The iterator yields all items from start to end. + /// /// # Examples /// /// ``` diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index c7348951511..0cb21ef53b1 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -62,9 +62,9 @@ macro_rules! panic { #[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")] #[allow_internal_unstable(print_internals)] macro_rules! print { - ($($arg:tt)*) => { - $crate::io::_print($crate::format_args!($($arg)*)) - }; + ($($arg:tt)*) => {{ + $crate::io::_print($crate::format_args!($($arg)*)); + }}; } /// Prints to the standard output, with a newline. @@ -133,9 +133,9 @@ macro_rules! println { #[cfg_attr(not(test), rustc_diagnostic_item = "eprint_macro")] #[allow_internal_unstable(print_internals)] macro_rules! eprint { - ($($arg:tt)*) => { - $crate::io::_eprint($crate::format_args!($($arg)*)) - }; + ($($arg:tt)*) => {{ + $crate::io::_eprint($crate::format_args!($($arg)*)); + }}; } /// Prints to the standard error, with a newline. diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index f629a1a0f99..46004c99142 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -138,7 +138,8 @@ pub struct Ipv4Addr { /// /// To convert from an IPv4 address to an IPv4-mapped IPv6 address, use [`Ipv4Addr::to_ipv6_mapped`]. /// Use [`Ipv6Addr::to_ipv4`] to convert an IPv4-mapped IPv6 address to the canonical IPv4 address. -/// Note that this will also convert the IPv6 loopback address `::1` to `0.0.0.1`. +/// Note that this will also convert the IPv6 loopback address `::1` to `0.0.0.1`. Use +/// [`Ipv6Addr::to_ipv4_mapped`] to avoid this. /// /// [IETF RFC 4291 Section 2.5.5.2]: https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2 /// @@ -1646,8 +1647,6 @@ impl Ipv6Addr { /// # Examples /// /// ``` - /// #![feature(ip)] - /// /// use std::net::{Ipv4Addr, Ipv6Addr}; /// /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None); @@ -1656,7 +1655,7 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[unstable(feature = "ip", issue = "27709")] + #[stable(feature = "ipv6_to_ipv4_mapped", since = "1.62.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1674,7 +1673,8 @@ impl Ipv6Addr { /// or an [IPv4-mapped] address as defined in [IETF RFC 4291 section 2.5.5.2], /// otherwise returns [`None`]. /// - /// Note that this will return an [`IPv4` address] for the IPv6 loopback address `::1`. + /// Note that this will return an [`IPv4` address] for the IPv6 loopback address `::1`. Use + /// [`Ipv6Addr::to_ipv4_mapped`] to avoid this. /// /// `::a.b.c.d` and `::ffff:a.b.c.d` become `a.b.c.d`. `::1` becomes `0.0.0.1`. /// All addresses *not* starting with either all zeroes or `::ffff` will return `None`. diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 9b045980d45..25c9201f2ed 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -325,7 +325,7 @@ pub mod panic_count { pub const ALWAYS_ABORT_FLAG: usize = 1 << (usize::BITS - 1); // Panic count for the current thread. - thread_local! { static LOCAL_PANIC_COUNT: Cell<usize> = Cell::new(0) } + thread_local! { static LOCAL_PANIC_COUNT: Cell<usize> = const { Cell::new(0) } } // Sum of panic counts from all threads. The purpose of this is to have // a fast path in `is_zero` (which is used by `panicking`). In any particular diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index ac4e668112b..631cc313fa0 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -994,6 +994,19 @@ mod prim_tuple {} /// surprising results upon inspecting the bit patterns, /// as the same calculations might produce NaNs with different bit patterns. /// +/// When the number resulting from a primitive operation (addition, +/// subtraction, multiplication, or division) on this type is not exactly +/// representable as `f32`, it is rounded according to the roundTiesToEven +/// direction defined in IEEE 754-2008. That means: +/// +/// - The result is the representable value closest to the true value, if there +/// is a unique closest representable value. +/// - If the true value is exactly half-way between two representable values, +/// the result is the one with an even least-significant binary digit. +/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` − +/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the +/// true value's sign). +/// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// /// *[See also the `std::f32::consts` module](crate::f32::consts).* diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 28e802d07e1..1def9fe0972 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2108,7 +2108,7 @@ pub fn id() -> u32 { /// A trait for implementing arbitrary return types in the `main` function. /// -/// The C-main function only supports to return integers as return type. +/// The C-main function only supports returning integers. /// So, every type implementing the `Termination` trait has to be converted /// to an integer. /// diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 708e4064e06..b2014f462bd 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -95,8 +95,8 @@ pub use core::time::FromFloatSecsError; /// use std::time::{Instant, Duration}; /// /// let now = Instant::now(); -/// let max_nanoseconds = u64::MAX / 1_000_000_000; -/// let duration = Duration::new(max_nanoseconds, 0); +/// let max_seconds = u64::MAX / 1_000_000_000; +/// let duration = Duration::new(max_seconds, 0); /// println!("{:?}", now + duration); /// ``` /// diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index d36344ece4e..6d46ea26e6a 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1192,7 +1192,6 @@ def bootstrap(help_triggered): env = os.environ.copy() env["BOOTSTRAP_PARENT_ID"] = str(os.getpid()) env["BOOTSTRAP_PYTHON"] = sys.executable - env["RUSTC_BOOTSTRAP"] = '1' if build.rustc_commit is not None: env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1' run(args, env=env, verbose=build.verbose, is_bootstrap=True) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 894d74fb269..761bd66b505 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1226,6 +1226,14 @@ impl<'a> Builder<'a> { // this), as well as #63012 which is the tracking issue for this // feature on the rustc side. cargo.arg("-Zbinary-dep-depinfo"); + match mode { + Mode::ToolBootstrap => { + // Restrict the allowed features to those passed by rustbuild, so we don't depend on nightly accidentally. + // HACK: because anyhow does feature detection in build.rs, we need to allow the backtrace feature too. + rustflags.arg("-Zallow-features=binary-dep-depinfo,backtrace"); + } + Mode::Std | Mode::Rustc | Mode::ToolStd | Mode::Codegen | Mode::ToolRustc => {} + } cargo.arg("-j").arg(self.jobs().to_string()); // Remove make-related flags to ensure Cargo can correctly set things up diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 87a130a0982..2fc036082cb 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -407,7 +407,7 @@ if 'target' in config: configured_targets.append(target) for target in configured_targets: targets[target] = sections['target'][:] - targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target) + targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target)) def is_number(value): diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index fcef784d2d1..be6655ddb61 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -881,6 +881,10 @@ impl Step for RustcBook { if self.validate { cmd.arg("--validate"); } + if !builder.unstable_features() { + // We need to validate nightly features, even on the stable channel. + cmd.env("RUSTC_BOOTSTRAP", "1"); + } // If the lib directories are in an unusual location (changed in // config.toml), then this needs to explicitly update the dylib search // path. diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index 5e6716baed6..ab6c888030e 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -98,8 +98,8 @@ COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/ RUN ./build-clang.sh ENV CC=clang CXX=clang++ -# rustc-perf version from 2022-04-05 -ENV PERF_COMMIT 04fccd80396f954b339c366e30221f4bd52c5e03 +# rustc-perf version from 2022-05-18 +ENV PERF_COMMIT f66cc8f3e04392b0e2fd811f21fd1ece6ebaded3 RUN curl -LS -o perf.zip https://github.com/rust-lang/rustc-perf/archive/$PERF_COMMIT.zip && \ unzip perf.zip && \ mv rustc-perf-$PERF_COMMIT rustc-perf && \ diff --git a/src/ci/pgo.sh b/src/ci/pgo.sh index aedfe98bdea..9b727947f6a 100755 --- a/src/ci/pgo.sh +++ b/src/ci/pgo.sh @@ -1,4 +1,5 @@ #!/bin/bash +# ignore-tidy-linelength set -euxo pipefail @@ -87,7 +88,7 @@ python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \ # That's why we override the profile path to include the PID. This will produce many more profiling # files, but the resulting profile will produce a slightly faster rustc binary. LLVM_PROFILE_FILE=/tmp/rustc-pgo/default_%m_%p.profraw gather_profiles "Check,Debug,Opt" "All" \ - "externs,ctfe-stress-4,cargo-0.60.0,token-stream-stress,match-stress,tuple-stress" +"externs,ctfe-stress-5,cargo-0.60.0,token-stream-stress,match-stress,tuple-stress,diesel-1.4.8,bitmaps-3.1.0" # Merge the profile data we gathered ./build/$PGO_HOST/llvm/bin/llvm-profdata \ diff --git a/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md b/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md deleted file mode 100644 index b59859dd348..00000000000 --- a/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md +++ /dev/null @@ -1,20 +0,0 @@ -# `crate_visibility_modifier` - -The tracking issue for this feature is: [#53120] - -[#53120]: https://github.com/rust-lang/rust/issues/53120 - ------ - -The `crate_visibility_modifier` feature allows the `crate` keyword to be used -as a visibility modifier synonymous to `pub(crate)`, indicating that a type -(function, _&c._) is to be visible to the entire enclosing crate, but not to -other crates. - -```rust -#![feature(crate_visibility_modifier)] - -crate struct Foo { - bar: usize, -} -``` diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e7b966758d6..d820e43cb61 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -236,7 +236,6 @@ fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum { clean::Enum { generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates), - variants_stripped: false, variants: cx.tcx.adt_def(did).variants().iter().map(|v| v.clean(cx)).collect(), } } @@ -249,7 +248,6 @@ fn build_struct(cx: &mut DocContext<'_>, did: DefId) -> clean::Struct { struct_type: variant.ctor_kind, generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates), fields: variant.fields.iter().map(|x| x.clean(cx)).collect(), - fields_stripped: false, } } @@ -259,7 +257,7 @@ fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union { let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates); let fields = variant.fields.iter().map(|x| x.clean(cx)).collect(); - clean::Union { generics, fields, fields_stripped: false } + clean::Union { generics, fields } } fn build_type_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::Typedef { @@ -544,7 +542,7 @@ fn build_module( segments: vec![clean::PathSegment { name: prim_ty.as_sym(), args: clean::GenericArgs::AngleBracketed { - args: Vec::new(), + args: Default::default(), bindings: ThinVec::new(), }, }], diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 04d97e0dabf..4ddfae4dacc 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -420,7 +420,7 @@ fn projection_to_path_segment(ty: ty::ProjectionTy<'_>, cx: &mut DocContext<'_>) PathSegment { name: item.name, args: GenericArgs::AngleBracketed { - args: substs_to_args(cx, &ty.substs[generics.parent_count..], false), + args: substs_to_args(cx, &ty.substs[generics.parent_count..], false).into(), bindings: Default::default(), }, } @@ -1205,7 +1205,7 @@ impl Clean<Item> for ty::AssocItem { || generics .params .iter() - .zip(args) + .zip(args.iter()) .any(|(param, arg)| !param_eq_arg(param, arg)) { return false; @@ -1784,7 +1784,6 @@ impl Clean<VariantStruct> for rustc_hir::VariantData<'_> { VariantStruct { struct_type: CtorKind::from_hir(self), fields: self.fields().iter().map(|x| x.clean(cx)).collect(), - fields_stripped: false, } } } @@ -1804,7 +1803,6 @@ impl Clean<Item> for ty::VariantDef { } CtorKind::Fictive => Variant::Struct(VariantStruct { struct_type: CtorKind::Fictive, - fields_stripped: false, fields: self.fields.iter().map(|field| field.clean(cx)).collect(), }), }; @@ -1837,7 +1835,7 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> { let output = self.bindings[0].ty().clean(cx); let output = if output != Type::Tuple(Vec::new()) { Some(Box::new(output)) } else { None }; - let inputs = self.inputs().iter().map(|x| x.clean(cx)).collect(); + let inputs = self.inputs().iter().map(|x| x.clean(cx)).collect::<Vec<_>>().into(); GenericArgs::Parenthesized { inputs, output } } else { let args = self @@ -1852,8 +1850,9 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> { hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(ct.clean(cx))), hir::GenericArg::Infer(_inf) => GenericArg::Infer, }) - .collect(); - let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect(); + .collect::<Vec<_>>() + .into(); + let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect::<Vec<_>>().into(); GenericArgs::AngleBracketed { args, bindings } } } @@ -1913,7 +1912,6 @@ fn clean_maybe_renamed_item( ItemKind::Enum(ref def, ref generics) => EnumItem(Enum { variants: def.variants.iter().map(|v| v.clean(cx)).collect(), generics: generics.clean(cx), - variants_stripped: false, }), ItemKind::TraitAlias(ref generics, bounds) => TraitAliasItem(TraitAlias { generics: generics.clean(cx), @@ -1922,13 +1920,11 @@ fn clean_maybe_renamed_item( ItemKind::Union(ref variant_data, ref generics) => UnionItem(Union { generics: generics.clean(cx), fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(), - fields_stripped: false, }), ItemKind::Struct(ref variant_data, ref generics) => StructItem(Struct { struct_type: CtorKind::from_hir(variant_data), generics: generics.clean(cx), fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(), - fields_stripped: false, }), ItemKind::Impl(ref impl_) => return clean_impl(impl_, item.hir_id(), cx), // proc macros can have a name set by attributes diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index a832d03a501..7118e05e58e 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -619,11 +619,12 @@ impl Item { _ => false, } } - pub(crate) fn has_stripped_fields(&self) -> Option<bool> { + pub(crate) fn has_stripped_entries(&self) -> Option<bool> { match *self.kind { - StructItem(ref _struct) => Some(_struct.fields_stripped), - UnionItem(ref union) => Some(union.fields_stripped), - VariantItem(Variant::Struct(ref vstruct)) => Some(vstruct.fields_stripped), + StructItem(ref struct_) => Some(struct_.has_stripped_entries()), + UnionItem(ref union_) => Some(union_.has_stripped_entries()), + EnumItem(ref enum_) => Some(enum_.has_stripped_entries()), + VariantItem(ref v) => v.has_stripped_entries(), _ => None, } } @@ -994,7 +995,7 @@ pub(crate) struct DocFragment { #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] rustc_data_structures::static_assert_size!(DocFragment, 32); -#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub(crate) enum DocFragmentKind { /// A doc fragment created from a `///` or `//!` doc comment. SugaredDoc, @@ -2028,14 +2029,24 @@ pub(crate) struct Struct { pub(crate) struct_type: CtorKind, pub(crate) generics: Generics, pub(crate) fields: Vec<Item>, - pub(crate) fields_stripped: bool, +} + +impl Struct { + pub(crate) fn has_stripped_entries(&self) -> bool { + self.fields.iter().any(|f| f.is_stripped()) + } } #[derive(Clone, Debug)] pub(crate) struct Union { pub(crate) generics: Generics, pub(crate) fields: Vec<Item>, - pub(crate) fields_stripped: bool, +} + +impl Union { + pub(crate) fn has_stripped_entries(&self) -> bool { + self.fields.iter().any(|f| f.is_stripped()) + } } /// This is a more limited form of the standard Struct, different in that @@ -2045,14 +2056,28 @@ pub(crate) struct Union { pub(crate) struct VariantStruct { pub(crate) struct_type: CtorKind, pub(crate) fields: Vec<Item>, - pub(crate) fields_stripped: bool, +} + +impl VariantStruct { + pub(crate) fn has_stripped_entries(&self) -> bool { + self.fields.iter().any(|f| f.is_stripped()) + } } #[derive(Clone, Debug)] pub(crate) struct Enum { pub(crate) variants: IndexVec<VariantIdx, Item>, pub(crate) generics: Generics, - pub(crate) variants_stripped: bool, +} + +impl Enum { + pub(crate) fn has_stripped_entries(&self) -> bool { + self.variants.iter().any(|f| f.is_stripped()) + } + + pub(crate) fn variants(&self) -> impl Iterator<Item = &Item> { + self.variants.iter().filter(|v| !v.is_stripped()) + } } #[derive(Clone, Debug)] @@ -2062,6 +2087,15 @@ pub(crate) enum Variant { Struct(VariantStruct), } +impl Variant { + pub(crate) fn has_stripped_entries(&self) -> Option<bool> { + match *self { + Self::Struct(ref struct_) => Some(struct_.has_stripped_entries()), + Self::CLike | Self::Tuple(_) => None, + } + } +} + /// Small wrapper around [`rustc_span::Span`] that adds helper methods /// and enforces calling [`rustc_span::Span::source_callsite()`]. #[derive(Copy, Clone, Debug)] @@ -2182,14 +2216,14 @@ rustc_data_structures::static_assert_size!(GenericArg, 80); #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub(crate) enum GenericArgs { - AngleBracketed { args: Vec<GenericArg>, bindings: ThinVec<TypeBinding> }, - Parenthesized { inputs: Vec<Type>, output: Option<Box<Type>> }, + AngleBracketed { args: Box<[GenericArg]>, bindings: ThinVec<TypeBinding> }, + Parenthesized { inputs: Box<[Type]>, output: Option<Box<Type>> }, } // `GenericArgs` is in every `PathSegment`, so its size can significantly // affect rustdoc's memory usage. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(GenericArgs, 40); +rustc_data_structures::static_assert_size!(GenericArgs, 32); #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub(crate) struct PathSegment { @@ -2200,7 +2234,7 @@ pub(crate) struct PathSegment { // `PathSegment` usually occurs multiple times in every `Path`, so its size can // significantly affect rustdoc's memory usage. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(PathSegment, 48); +rustc_data_structures::static_assert_size!(PathSegment, 40); #[derive(Clone, Debug)] pub(crate) struct Typedef { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 7a12ea0d5c2..47597e0413a 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -80,23 +80,23 @@ pub(crate) fn substs_to_args( substs: &[ty::subst::GenericArg<'_>], mut skip_first: bool, ) -> Vec<GenericArg> { - substs - .iter() - .filter_map(|kind| match kind.unpack() { - GenericArgKind::Lifetime(lt) => match *lt { - ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrAnon(_), .. }) => { - Some(GenericArg::Lifetime(Lifetime::elided())) - } - _ => lt.clean(cx).map(GenericArg::Lifetime), - }, - GenericArgKind::Type(_) if skip_first => { - skip_first = false; - None + let mut ret_val = + Vec::with_capacity(substs.len().saturating_sub(if skip_first { 1 } else { 0 })); + ret_val.extend(substs.iter().filter_map(|kind| match kind.unpack() { + GenericArgKind::Lifetime(lt) => match *lt { + ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrAnon(_), .. }) => { + Some(GenericArg::Lifetime(Lifetime::elided())) } - GenericArgKind::Type(ty) => Some(GenericArg::Type(ty.clean(cx))), - GenericArgKind::Const(ct) => Some(GenericArg::Const(Box::new(ct.clean(cx)))), - }) - .collect() + _ => lt.clean(cx).map(GenericArg::Lifetime), + }, + GenericArgKind::Type(_) if skip_first => { + skip_first = false; + None + } + GenericArgKind::Type(ty) => Some(GenericArg::Type(ty.clean(cx))), + GenericArgKind::Const(ct) => Some(GenericArg::Const(Box::new(ct.clean(cx)))), + })); + ret_val } fn external_generic_args( @@ -112,8 +112,8 @@ fn external_generic_args( let inputs = // The trait's first substitution is the one after self, if there is one. match substs.iter().nth(if has_self { 1 } else { 0 }).unwrap().expect_ty().kind() { - ty::Tuple(tys) => tys.iter().map(|t| t.clean(cx)).collect(), - _ => return GenericArgs::AngleBracketed { args, bindings: bindings.into() }, + ty::Tuple(tys) => tys.iter().map(|t| t.clean(cx)).collect::<Vec<_>>().into(), + _ => return GenericArgs::AngleBracketed { args: args.into(), bindings: bindings.into() }, }; let output = None; // FIXME(#20299) return type comes from a projection now @@ -123,7 +123,7 @@ fn external_generic_args( // }; GenericArgs::Parenthesized { inputs, output } } else { - GenericArgs::AngleBracketed { args, bindings: bindings.into() } + GenericArgs::AngleBracketed { args: args.into(), bindings: bindings.into() } } } @@ -148,7 +148,7 @@ pub(super) fn external_path( /// Remove the generic arguments from a path. pub(crate) fn strip_path_generics(mut path: Path) -> Path { for ps in path.segments.iter_mut() { - ps.args = GenericArgs::AngleBracketed { args: vec![], bindings: ThinVec::new() } + ps.args = GenericArgs::AngleBracketed { args: Default::default(), bindings: ThinVec::new() } } path diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index f3e075bc12a..336448904d1 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -18,30 +18,15 @@ pub(crate) trait DocFolder: Sized { StrippedItem(..) => unreachable!(), ModuleItem(i) => ModuleItem(self.fold_mod(i)), StructItem(mut i) => { - let num_fields = i.fields.len(); i.fields = i.fields.into_iter().filter_map(|x| self.fold_item(x)).collect(); - if !i.fields_stripped { - i.fields_stripped = - num_fields != i.fields.len() || i.fields.iter().any(|f| f.is_stripped()); - } StructItem(i) } UnionItem(mut i) => { - let num_fields = i.fields.len(); i.fields = i.fields.into_iter().filter_map(|x| self.fold_item(x)).collect(); - if !i.fields_stripped { - i.fields_stripped = - num_fields != i.fields.len() || i.fields.iter().any(|f| f.is_stripped()); - } UnionItem(i) } EnumItem(mut i) => { - let num_variants = i.variants.len(); i.variants = i.variants.into_iter().filter_map(|x| self.fold_item(x)).collect(); - if !i.variants_stripped { - i.variants_stripped = num_variants != i.variants.len() - || i.variants.iter().any(|f| f.is_stripped()); - } EnumItem(i) } TraitItem(mut i) => { @@ -54,12 +39,7 @@ pub(crate) trait DocFolder: Sized { } VariantItem(i) => match i { Variant::Struct(mut j) => { - let num_fields = j.fields.len(); j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect(); - if !j.fields_stripped { - j.fields_stripped = num_fields != j.fields.len() - || j.fields.iter().any(|f| f.is_stripped()); - } VariantItem(Variant::Struct(j)) } Variant::Tuple(fields) => { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 1214e4367c2..da32d8c90be 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -457,7 +457,7 @@ impl clean::GenericArgs { f.write_str("<")?; } let mut comma = false; - for arg in args { + for arg in args.iter() { if comma { f.write_str(", ")?; } @@ -468,7 +468,7 @@ impl clean::GenericArgs { write!(f, "{}", arg.print(cx))?; } } - for binding in bindings { + for binding in bindings.iter() { if comma { f.write_str(", ")?; } @@ -489,7 +489,7 @@ impl clean::GenericArgs { clean::GenericArgs::Parenthesized { inputs, output } => { f.write_str("(")?; let mut comma = false; - for ty in inputs { + for ty in inputs.iter() { if comma { f.write_str(", ")?; } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 0de50c60fac..1b4a2cf1cb0 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2363,8 +2363,7 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean: let mut sidebar = Buffer::new(); let mut variants = e - .variants - .iter() + .variants() .filter_map(|v| { v.name .as_ref() diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 2c0b8d7bde1..ed41b95e73f 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1136,6 +1136,7 @@ fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item] } fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum) { + let count_variants = e.variants().count(); wrap_into_docblock(w, |w| { wrap_item(w, "enum", |w| { render_attributes_in_pre(w, it, ""); @@ -1147,16 +1148,16 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum e.generics.print(cx), print_where_clause(&e.generics, cx, 0, true), ); - if e.variants.is_empty() && !e.variants_stripped { + let variants_stripped = e.has_stripped_entries(); + if count_variants == 0 && !variants_stripped { w.write_str(" {}"); } else { w.write_str(" {\n"); - let count_variants = e.variants.len(); let toggle = should_hide_fields(count_variants); if toggle { toggle_open(w, format_args!("{} variants", count_variants)); } - for v in &e.variants { + for v in e.variants() { w.write_str(" "); let name = v.name.unwrap(); match *v.kind { @@ -1185,7 +1186,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w.write_str(",\n"); } - if e.variants_stripped { + if variants_stripped { w.write_str(" // some variants omitted\n"); } if toggle { @@ -1198,7 +1199,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum document(w, cx, it, None, HeadingOffset::H2); - if !e.variants.is_empty() { + if count_variants != 0 { write!( w, "<h2 id=\"variants\" class=\"variants small-section-header\">\ @@ -1206,7 +1207,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum document_non_exhaustive_header(it) ); document_non_exhaustive(w, it); - for variant in &e.variants { + for variant in e.variants() { let id = cx.derive_id(format!("{}.{}", ItemType::Variant, variant.name.unwrap())); write!( w, @@ -1650,7 +1651,7 @@ fn render_union( } } - if it.has_stripped_fields().unwrap() { + if it.has_stripped_entries().unwrap() { write!(w, " /* private fields */\n{}", tab); } if toggle { @@ -1706,11 +1707,11 @@ fn render_struct( } if has_visible_fields { - if it.has_stripped_fields().unwrap() { + if it.has_stripped_entries().unwrap() { write!(w, "\n{} /* private fields */", tab); } write!(w, "\n{}", tab); - } else if it.has_stripped_fields().unwrap() { + } else if it.has_stripped_entries().unwrap() { write!(w, " /* private fields */ "); } if toggle { diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index cb163d540e0..bf962303b3a 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -46,5 +46,6 @@ module.exports = { "error", { "beforeColon": false, "afterColon": true, "mode": "strict" } ], + "func-call-spacing": ["error", "never"], } }; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 6f6f7e375a4..6a8e4787676 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -119,11 +119,11 @@ impl FromWithTcx<clean::GenericArgs> for GenericArgs { use clean::GenericArgs::*; match args { AngleBracketed { args, bindings } => GenericArgs::AngleBracketed { - args: args.into_iter().map(|a| a.into_tcx(tcx)).collect(), + args: args.into_vec().into_iter().map(|a| a.into_tcx(tcx)).collect(), bindings: bindings.into_iter().map(|a| a.into_tcx(tcx)).collect(), }, Parenthesized { inputs, output } => GenericArgs::Parenthesized { - inputs: inputs.into_iter().map(|a| a.into_tcx(tcx)).collect(), + inputs: inputs.into_vec().into_iter().map(|a| a.into_tcx(tcx)).collect(), output: output.map(|a| (*a).into_tcx(tcx)), }, } @@ -249,7 +249,8 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { impl FromWithTcx<clean::Struct> for Struct { fn from_tcx(struct_: clean::Struct, tcx: TyCtxt<'_>) -> Self { - let clean::Struct { struct_type, generics, fields, fields_stripped } = struct_; + let fields_stripped = struct_.has_stripped_entries(); + let clean::Struct { struct_type, generics, fields } = struct_; Struct { struct_type: from_ctor_kind(struct_type), generics: generics.into_tcx(tcx), @@ -261,8 +262,9 @@ impl FromWithTcx<clean::Struct> for Struct { } impl FromWithTcx<clean::Union> for Union { - fn from_tcx(struct_: clean::Union, tcx: TyCtxt<'_>) -> Self { - let clean::Union { generics, fields, fields_stripped } = struct_; + fn from_tcx(union_: clean::Union, tcx: TyCtxt<'_>) -> Self { + let fields_stripped = union_.has_stripped_entries(); + let clean::Union { generics, fields } = union_; Union { generics: generics.into_tcx(tcx), fields_stripped, @@ -586,7 +588,8 @@ pub(crate) fn from_function_method( impl FromWithTcx<clean::Enum> for Enum { fn from_tcx(enum_: clean::Enum, tcx: TyCtxt<'_>) -> Self { - let clean::Enum { variants, generics, variants_stripped } = enum_; + let variants_stripped = enum_.has_stripped_entries(); + let clean::Enum { variants, generics } = enum_; Enum { generics: generics.into_tcx(tcx), variants_stripped, @@ -598,7 +601,8 @@ impl FromWithTcx<clean::Enum> for Enum { impl FromWithTcx<clean::VariantStruct> for Struct { fn from_tcx(struct_: clean::VariantStruct, _tcx: TyCtxt<'_>) -> Self { - let clean::VariantStruct { struct_type, fields, fields_stripped } = struct_; + let fields_stripped = struct_.has_stripped_entries(); + let clean::VariantStruct { struct_type, fields } = struct_; Struct { struct_type: from_ctor_kind(struct_type), generics: Default::default(), diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index ab5526e0612..533e2ce46dd 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -38,9 +38,16 @@ impl<'a> DocFolder for Stripper<'a> { fn fold_item(&mut self, i: Item) -> Option<Item> { if i.attrs.lists(sym::doc).has_word(sym::hidden) { debug!("strip_hidden: stripping {:?} {:?}", i.type_(), i.name); - // use a dedicated hidden item for given item type if any + // Use a dedicated hidden item for fields, variants, and modules. + // We need to keep private fields and variants, so that the docs + // can show a placeholder "// some variants omitted". We need to keep + // private modules, because they can contain impl blocks, and impl + // block privacy is inherited from the type and trait, not from the + // module it's defined in. Both of these are marked "stripped," and + // not included in the final docs, but since they still have an effect + // on the final doc, cannot be completely removed from the Clean IR. match *i.kind { - clean::StructFieldItem(..) | clean::ModuleItem(..) => { + clean::StructFieldItem(..) | clean::ModuleItem(..) | clean::VariantItem(..) => { // We need to recurse into stripped modules to // strip things like impl methods but when doing so // we must not add any items to the `retained` set. diff --git a/src/test/rustdoc/strip-enum-variant.no-not-shown.html b/src/test/rustdoc/strip-enum-variant.no-not-shown.html new file mode 100644 index 00000000000..c4ee1a99114 --- /dev/null +++ b/src/test/rustdoc/strip-enum-variant.no-not-shown.html @@ -0,0 +1 @@ +<ul><li><a href="#variant.Shown">Shown</a></li></ul> \ No newline at end of file diff --git a/src/test/rustdoc/strip-enum-variant.rs b/src/test/rustdoc/strip-enum-variant.rs index 12e57610071..f82ffdfeda5 100644 --- a/src/test/rustdoc/strip-enum-variant.rs +++ b/src/test/rustdoc/strip-enum-variant.rs @@ -2,6 +2,8 @@ // @has - '//code' 'Shown' // @!has - '//code' 'NotShown' // @has - '//code' '// some variants omitted' +// Also check that `NotShown` isn't displayed in the sidebar. +// @snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block"][1]/ul' pub enum MyThing { Shown, #[doc(hidden)] diff --git a/src/test/ui/argument-suggestions/issue-97197.rs b/src/test/ui/argument-suggestions/issue-97197.rs new file mode 100644 index 00000000000..6f9f4293e49 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-97197.rs @@ -0,0 +1,6 @@ +fn main() { + g((), ()); + //~^ ERROR this function takes 6 arguments but 2 arguments were supplied +} + +pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} diff --git a/src/test/ui/argument-suggestions/issue-97197.stderr b/src/test/ui/argument-suggestions/issue-97197.stderr new file mode 100644 index 00000000000..10689d50957 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-97197.stderr @@ -0,0 +1,19 @@ +error[E0061]: this function takes 6 arguments but 2 arguments were supplied + --> $DIR/issue-97197.rs:2:5 + | +LL | g((), ()); + | ^-------- multiple arguments are missing + | +note: function defined here + --> $DIR/issue-97197.rs:6:8 + | +LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} + | ^ ------ -------- -------- -------- -------- ------ +help: provide the arguments + | +LL | g((), {bool}, {bool}, {bool}, {bool}, ()); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index b4dadb1b9da..5236d15b945 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -293,7 +293,7 @@ error[E0061]: this function takes 5 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:39:3 | LL | complex( 1, "" ); - | ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing + | ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing | note: function defined here --> $DIR/missing_arguments.rs:7:4 diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.stderr b/src/test/ui/associated-type-bounds/implied-region-constraints.base.stderr index c338e38d28f..b4437069cd7 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.stderr +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/implied-region-constraints.rs:17:64 + --> $DIR/implied-region-constraints.rs:21:64 | LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>) | ------------- this type is declared with multiple lifetimes... @@ -8,7 +8,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; | ^^^^^ ...but data with one lifetime flows into the other here error[E0623]: lifetime mismatch - --> $DIR/implied-region-constraints.rs:38:72 + --> $DIR/implied-region-constraints.rs:43:72 | LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>) | -------------- this type is declared with multiple lifetimes... diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr index cddce8777ea..bf9fecf06a4 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/implied-region-constraints.rs:17:56 + --> $DIR/implied-region-constraints.rs:21:56 | LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>) | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/implied-region-constraints.rs:38:64 + --> $DIR/implied-region-constraints.rs:43:64 | LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.rs b/src/test/ui/associated-type-bounds/implied-region-constraints.rs index ccad947f7f0..a41c7643430 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.rs +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(associated_type_bounds)] trait Tr1 { type As1; } @@ -15,7 +19,8 @@ where { // This should fail because `T: 'b` is not implied from `WF(St<'a, 'b, T>)`. let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } enum En7<'a, 'b, T> // `<T::As1 as Tr2>::As2: 'a` is implied. @@ -36,7 +41,8 @@ where En7::V0(x) => { // Also fails for the same reason as above: let _failure_proves_not_implied_outlives_region_b: &'b T = &x; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough }, En7::V1(_) => {}, } diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.base.stderr index 1329e1382fd..4313078064c 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.base.stderr @@ -1,18 +1,18 @@ error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize` - --> $DIR/associated-types-eq-hr.rs:87:5 + --> $DIR/associated-types-eq-hr.rs:91:5 | LL | foo::<UintStruct>(); | ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize` | note: expected this to be `&isize` - --> $DIR/associated-types-eq-hr.rs:26:14 + --> $DIR/associated-types-eq-hr.rs:30:14 | LL | type A = &'a usize; | ^^^^^^^^^ = note: expected reference `&isize` found reference `&usize` note: required by a bound in `foo` - --> $DIR/associated-types-eq-hr.rs:45:36 + --> $DIR/associated-types-eq-hr.rs:49:36 | LL | fn foo<T>() | --- required by a bound in this @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize` - --> $DIR/associated-types-eq-hr.rs:91:5 + --> $DIR/associated-types-eq-hr.rs:95:5 | LL | bar::<IntStruct>(); | ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize` | note: expected this to be `&usize` - --> $DIR/associated-types-eq-hr.rs:14:14 + --> $DIR/associated-types-eq-hr.rs:18:14 | LL | type A = &'a isize; | ^^^^^^^^^ = note: expected reference `&usize` found reference `&isize` note: required by a bound in `bar` - --> $DIR/associated-types-eq-hr.rs:52:36 + --> $DIR/associated-types-eq-hr.rs:56:36 | LL | fn bar<T>() | --- required by a bound in this @@ -43,7 +43,7 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>, | ^^^^^^^^^^^^^ required by this bound in `bar` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:96:5 + --> $DIR/associated-types-eq-hr.rs:100:5 | LL | tuple_one::<Tuple>(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -52,7 +52,7 @@ LL | tuple_one::<Tuple>(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:96:5 + --> $DIR/associated-types-eq-hr.rs:100:5 | LL | tuple_one::<Tuple>(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -61,7 +61,7 @@ LL | tuple_one::<Tuple>(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:102:5 + --> $DIR/associated-types-eq-hr.rs:106:5 | LL | tuple_two::<Tuple>(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -70,7 +70,7 @@ LL | tuple_two::<Tuple>(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:102:5 + --> $DIR/associated-types-eq-hr.rs:106:5 | LL | tuple_two::<Tuple>(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -79,7 +79,7 @@ LL | tuple_two::<Tuple>(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:112:5 + --> $DIR/associated-types-eq-hr.rs:116:5 | LL | tuple_four::<Tuple>(); | ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough diff --git a/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr b/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr index b306ae273e8..8d128821656 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr @@ -1,18 +1,18 @@ error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize` - --> $DIR/associated-types-eq-hr.rs:87:5 + --> $DIR/associated-types-eq-hr.rs:91:5 | LL | foo::<UintStruct>(); | ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize` | note: expected this to be `&isize` - --> $DIR/associated-types-eq-hr.rs:26:14 + --> $DIR/associated-types-eq-hr.rs:30:14 | LL | type A = &'a usize; | ^^^^^^^^^ = note: expected reference `&isize` found reference `&usize` note: required by a bound in `foo` - --> $DIR/associated-types-eq-hr.rs:45:36 + --> $DIR/associated-types-eq-hr.rs:49:36 | LL | fn foo<T>() | --- required by a bound in this @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize` - --> $DIR/associated-types-eq-hr.rs:91:5 + --> $DIR/associated-types-eq-hr.rs:95:5 | LL | bar::<IntStruct>(); | ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize` | note: expected this to be `&usize` - --> $DIR/associated-types-eq-hr.rs:14:14 + --> $DIR/associated-types-eq-hr.rs:18:14 | LL | type A = &'a isize; | ^^^^^^^^^ = note: expected reference `&usize` found reference `&isize` note: required by a bound in `bar` - --> $DIR/associated-types-eq-hr.rs:52:36 + --> $DIR/associated-types-eq-hr.rs:56:36 | LL | fn bar<T>() | --- required by a bound in this diff --git a/src/test/ui/associated-types/associated-types-eq-hr.rs b/src/test/ui/associated-types/associated-types-eq-hr.rs index fb391913c32..deb3fd059f8 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.rs +++ b/src/test/ui/associated-types/associated-types-eq-hr.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Check testing of equality constraints in a higher-ranked context. pub trait TheTrait<T> { @@ -94,14 +98,14 @@ pub fn call_bar() { pub fn call_tuple_one() { tuple_one::<Tuple>(); - //~^ ERROR implementation of `TheTrait` is not general enough - //~| ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough + //[base]~| ERROR implementation of `TheTrait` is not general enough } pub fn call_tuple_two() { tuple_two::<Tuple>(); - //~^ ERROR implementation of `TheTrait` is not general enough - //~| ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough + //[base]~| ERROR implementation of `TheTrait` is not general enough } pub fn call_tuple_three() { @@ -110,7 +114,7 @@ pub fn call_tuple_three() { pub fn call_tuple_four() { tuple_four::<Tuple>(); - //~^ ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough } fn main() {} diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.base.stderr index d5310c47fcf..fe238344263 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40 | LL | x: <I as Foo<&'a isize>>::A, | --------- these two types are declared with different lifetimes... diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr index e12d42e5ed0..ae6ccb8af55 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:29 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:29 | LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let z: I::A = if cond { x } else { y }; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40 | LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs index 9434a88e633..7ad12f2a1f3 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check projection of an associated type out of a higher-ranked // trait-bound in the context of a function body. @@ -20,7 +24,9 @@ fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( { // x and y here have two distinct lifetimes: let z: I::A = if cond { x } else { y }; - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } pub fn main() {} diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.stderr b/src/test/ui/associated-types/associated-types-subtyping-1.base.stderr index 58ceec9040b..35b3a83ee43 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.stderr +++ b/src/test/ui/associated-types/associated-types-subtyping-1.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/associated-types-subtyping-1.rs:26:38 + --> $DIR/associated-types-subtyping-1.rs:31:38 | LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) | ----- ----- these two types are declared with different lifetimes... @@ -8,7 +8,7 @@ LL | let _c: <T as Trait<'b>>::Type = a; | ^ ...but data from `y` flows into `x` here error[E0623]: lifetime mismatch - --> $DIR/associated-types-subtyping-1.rs:35:38 + --> $DIR/associated-types-subtyping-1.rs:41:38 | LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) | ----- ----- these two types are declared with different lifetimes... diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr index 11d3cfe5b46..44f918e12ba 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr +++ b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/associated-types-subtyping-1.rs:24:12 + --> $DIR/associated-types-subtyping-1.rs:28:12 | LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let a: <T as Trait<'a>>::Type = make_any(); = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/associated-types-subtyping-1.rs:35:13 + --> $DIR/associated-types-subtyping-1.rs:41:13 | LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.rs b/src/test/ui/associated-types/associated-types-subtyping-1.rs index 012cffb7b97..5b75e023b85 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.rs +++ b/src/test/ui/associated-types/associated-types-subtyping-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(unused_variables)] fn make_any<T>() -> T { loop {} } @@ -22,8 +26,10 @@ fn method2<'a,'b,T>(x: &'a T, y: &'b T) { // Note that &'static T <: &'a T. let a: <T as Trait<'a>>::Type = make_any(); + //[nll]~^ ERROR lifetime may not live long enough let b: <T as Trait<'b>>::Type = make_any(); - let _c: <T as Trait<'b>>::Type = a; //~ ERROR E0623 + let _c: <T as Trait<'b>>::Type = a; + //[base]~^ ERROR E0623 } fn method3<'a,'b,T>(x: &'a T, y: &'b T) @@ -32,7 +38,9 @@ fn method3<'a,'b,T>(x: &'a T, y: &'b T) // Note that &'static T <: &'a T. let a: <T as Trait<'a>>::Type = make_any(); let b: <T as Trait<'b>>::Type = make_any(); - let _c: <T as Trait<'a>>::Type = b; //~ ERROR E0623 + let _c: <T as Trait<'a>>::Type = b; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn method4<'a,'b,T>(x: &'a T, y: &'b T) diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr new file mode 100644 index 00000000000..ed5518b628f --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr @@ -0,0 +1,25 @@ +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant-nll.rs:51:5 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) + | ^ ...but data from `y` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant-nll.rs:51:8 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) + | ^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs new file mode 100644 index 00000000000..c3ac9949c21 --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs @@ -0,0 +1,55 @@ +#![feature(unboxed_closures)] + +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an contravariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross +//[ok] check-pass +//[oneuse] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should replace `project-fn-ret-contravariant.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +#![allow(dead_code, unused_variables)] + +fn foo<'a>() -> &'a u32 { loop { } } + +fn bar<T>(t: T, x: T::Output) -> T::Output + where T: FnOnce<()> +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: OK (surprisingly) +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let f /* : fn() -> &'static u32 */ = foo; // <-- inferred type annotated + let a = bar(f, x); // this is considered ok because fn args are contravariant... + let b = bar(f, y); // ...and hence we infer T to distinct values in each call. + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + bar(foo, x) //[transmute]~ ERROR E0759 +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, y); + let b = bar(foo, x); + (a, b) //[krisskross]~ ERROR lifetime mismatch [E0623] + //[krisskross]~^ ERROR lifetime mismatch [E0623] +} + +fn main() { } diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr new file mode 100644 index 00000000000..ca57142ecee --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr @@ -0,0 +1,11 @@ +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/project-fn-ret-contravariant-nll.rs:44:8 + | +LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + | ------- this data with lifetime `'a`... +LL | bar(foo, x) + | ^^^ - ...is used and required to live as long as `'static` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr deleted file mode 100644 index a5b6d640391..00000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:45:4 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | (a, b) - | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - | - = help: consider adding the following bound: `'a: 'b` - -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:45:4 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | (a, b) - | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -help: `'a` and `'b` must be the same: replace one with the other - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr index fa4c6adb5ff..52824b3922e 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-contravariant.rs:45:5 + --> $DIR/project-fn-ret-contravariant.rs:52:5 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | ------- ------------------ @@ -10,7 +10,7 @@ LL | (a, b) | ^ ...but data from `y` is returned here error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-contravariant.rs:45:8 + --> $DIR/project-fn-ret-contravariant.rs:52:8 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | ------- ------------------ diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr deleted file mode 100644 index ed900079cfc..00000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-contravariant.rs:50:1 - | -LL | fn main() { } - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr deleted file mode 100644 index ed900079cfc..00000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-contravariant.rs:50:1 - | -LL | fn main() { } - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs index 1eeb01ccc84..7bd245d1c34 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs @@ -1,5 +1,4 @@ #![feature(unboxed_closures)] -#![feature(rustc_attrs)] // Test for projection cache. We should be able to project distinct // lifetimes from `foo` as we reinstantiate it multiple times, but not @@ -7,6 +6,14 @@ // an contravariant position, which affects the results. // revisions: ok oneuse transmute krisskross +//[ok] check-pass +//[oneuse] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with +// `project-fn-ret-contravariant-nll.rs` The two would normally be just +// revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. #![allow(dead_code, unused_variables)] @@ -46,5 +53,4 @@ fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { //[krisskross]~^ ERROR lifetime mismatch [E0623] } -#[rustc_error] -fn main() { } //[ok,oneuse]~ ERROR fatal error triggered by #[rustc_error] +fn main() { } diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr deleted file mode 100644 index f532c96ed2c..00000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:38:4 - | -LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - | -- lifetime `'a` defined here -LL | bar(foo, x) - | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr index 33f1e0f05b2..3d7f36ca32b 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/project-fn-ret-contravariant.rs:38:8 + --> $DIR/project-fn-ret-contravariant.rs:45:8 | LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { | ------- this data with lifetime `'a`... diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.krisskross.stderr index 55532d6b9b3..231e98cf841 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.krisskross.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:56:5 + --> $DIR/project-fn-ret-invariant-nll.rs:63:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | (a, b) = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:56:5 + --> $DIR/project-fn-ret-invariant-nll.rs:63:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.oneuse.stderr index fd9eb05473a..1dbfff6a8cd 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.oneuse.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:39:13 + --> $DIR/project-fn-ret-invariant-nll.rs:46:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | let a = bar(f, x); = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:40:13 + --> $DIR/project-fn-ret-invariant-nll.rs:47:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs new file mode 100644 index 00000000000..6cd5c6417a9 --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs @@ -0,0 +1,68 @@ +#![feature(unboxed_closures)] +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an invariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross +//[ok] check-pass + +// compile-flags: -Z borrowck=mir +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should replace with `project-fn-ret-invariant.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +#![allow(dead_code, unused_variables)] + +use std::marker::PhantomData; + +struct Type<'a> { + // Invariant + data: PhantomData<fn(&'a u32) -> &'a u32>, +} + +fn foo<'a>() -> Type<'a> { + loop {} +} + +fn bar<T>(t: T, x: T::Output) -> T::Output +where + T: FnOnce<()>, +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: BAD +fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let f = foo; // <-- No consistent type can be inferred for `f` here. + let a = bar(f, x); //[oneuse]~ ERROR lifetime may not live long enough + let b = bar(f, y); //[oneuse]~ ERROR lifetime may not live long enough + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { + // Cannot instantiate `foo` with any lifetime other than `'a`, + // since it is provided as input. + + bar(foo, x) //[transmute]~ ERROR lifetime may not live long enough +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, y); + let b = bar(foo, x); + (a, b) + //[krisskross]~^ ERROR lifetime may not live long enough + //[krisskross]~| ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.transmute.stderr index 5a7ead72949..352914f020c 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.transmute.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:49:5 + --> $DIR/project-fn-ret-invariant-nll.rs:56:5 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -- lifetime `'a` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr index 9462121bdf2..fd1152dd80c 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:54:22 + --> $DIR/project-fn-ret-invariant.rs:60:22 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- @@ -9,7 +9,7 @@ LL | let a = bar(foo, y); | ^ ...but data from `x` is returned here error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:56:9 + --> $DIR/project-fn-ret-invariant.rs:62:9 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr deleted file mode 100644 index c3408500948..00000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-invariant.rs:60:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr index 64b57223908..1b10c6b990a 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:40:20 + --> $DIR/project-fn-ret-invariant.rs:46:20 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs index 08d864f7836..d42d99d7783 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs @@ -1,11 +1,17 @@ #![feature(unboxed_closures)] -#![feature(rustc_attrs)] // Test for projection cache. We should be able to project distinct // lifetimes from `foo` as we reinstantiate it multiple times, but not // if we do it just once. In this variant, the region `'a` is used in // an invariant position, which affects the results. // revisions: ok oneuse transmute krisskross +//[ok] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with `project-fn-ret-invariant-nll.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + #![allow(dead_code, unused_variables)] use std::marker::PhantomData; @@ -56,6 +62,4 @@ fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { (a, b) //[krisskross]~ ERROR E0623 } -#[rustc_error] fn main() {} -//[ok]~^ ERROR fatal error triggered by #[rustc_error] diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr index 609627aaa9e..8c1d9d1e284 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/project-fn-ret-invariant.rs:49:9 + --> $DIR/project-fn-ret-invariant.rs:55:9 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -------- this data with lifetime `'a`... @@ -8,7 +8,7 @@ LL | bar(foo, x) | ^^^ - ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/project-fn-ret-invariant.rs:45:37 + --> $DIR/project-fn-ret-invariant.rs:51:37 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr b/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr new file mode 100644 index 00000000000..732f5d9584b --- /dev/null +++ b/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/higher-ranked-projection.rs:25:5 + | +LL | foo(()); + | ^^^ lifetime mismatch + | + = note: expected reference `&'a ()` + found reference `&()` +note: the lifetime requirement is introduced here + --> $DIR/higher-ranked-projection.rs:16:33 + | +LL | where for<'a> &'a T: Mirror<Image=U> + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr b/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr new file mode 100644 index 00000000000..8b2b87223a5 --- /dev/null +++ b/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/higher-ranked-projection.rs:25:5 + | +LL | foo(()); + | ^^^^^^^ one type is more general than the other + | + = note: expected reference `&'a ()` + found reference `&()` +note: the lifetime requirement is introduced here + --> $DIR/higher-ranked-projection.rs:16:33 + | +LL | where for<'a> &'a T: Mirror<Image=U> + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-types/higher-ranked-projection.good.stderr b/src/test/ui/associated-types/higher-ranked-projection.good.stderr deleted file mode 100644 index 1dc41a2165f..00000000000 --- a/src/test/ui/associated-types/higher-ranked-projection.good.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/higher-ranked-projection.rs:24:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/higher-ranked-projection.rs b/src/test/ui/associated-types/higher-ranked-projection.rs index 1b5476d4c36..8b1046b6bbc 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.rs +++ b/src/test/ui/associated-types/higher-ranked-projection.rs @@ -1,6 +1,7 @@ -#![feature(rustc_attrs)] - -// revisions: good bad +// ignore-compare-mode-nll +// revisions: good badbase badnll +//[good] check-pass +// [badnll]compile-flags: -Zborrowck=mir trait Mirror { type Image; @@ -10,7 +11,7 @@ impl<T> Mirror for T { type Image = T; } -#[cfg(bad)] +#[cfg(any(badbase, badnll))] fn foo<U, T>(_t: T) where for<'a> &'a T: Mirror<Image=U> {} @@ -20,8 +21,8 @@ fn foo<U, T>(_t: T) where for<'a> &'a T: Mirror<Image=&'a U> {} -#[rustc_error] -fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error] +fn main() { foo(()); - //[bad]~^ ERROR mismatched types + //[badbase]~^ ERROR mismatched types + //[badnll]~^^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-20825-2.rs b/src/test/ui/associated-types/issue-20825-2.rs index b79a2973082..b79a2973082 100644 --- a/src/test/ui/issues/issue-20825-2.rs +++ b/src/test/ui/associated-types/issue-20825-2.rs diff --git a/src/test/ui/issues/issue-20825.rs b/src/test/ui/associated-types/issue-20825.rs index 516c304d8b3..516c304d8b3 100644 --- a/src/test/ui/issues/issue-20825.rs +++ b/src/test/ui/associated-types/issue-20825.rs diff --git a/src/test/ui/issues/issue-20825.stderr b/src/test/ui/associated-types/issue-20825.stderr index be2bbd44800..be2bbd44800 100644 --- a/src/test/ui/issues/issue-20825.stderr +++ b/src/test/ui/associated-types/issue-20825.stderr diff --git a/src/test/ui/async-await/issue-76547.stderr b/src/test/ui/async-await/issue-76547.base.stderr index ac5f99970c8..34705d4838e 100644 --- a/src/test/ui/async-await/issue-76547.stderr +++ b/src/test/ui/async-await/issue-76547.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-76547.rs:20:13 + --> $DIR/issue-76547.rs:24:13 | LL | async fn fut(bufs: &mut [&mut [u8]]) { | ---------------- these two types are declared with different lifetimes... @@ -7,7 +7,7 @@ LL | ListFut(bufs).await | ^^^^ ...but data from `bufs` flows into `bufs` here error[E0623]: lifetime mismatch - --> $DIR/issue-76547.rs:34:14 + --> $DIR/issue-76547.rs:39:14 | LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | ---------------- these two types are declared with different lifetimes... diff --git a/src/test/ui/async-await/issue-76547.nll.stderr b/src/test/ui/async-await/issue-76547.nll.stderr index 0ac2a396669..bc30da1e389 100644 --- a/src/test/ui/async-await/issue-76547.nll.stderr +++ b/src/test/ui/async-await/issue-76547.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-76547.rs:20:13 + --> $DIR/issue-76547.rs:24:13 | LL | async fn fut(bufs: &mut [&mut [u8]]) { | - - let's call the lifetime of this reference `'2` @@ -9,7 +9,7 @@ LL | ListFut(bufs).await | ^^^^ this usage requires that `'1` must outlive `'2` error: lifetime may not live long enough - --> $DIR/issue-76547.rs:34:14 + --> $DIR/issue-76547.rs:39:14 | LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | - - let's call the lifetime of this reference `'2` diff --git a/src/test/ui/async-await/issue-76547.rs b/src/test/ui/async-await/issue-76547.rs index 5b3ee5b95c4..45c7ab63135 100644 --- a/src/test/ui/async-await/issue-76547.rs +++ b/src/test/ui/async-await/issue-76547.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test for diagnostic improvement issue #76547 // edition:2018 @@ -18,7 +22,8 @@ impl<'a> Future for ListFut<'a> { async fn fut(bufs: &mut [&mut [u8]]) { ListFut(bufs).await - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]); @@ -32,7 +37,8 @@ impl<'a> Future for ListFut2<'a> { async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { ListFut2(bufs).await - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.base.stderr index e23277543c6..7577b95fa2e 100644 --- a/src/test/ui/async-await/issues/issue-62097.stderr +++ b/src/test/ui/async-await/issues/issue-62097.base.stderr @@ -1,13 +1,14 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-62097.rs:12:31 + --> $DIR/issue-62097.rs:16:31 | LL | pub async fn run_dummy_fn(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... +LL | LL | foo(|| self.bar()).await; | --- ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by this bound - --> $DIR/issue-62097.rs:4:19 + --> $DIR/issue-62097.rs:8:19 | LL | F: FnOnce() + 'static | ^^^^^^^ diff --git a/src/test/ui/async-await/issues/issue-62097.nll.stderr b/src/test/ui/async-await/issues/issue-62097.nll.stderr index 786f6213260..b2b7c46d348 100644 --- a/src/test/ui/async-await/issues/issue-62097.nll.stderr +++ b/src/test/ui/async-await/issues/issue-62097.nll.stderr @@ -1,5 +1,5 @@ error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function - --> $DIR/issue-62097.rs:13:13 + --> $DIR/issue-62097.rs:18:13 | LL | foo(|| self.bar()).await; | ^^ ---- `self` is borrowed here @@ -7,7 +7,7 @@ LL | foo(|| self.bar()).await; | may outlive borrowed value `self` | note: function requires argument type to outlive `'static` - --> $DIR/issue-62097.rs:13:9 + --> $DIR/issue-62097.rs:18:9 | LL | foo(|| self.bar()).await; | ^^^^^^^^^^^^^^^^^^ @@ -17,13 +17,14 @@ LL | foo(move || self.bar()).await; | ++++ error[E0521]: borrowed data escapes outside of associated function - --> $DIR/issue-62097.rs:13:9 + --> $DIR/issue-62097.rs:18:9 | LL | pub async fn run_dummy_fn(&self) { | ----- | | | `self` is a reference that is only valid in the associated function body | let's call the lifetime of this reference `'1` +LL | LL | foo(|| self.bar()).await; | ^^^^^^^^^^^^^^^^^^ | | diff --git a/src/test/ui/async-await/issues/issue-62097.rs b/src/test/ui/async-await/issues/issue-62097.rs index 66ebbd83ffa..d2260cd68c1 100644 --- a/src/test/ui/async-await/issues/issue-62097.rs +++ b/src/test/ui/async-await/issues/issue-62097.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 async fn foo<F>(fun: F) where @@ -9,8 +13,11 @@ where struct Struct; impl Struct { - pub async fn run_dummy_fn(&self) { //~ ERROR E0759 + pub async fn run_dummy_fn(&self) { + //[base]~^ ERROR E0759 foo(|| self.bar()).await; + //[nll]~^ ERROR closure may outlive the current function + //[nll]~| ERROR borrowed data escapes outside of associated function } pub fn bar(&self) {} diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.base.stderr index 8f602a1492a..2ff85a27a46 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.base.stderr @@ -1,11 +1,11 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-63388-1.rs:14:9 + --> $DIR/issue-63388-1.rs:19:9 | LL | &'a self, foo: &dyn Foo | -------- this parameter and the return type are declared with different lifetimes... LL | ) -> &dyn Foo | -------- -LL | { +... LL | foo | ^^^ ...but data from `foo` is returned here diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr index 464459d2d61..eee0cee278b 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-63388-1.rs:13:5 + --> $DIR/issue-63388-1.rs:17:5 | LL | async fn do_sth<'a>( | -- lifetime `'a` defined here @@ -7,7 +7,9 @@ LL | &'a self, foo: &dyn Foo | - let's call the lifetime of this reference `'1` LL | ) -> &dyn Foo LL | / { +LL | | LL | | foo +LL | | LL | | } | |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs index baecf49c798..c45d2a42177 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.rs +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 struct Xyz { @@ -11,7 +15,9 @@ impl Xyz { &'a self, foo: &dyn Foo ) -> &dyn Foo { - foo //~ ERROR lifetime mismatch + //[nll]~^ ERROR lifetime may not live long enough + foo + //[base]~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/async-await/issues/issue-72312.stderr b/src/test/ui/async-await/issues/issue-72312.base.stderr index 798f755765c..a4bdc447f65 100644 --- a/src/test/ui/async-await/issues/issue-72312.stderr +++ b/src/test/ui/async-await/issues/issue-72312.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-72312.rs:10:24 + --> $DIR/issue-72312.rs:14:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... @@ -8,12 +8,12 @@ LL | &self; | ----- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/issue-72312.rs:13:9 + --> $DIR/issue-72312.rs:20:9 | LL | require_static(async move { | ^^^^^^^^^^^^^^ note: `'static` lifetime requirement introduced by this bound - --> $DIR/issue-72312.rs:2:22 + --> $DIR/issue-72312.rs:6:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ diff --git a/src/test/ui/async-await/issues/issue-72312.nll.stderr b/src/test/ui/async-await/issues/issue-72312.nll.stderr index 068d8c64d68..53b2c931cce 100644 --- a/src/test/ui/async-await/issues/issue-72312.nll.stderr +++ b/src/test/ui/async-await/issues/issue-72312.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of associated function - --> $DIR/issue-72312.rs:13:24 + --> $DIR/issue-72312.rs:20:24 | LL | pub async fn start(&self) { | ----- @@ -9,6 +9,10 @@ LL | pub async fn start(&self) { ... LL | require_static(async move { | ________________________^ +LL | | +LL | | +LL | | +LL | | LL | | &self; LL | | }); | | ^ diff --git a/src/test/ui/async-await/issues/issue-72312.rs b/src/test/ui/async-await/issues/issue-72312.rs index eb7d12e290c..c1eceefd643 100644 --- a/src/test/ui/async-await/issues/issue-72312.rs +++ b/src/test/ui/async-await/issues/issue-72312.rs @@ -1,17 +1,28 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 fn require_static<T: 'static>(val: T) -> T { - //~^ NOTE 'static` lifetime requirement introduced by this bound + //[base]~^ NOTE 'static` lifetime requirement introduced by this bound val } struct Problem; impl Problem { - pub async fn start(&self) { //~ ERROR E0759 - //~^ NOTE this data with an anonymous lifetime `'_` - //~| NOTE in this expansion of desugaring of `async` block or function - require_static(async move { //~ NOTE ...and is required to live as long as `'static` here - &self; //~ NOTE ...is used here... + pub async fn start(&self) { + //[base]~^ ERROR E0759 + //[base]~| NOTE this data with an anonymous lifetime `'_` + //[base]~| NOTE in this expansion of desugaring of `async` block or function + //[nll]~^^^^ NOTE let's call + //[nll]~| NOTE `self` is a reference + require_static(async move { + //[base]~^ NOTE ...and is required to live as long as `'static` here + //[nll]~^^ ERROR borrowed data escapes + //[nll]~| NOTE `self` escapes + //[nll]~| NOTE argument requires + &self; //[base]~ NOTE ...is used here... }); } } diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr index 2eb3a07059f..907c1f6c407 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr @@ -1,17 +1,18 @@ error[E0623]: lifetime mismatch - --> $DIR/ret-impl-trait-one.rs:10:85 + --> $DIR/ret-impl-trait-one.rs:14:85 | LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { | ______________________________________________________------_____-------------------_^ | | | | | this parameter and the return type are declared with different lifetimes... LL | | +LL | | LL | | (a, b) LL | | } | |_^ ...but data from `a` is returned here error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:21:80 | LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { | ____________________________________--__________________________________________^ diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr index cdb141c0e3e..dbf7293a389 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ret-impl-trait-one.rs:10:85 + --> $DIR/ret-impl-trait-one.rs:14:85 | LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { | ________________________________--__--_______________________________________________^ @@ -7,6 +7,7 @@ LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trai | | | lifetime `'b` defined here | | lifetime `'a` defined here LL | | +LL | | LL | | (a, b) LL | | } | |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` @@ -14,7 +15,7 @@ LL | | } = help: consider adding the following bound: `'a: 'b` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:21:80 | LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { | ____________________________________--__________________________________________^ diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs index 4f32489014d..f4c309b4c10 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 // Test that a feature gate is needed to use `impl Trait` as the @@ -8,7 +12,8 @@ impl<T> Trait<'_> for T { } // Fails to recognize that both 'a and 'b are mentioned and should thus be accepted async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough (a, b) } diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.base.stderr index 67b6f64eaa6..3d6d00a0f95 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5 + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5 | LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { | ------------- ----- diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr index f28c42ce2d5..7c4de57320e 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5 + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5 | LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs index a7c9200d35a..60101d06820 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. @@ -7,7 +11,8 @@ struct S<'a> { fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { S { pointer: &mut *p.pointer } - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr new file mode 100644 index 00000000000..3518a663e59 --- /dev/null +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr @@ -0,0 +1,93 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:51:11 + | +LL | f(f(10)); + | - ^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call + +error[E0382]: use of moved value: `f` + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 + | +LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) { + | - move occurs because `f` has type `Box<F>`, which does not implement the `Copy` trait +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:63:11 + | +LL | f(f(10)); + | - ^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call + +error[E0382]: use of moved value: `f` + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 + | +LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) { + | - move occurs because `f` has type `Box<dyn FnOnce(i32) -> i32>`, which does not implement the `Copy` trait +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:108:27 + | +LL | double_access(&mut a, &a); + | ------------- ------ ^^ immutable borrow occurs here + | | | + | | mutable borrow occurs here + | mutable borrow later used by call + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 + | +LL | i[i[3]] = 4; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | mutable borrow later used here + | +help: try adding a local storing this... + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 + | +LL | i[i[3]] = 4; + | ^^^^ +help: ...and then using that local here + --> $DIR/two-phase-nonrecv-autoref.rs:133:5 + | +LL | i[i[3]] = 4; + | ^^^^^^^ + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 + | +LL | i[i[3]] = i[4]; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | mutable borrow later used here + | +help: try adding a local storing this... + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 + | +LL | i[i[3]] = i[4]; + | ^^^^ +help: ...and then using that local here + --> $DIR/two-phase-nonrecv-autoref.rs:139:5 + | +LL | i[i[3]] = i[4]; + | ^^^^^^^ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0382, E0499, E0502. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index 0f2daaf99d9..3518a663e59 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -8,7 +8,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:59:11 + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 | LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) { | - move occurs because `f` has type `Box<F>`, which does not implement the `Copy` trait @@ -18,7 +18,7 @@ LL | f(f(10)); | value moved here error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:65:11 + --> $DIR/two-phase-nonrecv-autoref.rs:63:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -27,7 +27,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:73:11 + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) { | - move occurs because `f` has type `Box<dyn FnOnce(i32) -> i32>`, which does not implement the `Copy` trait @@ -37,7 +37,7 @@ LL | f(f(10)); | value moved here error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:112:27 + --> $DIR/two-phase-nonrecv-autoref.rs:108:27 | LL | double_access(&mut a, &a); | ------------- ------ ^^ immutable borrow occurs here @@ -46,7 +46,7 @@ LL | double_access(&mut a, &a); | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:138:7 + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 | LL | i[i[3]] = 4; | --^---- @@ -56,18 +56,18 @@ LL | i[i[3]] = 4; | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:138:7 + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 | LL | i[i[3]] = 4; | ^^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:138:5 + --> $DIR/two-phase-nonrecv-autoref.rs:133:5 | LL | i[i[3]] = 4; | ^^^^^^^ error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:143:7 + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 | LL | i[i[3]] = i[4]; | --^---- @@ -77,12 +77,12 @@ LL | i[i[3]] = i[4]; | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:143:7 + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 | LL | i[i[3]] = i[4]; | ^^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:143:5 + --> $DIR/two-phase-nonrecv-autoref.rs:139:5 | LL | i[i[3]] = i[4]; | ^^^^^^^ diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index 918c7a1be19..b6cc099a614 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -1,4 +1,4 @@ -// revisions: nll +// revisions: base nll //[nll]compile-flags: -Z borrowck=mir //[g2p]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref @@ -49,30 +49,26 @@ fn overloaded_call_traits() { fn twice_ten_sm<F: FnMut(i32) -> i32>(f: &mut F) { f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //~^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_si<F: Fn(i32) -> i32>(f: &mut F) { f(f(10)); } fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) { f(f(10)); - //[nll]~^ ERROR use of moved value: `f` - //[g2p]~^^ ERROR use of moved value: `f` + //~^ ERROR use of moved value: `f` } fn twice_ten_om(f: &mut dyn FnMut(i32) -> i32) { f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //~^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_oi(f: &mut dyn Fn(i32) -> i32) { f(f(10)); } fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) { f(f(10)); - //[nll]~^ ERROR use of moved value: `f` - //[g2p]~^^ ERROR use of moved value: `f` + //~^ ERROR use of moved value: `f` } twice_ten_sm(&mut |x| x + 1); @@ -110,8 +106,7 @@ fn coerce_unsized() { // This is not okay. double_access(&mut a, &a); - //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // But this is okay. a.m(a.i(10)); @@ -136,12 +131,14 @@ impl IndexMut<i32> for I { fn coerce_index_op() { let mut i = I(10); i[i[3]] = 4; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + // Shoud be accepted with g2p i[3] = i[4]; i[i[3]] = i[4]; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + // Shoud be accepted with g2p } fn main() { diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.base.stderr index b25a7ab3dc6..c3efe16e251 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:16:52 + --> $DIR/expect-fn-supply-fn.rs:20:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); = note: expected fn pointer `fn(&u32)` found fn pointer `fn(&'x u32)` note: the anonymous lifetime #1 defined here... - --> $DIR/expect-fn-supply-fn.rs:16:48 + --> $DIR/expect-fn-supply-fn.rs:20:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^ note: ...does not necessarily outlive the lifetime `'x` as defined here - --> $DIR/expect-fn-supply-fn.rs:13:36 + --> $DIR/expect-fn-supply-fn.rs:17:36 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | ^^ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:16:52 + --> $DIR/expect-fn-supply-fn.rs:20:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ lifetime mismatch @@ -26,18 +26,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); = note: expected fn pointer `fn(&u32)` found fn pointer `fn(&'x u32)` note: the lifetime `'x` as defined here... - --> $DIR/expect-fn-supply-fn.rs:13:36 + --> $DIR/expect-fn-supply-fn.rs:17:36 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | ^^ note: ...does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/expect-fn-supply-fn.rs:16:48 + --> $DIR/expect-fn-supply-fn.rs:20:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:32:52 + --> $DIR/expect-fn-supply-fn.rs:38:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); | ^^^^^^^^ one type is more general than the other @@ -46,7 +46,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); found fn pointer `for<'r> fn(&'r u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:39:53 + --> $DIR/expect-fn-supply-fn.rs:45:53 | LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ one type is more general than the other @@ -55,7 +55,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); found fn pointer `fn(&'x u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:48:53 + --> $DIR/expect-fn-supply-fn.rs:54:53 | LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { | ^^^^^^^ one type is more general than the other diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr index 26f47eb684d..52e2898d2bb 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/expect-fn-supply-fn.rs:16:49 + --> $DIR/expect-fn-supply-fn.rs:20:49 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | -- lifetime `'x` defined here @@ -11,7 +11,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-fn-supply-fn.rs:16:49 + --> $DIR/expect-fn-supply-fn.rs:20:49 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | -- lifetime `'x` defined here @@ -20,7 +20,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^ requires that `'x` must outlive `'static` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:32:49 + --> $DIR/expect-fn-supply-fn.rs:38:49 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); | ^ one type is more general than the other @@ -29,7 +29,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); found fn pointer `fn(&u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:39:50 + --> $DIR/expect-fn-supply-fn.rs:45:50 | LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); | ^ one type is more general than the other @@ -38,7 +38,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); found fn pointer `for<'r> fn(&'r u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:48:50 + --> $DIR/expect-fn-supply-fn.rs:54:50 | LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { | ^ one type is more general than the other diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs index c81c40c18b4..1715f56ff63 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with_closure_expecting_fn_with_free_region<F>(_: F) where F: for<'a> FnOnce(fn(&'a u32), &i32), @@ -14,8 +18,10 @@ fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { // Here, the type given for `'x` "obscures" a region from the // expected signature that is bound at closure level. with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); - //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR mismatched types + //[base]~| ERROR mismatched types + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } fn expect_free_supply_free_from_closure() { diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr index af1f908a808..93ed51fa7e1 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr @@ -1,22 +1,24 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9 | LL | fn foo(x: &()) { | --- this data with an anonymous lifetime `'_`... LL | bar(|| { | _________^ LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | |_____^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | bar(|| { | ^^^ note: `'static` lifetime requirement introduced by this bound - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:1:39 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:39 | LL | fn bar<F>(blk: F) where F: FnOnce() + 'static { | ^^^^^^^ diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr index af3810e91ae..dc5188a8651 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | fn foo(x: &()) { | - - let's call the lifetime of this reference `'1` @@ -7,6 +7,8 @@ LL | fn foo(x: &()) { | `x` is a reference that is only valid in the function body LL | / bar(|| { LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | | ^ @@ -15,19 +17,21 @@ LL | | }) | argument requires that `'1` must outlive `'static` error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9 | LL | bar(|| { | ^^ may outlive borrowed value `x` -LL | +... LL | let _ = x; | - `x` is borrowed here | note: function requires argument type to outlive `'static` - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | / bar(|| { LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | |______^ diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs index cbdc8b7deef..6c49cd76b13 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs @@ -1,9 +1,15 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + fn bar<F>(blk: F) where F: FnOnce() + 'static { } fn foo(x: &()) { bar(|| { - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes + //[nll]~| ERROR closure may outlive let _ = x; }) } diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr index f584b0c8382..be81efd27c4 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/expect-region-supply-region-2.rs:14:33 + --> $DIR/expect-region-supply-region-2.rs:18:33 | LL | closure_expecting_bound(|x: &'x u32| { | ^^^^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | closure_expecting_bound(|x: &'x u32| { = note: expected reference `&u32` found reference `&'x u32` note: the anonymous lifetime #1 defined here... - --> $DIR/expect-region-supply-region-2.rs:14:29 + --> $DIR/expect-region-supply-region-2.rs:18:29 | LL | closure_expecting_bound(|x: &'x u32| { | _____________________________^ @@ -19,13 +19,13 @@ LL | | f = Some(x); LL | | }); | |_____^ note: ...does not necessarily outlive the lifetime `'x` as defined here - --> $DIR/expect-region-supply-region-2.rs:9:30 + --> $DIR/expect-region-supply-region-2.rs:13:30 | LL | fn expect_bound_supply_named<'x>() { | ^^ error[E0308]: mismatched types - --> $DIR/expect-region-supply-region-2.rs:14:33 + --> $DIR/expect-region-supply-region-2.rs:18:33 | LL | closure_expecting_bound(|x: &'x u32| { | ^^^^^^^ lifetime mismatch @@ -33,12 +33,12 @@ LL | closure_expecting_bound(|x: &'x u32| { = note: expected reference `&u32` found reference `&'x u32` note: the lifetime `'x` as defined here... - --> $DIR/expect-region-supply-region-2.rs:9:30 + --> $DIR/expect-region-supply-region-2.rs:13:30 | LL | fn expect_bound_supply_named<'x>() { | ^^ note: ...does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/expect-region-supply-region-2.rs:14:29 + --> $DIR/expect-region-supply-region-2.rs:18:29 | LL | closure_expecting_bound(|x: &'x u32| { | _____________________________^ diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr index 9aab51c986c..4a9a19422d7 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/expect-region-supply-region-2.rs:14:30 + --> $DIR/expect-region-supply-region-2.rs:18:30 | LL | fn expect_bound_supply_named<'x>() { | -- lifetime `'x` defined here @@ -10,7 +10,7 @@ LL | closure_expecting_bound(|x: &'x u32| { | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-region-supply-region-2.rs:14:30 + --> $DIR/expect-region-supply-region-2.rs:18:30 | LL | fn expect_bound_supply_named<'x>() { | -- lifetime `'x` defined here diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs index 7405b1a1e3a..072ba57c10b 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(warnings)] fn closure_expecting_bound<F>(_: F) @@ -12,8 +16,10 @@ fn expect_bound_supply_named<'x>() { // Here we give a type annotation that `x` should be free. We get // an error because of that. closure_expecting_bound(|x: &'x u32| { - //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR mismatched types + //[base]~| ERROR mismatched types + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough // Borrowck doesn't get a chance to run, but if it did it should error // here. diff --git a/src/test/ui/const-generics/invariant.stderr b/src/test/ui/const-generics/invariant.base.stderr index 318c885e6a6..255900e19bb 100644 --- a/src/test/ui/const-generics/invariant.stderr +++ b/src/test/ui/const-generics/invariant.base.stderr @@ -1,5 +1,5 @@ warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())` - --> $DIR/invariant.rs:14:1 + --> $DIR/invariant.rs:18:1 | LL | impl SadBee for for<'a> fn(&'a ()) { | ---------------------------------- first implementation here @@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) { = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details error[E0308]: mismatched types - --> $DIR/invariant.rs:27:5 + --> $DIR/invariant.rs:31:5 | LL | v | ^ one type is more general than the other diff --git a/src/test/ui/const-generics/invariant.nll.stderr b/src/test/ui/const-generics/invariant.nll.stderr index ce0fad10471..f684f7fddc8 100644 --- a/src/test/ui/const-generics/invariant.nll.stderr +++ b/src/test/ui/const-generics/invariant.nll.stderr @@ -1,5 +1,5 @@ warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())` - --> $DIR/invariant.rs:14:1 + --> $DIR/invariant.rs:18:1 | LL | impl SadBee for for<'a> fn(&'a ()) { | ---------------------------------- first implementation here @@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) { = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details error[E0308]: mismatched types - --> $DIR/invariant.rs:27:5 + --> $DIR/invariant.rs:31:5 | LL | v | ^ one type is more general than the other diff --git a/src/test/ui/const-generics/invariant.rs b/src/test/ui/const-generics/invariant.rs index ee191b65c2c..65d1ee9420c 100644 --- a/src/test/ui/const-generics/invariant.rs +++ b/src/test/ui/const-generics/invariant.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generic_const_exprs)] #![allow(incomplete_features)] use std::marker::PhantomData; diff --git a/src/test/ui/error-codes/E0490.stderr b/src/test/ui/error-codes/E0490.base.stderr index 96e99bd88a4..5cb62e19ccf 100644 --- a/src/test/ui/error-codes/E0490.stderr +++ b/src/test/ui/error-codes/E0490.base.stderr @@ -1,72 +1,72 @@ error[E0490]: a value of type `&'b ()` is borrowed for too long - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: the type is valid for the lifetime `'a` as defined here - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: but the borrow lasts for the lifetime `'b` as defined here - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: first, the lifetime cannot outlive the lifetime `'b` as defined here... - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the type `&'b ()` is not borrowed for too long - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: first, the lifetime cannot outlive the lifetime `'b` as defined here... - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the expression is assignable - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ = note: expected `&'a &()` found `&'a &'b ()` note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the reference type `&'a &()` does not outlive the data it points at - --> $DIR/E0490.rs:2:12 + --> $DIR/E0490.rs:6:12 | LL | let x: &'a _ = &y; | ^^^^^ diff --git a/src/test/ui/error-codes/E0490.nll.stderr b/src/test/ui/error-codes/E0490.nll.stderr index a1c33bbcd5f..80bf076e2bd 100644 --- a/src/test/ui/error-codes/E0490.nll.stderr +++ b/src/test/ui/error-codes/E0490.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/E0490.rs:2:12 + --> $DIR/E0490.rs:6:12 | LL | fn f<'a, 'b>(y: &'b ()) { | -- -- lifetime `'b` defined here @@ -11,7 +11,7 @@ LL | let x: &'a _ = &y; = help: consider adding the following bound: `'b: 'a` error[E0597]: `y` does not live long enough - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | fn f<'a, 'b>(y: &'b ()) { | -- lifetime `'a` defined here diff --git a/src/test/ui/error-codes/E0490.rs b/src/test/ui/error-codes/E0490.rs index 36bafa2bd86..304548215dc 100644 --- a/src/test/ui/error-codes/E0490.rs +++ b/src/test/ui/error-codes/E0490.rs @@ -1,8 +1,14 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn f<'a, 'b>(y: &'b ()) { let x: &'a _ = &y; - //~^ E0490 - //~| E0495 - //~| E0495 + //[base]~^ E0490 + //[base]~| E0495 + //[base]~| E0495 + //[nll]~^^^^ lifetime may not live long enough + //[nll]~| E0597 } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.rs b/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.rs deleted file mode 100644 index 0e3f6b168be..00000000000 --- a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.rs +++ /dev/null @@ -1,8 +0,0 @@ -crate struct Bender { //~ ERROR `crate` visibility modifier is experimental - earth: bool, - fire: bool, - air: bool, - water: bool, -} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr b/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr deleted file mode 100644 index 969606375c3..00000000000 --- a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `crate` visibility modifier is experimental - --> $DIR/feature-gate-crate_visibility_modifier.rs:1:1 - | -LL | crate struct Bender { - | ^^^^^ - | - = note: see issue #53120 <https://github.com/rust-lang/rust/issues/53120> for more information - = help: add `#![feature(crate_visibility_modifier)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.base.stderr index 93ab5dceee9..6f0ea1af057 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + --> $DIR/implied-bounds-unnorm-associated-type.rs:18:5 | LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { | ------- ---------- diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr index 8096f08385c..a7a91f3e685 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + --> $DIR/implied-bounds-unnorm-associated-type.rs:18:5 | LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs index 2e5ac7d7398..30bd042009b 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // check-fail // See issue #91068. Types in the substs of an associated type can't be implied // to be WF, since they don't actually have to be constructed. @@ -11,7 +15,9 @@ impl<T> Trait for T { } fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { - s //~ ERROR lifetime mismatch [E0623] + s + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.base.stderr index da3d3249f0e..d44c8eb1b82 100644 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ b/src/test/ui/generator/auto-trait-regions.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/generator/auto-trait-regions.nll.stderr b/src/test/ui/generator/auto-trait-regions.nll.stderr index 76970fb7872..25456881fa0 100644 --- a/src/test/ui/generator/auto-trait-regions.nll.stderr +++ b/src/test/ui/generator/auto-trait-regions.nll.stderr @@ -1,31 +1,31 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:46:24 + --> $DIR/auto-trait-regions.rs:50:24 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | | creates a temporary which is freed while still in use -LL | yield; +... LL | assert_foo(a); | - borrow later used here | = note: consider using a `let` binding to create a longer lived value error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:46:35 + --> $DIR/auto-trait-regions.rs:50:35 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | | creates a temporary which is freed while still in use -LL | yield; +... LL | assert_foo(a); | - borrow later used here | = note: consider using a `let` binding to create a longer lived value error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -34,7 +34,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/generator/auto-trait-regions.rs b/src/test/ui/generator/auto-trait-regions.rs index 8f1e4f1b66f..98af4a39391 100644 --- a/src/test/ui/generator/auto-trait-regions.rs +++ b/src/test/ui/generator/auto-trait-regions.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generators)] #![feature(auto_traits)] #![feature(negative_impls)] @@ -30,7 +34,7 @@ fn main() { }; assert_foo(gen); //~^ ERROR implementation of `Foo` is not general enough - //~| ERROR implementation of `Foo` is not general enough + //[base]~^^ ERROR implementation of `Foo` is not general enough // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); @@ -44,10 +48,12 @@ fn main() { // Disallow impls which relates lifetimes in the generator interior let gen = || { let a = A(&mut true, &mut true, No); + //[nll]~^ temporary value dropped while borrowed + //[nll]~| temporary value dropped while borrowed yield; assert_foo(a); }; assert_foo(gen); //~^ ERROR not general enough - //~| ERROR not general enough + //[base]~^^ ERROR not general enough } diff --git a/src/test/ui/generator/generator-region-requirements.stderr b/src/test/ui/generator/generator-region-requirements.base.stderr index 30d67050b90..89f6a81ad3b 100644 --- a/src/test/ui/generator/generator-region-requirements.stderr +++ b/src/test/ui/generator/generator-region-requirements.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/generator-region-requirements.rs:8:9 + --> $DIR/generator-region-requirements.rs:12:9 | LL | fn dangle(x: &mut i32) -> &'static mut i32 { | -------- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/generator/generator-region-requirements.nll.stderr b/src/test/ui/generator/generator-region-requirements.nll.stderr index b4530cfda2b..9f54c6c9dc1 100644 --- a/src/test/ui/generator/generator-region-requirements.nll.stderr +++ b/src/test/ui/generator/generator-region-requirements.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/generator-region-requirements.rs:13:51 + --> $DIR/generator-region-requirements.rs:17:51 | LL | fn dangle(x: &mut i32) -> &'static mut i32 { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs index cec68509a66..ec718b17460 100644 --- a/src/test/ui/generator/generator-region-requirements.rs +++ b/src/test/ui/generator/generator-region-requirements.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generators, generator_trait)] use std::ops::{Generator, GeneratorState}; use std::pin::Pin; @@ -6,11 +10,12 @@ fn dangle(x: &mut i32) -> &'static mut i32 { let mut g = || { yield; x - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] }; loop { match Pin::new(&mut g).resume(()) { GeneratorState::Complete(c) => return c, + //[nll]~^ ERROR lifetime may not live long enough GeneratorState::Yielded(_) => (), } } diff --git a/src/test/ui/generator/resume-arg-late-bound.stderr b/src/test/ui/generator/resume-arg-late-bound.base.stderr index 5e60e33584e..8521951d0c9 100644 --- a/src/test/ui/generator/resume-arg-late-bound.stderr +++ b/src/test/ui/generator/resume-arg-late-bound.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the required lifetime does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/resume-arg-late-bound.rs:11:15 + --> $DIR/resume-arg-late-bound.rs:15:15 | LL | let gen = |arg: &mut bool| { | _______________^ @@ -16,13 +16,13 @@ LL | | *arg = true; LL | | }; | |_____^ note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^ lifetime mismatch @@ -30,7 +30,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/resume-arg-late-bound.rs:11:15 + --> $DIR/resume-arg-late-bound.rs:15:15 | LL | let gen = |arg: &mut bool| { | _______________^ @@ -39,7 +39,7 @@ LL | | *arg = true; LL | | }; | |_____^ note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/generator/resume-arg-late-bound.nll.stderr b/src/test/ui/generator/resume-arg-late-bound.nll.stderr index b5144c607a8..868d1352f25 100644 --- a/src/test/ui/generator/resume-arg-late-bound.nll.stderr +++ b/src/test/ui/generator/resume-arg-late-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^^^^^^ one type is more general than the other @@ -7,7 +7,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/generator/resume-arg-late-bound.rs b/src/test/ui/generator/resume-arg-late-bound.rs index a8f657eaabe..b973d8a300a 100644 --- a/src/test/ui/generator/resume-arg-late-bound.rs +++ b/src/test/ui/generator/resume-arg-late-bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + //! Tests that we cannot produce a generator that accepts a resume argument //! with any lifetime and then stores it across a `yield`. @@ -14,5 +18,5 @@ fn main() { }; test(gen); //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^^ ERROR mismatched types } diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr b/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr deleted file mode 100644 index 3da7794b3d2..00000000000 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator.rs:14:45 - | -LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; - | ------------------------------------------------------------------------ definition of `from_iter` from trait -... -LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self { - | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0276`. diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr b/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr index c5588b0912b..aa1e50014fe 100644 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr +++ b/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr @@ -1,5 +1,5 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator.rs:14:45 + --> $DIR/lending_iterator.rs:16:45 | LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; | ------------------------------------------------------------------------ definition of `from_iter` from trait @@ -8,7 +8,7 @@ LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` error[E0311]: the parameter type `Self` may not live long enough - --> $DIR/lending_iterator.rs:35:9 + --> $DIR/lending_iterator.rs:37:9 | LL | <B as FromLendingIterator<A>>::from_iter(self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | <B as FromLendingIterator<A>>::from_iter(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/lending_iterator.rs:10:45 + --> $DIR/lending_iterator.rs:12:45 | LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; | ^^^^^^^^^^^^ diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.rs b/src/test/ui/generic-associated-types/extended/lending_iterator.rs index df11ab21249..6048e6e87c0 100644 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.rs +++ b/src/test/ui/generic-associated-types/extended/lending_iterator.rs @@ -1,3 +1,5 @@ +// FIXME(nll): this is experimental anyways, don't really care about the output +// ignore-compare-mode-nll // revisions: base extended //[base] check-fail //[extended] check-pass diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.base.stderr index 32c5ccf1648..341e2e05d1c 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:17:7 + --> $DIR/projection-type-lifetime-mismatch.rs:21:7 | LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () { | ------------------------------- this data with an anonymous lifetime `'_`... @@ -9,7 +9,7 @@ LL | x.m() | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:22:7 + --> $DIR/projection-type-lifetime-mismatch.rs:27:7 | LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () { | -- this data with an anonymous lifetime `'_`... @@ -19,7 +19,7 @@ LL | x.m() | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:27:7 + --> $DIR/projection-type-lifetime-mismatch.rs:33:7 | LL | fn h(x: &()) -> &'static () { | --- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr index 4620aa34e84..00395af4889 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:17:5 + --> $DIR/projection-type-lifetime-mismatch.rs:21:5 | LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () { | - let's call the lifetime of this reference `'1` @@ -7,7 +7,7 @@ LL | x.m() | ^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:22:5 + --> $DIR/projection-type-lifetime-mismatch.rs:27:5 | LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () { | - let's call the lifetime of this reference `'1` @@ -15,7 +15,7 @@ LL | x.m() | ^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:27:5 + --> $DIR/projection-type-lifetime-mismatch.rs:33:5 | LL | fn h(x: &()) -> &'static () { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs index 9b04fe23320..9f14c6f3dc0 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generic_associated_types)] pub trait X { @@ -15,17 +19,20 @@ impl X for () { fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn h(x: &()) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/generic-associated-types/trait-objects.base.stderr b/src/test/ui/generic-associated-types/trait-objects.base.stderr index 1df76a21bf9..eed12f56be2 100644 --- a/src/test/ui/generic-associated-types/trait-objects.base.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.base.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object - --> $DIR/trait-objects.rs:14:21 + --> $DIR/trait-objects.rs:16:21 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/trait-objects.rs:8:10 + --> $DIR/trait-objects.rs:10:10 | LL | trait StreamingIterator { | ----------------- this trait cannot be made into an object... diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr deleted file mode 100644 index 52d48d57859..00000000000 --- a/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/trait-objects.rs:16:5 - | -LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize { - | - - let's call the lifetime of this reference `'1` - | | - | `x` is a reference that is only valid in the function body -LL | -LL | x.size_hint().0 - | ^^^^^^^^^^^^^ - | | - | `x` escapes the function body here - | argument requires that `'1` must outlive `'static` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.stderr index 7cc3dad9921..c7b072256ad 100644 --- a/src/test/ui/generic-associated-types/trait-objects.extended.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.extended.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/trait-objects.rs:16:7 + --> $DIR/trait-objects.rs:18:7 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize { | ------------------------------------------------------ help: add explicit lifetime `'a` to the type of `x`: `&'a mut (dyn StreamingIterator<for<'a> Item = &'a i32> + 'a)` diff --git a/src/test/ui/generic-associated-types/trait-objects.rs b/src/test/ui/generic-associated-types/trait-objects.rs index 644e56ce21f..d742d2051be 100644 --- a/src/test/ui/generic-associated-types/trait-objects.rs +++ b/src/test/ui/generic-associated-types/trait-objects.rs @@ -1,3 +1,5 @@ +// FIXME(nll): this is experimental anyways, don't really care about the output +// ignore-compare-mode-nll // revisions: base extended #![feature(generic_associated_types)] diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.base.stderr index 3dd05bba5c0..ec576ee529a 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'a V` does not fulfill the required lifetime - --> $DIR/issue-59311.rs:17:5 + --> $DIR/issue-59311.rs:21:5 | LL | v.t(|| {}); | ^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/issue-59311.rs:15:24 + --> $DIR/issue-59311.rs:19:24 | LL | for<'a> &'a V: T + 'static, | ^^^^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr index 15e83ab5a34..7f98cefdf01 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr @@ -1,13 +1,13 @@ error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:5 + --> $DIR/issue-59311.rs:21:5 | LL | v.t(|| {}); | ^^^^^^^^^^ | - = note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed + = note: could not prove [closure@$DIR/issue-59311.rs:21:9: 21:14] well-formed error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:9 + --> $DIR/issue-59311.rs:21:9 | LL | v.t(|| {}); | ^^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs index 69708577285..a63c5754f8f 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs @@ -6,6 +6,10 @@ // an error, but the regression test is here to ensure // that it does not ICE. See discussion on #74889 for details. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait T { fn t<F: Fn()>(&self, _: F) {} } @@ -14,7 +18,10 @@ pub fn crash<V>(v: &V) where for<'a> &'a V: T + 'static, { - v.t(|| {}); //~ ERROR: `&'a V` does not fulfill the required lifetime + v.t(|| {}); + //[base]~^ ERROR: `&'a V` does not fulfill the required lifetime + //[nll]~^^ ERROR: higher-ranked lifetime error + //[nll]~| ERROR: higher-ranked lifetime error } fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr new file mode 100644 index 00000000000..c24afdd418b --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr @@ -0,0 +1,20 @@ +error: implementation of `Parser` is not general enough + --> $DIR/issue-71955.rs:49:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^ implementation of `Parser` is not general enough + | + = note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... + = note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` + +error: implementation of `Parser` is not general enough + --> $DIR/issue-71955.rs:53:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^ implementation of `Parser` is not general enough + | + = note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... + = note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr index 0f38f8e3283..9d3cd4dee53 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 + --> $DIR/issue-71955.rs:49:5 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -7,18 +7,18 @@ LL | foo(bar, "string", |s| s.len() == 5); = note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>` found type `for<'r> FnOnce<(&'r &str,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 + --> $DIR/issue-71955.rs:49:24 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 + --> $DIR/issue-71955.rs:29:9 | LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 + --> $DIR/issue-71955.rs:49:5 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -26,18 +26,18 @@ LL | foo(bar, "string", |s| s.len() == 5); = note: expected type `FnOnce<(&&str,)>` found type `for<'r> FnOnce<(&'r &str,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 + --> $DIR/issue-71955.rs:49:24 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 + --> $DIR/issue-71955.rs:29:44 | LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 + --> $DIR/issue-71955.rs:53:5 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -45,18 +45,18 @@ LL | foo(baz, "string", |s| s.0.len() == 5); = note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 + --> $DIR/issue-71955.rs:53:24 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 + --> $DIR/issue-71955.rs:29:9 | LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 + --> $DIR/issue-71955.rs:53:5 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -64,12 +64,12 @@ LL | foo(baz, "string", |s| s.0.len() == 5); = note: expected type `FnOnce<(&Wrapper<'_>,)>` found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 + --> $DIR/issue-71955.rs:53:24 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 + --> $DIR/issue-71955.rs:29:44 | LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs index 4b7e207b96d..8d283afd09d 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs @@ -1,13 +1,8 @@ // ignore-compare-mode-nll -// revisions: migrate nll +// revisions: base nll // [nll]compile-flags: -Zborrowck=mir -// check-fail - -// Since we are testing nll (and migration) explicitly as a separate -// revisions, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll +// check-fail #![feature(rustc_attrs)] trait Parser<'s> { @@ -52,11 +47,11 @@ fn main() { } foo(bar, "string", |s| s.len() == 5); - //[migrate]~^ ERROR implementation of `Parser` is not general enough + //[base]~^ ERROR implementation of `Parser` is not general enough //[nll]~^^ ERROR mismatched types //[nll]~| ERROR mismatched types foo(baz, "string", |s| s.0.len() == 5); - //[migrate]~^ ERROR implementation of `Parser` is not general enough + //[base]~^ ERROR implementation of `Parser` is not general enough //[nll]~^^ ERROR mismatched types //[nll]~| ERROR mismatched types } diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_b_ret_a_vs_bound_a_ret_a.stderr index 87d826021b7..3edb1064e3e 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_vs_free_x.stderr index bd97f6f0906..f02eeea90bf 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_vs_free_x.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_inv_a_b_vs_bound_inv_a.stderr index 874909bf486..bfc9793fe5d 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_inv_a_b_vs_bound_inv_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -13,7 +13,7 @@ LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.free_inv_x_vs_free_inv_y.stderr index f5db68e8be1..ee0dc877fd1 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.free_inv_x_vs_free_inv_y.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:39:13 + --> $DIR/hr-subtype-nll.rs:54:13 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here @@ -19,7 +19,7 @@ LL | | fn(Inv<'y>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.free_x_vs_free_y.stderr index ab97481824d..75904d6df99 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.free_x_vs_free_y.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/hr-subtype/hr-subtype-nll.rs b/src/test/ui/hr-subtype/hr-subtype-nll.rs new file mode 100644 index 00000000000..7fc1692b350 --- /dev/null +++ b/src/test/ui/hr-subtype/hr-subtype-nll.rs @@ -0,0 +1,117 @@ +// Targeted tests for the higher-ranked subtyping code. + +#![allow(dead_code)] + +// revisions: bound_a_vs_bound_a +// revisions: bound_a_vs_bound_b +// revisions: bound_inv_a_vs_bound_inv_b +// revisions: bound_co_a_vs_bound_co_b +// revisions: bound_a_vs_free_x +// revisions: free_x_vs_free_x +// revisions: free_x_vs_free_y +// revisions: free_inv_x_vs_free_inv_y +// revisions: bound_a_b_vs_bound_a +// revisions: bound_co_a_b_vs_bound_co_a +// revisions: bound_contra_a_contra_b_ret_co_a +// revisions: bound_co_a_co_b_ret_contra_a +// revisions: bound_inv_a_b_vs_bound_inv_a +// revisions: bound_a_b_ret_a_vs_bound_a_ret_a + +//[bound_a_vs_bound_a] check-pass +//[bound_a_vs_bound_b] check-pass +//[bound_inv_a_vs_bound_inv_b] check-pass +//[bound_co_a_vs_bound_co_b] check-pass +//[free_x_vs_free_x] check-pass +//[bound_co_a_b_vs_bound_co_a] check-pass +//[bound_co_a_co_b_ret_contra_a] check-pass +//[bound_a_b_vs_bound_a] check-pass +//[bound_contra_a_contra_b_ret_co_a] check-pass + +// compile-flags: -Z borrowck=mir +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replace with `hr-subtype.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +fn gimme<T>(_: Option<T>) {} + +struct Inv<'a> { + x: *mut &'a u32, +} + +struct Co<'a> { + x: fn(&'a u32), +} + +struct Contra<'a> { + x: &'a u32, +} + +macro_rules! check { + ($rev:ident: ($t1:ty, $t2:ty)) => { + #[cfg($rev)] + fn subtype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t2>(None::<$t1>); + //[free_inv_x_vs_free_inv_y]~^ ERROR + } + + #[cfg($rev)] + fn supertype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t1>(None::<$t2>); + //[bound_a_vs_free_x]~^ ERROR + //[free_x_vs_free_y]~^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~| ERROR + //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^^ ERROR + //[free_inv_x_vs_free_inv_y]~^^^^^^ ERROR + } + }; +} + +// If both have bound regions, they are equivalent, regardless of +// variant. +check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), +for<'a> fn(&'a u32)) } +check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), +for<'b> fn(&'b u32)) } +check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), +for<'b> fn(Inv<'b>)) } +check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), +for<'b> fn(Co<'b>)) } + +// Bound is a subtype of free. +check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), +fn(&'x u32)) } + +// Two free regions are relatable if subtyping holds. +check! { free_x_vs_free_x: (fn(&'x u32), +fn(&'x u32)) } +check! { free_x_vs_free_y: (fn(&'x u32), +fn(&'y u32)) } +check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +fn(Inv<'y>)) } + +// Somewhat surprisingly, a fn taking two distinct bound lifetimes and +// a fn taking one bound lifetime can be interchangeable, but only if +// we are co- or contra-variant with respect to both lifetimes. +// +// The reason is: +// - if we are covariant, then 'a and 'b can be set to the call-site +// intersection; +// - if we are contravariant, then 'a can be inferred to 'static. +check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), +for<'a> fn(&'a u32, &'a u32)) } +check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), +for<'a> fn(Co<'a>, Co<'a>)) } +check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, +for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } +check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, +for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + +// If we make those lifetimes invariant, then the two types are not interchangeable. +check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +for<'a> fn(Inv<'a>, Inv<'a>)) } +check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, +for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + +fn main() {} diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr index 91bd0b6929a..13e9fa8a894 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr index 27ce56fc16a..b66ff5a392e 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr index bb20f81a1de..fa715fd354e 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr index 9f200357222..377689603aa 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:39:26 + --> $DIR/hr-subtype.rs:53:26 | LL | gimme::<$t2>(None::<$t1>); | ^^^^^^^^^^^ lifetime mismatch @@ -11,7 +11,7 @@ LL | | fn(Inv<'y>)) } = note: expected enum `Option<fn(Inv<'y>)>` found enum `Option<fn(Inv<'x>)>` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:38:20 + --> $DIR/hr-subtype.rs:52:20 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -20,7 +20,7 @@ LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:38:24 + --> $DIR/hr-subtype.rs:52:24 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -31,7 +31,7 @@ LL | | fn(Inv<'y>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ lifetime mismatch @@ -43,7 +43,7 @@ LL | | fn(Inv<'y>)) } = note: expected enum `Option<fn(Inv<'x>)>` found enum `Option<fn(Inv<'y>)>` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:44:22 + --> $DIR/hr-subtype.rs:58:22 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -52,7 +52,7 @@ LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:44:26 + --> $DIR/hr-subtype.rs:58:26 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr deleted file mode 100644 index 2bf78d12290..00000000000 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr index 07add3d91a0..9e5eb972f47 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ lifetime mismatch @@ -11,7 +11,7 @@ LL | | fn(&'y u32)) } = note: expected enum `Option<fn(&'x u32)>` found enum `Option<fn(&'y u32)>` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:44:22 + --> $DIR/hr-subtype.rs:58:22 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -20,7 +20,7 @@ LL | / check! { free_x_vs_free_y: (fn(&'x u32), LL | | fn(&'y u32)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:44:26 + --> $DIR/hr-subtype.rs:58:26 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ diff --git a/src/test/ui/hr-subtype/hr-subtype.rs b/src/test/ui/hr-subtype/hr-subtype.rs index ad9500eedca..33929cdb868 100644 --- a/src/test/ui/hr-subtype/hr-subtype.rs +++ b/src/test/ui/hr-subtype/hr-subtype.rs @@ -1,6 +1,5 @@ // Targeted tests for the higher-ranked subtyping code. -#![feature(rustc_attrs)] #![allow(dead_code)] // revisions: bound_a_vs_bound_a @@ -18,6 +17,21 @@ // revisions: bound_inv_a_b_vs_bound_inv_a // revisions: bound_a_b_ret_a_vs_bound_a_ret_a +//[bound_a_vs_bound_a] check-pass +//[bound_a_vs_bound_b] check-pass +//[bound_inv_a_vs_bound_inv_b] check-pass +//[bound_co_a_vs_bound_co_b] check-pass +//[free_x_vs_free_x] check-pass +//[bound_co_a_b_vs_bound_co_a] check-pass +//[bound_co_a_co_b_ret_contra_a] check-pass +//[bound_a_b_vs_bound_a] check-pass +//[bound_contra_a_contra_b_ret_co_a] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with `hr-subtype-nll.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + fn gimme<T>(_: Option<T>) {} struct Inv<'a> { @@ -98,15 +112,4 @@ for<'a> fn(Inv<'a>, Inv<'a>)) } check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, for<'a> fn(&'a u32, &'a u32) -> &'a u32) } -#[rustc_error] -fn main() { - //[bound_a_vs_bound_a]~^ ERROR fatal error triggered by #[rustc_error] - //[bound_a_vs_bound_b]~^^ ERROR fatal error triggered by #[rustc_error] - //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error] - //[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error] - //[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error] - //[bound_co_a_b_vs_bound_co_a]~^^^^^^ ERROR - //[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR - //[bound_a_b_vs_bound_a]~^^^^^^^^ ERROR - //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR -} +fn main() {} diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr b/src/test/ui/hr-subtype/placeholder-pattern-fail.base.stderr index 7bd5308052b..c6cb77d8d8d 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:9:47 + --> $DIR/placeholder-pattern-fail.rs:13:47 | LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:14:31 + --> $DIR/placeholder-pattern-fail.rs:18:31 | LL | let _x: (&'static i32,) = x; | ^ lifetime mismatch @@ -16,14 +16,14 @@ LL | let _x: (&'static i32,) = x; = note: expected tuple `(&'static i32,)` found tuple `(&'c i32,)` note: the lifetime `'c` as defined here... - --> $DIR/placeholder-pattern-fail.rs:13:12 + --> $DIR/placeholder-pattern-fail.rs:17:12 | LL | fn simple1<'c>(x: (&'c i32,)) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:19:30 + --> $DIR/placeholder-pattern-fail.rs:23:30 | LL | let _: (&'static i32,) = x; | ^ lifetime mismatch @@ -31,7 +31,7 @@ LL | let _: (&'static i32,) = x; = note: expected tuple `(&'static i32,)` found tuple `(&'c i32,)` note: the lifetime `'c` as defined here... - --> $DIR/placeholder-pattern-fail.rs:18:12 + --> $DIR/placeholder-pattern-fail.rs:22:12 | LL | fn simple2<'c>(x: (&'c i32,)) { | ^^ diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr b/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr index 1836249efdb..a1f713d8afb 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr @@ -1,37 +1,12 @@ error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:9:12 + --> $DIR/placeholder-pattern-fail.rs:13:47 | LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^^^ one type is more general than the other | = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)` found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` -error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:9:12 - | -LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)` - found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` - -error: lifetime may not live long enough - --> $DIR/placeholder-pattern-fail.rs:14:13 - | -LL | fn simple1<'c>(x: (&'c i32,)) { - | -- lifetime `'c` defined here -LL | let _x: (&'static i32,) = x; - | ^^^^^^^^^^^^^^^ type annotation requires that `'c` must outlive `'static` - -error: lifetime may not live long enough - --> $DIR/placeholder-pattern-fail.rs:19:12 - | -LL | fn simple2<'c>(x: (&'c i32,)) { - | -- lifetime `'c` defined here -LL | let _: (&'static i32,) = x; - | ^^^^^^^^^^^^^^^ type annotation requires that `'c` must outlive `'static` - -error: aborting due to 4 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs b/src/test/ui/hr-subtype/placeholder-pattern-fail.rs index 3b5b075cb58..ac276a88982 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Check that incorrect higher ranked subtyping // causes an error. struct Inv<'a>(fn(&'a ()) -> &'a ()); @@ -12,12 +16,12 @@ fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) { fn simple1<'c>(x: (&'c i32,)) { let _x: (&'static i32,) = x; - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types } fn simple2<'c>(x: (&'c i32,)) { let _: (&'static i32,) = x; - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types } fn main() { diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.base.stderr index b1d4c0bf375..e55e56f916b 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::<SomeStruct>(); } | ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr index 46f5308dd87..61b549b9cd7 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::<SomeStruct>(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | fn b() { want_foo2::<SomeStruct>(); } = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::<SomeStruct>(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.rs b/src/test/ui/hrtb/hrtb-conflate-regions.rs index 004d62ac513..11285d07575 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.rs +++ b/src/test/ui/hrtb/hrtb-conflate-regions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that an impl with only one bound region `'a` cannot be used to // satisfy a constraint where there are two bound regions. @@ -24,6 +28,9 @@ impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct } fn a() { want_foo1::<SomeStruct>(); } // OK -- foo wants just one region -fn b() { want_foo2::<SomeStruct>(); } //~ ERROR +fn b() { want_foo2::<SomeStruct>(); } +//[base]~^ ERROR +//[nll]~^^ ERROR implementation of +//[nll]~| ERROR implementation of fn main() { } diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr deleted file mode 100644 index 1ee3c674963..00000000000 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hrtb-exists-forall-fn.rs:17:12 - | -LL | let _: for<'b> fn(&'b u32) = foo(); - | ^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'b> fn(&'b u32)` - found fn pointer `fn(&u32)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.base.stderr index 613f4dc4951..006b6756b1e 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:38:5 | LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr index 364b613fc77..23b50728264 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:38:5 | LL | foo::<()>(); | ^^^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs index 921061916fc..4b33dcb2cab 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where variance and higher-ranked types interact in surprising ways. // // In particular, we test this pattern in trait solving, where it is not connected diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.base.stderr index b487ce3e0ff..05575b01834 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + --> $DIR/hrtb-exists-forall-trait-invariant.rs:32:5 | LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr index cb2ce8a4116..58d59f60379 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + --> $DIR/hrtb-exists-forall-trait-invariant.rs:32:5 | LL | foo::<()>(); | ^^^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs index 9b9e4496a87..c779bc3f46c 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! // // In particular, we test this pattern in trait solving, where it is not connected diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.base.stderr index ffc83aab4af..6e20b100664 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 + --> $DIR/hrtb-just-for-static.rs:28:5 | LL | want_hrtb::<StaticInt>() | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | want_hrtb::<StaticInt>() = note: ...but it actually implements `Foo<&'static isize>` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr b/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr index a5770431eaf..090bd9f68ad 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 + --> $DIR/hrtb-just-for-static.rs:28:5 | LL | want_hrtb::<StaticInt>() | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | want_hrtb::<StaticInt>() = note: ...but it actually implements `Foo<&'static isize>` error: lifetime may not live long enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | fn give_some<'a>() { | -- lifetime `'a` defined here @@ -16,7 +16,7 @@ LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-just-for-static.rs b/src/test/ui/hrtb/hrtb-just-for-static.rs index 88d5ce8e640..dc70609c168 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.rs +++ b/src/test/ui/hrtb/hrtb-just-for-static.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where you have an impl of `Foo<X>` for all `X` that // is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. @@ -27,7 +31,10 @@ fn give_static() { // AnyInt implements Foo<&'a isize> for any 'a, so it is a match. impl<'a> Foo<&'a isize> for &'a u32 { } fn give_some<'a>() { - want_hrtb::<&'a u32>() //~ ERROR + want_hrtb::<&'a u32>() + //[base]~^ ERROR + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR implementation of `Foo` is not general enough } fn main() { } diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.base.stderr index 07ff9b96e44..678a1137cd6 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough @@ -8,7 +8,7 @@ LL | foo_hrtb_bar_not(&mut t); = note: ...but it actually implements `Bar<&'b isize>` error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr index 68da46d46bd..3643ce62d40 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:16:1 + --> $DIR/hrtb-perfect-forwarding.rs:20:1 | LL | / fn no_hrtb<'b, T>(mut t: T) LL | | where @@ -15,7 +15,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:25:1 + --> $DIR/hrtb-perfect-forwarding.rs:29:1 | LL | / fn bar_hrtb<T>(mut t: T) LL | | where @@ -30,7 +30,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:35:1 + --> $DIR/hrtb-perfect-forwarding.rs:39:1 | LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) LL | | where @@ -39,7 +39,7 @@ LL | | { ... | LL | | foo_hrtb_bar_not(&mut t); | | ------------------------ recursive call site -LL | | +... | LL | | LL | | } | |_^ cannot return without recursing @@ -47,7 +47,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose error: lifetime may not live long enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) | -- lifetime `'b` defined here @@ -56,7 +56,7 @@ LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough @@ -65,7 +65,7 @@ LL | foo_hrtb_bar_not(&mut t); = note: ...but it actually implements `Bar<&'1 isize>`, for some specific lifetime `'1` warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:48:1 + --> $DIR/hrtb-perfect-forwarding.rs:53:1 | LL | / fn foo_hrtb_bar_hrtb<T>(mut t: T) LL | | where diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs index 441a788359e..2db9f661cf4 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where you have an impl of `Foo<X>` for all `X` that // is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. @@ -13,7 +17,7 @@ impl<'a, X, F> Foo<X> for &'a mut F where F: Foo<X> + Bar<X> {} impl<'a, X, F> Bar<X> for &'a mut F where F: Bar<X> {} -fn no_hrtb<'b, T>(mut t: T) +fn no_hrtb<'b, T>(mut t: T) //[nll]~ WARN function cannot return where T: Bar<&'b isize>, { @@ -22,7 +26,7 @@ where no_hrtb(&mut t); } -fn bar_hrtb<T>(mut t: T) +fn bar_hrtb<T>(mut t: T) //[nll]~ WARN function cannot return where T: for<'b> Bar<&'b isize>, { @@ -32,7 +36,7 @@ where bar_hrtb(&mut t); } -fn foo_hrtb_bar_not<'b, T>(mut t: T) +fn foo_hrtb_bar_not<'b, T>(mut t: T) //[nll]~ WARN function cannot return where T: for<'a> Foo<&'a isize> + Bar<&'b isize>, { @@ -42,10 +46,11 @@ where // clause only specifies `T : Bar<&'b isize>`. foo_hrtb_bar_not(&mut t); //~^ ERROR implementation of `Bar` is not general enough - //~| ERROR implementation of `Bar` is not general enough + //[base]~^^ ERROR implementation of `Bar` is not general enough + //[nll]~^^^ ERROR lifetime may not live long enough } -fn foo_hrtb_bar_hrtb<T>(mut t: T) +fn foo_hrtb_bar_hrtb<T>(mut t: T) //[nll]~ WARN function cannot return where T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, { diff --git a/src/test/ui/hrtb/issue-30786.migrate.stderr b/src/test/ui/hrtb/issue-30786.base.stderr index 7157b186fc8..dba3911d99c 100644 --- a/src/test/ui/hrtb/issue-30786.migrate.stderr +++ b/src/test/ui/hrtb/issue-30786.base.stderr @@ -1,5 +1,5 @@ -error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:127:22 +error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:122:22 | LL | pub struct Map<S, F> { | -------------------- @@ -8,13 +8,13 @@ LL | pub struct Map<S, F> { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>` due to unsatisfied trait bounds + | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here @@ -23,8 +23,8 @@ help: one of the expressions' fields has a method of the same name LL | let filter = map.stream.filterx(|x: &_| true); | +++++++ -error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:140:24 +error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:134:24 | LL | pub struct Filter<S, F> { | ----------------------- @@ -33,13 +33,13 @@ LL | pub struct Filter<S, F> { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here diff --git a/src/test/ui/hrtb/issue-30786.nll.stderr b/src/test/ui/hrtb/issue-30786.nll.stderr index 7157b186fc8..dba3911d99c 100644 --- a/src/test/ui/hrtb/issue-30786.nll.stderr +++ b/src/test/ui/hrtb/issue-30786.nll.stderr @@ -1,5 +1,5 @@ -error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:127:22 +error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:122:22 | LL | pub struct Map<S, F> { | -------------------- @@ -8,13 +8,13 @@ LL | pub struct Map<S, F> { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>` due to unsatisfied trait bounds + | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:126:27: 126:36]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:121:27: 121:36]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here @@ -23,8 +23,8 @@ help: one of the expressions' fields has a method of the same name LL | let filter = map.stream.filterx(|x: &_| true); | +++++++ -error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:140:24 +error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:134:24 | LL | pub struct Filter<S, F> { | ----------------------- @@ -33,13 +33,13 @@ LL | pub struct Filter<S, F> { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here diff --git a/src/test/ui/hrtb/issue-30786.rs b/src/test/ui/hrtb/issue-30786.rs index 540c26c358b..c2e01909870 100644 --- a/src/test/ui/hrtb/issue-30786.rs +++ b/src/test/ui/hrtb/issue-30786.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // rust-lang/rust#30786: the use of `for<'b> &'b mut A: Stream<Item=T` // should act as assertion that item does not borrow from its stream; // but an earlier buggy rustc allowed `.map(|x: &_| x)` which does @@ -6,15 +10,6 @@ // This tests double-checks that we do not allow such behavior to leak // through again. -// revisions: migrate nll -//[nll]compile-flags: -Z borrowck=mir - -// Since we are testing nll (and migration) explicitly as a separate -// revisions, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll -// ignore-compare-mode-polonius - pub trait Stream { type Item; fn next(self) -> Option<Self::Item>; @@ -125,8 +120,7 @@ fn variant1() { // guess. let map = source.mapx(|x: &_| x); let filter = map.filterx(|x: &_| true); - //[migrate]~^ ERROR the method - //[nll]~^^ ERROR the method + //~^ ERROR the method } fn variant2() { @@ -138,8 +132,7 @@ fn variant2() { let map = source.mapx(identity); let filter = map.filterx(|x: &_| true); let count = filter.countx(); - //[migrate]~^ ERROR the method - //[nll]~^^ ERROR the method + //~^ ERROR the method } fn main() {} diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.base.stderr index f3d906cae4c..d1f6fed10fd 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:38:5 + --> $DIR/issue-46989.rs:42:5 | LL | assert_foo::<fn(&i32)>(); | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/issue-46989.nll.stderr b/src/test/ui/hrtb/issue-46989.nll.stderr index 309e1a676ed..e1ddd7235f5 100644 --- a/src/test/ui/hrtb/issue-46989.nll.stderr +++ b/src/test/ui/hrtb/issue-46989.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:38:5 + --> $DIR/issue-46989.rs:42:5 | LL | assert_foo::<fn(&i32)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/issue-46989.rs b/src/test/ui/hrtb/issue-46989.rs index 4a09f4be156..0bb6d7a18eb 100644 --- a/src/test/ui/hrtb/issue-46989.rs +++ b/src/test/ui/hrtb/issue-46989.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #46989: // // In the move to universes, this test started passing. diff --git a/src/test/ui/issues/issue-32922.rs b/src/test/ui/hygiene/issue-32922.rs index 54ec44a1cf4..54ec44a1cf4 100644 --- a/src/test/ui/issues/issue-32922.rs +++ b/src/test/ui/hygiene/issue-32922.rs diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.base.stderr index 2307572cc3f..a01560e70e3 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/dyn-trait.rs:20:16 + --> $DIR/dyn-trait.rs:24:16 | LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { | ------------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | static_val(x); | ^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/dyn-trait.rs:20:5 + --> $DIR/dyn-trait.rs:24:5 | LL | static_val(x); | ^^^^^^^^^^ diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr index 88c260b18cb..762698c4fc1 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/dyn-trait.rs:20:5 + --> $DIR/dyn-trait.rs:24:5 | LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs index 89210fdf137..a103034a537 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a, // 'b> MyTrait<'a> for &'b i32`. @@ -17,7 +21,9 @@ fn static_val<T: StaticTrait>(_: T) { } fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { - static_val(x); //~ ERROR E0759 + static_val(x); + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR borrowed data escapes outside of function } fn not_static_val<T: NotStaticTrait>(_: T) { diff --git a/src/test/ui/issues/issue-46959.rs b/src/test/ui/impl-trait/issue-46959.rs index 3611a956836..3611a956836 100644 --- a/src/test/ui/issues/issue-46959.rs +++ b/src/test/ui/impl-trait/issue-46959.rs diff --git a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs index 41b6a9eb055..5251eeee8bb 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs @@ -1,7 +1,5 @@ // edition:2018 // check-pass -// revisions: migrate mir -//[mir]compile-flags: -Z borrowck=mir trait Trait<'a, 'b> {} impl<T> Trait<'_, '_> for T {} diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr index dade2b91fe0..45cc935b7cc 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:7:35 | LL | fn elided(x: &i32) -> impl Copy { x } | ---- ^ @@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:10:44 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- ^ @@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 + --> $DIR/must_outlive_least_region_or_bound.rs:13:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ---- ^ ...is used here... @@ -33,7 +33,7 @@ LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | this data with an anonymous lifetime `'_`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:9:24 + --> $DIR/must_outlive_least_region_or_bound.rs:13:24 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:11:55 + --> $DIR/must_outlive_least_region_or_bound.rs:17:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ------- ^ ...is used here... @@ -55,7 +55,7 @@ LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | this data with lifetime `'a`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:11:33 + --> $DIR/must_outlive_least_region_or_bound.rs:17:33 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:24 + --> $DIR/must_outlive_least_region_or_bound.rs:21:24 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^^^^^^^^^^^^^^ lifetime `'a` required @@ -77,7 +77,7 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:24:65 + --> $DIR/must_outlive_least_region_or_bound.rs:36:65 | LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } | ---- this data with an anonymous lifetime `'_`... ^ ...is used and required to live as long as `'static` here @@ -92,13 +92,13 @@ LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x) | ++++ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:29:69 + --> $DIR/must_outlive_least_region_or_bound.rs:43:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ------- this data with lifetime `'a`... ^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:29:34 + --> $DIR/must_outlive_least_region_or_bound.rs:43:34 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,10 +112,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ~~~~~~~~~~~~ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:50:5 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here + | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -125,7 +125,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:38:51 + --> $DIR/must_outlive_least_region_or_bound.rs:54:51 | LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds @@ -136,7 +136,7 @@ LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 's | +++++++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:16:50 + --> $DIR/must_outlive_least_region_or_bound.rs:24:50 | LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } | ---- ^ ...is used and required to live as long as `'static` here @@ -144,7 +144,7 @@ LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } | this data with an anonymous lifetime `'_`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:16:28 + --> $DIR/must_outlive_least_region_or_bound.rs:24:28 | LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } | ^^^^^^^^^ ----------- because of this returned expression @@ -156,7 +156,7 @@ LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) } | ++++ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:18:59 + --> $DIR/must_outlive_least_region_or_bound.rs:27:59 | LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } | ------- ^ ...is used and required to live as long as `'static` here @@ -164,7 +164,7 @@ LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } | this data with lifetime `'a`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:18:37 + --> $DIR/must_outlive_least_region_or_bound.rs:27:37 | LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } | ^^^^^^^^^ ----------- because of this returned expression @@ -176,7 +176,7 @@ LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) } | ++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:20:60 + --> $DIR/must_outlive_least_region_or_bound.rs:30:60 | LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ---- ^ ...is used and required to live as long as `'static` here @@ -184,7 +184,7 @@ LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } | this data with an anonymous lifetime `'_`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:20:40 + --> $DIR/must_outlive_least_region_or_bound.rs:30:40 | LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ^^^^^^^ ----------- because of this returned expression @@ -200,13 +200,13 @@ LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ~~~~~~~~~~~~ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:22:69 + --> $DIR/must_outlive_least_region_or_bound.rs:33:69 | LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ------- this data with lifetime `'a`... ^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:22:49 + --> $DIR/must_outlive_least_region_or_bound.rs:33:49 | LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ^^^^^^^ ----------- because of this returned expression diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index db737a9c544..0252e546fb0 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:7:35 | LL | fn elided(x: &i32) -> impl Copy { x } | ---- ^ @@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:10:44 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- ^ @@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ++++ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 + --> $DIR/must_outlive_least_region_or_bound.rs:13:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | - ^ returning this value requires that `'1` must outlive `'static` @@ -42,7 +42,7 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:11:55 + --> $DIR/must_outlive_least_region_or_bound.rs:17:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -57,7 +57,7 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:41 + --> $DIR/must_outlive_least_region_or_bound.rs:21:41 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^ lifetime `'a` required @@ -65,7 +65,7 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:24:55 + --> $DIR/must_outlive_least_region_or_bound.rs:36:55 | LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } | - ^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` @@ -82,7 +82,7 @@ LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x) | ++++ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:29:69 + --> $DIR/must_outlive_least_region_or_bound.rs:43:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -97,10 +97,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ~~~~~~~~~~~~ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:50:5 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here + | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -110,7 +110,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:40:5 + --> $DIR/must_outlive_least_region_or_bound.rs:56:5 | LL | x | ^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index 60e4672f1b7..6bb3141b012 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + use std::fmt::Debug; fn elided(x: &i32) -> impl Copy { x } @@ -6,27 +10,39 @@ fn elided(x: &i32) -> impl Copy { x } fn explicit<'a>(x: &'a i32) -> impl Copy { x } //~^ ERROR: captures lifetime that does not appear in bounds -fn elided2(x: &i32) -> impl Copy + 'static { x } //~ ERROR E0759 +fn elided2(x: &i32) -> impl Copy + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough -fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } //~ ERROR E0759 +fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough fn foo<'a>(x: &i32) -> impl Copy + 'a { x } //~^ ERROR explicit lifetime required in the type of `x` -fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } //~ ERROR E0759 +fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } +//[base]~^ ERROR E0759 -fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } //~ ERROR E0759 +fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } +//[base]~^ ERROR E0759 -fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } //~ ERROR E0759 +fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } +//[base]~^ ERROR E0759 -fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } //~ ERROR E0759 +fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } +//[base]~^ ERROR E0759 -fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } //~ ERROR E0759 +fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough trait LifetimeTrait<'a> {} impl<'a> LifetimeTrait<'a> for &'a i32 {} -fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~ ERROR E0759 +fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough // Tests that a closure type containing 'b cannot be returned from a type where // only 'a was expected. @@ -36,8 +52,9 @@ fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { } fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - //~^ ERROR the parameter type `T` may not live long enough + //[base]~^ ERROR the parameter type `T` may not live long enough x + //[nll]~^ ERROR the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/ui/impl-trait/type_parameters_captured.stderr b/src/test/ui/impl-trait/type_parameters_captured.base.stderr index 9f28a8d44a7..cfa1d93d571 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:7:20 + --> $DIR/type_parameters_captured.rs:11:20 | LL | fn foo<T>(x: T) -> impl Any + 'static { | ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr index 3050f10b205..a07ba564490 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:9:5 + --> $DIR/type_parameters_captured.rs:13:5 | LL | x | ^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/type_parameters_captured.rs b/src/test/ui/impl-trait/type_parameters_captured.rs index 6c9c9d4a42a..0618beeef97 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.rs +++ b/src/test/ui/impl-trait/type_parameters_captured.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + use std::fmt::Debug; trait Any {} @@ -5,8 +9,9 @@ impl<T> Any for T {} // Check that type parameters are captured and not considered 'static fn foo<T>(x: T) -> impl Any + 'static { - //~^ ERROR the parameter type `T` may not live long enough + //[base]~^ ERROR the parameter type `T` may not live long enough x + //[nll]~^ ERROR the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.base.stderr index a80b0ba5e91..cad22b2f3ea 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.base.stderr @@ -1,19 +1,21 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/issue-10291.rs:3:9 + --> $DIR/issue-10291.rs:7:9 | LL | x | ^ | note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/issue-10291.rs:2:69 + --> $DIR/issue-10291.rs:6:69 | LL | drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { | _____________________________________________________________________^ LL | | x +LL | | +LL | | LL | | })); | |_____^ note: ...but the borrowed content is only valid for the lifetime `'x` as defined here - --> $DIR/issue-10291.rs:1:9 + --> $DIR/issue-10291.rs:5:9 | LL | fn test<'x>(x: &'x isize) { | ^^ diff --git a/src/test/ui/issues/issue-10291.nll.stderr b/src/test/ui/issues/issue-10291.nll.stderr index a7b827d27a8..47c4d4945f3 100644 --- a/src/test/ui/issues/issue-10291.nll.stderr +++ b/src/test/ui/issues/issue-10291.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-10291.rs:3:9 + --> $DIR/issue-10291.rs:7:9 | LL | fn test<'x>(x: &'x isize) { | -- lifetime `'x` defined here diff --git a/src/test/ui/issues/issue-10291.rs b/src/test/ui/issues/issue-10291.rs index 559c5fcac95..8ee3ce44d3d 100644 --- a/src/test/ui/issues/issue-10291.rs +++ b/src/test/ui/issues/issue-10291.rs @@ -1,6 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn test<'x>(x: &'x isize) { drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - x //~ ERROR E0312 + x + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough })); } diff --git a/src/test/ui/issues/issue-13058.stderr b/src/test/ui/issues/issue-13058.base.stderr index 53a2c987c52..2b9fff3f981 100644 --- a/src/test/ui/issues/issue-13058.stderr +++ b/src/test/ui/issues/issue-13058.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:26 + --> $DIR/issue-13058.rs:18:26 | LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool | -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T` diff --git a/src/test/ui/issues/issue-13058.nll.stderr b/src/test/ui/issues/issue-13058.nll.stderr index 8368978deab..ddefa8a62c9 100644 --- a/src/test/ui/issues/issue-13058.nll.stderr +++ b/src/test/ui/issues/issue-13058.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:21 + --> $DIR/issue-13058.rs:18:21 | LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool | -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T` diff --git a/src/test/ui/issues/issue-13058.rs b/src/test/ui/issues/issue-13058.rs index a5806feb720..cbd52a802e8 100644 --- a/src/test/ui/issues/issue-13058.rs +++ b/src/test/ui/issues/issue-13058.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::ops::Range; trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; } diff --git a/src/test/ui/issues/issue-15034.stderr b/src/test/ui/issues/issue-15034.base.stderr index 3ede5ba4fa3..293692c1ddc 100644 --- a/src/test/ui/issues/issue-15034.stderr +++ b/src/test/ui/issues/issue-15034.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:25 + --> $DIR/issue-15034.rs:21:25 | LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>` diff --git a/src/test/ui/issues/issue-15034.nll.stderr b/src/test/ui/issues/issue-15034.nll.stderr index f142e260a23..54af22fb726 100644 --- a/src/test/ui/issues/issue-15034.nll.stderr +++ b/src/test/ui/issues/issue-15034.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:9 + --> $DIR/issue-15034.rs:21:9 | LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>` diff --git a/src/test/ui/issues/issue-15034.rs b/src/test/ui/issues/issue-15034.rs index 9ea6ed89ca2..f95275e3a7b 100644 --- a/src/test/ui/issues/issue-15034.rs +++ b/src/test/ui/issues/issue-15034.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub struct Lexer<'a> { input: &'a str, } diff --git a/src/test/ui/issues/issue-16683.stderr b/src/test/ui/issues/issue-16683.base.stderr index d4e18df8de3..f684dd04a36 100644 --- a/src/test/ui/issues/issue-16683.stderr +++ b/src/test/ui/issues/issue-16683.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/issue-16683.rs:4:14 + --> $DIR/issue-16683.rs:8:14 | LL | self.a(); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime defined here... - --> $DIR/issue-16683.rs:3:10 + --> $DIR/issue-16683.rs:7:10 | LL | fn b(&self) { | ^^^^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-16683.rs:4:9 + --> $DIR/issue-16683.rs:8:9 | LL | self.a(); | ^^^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/issue-16683.rs:1:9 + --> $DIR/issue-16683.rs:5:9 | LL | trait T<'a> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-16683.rs:4:14 + --> $DIR/issue-16683.rs:8:14 | LL | self.a(); | ^ diff --git a/src/test/ui/issues/issue-16683.nll.stderr b/src/test/ui/issues/issue-16683.nll.stderr index fff681b2e0b..308d6352602 100644 --- a/src/test/ui/issues/issue-16683.nll.stderr +++ b/src/test/ui/issues/issue-16683.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-16683.rs:4:9 + --> $DIR/issue-16683.rs:8:9 | LL | trait T<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-16683.rs b/src/test/ui/issues/issue-16683.rs index bbbd4daa4c5..05969bc7b9f 100644 --- a/src/test/ui/issues/issue-16683.rs +++ b/src/test/ui/issues/issue-16683.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait T<'a> { fn a(&'a self) -> &'a bool; fn b(&self) { - self.a(); //~ ERROR cannot infer + self.a(); + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.base.stderr index 53405a660f8..e139de2019d 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-16922.rs:4:14 + --> $DIR/issue-16922.rs:8:14 | LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> { | -- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/issues/issue-16922.nll.stderr b/src/test/ui/issues/issue-16922.nll.stderr index 9d9f32a97c0..00a42e67242 100644 --- a/src/test/ui/issues/issue-16922.nll.stderr +++ b/src/test/ui/issues/issue-16922.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-16922.rs:4:5 + --> $DIR/issue-16922.rs:8:5 | LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/issues/issue-16922.rs b/src/test/ui/issues/issue-16922.rs index f048ccd2427..1767017eb3d 100644 --- a/src/test/ui/issues/issue-16922.rs +++ b/src/test/ui/issues/issue-16922.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::any::Any; fn foo<T: Any>(value: &T) -> Box<dyn Any> { - Box::new(value) as Box<dyn Any> //~ ERROR E0759 + Box::new(value) as Box<dyn Any> + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/issues/issue-17728.stderr b/src/test/ui/issues/issue-17728.base.stderr index 943c63667e0..b52dc444593 100644 --- a/src/test/ui/issues/issue-17728.stderr +++ b/src/test/ui/issues/issue-17728.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-17728.rs:15:28 + --> $DIR/issue-17728.rs:19:28 | LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&Room, &str> { | ----- ------------------- @@ -16,7 +16,7 @@ LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> | ++++ ++ ++ error[E0308]: `match` arms have incompatible types - --> $DIR/issue-17728.rs:109:14 + --> $DIR/issue-17728.rs:113:14 | LL | / match to_parse { LL | | "w" | "west" => RoomDirection::West, diff --git a/src/test/ui/issues/issue-17728.nll.stderr b/src/test/ui/issues/issue-17728.nll.stderr index a13d2dfa1fb..ddfb890eac3 100644 --- a/src/test/ui/issues/issue-17728.nll.stderr +++ b/src/test/ui/issues/issue-17728.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/issue-17728.rs:109:14 + --> $DIR/issue-17728.rs:113:14 | LL | / match to_parse { LL | | "w" | "west" => RoomDirection::West, diff --git a/src/test/ui/issues/issue-17728.rs b/src/test/ui/issues/issue-17728.rs index bec52d87d29..91b71ad6d0b 100644 --- a/src/test/ui/issues/issue-17728.rs +++ b/src/test/ui/issues/issue-17728.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::fmt::{Debug, Formatter, Error}; use std::collections::HashMap; @@ -13,7 +17,7 @@ trait TraversesWorld { let maybe_room = room.direction_to_room.get(&direction); match maybe_room { Some(entry) => Ok(entry), - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] _ => Err("Direction does not exist in room.") } } diff --git a/src/test/ui/issues/issue-17758.stderr b/src/test/ui/issues/issue-17758.base.stderr index 711217033a1..202238a49cb 100644 --- a/src/test/ui/issues/issue-17758.stderr +++ b/src/test/ui/issues/issue-17758.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/issue-17758.rs:7:14 + --> $DIR/issue-17758.rs:11:14 | LL | self.foo(); | ^^^ | note: first, the lifetime cannot outlive the anonymous lifetime defined here... - --> $DIR/issue-17758.rs:6:12 + --> $DIR/issue-17758.rs:10:12 | LL | fn bar(&self) { | ^^^^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-17758.rs:7:9 + --> $DIR/issue-17758.rs:11:9 | LL | self.foo(); | ^^^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/issue-17758.rs:4:11 + --> $DIR/issue-17758.rs:8:11 | LL | trait Foo<'a> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-17758.rs:7:14 + --> $DIR/issue-17758.rs:11:14 | LL | self.foo(); | ^^^ diff --git a/src/test/ui/issues/issue-17758.nll.stderr b/src/test/ui/issues/issue-17758.nll.stderr index 613ef6b907c..32030540a84 100644 --- a/src/test/ui/issues/issue-17758.nll.stderr +++ b/src/test/ui/issues/issue-17758.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-17758.rs:7:9 + --> $DIR/issue-17758.rs:11:9 | LL | trait Foo<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-17758.rs b/src/test/ui/issues/issue-17758.rs index d0dbd3455df..8090022b6d0 100644 --- a/src/test/ui/issues/issue-17758.rs +++ b/src/test/ui/issues/issue-17758.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that regionck suggestions in a provided method of a trait // don't ICE @@ -5,7 +9,8 @@ trait Foo<'a> { fn foo(&'a self); fn bar(&self) { self.foo(); - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-26217.stderr b/src/test/ui/issues/issue-26217.base.stderr index f5c641be2d4..8b1ef806abb 100644 --- a/src/test/ui/issues/issue-26217.stderr +++ b/src/test/ui/issues/issue-26217.base.stderr @@ -1,5 +1,5 @@ error[E0477]: the type `&'a i32` does not fulfill the required lifetime - --> $DIR/issue-26217.rs:4:5 + --> $DIR/issue-26217.rs:8:5 | LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-26217.nll.stderr b/src/test/ui/issues/issue-26217.nll.stderr index c7601caacdc..c8b7d620557 100644 --- a/src/test/ui/issues/issue-26217.nll.stderr +++ b/src/test/ui/issues/issue-26217.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-26217.rs:4:5 + --> $DIR/issue-26217.rs:8:5 | LL | fn bar<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-26217.rs b/src/test/ui/issues/issue-26217.rs index 05e04621909..6cc60b05dc6 100644 --- a/src/test/ui/issues/issue-26217.rs +++ b/src/test/ui/issues/issue-26217.rs @@ -1,8 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo<T>() where for<'a> T: 'a {} fn bar<'a>() { foo::<&'a i32>(); - //~^ ERROR the type `&'a i32` does not fulfill the required lifetime + //[base]~^ ERROR the type `&'a i32` does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/issues/issue-40000.stderr b/src/test/ui/issues/issue-40000.base.stderr index 00543c5fff4..a8518dde22e 100644 --- a/src/test/ui/issues/issue-40000.stderr +++ b/src/test/ui/issues/issue-40000.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other diff --git a/src/test/ui/issues/issue-40000.nll.stderr b/src/test/ui/issues/issue-40000.nll.stderr index e6f0b5fbfba..81df9969a4f 100644 --- a/src/test/ui/issues/issue-40000.nll.stderr +++ b/src/test/ui/issues/issue-40000.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | foo(bar); found trait object `dyn Fn(&i32)` error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other diff --git a/src/test/ui/issues/issue-40000.rs b/src/test/ui/issues/issue-40000.rs index 9d5ef481afc..3639413bfaf 100644 --- a/src/test/ui/issues/issue-40000.rs +++ b/src/test/ui/issues/issue-40000.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn main() { let bar: fn(&mut u32) = |_| {}; fn foo(x: Box<dyn Fn(&i32)>) {} let bar = Box::new(|x: &i32| {}) as Box<dyn Fn(_)>; - foo(bar); //~ ERROR E0308 + foo(bar); + //~^ ERROR E0308 + //[nll]~^^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-46983.stderr b/src/test/ui/issues/issue-46983.base.stderr index ed9f1884c42..97ed4d65093 100644 --- a/src/test/ui/issues/issue-46983.stderr +++ b/src/test/ui/issues/issue-46983.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-46983.rs:2:5 + --> $DIR/issue-46983.rs:6:5 | LL | fn foo(x: &u32) -> &'static u32 { | ---- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/issues/issue-46983.nll.stderr b/src/test/ui/issues/issue-46983.nll.stderr index 38a219bbd7b..1327ff80c80 100644 --- a/src/test/ui/issues/issue-46983.nll.stderr +++ b/src/test/ui/issues/issue-46983.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-46983.rs:2:5 + --> $DIR/issue-46983.rs:6:5 | LL | fn foo(x: &u32) -> &'static u32 { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/issues/issue-46983.rs b/src/test/ui/issues/issue-46983.rs index 87ed8928944..e3ecdc8deac 100644 --- a/src/test/ui/issues/issue-46983.rs +++ b/src/test/ui/issues/issue-46983.rs @@ -1,6 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x: &u32) -> &'static u32 { &*x - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/issues/issue-52533.stderr b/src/test/ui/issues/issue-52533.base.stderr index ccedbcfec7a..6556a52de14 100644 --- a/src/test/ui/issues/issue-52533.stderr +++ b/src/test/ui/issues/issue-52533.base.stderr @@ -1,16 +1,16 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/issue-52533.rs:5:16 + --> $DIR/issue-52533.rs:9:16 | LL | foo(|a, b| b) | ^ | note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/issue-52533.rs:5:9 + --> $DIR/issue-52533.rs:9:9 | LL | foo(|a, b| b) | ^^^^^^^^ note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined here - --> $DIR/issue-52533.rs:5:9 + --> $DIR/issue-52533.rs:9:9 | LL | foo(|a, b| b) | ^^^^^^^^ diff --git a/src/test/ui/issues/issue-52533.nll.stderr b/src/test/ui/issues/issue-52533.nll.stderr index c764736d798..75fe5a5b862 100644 --- a/src/test/ui/issues/issue-52533.nll.stderr +++ b/src/test/ui/issues/issue-52533.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-52533.rs:5:16 + --> $DIR/issue-52533.rs:9:16 | LL | foo(|a, b| b) | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` diff --git a/src/test/ui/issues/issue-52533.rs b/src/test/ui/issues/issue-52533.rs index a35f5a80a87..bc6264d0e2f 100644 --- a/src/test/ui/issues/issue-52533.rs +++ b/src/test/ui/issues/issue-52533.rs @@ -1,7 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(_: impl for<'a> FnOnce(&'a u32, &u32) -> &'a u32) { } fn main() { foo(|a, b| b) - //~^ ERROR lifetime of reference outlives lifetime of borrowed content... + //[base]~^ ERROR lifetime of reference outlives lifetime of borrowed content... + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/issues/issue-54302-cases.stderr b/src/test/ui/issues/issue-54302-cases.base.stderr index baa75f28d37..db91edf51e3 100644 --- a/src/test/ui/issues/issue-54302-cases.stderr +++ b/src/test/ui/issues/issue-54302-cases.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:63:5 + --> $DIR/issue-54302-cases.rs:67:5 | LL | <u32 as RefFoo<u32>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | <u32 as RefFoo<u32>>::ref_foo(a) = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:69:5 + --> $DIR/issue-54302-cases.rs:73:5 | LL | <i32 as RefFoo<i32>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | <i32 as RefFoo<i32>>::ref_foo(a) = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:75:5 + --> $DIR/issue-54302-cases.rs:79:5 | LL | <u64 as RefFoo<u64>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | <u64 as RefFoo<u64>>::ref_foo(a) = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:81:5 + --> $DIR/issue-54302-cases.rs:85:5 | LL | <i64 as RefFoo<i64>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/issues/issue-54302-cases.nll.stderr b/src/test/ui/issues/issue-54302-cases.nll.stderr index 6e8b69c4bee..89725d3b03a 100644 --- a/src/test/ui/issues/issue-54302-cases.nll.stderr +++ b/src/test/ui/issues/issue-54302-cases.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:63:5 + --> $DIR/issue-54302-cases.rs:67:5 | LL | <u32 as RefFoo<u32>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | <u32 as RefFoo<u32>>::ref_foo(a) = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:69:5 + --> $DIR/issue-54302-cases.rs:73:5 | LL | <i32 as RefFoo<i32>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | <i32 as RefFoo<i32>>::ref_foo(a) = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:75:5 + --> $DIR/issue-54302-cases.rs:79:5 | LL | <u64 as RefFoo<u64>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | <u64 as RefFoo<u64>>::ref_foo(a) = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:81:5 + --> $DIR/issue-54302-cases.rs:85:5 | LL | <i64 as RefFoo<i64>>::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/issues/issue-54302-cases.rs b/src/test/ui/issues/issue-54302-cases.rs index faa116269ee..f712d9b7718 100644 --- a/src/test/ui/issues/issue-54302-cases.rs +++ b/src/test/ui/issues/issue-54302-cases.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Mirror { type Image; fn coerce(self) -> Self::Image; diff --git a/src/test/ui/issues/issue-54943.stderr b/src/test/ui/issues/issue-54943.base.stderr index e917958c05e..ebd679996d0 100644 --- a/src/test/ui/issues/issue-54943.stderr +++ b/src/test/ui/issues/issue-54943.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'a u32` does not fulfill the required lifetime - --> $DIR/issue-54943.rs:6:13 + --> $DIR/issue-54943.rs:10:13 | LL | let x = foo::<&'a u32>(); | ^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/issue-54943.rs:1:11 + --> $DIR/issue-54943.rs:5:11 | LL | fn foo<T: 'static>() { } | ^^^^^^^ diff --git a/src/test/ui/issues/issue-54943.nll.stderr b/src/test/ui/issues/issue-54943.nll.stderr index 59be0f983b9..2c86a5a3390 100644 --- a/src/test/ui/issues/issue-54943.nll.stderr +++ b/src/test/ui/issues/issue-54943.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-54943.rs:6:13 + --> $DIR/issue-54943.rs:10:13 | LL | fn boo<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-54943.rs b/src/test/ui/issues/issue-54943.rs index 85722300bf0..ad463e7a466 100644 --- a/src/test/ui/issues/issue-54943.rs +++ b/src/test/ui/issues/issue-54943.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo<T: 'static>() { } fn boo<'a>() { diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.base.stderr index de327cd3cc2..26b1c9ec468 100644 --- a/src/test/ui/issues/issue-55731.stderr +++ b/src/test/ui/issues/issue-55731.base.stderr @@ -1,5 +1,5 @@ error: implementation of `DistributedIteratorMulti` is not general enough - --> $DIR/issue-55731.rs:48:5 + --> $DIR/issue-55731.rs:52:5 | LL | multi(Map { | ^^^^^ implementation of `DistributedIteratorMulti` is not general enough diff --git a/src/test/ui/issues/issue-55731.nll.stderr b/src/test/ui/issues/issue-55731.nll.stderr index 97fd6678c99..168a2cbccd7 100644 --- a/src/test/ui/issues/issue-55731.nll.stderr +++ b/src/test/ui/issues/issue-55731.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `DistributedIteratorMulti` is not general enough - --> $DIR/issue-55731.rs:48:5 + --> $DIR/issue-55731.rs:52:5 | LL | / multi(Map { LL | | i: Cloned(PhantomData), diff --git a/src/test/ui/issues/issue-55731.rs b/src/test/ui/issues/issue-55731.rs index 7b4f4e2cd3b..c6a0ee12589 100644 --- a/src/test/ui/issues/issue-55731.rs +++ b/src/test/ui/issues/issue-55731.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker::PhantomData; trait DistributedIterator { diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.base.stderr index 569a13f45bc..a4c5d68472d 100644 --- a/src/test/ui/issues/issue-55796.stderr +++ b/src/test/ui/issues/issue-55796.base.stderr @@ -1,22 +1,22 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-55796.rs:5:17 + --> $DIR/issue-55796.rs:9:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<<Self as Graph<'a>>::EdgesIter, [closure@$DIR/issue-55796.rs:16:40: 16:54]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:16:9 +note: ...so that the type `Map<<Self as Graph<'a>>::EdgesIter, [closure@$DIR/issue-55796.rs:20:40: 20:54]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,24 +24,24 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) found `Box<dyn Iterator<Item = <Self as Graph<'a>>::Node>>` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-55796.rs:5:17 + --> $DIR/issue-55796.rs:9:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<<Self as Graph<'a>>::EdgesIter, [closure@$DIR/issue-55796.rs:21:39: 21:53]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:21:9 +note: ...so that the type `Map<<Self as Graph<'a>>::EdgesIter, [closure@$DIR/issue-55796.rs:26:39: 26:53]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-55796.nll.stderr b/src/test/ui/issues/issue-55796.nll.stderr index 5809a56cd4b..2b7d231871a 100644 --- a/src/test/ui/issues/issue-55796.nll.stderr +++ b/src/test/ui/issues/issue-55796.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here @@ -8,7 +8,7 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index d802ce3b6cf..a0bc63dd2a7 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait EdgeTrait<N> { fn target(&self) -> N; } @@ -14,12 +18,14 @@ pub trait Graph<'a> { fn out_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> { Box::new(self.out_edges(u).map(|e| e.target())) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn in_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> { Box::new(self.in_edges(u).map(|e| e.target())) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-75777.stderr b/src/test/ui/issues/issue-75777.base.stderr index f440d7d1932..d2c6738cb59 100644 --- a/src/test/ui/issues/issue-75777.stderr +++ b/src/test/ui/issues/issue-75777.base.stderr @@ -1,16 +1,16 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-75777.rs:11:14 + --> $DIR/issue-75777.rs:15:14 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-75777.rs:9:11 + --> $DIR/issue-75777.rs:13:11 | LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-75777.rs:11:14 + --> $DIR/issue-75777.rs:15:14 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | Box::new(move |_| fut) found `(Pin<Box<(dyn Future<Output = A> + Send + 'a)>>,)` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-75777.rs:11:5 + --> $DIR/issue-75777.rs:15:5 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-75777.nll.stderr b/src/test/ui/issues/issue-75777.nll.stderr index 370cd72fd55..d1f8d388676 100644 --- a/src/test/ui/issues/issue-75777.nll.stderr +++ b/src/test/ui/issues/issue-75777.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-75777.rs:11:5 + --> $DIR/issue-75777.rs:15:5 | LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-75777.rs b/src/test/ui/issues/issue-75777.rs index 357c07c7cec..930cd7ad37b 100644 --- a/src/test/ui/issues/issue-75777.rs +++ b/src/test/ui/issues/issue-75777.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #75777. // Checks that a boxed future can be properly constructed. @@ -9,7 +13,8 @@ type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a + Send>>; fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { let fut: BoxFuture<'a, A> = Box::pin(future::ready(v)); Box::new(move |_| fut) - //~^ ERROR: cannot infer an appropriate lifetime + //[base]~^ ERROR: cannot infer an appropriate lifetime + //[nll]~^^ ERROR: lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.base.stderr index f227ac2477e..2fa8993b71a 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.base.stderr @@ -1,11 +1,11 @@ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable<T>; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -16,13 +16,13 @@ LL | fn f<T: std::marker::Send>(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable<T>; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -33,13 +33,13 @@ LL | fn f<T: std::marker::Copy>(val: T) { | +++++++++++++++++++ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable<T> = &t; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -50,13 +50,13 @@ LL | fn g<T: std::marker::Send>(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable<T> = &t; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -67,7 +67,7 @@ LL | fn g<T: std::marker::Copy>(val: T) { | +++++++++++++++++++ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/kindck-impl-type-params.rs:32:13 + --> $DIR/kindck-impl-type-params.rs:34:13 | LL | let a = &t as &dyn Gettable<&'a isize>; | ^^ @@ -75,28 +75,28 @@ LL | let a = &t as &dyn Gettable<&'a isize>; = note: type must satisfy the static lifetime error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:38:13 + --> $DIR/kindck-impl-type-params.rs:40:13 | LL | let a = t as Box<dyn Gettable<String>>; | ^ the trait `Copy` is not implemented for `String` | = help: the trait `Gettable<T>` is implemented for `S<T>` note: required because of the requirements on the impl of `Gettable<String>` for `S<String>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable<String>` error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:37 + --> $DIR/kindck-impl-type-params.rs:48:37 | LL | let a: Box<dyn Gettable<Foo>> = t; | ^ the trait `Copy` is not implemented for `Foo` | = help: the trait `Gettable<T>` is implemented for `S<T>` note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index 1772d353fe4..c6f5e17fb69 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -1,11 +1,11 @@ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable<T>; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -16,13 +16,13 @@ LL | fn f<T: std::marker::Send>(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable<T>; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -33,13 +33,13 @@ LL | fn f<T: std::marker::Copy>(val: T) { | +++++++++++++++++++ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable<T> = &t; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -50,13 +50,13 @@ LL | fn g<T: std::marker::Send>(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable<T> = &t; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ @@ -67,28 +67,28 @@ LL | fn g<T: std::marker::Copy>(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:38:13 + --> $DIR/kindck-impl-type-params.rs:40:13 | LL | let a = t as Box<dyn Gettable<String>>; | ^ the trait `Copy` is not implemented for `String` | = help: the trait `Gettable<T>` is implemented for `S<T>` note: required because of the requirements on the impl of `Gettable<String>` for `S<String>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable<String>` error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:37 + --> $DIR/kindck-impl-type-params.rs:48:37 | LL | let a: Box<dyn Gettable<Foo>> = t; | ^ the trait `Copy` is not implemented for `Foo` | = help: the trait `Gettable<T>` is implemented for `S<T>` note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ^^^^^^^^^^^ ^^^^ diff --git a/src/test/ui/kindck/kindck-impl-type-params.rs b/src/test/ui/kindck/kindck-impl-type-params.rs index 5622d65cb17..1a563872585 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.rs +++ b/src/test/ui/kindck/kindck-impl-type-params.rs @@ -1,8 +1,10 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Issue #14061: tests the interaction between generic implementation // parameter bounds and trait objects. - - use std::marker; struct S<T>(marker::PhantomData<T>); @@ -30,7 +32,7 @@ fn g<T>(val: T) { fn foo<'a>() { let t: S<&'a isize> = S(marker::PhantomData); let a = &t as &dyn Gettable<&'a isize>; - //~^ ERROR does not fulfill + //[base]~^ ERROR does not fulfill } fn foo2<'a>() { diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.base.stderr index 58397b7f597..5976c7119c7 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.base.stderr @@ -1,5 +1,5 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely - --> $DIR/kindck-send-object1.rs:10:5 + --> $DIR/kindck-send-object1.rs:14:5 | LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -7,25 +7,25 @@ LL | assert_send::<&'a dyn Dummy>(); = help: the trait `Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `Send` for `&'a (dyn Dummy + 'a)` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send<T:Send+'static>() { } | ^^^^ required by this bound in `assert_send` error[E0477]: the type `&'a (dyn Dummy + Sync + 'a)` does not fulfill the required lifetime - --> $DIR/kindck-send-object1.rs:14:5 + --> $DIR/kindck-send-object1.rs:18:5 | LL | assert_send::<&'a (dyn Dummy + Sync)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/kindck-send-object1.rs:5:23 + --> $DIR/kindck-send-object1.rs:9:23 | LL | fn assert_send<T:Send+'static>() { } | ^^^^^^^ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely - --> $DIR/kindck-send-object1.rs:29:5 + --> $DIR/kindck-send-object1.rs:33:5 | LL | assert_send::<Box<dyn Dummy + 'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely @@ -34,7 +34,7 @@ LL | assert_send::<Box<dyn Dummy + 'a>>(); = note: required because of the requirements on the impl of `Send` for `Unique<(dyn Dummy + 'a)>` = note: required because it appears within the type `Box<(dyn Dummy + 'a)>` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send<T:Send+'static>() { } | ^^^^ required by this bound in `assert_send` diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index fa190449b64..f34374dcc54 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -1,5 +1,5 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely - --> $DIR/kindck-send-object1.rs:10:5 + --> $DIR/kindck-send-object1.rs:14:5 | LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -7,13 +7,13 @@ LL | assert_send::<&'a dyn Dummy>(); = help: the trait `Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `Send` for `&'a (dyn Dummy + 'a)` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send<T:Send+'static>() { } | ^^^^ required by this bound in `assert_send` error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely - --> $DIR/kindck-send-object1.rs:29:5 + --> $DIR/kindck-send-object1.rs:33:5 | LL | assert_send::<Box<dyn Dummy + 'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely @@ -22,7 +22,7 @@ LL | assert_send::<Box<dyn Dummy + 'a>>(); = note: required because of the requirements on the impl of `Send` for `Unique<(dyn Dummy + 'a)>` = note: required because it appears within the type `Box<(dyn Dummy + 'a)>` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send<T:Send+'static>() { } | ^^^^ required by this bound in `assert_send` diff --git a/src/test/ui/kindck/kindck-send-object1.rs b/src/test/ui/kindck/kindck-send-object1.rs index 0e198395c26..26894dc2ce4 100644 --- a/src/test/ui/kindck/kindck-send-object1.rs +++ b/src/test/ui/kindck/kindck-send-object1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test which object types are considered sendable. This test // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! @@ -12,7 +16,7 @@ fn test51<'a>() { } fn test52<'a>() { assert_send::<&'a (dyn Dummy + Sync)>(); - //~^ ERROR does not fulfill the required lifetime + //[base]~^ ERROR does not fulfill the required lifetime } // ...unless they are properly bounded diff --git a/src/test/ui/lifetimes/issue-79187-2.stderr b/src/test/ui/lifetimes/issue-79187-2.base.stderr index 2aca8faff9f..95591412f7e 100644 --- a/src/test/ui/lifetimes/issue-79187-2.stderr +++ b/src/test/ui/lifetimes/issue-79187-2.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | take_foo(|a| a); = note: expected type `for<'r> Fn<(&'r i32,)>` found type `Fn<(&i32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187-2.rs:8:14 + --> $DIR/issue-79187-2.rs:12:14 | LL | take_foo(|a| a); | ^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:9:5 + --> $DIR/issue-79187-2.rs:16:5 | LL | take_foo(|a: &i32| a); | ^^^^^^^^ lifetime mismatch @@ -26,18 +26,18 @@ LL | take_foo(|a: &i32| a); = note: expected reference `&i32` found reference `&i32` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/issue-79187-2.rs:9:14 + --> $DIR/issue-79187-2.rs:16:14 | LL | take_foo(|a: &i32| a); | ^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:10:5 + --> $DIR/issue-79187-2.rs:20:5 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^ lifetime mismatch @@ -45,12 +45,12 @@ LL | take_foo(|a: &i32| -> &i32 { a }); = note: expected reference `&i32` found reference `&i32` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/issue-79187-2.rs:10:14 + --> $DIR/issue-79187-2.rs:20:14 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ diff --git a/src/test/ui/lifetimes/issue-79187-2.nll.stderr b/src/test/ui/lifetimes/issue-79187-2.nll.stderr index 04d9b64d64f..3cbce7600f9 100644 --- a/src/test/ui/lifetimes/issue-79187-2.nll.stderr +++ b/src/test/ui/lifetimes/issue-79187-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-79187-2.rs:9:24 + --> $DIR/issue-79187-2.rs:16:24 | LL | take_foo(|a: &i32| a); | - - ^ returning this value requires that `'1` must outlive `'2` @@ -8,7 +8,7 @@ LL | take_foo(|a: &i32| a); | let's call the lifetime of this reference `'1` error: lifetime may not live long enough - --> $DIR/issue-79187-2.rs:10:34 + --> $DIR/issue-79187-2.rs:20:34 | LL | take_foo(|a: &i32| -> &i32 { a }); | - - ^ returning this value requires that `'1` must outlive `'2` @@ -17,7 +17,7 @@ LL | take_foo(|a: &i32| -> &i32 { a }); | let's call the lifetime of this reference `'1` error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough @@ -26,7 +26,7 @@ LL | take_foo(|a| a); = note: ...but it actually implements `FnOnce<(&'2 i32,)>`, for some specific lifetime `'2` error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ one type is more general than the other @@ -34,18 +34,18 @@ LL | take_foo(|a| a); = note: expected type `for<'r> Fn<(&'r i32,)>` found type `Fn<(&i32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187-2.rs:8:14 + --> $DIR/issue-79187-2.rs:12:14 | LL | take_foo(|a| a); | ^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:9:5 + --> $DIR/issue-79187-2.rs:16:5 | LL | take_foo(|a: &i32| a); | ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -53,13 +53,13 @@ LL | take_foo(|a: &i32| a); = note: expected reference `&i32` found reference `&i32` note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:10:5 + --> $DIR/issue-79187-2.rs:20:5 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -67,7 +67,7 @@ LL | take_foo(|a: &i32| -> &i32 { a }); = note: expected reference `&i32` found reference `&i32` note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ diff --git a/src/test/ui/lifetimes/issue-79187-2.rs b/src/test/ui/lifetimes/issue-79187-2.rs index 29d108facab..d122b92f74b 100644 --- a/src/test/ui/lifetimes/issue-79187-2.rs +++ b/src/test/ui/lifetimes/issue-79187-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<F> Foo for F where F: Fn(&i32) -> &i32 {} @@ -5,9 +9,18 @@ impl<F> Foo for F where F: Fn(&i32) -> &i32 {} fn take_foo(_: impl Foo) {} fn main() { - take_foo(|a| a); //~ ERROR mismatched types - take_foo(|a: &i32| a); //~ ERROR mismatched types - take_foo(|a: &i32| -> &i32 { a }); //~ ERROR mismatched types + take_foo(|a| a); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR implementation of `FnOnce` is not general enough + //[nll]~| ERROR mismatched types + take_foo(|a: &i32| a); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR mismatched types + take_foo(|a: &i32| -> &i32 { a }); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR mismatched types // OK take_foo(identity(|a| a)); diff --git a/src/test/ui/lifetimes/issue-79187.stderr b/src/test/ui/lifetimes/issue-79187.base.stderr index 3c0439fb660..c4654ca1517 100644 --- a/src/test/ui/lifetimes/issue-79187.stderr +++ b/src/test/ui/lifetimes/issue-79187.base.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/issue-79187.nll.stderr b/src/test/ui/lifetimes/issue-79187.nll.stderr index 3a993e88d8a..54dce9b4bac 100644 --- a/src/test/ui/lifetimes/issue-79187.nll.stderr +++ b/src/test/ui/lifetimes/issue-79187.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^^^^ one type is more general than the other @@ -7,18 +7,18 @@ LL | thing(f); = note: expected type `for<'r> FnOnce<(&'r u32,)>` found type `FnOnce<(&u32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187.rs:4:13 + --> $DIR/issue-79187.rs:8:13 | LL | let f = |_| (); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187.rs:1:18 + --> $DIR/issue-79187.rs:5:18 | LL | fn thing(x: impl FnOnce(&u32)) {} | ^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/issue-79187.rs b/src/test/ui/lifetimes/issue-79187.rs index 2ee69ee2234..b97890d94e9 100644 --- a/src/test/ui/lifetimes/issue-79187.rs +++ b/src/test/ui/lifetimes/issue-79187.rs @@ -1,6 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn thing(x: impl FnOnce(&u32)) {} fn main() { let f = |_| (); - thing(f); //~ERROR implementation of `FnOnce` is not general enough + thing(f); + //[nll]~^ ERROR mismatched types + //~^^ ERROR implementation of `FnOnce` is not general enough } diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed new file mode 100644 index 00000000000..4b417afb038 --- /dev/null +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed @@ -0,0 +1,15 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `issue-90170-elision-mismatch.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs new file mode 100644 index 00000000000..ec50e8e1d9a --- /dev/null +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs @@ -0,0 +1,15 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `issue-90170-elision-mismatch.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr index 48fb3fb4a22..144fe3bf9da 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:3:40 + --> $DIR/issue-90170-elision-mismatch-nll.rs:9:40 | LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:5:44 + --> $DIR/issue-90170-elision-mismatch-nll.rs:11:44 | LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ~~ ++ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:7:63 + --> $DIR/issue-90170-elision-mismatch-nll.rs:13:63 | LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed b/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed index 0bc889ee721..f05943284f7 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `issue-90170-elision-mismatch-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs b/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs index 1d6573c00ad..fee2b461ef9 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `issue-90170-elision-mismatch-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr index 7fa092ca220..28f3957041c 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:3:47 + --> $DIR/issue-90170-elision-mismatch.rs:8:47 | LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | --- --- ^ ...but data from `y` flows into `x` here @@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ++ ++ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:5:51 + --> $DIR/issue-90170-elision-mismatch.rs:10:51 | LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | ------ --- ^ ...but data from `y` flows into `x` here @@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ~~ ++ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:7:70 + --> $DIR/issue-90170-elision-mismatch.rs:12:70 | LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | --- --- ^ ...but data from `y` flows into `x` here diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr index e06255e4ea3..b20ce7b07ff 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32 + --> $DIR/issue-90600-expected-return-static-indirect.rs:11:32 | LL | fn inner(mut foo: &[u8]) { | ----- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr index 99e1e7217b4..b35505ac8c5 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr @@ -1,9 +1,9 @@ error[E0597]: `foo` does not live long enough - --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32 + --> $DIR/issue-90600-expected-return-static-indirect.rs:11:32 | LL | let refcell = RefCell::new(&mut foo); | ^^^^^^^^ borrowed value does not live long enough -LL | +... LL | let read = &refcell as &RefCell<dyn Read>; | -------- cast requires that `foo` is borrowed for `'static` ... @@ -11,7 +11,7 @@ LL | } | - `foo` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/issue-90600-expected-return-static-indirect.rs:9:16 + --> $DIR/issue-90600-expected-return-static-indirect.rs:14:16 | LL | fn inner(mut foo: &[u8]) { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs index 39996bbf43b..fa44be9a912 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::cell::RefCell; use std::io::Read; @@ -5,8 +9,10 @@ fn main() {} fn inner(mut foo: &[u8]) { let refcell = RefCell::new(&mut foo); - //~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR `foo` does not live long enough let read = &refcell as &RefCell<dyn Read>; + //[nll]~^ ERROR lifetime may not live long enough read_thing(read); } diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.base.stderr index bb691fc072b..54fa49b47f6 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/lifetime-bound-will-change-warning.rs:34:13 + --> $DIR/lifetime-bound-will-change-warning.rs:38:13 | LL | ref_obj(x) | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | ref_obj(x) = note: expected reference `&Box<(dyn Fn() + 'static)>` found reference `&Box<(dyn Fn() + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/lifetime-bound-will-change-warning.rs:32:10 + --> $DIR/lifetime-bound-will-change-warning.rs:36:10 | LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/lifetime-bound-will-change-warning.rs:39:18 + --> $DIR/lifetime-bound-will-change-warning.rs:45:18 | LL | lib::ref_obj(x) | ^ lifetime mismatch @@ -22,7 +22,7 @@ LL | lib::ref_obj(x) = note: expected reference `&Box<(dyn Fn() + 'static)>` found reference `&Box<(dyn Fn() + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/lifetime-bound-will-change-warning.rs:37:12 + --> $DIR/lifetime-bound-will-change-warning.rs:43:12 | LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { | ^^ diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index 6f3f84096e4..10105c5ccec 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:34:5 + --> $DIR/lifetime-bound-will-change-warning.rs:38:5 | LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { | -- - `x` is a reference that is only valid in the function body @@ -13,7 +13,7 @@ LL | ref_obj(x) | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:39:5 + --> $DIR/lifetime-bound-will-change-warning.rs:45:5 | LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs index 3c6d92234c4..0a082e1bae8 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // aux-build:lifetime_bound_will_change_warning_lib.rs // Test that various corner cases cause an error. These are tests @@ -31,12 +35,16 @@ fn test1cc<'a>(x: &'a Box<dyn Fn() + 'a>) { fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { // but ref_obj will not, so warn. - ref_obj(x) //~ ERROR mismatched types + ref_obj(x) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes } fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { // same as test2, but cross crate - lib::ref_obj(x) //~ ERROR mismatched types + lib::ref_obj(x) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes } fn test3<'a>(x: &'a Box<dyn Fn() + 'static>) { diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.base.stderr index e9f5fc311df..60cd3493875 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20 + --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20 | LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | ---- ------- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr index 4c788211576..f8e275e9b14 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20 + --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20 | LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs index 12024bd1080..fbb523daa1f 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32; @@ -8,7 +12,9 @@ impl Foo for () { fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { - if x > y { x } else { y } //~ ERROR lifetime mismatch + if x > y { x } else { y } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.base.stderr index 0d506f2b9fc..697950a00fb 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5 | LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | ------- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr index 11e7fa96d7e..97af4b58cbf 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5 | LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs index ef5dd1160fb..704db7dc8b4 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32 } @@ -5,7 +9,9 @@ struct Foo { impl Foo { fn foo<'a>(&self, x: &'a i32) -> &i32 { - x //~ ERROR lifetime mismatch + x + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.base.stderr index 98a23613c36..65644d03cdc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30 + --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30 | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | ----- ------- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr index c41f08e691a..00a348de4bc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30 + --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30 | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs index 597d20dbacd..a846c115c06 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32, } @@ -5,7 +9,9 @@ struct Foo { impl Foo { fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { - if true { x } else { self } //~ ERROR lifetime mismatch + if true { x } else { self } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.base.stderr index 412cac43563..9203d6603bd 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex2a-push-one-existing-name-2.rs:6:12 + --> $DIR/ex2a-push-one-existing-name-2.rs:10:12 | LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) { | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr index 90d4754ebab..5ab8b449816 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex2a-push-one-existing-name-2.rs:6:5 + --> $DIR/ex2a-push-one-existing-name-2.rs:10:5 | LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) { | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs index 998a48ce20c..7e776baa6a9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.base.stderr index 30826c3613c..ec1ab19d5a4 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:12 + --> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:12 | LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr index a03e16b3b79..bd5864bae32 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:5 + --> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:5 | LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs index d18b50d0d0c..73613a9bf35 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo<'a> {} impl<'a, T> Foo<'a> for T {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.base.stderr index 13d0835287d..ab0e202a32e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name.rs:6:12 + --> $DIR/ex2a-push-one-existing-name.rs:10:12 | LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) { | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr index 487b34e3d18..01b7f45d81b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name.rs:6:5 + --> $DIR/ex2a-push-one-existing-name.rs:10:5 | LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) { | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs index 5188ea1cc9c..5773e13304c 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.base.stderr index e505c9c0dc2..58a2088df5e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2b-push-no-existing-names.rs:6:12 + --> $DIR/ex2b-push-no-existing-names.rs:10:12 | LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) { | -------- -------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr index 1622ce42290..afe413bcca5 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2b-push-no-existing-names.rs:6:5 + --> $DIR/ex2b-push-no-existing-names.rs:10:5 | LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) { | - - has type `Ref<'1, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs index 82e0c9bc26e..8d830343b08 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.base.stderr index 63b1c6db28f..63033b8d16e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2c-push-inference-variable.rs:7:12 + --> $DIR/ex2c-push-inference-variable.rs:11:12 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr index 99fab4631a2..63a0f2409d9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2c-push-inference-variable.rs:7:5 + --> $DIR/ex2c-push-inference-variable.rs:11:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs index 7f15aee5f08..f676eb403a8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { let z = Ref { data: y.data }; - x.push(z); //~ ERROR lifetime mismatch + x.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.base.stderr index 2f669efcf1e..a50985ca704 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2d-push-inference-variable-2.rs:6:33 + --> $DIR/ex2d-push-inference-variable-2.rs:10:33 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr index 52c5752f6ea..0d7461fa682 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2d-push-inference-variable-2.rs:8:5 + --> $DIR/ex2d-push-inference-variable-2.rs:13:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs index ee77d9e7fde..e65638fb0df 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs @@ -1,11 +1,17 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { - let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch + let a: &mut Vec<Ref<i32>> = x; + //[base]~^ ERROR lifetime mismatch let b = Ref { data: y.data }; a.push(b); + //[nll]~^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.base.stderr index 258b6805acd..dbe965a340c 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2e-push-inference-variable-3.rs:6:33 + --> $DIR/ex2e-push-inference-variable-3.rs:10:33 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr index e90c81ee3e1..74b2739b2c3 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2e-push-inference-variable-3.rs:8:5 + --> $DIR/ex2e-push-inference-variable-3.rs:13:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs index e2a795a071c..036afe09be6 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs @@ -1,11 +1,17 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) { - let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch + let a: &mut Vec<Ref<i32>> = x; + //[base]~^ ERROR lifetime mismatch let b = Ref { data: y.data }; Vec::push(a, b); + //[nll]~^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.base.stderr index 5c793636778..459f18dcc3d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-2.rs:2:10 + --> $DIR/ex3-both-anon-regions-2.rs:6:10 | LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr index 5a23f1e0e9d..b072c12ea3b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-2.rs:2:5 + --> $DIR/ex3-both-anon-regions-2.rs:6:5 | LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs index 1ff96aadd93..668cadd614b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { - *v = x; //~ ERROR lifetime mismatch + *v = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.base.stderr index 1a7b4fca1ba..28df5f18369 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-3.rs:2:13 + --> $DIR/ex3-both-anon-regions-3.rs:6:13 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | --- --- these two types are declared with different lifetimes... @@ -13,7 +13,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { | ++++ ++ ++ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-3.rs:2:15 + --> $DIR/ex3-both-anon-regions-3.rs:6:15 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr index 6ba130308a3..c1d809abad5 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-3.rs:2:5 + --> $DIR/ex3-both-anon-regions-3.rs:6:5 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-3.rs:2:5 + --> $DIR/ex3-both-anon-regions-3.rs:6:5 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | - - let's call the lifetime of this reference `'3` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs index c483f59f9d9..4d7fd63e5b9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs @@ -1,6 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - z.push((x,y)); //~ ERROR lifetime mismatch - //~^ ERROR lifetime mismatch + z.push((x,y)); + //[base]~^ ERROR lifetime mismatch + //[base]~| ERROR lifetime mismatch + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.base.stderr index 8e41d7c54e6..32263cd56ee 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:11 + --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:11 | LL | fn foo(mut x: Ref, y: Ref) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr index 4c0ffe5c090..bfde4025194 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:5 | LL | fn foo(mut x: Ref, y: Ref) { | ----- - has type `Ref<'_, '1>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs index 94bb8092407..30764e2ad17 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref, y: Ref) { - x.b = y.b; //~ ERROR lifetime mismatch + x.b = y.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.base.stderr index d659c88f69e..fb4a2f8f6fe 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:11 + --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:11 | LL | fn foo(mut x: Ref) { | --- this type is declared with multiple lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr index 97c665347f6..9ba2c38d6fe 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:5 | LL | fn foo(mut x: Ref) { | ----- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs index 3b22aef6f32..665be2aa2c8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref) { - x.a = x.b; //~ ERROR lifetime mismatch + x.a = x.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.base.stderr index 374bbd93d08..66a993e0340 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:12 + --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:12 | LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr index b3d0bc2b882..ddf878ba9f9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:5 | LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs index 87f9cc17726..6e151879f4d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } @@ -6,7 +10,9 @@ fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) where &'a (): Sized, &'b u32: Sized { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.base.stderr index 94798d1ce2a..5453dbb08f1 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:12 + --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:12 | LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) { | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr index fbe98a4263e..cfd3186c809 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:5 | LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs index 4be76c2a0da..ecc04fbc8ad 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.base.stderr index 9f5a79ed333..23e752e4a0e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:12 + --> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:12 | LL | fn foo(mut x: Vec<Ref>, y: Ref) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr index 9630729d0ee..fa906a90ccc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:5 + --> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:5 | LL | fn foo(mut x: Vec<Ref>, y: Ref) { | ----- - has type `Ref<'1>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs index 8fbb405a23d..f002dfc208f 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } fn foo(mut x: Vec<Ref>, y: Ref) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.base.stderr index 2c87f8dbd2c..b5fbc091ebc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:12 + --> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:12 | LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { | ------ ------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr index 1e24032fc1c..d59bee08748 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:5 + --> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:5 | LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs index 7938d11a905..f0a81eba412 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.base.stderr index 60b92ed2b32..3d9138f02c6 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:9 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:9 | LL | fn foo(mut x: Ref, y: &u32) { | --- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr index bbd62902d9f..cac2a9470a8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5 | LL | fn foo(mut x: Ref, y: &u32) { | ----- - let's call the lifetime of this reference `'2` @@ -9,7 +9,7 @@ LL | y = x.b; | ^^^^^^^ assignment requires that `'1` must outlive `'2` error[E0384]: cannot assign to immutable argument `y` - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5 | LL | fn foo(mut x: Ref, y: &u32) { | - help: consider making this binding mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs index 1e6425cf5ca..31ef28e726d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs @@ -1,7 +1,14 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut x: Ref, y: &u32) { - y = x.b; //~ ERROR lifetime mismatch + y = x.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot assign to immutable argument } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.base.stderr index a220c8ddb2b..77e035562a8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:11 + --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:11 | LL | fn foo(mut y: Ref, x: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr index 79e7e8e157d..ba41cc3e908 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:5 | LL | fn foo(mut y: Ref, x: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs index 02838362c80..9a5ac0a9769 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut y: Ref, x: &u32) { - y.b = x; //~ ERROR lifetime mismatch + y.b = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.base.stderr index 73472a8d022..6cbbabb150a 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:11 + --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:11 | LL | fn foo(mut y: Ref, x: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr index 53615fd1aba..c9570aa7206 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:5 | LL | fn foo(mut y: Ref, x: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs index 02838362c80..9a5ac0a9769 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut y: Ref, x: &u32) { - y.b = x; //~ ERROR lifetime mismatch + y.b = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.base.stderr index eb6e6f2e95e..7caf19e8935 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:11 + --> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:11 | LL | fn foo(mut x: Ref, y: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr index 6ff44116737..9b295248fc9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:5 + --> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:5 | LL | fn foo(mut x: Ref, y: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs index 7c827510be8..0b4ee5adacc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref, y: &u32) { - x.b = y; //~ ERROR lifetime mismatch + x.b = y; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.base.stderr index 636904aefb4..add05a11193 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | ---- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr index 5601335d275..188ff4d77e0 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs index 286cb6dc90e..a4f838c0747 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32 } impl Foo { fn foo<'a>(&self, x: &i32) -> &i32 { - x //~ ERROR lifetime mismatch + x + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.base.stderr index 474eadb7f92..365a0ab3b10 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19 + --> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19 | LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | ---- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr index e221902c4a9..ed9b81f7d01 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19 + --> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19 | LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs index 79d7d63c8bb..c5854537a5f 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32, } impl Foo { fn foo<'a>(&self, x: &Foo) -> &Foo { - if true { x } else { self } //~ ERROR lifetime mismatch + if true { x } else { self } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.base.stderr index 6ed3528bb9f..755e9798170 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:10 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:10 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr index a909c5fa823..904a09610fc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) { | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | - help: consider changing this to be mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs index f9f1a75df58..4b2280b66f2 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs @@ -1,5 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { - y.push(z); //~ ERROR lifetime mismatch + y.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot borrow } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.base.stderr index 68893781dc2..6a8b07dbec8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:16 + --> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:16 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr index 9661f1e5144..46b9e98907d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:9 + --> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:9 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs index 6f95d5a710d..242a2d6fd4f 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn foo<'a>(x: &mut Vec<&u8>, y: &u8); } impl Foo for () { fn foo(x: &mut Vec<&u8>, y: &u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.base.stderr index ede1631db27..e38dd0fc6ee 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:10 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:10 | LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index cce0a31bfbb..54172a845d7 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3 | LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(x:Box<dyn Fn(&'a u8, &'a u8)> , y: Vec<&u8>, z: &u8) { | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3 | LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { | - help: consider changing this to be mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs index 6625d41c7de..b93d75b156d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs @@ -1,5 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { - y.push(z); //~ ERROR lifetime mismatch + y.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot borrow } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.base.stderr index cf405c0de3f..dd96c6eef68 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions.rs:2:12 + --> $DIR/ex3-both-anon-regions.rs:6:12 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr index ec9fac0c288..48e09e37241 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions.rs:2:5 + --> $DIR/ex3-both-anon-regions.rs:6:5 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs index 44195dadbb9..b1d30e83b62 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x: &mut Vec<&u8>, y: &u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.base.stderr index d972861a2b5..ba672f29718 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.base.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr index 2906c05864b..645d14cd54b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds @@ -10,7 +10,7 @@ LL | fn g<T: 'static>(data: &[T]) { | +++++++++ error[E0308]: mismatched types - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -18,13 +18,13 @@ LL | f(data, identity) = note: expected type `for<'r> Fn<(&'r T,)>` found type `Fn<(&T,)>` note: the lifetime requirement is introduced here - --> $DIR/issue_74400.rs:8:34 + --> $DIR/issue_74400.rs:12:34 | LL | fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) { | ^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs index f83384524f7..fdaf2f8a591 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs @@ -1,6 +1,10 @@ //! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely //! recognized as E0308 mismatched types. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::convert::identity; fn main() {} @@ -9,5 +13,9 @@ fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) { } fn g<T>(data: &[T]) { - f(data, identity) //~ ERROR implementation of `FnOnce` is not general + f(data, identity) + //[base]~^ ERROR implementation of `FnOnce` is not general + //[nll]~^^ ERROR the parameter type + //[nll]~| ERROR mismatched types + //[nll]~| ERROR implementation of `FnOnce` is not general } diff --git a/src/test/ui/lifetimes/re-empty-in-error.stderr b/src/test/ui/lifetimes/re-empty-in-error.base.stderr index 227e3ca6139..7dfe23f4f01 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.stderr +++ b/src/test/ui/lifetimes/re-empty-in-error.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'b ()` does not fulfill the required lifetime - --> $DIR/re-empty-in-error.rs:8:5 + --> $DIR/re-empty-in-error.rs:12:5 | LL | foo(&10); | ^^^ | note: type must outlive the empty lifetime as required by this binding - --> $DIR/re-empty-in-error.rs:3:47 + --> $DIR/re-empty-in-error.rs:7:47 | LL | fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a { | ^^ diff --git a/src/test/ui/lifetimes/re-empty-in-error.nll.stderr b/src/test/ui/lifetimes/re-empty-in-error.nll.stderr index 9becdab9186..cddb5732f98 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.nll.stderr +++ b/src/test/ui/lifetimes/re-empty-in-error.nll.stderr @@ -1,5 +1,5 @@ error: higher-ranked lifetime error - --> $DIR/re-empty-in-error.rs:8:5 + --> $DIR/re-empty-in-error.rs:12:5 | LL | foo(&10); | ^^^^^^^^ diff --git a/src/test/ui/lifetimes/re-empty-in-error.rs b/src/test/ui/lifetimes/re-empty-in-error.rs index 41c3718592d..fdb0a3002c4 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.rs +++ b/src/test/ui/lifetimes/re-empty-in-error.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // We didn't have a single test mentioning // `ReEmpty` and this test changes that. fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a { - //~^ NOTE type must outlive the empty lifetime as required by this binding + //[base]~^ NOTE type must outlive the empty lifetime as required by this binding } fn main() { foo(&10); - //~^ ERROR the type `&'b ()` does not fulfill the required lifetime + //[base]~^ ERROR the type `&'b ()` does not fulfill the required lifetime + //[nll]~^^ ERROR higher-ranked lifetime error + //[nll]~| NOTE could not prove } diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.baseleak.stderr index 305e952d604..4448f9326cb 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.baseleak.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/old-lub-glb-hr-noteq1.rs:11:14 + --> $DIR/old-lub-glb-hr-noteq1.rs:17:14 | LL | let z = match 22 { | _____________- @@ -7,6 +7,9 @@ LL | | 0 => x, | | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` LL | | _ => y, | | ^ one type is more general than the other +LL | | +... | +LL | | LL | | }; | |_____- `match` arms have incompatible types | diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.basenoleak.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.basenoleak.stderr new file mode 100644 index 00000000000..4448f9326cb --- /dev/null +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.basenoleak.stderr @@ -0,0 +1,21 @@ +error[E0308]: `match` arms have incompatible types + --> $DIR/old-lub-glb-hr-noteq1.rs:17:14 + | +LL | let z = match 22 { + | _____________- +LL | | 0 => x, + | | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` +LL | | _ => y, + | | ^ one type is more general than the other +LL | | +... | +LL | | +LL | | }; + | |_____- `match` arms have incompatible types + | + = note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` + found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nllleak.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nllleak.stderr new file mode 100644 index 00000000000..4448f9326cb --- /dev/null +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nllleak.stderr @@ -0,0 +1,21 @@ +error[E0308]: `match` arms have incompatible types + --> $DIR/old-lub-glb-hr-noteq1.rs:17:14 + | +LL | let z = match 22 { + | _____________- +LL | | 0 => x, + | | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` +LL | | _ => y, + | | ^ one type is more general than the other +LL | | +... | +LL | | +LL | | }; + | |_____- `match` arms have incompatible types + | + = note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` + found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nll.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nllnoleak.stderr index 5ac392914e5..0d61311350e 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nll.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.nllnoleak.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/old-lub-glb-hr-noteq1.rs:11:14 + --> $DIR/old-lub-glb-hr-noteq1.rs:17:14 | LL | _ => y, | ^ one type is more general than the other diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs index 918542d471b..2cf123cce7f 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs @@ -2,13 +2,23 @@ // general than the other. Test the case where the more general type (`x`) is the first // match arm specifically. +// revisions: baseleak basenoleak nllleak nllnoleak +// ignore-compare-mode-nll +//[nllleak] compile-flags: -Zborrowck=mir +//[nllnoleak] compile-flags: -Zborrowck=mir -Zno-leak-check +//[basenoleak] compile-flags:-Zno-leak-check + fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) { // The two types above are not equivalent. With the older LUB/GLB // algorithm, this may have worked (I don't remember), but now it // doesn't because we require equality. let z = match 22 { 0 => x, - _ => y, //~ ERROR `match` arms have incompatible types + _ => y, + //[baseleak]~^ ERROR `match` arms have incompatible types + //[nllleak]~^^ ERROR `match` arms have incompatible types + //[basenoleak]~^^^ ERROR `match` arms have incompatible types + //[nllnoleak]~^^^^ ERROR mismatched types }; } diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.baseleak.stderr index eacbbb87640..1c9ce115e96 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.baseleak.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/old-lub-glb-hr-noteq2.rs:21:14 + --> $DIR/old-lub-glb-hr-noteq2.rs:28:14 | LL | let z = match 22 { | _____________- @@ -7,6 +7,9 @@ LL | | 0 => y, | | - this is found to be of type `for<'a> fn(&'a u8, &'a u8) -> &'a u8` LL | | _ => x, | | ^ one type is more general than the other +LL | | +LL | | +LL | | LL | | }; | |_____- `match` arms have incompatible types | diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.basenoleak.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.basenoleak.stderr new file mode 100644 index 00000000000..1c9ce115e96 --- /dev/null +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.basenoleak.stderr @@ -0,0 +1,21 @@ +error[E0308]: `match` arms have incompatible types + --> $DIR/old-lub-glb-hr-noteq2.rs:28:14 + | +LL | let z = match 22 { + | _____________- +LL | | 0 => y, + | | - this is found to be of type `for<'a> fn(&'a u8, &'a u8) -> &'a u8` +LL | | _ => x, + | | ^ one type is more general than the other +LL | | +LL | | +LL | | +LL | | }; + | |_____- `match` arms have incompatible types + | + = note: expected fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` + found fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.nllleak.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.nllleak.stderr new file mode 100644 index 00000000000..1c9ce115e96 --- /dev/null +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.nllleak.stderr @@ -0,0 +1,21 @@ +error[E0308]: `match` arms have incompatible types + --> $DIR/old-lub-glb-hr-noteq2.rs:28:14 + | +LL | let z = match 22 { + | _____________- +LL | | 0 => y, + | | - this is found to be of type `for<'a> fn(&'a u8, &'a u8) -> &'a u8` +LL | | _ => x, + | | ^ one type is more general than the other +LL | | +LL | | +LL | | +LL | | }; + | |_____- `match` arms have incompatible types + | + = note: expected fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` + found fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs index 2aabc0dab1e..d49b85ce05e 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs @@ -2,15 +2,22 @@ // one is more general than the other. Test the case where the more general type // (`x`) is the second match arm specifically. // -// FIXME(#73154) Skip for compare-mode because the pure NLL checker accepts this -// test. (Note that it still errors in old-lub-glb-hr-noteq1.rs). What happens +// FIXME(#73154) Pure NLL checker without leak check accepts this test. +// (Note that it still errors in old-lub-glb-hr-noteq1.rs). What happens // is that, due to the ordering of the match arms, we pick the correct "more // general" fn type, and we ignore the errors from the non-NLL type checker that // requires equality. The NLL type checker only requires a subtyping -// relationship, and that holds. -// +// relationship, and that holds. To unblock landing NLL - and ensure that we can +// choose to make this always in error in the future - we perform the leak check +// after coercing a function pointer. + +// revisions: baseleak basenoleak nllleak nllnoleak // ignore-compare-mode-nll -// ignore-compare-mode-polonius +//[nllleak] compile-flags: -Zborrowck=mir +//[nllnoleak] compile-flags: -Zborrowck=mir -Zno-leak-check +//[basenoleak] compile-flags:-Zno-leak-check + +//[nllnoleak] check-pass fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) { // The two types above are not equivalent. With the older LUB/GLB @@ -18,7 +25,10 @@ fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8 // doesn't because we require equality. let z = match 22 { 0 => y, - _ => x, //~ ERROR `match` arms have incompatible types + _ => x, + //[baseleak]~^ ERROR `match` arms have incompatible types + //[nllleak]~^^ ERROR `match` arms have incompatible types + //[basenoleak]~^^^ ERROR `match` arms have incompatible types }; } diff --git a/src/test/ui/lub-glb/old-lub-glb-object.stderr b/src/test/ui/lub-glb/old-lub-glb-object.base.stderr index 6eabe5eaeee..da98483906f 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-object.base.stderr @@ -1,11 +1,13 @@ error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:7:13 + --> $DIR/old-lub-glb-object.rs:11:13 | LL | let z = match 22 { | _____________^ LL | | LL | | 0 => x, LL | | _ => y, +LL | | +LL | | LL | | }; | |_____^ one type is more general than the other | diff --git a/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr b/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr index 355f0754ab1..8f19133be44 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:10:14 + --> $DIR/old-lub-glb-object.rs:14:14 | LL | _ => y, | ^ one type is more general than the other @@ -8,7 +8,7 @@ LL | _ => y, found trait object `dyn for<'a> Foo<&'a u8, &'a u8>` error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:10:14 + --> $DIR/old-lub-glb-object.rs:14:14 | LL | _ => y, | ^ one type is more general than the other diff --git a/src/test/ui/lub-glb/old-lub-glb-object.rs b/src/test/ui/lub-glb/old-lub-glb-object.rs index 39d351c2355..b4dbb0caae6 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.rs +++ b/src/test/ui/lub-glb/old-lub-glb-object.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that we give a note when the old LUB/GLB algorithm would have // succeeded but the new code (which is stricter) gives an error. @@ -5,9 +9,11 @@ trait Foo<T, U> {} fn foo(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) { let z = match 22 { - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types 0 => x, _ => y, + //[nll]~^ ERROR mismatched types + //[nll]~| ERROR mismatched types }; } diff --git a/src/test/ui/macros/format-args-temporaries.rs b/src/test/ui/macros/format-args-temporaries.rs new file mode 100644 index 00000000000..ddd4c9754bf --- /dev/null +++ b/src/test/ui/macros/format-args-temporaries.rs @@ -0,0 +1,70 @@ +// check-pass + +use std::fmt::{self, Display}; + +struct Mutex; + +impl Mutex { + fn lock(&self) -> MutexGuard { + MutexGuard(self) + } +} + +struct MutexGuard<'a>(&'a Mutex); + +impl<'a> Drop for MutexGuard<'a> { + fn drop(&mut self) { + // Empty but this is a necessary part of the repro. Otherwise borrow + // checker is fine with 'a dangling at the time that MutexGuard goes out + // of scope. + } +} + +impl<'a> MutexGuard<'a> { + fn write_fmt(&self, _args: fmt::Arguments) {} +} + +impl<'a> Display for MutexGuard<'a> { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} + +fn main() { + let _write = { + let out = Mutex; + let mutex = Mutex; + write!(out.lock(), "{}", mutex.lock()) /* no semicolon */ + }; + + let _writeln = { + let out = Mutex; + let mutex = Mutex; + writeln!(out.lock(), "{}", mutex.lock()) /* no semicolon */ + }; + + let _print = { + let mutex = Mutex; + print!("{}", mutex.lock()) /* no semicolon */ + }; + + let _println = { + let mutex = Mutex; + println!("{}", mutex.lock()) /* no semicolon */ + }; + + let _eprint = { + let mutex = Mutex; + eprint!("{}", mutex.lock()) /* no semicolon */ + }; + + let _eprintln = { + let mutex = Mutex; + eprintln!("{}", mutex.lock()) /* no semicolon */ + }; + + let _panic = { + let mutex = Mutex; + panic!("{}", mutex.lock()) /* no semicolon */ + }; +} diff --git a/src/test/ui/issues/issue-33185.rs b/src/test/ui/macros/issue-33185.rs index 0d6669146a6..0d6669146a6 100644 --- a/src/test/ui/issues/issue-33185.rs +++ b/src/test/ui/macros/issue-33185.rs diff --git a/src/test/ui/macros/stringify.rs b/src/test/ui/macros/stringify.rs index 57e5ab42f79..f246aa26a9d 100644 --- a/src/test/ui/macros/stringify.rs +++ b/src/test/ui/macros/stringify.rs @@ -861,10 +861,8 @@ fn test_vis() { // VisibilityKind::Public assert_eq!(stringify_vis!(pub), "pub "); - // VisibilityKind::Crate - assert_eq!(stringify_vis!(crate), "crate "); - // VisibilityKind::Restricted + assert_eq!(stringify_vis!(pub(crate)), "pub(crate) "); assert_eq!(stringify_vis!(pub(self)), "pub(self) "); assert_eq!(stringify_vis!(pub(super)), "pub(super) "); assert_eq!(stringify_vis!(pub(in self)), "pub(self) "); diff --git a/src/test/ui/issues/issue-27021.rs b/src/test/ui/match/issue-27021.rs index ef3b114a5fa..ef3b114a5fa 100644 --- a/src/test/ui/issues/issue-27021.rs +++ b/src/test/ui/match/issue-27021.rs diff --git a/src/test/ui/match/match-ref-mut-invariance.stderr b/src/test/ui/match/match-ref-mut-invariance.base.stderr index f9271cb3d06..060c8237974 100644 --- a/src/test/ui/match/match-ref-mut-invariance.stderr +++ b/src/test/ui/match/match-ref-mut-invariance.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/match-ref-mut-invariance.rs:10:37 + --> $DIR/match-ref-mut-invariance.rs:14:37 | LL | match self.0 { ref mut x => x } | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | match self.0 { ref mut x => x } = note: expected mutable reference `&'a mut &'a i32` found mutable reference `&'a mut &'b i32` note: the lifetime `'a` as defined here... - --> $DIR/match-ref-mut-invariance.rs:9:12 + --> $DIR/match-ref-mut-invariance.rs:13:12 | LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/match-ref-mut-invariance.rs:8:6 + --> $DIR/match-ref-mut-invariance.rs:12:6 | LL | impl<'b> S<'b> { | ^^ diff --git a/src/test/ui/match/match-ref-mut-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-invariance.nll.stderr index 3b7e53cd527..b98539d91b6 100644 --- a/src/test/ui/match/match-ref-mut-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-invariance.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/match-ref-mut-invariance.rs:10:9 + --> $DIR/match-ref-mut-invariance.rs:14:9 | LL | impl<'b> S<'b> { | -- lifetime `'b` defined here diff --git a/src/test/ui/match/match-ref-mut-invariance.rs b/src/test/ui/match/match-ref-mut-invariance.rs index 50b0ede09c2..f876a4e2498 100644 --- a/src/test/ui/match/match-ref-mut-invariance.rs +++ b/src/test/ui/match/match-ref-mut-invariance.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check that when making a ref mut binding with type `&mut T`, the // type `T` must match precisely the type `U` of the value being // matched, and in particular cannot be some supertype of `U`. Issue @@ -7,7 +11,9 @@ struct S<'b>(&'b i32); impl<'b> S<'b> { fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - match self.0 { ref mut x => x } //~ ERROR mismatched types + match self.0 { ref mut x => x } + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/match/match-ref-mut-let-invariance.stderr b/src/test/ui/match/match-ref-mut-let-invariance.base.stderr index c021a5a91f5..7b6dd5af539 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.stderr +++ b/src/test/ui/match/match-ref-mut-let-invariance.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/match-ref-mut-let-invariance.rs:11:9 + --> $DIR/match-ref-mut-let-invariance.rs:15:9 | LL | x | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | x = note: expected mutable reference `&'a mut &'a i32` found mutable reference `&'a mut &'b i32` note: the lifetime `'a` as defined here... - --> $DIR/match-ref-mut-let-invariance.rs:9:12 + --> $DIR/match-ref-mut-let-invariance.rs:13:12 | LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/match-ref-mut-let-invariance.rs:8:6 + --> $DIR/match-ref-mut-let-invariance.rs:12:6 | LL | impl<'b> S<'b> { | ^^ diff --git a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr index f4d1cea670b..4b8bdd157c2 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/match-ref-mut-let-invariance.rs:11:9 + --> $DIR/match-ref-mut-let-invariance.rs:15:9 | LL | impl<'b> S<'b> { | -- lifetime `'b` defined here diff --git a/src/test/ui/match/match-ref-mut-let-invariance.rs b/src/test/ui/match/match-ref-mut-let-invariance.rs index a62eb714a4d..0a8daed569f 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.rs +++ b/src/test/ui/match/match-ref-mut-let-invariance.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check that when making a ref mut binding with type `&mut T`, the // type `T` must match precisely the type `U` of the value being // matched, and in particular cannot be some supertype of `U`. Issue @@ -8,7 +12,9 @@ struct S<'b>(&'b i32); impl<'b> S<'b> { fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { let ref mut x = self.0; - x //~ ERROR mismatched types + x + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.base.stderr index f34ac35c757..dfc6ef567f0 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:3:14 + --> $DIR/closure-arg-type-mismatch.rs:7:14 | LL | a.iter().map(|_: (u32, u32)| 45); | ^^^ ------------------ found signature of `fn((u32, u32)) -> _` @@ -13,7 +13,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:4:14 + --> $DIR/closure-arg-type-mismatch.rs:8:14 | LL | a.iter().map(|_: &(u16, u16)| 45); | ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _` @@ -27,7 +27,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:5:14 + --> $DIR/closure-arg-type-mismatch.rs:9:14 | LL | a.iter().map(|_: (u16, u16)| 45); | ^^^ ------------------ found signature of `fn((u16, u16)) -> _` @@ -41,7 +41,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0308]: mismatched types - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ lifetime mismatch @@ -49,18 +49,18 @@ LL | baz(f); = note: expected type `for<'r> Fn<(*mut &'r u32,)>` found type `Fn<(*mut &'a u32,)>` note: the required lifetime does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/closure-arg-type-mismatch.rs:9:10 + --> $DIR/closure-arg-type-mismatch.rs:13:10 | LL | fn _test<'a>(f: fn(*mut &'a u32)) { | ^^ note: the lifetime requirement is introduced here - --> $DIR/closure-arg-type-mismatch.rs:8:11 + --> $DIR/closure-arg-type-mismatch.rs:12:11 | LL | fn baz<F: Fn(*mut &u32)>(_: F) {} | ^^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ implementation of `FnOnce` is not general enough @@ -69,7 +69,7 @@ LL | baz(f); = note: ...but it actually implements `FnOnce<(*mut &'a u32,)>` error[E0308]: mismatched types - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ lifetime mismatch @@ -77,18 +77,18 @@ LL | baz(f); = note: expected type `for<'r> Fn<(*mut &'r u32,)>` found type `Fn<(*mut &'a u32,)>` note: the lifetime `'a` as defined here doesn't meet the lifetime requirements - --> $DIR/closure-arg-type-mismatch.rs:9:10 + --> $DIR/closure-arg-type-mismatch.rs:13:10 | LL | fn _test<'a>(f: fn(*mut &'a u32)) { | ^^ note: the lifetime requirement is introduced here - --> $DIR/closure-arg-type-mismatch.rs:8:11 + --> $DIR/closure-arg-type-mismatch.rs:12:11 | LL | fn baz<F: Fn(*mut &u32)>(_: F) {} | ^^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr index 1f46229cb5a..314000e8848 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:3:14 + --> $DIR/closure-arg-type-mismatch.rs:7:14 | LL | a.iter().map(|_: (u32, u32)| 45); | ^^^ ------------------ found signature of `fn((u32, u32)) -> _` @@ -13,7 +13,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:4:14 + --> $DIR/closure-arg-type-mismatch.rs:8:14 | LL | a.iter().map(|_: &(u16, u16)| 45); | ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _` @@ -27,7 +27,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:5:14 + --> $DIR/closure-arg-type-mismatch.rs:9:14 | LL | a.iter().map(|_: (u16, u16)| 45); | ^^^ ------------------ found signature of `fn((u16, u16)) -> _` diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs b/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs index 2d485d14a8d..da8011cc92b 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn main() { let a = [(1u32, 2u32)]; a.iter().map(|_: (u32, u32)| 45); //~ ERROR type mismatch @@ -8,8 +12,8 @@ fn main() { fn baz<F: Fn(*mut &u32)>(_: F) {} fn _test<'a>(f: fn(*mut &'a u32)) { baz(f); - //~^ ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR implementation of `FnOnce` is not general enough + //[base]~| ERROR implementation of `FnOnce` is not general enough + //[base]~| ERROR mismatched types + //[base]~| ERROR mismatched types } diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.base.stderr index c41bece3c19..7c81ebdf490 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^ lifetime mismatch @@ -7,12 +7,12 @@ LL | baz(|_| ()); = note: expected type `for<'r> Fn<(&'r (),)>` found type `Fn<(&(),)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/closure-mismatch.rs:8:9 + --> $DIR/closure-mismatch.rs:12:9 | LL | baz(|_| ()); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/closure-mismatch.rs:5:11 + --> $DIR/closure-mismatch.rs:9:11 | LL | fn baz<T: Foo>(_: T) {} | ^^^ diff --git a/src/test/ui/mismatched_types/closure-mismatch.nll.stderr b/src/test/ui/mismatched_types/closure-mismatch.nll.stderr index bd36fab9288..9508fc8a9be 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.nll.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^^^^^^^^^ implementation of `FnOnce` is not general enough @@ -8,7 +8,7 @@ LL | baz(|_| ()); = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error[E0308]: mismatched types - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^^^^^^^^^ one type is more general than the other @@ -16,12 +16,12 @@ LL | baz(|_| ()); = note: expected type `for<'r> Fn<(&'r (),)>` found type `Fn<(&(),)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/closure-mismatch.rs:8:9 + --> $DIR/closure-mismatch.rs:12:9 | LL | baz(|_| ()); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/closure-mismatch.rs:5:11 + --> $DIR/closure-mismatch.rs:9:11 | LL | fn baz<T: Foo>(_: T) {} | ^^^ diff --git a/src/test/ui/mismatched_types/closure-mismatch.rs b/src/test/ui/mismatched_types/closure-mismatch.rs index d2b78b4b7db..5bf3aef9bb0 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.rs +++ b/src/test/ui/mismatched_types/closure-mismatch.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<T: Fn(&())> Foo for T {} @@ -5,5 +9,8 @@ impl<T: Fn(&())> Foo for T {} fn baz<T: Foo>(_: T) {} fn main() { - baz(|_| ()); //~ ERROR mismatched types + baz(|_| ()); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR implementation of `FnOnce` is not general enough + //[nll]~| ERROR mismatched types } diff --git a/src/test/ui/nll/continue-after-missing-main.stderr b/src/test/ui/nll/continue-after-missing-main.base.stderr index 29e7dc1e56c..9d1fa66813d 100644 --- a/src/test/ui/nll/continue-after-missing-main.stderr +++ b/src/test/ui/nll/continue-after-missing-main.base.stderr @@ -1,11 +1,11 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main` - --> $DIR/continue-after-missing-main.rs:30:2 + --> $DIR/continue-after-missing-main.rs:34:2 | LL | } | ^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs` error[E0623]: lifetime mismatch - --> $DIR/continue-after-missing-main.rs:28:56 + --> $DIR/continue-after-missing-main.rs:32:56 | LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>, | ------------------------------------------------------------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/nll/continue-after-missing-main.nll.stderr b/src/test/ui/nll/continue-after-missing-main.nll.stderr index ebebabe349b..2bad3be8b4e 100644 --- a/src/test/ui/nll/continue-after-missing-main.nll.stderr +++ b/src/test/ui/nll/continue-after-missing-main.nll.stderr @@ -1,5 +1,5 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main` - --> $DIR/continue-after-missing-main.rs:30:2 + --> $DIR/continue-after-missing-main.rs:34:2 | LL | } | ^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs` diff --git a/src/test/ui/nll/continue-after-missing-main.rs b/src/test/ui/nll/continue-after-missing-main.rs index 1019cacce64..ddead7dc233 100644 --- a/src/test/ui/nll/continue-after-missing-main.rs +++ b/src/test/ui/nll/continue-after-missing-main.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(dead_code)] struct Tableau<'a, MP> { @@ -26,5 +30,5 @@ fn create_and_solve_subproblems<'data_provider, 'original_data, MP>( tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>, ) { let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound(); - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch } //~ ERROR `main` function not found in crate diff --git a/src/test/ui/nll/issue-52213.stderr b/src/test/ui/nll/issue-52213.base.stderr index aef5e258a1b..fb758ca17a8 100644 --- a/src/test/ui/nll/issue-52213.stderr +++ b/src/test/ui/nll/issue-52213.base.stderr @@ -1,28 +1,28 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-52213.rs:2:11 + --> $DIR/issue-52213.rs:6:11 | LL | match (&t,) { | ^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-52213.rs:1:23 + --> $DIR/issue-52213.rs:5:23 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | ^^ note: ...so that the types are compatible - --> $DIR/issue-52213.rs:2:11 + --> $DIR/issue-52213.rs:6:11 | LL | match (&t,) { | ^^^^^ = note: expected `(&&(T,),)` found `(&&'a (T,),)` note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/issue-52213.rs:1:27 + --> $DIR/issue-52213.rs:5:27 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-52213.rs:3:20 + --> $DIR/issue-52213.rs:8:20 | LL | ((u,),) => u, | ^ diff --git a/src/test/ui/nll/issue-52213.nll.stderr b/src/test/ui/nll/issue-52213.nll.stderr index da31bcd5475..a7553de6910 100644 --- a/src/test/ui/nll/issue-52213.nll.stderr +++ b/src/test/ui/nll/issue-52213.nll.stderr @@ -1,11 +1,11 @@ error: lifetime may not live long enough - --> $DIR/issue-52213.rs:3:20 + --> $DIR/issue-52213.rs:8:20 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | match (&t,) { +... LL | ((u,),) => u, | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | diff --git a/src/test/ui/nll/issue-52213.rs b/src/test/ui/nll/issue-52213.rs index c4ce4946b2e..c5918b47f57 100644 --- a/src/test/ui/nll/issue-52213.rs +++ b/src/test/ui/nll/issue-52213.rs @@ -1,6 +1,12 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { - match (&t,) { //~ ERROR cannot infer an appropriate lifetime + match (&t,) { + //[base]~^ ERROR cannot infer an appropriate lifetime ((u,),) => u, + //[nll]~^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/nll/issue-52533-1.stderr b/src/test/ui/nll/issue-52533-1.base.stderr index 475c7d0b48b..ddcb01b8f46 100644 --- a/src/test/ui/nll/issue-52533-1.stderr +++ b/src/test/ui/nll/issue-52533-1.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-52533-1.rs:9:18 + --> $DIR/issue-52533-1.rs:13:18 | LL | gimme(|x, y| y) | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | gimme(|x, y| y) = note: expected reference `&Foo<'_, '_, u32>` found reference `&Foo<'_, '_, u32>` note: the anonymous lifetime #3 defined here... - --> $DIR/issue-52533-1.rs:9:11 + --> $DIR/issue-52533-1.rs:13:11 | LL | gimme(|x, y| y) | ^^^^^^^^ note: ...does not necessarily outlive the anonymous lifetime #2 defined here - --> $DIR/issue-52533-1.rs:9:11 + --> $DIR/issue-52533-1.rs:13:11 | LL | gimme(|x, y| y) | ^^^^^^^^ diff --git a/src/test/ui/nll/issue-52533-1.nll.stderr b/src/test/ui/nll/issue-52533-1.nll.stderr index 20f19b25967..5554339eb7c 100644 --- a/src/test/ui/nll/issue-52533-1.nll.stderr +++ b/src/test/ui/nll/issue-52533-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-52533-1.rs:9:18 + --> $DIR/issue-52533-1.rs:13:18 | LL | gimme(|x, y| y) | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` diff --git a/src/test/ui/nll/issue-52533-1.rs b/src/test/ui/nll/issue-52533-1.rs index c80f43237fc..3ee7dd556a5 100644 --- a/src/test/ui/nll/issue-52533-1.rs +++ b/src/test/ui/nll/issue-52533-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(warnings)] struct Foo<'a, 'b, T: 'a + 'b> { x: &'a T, y: &'b T } @@ -7,5 +11,6 @@ fn gimme(_: impl for<'a, 'b, 'c> FnOnce(&'a Foo<'a, 'b, u32>, fn main() { gimme(|x, y| y) - //~^ ERROR mismatched types [E0308] + //[base]~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/nll/lint-no-err.rs b/src/test/ui/nll/lint-no-err.rs index f5f7bf0a758..2d1d5cb26d3 100644 --- a/src/test/ui/nll/lint-no-err.rs +++ b/src/test/ui/nll/lint-no-err.rs @@ -4,11 +4,6 @@ // when buffering lints, which resulted in ICE later on, // see #94502. -// Errors with `nll` which is already tested in enough other tests, -// so we ignore it here. -// -// ignore-compare-mode-nll - struct Repro; impl Repro { fn get(&self) -> &i32 { diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.base.stderr index 88253bad194..c7710146ea4 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `<T as MyTrait<'a>>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 + --> $DIR/projection-where-clause-env-wrong-bound.rs:19:5 | LL | bar::<T::Output>() | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | bar::<T::Output>() = help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`... = note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/projection-where-clause-env-wrong-bound.rs:29:8 + --> $DIR/projection-where-clause-env-wrong-bound.rs:33:8 | LL | T: 'a, | ^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr index b4435fe06bc..d235dee6444 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 + --> $DIR/projection-where-clause-env-wrong-bound.rs:19:5 | LL | bar::<T::Output>() | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs index dce88b88c75..22edb22a536 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that we are able to establish that `<T as // MyTrait<'a>>::Output` outlives `'b` here. We need to prove however // that `<T as MyTrait<'a>>::Output` outlives `'a`, so we also have to diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.base.stderr index 9f7fc030aa9..c3e2301bd66 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `<T as MyTrait<'a>>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:18:5 | LL | bar::<<T as MyTrait<'a>>::Output>() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | bar::<<T as MyTrait<'a>>::Output>() = help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`... = note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:20:8 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:25:8 | LL | T: 'a, | ^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr index ddeaf3c1f9e..82fe2fad9f7 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:18:5 | LL | bar::<<T as MyTrait<'a>>::Output>() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs index 9e3590ca715..d89b065673b 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that if we need to prove that `<T as MyTrait<'a>>::Output: // 'a`, but we only know that `<T as MyTrait<'b>>::Output: 'a`, that // doesn't suffice. @@ -12,7 +16,8 @@ where <T as MyTrait<'b>>::Output: 'a, { bar::<<T as MyTrait<'a>>::Output>() - //~^ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough + //[base]~^ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough + //[nll]~^^ ERROR the associated type `<T as MyTrait<'_>>::Output` may not live long enough } fn bar<'a, T>() -> &'a () diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr index 5af4c5bdfae..c402d1fefad 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ @@ -28,28 +28,28 @@ LL | ss found `&dyn SomeTrait` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index 61e96f59fed..49bbadf7224 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs index dc42edfba2c..16b4df7bad5 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the old rules under lifetime elision // yield slightly different results than the new rules. @@ -69,8 +73,9 @@ fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { // which fails to type check. ss - //~^ ERROR cannot infer - //~| ERROR cannot infer + //[base]~^ ERROR cannot infer + //[base]~| ERROR cannot infer + //[nll]~^^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr index 1708700f77a..5a8cba175e9 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `ss` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | --------------- this data with an anonymous lifetime `'_`... @@ -8,7 +8,7 @@ LL | ss.r | ^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/object-lifetime-default-from-box-error.rs:14:37 + --> $DIR/object-lifetime-default-from-box-error.rs:18:37 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | ^^^^^^^^^^^^^ `'static` requirement introduced here @@ -21,7 +21,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> { | ++++ error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:12 + --> $DIR/object-lifetime-default-from-box-error.rs:38:12 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr index 43695a7511d..7907813f267 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | -- has type `&mut SomeStruct<'1>` @@ -13,13 +13,13 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> { | ++++ error[E0507]: cannot move out of `ss.r` which is behind a mutable reference - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | ss.r | ^^^^ move occurs because `ss.r` has type `Box<dyn SomeTrait>`, which does not implement the `Copy` trait error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:5 + --> $DIR/object-lifetime-default-from-box-error.rs:38:5 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index 4a2665d8e16..1cb9834913c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the defaults should lead to errors being // reported. @@ -15,7 +19,10 @@ fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { // `Box<SomeTrait>` defaults to a `'static` bound, so this return // is illegal. - ss.r //~ ERROR E0759 + ss.r + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot move out of } fn store(ss: &mut SomeStruct, b: Box<dyn SomeTrait>) { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr index e7fab9ecefc..7e88aa32357 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:12 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a Box<(dyn Test + 'static)>` found reference `&'a Box<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:14:6 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:18:6 | LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 7d6f9f39d13..a07cc0718f1 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:5 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:5 | LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs index bf9e0beb57c..8cdd64be193 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `Box` struct. @@ -12,7 +16,9 @@ struct SomeStruct<'a> { } fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr index 1649841c186..b97a7d22549 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:12 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a MyBox<(dyn Test + 'static)>` found reference `&'a MyBox<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:19:6 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:23:6 | LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index 2bc8e097859..63d51b5c28c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:5 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:5 | LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs index dc0b86903c9..2d9a148a389 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `MyBox` struct. @@ -17,7 +21,9 @@ struct MyBox<T:?Sized> { } fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr index 4c5fb452ebe..6a72fab307b 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, | ------------------------ this parameter and the return type are declared with different lifetimes... @@ -11,7 +11,7 @@ LL | a | ^ ...but data from `a` is returned here error[E0308]: mismatched types - --> $DIR/object-lifetime-default-mybox.rs:31:11 + --> $DIR/object-lifetime-default-mybox.rs:37:11 | LL | load0(ss) | ^^ lifetime mismatch @@ -19,7 +19,7 @@ LL | load0(ss) = note: expected reference `&MyBox<(dyn SomeTrait + 'static)>` found reference `&MyBox<(dyn SomeTrait + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-mybox.rs:30:10 + --> $DIR/object-lifetime-default-mybox.rs:36:10 | LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index af20c5e5fc0..aa454cb9931 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | a = help: consider adding the following bound: `'a: 'b` error[E0521]: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-mybox.rs:31:5 + --> $DIR/object-lifetime-default-mybox.rs:37:5 | LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | -- -- `ss` is a reference that is only valid in the function body diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs index eb27fe90f47..874556dafeb 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test a "pass-through" object-lifetime-default that produces errors. #![allow(dead_code)] @@ -24,11 +28,15 @@ fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, b: &'b MyBox<dyn SomeTrait>) -> &'b MyBox<dyn SomeTrait> { - a //~ ERROR lifetime mismatch + a + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { - load0(ss) //~ ERROR mismatched types + load0(ss) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes outside of function } fn main() { diff --git a/src/test/ui/issues/issue-27320.rs b/src/test/ui/pattern/issue-27320.rs index d1aa56b915b..d1aa56b915b 100644 --- a/src/test/ui/issues/issue-27320.rs +++ b/src/test/ui/pattern/issue-27320.rs diff --git a/src/test/ui/issues/issue-13304.rs b/src/test/ui/process/issue-13304.rs index b10f6d57255..b10f6d57255 100644 --- a/src/test/ui/issues/issue-13304.rs +++ b/src/test/ui/process/issue-13304.rs diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr index 2ba4f4f5d9f..b8b9de627af 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr @@ -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:20:7 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:19:7 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -17,13 +17,13 @@ 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:28:43 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:26:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + found fn item `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` error: aborting due to 3 previous errors 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 c6430974334..8a4b3132646 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,50 +1,12 @@ -error: lifetime may not live long enough - --> $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 - | | - | 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-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 - | | - | lifetime `'a` defined here -... -LL | a(x, y); - | ^^^^^^^ 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 <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance - -error[E0308]: mismatched types - --> $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 - | - = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - 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:28:12 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:26:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + found fn item `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` -error: aborting due to 4 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. 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 ec91d179808..61ae1cc3fad 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 @@ -11,7 +11,6 @@ fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. *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) { @@ -19,7 +18,6 @@ fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // related as required. a(x, y); //[base]~^ ERROR lifetime mismatch [E0623] - //[nll]~^^ ERROR lifetime may not live long enough } fn d() { @@ -27,7 +25,6 @@ fn d() { // inconstraints: 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.base.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr index 537a1fb98a5..062411e6f68 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr @@ -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:16:10 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:15: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:22:7 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:21: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,13 +28,13 @@ 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:30:56 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:28:56 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` + found fn item `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` error: aborting due to 4 previous errors 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 053078f58df..f304c69d44b 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,59 +1,12 @@ -error: lifetime may not live long enough - --> $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 - | | - | 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:22: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 <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance - -error[E0308]: mismatched types - --> $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 - | - = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - 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:30:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - 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:30:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:28:56 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` + found fn item `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` -error: aborting due to 5 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. 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 8b5c1d47ec6..da225d842d9 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 @@ -12,7 +12,6 @@ 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; //[base]~^ ERROR E0623 - //[nll]~^^ ERROR lifetime may not live long enough *z = *y; //[base]~ ERROR E0623 } @@ -21,7 +20,6 @@ fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // related as required. a(x, y, z); //[base]~^ ERROR lifetime mismatch [E0623] - //[nll]~^^ ERROR lifetime may not live long enough } fn d() { @@ -29,8 +27,6 @@ fn d() { // inconstraints: 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/regions-fn-subtyping-return-static-fail.base.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr index 2182d8f661f..4616035870a 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr @@ -2,10 +2,17 @@ error[E0308]: mismatched types --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:12 | LL | want_G(baz); - | ^^^ one type is more general than the other + | ------ ^^^ one type is more general than the other + | | + | arguments to this function are incorrect | = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` - found fn pointer `for<'r> fn(&'r S) -> &'r S` + found fn item `for<'r> fn(&'r S) -> &'r S {baz}` +note: function defined here + --> $DIR/regions-fn-subtyping-return-static-fail.rs:24:4 + | +LL | fn want_G(f: G) {} + | ^^^^^^ ---- error: aborting due to previous error 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 0bca2cfbefd..4616035870a 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,11 +1,18 @@ error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:5 + --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:12 | LL | want_G(baz); - | ^^^^^^^^^^^ one type is more general than the other + | ------ ^^^ one type is more general than the other + | | + | arguments to this function are incorrect | = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` - found fn pointer `for<'r> fn(&'r S) -> &'r S` + found fn item `for<'r> fn(&'r S) -> &'r S {baz}` +note: function defined here + --> $DIR/regions-fn-subtyping-return-static-fail.rs:24:4 + | +LL | fn want_G(f: G) {} + | ^^^^^^ ---- error: aborting due to previous error diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr index e57b06aac39..613e9af90a4 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr @@ -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:20:7 + --> $DIR/regions-lifetime-bounds-on-fns.rs:19:7 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | --------- --------- these two types are declared with different lifetimes... @@ -17,13 +17,13 @@ LL | a(x, y); | ^ ...but data from `y` flows into `x` here error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:28:43 + --> $DIR/regions-lifetime-bounds-on-fns.rs:26:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + found fn item `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` error: aborting due to 3 previous errors 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 7fe8b4bf57f..268a60968b7 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,50 +1,12 @@ -error: lifetime may not live long enough - --> $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 - | | - | 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/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 - | | - | lifetime `'a` defined here -... -LL | a(x, y); - | ^^^^^^^ 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 <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance - -error[E0308]: mismatched types - --> $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 - | - = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` - error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:28:12 + --> $DIR/regions-lifetime-bounds-on-fns.rs:26:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^ one type is more general than the other | = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + found fn item `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` -error: aborting due to 4 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. 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 97c08d8ab0e..ef5e5cb12ef 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs @@ -11,7 +11,6 @@ fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. *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) { @@ -19,7 +18,6 @@ fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // related as required. a(x, y); //[base]~^ ERROR lifetime mismatch [E0623] - //[nll]~^^ ERROR lifetime may not live long enough } fn d() { @@ -27,7 +25,6 @@ fn d() { // inconstraints: let _: fn(&mut &isize, &mut &isize) = a; //~^ ERROR mismatched types [E0308] - //[nll]~^^ ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs new file mode 100644 index 00000000000..ecd3f588119 --- /dev/null +++ b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs @@ -0,0 +1,46 @@ +struct A { + config: String, +} + +impl A { + fn new(cofig: String) -> Self { + Self { config } //~ Error cannot find value `config` in this scope + } + + fn do_something(cofig: String) { + println!("{config}"); //~ Error cannot find value `config` in this scope + } + + fn self_is_available(self, cofig: String) { + println!("{config}"); //~ Error cannot find value `config` in this scope + } +} + +trait B { + const BAR: u32 = 3; + type Baz; + fn bar(&self); + fn baz(&self) {} + fn bah() {} +} + +impl B for Box<isize> { + type Baz = String; + fn bar(&self) { + // let baz = 3; + baz(); + //~^ ERROR cannot find function `baz` + bah; + //~^ ERROR cannot find value `bah` + BAR; + //~^ ERROR cannot find value `BAR` in this scope + let foo: Baz = "".to_string(); + //~^ ERROR cannot find type `Baz` in this scope + } +} + +fn ba() {} +const BARR: u32 = 3; +type Bar = String; + +fn main() {} diff --git a/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr new file mode 100644 index 00000000000..0b0a37f246c --- /dev/null +++ b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr @@ -0,0 +1,109 @@ +error[E0425]: cannot find value `config` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16 + | +LL | Self { config } + | ^^^^^^ + | | + | a field by this name exists in `Self` + | help: a local variable with a similar name exists: `cofig` + +error[E0425]: cannot find value `config` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20 + | +LL | println!("{config}"); + | ^^^^^^ + | | + | a field by this name exists in `Self` + | help: a local variable with a similar name exists: `cofig` + +error[E0425]: cannot find value `config` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20 + | +LL | println!("{config}"); + | ^^^^^^ + | +help: you might have meant to use the available field + | +LL | println!("{self.config}"); + | ~~~~~~~~~~~ +help: a local variable with a similar name exists + | +LL | println!("{cofig}"); + | ~~~~~ + +error[E0425]: cannot find function `baz` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9 + | +LL | baz(); + | ^^^ +... +LL | fn ba() {} + | ------- similarly named function `ba` defined here + | +help: you might have meant to call the method + | +LL | self.baz(); + | ~~~~~~~~ +help: a function with a similar name exists + | +LL | ba(); + | ~~ + +error[E0425]: cannot find value `bah` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9 + | +LL | bah; + | ^^^ +... +LL | fn ba() {} + | ------- similarly named function `ba` defined here + | +help: you might have meant to call the associated function + | +LL | Self::bah; + | ~~~~~~~~~ +help: a function with a similar name exists + | +LL | ba; + | ~~ + +error[E0425]: cannot find value `BAR` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:35:9 + | +LL | BAR; + | ^^^ +... +LL | const BARR: u32 = 3; + | -------------------- similarly named constant `BARR` defined here + | +help: you might have meant to use the associated `const` + | +LL | Self::BAR; + | ~~~~~~~~~ +help: a constant with a similar name exists + | +LL | BARR; + | ~~~~ + +error[E0412]: cannot find type `Baz` in this scope + --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:37:18 + | +LL | let foo: Baz = "".to_string(); + | ^^^ +... +LL | type Bar = String; + | ------------------ similarly named type alias `Bar` defined here + | +help: you might have meant to use the associated type + | +LL | let foo: Self::Baz = "".to_string(); + | ~~~~~~~~~ +help: a type alias with a similar name exists + | +LL | let foo: Bar = "".to_string(); + | ~~~ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0412, E0425. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/issues/issue-26459.rs b/src/test/ui/save-analysis/issue-26459.rs index 2ba05a0a47e..2ba05a0a47e 100644 --- a/src/test/ui/issues/issue-26459.rs +++ b/src/test/ui/save-analysis/issue-26459.rs diff --git a/src/test/ui/issues/issue-26459.stderr b/src/test/ui/save-analysis/issue-26459.stderr index 9f594990c6d..9f594990c6d 100644 --- a/src/test/ui/issues/issue-26459.stderr +++ b/src/test/ui/save-analysis/issue-26459.stderr diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr index b125eacfb6c..12c7c8f9b7e 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr @@ -1,23 +1,23 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:70:13 | LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () { | -------------------------------------- this data with lifetime `'a`... @@ -25,7 +25,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:64:30 | LL | impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> { | ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr index 2dc300ac76f..db790049c6f 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr @@ -1,17 +1,17 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs index 0045d3fcf1c..ec90a0987f0 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // FIXME: the following cases need to suggest more things to make users reach a working end state. mod bav { @@ -63,7 +67,7 @@ mod bay { impl Bar for i32 {} fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () { - val.use_self() //~ ERROR E0772 + val.use_self() //[base]~ ERROR E0772 } } diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs new file mode 100644 index 00000000000..37be629e77c --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs @@ -0,0 +1,118 @@ +// FIXME(nll): On NLL stabilization, this should replace +// `impl-on-dyn-trait-with-implicit-static-bound.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +#![allow(dead_code)] + +mod foo { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait<T> {} + trait MyTrait<T> { + fn use_self<K>(&self) -> &(); + } + trait Irrelevant {} + + impl<T> MyTrait<T> for dyn ObjectTrait<T> { + fn use_self<K>(&self) -> &() { panic!() } + } + impl<T> Irrelevant for dyn ObjectTrait<T> {} + + fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a { + val.use_self::<T>() //~ ERROR borrowed data escapes + } +} + +mod bar { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + val.use_self() + } +} + +mod baz { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for Box<dyn ObjectTrait> { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for Box<dyn ObjectTrait> {} + + fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () { + val.use_self() + } +} + +mod bat { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + + impl dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() + //~^ ERROR borrowed data escapes + } +} + +mod ban { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + val.use_self() //~ ERROR borrowed data escapes + } +} + +mod bal { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + MyTrait::use_self(val) //~ ERROR borrowed data escapes + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr index a1ef32c5445..38731ea8955 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:25:9 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -12,7 +12,7 @@ LL | val.use_self::<T>() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:74:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -25,7 +25,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:94:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | -- --- `val` is a reference that is only valid in the function body @@ -38,7 +38,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:114:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed index 3c10f85d942..74da1cbfea5 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs index 88ab03dfc1e..e0058b181b4 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index ed094c1365c..fbe7ac94a0a 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -1,5 +1,5 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:25:13 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a { | ---------------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | val.use_self::<T>() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:19:32 | LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> { | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -19,7 +19,7 @@ LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:74:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -27,7 +27,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:14 | LL | impl dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -39,7 +39,7 @@ LL | impl dyn ObjectTrait + '_ { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:93:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | ------------------- this data with lifetime `'a`... @@ -47,7 +47,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -64,7 +64,7 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:27 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -72,12 +72,12 @@ LL | MyTrait::use_self(val) | ^^^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:9 | LL | MyTrait::use_self(val) | ^^^^^^^^^^^^^^^^^ note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:109:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -90,7 +90,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ {} | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:42:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { | ------------------- this data with lifetime `'a`... @@ -98,7 +98,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:36:26 | LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -110,7 +110,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:59:13 | LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () { | ----------------------------- this data with lifetime `'a`... @@ -118,7 +118,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:53:30 | LL | impl MyTrait for Box<dyn ObjectTrait> { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr index 5d195e5ff32..4e0e6675e5a 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr @@ -1,21 +1,21 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func<T: Test>(foo: &Foo, t: T) { | ^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds... - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:24:13: 27:6]` will meet its required lifetime bounds... + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ note: ...that is required by this bound - --> $DIR/missing-lifetimes-in-signature-2.rs:11:12 + --> $DIR/missing-lifetimes-in-signature-2.rs:15:12 | LL | F: 'a, | ^^ diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr index 0212c2d712c..9f35175c08d 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | @@ -8,12 +8,12 @@ LL | | }); | |______^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func<T: Test>(foo: &Foo, t: T) { | ^^^ note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs index c6802ac6cc7..3e3b4403304 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #81650 struct Foo<'a> { diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr index ae9a020a099..d51d12b909d 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | help: consider introducing lifetime `'a` here: `'a,` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,18 +24,18 @@ LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:26:37 + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:31:5: 33:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:26:37 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:35:5: 38:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -48,18 +48,18 @@ LL ~ G: Get<T> + 'a, | error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:48:45 + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:53:5: 55:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:48:45 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:58:5: 61:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -69,18 +69,18 @@ LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + ' | +++ ++++ ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:60:58 + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:62:9: 64:10]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:60:58 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:68:9: 71:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOn | +++ ++++ ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:69:45 + --> $DIR/missing-lifetimes-in-signature.rs:76:45 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required @@ -98,10 +98,10 @@ LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:80:44 + --> $DIR/missing-lifetimes-in-signature.rs:89:44 | LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:85:5: 87:6]` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:94:5: 97:6]` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr index 24eac64d334..63932cb6ba0 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | help: consider introducing lifetime `'a` here: `'a,` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,22 +24,24 @@ LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -49,22 +51,24 @@ LL | G: Get<T> + 'a, | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -74,22 +78,24 @@ LL | fn qux<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ @@ -99,22 +105,26 @@ LL | fn qux<'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:69:34 + --> $DIR/missing-lifetimes-in-signature.rs:76:34 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -124,20 +134,23 @@ LL | fn bat<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ... LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ lifetime `'a` required error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:85:5 + --> $DIR/missing-lifetimes-in-signature.rs:94:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ ...so that the type `G` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index 0a3e6b48163..20366201269 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait Get<T> { fn get(self) -> T; } @@ -24,11 +28,12 @@ where // After applying suggestion for `foo`: fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get<T>, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -46,11 +51,12 @@ where // After applying suggestion for `baz`: fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get<T>, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -58,8 +64,9 @@ where // Same as above, but show that we pay attention to lifetime names from parent item impl<'a> Foo { fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - //~^ ERROR the parameter type `G` may not live long enough + //[base]~^ ERROR the parameter type `G` may not live long enough move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -67,22 +74,25 @@ impl<'a> Foo { // After applying suggestion for `qux`: fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a -//~^ ERROR explicit lifetime required in the type of `dest` +//[base]~^ ERROR explicit lifetime required in the type of `dest` where G: Get<T>, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough + //[nll]~| ERROR explicit lifetime required *dest = g.get(); } } // Potential incorrect attempt: fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get<T>, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr index a5b50634c71..0bd7f289340 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:30:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:35:31 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { | ----- this data with an anonymous lifetime `'_`... @@ -10,7 +10,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:27:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:31:23 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> { | ++++ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:41:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:48:31 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { | ----- this data with an anonymous lifetime `'_`... @@ -35,7 +35,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:38:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:44:23 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:52:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:61:31 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { | -------- this data with lifetime `'a`... @@ -56,7 +56,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:49:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:57:30 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + 'a { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:63:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:74:31 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { | -------- this data with lifetime `'a`... @@ -77,7 +77,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:60:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:70:30 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr index 6c65e4f0175..989f18e7182 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr @@ -1,11 +1,13 @@ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:28:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:32:9 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -19,13 +21,15 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:39:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:45:9 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -35,13 +39,15 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:50:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:58:9 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | @@ -51,13 +57,15 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + 'a { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:61:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:71:9 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs index d8446e58dbb..5d868a58c0f 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<'a, T: Foo> Foo for &'a T {} impl<T: Foo + ?Sized> Foo for Box<T> {} @@ -26,8 +30,10 @@ struct Bar(Vec<Box<dyn Foo>>); impl Bar { fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -37,8 +43,10 @@ struct Baz(Vec<Box<dyn Foo>>); impl Baz { fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -48,8 +56,10 @@ struct Bat(Vec<Box<dyn Foo>>); impl Bat { fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -59,8 +69,10 @@ struct Ban(Vec<Box<dyn Foo>>); impl Ban { fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed new file mode 100644 index 00000000000..c363cc2d0e1 --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug + 'static) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs new file mode 100644 index 00000000000..dd275f6630b --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr index cf912f4aac2..41226fdf9fe 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime-nll.rs:13:5 | LL | bar(d); | ^^^^^^ ...so that the type `impl Debug` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed index 65aab97d3d7..75ff26c0435 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs index fb1848d130f..b93fe103a4a 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr index 4a99c3a14d7..85f36ea78aa 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr @@ -1,11 +1,11 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime.rs:12:5 | LL | bar(d); | ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/suggest-impl-trait-lifetime.rs:12:24 + --> $DIR/suggest-impl-trait-lifetime.rs:17:24 | LL | fn bar(d: impl Debug + 'static) { | ^^^^^^^ diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.rs b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs new file mode 100644 index 00000000000..cf2218fe522 --- /dev/null +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs @@ -0,0 +1,30 @@ +// build-fail +// error-pattern: overflow evaluating the requirement `(): Sized` +// error-pattern: function cannot return without recursing + +// Regression test for #91949. +// This hanged *forever* on 1.56, fixed by #90423. + +#![recursion_limit = "256"] + +struct Wrapped<T>(T); + +struct IteratorOfWrapped<T, I: Iterator<Item = T>>(I); + +impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> { + type Item = Wrapped<T>; + fn next(&mut self) -> Option<Wrapped<T>> { + self.0.next().map(Wrapped) + } +} + +fn recurse<T>(elements: T) -> Vec<char> +where + T: Iterator<Item = ()>, +{ + recurse(IteratorOfWrapped(elements).map(|t| t.0)) +} + +fn main() { + recurse(std::iter::empty()); +} diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr new file mode 100644 index 00000000000..6c04616344f --- /dev/null +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -0,0 +1,25 @@ +warning: function cannot return without recursing + --> $DIR/issue-91949-hangs-on-recursion.rs:21:1 + | +LL | / fn recurse<T>(elements: T) -> Vec<char> +LL | | where +LL | | T: Iterator<Item = ()>, +LL | | { +LL | | recurse(IteratorOfWrapped(elements).map(|t| t.0)) + | | ------------------------------------------------- recursive call site +LL | | } + | |_^ cannot return without recursing + | + = note: `#[warn(unconditional_recursion)]` on by default + = help: a `loop` may express intention better if this is on purpose + +error[E0275]: overflow evaluating the requirement `(): Sized` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) + = note: required because of the requirements on the impl of `Iterator` for `std::iter::Empty<()>` + = note: 171 redundant requirements hidden + = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.stderr b/src/test/ui/traits/object/supertrait-lifetime-bound.base.stderr index c3d7f8cd0c1..8d1ef324c81 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.stderr +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime - --> $DIR/supertrait-lifetime-bound.rs:10:5 + --> $DIR/supertrait-lifetime-bound.rs:14:5 | LL | test1::<dyn Bar<&'a u32>, _>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/supertrait-lifetime-bound.rs:5:22 + --> $DIR/supertrait-lifetime-bound.rs:9:22 | LL | fn test1<T: ?Sized + Bar<S>, S>() { } | ^^^^^^ diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr b/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr index ed2f8624357..271c6a10998 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/supertrait-lifetime-bound.rs:10:5 + --> $DIR/supertrait-lifetime-bound.rs:14:5 | LL | fn test2<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.rs b/src/test/ui/traits/object/supertrait-lifetime-bound.rs index 5349771693a..a57151853e0 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.rs +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + trait Foo: 'static { } trait Bar<T>: Foo { } @@ -8,7 +12,8 @@ fn test2<'a>() { // Here: the type `dyn Bar<&'a u32>` references `'a`, // and so it does not outlive `'static`. test1::<dyn Bar<&'a u32>, _>(); - //~^ ERROR the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime + //[base]~^ ERROR the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr index 641e5c97c10..e1831c5617f 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-checking-test-3.rs:13:13 + --> $DIR/type-checking-test-3.rs:16:13 | LL | let _ = x as &dyn Bar<'a>; // Error | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | let _ = x as &dyn Bar<'a>; // Error = note: expected trait object `dyn Bar<'a>` found trait object `dyn Bar<'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-3.rs:12:16 + --> $DIR/type-checking-test-3.rs:15:16 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/type-checking-test-3.rs:18:13 + --> $DIR/type-checking-test-3.rs:22:13 | LL | let _ = x as &dyn Bar<'static>; // Error | ^ lifetime mismatch @@ -22,7 +22,7 @@ LL | let _ = x as &dyn Bar<'static>; // Error = note: expected trait object `dyn Bar<'static>` found trait object `dyn Bar<'a>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-3.rs:17:16 + --> $DIR/type-checking-test-3.rs:21:16 | LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { | ^^ diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr new file mode 100644 index 00000000000..983027d9b16 --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr @@ -0,0 +1,18 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:16:13 + | +LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'a>; // Error + | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:22:13 + | +LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'static>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs index 49c24e404dc..89e8821d34e 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs @@ -1,4 +1,7 @@ +// revisions: base nll // ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(trait_upcasting)] #![allow(incomplete_features)] @@ -11,12 +14,14 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'a>) { let _ = x as &dyn Bar<'static>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr index d4bb9350b0b..c343698f27f 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-checking-test-4.rs:17:13 + --> $DIR/type-checking-test-4.rs:20:13 | LL | let _ = x as &dyn Bar<'static, 'a>; // Error | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | let _ = x as &dyn Bar<'static, 'a>; // Error = note: expected trait object `dyn Bar<'static, 'a>` found trait object `dyn Bar<'static, 'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-4.rs:16:16 + --> $DIR/type-checking-test-4.rs:19:16 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/type-checking-test-4.rs:22:13 + --> $DIR/type-checking-test-4.rs:26:13 | LL | let _ = x as &dyn Bar<'a, 'static>; // Error | ^ lifetime mismatch @@ -22,14 +22,14 @@ LL | let _ = x as &dyn Bar<'a, 'static>; // Error = note: expected trait object `dyn Bar<'a, 'static>` found trait object `dyn Bar<'static, 'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-4.rs:21:16 + --> $DIR/type-checking-test-4.rs:25:16 | LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:27:27 + --> $DIR/type-checking-test-4.rs:32:27 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -42,12 +42,12 @@ LL | y.get_b() // ERROR | - ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/type-checking-test-4.rs:29:5 + --> $DIR/type-checking-test-4.rs:34:5 | LL | y.get_b() // ERROR | ^^^^^^^^^ note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:26:48 + --> $DIR/type-checking-test-4.rs:31:48 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -56,7 +56,7 @@ LL | y.get_b() // ERROR | --------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:33:5 + --> $DIR/type-checking-test-4.rs:39:5 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -64,7 +64,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:32:48 + --> $DIR/type-checking-test-4.rs:38:48 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -72,7 +72,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | -------------------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:38:15 + --> $DIR/type-checking-test-4.rs:45:15 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -80,7 +80,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ----------^^------------- ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:37:48 + --> $DIR/type-checking-test-4.rs:44:48 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -88,7 +88,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ---------------------------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:43:27 + --> $DIR/type-checking-test-4.rs:51:27 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -104,12 +104,12 @@ LL | z.get_b() // ERROR | - ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/type-checking-test-4.rs:47:5 + --> $DIR/type-checking-test-4.rs:55:5 | LL | z.get_b() // ERROR | ^^^^^^^^^ note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:42:48 + --> $DIR/type-checking-test-4.rs:50:48 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr new file mode 100644 index 00000000000..9b69bab56ae --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr @@ -0,0 +1,52 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:20:13 + | +LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'static, 'a>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:26:13 + | +LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'a, 'static>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:34:5 + | +LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +... +LL | y.get_b() // ERROR + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:39:5 + | +LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:45:5 + | +LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:55:5 + | +LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +... +LL | z.get_b() // ERROR + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs index 95698fd1e1a..575d60a5e56 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs @@ -1,4 +1,7 @@ +// revisions: base nll // ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(trait_upcasting)] #![allow(incomplete_features)] @@ -15,36 +18,42 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'static, 'a>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a, 'static>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { let y = x as &dyn Bar<'_, '_>; - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement y.get_b() // ERROR + //[nll]~^ ERROR lifetime may not live long enough } fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar>::get_b(x) // ERROR - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar<'_, '_>>::get_b(x) // ERROR - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { let y = x as &dyn Bar<'_, '_>; - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement y.get_b(); // ERROR let z = y; z.get_b() // ERROR + //[nll]~^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-1.rs b/src/test/ui/type-alias-impl-trait/issue-90400-1.rs new file mode 100644 index 00000000000..8550a3e8637 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-90400-1.rs @@ -0,0 +1,30 @@ +// Regression test for #90400, +// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836 + +#![feature(generic_associated_types)] +#![feature(type_alias_impl_trait)] + +trait Bar { + fn bar(&self); +} + +trait Foo { + type FooFn<B>: FnOnce(); + + fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>; +} + +struct MyFoo; + +impl Foo for MyFoo { + type FooFn<B> = impl FnOnce(); + + fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> { + move || bar.bar() //~ ERROR: the trait bound `B: Bar` is not satisfied + } +} + +fn main() { + let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() }; + boom(); +} diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr b/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr new file mode 100644 index 00000000000..428a1074031 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `B: Bar` is not satisfied + --> $DIR/issue-90400-1.rs:23:9 + | +LL | move || bar.bar() + | ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `B` + | +note: required by a bound in `<MyFoo as Foo>::foo` + --> $DIR/issue-90400-1.rs:22:15 + | +LL | fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> { + | ^^^ required by this bound in `<MyFoo as Foo>::foo` +help: consider restricting type parameter `B` + | +LL | type FooFn<B: Bar> = impl FnOnce(); + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-2.rs b/src/test/ui/type-alias-impl-trait/issue-90400-2.rs new file mode 100644 index 00000000000..2b369bb8a2b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-90400-2.rs @@ -0,0 +1,38 @@ +// Regression test for #90400, +// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836 + +#![feature(generic_associated_types)] +#![feature(type_alias_impl_trait)] + +trait Bar { + fn bar(&self); +} + +trait Baz { + fn baz(&self); +} + +trait Foo { + type FooFn<B>: Baz; + + fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>; +} + +struct MyFoo; +impl Foo for MyFoo { + type FooFn<B> = impl Baz; + + fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> { + MyBaz(bar) //~ ERROR: the trait bound `B: Bar` is not satisfied + } +} + +struct MyBaz<B: Bar>(B); +impl<B: Bar> Baz for MyBaz<B> { + fn baz(&self) {} +} + +fn main() { + let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() }; + boom.baz(); +} diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr b/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr new file mode 100644 index 00000000000..5da05a4390f --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `B: Bar` is not satisfied + --> $DIR/issue-90400-2.rs:26:9 + | +LL | MyBaz(bar) + | ^^^^^^^^^^ the trait `Bar` is not implemented for `B` + | +note: required because of the requirements on the impl of `Baz` for `MyBaz<B>` + --> $DIR/issue-90400-2.rs:31:14 + | +LL | impl<B: Bar> Baz for MyBaz<B> { + | ^^^ ^^^^^^^^ +help: consider restricting type parameter `B` + | +LL | type FooFn<B: Bar> = impl Baz; + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/auxiliary/issue-36708.rs b/src/test/ui/typeck/auxiliary/issue-36708.rs index bd8580f9782..bd8580f9782 100644 --- a/src/test/ui/issues/auxiliary/issue-36708.rs +++ b/src/test/ui/typeck/auxiliary/issue-36708.rs diff --git a/src/test/ui/issues/issue-36708.rs b/src/test/ui/typeck/issue-36708.rs index c9d9f2a6d50..c9d9f2a6d50 100644 --- a/src/test/ui/issues/issue-36708.rs +++ b/src/test/ui/typeck/issue-36708.rs diff --git a/src/test/ui/issues/issue-36708.stderr b/src/test/ui/typeck/issue-36708.stderr index 140f19f1ff7..140f19f1ff7 100644 --- a/src/test/ui/issues/issue-36708.stderr +++ b/src/test/ui/typeck/issue-36708.stderr diff --git a/src/test/ui/issues/issue-40231-1.rs b/src/test/ui/unsized/issue-40231-1.rs index 999399ec8d3..999399ec8d3 100644 --- a/src/test/ui/issues/issue-40231-1.rs +++ b/src/test/ui/unsized/issue-40231-1.rs diff --git a/src/test/ui/issues/issue-40231-2.rs b/src/test/ui/unsized/issue-40231-2.rs index 780433b28c5..780433b28c5 100644 --- a/src/test/ui/issues/issue-40231-2.rs +++ b/src/test/ui/unsized/issue-40231-2.rs diff --git a/src/tools/clippy/clippy_lints/src/explicit_write.rs b/src/tools/clippy/clippy_lints/src/explicit_write.rs index 3e2217c28da..d8f765b288a 100644 --- a/src/tools/clippy/clippy_lints/src/explicit_write.rs +++ b/src/tools/clippy/clippy_lints/src/explicit_write.rs @@ -4,7 +4,8 @@ use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_expn_of, match_function_call, paths}; use if_chain::if_chain; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::def::Res; +use rustc_hir::{BindingAnnotation, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; @@ -39,7 +40,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { if let ExprKind::MethodCall(unwrap_fun, [write_call], _) = expr.kind; if unwrap_fun.ident.name == sym::unwrap; // match call to write_fmt - if let ExprKind::MethodCall(write_fun, [write_recv, write_arg], _) = write_call.kind; + if let ExprKind::MethodCall(write_fun, [write_recv, write_arg], _) = look_in_block(cx, &write_call.kind); if write_fun.ident.name == sym!(write_fmt); // match calls to std::io::stdout() / std::io::stderr () if let Some(dest_name) = if match_function_call(cx, write_recv, &paths::STDOUT).is_some() { @@ -100,3 +101,34 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { } } } + +/// If `kind` is a block that looks like `{ let result = $expr; result }` then +/// returns $expr. Otherwise returns `kind`. +fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>) -> &'tcx ExprKind<'hir> { + if_chain! { + if let ExprKind::Block(block, _label @ None) = kind; + if let Block { + stmts: [Stmt { kind: StmtKind::Local(local), .. }], + expr: Some(expr_end_of_block), + rules: BlockCheckMode::DefaultBlock, + .. + } = block; + + // Find id of the local that expr_end_of_block resolves to + if let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind; + if let Res::Local(expr_res) = expr_path.res; + if let Some(Node::Binding(res_pat)) = cx.tcx.hir().find(expr_res); + + // Find id of the local we found in the block + if let PatKind::Binding(BindingAnnotation::Unannotated, local_hir_id, _ident, None) = local.pat.kind; + + // If those two are the same hir id + if res_pat.hir_id == local_hir_id; + + if let Some(init) = local.init; + then { + return &init.kind; + } + } + kind +} diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index b379f8c06c6..6487199172e 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -545,7 +545,7 @@ pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool { pub fn eq_vis(l: &Visibility, r: &Visibility) -> bool { use VisibilityKind::*; match (&l.kind, &r.kind) { - (Public, Public) | (Inherited, Inherited) | (Crate(_), Crate(_)) => true, + (Public, Public) | (Inherited, Inherited) => true, (Restricted { path: l, .. }, Restricted { path: r, .. }) => eq_path(l, r), _ => false, } diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index ad2502b0418..8816d7d2f1f 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -1361,7 +1361,7 @@ pub(crate) fn format_struct_struct( fn get_bytepos_after_visibility(vis: &ast::Visibility, default_span: Span) -> BytePos { match vis.kind { - ast::VisibilityKind::Crate(..) | ast::VisibilityKind::Restricted { .. } => vis.span.hi(), + ast::VisibilityKind::Restricted { .. } => vis.span.hi(), _ => default_span.lo(), } } diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index ed418fb1fec..58fd95c656e 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use rustc_ast::ast::{ - self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility, + self, Attribute, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility, VisibilityKind, }; use rustc_ast::ptr; @@ -44,15 +44,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool { VisibilityKind::Restricted { path: q, .. }, ) => pprust::path_to_string(p) == pprust::path_to_string(q), (VisibilityKind::Public, VisibilityKind::Public) - | (VisibilityKind::Inherited, VisibilityKind::Inherited) - | ( - VisibilityKind::Crate(CrateSugar::PubCrate), - VisibilityKind::Crate(CrateSugar::PubCrate), - ) - | ( - VisibilityKind::Crate(CrateSugar::JustCrate), - VisibilityKind::Crate(CrateSugar::JustCrate), - ) => true, + | (VisibilityKind::Inherited, VisibilityKind::Inherited) => true, _ => false, } } @@ -65,8 +57,6 @@ pub(crate) fn format_visibility( match vis.kind { VisibilityKind::Public => Cow::from("pub "), VisibilityKind::Inherited => Cow::from(""), - VisibilityKind::Crate(CrateSugar::PubCrate) => Cow::from("pub(crate) "), - VisibilityKind::Crate(CrateSugar::JustCrate) => Cow::from("crate "), VisibilityKind::Restricted { ref path, .. } => { let Path { ref segments, .. } = **path; let mut segments_iter = segments.iter().map(|seg| rewrite_ident(context, seg.ident)); @@ -75,7 +65,7 @@ pub(crate) fn format_visibility( .next() .expect("Non-global path in pub(restricted)?"); } - let is_keyword = |s: &str| s == "self" || s == "super"; + let is_keyword = |s: &str| s == "crate" || s == "self" || s == "super"; let path = segments_iter.collect::<Vec<_>>().join("::"); let in_str = if is_keyword(&path) { "" } else { "in " }; diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 5712e84adbc..cf72dc4bd09 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,8 +7,8 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 974; -const ISSUES_ENTRY_LIMIT: usize = 2248; +const ROOT_ENTRY_LIMIT: usize = 971; +const ISSUES_ENTRY_LIMIT: usize = 2234; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) |
