1
Fork 0

resolve: Do not build expensive suggestions if they are not actually used

Also remove a redundant parameter from `fn resolve_path(_with_ribs)`, `crate_lint: CrateLint` is a more detailed version of `record_used: bool` with `CrateLint::No` meaning `false` and anything else meaning `true`.
This commit is contained in:
Vadim Petrochenkov 2022-03-23 22:47:19 +03:00
parent 63b8f01bb5
commit 0749ec67bc
22 changed files with 237 additions and 448 deletions

View file

@ -296,9 +296,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
&segments, &segments,
Some(TypeNS), Some(TypeNS),
parent_scope, parent_scope,
!speculative,
path.span, path.span,
CrateLint::SimplePath(id), if speculative { CrateLint::No } else { CrateLint::SimplePath(id) },
) { ) {
PathResult::Module(ModuleOrUniformRoot::Module(module)) => { PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
let res = module.res().expect("visibility resolved to unnamed block"); let res = module.res().expect("visibility resolved to unnamed block");

View file

@ -1426,7 +1426,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
) -> Option<(Vec<Segment>, Vec<String>)> { ) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `self` and check if that is valid. // Replace first ident with `self` and check if that is valid.
path[0].ident.name = kw::SelfLower; path[0].ident.name = kw::SelfLower;
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result); 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, Vec::new())) } else { None }
} }
@ -1446,7 +1446,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
) -> Option<(Vec<Segment>, Vec<String>)> { ) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `crate` and check if that is valid. // Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Crate; path[0].ident.name = kw::Crate;
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result); debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result { if let PathResult::Module(..) = result {
Some(( Some((
@ -1478,7 +1478,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
) -> Option<(Vec<Segment>, Vec<String>)> { ) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `crate` and check if that is valid. // Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Super; path[0].ident.name = kw::Super;
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result); 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, Vec::new())) } else { None }
} }
@ -1513,7 +1513,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
for name in extern_crate_names.into_iter() { for name in extern_crate_names.into_iter() {
// Replace first ident with a crate name and check if that is valid. // Replace first ident with a crate name and check if that is valid.
path[0].ident.name = name; path[0].ident.name = name;
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
debug!( debug!(
"make_external_crate_suggestion: name={:?} path={:?} result={:?}", "make_external_crate_suggestion: name={:?} path={:?} result={:?}",
name, path, result name, path, result

View file

@ -123,10 +123,6 @@ impl<'a> Import<'a> {
_ => false, _ => false,
} }
} }
crate fn crate_lint(&self) -> CrateLint {
CrateLint::UsePath { root_id: self.root_id, root_span: self.root_span }
}
} }
#[derive(Clone, Default, Debug)] #[derive(Clone, Default, Debug)]
@ -791,9 +787,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
&import.module_path, &import.module_path,
None, None,
&import.parent_scope, &import.parent_scope,
false,
import.span, import.span,
import.crate_lint(), CrateLint::No,
); );
import.vis.set(orig_vis); import.vis.set(orig_vis);
@ -887,13 +882,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
_ => None, _ => None,
}; };
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len(); let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
let crate_lint =
CrateLint::UsePath { root_id: import.root_id, root_span: import.root_span };
let path_res = self.r.resolve_path( let path_res = self.r.resolve_path(
&import.module_path, &import.module_path,
None, None,
&import.parent_scope, &import.parent_scope,
true,
import.span, import.span,
import.crate_lint(), crate_lint,
); );
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len; let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
if let Some(orig_unusable_binding) = orig_unusable_binding { if let Some(orig_unusable_binding) = orig_unusable_binding {
@ -982,7 +978,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let mut full_path = import.module_path.clone(); let mut full_path = import.module_path.clone();
full_path.push(Segment::from_ident(Ident::empty())); full_path.push(Segment::from_ident(Ident::empty()));
self.r.lint_if_path_starts_with_module( self.r.lint_if_path_starts_with_module(
import.crate_lint(), crate_lint,
&full_path, &full_path,
import.span, import.span,
None, None,
@ -1254,7 +1250,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
self.r.per_ns(|this, ns| { self.r.per_ns(|this, ns| {
if let Ok(binding) = source_bindings[ns].get() { if let Ok(binding) = source_bindings[ns].get() {
this.lint_if_path_starts_with_module( this.lint_if_path_starts_with_module(
import.crate_lint(), crate_lint,
&full_path, &full_path,
import.span, import.span,
Some(binding), Some(binding),

View file

@ -768,7 +768,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
&mut self, &mut self,
path: &[Segment], path: &[Segment],
opt_ns: Option<Namespace>, // `None` indicates a module path in import opt_ns: Option<Namespace>, // `None` indicates a module path in import
record_used: bool,
path_span: Span, path_span: Span,
crate_lint: CrateLint, crate_lint: CrateLint,
) -> PathResult<'a> { ) -> PathResult<'a> {
@ -776,7 +775,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
path, path,
opt_ns, opt_ns,
&self.parent_scope, &self.parent_scope,
record_used,
path_span, path_span,
crate_lint, crate_lint,
Some(&self.ribs), Some(&self.ribs),
@ -1253,18 +1251,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
PathSource::Trait(AliasPossibility::No), PathSource::Trait(AliasPossibility::No),
CrateLint::SimplePath(trait_ref.ref_id), CrateLint::SimplePath(trait_ref.ref_id),
); );
let res = res.base_res(); if let Some(def_id) = res.base_res().opt_def_id() {
if res != Res::Err { new_id = Some(def_id);
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path( new_val = Some((self.r.expect_module(def_id), trait_ref.clone()));
&path,
Some(TypeNS),
true,
trait_ref.path.span,
CrateLint::SimplePath(trait_ref.ref_id),
) {
new_id = Some(res.def_id());
new_val = Some((module, trait_ref.clone()));
}
} }
} }
let original_trait_ref = replace(&mut self.current_trait_ref, new_val); let original_trait_ref = replace(&mut self.current_trait_ref, new_val);
@ -2026,6 +2015,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
None None
}; };
assert_ne!(crate_lint, CrateLint::No);
let partial_res = match self.resolve_qpath_anywhere( let partial_res = match self.resolve_qpath_anywhere(
id, id,
qself, qself,
@ -2060,7 +2050,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std))); std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std)));
std_path.extend(path); std_path.extend(path);
if let PathResult::Module(_) | PathResult::NonModule(_) = if let PathResult::Module(_) | PathResult::NonModule(_) =
self.resolve_path(&std_path, Some(ns), false, span, CrateLint::No) self.resolve_path(&std_path, Some(ns), span, CrateLint::No)
{ {
// Check if we wrote `str::from_utf8` instead of `std::str::from_utf8` // Check if we wrote `str::from_utf8` instead of `std::str::from_utf8`
let item_span = let item_span =
@ -2228,7 +2218,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
))); )));
} }
let result = match self.resolve_path(&path, Some(ns), true, span, crate_lint) { let result = match self.resolve_path(&path, Some(ns), span, crate_lint) {
PathResult::NonModule(path_res) => path_res, PathResult::NonModule(path_res) => path_res,
PathResult::Module(ModuleOrUniformRoot::Module(module)) if !module.is_normal() => { PathResult::Module(ModuleOrUniformRoot::Module(module)) if !module.is_normal() => {
PartialRes::new(module.res().unwrap()) PartialRes::new(module.res().unwrap())
@ -2268,13 +2258,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
&& path[0].ident.name != kw::DollarCrate && path[0].ident.name != kw::DollarCrate
{ {
let unqualified_result = { let unqualified_result = {
match self.resolve_path( match self.resolve_path(&[*path.last().unwrap()], Some(ns), span, CrateLint::No) {
&[*path.last().unwrap()],
Some(ns),
false,
span,
CrateLint::No,
) {
PathResult::NonModule(path_res) => path_res.base_res(), PathResult::NonModule(path_res) => path_res.base_res(),
PathResult::Module(ModuleOrUniformRoot::Module(module)) => { PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
module.res().unwrap() module.res().unwrap()

View file

@ -188,7 +188,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
} else { } else {
let mod_path = &path[..path.len() - 1]; let mod_path = &path[..path.len() - 1];
let mod_prefix = let mod_prefix =
match self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No) { match self.resolve_path(mod_path, Some(TypeNS), span, CrateLint::No) {
PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(), PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
_ => None, _ => None,
} }
@ -648,7 +648,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
if let crate::PathSource::TraitItem(_) = source { if let crate::PathSource::TraitItem(_) = source {
let mod_path = &path[..path.len() - 1]; let mod_path = &path[..path.len() - 1];
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
self.resolve_path(mod_path, None, false, span, CrateLint::No) self.resolve_path(mod_path, None, span, CrateLint::No)
{ {
let resolutions = self.r.resolutions(module).borrow(); let resolutions = self.r.resolutions(module).borrow();
let targets: Vec<_> = let targets: Vec<_> =
@ -1384,7 +1384,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
// Search in module. // Search in module.
let mod_path = &path[..path.len() - 1]; let mod_path = &path[..path.len() - 1];
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No) self.resolve_path(mod_path, Some(TypeNS), span, CrateLint::No)
{ {
self.r.add_module_candidates(module, &mut names, &filter_fn); self.r.add_module_candidates(module, &mut names, &filter_fn);
} }

View file

@ -449,6 +449,19 @@ enum PathResult<'a> {
}, },
} }
impl<'a> PathResult<'a> {
fn failed(
span: Span,
is_error_from_last_segment: bool,
record_used: bool,
label_and_suggestion: impl FnOnce() -> (String, Option<Suggestion>),
) -> PathResult<'a> {
let (label, suggestion) =
if record_used { label_and_suggestion() } else { (String::new(), None) };
PathResult::Failed { span, label, suggestion, is_error_from_last_segment }
}
}
#[derive(Debug)] #[derive(Debug)]
enum ModuleKind { enum ModuleKind {
/// An anonymous module; e.g., just a block. /// An anonymous module; e.g., just a block.
@ -2206,19 +2219,10 @@ impl<'a> Resolver<'a> {
path: &[Segment], path: &[Segment],
opt_ns: Option<Namespace>, // `None` indicates a module path in import opt_ns: Option<Namespace>, // `None` indicates a module path in import
parent_scope: &ParentScope<'a>, parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span, path_span: Span,
crate_lint: CrateLint, crate_lint: CrateLint,
) -> PathResult<'a> { ) -> PathResult<'a> {
self.resolve_path_with_ribs( self.resolve_path_with_ribs(path, opt_ns, parent_scope, path_span, crate_lint, None)
path,
opt_ns,
parent_scope,
record_used,
path_span,
crate_lint,
None,
)
} }
fn resolve_path_with_ribs( fn resolve_path_with_ribs(
@ -2226,19 +2230,18 @@ impl<'a> Resolver<'a> {
path: &[Segment], path: &[Segment],
opt_ns: Option<Namespace>, // `None` indicates a module path in import opt_ns: Option<Namespace>, // `None` indicates a module path in import
parent_scope: &ParentScope<'a>, parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span, path_span: Span,
crate_lint: CrateLint, crate_lint: CrateLint,
ribs: Option<&PerNS<Vec<Rib<'a>>>>, ribs: Option<&PerNS<Vec<Rib<'a>>>>,
) -> PathResult<'a> { ) -> PathResult<'a> {
let record_used = crate_lint != CrateLint::No;
let mut module = None; let mut module = None;
let mut allow_super = true; let mut allow_super = true;
let mut second_binding = None; let mut second_binding = None;
debug!( debug!(
"resolve_path(path={:?}, opt_ns={:?}, record_used={:?}, \ "resolve_path(path={:?}, opt_ns={:?}, path_span={:?}, crate_lint={:?})",
path_span={:?}, crate_lint={:?})", path, opt_ns, path_span, crate_lint,
path, opt_ns, record_used, path_span, crate_lint,
); );
for (i, &Segment { ident, id, has_generic_args: _ }) in path.iter().enumerate() { for (i, &Segment { ident, id, has_generic_args: _ }) in path.iter().enumerate() {
@ -2278,13 +2281,9 @@ impl<'a> Resolver<'a> {
continue; continue;
} }
} }
let msg = "there are too many leading `super` keywords".to_string(); return PathResult::failed(ident.span, false, record_used, || {
return PathResult::Failed { ("there are too many leading `super` keywords".to_string(), None)
span: ident.span, });
label: msg,
suggestion: None,
is_error_from_last_segment: false,
};
} }
if i == 0 { if i == 0 {
if name == kw::SelfLower { if name == kw::SelfLower {
@ -2313,22 +2312,19 @@ impl<'a> Resolver<'a> {
// Report special messages for path segment keywords in wrong positions. // Report special messages for path segment keywords in wrong positions.
if ident.is_path_segment_keyword() && i != 0 { if ident.is_path_segment_keyword() && i != 0 {
let name_str = if name == kw::PathRoot { return PathResult::failed(ident.span, false, record_used, || {
"crate root".to_string() let name_str = if name == kw::PathRoot {
} else { "crate root".to_string()
format!("`{}`", name) } else {
}; format!("`{}`", name)
let label = if i == 1 && path[0].ident.name == kw::PathRoot { };
format!("global paths cannot start with {}", name_str) let label = if i == 1 && path[0].ident.name == kw::PathRoot {
} else { format!("global paths cannot start with {}", name_str)
format!("{} in paths can only be used in start position", name_str) } else {
}; format!("{} in paths can only be used in start position", name_str)
return PathResult::Failed { };
span: ident.span, (label, None)
label, });
suggestion: None,
is_error_from_last_segment: false,
};
} }
enum FindBindingResult<'a> { enum FindBindingResult<'a> {
@ -2356,16 +2352,11 @@ impl<'a> Resolver<'a> {
path_span, path_span,
) )
} else { } else {
let record_used_id = if record_used {
crate_lint.node_id().or(Some(CRATE_NODE_ID))
} else {
None
};
match this.resolve_ident_in_lexical_scope( match this.resolve_ident_in_lexical_scope(
ident, ident,
ns, ns,
parent_scope, parent_scope,
record_used_id, crate_lint.node_id(),
path_span, path_span,
&ribs.unwrap()[ns], &ribs.unwrap()[ns],
) { ) {
@ -2425,19 +2416,14 @@ impl<'a> Resolver<'a> {
path.len() - i - 1, path.len() - i - 1,
)); ));
} else { } else {
let label = format!( return PathResult::failed(ident.span, is_last, record_used, || {
"`{}` is {} {}, not a module", let label = format!(
ident, "`{ident}` is {} {}, not a module",
res.article(), res.article(),
res.descr(), res.descr()
); );
(label, None)
return PathResult::Failed { });
span: ident.span,
label,
suggestion: None,
is_error_from_last_segment: is_last,
};
} }
} }
Err(Undetermined) => return PathResult::Indeterminate, Err(Undetermined) => return PathResult::Indeterminate,
@ -2450,171 +2436,169 @@ impl<'a> Resolver<'a> {
)); ));
} }
} }
let module_res = match module {
Some(ModuleOrUniformRoot::Module(module)) => module.res(), return PathResult::failed(ident.span, is_last, record_used, || {
_ => None, let module_res = match module {
}; Some(ModuleOrUniformRoot::Module(module)) => module.res(),
let (label, suggestion) = if module_res == self.graph_root.res() { _ => None,
let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _));
// Don't look up import candidates if this is a speculative resolve
let mut candidates = if record_used {
self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod)
} else {
Vec::new()
}; };
candidates.sort_by_cached_key(|c| { if module_res == self.graph_root.res() {
(c.path.segments.len(), pprust::path_to_string(&c.path)) let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _));
}); let mut candidates =
if let Some(candidate) = candidates.get(0) { self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod);
( candidates.sort_by_cached_key(|c| {
String::from("unresolved import"), (c.path.segments.len(), pprust::path_to_string(&c.path))
Some(( });
vec![(ident.span, pprust::path_to_string(&candidate.path))], if let Some(candidate) = candidates.get(0) {
String::from("a similar path exists"), (
Applicability::MaybeIncorrect, String::from("unresolved import"),
)),
)
} else if self.session.edition() == Edition::Edition2015 {
(format!("maybe a missing crate `{}`?", ident), None)
} else {
(format!("could not find `{}` in the crate root", ident), None)
}
} else if i == 0 {
if ident
.name
.as_str()
.chars()
.next()
.map_or(false, |c| c.is_ascii_uppercase())
{
// Check whether the name refers to an item in the value namespace.
let suggestion = if ribs.is_some() {
let match_span = match self.resolve_ident_in_lexical_scope(
ident,
ValueNS,
parent_scope,
None,
path_span,
&ribs.unwrap()[ValueNS],
) {
// Name matches a local variable. For example:
// ```
// fn f() {
// let Foo: &str = "";
// println!("{}", Foo::Bar); // Name refers to local
// // variable `Foo`.
// }
// ```
Some(LexicalScopeBinding::Res(Res::Local(id))) => {
Some(*self.pat_span_map.get(&id).unwrap())
}
// Name matches item from a local name binding
// created by `use` declaration. For example:
// ```
// pub Foo: &str = "";
//
// mod submod {
// use super::Foo;
// println!("{}", Foo::Bar); // Name refers to local
// // binding `Foo`.
// }
// ```
Some(LexicalScopeBinding::Item(name_binding)) => {
Some(name_binding.span)
}
_ => None,
};
if let Some(span) = match_span {
Some(( Some((
vec![(span, String::from(""))], vec![(ident.span, pprust::path_to_string(&candidate.path))],
format!("`{}` is defined here, but is not a type", ident), String::from("a similar path exists"),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
)) )),
} else { )
None } else if self.session.edition() == Edition::Edition2015 {
} (format!("maybe a missing crate `{}`?", ident), None)
} else { } else {
None (format!("could not find `{}` in the crate root", ident), None)
}; }
} else if i == 0 {
if ident
.name
.as_str()
.chars()
.next()
.map_or(false, |c| c.is_ascii_uppercase())
{
// Check whether the name refers to an item in the value namespace.
let suggestion = if ribs.is_some() {
let match_span = match self.resolve_ident_in_lexical_scope(
ident,
ValueNS,
parent_scope,
None,
path_span,
&ribs.unwrap()[ValueNS],
) {
// Name matches a local variable. For example:
// ```
// fn f() {
// let Foo: &str = "";
// println!("{}", Foo::Bar); // Name refers to local
// // variable `Foo`.
// }
// ```
Some(LexicalScopeBinding::Res(Res::Local(id))) => {
Some(*self.pat_span_map.get(&id).unwrap())
}
(format!("use of undeclared type `{}`", ident), suggestion) // Name matches item from a local name binding
} else { // created by `use` declaration. For example:
( // ```
format!("use of undeclared crate or module `{}`", ident), // pub Foo: &str = "";
if ident.name == sym::alloc { //
Some(( // mod submod {
vec![], // use super::Foo;
String::from( // println!("{}", Foo::Bar); // Name refers to local
"add `extern crate alloc` to use the `alloc` crate", // // binding `Foo`.
), // }
Applicability::MaybeIncorrect, // ```
)) Some(LexicalScopeBinding::Item(name_binding)) => {
} else { Some(name_binding.span)
self.find_similarly_named_module_or_crate( }
ident.name, _ => None,
&parent_scope.module, };
)
.map(|sugg| { if let Some(span) = match_span {
( Some((
vec![(ident.span, sugg.to_string())], vec![(span, String::from(""))],
String::from( format!(
"there is a crate or module with a similar name", "`{}` is defined here, but is not a type",
ident
), ),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
) ))
}) } else {
}, None
)
}
} else {
let parent = path[i - 1].ident.name;
let parent = match parent {
// ::foo is mounted at the crate root for 2015, and is the extern
// prelude for 2018+
kw::PathRoot if self.session.edition() > Edition::Edition2015 => {
"the list of imported crates".to_owned()
}
kw::PathRoot | kw::Crate => "the crate root".to_owned(),
_ => {
format!("`{}`", parent)
}
};
let mut msg = format!("could not find `{}` in {}", ident, parent);
if ns == TypeNS || ns == ValueNS {
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
if let FindBindingResult::Binding(Ok(binding)) =
find_binding_in_ns(self, ns_to_try)
{
let mut found = |what| {
msg = format!(
"expected {}, found {} `{}` in {}",
ns.descr(),
what,
ident,
parent
)
};
if binding.module().is_some() {
found("module")
} else {
match binding.res() {
def::Res::<NodeId>::Def(kind, id) => found(kind.descr(id)),
_ => found(ns_to_try.descr()),
} }
} else {
None
};
(format!("use of undeclared type `{}`", ident), suggestion)
} else {
(
format!("use of undeclared crate or module `{}`", ident),
if ident.name == sym::alloc {
Some((
vec![],
String::from(
"add `extern crate alloc` to use the `alloc` crate",
),
Applicability::MaybeIncorrect,
))
} else {
self.find_similarly_named_module_or_crate(
ident.name,
&parent_scope.module,
)
.map(|sugg| {
(
vec![(ident.span, sugg.to_string())],
String::from(
"there is a crate or module with a similar name",
),
Applicability::MaybeIncorrect,
)
})
},
)
}
} else {
let parent = path[i - 1].ident.name;
let parent = match parent {
// ::foo is mounted at the crate root for 2015, and is the extern
// prelude for 2018+
kw::PathRoot if self.session.edition() > Edition::Edition2015 => {
"the list of imported crates".to_owned()
}
kw::PathRoot | kw::Crate => "the crate root".to_owned(),
_ => {
format!("`{}`", parent)
} }
}; };
let mut msg = format!("could not find `{}` in {}", ident, parent);
if ns == TypeNS || ns == ValueNS {
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
if let FindBindingResult::Binding(Ok(binding)) =
find_binding_in_ns(self, ns_to_try)
{
let mut found = |what| {
msg = format!(
"expected {}, found {} `{}` in {}",
ns.descr(),
what,
ident,
parent
)
};
if binding.module().is_some() {
found("module")
} else {
match binding.res() {
def::Res::<NodeId>::Def(kind, id) => {
found(kind.descr(id))
}
_ => found(ns_to_try.descr()),
}
}
};
}
(msg, None)
} }
(msg, None) });
};
return PathResult::Failed {
span: ident.span,
label,
suggestion,
is_error_from_last_segment: is_last,
};
} }
} }
} }
@ -3374,7 +3358,6 @@ impl<'a> Resolver<'a> {
&Segment::from_path(path), &Segment::from_path(path),
Some(ns), Some(ns),
parent_scope, parent_scope,
false,
path.span, path.span,
CrateLint::No, CrateLint::No,
) { ) {
@ -3543,7 +3526,7 @@ fn module_to_string(module: Module<'_>) -> Option<String> {
Some(names_to_string(&names)) Some(names_to_string(&names))
} }
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, PartialEq, Debug)]
enum CrateLint { enum CrateLint {
/// Do not issue the lint. /// Do not issue the lint.
No, No,

View file

@ -415,7 +415,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
let mut indeterminate = false; let mut indeterminate = false;
for ns in [TypeNS, ValueNS, MacroNS].iter().copied() { for ns in [TypeNS, ValueNS, MacroNS].iter().copied() {
match self.resolve_path(path, Some(ns), &parent_scope, false, span, CrateLint::No) { match self.resolve_path(path, Some(ns), &parent_scope, span, CrateLint::No) {
PathResult::Module(ModuleOrUniformRoot::Module(_)) => return Ok(true), PathResult::Module(ModuleOrUniformRoot::Module(_)) => return Ok(true),
PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => { PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
return Ok(true); return Ok(true);
@ -579,7 +579,6 @@ impl<'a> Resolver<'a> {
&path, &path,
Some(MacroNS), Some(MacroNS),
parent_scope, parent_scope,
false,
path_span, path_span,
CrateLint::No, CrateLint::No,
) { ) {
@ -1033,9 +1032,8 @@ impl<'a> Resolver<'a> {
&path, &path,
Some(MacroNS), Some(MacroNS),
&parent_scope, &parent_scope,
true,
path_span, path_span,
CrateLint::No, CrateLint::SimplePath(ast::CRATE_NODE_ID),
) { ) {
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => { PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
let res = path_res.base_res(); let res = path_res.base_res();

View file

@ -17,28 +17,18 @@ crate mod foo {
use crate::foo::{bar::{baz::{}}}; use crate::foo::{bar::{baz::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
use crate::foo::{bar::{XX, baz::{}}}; use crate::foo::{bar::{XX, baz::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
use crate::foo::{bar::{baz::{}, baz1::{}}}; use crate::foo::{bar::{baz::{}, baz1::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
fn main() { fn main() {
} }

View file

@ -17,28 +17,18 @@ crate mod foo {
use foo::{bar::{baz::{}}}; use foo::{bar::{baz::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
use foo::{bar::{XX, baz::{}}}; use foo::{bar::{XX, baz::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
use foo::{bar::{baz::{}, baz1::{}}}; use foo::{bar::{baz::{}, baz1::{}}};
//~^ ERROR absolute paths must start with //~^ ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| WARN this is accepted in the current edition
fn main() { fn main() {
} }

View file

@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:17:5 --> $DIR/edition-lint-nested-empty-paths.rs:21:5
|
LL | use foo::{bar::{baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
| |
LL | use foo::{bar::{XX, baz::{}}}; LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@ -31,7 +22,7 @@ LL | use foo::{bar::{XX, baz::{}}};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:23:5 --> $DIR/edition-lint-nested-empty-paths.rs:21:5
| |
LL | use foo::{bar::{XX, baz::{}}}; LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@ -40,25 +31,7 @@ LL | use foo::{bar::{XX, baz::{}}};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:23:5 --> $DIR/edition-lint-nested-empty-paths.rs:27:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
| |
LL | use foo::{bar::{baz::{}, baz1::{}}}; LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@ -67,7 +40,7 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:33:5 --> $DIR/edition-lint-nested-empty-paths.rs:27:5
| |
LL | use foo::{bar::{baz::{}, baz1::{}}}; LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@ -75,23 +48,5 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: aborting due to 5 previous errors
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 10 previous errors

View file

@ -8,10 +8,6 @@ use crate::foo::{a, b};
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
mod foo { mod foo {
crate fn a() {} crate fn a() {}
@ -29,8 +25,6 @@ fn main() {
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
x::a(); x::a();
c(); c();
} }

View file

@ -8,10 +8,6 @@ use foo::{a, b};
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
mod foo { mod foo {
crate fn a() {} crate fn a() {}
@ -29,8 +25,6 @@ fn main() {
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with //~| ERROR absolute paths must start with
//~| this is accepted in the current edition //~| this is accepted in the current edition
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
x::a(); x::a();
c(); c();
} }

View file

@ -22,25 +22,7 @@ LL | use foo::{a, b};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:6:5 --> $DIR/edition-lint-nested-paths.rs:23:13
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:6:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:27:13
| |
LL | use foo::{self as x, c}; LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@ -49,7 +31,7 @@ LL | use foo::{self as x, c};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:27:13 --> $DIR/edition-lint-nested-paths.rs:23:13
| |
LL | use foo::{self as x, c}; LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@ -57,14 +39,5 @@ LL | use foo::{self as x, c};
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: aborting due to 4 previous errors
--> $DIR/edition-lint-nested-paths.rs:27:13
|
LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 7 previous errors

View file

@ -12,8 +12,6 @@ pub mod foo {
use crate::bar::Bar; use crate::bar::Bar;
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
use super::bar::Bar2; use super::bar::Bar2;
use crate::bar::Bar3; use crate::bar::Bar3;
@ -42,8 +40,6 @@ pub mod foo {
use crate::bar::Bar; use crate::bar::Bar;
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
pub mod bar { pub mod bar {
use edition_lint_paths as foo; use edition_lint_paths as foo;
@ -61,8 +57,6 @@ mod baz {
impl crate::foo::SomeTrait for u32 {} impl crate::foo::SomeTrait for u32 {}
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
fn main() { fn main() {
let x = crate::bar::Bar; let x = crate::bar::Bar;

View file

@ -12,8 +12,6 @@ pub mod foo {
use bar::Bar; use bar::Bar;
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
use super::bar::Bar2; use super::bar::Bar2;
use crate::bar::Bar3; use crate::bar::Bar3;
@ -42,8 +40,6 @@ pub mod foo {
use bar::Bar; use bar::Bar;
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
pub mod bar { pub mod bar {
use edition_lint_paths as foo; use edition_lint_paths as foo;
@ -61,8 +57,6 @@ mod baz {
impl ::foo::SomeTrait for u32 {} impl ::foo::SomeTrait for u32 {}
//~^ ERROR absolute //~^ ERROR absolute
//~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
fn main() { fn main() {
let x = ::bar::Bar; let x = ::bar::Bar;

View file

@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:12:9 --> $DIR/edition-lint-paths.rs:19:9
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:21:9
| |
LL | use bar; LL | use bar;
| ^^^ help: use `crate`: `crate::bar` | ^^^ help: use `crate`: `crate::bar`
@ -31,7 +22,7 @@ LL | use bar;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:27:9 --> $DIR/edition-lint-paths.rs:25:9
| |
LL | use {main, Bar as SomethingElse}; LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -40,7 +31,7 @@ LL | use {main, Bar as SomethingElse};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:27:9 --> $DIR/edition-lint-paths.rs:25:9
| |
LL | use {main, Bar as SomethingElse}; LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -49,7 +40,7 @@ LL | use {main, Bar as SomethingElse};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:27:9 --> $DIR/edition-lint-paths.rs:25:9
| |
LL | use {main, Bar as SomethingElse}; LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@ -58,7 +49,7 @@ LL | use {main, Bar as SomethingElse};
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:42:5 --> $DIR/edition-lint-paths.rs:40:5
| |
LL | use bar::Bar; LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar` | ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@ -67,16 +58,7 @@ LL | use bar::Bar;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:42:5 --> $DIR/edition-lint-paths.rs:52:9
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:56:9
| |
LL | use *; LL | use *;
| ^ help: use `crate`: `crate::*` | ^ help: use `crate`: `crate::*`
@ -85,7 +67,7 @@ LL | use *;
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:61:6 --> $DIR/edition-lint-paths.rs:57:6
| |
LL | impl ::foo::SomeTrait for u32 {} LL | impl ::foo::SomeTrait for u32 {}
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
@ -94,16 +76,7 @@ LL | impl ::foo::SomeTrait for u32 {}
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:61:6 --> $DIR/edition-lint-paths.rs:62:13
|
LL | impl ::foo::SomeTrait for u32 {}
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:68:13
| |
LL | let x = ::bar::Bar; LL | let x = ::bar::Bar;
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@ -111,5 +84,5 @@ LL | let x = ::bar::Bar;
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 12 previous errors error: aborting due to 9 previous errors

View file

@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
use crate::my_crate::foo; use crate::my_crate::foo;
//~^ ERROR absolute paths must start //~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition //~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() { fn main() {
foo(); foo();

View file

@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
use my_crate::foo; use my_crate::foo;
//~^ ERROR absolute paths must start //~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition //~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() { fn main() {
foo(); foo();

View file

@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: aborting due to previous error
--> $DIR/extern-crate-rename.rs:12:5
|
LL | use my_crate::foo;
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 2 previous errors

View file

@ -19,9 +19,6 @@ mod m {
use crate::m::edition_lint_paths::foo; use crate::m::edition_lint_paths::foo;
//~^ ERROR absolute paths must start //~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition //~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() { fn main() {
foo(); foo();

View file

@ -19,9 +19,6 @@ mod m {
use m::edition_lint_paths::foo; use m::edition_lint_paths::foo;
//~^ ERROR absolute paths must start //~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition //~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() { fn main() {
foo(); foo();

View file

@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition error: aborting due to previous error
--> $DIR/extern-crate-submod.rs:19:5
|
LL | use m::edition_lint_paths::foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 2 previous errors