Skip to content

Don't assume traits used as type are trait objs in 2021 edition - #131239

Merged
bors merged 1 commit into
rust-lang:masterfrom
VulnBandit:trait-vulnerability
Oct 13, 2024
Merged

Don't assume traits used as type are trait objs in 2021 edition#131239
bors merged 1 commit into
rust-lang:masterfrom
VulnBandit:trait-vulnerability

Conversation

@VulnBandit

@VulnBandit VulnBandit commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

Fixes #127548

When you use a trait as a type, the compiler automatically assumes you meant to use a trait object, which is not always the case.
This PR fixes the bug where you don't need a trait object, so the error message was changed to:

error[E0782]: expected a type, found a trait

Also fixes some ICEs:
Fixes #120241
Fixes #120482
Fixes #125512

@rustbot

rustbot commented Oct 4, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Oct 4, 2024
@rustbot

rustbot commented Oct 4, 2024

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@VulnBandit

Copy link
Copy Markdown
Contributor Author

@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 Oct 4, 2024
@jieyouxu

jieyouxu commented Oct 4, 2024

Copy link
Copy Markdown
Member

This PR fixes the vunlnerability where you don't need a trait object

FYI the word "vunlnerability" has a specific meaning (i.e. a weakness that makes something easy to be attacked/exploited) in the context of this repo (e.g. related to compiler or std), but this PR is just trying to improve diagnostics not trying to address an exploit.

@VulnBandit

Copy link
Copy Markdown
Contributor Author

I see vulnerability as when something is not right and I fix it. Ok I will change the word

@jieyouxu

jieyouxu commented Oct 4, 2024

Copy link
Copy Markdown
Member

We usually call those those "bugs" or "diagnostic issues", "vulnerability" usually indicates an exploitable weakness that has to do with security that wg-security-response would need to look at.

@Dylan-DPC
Dylan-DPC marked this pull request as draft October 4, 2024 14:43
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@VulnBandit
VulnBandit force-pushed the trait-vulnerability branch from 4481349 to 6a66761 Compare October 5, 2024 19:41
@VulnBandit
VulnBandit marked this pull request as ready for review October 5, 2024 19:48
@VulnBandit VulnBandit changed the title [WIP] Don't assume traits used as type are trait objs in 2021 edition Don't assume traits used as type are trait objs in 2021 edition Oct 5, 2024
@VulnBandit

Copy link
Copy Markdown
Contributor Author

@rustbot review

@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 Oct 5, 2024
@VulnBandit
VulnBandit force-pushed the trait-vulnerability branch 2 times, most recently from 71f96e3 to 6037e9e Compare October 5, 2024 20:17
@rust-log-analyzer

This comment has been minimized.

@VulnBandit
VulnBandit force-pushed the trait-vulnerability branch 2 times, most recently from a28d963 to 60f3737 Compare October 8, 2024 08:54
@lcnr

lcnr commented Oct 9, 2024

Copy link
Copy Markdown
Contributor

r=me after CI

Comment thread compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs
@bors

bors commented Oct 10, 2024

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #131511) made this pull request unmergeable. Please resolve the merge conflicts.

@lcnr

lcnr commented Oct 12, 2024

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented Oct 12, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 9a2772e has been approved by lcnr

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 Oct 12, 2024
@bors
bors merged commit 663da00 into rust-lang:master Oct 13, 2024
@rustbot rustbot added this to the 1.83.0 milestone Oct 13, 2024
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

6 participants