Always create elided lifetimes, even if inferred.
This commit is contained in:
parent
2643b16468
commit
ec3f3074a1
@ -1644,14 +1644,30 @@ fn resolve_elided_lifetimes_in_path(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let missing = match source {
|
let node_ids = self.r.next_node_ids(expected_lifetimes);
|
||||||
PathSource::Trait(..) | PathSource::TraitItem(..) | PathSource::Type => true,
|
self.record_lifetime_res(
|
||||||
|
segment_id,
|
||||||
|
LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end },
|
||||||
|
LifetimeElisionCandidate::Ignore,
|
||||||
|
);
|
||||||
|
|
||||||
|
let inferred = match source {
|
||||||
|
PathSource::Trait(..) | PathSource::TraitItem(..) | PathSource::Type => false,
|
||||||
PathSource::Expr(..)
|
PathSource::Expr(..)
|
||||||
| PathSource::Pat
|
| PathSource::Pat
|
||||||
| PathSource::Struct
|
| PathSource::Struct
|
||||||
| PathSource::TupleStruct(..) => false,
|
| PathSource::TupleStruct(..) => true,
|
||||||
};
|
};
|
||||||
if !missing && !segment.has_generic_args {
|
if inferred {
|
||||||
|
// Do not create a parameter for patterns and expressions: type checking can infer
|
||||||
|
// the appropriate lifetime for us.
|
||||||
|
for id in node_ids {
|
||||||
|
self.record_lifetime_res(
|
||||||
|
id,
|
||||||
|
LifetimeRes::Infer,
|
||||||
|
LifetimeElisionCandidate::Named,
|
||||||
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1666,25 +1682,6 @@ fn resolve_elided_lifetimes_in_path(
|
|||||||
};
|
};
|
||||||
let ident = Ident::new(kw::UnderscoreLifetime, elided_lifetime_span);
|
let ident = Ident::new(kw::UnderscoreLifetime, elided_lifetime_span);
|
||||||
|
|
||||||
let node_ids = self.r.next_node_ids(expected_lifetimes);
|
|
||||||
self.record_lifetime_res(
|
|
||||||
segment_id,
|
|
||||||
LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end },
|
|
||||||
LifetimeElisionCandidate::Ignore,
|
|
||||||
);
|
|
||||||
|
|
||||||
if !missing {
|
|
||||||
// Do not create a parameter for patterns and expressions.
|
|
||||||
for id in node_ids {
|
|
||||||
self.record_lifetime_res(
|
|
||||||
id,
|
|
||||||
LifetimeRes::Infer,
|
|
||||||
LifetimeElisionCandidate::Named,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let missing_lifetime = MissingLifetime {
|
let missing_lifetime = MissingLifetime {
|
||||||
id: node_ids.start,
|
id: node_ids.start,
|
||||||
span: elided_lifetime_span,
|
span: elided_lifetime_span,
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
// check-pass
|
||||||
|
|
||||||
|
struct Sqlite {}
|
||||||
|
|
||||||
|
trait HasArguments<'q> {
|
||||||
|
type Arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'q> HasArguments<'q> for Sqlite {
|
||||||
|
type Arguments = std::marker::PhantomData<&'q ()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
let _ = <Sqlite as HasArguments>::Arguments::default();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user