Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip suggest impl or dyn when poly trait is not a real trait #139200

Merged
merged 2 commits into from
Apr 2, 2025

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Apr 1, 2025

Fixes #139174
When poly_trait_ref is not a real trait, we should stop suggesting impl and dyn to avoid false positives. 3 cases were added to the ui test.

if self_ty.span.can_be_used_for_suggestions()
&& !self.maybe_suggest_impl_trait(self_ty, &mut diag)
&& !self.maybe_suggest_dyn_trait(self_ty, sugg, &mut diag)
{
self.maybe_suggest_add_generic_impl_trait(self_ty, &mut diag);
}

In the first commit, I submitted the test and passed it. In the second commit, I modified the code and we can see the changes in the test.

r? compiler

xizheyin added 2 commits April 1, 2025 14:27
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@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 Apr 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 1, 2025

HIR ty lowering was modified

cc @fmease

@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 1, 2025

📌 Commit 12604fa has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors 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 Apr 1, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2025
Rollup of 14 pull requests

Successful merges:

 - rust-lang#135295 (Check empty SIMD vector in inline asm)
 - rust-lang#138003 (Add the new `amx` target features and the `movrs` target feature)
 - rust-lang#138823 (rustc_target: RISC-V: add base `I`-related important extensions)
 - rust-lang#138913 (Remove even more instances of `@ts-expect-error` from search.js)
 - rust-lang#138941 (Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable`)
 - rust-lang#139060 (replace commit placeholder in vendor status with actual commit)
 - rust-lang#139102 (coverage: Avoid splitting spans during span extraction/refinement)
 - rust-lang#139191 (small opaque type/borrowck cleanup)
 - rust-lang#139200 (Skip suggest impl or dyn when poly trait is not a real trait)
 - rust-lang#139208 (fix dead link netbsd.md)
 - rust-lang#139210 (chore: remove redundant backtick)
 - rust-lang#139212 (Update mdbook to 0.4.48)
 - rust-lang#139214 (Tell rustfmt to use the 2024 edition in ./x.py fmt)
 - rust-lang#139225 (move autodiff from EnzymeAD/Enzyme to our rust-lang/Enzyme soft-fork)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2d43a8b into rust-lang:master Apr 2, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 2, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2025
Rollup merge of rust-lang#139200 - xizheyin:issue-139174, r=compiler-errors

Skip suggest impl or dyn when poly trait is not a real trait

Fixes rust-lang#139174
When `poly_trait_ref` is not a real trait, we should stop suggesting `impl` and `dyn` to avoid false positives. 3 cases were added to the ui test.
https://github.com/rust-lang/rust/blob/0b45675cfcec57f30a3794e1a1e18423aa9cf200/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs#L88-L93

In the first commit, I submitted the test and passed it. In the second commit, I modified the code and we can see the changes in the test.

r? compiler
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.

Invalid suggestion to add dyn to something that is not a trait
5 participants