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

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

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

VulnBandit
Copy link
Contributor

@VulnBandit VulnBandit commented Oct 4, 2024

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
Copy link
Collaborator

rustbot commented Oct 4, 2024

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
Copy link
Collaborator

rustbot commented Oct 4, 2024

HIR ty lowering was modified

cc @fmease

@VulnBandit
Copy link
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
Copy link
Member

jieyouxu commented Oct 4, 2024

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
Contributor Author

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

@jieyouxu
Copy link
Member

jieyouxu commented Oct 4, 2024

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 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
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
Copy link
Contributor

lcnr commented Oct 9, 2024

r=me after CI

@bors
Copy link
Contributor

bors commented Oct 10, 2024

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

@lcnr
Copy link
Contributor

lcnr commented Oct 12, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 12, 2024

📌 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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 12, 2024
…lcnr

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

Fixes rust-lang#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 rust-lang#120241
Fixes rust-lang#120482
Fixes rust-lang#125512
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 12, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#130870 (Add suggestion for removing invalid path sep `::` in fn def)
 - rust-lang#131233 (std: fix stdout-before-main)
 - rust-lang#131239 (Don't assume traits used as type are trait objs in 2021 edition)
 - rust-lang#131277 (Handle `clippy` cases of `rustc::potential_query_instability` lint)
 - rust-lang#131567 (Emit an error for unstable attributes that reference already stable features)
 - rust-lang#131585 (compiletest: Remove the one thing that was checking a directive's `original_line`)
 - rust-lang#131590 (yeet some clones)
 - rust-lang#131597 (Take a display name for `tool_check_step!`)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 12, 2024
…lcnr

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

Fixes rust-lang#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 rust-lang#120241
Fixes rust-lang#120482
Fixes rust-lang#125512
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 12, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#128784 (Check ABI target compatibility for function pointers)
 - rust-lang#130965 (make `Step` doc-comments more clear)
 - rust-lang#131239 (Don't assume traits used as type are trait objs in 2021 edition)
 - rust-lang#131277 (Handle `clippy` cases of `rustc::potential_query_instability` lint)
 - rust-lang#131503 (More clearly document Stdin::read_line)
 - rust-lang#131567 (Emit an error for unstable attributes that reference already stable features)
 - rust-lang#131599 (Shallowly match opaque key in storage)
 - rust-lang#131617 (remove const_cow_is_borrowed feature gate)

Failed merges:

 - rust-lang#131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 663da00 into rust-lang:master Oct 13, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 13, 2024
Rollup merge of rust-lang#131239 - VulnBandit:trait-vulnerability, r=lcnr

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

Fixes rust-lang#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 rust-lang#120241
Fixes rust-lang#120482
Fixes rust-lang#125512
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