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};
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");
}
// 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<_>>();
/// ```
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>)> {
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={:?}",
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={:?}",
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)
},
));
}