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 @@ fn resolve_visibility_speculative<'ast>(
&segments,
Some(TypeNS),
parent_scope,
!speculative,
path.span,
CrateLint::SimplePath(id),
if speculative { CrateLint::No } else { CrateLint::SimplePath(id) },
) {
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
let res = module.res().expect("visibility resolved to unnamed block");

View File

@ -1426,7 +1426,7 @@ fn make_missing_self_suggestion(
) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `self` and check if that is valid.
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);
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
}
@ -1446,7 +1446,7 @@ fn make_missing_crate_suggestion(
) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `crate` and check if that is valid.
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);
if let PathResult::Module(..) = result {
Some((
@ -1478,7 +1478,7 @@ fn make_missing_super_suggestion(
) -> Option<(Vec<Segment>, Vec<String>)> {
// Replace first ident with `crate` and check if that is valid.
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);
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
}
@ -1513,7 +1513,7 @@ fn make_external_crate_suggestion(
for name in extern_crate_names.into_iter() {
// Replace first ident with a crate name and check if that is valid.
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!(
"make_external_crate_suggestion: name={:?} path={:?} result={:?}",
name, path, result

View File

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

View File

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

View File

@ -188,7 +188,7 @@ pub(crate) fn smart_resolve_report_errors(
} else {
let mod_path = &path[..path.len() - 1];
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(),
_ => None,
}
@ -648,7 +648,7 @@ fn get_single_associated_item(
if let crate::PathSource::TraitItem(_) = source {
let mod_path = &path[..path.len() - 1];
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 targets: Vec<_> =
@ -1384,7 +1384,7 @@ fn lookup_typo_candidate(
// Search in module.
let mod_path = &path[..path.len() - 1];
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);
}

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)]
enum ModuleKind {
/// An anonymous module; e.g., just a block.
@ -2206,19 +2219,10 @@ fn resolve_path(
path: &[Segment],
opt_ns: Option<Namespace>, // `None` indicates a module path in import
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint,
) -> PathResult<'a> {
self.resolve_path_with_ribs(
path,
opt_ns,
parent_scope,
record_used,
path_span,
crate_lint,
None,
)
self.resolve_path_with_ribs(path, opt_ns, parent_scope, path_span, crate_lint, None)
}
fn resolve_path_with_ribs(
@ -2226,19 +2230,18 @@ fn resolve_path_with_ribs(
path: &[Segment],
opt_ns: Option<Namespace>, // `None` indicates a module path in import
parent_scope: &ParentScope<'a>,
record_used: bool,
path_span: Span,
crate_lint: CrateLint,
ribs: Option<&PerNS<Vec<Rib<'a>>>>,
) -> PathResult<'a> {
let record_used = crate_lint != CrateLint::No;
let mut module = None;
let mut allow_super = true;
let mut second_binding = None;
debug!(
"resolve_path(path={:?}, opt_ns={:?}, record_used={:?}, \
path_span={:?}, crate_lint={:?})",
path, opt_ns, record_used, path_span, crate_lint,
"resolve_path(path={:?}, opt_ns={:?}, path_span={:?}, crate_lint={:?})",
path, opt_ns, path_span, crate_lint,
);
for (i, &Segment { ident, id, has_generic_args: _ }) in path.iter().enumerate() {
@ -2278,13 +2281,9 @@ fn resolve_path_with_ribs(
continue;
}
}
let msg = "there are too many leading `super` keywords".to_string();
return PathResult::Failed {
span: ident.span,
label: msg,
suggestion: None,
is_error_from_last_segment: false,
};
return PathResult::failed(ident.span, false, record_used, || {
("there are too many leading `super` keywords".to_string(), None)
});
}
if i == 0 {
if name == kw::SelfLower {
@ -2313,22 +2312,19 @@ fn resolve_path_with_ribs(
// Report special messages for path segment keywords in wrong positions.
if ident.is_path_segment_keyword() && i != 0 {
let name_str = if name == kw::PathRoot {
"crate root".to_string()
} else {
format!("`{}`", name)
};
let label = if i == 1 && path[0].ident.name == kw::PathRoot {
format!("global paths cannot start with {}", name_str)
} else {
format!("{} in paths can only be used in start position", name_str)
};
return PathResult::Failed {
span: ident.span,
label,
suggestion: None,
is_error_from_last_segment: false,
};
return PathResult::failed(ident.span, false, record_used, || {
let name_str = if name == kw::PathRoot {
"crate root".to_string()
} else {
format!("`{}`", name)
};
let label = if i == 1 && path[0].ident.name == kw::PathRoot {
format!("global paths cannot start with {}", name_str)
} else {
format!("{} in paths can only be used in start position", name_str)
};
(label, None)
});
}
enum FindBindingResult<'a> {
@ -2356,16 +2352,11 @@ enum FindBindingResult<'a> {
path_span,
)
} 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(
ident,
ns,
parent_scope,
record_used_id,
crate_lint.node_id(),
path_span,
&ribs.unwrap()[ns],
) {
@ -2425,19 +2416,14 @@ enum FindBindingResult<'a> {
path.len() - i - 1,
));
} else {
let label = format!(
"`{}` is {} {}, not a module",
ident,
res.article(),
res.descr(),
);
return PathResult::Failed {
span: ident.span,
label,
suggestion: None,
is_error_from_last_segment: is_last,
};
return PathResult::failed(ident.span, is_last, record_used, || {
let label = format!(
"`{ident}` is {} {}, not a module",
res.article(),
res.descr()
);
(label, None)
});
}
}
Err(Undetermined) => return PathResult::Indeterminate,
@ -2450,171 +2436,169 @@ enum FindBindingResult<'a> {
));
}
}
let module_res = match module {
Some(ModuleOrUniformRoot::Module(module)) => module.res(),
_ => None,
};
let (label, suggestion) = if module_res == self.graph_root.res() {
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()
return PathResult::failed(ident.span, is_last, record_used, || {
let module_res = match module {
Some(ModuleOrUniformRoot::Module(module)) => module.res(),
_ => None,
};
candidates.sort_by_cached_key(|c| {
(c.path.segments.len(), pprust::path_to_string(&c.path))
});
if let Some(candidate) = candidates.get(0) {
(
String::from("unresolved import"),
Some((
vec![(ident.span, pprust::path_to_string(&candidate.path))],
String::from("a similar path exists"),
Applicability::MaybeIncorrect,
)),
)
} 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 {
if module_res == self.graph_root.res() {
let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _));
let mut candidates =
self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod);
candidates.sort_by_cached_key(|c| {
(c.path.segments.len(), pprust::path_to_string(&c.path))
});
if let Some(candidate) = candidates.get(0) {
(
String::from("unresolved import"),
Some((
vec![(span, String::from(""))],
format!("`{}` is defined here, but is not a type", ident),
vec![(ident.span, pprust::path_to_string(&candidate.path))],
String::from("a similar path exists"),
Applicability::MaybeIncorrect,
))
} else {
None
}
)),
)
} else if self.session.edition() == Edition::Edition2015 {
(format!("maybe a missing crate `{}`?", ident), None)
} 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)
} 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",
// 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((
vec![(span, String::from(""))],
format!(
"`{}` is defined here, but is not a type",
ident
),
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()),
))
} else {
None
}
} 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 @@ fn resolve_ast_path(
&Segment::from_path(path),
Some(ns),
parent_scope,
false,
path.span,
CrateLint::No,
) {
@ -3543,7 +3526,7 @@ fn collect_mod(names: &mut Vec<Symbol>, module: Module<'_>) {
Some(names_to_string(&names))
}
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, PartialEq, Debug)]
enum CrateLint {
/// Do not issue the lint.
No,

View File

@ -415,7 +415,7 @@ fn cfg_accessible(
let mut indeterminate = false;
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::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
return Ok(true);
@ -579,7 +579,6 @@ pub fn resolve_macro_path(
&path,
Some(MacroNS),
parent_scope,
false,
path_span,
CrateLint::No,
) {
@ -1033,9 +1032,8 @@ struct Flags: u8 {
&path,
Some(MacroNS),
&parent_scope,
true,
path_span,
CrateLint::No,
CrateLint::SimplePath(ast::CRATE_NODE_ID),
) {
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
let res = path_res.base_res();

View File

@ -17,28 +17,18 @@ crate mod foo {
use crate::foo::{bar::{baz::{}}};
//~^ 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::{XX, baz::{}}};
//~^ 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
//~| 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::{}}};
//~^ 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
//~| 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() {
}

View File

@ -17,28 +17,18 @@
use foo::{bar::{baz::{}}};
//~^ 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::{XX, baz::{}}};
//~^ 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
//~| 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::{}}};
//~^ 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
//~| 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() {
}

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>
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
|
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
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
|
LL | use 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>
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::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ 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>
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: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
--> $DIR/edition-lint-nested-empty-paths.rs:27:5
|
LL | use 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>
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::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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!
= 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: 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
error: aborting due to 5 previous errors

View File

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

View File

@ -8,10 +8,6 @@
//~| 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
//~| ERROR absolute paths must start with
//~| this is accepted in the current edition
mod foo {
crate fn a() {}
@ -29,8 +25,6 @@ fn main() {
//~| 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
x::a();
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>
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: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
--> $DIR/edition-lint-nested-paths.rs:23:13
|
LL | use 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>
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};
| ^^^^^^^^^^^^^^^^^^^ 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!
= 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};
| ^^^^^^^^^^^^^^^^^^^ 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
error: aborting due to 4 previous errors

View File

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

View File

@ -12,8 +12,6 @@ pub mod foo {
use bar::Bar;
//~^ ERROR absolute
//~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
use super::bar::Bar2;
use crate::bar::Bar3;
@ -42,8 +40,6 @@ pub trait SomeTrait {}
use bar::Bar;
//~^ ERROR absolute
//~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
pub mod bar {
use edition_lint_paths as foo;
@ -61,8 +57,6 @@ mod baz {
impl ::foo::SomeTrait for u32 {}
//~^ ERROR absolute
//~| WARN this is accepted in the current edition
//~| ERROR absolute
//~| WARN this is accepted in the current edition
fn main() {
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>
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
|
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
--> $DIR/edition-lint-paths.rs:19:9
|
LL | use 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>
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};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>
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};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>
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};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>
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;
| ^^^^^^^^ 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>
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
|
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
--> $DIR/edition-lint-paths.rs:52:9
|
LL | use *;
| ^ 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>
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 {}
| ^^^^^^^^^^^^^^^^ 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>
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
|
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
--> $DIR/edition-lint-paths.rs:62:13
|
LL | let x = ::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!
= 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;
//~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() {
foo();

View File

@ -12,8 +12,6 @@
use my_crate::foo;
//~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() {
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!
= 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/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
error: aborting due to previous error

View File

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

View File

@ -19,9 +19,6 @@ mod m {
use m::edition_lint_paths::foo;
//~^ ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
//~| ERROR absolute paths must start
//~| WARNING this is accepted in the current edition
fn main() {
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!
= 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/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
error: aborting due to previous error