Skip to content

Skip trivial cast lint for trait object upcasts#159061

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-148219-trivial-casts-dyn-any
Jul 14, 2026
Merged

Skip trivial cast lint for trait object upcasts#159061
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-148219-trivial-casts-dyn-any

Conversation

@chenyukang

@chenyukang chenyukang commented Jul 10, 2026

Copy link
Copy Markdown
Member

Fixes #148219

In the case like (other as &dyn Any).downcast_ref::<T>(), removing the cast can change method lookup, so the cast is not always trivial, so skip lint on it.

@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 Jul 10, 2026
@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

r? @khyperia

rustbot has assigned @khyperia.
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:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

@chenyukang chenyukang force-pushed the yukang-fix-148219-trivial-casts-dyn-any branch from ce87ffa to 742e489 Compare July 10, 2026 09:30
@chenyukang chenyukang force-pushed the yukang-fix-148219-trivial-casts-dyn-any branch from 742e489 to d7418a0 Compare July 10, 2026 09:31
@khyperia

Copy link
Copy Markdown
Contributor

apologies, I've fallen ill and probably won't get around to reviewing this for a while, so I'm rerolling

r? compiler

@rustbot rustbot assigned folkertdev and unassigned khyperia Jul 13, 2026
@folkertdev

Copy link
Copy Markdown
Contributor

Right, that makes sense, thanks!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d7418a0 has been approved by folkertdev

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 Jul 13, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 14, 2026
…al-casts-dyn-any, r=folkertdev

Skip trivial cast lint for trait object upcasts

Fixes rust-lang#148219

In the case like `(other as &dyn Any).downcast_ref::<T>()`, removing the cast can change method lookup, so the cast is not always trivial, so skip lint on it.
rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
Rollup of 6 pull requests

Successful merges:

 - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
 - #156047 (Fix trait method resolution on an adjusted never type)
 - #159061 (Skip trivial cast lint for trait object upcasts)
 - #159241 (Update books)
 - #159248 (compiler: Remove `-Zmutable-noalias`)
 - #159250 (Rename `errors.rs` file to `diagnostics.rs` (13/N))
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 14, 2026
…al-casts-dyn-any, r=folkertdev

Skip trivial cast lint for trait object upcasts

Fixes rust-lang#148219

In the case like `(other as &dyn Any).downcast_ref::<T>()`, removing the cast can change method lookup, so the cast is not always trivial, so skip lint on it.
rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
Rollup of 6 pull requests

Successful merges:

 - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
 - #156047 (Fix trait method resolution on an adjusted never type)
 - #158981 (Fix where-bound suggestion with legacy const generics)
 - #159061 (Skip trivial cast lint for trait object upcasts)
 - #159248 (compiler: Remove `-Zmutable-noalias`)
 - #159250 (Rename `errors.rs` file to `diagnostics.rs` (13/N))
rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
Rollup of 6 pull requests

Successful merges:

 - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
 - #158981 (Fix where-bound suggestion with legacy const generics)
 - #159061 (Skip trivial cast lint for trait object upcasts)
 - #159241 (Update books)
 - #159248 (compiler: Remove `-Zmutable-noalias`)
 - #159250 (Rename `errors.rs` file to `diagnostics.rs` (13/N))
@rust-bors rust-bors Bot merged commit 7035da7 into rust-lang:main Jul 14, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 14, 2026
rust-timer added a commit that referenced this pull request Jul 14, 2026
Rollup merge of #159061 - chenyukang:yukang-fix-148219-trivial-casts-dyn-any, r=folkertdev

Skip trivial cast lint for trait object upcasts

Fixes #148219

In the case like `(other as &dyn Any).downcast_ref::<T>()`, removing the cast can change method lookup, so the cast is not always trivial, so skip lint on it.
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.

trivial_casts diagnostic creates spurious errors when working with Any

4 participants