Skip to content

Conversation

@fmease
Copy link
Member

@fmease fmease commented Feb 6, 2026

  • remove suggestion from the diagnostic message (bad style, too long) and turn it into a structured suggestion
  • replace object type with trait object type since the former is an outdated term

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • People who recently interacted with files modified in this PR: compiler
  • compiler expanded to 20 candidates
  • Random selection from 11 candidates

Comment on lines +318 to +319
// FIXME: Account for trailing plus `dyn Trait+`, the need of parens in
// `*const dyn Trait` and `Fn() -> *const dyn Trait`.
Copy link
Member Author

@fmease fmease Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided against fixing these ~minor issues in this PR because it's a rabbit hole I didn't want to pursue at the moment:

Most diagnostics in the compiler that suggest adding + /* bound */ to a type don't consider both last cases mentioned in the FIXME above (and I bet none properly account for trailing pluses1). E.g., suggest_new_region_bound (see FIXME).

We do have some helpers in place for cases like this like hir::Generics::bounds_span_for_suggestions but it's not general enough (e.g., I can't use it here) & it doesn't account for everything (like raw pointers).

I hope this paints a clear enough picture. I'd rather fix a bunch of these diagnostic suggestions at once in a separate future PR by providing better HIR helpers for these cases. I'm already tracking this in my internal issue tracker (and I might upstream this issue to r-l/r if I won't get to write a PR soon-ish). From a technical standpoint, it shouldn't be hard at all, you just need to check the parent & the child of the HIR type. I just really want to avoid duplicating code for this.

Footnotes

  1. Since trailing pluses aren't represented in the AST, HIR etc. and you can't just trim & contains('+')-check the relevant part of the source text as obtained via source_map() since it wouldn't account for source code comments; you'd actually need to re-lex the snippet (which is overkill for such a niche issue)

@fmease
Copy link
Member Author

fmease commented Feb 6, 2026

This PR conflicts with #152076 which I'm assigned to and which I'll hopefully review today. Can't tell yet which one's more likely to get merged first.

@chenyukang
Copy link
Member

@bors r=chenyukang

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

📌 Commit dc24aae has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 10, 2026
…ect-lifetime-diag, r=chenyukang

Modernize diagnostic for indeterminate trait object lifetime bounds

* remove suggestion from the diagnostic message (bad style, too long) and turn it into a structured suggestion
* replace *object type* with *trait object type* since the former is an outdated term
rust-bors bot pushed a commit that referenced this pull request Feb 10, 2026
Rollup of 7 pull requests

Successful merges:

 - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes)
 - #151954 (Add help message suggesting explicit reference cast for From/TryFrom)
 - #152148 (Move `impl Interner for TyCtxt` to its own submodule)
 - #152226 (Modernize diagnostic for indeterminate trait object lifetime bounds)
 - #150688 (typeck: Make it clearer that `check_pat_lit` only handles literal patterns)
 - #152293 (Format heterogeneous try blocks)
 - #152396 (Uplift `Predicate::allow_normalization` to `rustc_type_ir`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 10, 2026
…ect-lifetime-diag, r=chenyukang

Modernize diagnostic for indeterminate trait object lifetime bounds

* remove suggestion from the diagnostic message (bad style, too long) and turn it into a structured suggestion
* replace *object type* with *trait object type* since the former is an outdated term
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 10, 2026
…ect-lifetime-diag, r=chenyukang

Modernize diagnostic for indeterminate trait object lifetime bounds

* remove suggestion from the diagnostic message (bad style, too long) and turn it into a structured suggestion
* replace *object type* with *trait object type* since the former is an outdated term
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 10, 2026
…ect-lifetime-diag, r=chenyukang

Modernize diagnostic for indeterminate trait object lifetime bounds

* remove suggestion from the diagnostic message (bad style, too long) and turn it into a structured suggestion
* replace *object type* with *trait object type* since the former is an outdated term
rust-bors bot pushed a commit that referenced this pull request Feb 10, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #152364 (Port a lot of attributes to the new parser)
 - #151954 (Add help message suggesting explicit reference cast for From/TryFrom)
 - #152148 (Move `impl Interner for TyCtxt` to its own submodule)
 - #152226 (Modernize diagnostic for indeterminate trait object lifetime bounds)
 - #152351 (Remove `SubdiagMessage` in favour of the identical `DiagMessage`)
 - #152417 (Move the needs-drop check for `arena_cache` queries out of macro code)
 - #150688 (typeck: Make it clearer that `check_pat_lit` only handles literal patterns)
 - #152293 (Format heterogeneous try blocks)
 - #152355 (Update documentation of rustc_macros)
 - #152396 (Uplift `Predicate::allow_normalization` to `rustc_type_ir`)
 - #152425 (Port #![test_runner] to the attribute parser)
rust-bors bot pushed a commit that referenced this pull request Feb 10, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #152364 (Port a lot of attributes to the new parser)
 - #151954 (Add help message suggesting explicit reference cast for From/TryFrom)
 - #152148 (Move `impl Interner for TyCtxt` to its own submodule)
 - #152226 (Modernize diagnostic for indeterminate trait object lifetime bounds)
 - #152351 (Remove `SubdiagMessage` in favour of the identical `DiagMessage`)
 - #152417 (Move the needs-drop check for `arena_cache` queries out of macro code)
 - #150688 (typeck: Make it clearer that `check_pat_lit` only handles literal patterns)
 - #152293 (Format heterogeneous try blocks)
 - #152355 (Update documentation of rustc_macros)
 - #152396 (Uplift `Predicate::allow_normalization` to `rustc_type_ir`)
@rust-bors rust-bors bot merged commit 2af7bc0 into rust-lang:main Feb 10, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 10, 2026
@fmease fmease deleted the modernize-indeterminate-object-lifetime-diag branch February 10, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants