Skip to content

Commit 9c588c1

Browse files
committed
Auto merge of #65140 - petrochenkov:disapp, r=nikomatsakis
resolve: Remove an incorrect assert Fixes #64803.
2 parents 8c7b921 + fcd98cf commit 9c588c1

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/librustc_resolve/macros.rs

-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ impl<'a> Resolver<'a> {
773773
check_consistency(self, &[seg], ident.span, kind, initial_res, res);
774774
}
775775
Err(..) => {
776-
assert!(initial_binding.is_none());
777776
let expected = kind.descr_expected();
778777
let msg = format!("cannot find {} `{}` in this scope", expected, ident);
779778
let mut err = self.session.struct_span_err(ident.span, &msg);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for issue #64803 (initial attribute resolution can disappear later).
2+
3+
// aux-build:test-macros.rs
4+
5+
#[macro_use]
6+
extern crate test_macros;
7+
8+
mod m {
9+
use test_macros::Empty;
10+
}
11+
use m::Empty; //~ ERROR derive macro `Empty` is private
12+
13+
// To resolve `empty_helper` we need to resolve `Empty`.
14+
// During initial resolution `use m::Empty` introduces no entries, so we proceed to `macro_use`,
15+
// successfully resolve `Empty` from there, and then resolve `empty_helper` as its helper.
16+
// During validation `use m::Empty` introduces a `Res::Err` stub, so `Empty` resolves to it,
17+
// and `empty_helper` can no longer be resolved.
18+
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
19+
#[derive(Empty)]
20+
struct S;
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: cannot find attribute `empty_helper` in this scope
2+
--> $DIR/disappearing-resolution.rs:18:3
3+
|
4+
LL | #[empty_helper]
5+
| ^^^^^^^^^^^^
6+
7+
error[E0603]: derive macro `Empty` is private
8+
--> $DIR/disappearing-resolution.rs:11:8
9+
|
10+
LL | use m::Empty;
11+
| ^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0603`.

0 commit comments

Comments
 (0)