span: Span,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
- ) -> Option<(Vec<Segment>, Vec<String>)> {
+ ) -> Option<(Vec<Segment>, Option<String>)> {
debug!("make_path_suggestion: span={:?} path={:?}", span, path);
match (path.get(0), path.get(1)) {
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
- ) -> Option<(Vec<Segment>, Vec<String>)> {
+ ) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `self` and check if that is valid.
path[0].ident.name = kw::SelfLower;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
- if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
+ if let PathResult::Module(..) = result { Some((path, None)) } else { None }
}
/// Suggests a missing `crate::` if that resolves to an correct module.
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
- ) -> Option<(Vec<Segment>, Vec<String>)> {
+ ) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Crate;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
if let PathResult::Module(..) = result {
Some((
path,
- vec![
+ Some(
"`use` statements changed in Rust 2018; read more at \
<https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-\
clarity.html>"
.to_string(),
- ],
+ ),
))
} else {
None
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
- ) -> Option<(Vec<Segment>, Vec<String>)> {
+ ) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Super;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
- if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
+ if let PathResult::Module(..) = result { Some((path, None)) } else { None }
}
/// Suggests a missing external crate name if that resolves to an correct module.
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
- ) -> Option<(Vec<Segment>, Vec<String>)> {
+ ) -> Option<(Vec<Segment>, Option<String>)> {
if path[1].ident.span.rust_2015() {
return None;
}
name, path, result
);
if let PathResult::Module(..) = result {
- return Some((path, Vec::new()));
+ return Some((path, None));
}
}
import: &'b Import<'b>,
module: ModuleOrUniformRoot<'b>,
ident: Ident,
- ) -> Option<(Option<Suggestion>, Vec<String>)> {
+ ) -> Option<(Option<Suggestion>, Option<String>)> {
let ModuleOrUniformRoot::Module(mut crate_module) = module else {
return None;
};
String::from("a macro with this name exists at the root of the crate"),
Applicability::MaybeIncorrect,
));
- let note = vec![
- "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"
- .to_string(),
- ];
- Some((suggestion, note))
+ Some((suggestion, Some("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"
+ .to_string())))
} else {
None
}
struct UnresolvedImportError {
span: Span,
label: Option<String>,
- note: Vec<String>,
+ note: Option<String>,
suggestion: Option<Suggestion>,
}
let err = UnresolvedImportError {
span: import.span,
label: None,
- note: Vec::new(),
+ note: None,
suggestion: None,
};
if path.contains("::") {
let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg);
- if let Some((_, UnresolvedImportError { note, .. })) = errors.iter().last() {
- for message in note {
- diag.note(message);
- }
+ if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
+ diag.note(note);
}
for (_, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
None => UnresolvedImportError {
span,
label: Some(label),
- note: Vec::new(),
+ note: None,
suggestion,
},
};
return Some(UnresolvedImportError {
span: import.span,
label: Some(String::from("cannot glob-import a module into itself")),
- note: Vec::new(),
+ note: None,
suggestion: None,
});
}
let (suggestion, note) =
match self.check_for_module_export_macro(import, module, ident) {
Some((suggestion, note)) => (suggestion.or(lev_suggestion), note),
- _ => (lev_suggestion, Vec::new()),
+ _ => (lev_suggestion, None),
};
let label = match module {