1
Fork 0

Rollup merge of #139880 - compiler-errors:rpitit-nameless, r=nnethercote

Don't compute name of associated item if it's an RPITIT

Use `Option::then` in favor of `Option::then_some` to not compute `AssocItem::name` if it fails the condition. Alternatively, I'd be open to changing this just to an `if`.

Fixes https://github.com/rust-lang/rust/issues/139873

r? ```@nnethercote```
This commit is contained in:
Matthias Krüger 2025-04-16 13:45:30 +02:00 committed by GitHub
commit ec6bdda983
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 2 deletions

View file

@ -204,8 +204,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.iter()
.flat_map(|trait_def_id| tcx.associated_items(*trait_def_id).in_definition_order())
.filter_map(|item| {
(!item.is_impl_trait_in_trait() && item.as_tag() == assoc_tag)
.then_some(item.name())
(!item.is_impl_trait_in_trait() && item.as_tag() == assoc_tag).then(|| item.name())
})
.collect();