Skip to content

Commit cf07525

Browse files
committed
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 rust-lang#133426.
1 parent e5c1d1c commit cf07525

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
34893489
// a::b::c ::d::sym refers to
34903490
// e::f::sym:: ::
34913491
// result should be super::super::super::super::e::f
3492-
if let DefPathData::TypeNs(s) = l {
3492+
if let DefPathData::TypeNs(Some(s)) = l {
34933493
path.push(s.to_string());
34943494
}
34953495
if let DefPathData::TypeNs(_) = r {
@@ -3500,7 +3500,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
35003500
// a::b::sym:: :: refers to
35013501
// c::d::e ::f::sym
35023502
// when looking at `f`
3503-
Left(DefPathData::TypeNs(sym)) => path.push(sym.to_string()),
3503+
Left(DefPathData::TypeNs(Some(sym))) => path.push(sym.to_string()),
35043504
// consider:
35053505
// a::b::c ::d::sym refers to
35063506
// e::f::sym:: ::
@@ -3514,7 +3514,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
35143514
// `super` chain would be too long, just use the absolute path instead
35153515
once(String::from("crate"))
35163516
.chain(to.data.iter().filter_map(|el| {
3517-
if let DefPathData::TypeNs(sym) = el.data {
3517+
if let DefPathData::TypeNs(Some(sym)) = el.data {
35183518
Some(sym.to_string())
35193519
} else {
35203520
None

0 commit comments

Comments
 (0)