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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VulnBandit
Copy link

@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

@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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Traits in type position should be a fatal error in ≥2018 editions
5 participants