1
Fork 0

Don't trigger unused_qualifications on global paths

# Conflicts:
#	tests/ui/lint/lint-qualification.stderr
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-03-15 14:59:05 +00:00
parent accc516128
commit 85bad8d1bf
No known key found for this signature in database
GPG key ID: 95DDEBD74A1DC2C0
5 changed files with 30 additions and 25 deletions

View file

@ -4645,6 +4645,13 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
}
fn lint_unused_qualifications(&mut self, path: &[Segment], ns: Namespace, finalize: Finalize) {
// Don't lint on global paths because the user explicitly wrote out the full path.
if let Some(seg) = path.first()
&& seg.ident.name == kw::PathRoot
{
return;
}
if path.iter().any(|seg| seg.ident.span.from_expansion()) {
return;
}