resolve: Continue search in outer scopes after applying derive resolution fallback
This commit is contained in:
parent
f28f648a96
commit
7e8825b4ec
@ -1900,12 +1900,13 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
}
|
||||
|
||||
ident.span = ident.span.modern();
|
||||
let mut poisoned = None;
|
||||
loop {
|
||||
let (opt_module, poisoned) = if let Some(node_id) = record_used_id {
|
||||
let opt_module = if let Some(node_id) = record_used_id {
|
||||
self.hygienic_lexical_parent_with_compatibility_fallback(module, &mut ident.span,
|
||||
node_id)
|
||||
node_id, &mut poisoned)
|
||||
} else {
|
||||
(self.hygienic_lexical_parent(module, &mut ident.span), None)
|
||||
self.hygienic_lexical_parent(module, &mut ident.span)
|
||||
};
|
||||
module = unwrap_or!(opt_module, break);
|
||||
let orig_current_module = self.current_module;
|
||||
@ -1933,7 +1934,6 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
}
|
||||
return Some(LexicalScopeBinding::Item(binding))
|
||||
}
|
||||
_ if poisoned.is_some() => break,
|
||||
Err(Determined) => continue,
|
||||
Err(Undetermined) =>
|
||||
span_bug!(ident.span, "undetermined resolution during main resolution pass"),
|
||||
@ -1993,12 +1993,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
None
|
||||
}
|
||||
|
||||
fn hygienic_lexical_parent_with_compatibility_fallback(
|
||||
&mut self, module: Module<'a>, span: &mut Span, node_id: NodeId
|
||||
) -> (Option<Module<'a>>, /* poisoned */ Option<NodeId>)
|
||||
{
|
||||
fn hygienic_lexical_parent_with_compatibility_fallback(&mut self, module: Module<'a>,
|
||||
span: &mut Span, node_id: NodeId,
|
||||
poisoned: &mut Option<NodeId>)
|
||||
-> Option<Module<'a>> {
|
||||
if let module @ Some(..) = self.hygienic_lexical_parent(module, span) {
|
||||
return (module, None);
|
||||
return module;
|
||||
}
|
||||
|
||||
// We need to support the next case under a deprecation warning
|
||||
@ -2019,13 +2019,14 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
// The macro is a proc macro derive
|
||||
if module.expansion.looks_like_proc_macro_derive() {
|
||||
if parent.expansion.is_descendant_of(span.ctxt().outer()) {
|
||||
return (module.parent, Some(node_id));
|
||||
*poisoned = Some(node_id);
|
||||
return module.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(None, None)
|
||||
None
|
||||
}
|
||||
|
||||
fn resolve_ident_in_module(&mut self,
|
||||
|
@ -31,6 +31,14 @@ struct S;
|
||||
//~| WARN this was previously accepted
|
||||
struct Z;
|
||||
|
||||
fn inner_block() {
|
||||
#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope
|
||||
//~| WARN cannot find type `OuterDerive` in this scope
|
||||
//~| WARN this was previously accepted
|
||||
//~| WARN this was previously accepted
|
||||
struct InnerZ;
|
||||
}
|
||||
|
||||
#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
|
||||
struct W;
|
||||
|
||||
|
@ -41,6 +41,24 @@ LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
|
||||
|
||||
warning: cannot find type `FromOutside` in this scope
|
||||
--> $DIR/generate-mod.rs:35:14
|
||||
|
|
||||
LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
|
||||
|
||||
warning: cannot find type `OuterDerive` in this scope
|
||||
--> $DIR/generate-mod.rs:35:14
|
||||
|
|
||||
LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0412`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user