1
Fork 0
rust/compiler/rustc_trait_selection/src
Nicholas Nethercote 8d2c63f514 Don't use kw::Empty in hir::Lifetime::ident.
`hir::Lifetime::ident` currently sometimes uses `kw::Empty` for elided
lifetimes and sometimes uses `kw::UnderscoreLifetime`, and the
distinction is used when creating some error suggestions, e.g. in
`Lifetime::suggestion` and `ImplicitLifetimeFinder::visit_ty`. I found
this *really* confusing, and it took me a while to understand what was
going on.

This commit replaces all uses of `kw::Empty` in `hir::Lifetime::ident`
with `kw::UnderscoreLifetime`. It adds a new field
`hir::Lifetime::is_path_anon` that mostly replaces the old
empty/underscore distinction and makes things much clearer.

Some other notable changes:

- Adds a big comment to `Lifetime` talking about permissable field
  values.

- Adds some assertions in `new_named_lifetime` about what ident values
  are permissible for the different `LifetimeRes` values.

- Adds a `Lifetime::new` constructor that does some checking to make
  sure the `is_elided` and `is_anonymous` states are valid.

- `add_static_impl_trait_suggestion` now looks at `Lifetime::res`
  instead of the ident when creating the suggestion. This is the one
  case where `is_path_anon` doesn't replace the old empty/underscore
  distinction.

- A couple of minor pretty-printing improvements.
2025-03-28 10:15:23 +11:00
..
error_reporting Use Option<Ident> for lowered param names. 2025-03-19 20:54:10 +11:00
errors Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
solve Obligation::as_goal 2025-03-23 18:18:47 +00:00
traits Auto merge of #139012 - Zalathar:rollup-qgt5yfo, r=Zalathar 2025-03-27 07:47:39 +00:00
errors.rs Don't use kw::Empty in hir::Lifetime::ident. 2025-03-28 10:15:23 +11:00
infer.rs Fix next solver handling of shallow trait impl check 2025-03-19 14:40:14 +00:00
lib.rs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
regions.rs Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack 2025-03-04 18:18:48 +00:00
solve.rs impossible obligations check fast path 2024-10-10 06:09:50 -04:00