Skip to content

traits: Fix dead match arm for String type suggestions. - #166506

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
hardikxk:rtc/suggest-string
Nov 26, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
hardikxk:rtc/suggest-string

Conversation

@hardikxk

@hardikxk hardikxk commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The existing arm was trying to match with a diagnostic named "String", which doesn't exist and was dead code that never actually matched any case.

Replace and fix the match condition by matching the definition id with the String LangItem instead as String exists as a LangItem and not a diagnostic item.

closes #166392

@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 Nov 24, 2026
@rustbot

rustbot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
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, types
  • compiler, types expanded to 79 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

This comment has been minimized.

@nnethercote

Copy link
Copy Markdown
Contributor

Basically looks good. Two suggestions:

  • Remove the Signed-off-by lines in the commit messages; this project doesn't use those.
  • Reduce the changes to two commits: the first one that updates the test, and the second one that makes the code change and updates the test output. That way the tests pass on every commit, and it makes reviewing easier.

Thanks! @rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2026
@rustbot

rustbot commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@hardikxk

Copy link
Copy Markdown
Contributor Author
* Remove the `Signed-off-by` lines in the commit messages; this project doesn't use those.

Oh sure I'll keep that in mind from future.

@hardikxk

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 25, 2026
@nnethercote

Copy link
Copy Markdown
Contributor

the first one that updates the test, and the second one that makes the code change and updates the test output.

You made the code changes in the first commit and the test changes in the second commit, which is not what I requested.

The point is that the tests should pass for each commit, rather than "the first commit breaks tests, the second commit fixes tests".

@hardikxk

Copy link
Copy Markdown
Contributor Author

the first one that updates the test, and the second one that makes the code change and updates the test output.

You made the code changes in the first commit and the test changes in the second commit, which is not what I requested.

Sorry, I didn't read that properly the first time :<

The existing arm was trying to match with a diagnostic named "String",
which doesn't exist and was dead code that never actually matched any
case.

Replace and fix the match condition by matching the definition id with
the `String` `LangItem` instead as `String` exists as a LangItem and not
a diagnostic item.

Update tests that were affecting by this change.
@nnethercote

Copy link
Copy Markdown
Contributor

It's nice, right? You can see the code change and the effect on the tests all in the second commit.

@bors r+

@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit eb8fa57 has been tentatively approved by nnethercote

It will be put into the queue for this repository once PR CI succeeds.

@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 Nov 26, 2026
@hardikxk

Copy link
Copy Markdown
Contributor Author

It's nice, right? You can see the code change and the effect on the tests all in the second commit.

Yeaa it does look much better. Thankss! :)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 26, 2026
…thercote

traits: Fix dead match arm for String type suggestions.

The existing arm was trying to match with a diagnostic named "String", which doesn't exist and was dead code that never actually matched any case.

Replace and fix the match condition by matching the definition id with the `String` `LangItem` instead as `String` exists as a LangItem and not a diagnostic item.

closes rust-lang#166392
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - #166156 (tests: cover proc-macro metadata path remapping)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
 - #166562 (docs: add backticks around `!` in primitive docs )
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - #166156 (tests: cover proc-macro metadata path remapping)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
 - #166562 (docs: add backticks around `!` in primitive docs )
@rust-bors
rust-bors Bot merged commit 16a75a8 into rust-lang:main Nov 26, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
Rollup merge of #166506 - hardikxk:rtc/suggest-string, r=nnethercote

traits: Fix dead match arm for String type suggestions.

The existing arm was trying to match with a diagnostic named "String", which doesn't exist and was dead code that never actually matched any case.

Replace and fix the match condition by matching the definition id with the `String` `LangItem` instead as `String` exists as a LangItem and not a diagnostic item.

closes #166392
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#164252 (Share retain implementation between Vec and VecDeque)
 - rust-lang/rust#166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - rust-lang/rust#166156 (tests: cover proc-macro metadata path remapping)
 - rust-lang/rust#166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - rust-lang/rust#166506 (traits: Fix dead match arm for String type suggestions.)
 - rust-lang/rust#164542 (Add regression test for rust-lang/rust#151312)
 - rust-lang/rust#165651 (compiletest: Further clean up directive parsing)
 - rust-lang/rust#166196 (autodiff: don't ICE on invalid macro arguments)
 - rust-lang/rust#166556 (remove `Box::into_boxed_slice`)
 - rust-lang/rust#166562 (docs: add backticks around `!` in primitive docs )
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.

ty_kind_suggestion never matches String, so E0381 and E0069 suggest Default::default() instead of String::new()

4 participants