Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
355 changes: 231 additions & 124 deletions compiler/rustc_resolve/src/imports.rs

Large diffs are not rendered by default.

35 changes: 21 additions & 14 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2868,16 +2868,10 @@ mod ref_mut {
#[track_caller]
pub(crate) fn get_mut(&mut self) -> &mut T {
match self.mutable {
false => panic!("Can't mutably borrow speculative resolver"),
false => panic!("can't mutably borrow speculative resolver"),
true => self.p,
}
}

/// Returns a mutable reference to the inner value without checking if
/// it's in a mutable state.
pub(crate) fn get_mut_unchecked(&mut self) -> &mut T {
self.p
}
}

/// A wrapper around a [`Cell`] that only allows mutation based on a condition in the resolver.
Expand All @@ -2901,12 +2895,12 @@ mod ref_mut {
self.0.get()
}

pub(crate) fn update_unchecked(&self, f: impl FnOnce(T) -> T)
pub(crate) fn update<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>, f: impl FnOnce(T) -> T)
where
T: Copy,
{
let old = self.get();
self.set_unchecked(f(old));
self.set(f(old), r);
}
}

Expand All @@ -2915,7 +2909,10 @@ mod ref_mut {
CmCell(Cell::new(value))
}

pub(crate) fn set_unchecked(&self, val: T) {
pub(crate) fn set<'ra, 'tcx>(&self, val: T, r: &Resolver<'ra, 'tcx>) {
if r.assert_speculative {
panic!("not allowed to mutate a `CmCell` during speculative resolution")
}
self.0.set(val);
}

Expand All @@ -2941,16 +2938,26 @@ mod ref_mut {
#[track_caller]
pub(crate) fn borrow_mut<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> RefMut<'_, T> {
if r.assert_speculative {
panic!("Not allowed to mutably borrow a CmRefCell during speculative resolution");
panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution");
}
self.borrow_mut_unchecked()
self.0.borrow_mut()
}

#[track_caller]
pub(crate) fn try_borrow_mut_unchecked(&self) -> Result<RefMut<'_, T>, BorrowMutError> {
self.0.try_borrow_mut()
}

#[track_caller]
pub(crate) fn try_borrow_mut<'ra, 'tcx>(
&self,
r: &Resolver<'ra, 'tcx>,
) -> Result<RefMut<'_, T>, BorrowMutError> {
if r.assert_speculative {
panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution");
}
self.0.try_borrow_mut()
}

#[track_caller]
pub(crate) fn borrow(&self) -> Ref<'_, T> {
self.0.borrow()
Expand All @@ -2960,7 +2967,7 @@ mod ref_mut {
impl<T: Default> CmRefCell<T> {
pub(crate) fn take<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> T {
if r.assert_speculative {
panic!("Not allowed to mutate a CmRefCell during speculative resolution");
panic!("not allowed to mutate a CmRefCell during speculative resolution");
}
self.0.take()
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ symbols! {
ResumeTy,
Reverse,
Rust,
// Temporary name for the rust_embed hack introduced in #145108
RustEmbed,
RustaceansAreAwesome,
RwLock,
RwLockReadGuard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use stdarch_test::assert_instr;

use super::*;
use crate::core_arch::arch::aarch64::*;
use super::{AsSigned, AsUnsigned};

#[doc = "Absolute difference"]
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/svabd[_f32]_m)"]
Expand Down
2 changes: 1 addition & 1 deletion library/stdarch/crates/stdarch-gen-arm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ use super::*;{uses_neon}

"#,
uses_neon = if generated_input.ctx.uses_neon_types {
"\nuse crate::core_arch::arch::aarch64::*;"
"\nuse crate::core_arch::arch::aarch64::*;\nuse super::{AsSigned, AsUnsigned};"
} else {
""
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! MIR lowering for places

use hir_def::FunctionId;
use rustc_type_ir::inherent::{Region as _, Ty as _};
use rustc_type_ir::inherent::Region as _;

use super::*;
use crate::{
Expand Down
1 change: 0 additions & 1 deletion tests/ui/imports/ambiguous-14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ mod g {
fn main() {
g::foo();
//~^ ERROR `foo` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
36 changes: 5 additions & 31 deletions tests/ui/imports/ambiguous-14.stderr
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
error: `foo` is ambiguous
error[E0659]: `foo` is ambiguous
--> $DIR/ambiguous-14.rs:23:8
|
LL | g::foo();
| ^^^ ambiguous name
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `foo` could refer to the function imported here
--> $DIR/ambiguous-14.rs:18:13
--> $DIR/ambiguous-14.rs:13:13
|
LL | pub use a::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
note: `foo` could also refer to the function imported here
--> $DIR/ambiguous-14.rs:19:13
--> $DIR/ambiguous-14.rs:14:13
|
LL | pub use f::*;
LL | pub use b::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
= 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 #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

error: aborting due to 1 previous error

Future incompatibility report: Future breakage diagnostic:
error: `foo` is ambiguous
--> $DIR/ambiguous-14.rs:23:8
|
LL | g::foo();
| ^^^ ambiguous name
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `foo` could refer to the function imported here
--> $DIR/ambiguous-14.rs:18:13
|
LL | pub use a::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
note: `foo` could also refer to the function imported here
--> $DIR/ambiguous-14.rs:19:13
|
LL | pub use f::*;
| ^^^^
= help: consider adding an explicit import of `foo` to disambiguate
= 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 #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

For more information about this error, try `rustc --explain E0659`.
9 changes: 4 additions & 5 deletions tests/ui/imports/ambiguous-9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pub mod dsl {
mod range {
pub fn date_range() {}
}
pub use self::range::*; //~ WARNING ambiguous glob re-exports
pub use self::range::*;
use super::prelude::*;
}

pub mod prelude {
mod t {
pub fn date_range() {}
pub fn date_range() {}
}
pub use self::t::*; //~ WARNING ambiguous glob re-exports
pub use super::dsl::*;
pub use self::t::*;
pub use super::dsl::*; //~ WARNING ambiguous glob re-exports
}

use dsl::*;
Expand All @@ -22,5 +22,4 @@ use prelude::*;
fn main() {
date_range();
//~^ ERROR `date_range` is ambiguous
//~| ERROR `date_range` is ambiguous
}
52 changes: 12 additions & 40 deletions tests/ui/imports/ambiguous-9.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,28 @@ LL | date_range();
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:19:5
--> $DIR/ambiguous-9.rs:16:13
|
LL | use dsl::*;
| ^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:20:5
|
LL | use prelude::*;
| ^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate

error[E0659]: `date_range` is ambiguous
--> $DIR/ambiguous-9.rs:23:5
|
LL | date_range();
| ^^^^^^^^^^ ambiguous name
|
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:7:13
|
LL | pub use self::range::*;
| ^^^^^^^^^^^^^^
LL | pub use super::dsl::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:8:9
--> $DIR/ambiguous-9.rs:15:13
|
LL | use super::prelude::*;
| ^^^^^^^^^^^^^^^^^
LL | pub use self::t::*;
| ^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate

warning: ambiguous glob re-exports
--> $DIR/ambiguous-9.rs:7:13
|
LL | pub use self::range::*;
| ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
LL | use super::prelude::*;
| ----------------- but the name `date_range` in the value namespace is also re-exported here
|
= note: `#[warn(ambiguous_glob_reexports)]` on by default

warning: ambiguous glob re-exports
--> $DIR/ambiguous-9.rs:15:13
--> $DIR/ambiguous-9.rs:16:13
|
LL | pub use self::t::*;
| ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
| ---------- but the name `date_range` in the value namespace is also re-exported here
LL | pub use super::dsl::*;
| ------------- but the name `date_range` in the value namespace is also re-exported here
| ^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
|
= note: `#[warn(ambiguous_glob_reexports)]` on by default

error: aborting due to 2 previous errors; 2 warnings emitted
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0659`.
1 change: 0 additions & 1 deletion tests/ui/imports/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ fn main() {
f::foo(); //~ ERROR `foo` is ambiguous
g::foo();
//~^ ERROR `foo` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}

mod ambiguous_module_errors {
Expand Down
Loading
Loading