err.span_suggestion_with_applicability(
binding.span,
&rename_msg,
- match (&directive.subclass, snippet.as_ref()) {
- (ImportDirectiveSubclass::SingleImport { .. }, "self") =>
+ match directive.subclass {
+ ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
format!("self as {}", suggested_name),
- (ImportDirectiveSubclass::SingleImport { source, .. }, _) =>
+ ImportDirectiveSubclass::SingleImport { source, .. } =>
format!(
"{} as {}{}",
&snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)],
""
}
),
- (ImportDirectiveSubclass::ExternCrate { source, target, .. }, _) =>
+ ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
format!(
"extern crate {} as {};",
source.unwrap_or(target.name),
suggested_name,
),
- (_, _) => unreachable!(),
+ _ => unreachable!(),
},
Applicability::MaybeIncorrect,
);
LL | use foo::{self as other_foo};
| ^^^^^^^^^^^^^^^^^
-error: aborting due to 3 previous errors
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/import-self.rs:23:11
+ |
+LL | use foo::A;
+ | ------ previous import of the type `A` here
+LL | use foo::{self as A};
+ | ^^^^^^^^^ `A` reimported here
+ |
+ = note: `A` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo::{self as OtherA};
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
-Some errors occurred: E0255, E0429.
-For more information about an error, try `rustc --explain E0255`.
+Some errors occurred: E0252, E0255, E0429.
+For more information about an error, try `rustc --explain E0252`.