Skip to content

Commit a7b37fa

Browse files
committed
Don't trigger unused_qualifications on global paths
1 parent 9ce37dc commit a7b37fa

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler/rustc_resolve/src/late.rs

+7
Original file line numberDiff line numberDiff line change
@@ -4636,6 +4636,13 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
46364636
}
46374637

46384638
fn lint_unused_qualifications(&mut self, path: &[Segment], ns: Namespace, finalize: Finalize) {
4639+
// Don't lint on global paths because the user explicitly wrote out the full path.
4640+
if let Some(seg) = path.first()
4641+
&& seg.ident.name == kw::PathRoot
4642+
{
4643+
return;
4644+
}
4645+
46394646
if path.iter().any(|seg| seg.ident.span.from_expansion()) {
46404647
return;
46414648
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Checks that `unused_qualifications` don't fire on explicit global paths.
2+
// Issue: <https://github.com/rust-lang/rust/issues/122374>.
3+
4+
//@ check-pass
5+
6+
#![deny(unused_qualifications)]
7+
8+
pub fn bar() -> u64 {
9+
::std::default::Default::default()
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)