Do not treat lifetimes from parent items as influencing child items
This commit is contained in:
parent
2a06022951
commit
dabee5d563
2 changed files with 17 additions and 1 deletions
|
@ -1833,7 +1833,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
LifetimeRibKind::StaticIfNoLifetimeInScope { lint_id: node_id, emit_lint } => {
|
LifetimeRibKind::StaticIfNoLifetimeInScope { lint_id: node_id, emit_lint } => {
|
||||||
let mut lifetimes_in_scope = vec![];
|
let mut lifetimes_in_scope = vec![];
|
||||||
for rib in &self.lifetime_ribs[..i] {
|
for rib in self.lifetime_ribs[..i].iter().rev() {
|
||||||
lifetimes_in_scope.extend(rib.bindings.iter().map(|(ident, _)| ident.span));
|
lifetimes_in_scope.extend(rib.bindings.iter().map(|(ident, _)| ident.span));
|
||||||
// Consider any anonymous lifetimes, too
|
// Consider any anonymous lifetimes, too
|
||||||
if let LifetimeRibKind::AnonymousCreateParameter { binder, .. } = rib.kind
|
if let LifetimeRibKind::AnonymousCreateParameter { binder, .. } = rib.kind
|
||||||
|
@ -1841,6 +1841,9 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||||
{
|
{
|
||||||
lifetimes_in_scope.extend(extra.iter().map(|(ident, _, _)| ident.span));
|
lifetimes_in_scope.extend(extra.iter().map(|(ident, _, _)| ident.span));
|
||||||
}
|
}
|
||||||
|
if let LifetimeRibKind::Item = rib.kind {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if lifetimes_in_scope.is_empty() {
|
if lifetimes_in_scope.is_empty() {
|
||||||
self.record_lifetime_res(
|
self.record_lifetime_res(
|
||||||
|
|
|
@ -17,4 +17,17 @@ impl Bar<'static> for B {
|
||||||
const STATIC: &str = "";
|
const STATIC: &str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct C;
|
||||||
|
impl Bar<'_> for C {
|
||||||
|
// make ^^ not cause
|
||||||
|
const STATIC: &'static str = {
|
||||||
|
struct B;
|
||||||
|
impl Bar<'static> for B {
|
||||||
|
const STATIC: &str = "";
|
||||||
|
// ^ to emit a future incompat warning
|
||||||
|
}
|
||||||
|
""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue