diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-04 14:34:18 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-07 20:59:45 +1100 |
| commit | cf0752527f1e1b91cff5683b59e49153187d9efe (patch) | |
| tree | 4bf805672d15664f31b1b62c37ce2f0661c2fee7 | |
| parent | e5c1d1cb7ee727246a6d453f52b5707e264387d5 (diff) | |
| download | rust-cf0752527f1e1b91cff5683b59e49153187d9efe.tar.gz rust-cf0752527f1e1b91cff5683b59e49153187d9efe.zip | |
Make synthetic RPITIT assoc ty name handling more rigorous.
Currently it relies on special treatment of `kw::Empty`, which is really easy to get wrong. This commit makes the special case clearer in the type system by using `Option`. It's a bit clumsy, but the synthetic name handling itself is a bit clumsy; better to make it explicit than sneak it in. Fixes #133426.
| -rw-r--r-- | clippy_utils/src/lib.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index d850cc41000..ef706cd076f 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -3489,7 +3489,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St // a::b::c ::d::sym refers to // e::f::sym:: :: // result should be super::super::super::super::e::f - if let DefPathData::TypeNs(s) = l { + if let DefPathData::TypeNs(Some(s)) = l { path.push(s.to_string()); } if let DefPathData::TypeNs(_) = r { @@ -3500,7 +3500,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St // a::b::sym:: :: refers to // c::d::e ::f::sym // when looking at `f` - Left(DefPathData::TypeNs(sym)) => path.push(sym.to_string()), + Left(DefPathData::TypeNs(Some(sym))) => path.push(sym.to_string()), // consider: // a::b::c ::d::sym refers to // e::f::sym:: :: @@ -3514,7 +3514,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St // `super` chain would be too long, just use the absolute path instead once(String::from("crate")) .chain(to.data.iter().filter_map(|el| { - if let DefPathData::TypeNs(sym) = el.data { + if let DefPathData::TypeNs(Some(sym)) = el.data { Some(sym.to_string()) } else { None |
