Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cf2d0ce
diagnostics: suggest changing `s@self::{macro}@::macro` for exported
notriddle Nov 13, 2022
98091c0
diagnostics: add `};` only if `{` was added too
notriddle Nov 13, 2022
dbc0ed2
Unify stable and unstable sort implementations in same core module
Voultapher Nov 20, 2022
1ec59cd
Remove debug unused
Voultapher Nov 21, 2022
4b5844f
Document all unsafe blocks
Voultapher Nov 21, 2022
04af19f
diagnostics: use `module_path` to check crate import instead of strings
notriddle Dec 6, 2022
f2070c3
diagnostics: remvoe unnecessary use of `source_map.start_point`
notriddle Dec 6, 2022
280f69d
Fix IndexVec::drain_enumerated
compiler-errors Jan 19, 2023
c9c8e29
HACK: self ty ambiguity hack
compiler-errors Jan 19, 2023
ac4956b
Support `.comment` section like GCC/Clang (`!llvm.ident`)
ojeda May 28, 2022
aee75f2
Assert goal is fully normalized during assemble
compiler-errors Jan 19, 2023
f53f5b4
swap Ambiguity and Unimplemented in new trait engine
compiler-errors Jan 19, 2023
69890b2
trait solver: PointerSized
compiler-errors Jan 18, 2023
ed6aebb
trait solver: Implement Fn traits and tuple trait
compiler-errors Jan 19, 2023
05889fc
rustdoc: remove redundant CSS selector `.sidebar .current`
notriddle Jan 19, 2023
734f375
Change `bindings_with_variant_name` to deny-by-default
timrobertsdev Nov 8, 2022
1cbce72
Add `compile_fail` to doctest for `bindings_with_variant_name`
timrobertsdev Nov 8, 2022
1adb4d6
Fix typo in opaque_types.rs
eltociear Jan 20, 2023
a641b92
remove leading comma when there are no args in check macro expansion
DebugSteven Jan 19, 2023
c3e30f1
Rollup merge of #97550 - ojeda:comment-section, r=bjorn3
compiler-errors Jan 20, 2023
bb5f43e
Rollup merge of #104154 - timrobertsdev:deny-by-default-bindings_with…
compiler-errors Jan 20, 2023
993932b
Rollup merge of #104347 - notriddle:notriddle/import-macro-from-self-…
compiler-errors Jan 20, 2023
4b7bec8
Rollup merge of #104672 - Voultapher:unify-sort-modules, r=thomcc
compiler-errors Jan 20, 2023
8a66e39
Rollup merge of #107061 - compiler-errors:new-solver-new-candidates-3…
compiler-errors Jan 20, 2023
7c5f572
Rollup merge of #107095 - notriddle:notriddle/sidebar-current, r=Guil…
compiler-errors Jan 20, 2023
644e0cc
Rollup merge of #107112 - eltociear:patch-19, r=albertlarsan68
compiler-errors Jan 20, 2023
222510e
Rollup merge of #107124 - DebugSteven:check-macro-expansion, r=albert…
compiler-errors Jan 20, 2023
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
22 changes: 17 additions & 5 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2125,9 +2125,15 @@ impl<'a, 'b> ImportResolver<'a, 'b> {

let source_map = self.r.session.source_map();

// Make sure this is actually crate-relative.
let is_definitely_crate = import
.module_path
.first()
.map_or(false, |f| f.ident.name != kw::SelfLower && f.ident.name != kw::Super);

// Add the import to the start, with a `{` if required.
let start_point = source_map.start_point(after_crate_name);
if let Ok(start_snippet) = source_map.span_to_snippet(start_point) {
if is_definitely_crate && let Ok(start_snippet) = source_map.span_to_snippet(start_point) {
corrections.push((
start_point,
if has_nested {
Expand All @@ -2139,11 +2145,17 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
format!("{{{}, {}", import_snippet, start_snippet)
},
));
}

// Add a `};` to the end if nested, matching the `{` added at the start.
if !has_nested {
corrections.push((source_map.end_point(after_crate_name), "};".to_string()));
// Add a `};` to the end if nested, matching the `{` added at the start.
if !has_nested {
corrections.push((source_map.end_point(after_crate_name), "};".to_string()));
}
} else {
// If the root import is module-relative, add the import separately
corrections.push((
import.use_span.shrink_to_lo(),
format!("use {module_name}::{import_snippet};\n"),
));
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/imports/issue-99695-b.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// run-rustfix
#![allow(unused, nonstandard_style)]
mod m {

mod p {
#[macro_export]
macro_rules! nu {
{} => {};
}

pub struct other_item;
}

use ::nu;
pub use self::p::{other_item as _};
//~^ ERROR unresolved import `self::p::nu` [E0432]
//~| HELP a macro with this name exists at the root of the crate
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/imports/issue-99695-b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// run-rustfix
#![allow(unused, nonstandard_style)]
mod m {

mod p {
#[macro_export]
macro_rules! nu {
{} => {};
}

pub struct other_item;
}

pub use self::p::{nu, other_item as _};
//~^ ERROR unresolved import `self::p::nu` [E0432]
//~| HELP a macro with this name exists at the root of the crate
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/imports/issue-99695-b.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0432]: unresolved import `self::p::nu`
--> $DIR/issue-99695-b.rs:14:23
|
LL | pub use self::p::{nu, other_item as _};
| ^^ no `nu` in `m::p`
|
= note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
help: a macro with this name exists at the root of the crate
|
LL ~ use ::nu;
LL ~ pub use self::p::{other_item as _};
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
17 changes: 17 additions & 0 deletions src/test/ui/imports/issue-99695.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// run-rustfix
#![allow(unused, nonstandard_style)]
mod m {
#[macro_export]
macro_rules! nu {
{} => {};
}

pub struct other_item;

use ::nu;
pub use self::{other_item as _};
//~^ ERROR unresolved import `self::nu` [E0432]
//~| HELP a macro with this name exists at the root of the crate
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/imports/issue-99695.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// run-rustfix
#![allow(unused, nonstandard_style)]
mod m {
#[macro_export]
macro_rules! nu {
{} => {};
}

pub struct other_item;

pub use self::{nu, other_item as _};
//~^ ERROR unresolved import `self::nu` [E0432]
//~| HELP a macro with this name exists at the root of the crate
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/imports/issue-99695.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0432]: unresolved import `self::nu`
--> $DIR/issue-99695.rs:11:20
|
LL | pub use self::{nu, other_item as _};
| ^^ no `nu` in `m`
|
= note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
help: a macro with this name exists at the root of the crate
|
LL ~ use ::nu;
LL ~ pub use self::{other_item as _};
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.