Skip to content

Commit 4e7e62a

Browse files
committed
resolve: Always update globs importing from a module when bindings in that module change
1 parent 6162f6f commit 4e7e62a

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

compiler/rustc_resolve/src/imports.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
391391
// during which the resolution might end up getting re-defined via a glob cycle.
392392
let (binding, t) = {
393393
let resolution = &mut *self.resolution(module, key).borrow_mut();
394-
let old_binding = resolution.binding();
394+
let old_binding = resolution.binding;
395395

396396
let t = f(self, resolution);
397397

398-
match resolution.binding() {
399-
_ if old_binding.is_some() => return t,
400-
None => return t,
401-
Some(binding) => match old_binding {
402-
Some(old_binding) if ptr::eq(old_binding, binding) => return t,
403-
_ => (binding, t),
404-
},
398+
match resolution.binding {
399+
Some(binding)
400+
if !old_binding.is_some_and(|old_binding| ptr::eq(binding, old_binding)) =>
401+
{
402+
(binding, t)
403+
}
404+
_ => return t,
405405
}
406406
};
407407

tests/ui/resolve/issue-112831.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// check-pass
21
// aux-build:issue-112831-aux.rs
32

43
mod zeroable {
@@ -9,7 +8,7 @@ use zeroable::*;
98

109
mod pod {
1110
use super::*;
12-
pub trait Pod: Zeroable {}
11+
pub trait Pod: Zeroable {} //~ ERROR expected trait, found derive macro `Zeroable`
1312
}
1413

1514
use pod::*;

tests/ui/resolve/issue-112831.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0404]: expected trait, found derive macro `Zeroable`
2+
--> $DIR/issue-112831.rs:11:20
3+
|
4+
LL | pub trait Pod: Zeroable {}
5+
| ^^^^^^^^ not a trait
6+
|
7+
help: consider importing this trait through its public re-export instead
8+
|
9+
LL + use Zeroable;
10+
|
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0404`.

0 commit comments

Comments
 (0)