diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-06 03:56:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-06 03:56:09 +0200 |
| commit | 83d84ffdd5efc9ea00e959b2c73a7f897673ee68 (patch) | |
| tree | 09e6fcc5d9b8eb3d0cbee6984ae41e44365e233c | |
| parent | 1305a43d0a0c02cb224ab626745bd94af59c6098 (diff) | |
| parent | c9be1a71b69fb99f9a10b1ba058138d374b5b3a9 (diff) | |
| download | rust-83d84ffdd5efc9ea00e959b2c73a7f897673ee68.tar.gz rust-83d84ffdd5efc9ea00e959b2c73a7f897673ee68.zip | |
Rollup merge of #114503 - chenyukang:yukang-fix-114433-unused-qualifications, r=compiler-errors
Remove invalid lint when there is a generic argument in prefix path Fixes #114433
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 3 | ||||
| -rw-r--r-- | tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 7b590d16d8c..06da00f1135 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3944,11 +3944,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { if path.len() > 1 && let Some(res) = result.full_res() + && let Some((&last_segment, prev_segs)) = path.split_last() + && prev_segs.iter().all(|seg| !seg.has_generic_args) && res != Res::Err && path[0].ident.name != kw::PathRoot && path[0].ident.name != kw::DollarCrate { - let last_segment = *path.last().unwrap(); let unqualified_result = { match self.resolve_path(&[last_segment], Some(ns), None) { PathResult::NonModule(path_res) => path_res.expect_full_res(), diff --git a/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs b/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs new file mode 100644 index 00000000000..83349dd3350 --- /dev/null +++ b/tests/ui/resolve/issue-114433-invalid-unused-qualifications-suggestion.rs @@ -0,0 +1,10 @@ +#![deny(unused_qualifications)] +// check-pass +fn bar() { + match Option::<Option<()>>::None { + Some(v) => {} + None => {} + } +} + +fn main() {} |
