remove get_named_span
This commit is contained in:
parent
59a768ce14
commit
05db660d39
6 changed files with 33 additions and 89 deletions
|
@ -13,13 +13,13 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::infer::InferCtxt;
|
||||
use rustc::mir::{Local, Body};
|
||||
use rustc::ty::subst::{SubstsRef, GenericArgKind};
|
||||
use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
|
||||
use rustc::ty::{self, RegionVid, Ty, TyCtxt};
|
||||
use rustc::ty::print::RegionHighlightMode;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use syntax::symbol::kw;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax_pos::{Span, symbol::Symbol};
|
||||
use syntax_pos::{Span, symbol::Symbol, DUMMY_SP};
|
||||
|
||||
/// A name for a particular region used in emitting diagnostics. This name could be a generated
|
||||
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
|
||||
|
@ -275,7 +275,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
match error_region {
|
||||
ty::ReEarlyBound(ebr) => {
|
||||
if ebr.has_name() {
|
||||
let span = self.get_named_span(tcx, error_region, ebr.name);
|
||||
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
|
||||
Some(RegionName {
|
||||
name: ebr.name,
|
||||
source: RegionNameSource::NamedEarlyBoundRegion(span),
|
||||
|
@ -291,9 +291,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
}),
|
||||
|
||||
ty::ReFree(free_region) => match free_region.bound_region {
|
||||
ty::BoundRegion::BrNamed(_, name) => {
|
||||
ty::BoundRegion::BrNamed(region_def_id, name) => {
|
||||
// Get the span to point to, even if we don't use the name.
|
||||
let span = self.get_named_span(tcx, error_region, name);
|
||||
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
|
||||
debug!("bound region named: {:?}, is_named: {:?}",
|
||||
name, free_region.bound_region.is_named());
|
||||
|
||||
|
@ -373,40 +373,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets a span of a named region to provide context for error messages that
|
||||
/// mention that span, for example:
|
||||
///
|
||||
/// ```
|
||||
/// |
|
||||
/// | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
|
||||
/// | -- -- lifetime `'b` defined here
|
||||
/// | |
|
||||
/// | lifetime `'a` defined here
|
||||
/// |
|
||||
/// | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must
|
||||
/// | outlive `'a`
|
||||
/// ```
|
||||
fn get_named_span(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
error_region: &RegionKind,
|
||||
name: Symbol,
|
||||
) -> Span {
|
||||
let scope = error_region.free_region_binding_scope(tcx);
|
||||
let node = tcx.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
|
||||
|
||||
let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
|
||||
if let Some(param) = tcx.hir()
|
||||
.get_generics(scope)
|
||||
.and_then(|generics| generics.get_named(name))
|
||||
{
|
||||
param.span
|
||||
} else {
|
||||
span
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds an argument that contains `fr` and label it with a fully
|
||||
/// elaborated type, returning something like `'1`. Result looks
|
||||
/// like:
|
||||
|
|
|
@ -10,18 +10,18 @@ error: lifetime may not live long enough
|
|||
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52
|
||||
|
|
||||
LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
|
||||
| - ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| - - ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
| | |
|
||||
| | let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:75
|
||||
|
|
||||
LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
|
||||
| - ^^^^^^^^^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| - - ^^^^^^^^^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
| | |
|
||||
| | let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
|
|
|
@ -10,9 +10,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:13:9
|
||||
|
|
||||
LL | async fn ref_self(&self, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -29,9 +28,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:19:9
|
||||
|
|
||||
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -48,9 +46,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:23:9
|
||||
|
|
||||
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -67,9 +64,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:27:9
|
||||
|
|
||||
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -86,9 +82,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:31:9
|
||||
|
|
||||
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -105,9 +100,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/lt-ref-self-async.rs:35:9
|
||||
|
|
||||
LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
|
|
@ -10,9 +10,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:13:9
|
||||
|
|
||||
LL | async fn ref_self(&mut self, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -29,9 +28,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:19:9
|
||||
|
|
||||
LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -48,9 +46,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:23:9
|
||||
|
|
||||
LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -67,9 +64,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:27:9
|
||||
|
|
||||
LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -86,9 +82,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:31:9
|
||||
|
|
||||
LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -105,9 +100,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-self-async.rs:35:9
|
||||
|
|
||||
LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
|
|
@ -10,9 +10,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-struct-async.rs:13:9
|
||||
|
|
||||
LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -29,9 +28,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-struct-async.rs:17:9
|
||||
|
|
||||
LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -48,9 +46,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-struct-async.rs:21:9
|
||||
|
|
||||
LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -67,9 +64,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-struct-async.rs:25:9
|
||||
|
|
||||
LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -86,9 +82,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-mut-struct-async.rs:29:9
|
||||
|
|
||||
LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
|
|
@ -10,9 +10,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-struct-async.rs:13:9
|
||||
|
|
||||
LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -29,9 +28,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-struct-async.rs:17:9
|
||||
|
|
||||
LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -48,9 +46,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-struct-async.rs:21:9
|
||||
|
|
||||
LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -67,9 +64,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-struct-async.rs:25:9
|
||||
|
|
||||
LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
@ -86,9 +82,8 @@ error: lifetime may not live long enough
|
|||
--> $DIR/ref-struct-async.rs:29:9
|
||||
|
|
||||
LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
|
||||
| -
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue