diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-05 22:41:07 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-23 19:33:06 +0000 |
| commit | fb7d25e97863e1a305bfeed6f418c5accc152123 (patch) | |
| tree | c16b4d87a42297c2a05095e12a75641c0e6e645d /compiler/rustc_borrowck/src/diagnostics | |
| parent | d121aa3b5584eb919a4aaf64dbae0ea1e8e30231 (diff) | |
| download | rust-fb7d25e97863e1a305bfeed6f418c5accc152123.tar.gz rust-fb7d25e97863e1a305bfeed6f418c5accc152123.zip | |
Separate lifetime ident from resolution in HIR.
Diffstat (limited to 'compiler/rustc_borrowck/src/diagnostics')
3 files changed, 7 insertions, 27 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 5f99d86b4ea..0790a2ede39 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2509,7 +2509,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].kind { // With access to the lifetime, we can get // the span of it. - arguments.push((*argument, lifetime.span)); + arguments.push((*argument, lifetime.ident.span)); } else { bug!("ty type is a ref but hir type is not"); } @@ -2528,7 +2528,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut return_span = fn_decl.output.span(); if let hir::FnRetTy::Return(ty) = &fn_decl.output { if let hir::TyKind::Rptr(lifetime, _) = ty.kind { - return_span = lifetime.span; + return_span = lifetime.ident.span; } } diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 7457369aa58..5d212b6c977 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1211,7 +1211,7 @@ fn get_mut_span_in_struct_field<'tcx>( && let hir::Node::Field(field) = node && let hir::TyKind::Rptr(lt, hir::MutTy { mutbl: hir::Mutability::Not, ty }) = field.ty.kind { - return Some(lt.span.between(ty.span)); + return Some(lt.ident.span.between(ty.span)); } None diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f9741bacd17..d8d31fae35e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -576,30 +576,10 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let args = last_segment.args.as_ref()?; let lifetime = self.try_match_adt_and_generic_args(substs, needle_fr, args, search_stack)?; - match lifetime.name { - hir::LifetimeName::Param(_, hir::ParamName::Plain(_) | hir::ParamName::Error) - | hir::LifetimeName::Error - | hir::LifetimeName::Static => { - let lifetime_span = lifetime.span; - Some(RegionNameHighlight::MatchedAdtAndSegment(lifetime_span)) - } - - hir::LifetimeName::Param(_, hir::ParamName::Fresh) - | hir::LifetimeName::ImplicitObjectLifetimeDefault - | hir::LifetimeName::Infer => { - // In this case, the user left off the lifetime; so - // they wrote something like: - // - // ``` - // x: Foo<T> - // ``` - // - // where the fully elaborated form is `Foo<'_, '1, - // T>`. We don't consider this a match; instead we let - // the "fully elaborated" type fallback above handle - // it. - None - } + if lifetime.is_anonymous() { + None + } else { + Some(RegionNameHighlight::MatchedAdtAndSegment(lifetime.ident.span)) } } |
