}
fn report_with_use_injections(&mut self, krate: &Crate) {
- for UseError { mut err, candidates, def_id, instead, suggestion } in
+ for UseError { mut err, candidates, def_id, instead, suggestion, path } in
self.use_injections.drain(..)
{
let (span, found_use) = if let Some(def_id) = def_id.as_local() {
if instead { Instead::Yes } else { Instead::No },
found_use,
IsPattern::No,
+ path,
);
} else if let Some((span, msg, sugg, appl)) = suggestion {
err.span_suggestion(span, msg, sugg, appl);
Instead::No,
FoundUse::Yes,
IsPattern::Yes,
+ vec![],
);
}
err
segms.push(ast::PathSegment::from_ident(ident));
let path = Path { span: name_binding.span, segments: segms, tokens: None };
let did = match res {
- Res::Def(DefKind::Ctor(..), did) => this.parent(did),
+ Res::Def(DefKind::Ctor(..), did) => this.opt_parent(did),
_ => res.opt_def_id(),
};
Instead::No,
FoundUse::Yes,
IsPattern::No,
+ vec![],
);
if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
_,
) = binding.kind
{
- let def_id = self.parent(ctor_def_id).expect("no parent for a constructor");
+ let def_id = self.parent(ctor_def_id);
let fields = self.field_names.get(&def_id)?;
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
}
instead: Instead,
found_use: FoundUse,
is_pattern: IsPattern,
+ path: Vec<Segment>,
) {
if candidates.is_empty() {
return;
accessible_path_strings.into_iter().map(|a| a.0),
Applicability::MaybeIncorrect,
);
+ if let [first, .., last] = &path[..] {
+ err.span_suggestion_verbose(
+ first.ident.span.until(last.ident.span),
+ &format!("if you import `{}`, refer to it directly", last.ident),
+ String::new(),
+ Applicability::Unspecified,
+ );
+ }
} else {
msg.push(':');