mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
diagnostics: add };
only if {
was added too
This commit is contained in:
parent
e9d8d238ef
commit
e237690a28
@ -2161,6 +2161,11 @@ 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()));
|
||||
}
|
||||
} else {
|
||||
// If the root import is module-relative, add the import separately
|
||||
corrections.push((
|
||||
@ -2168,11 +2173,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||
format!("use {module_name}::{import_snippet};\n"),
|
||||
));
|
||||
}
|
||||
|
||||
// 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()));
|
||||
}
|
||||
}
|
||||
|
||||
let suggestion = Some((
|
||||
|
20
tests/ui/imports/issue-99695-b.fixed
Normal file
20
tests/ui/imports/issue-99695-b.fixed
Normal file
@ -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
tests/ui/imports/issue-99695-b.rs
Normal file
19
tests/ui/imports/issue-99695-b.rs
Normal file
@ -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
tests/ui/imports/issue-99695-b.stderr
Normal file
16
tests/ui/imports/issue-99695-b.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user