Skip to content

Commit 3b4fd29

Browse files
committed
Handle edition lint for absolute paths not starting with crate in the case of non-module item
fixes rust-lang#50660
1 parent fe63e47 commit 3b4fd29

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/librustc_resolve/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -3324,6 +3324,24 @@ impl<'a> Resolver<'a> {
33243324
Some(LexicalScopeBinding::Item(binding)) => Ok(binding),
33253325
Some(LexicalScopeBinding::Def(def))
33263326
if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => {
3327+
3328+
if let Some(id) = node_id {
3329+
if i == 1 && self.session.features_untracked().crate_in_paths
3330+
&& !self.session.rust_2018() {
3331+
let prev_name = path[0].name;
3332+
if prev_name == keywords::Extern.name() ||
3333+
prev_name == keywords::CrateRoot.name() {
3334+
let diag = lint::builtin::BuiltinLintDiagnostics
3335+
::AbsPathWithModule(path_span);
3336+
self.session.buffer_lint_with_diagnostic(
3337+
lint::builtin::ABSOLUTE_PATH_STARTING_WITH_MODULE,
3338+
id, path_span,
3339+
"Absolute paths must start with `self`, `super`, \
3340+
`crate`, or an external crate name in the 2018 edition",
3341+
diag);
3342+
}
3343+
}
3344+
}
33273345
return PathResult::NonModule(PathResolution::with_unresolved_segments(
33283346
def, path.len() - 1
33293347
));

0 commit comments

Comments
 (0)