]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_resolve/diagnostics.rs
Auto merge of #68191 - simlay:add-tvSO-target, r=nagisa
[rust.git] / src / librustc_resolve / diagnostics.rs
index 18192a18cef3663e60f579f2f7a77b661c45d204..47a05ec90d42fc8cfa7427f8da3577cf29f0f226 100644 (file)
@@ -18,7 +18,7 @@
 use rustc_span::symbol::{kw, Symbol};
 use rustc_span::{BytePos, MultiSpan, Span};
 
-use crate::imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver};
+use crate::imports::{Import, ImportKind, ImportResolver};
 use crate::path_names_to_string;
 use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind};
 use crate::{BindingError, CrateLint, HasGenericParams, LegacyScope, Module, ModuleOrUniformRoot};
@@ -249,8 +249,7 @@ impl<'a> Resolver<'a> {
                     self.session,
                     span,
                     E0409,
-                    "variable `{}` is bound in inconsistent \
-                                ways within the same match arm",
+                    "variable `{}` is bound inconsistently across alternatives separated by `|`",
                     variable_name
                 );
                 err.span_label(span, "bound in different ways");
@@ -1090,7 +1089,7 @@ fn make_external_crate_suggestion(
         }
 
         // Sort extern crate names in reverse order to get
-        // 1) some consistent ordering for emitted dignostics, and
+        // 1) some consistent ordering for emitted diagnostics, and
         // 2) `std` suggestions before `core` suggestions.
         let mut extern_crate_names =
             self.r.extern_prelude.iter().map(|(ident, _)| ident.name).collect::<Vec<_>>();
@@ -1126,7 +1125,7 @@ fn make_external_crate_suggestion(
     /// ```
     pub(crate) fn check_for_module_export_macro(
         &mut self,
-        directive: &'b ImportDirective<'b>,
+        import: &'b Import<'b>,
         module: ModuleOrUniformRoot<'b>,
         ident: Ident,
     ) -> Option<(Option<Suggestion>, Vec<String>)> {
@@ -1151,28 +1150,26 @@ pub(crate) fn check_for_module_export_macro(
         let binding = resolution.borrow().binding()?;
         if let Res::Def(DefKind::Macro(MacroKind::Bang), _) = binding.res() {
             let module_name = crate_module.kind.name().unwrap();
-            let import = match directive.subclass {
-                ImportDirectiveSubclass::SingleImport { source, target, .. }
-                    if source != target =>
-                {
+            let import_snippet = match import.kind {
+                ImportKind::Single { source, target, .. } if source != target => {
                     format!("{} as {}", source, target)
                 }
                 _ => format!("{}", ident),
             };
 
             let mut corrections: Vec<(Span, String)> = Vec::new();
-            if !directive.is_nested() {
+            if !import.is_nested() {
                 // Assume this is the easy case of `use issue_59764::foo::makro;` and just remove
                 // intermediate segments.
-                corrections.push((directive.span, format!("{}::{}", module_name, import)));
+                corrections.push((import.span, format!("{}::{}", module_name, import_snippet)));
             } else {
                 // Find the binding span (and any trailing commas and spaces).
                 //   ie. `use a::b::{c, d, e};`
                 //                      ^^^
                 let (found_closing_brace, binding_span) = find_span_of_binding_until_next_binding(
                     self.r.session,
-                    directive.span,
-                    directive.use_span,
+                    import.span,
+                    import.use_span,
                 );
                 debug!(
                     "check_for_module_export_macro: found_closing_brace={:?} binding_span={:?}",
@@ -1209,7 +1206,7 @@ pub(crate) fn check_for_module_export_macro(
                 let (has_nested, after_crate_name) = find_span_immediately_after_crate_name(
                     self.r.session,
                     module_name,
-                    directive.use_span,
+                    import.use_span,
                 );
                 debug!(
                     "check_for_module_export_macro: has_nested={:?} after_crate_name={:?}",
@@ -1225,11 +1222,11 @@ pub(crate) fn check_for_module_export_macro(
                         start_point,
                         if has_nested {
                             // In this case, `start_snippet` must equal '{'.
-                            format!("{}{}, ", start_snippet, import)
+                            format!("{}{}, ", start_snippet, import_snippet)
                         } else {
                             // In this case, add a `{`, then the moved import, then whatever
                             // was there before.
-                            format!("{{{}, {}", import, start_snippet)
+                            format!("{{{}, {}", import_snippet, start_snippet)
                         },
                     ));
                 }