diff options
| author | yukang <moorekang@gmail.com> | 2023-08-05 15:58:26 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2023-08-05 15:58:26 +0800 |
| commit | c9be1a71b69fb99f9a10b1ba058138d374b5b3a9 (patch) | |
| tree | 20f75d34e5e01749b55c6e08124f6c5adf4c50d4 | |
| parent | fca59ab5f0e7df7d816bed77a32abc0045ebe80b (diff) | |
| download | rust-c9be1a71b69fb99f9a10b1ba058138d374b5b3a9.tar.gz rust-c9be1a71b69fb99f9a10b1ba058138d374b5b3a9.zip | |
Remove invalid lint when there is a generic argument in prefix path
| -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() {} |
