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

Generalize trait object generic param check to aliases. #100247

Merged
merged 2 commits into from
Aug 12, 2022

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Aug 7, 2022

The current algorithm only checks that Self does not appear in defaults for traits. This is not sufficient for trait aliases.
This PR moves the check to trait object elaboration, which sees through trait aliases.

Fixes #82927.
Fixes #84789.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 7, 2022
@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 7, 2022
@cjgillot cjgillot force-pushed the verify-dyn-trait-alias-defaults branch from ab8fe17 to ee7eb58 Compare August 7, 2022 20:03
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit, then r=me

let param = &generics.params[index];
missing_type_params.push(param.name);
tcx.ty_error().into()
} else if ty.has_fresh_types() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe instead use ty.walk().any(|arg| arg == dummy_self.into()) 🤔 this feels a lot more clear than checking for HAS_TY_FRESH

@cjgillot cjgillot force-pushed the verify-dyn-trait-alias-defaults branch from ee7eb58 to 0df84ae Compare August 10, 2022 16:33
@cjgillot
Copy link
Contributor Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Aug 10, 2022

📌 Commit 0df84ae 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 Aug 10, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 11, 2022
…faults, r=lcnr

Generalize trait object generic param check to aliases.

The current algorithm only checks that `Self` does not appear in defaults for traits.  This is not sufficient for trait aliases.
This PR moves the check to trait object elaboration, which sees through trait aliases.

Fixes rust-lang#82927.
Fixes rust-lang#84789.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 12, 2022
…faults, r=lcnr

Generalize trait object generic param check to aliases.

The current algorithm only checks that `Self` does not appear in defaults for traits.  This is not sufficient for trait aliases.
This PR moves the check to trait object elaboration, which sees through trait aliases.

Fixes rust-lang#82927.
Fixes rust-lang#84789.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 12, 2022
…faults, r=lcnr

Generalize trait object generic param check to aliases.

The current algorithm only checks that `Self` does not appear in defaults for traits.  This is not sufficient for trait aliases.
This PR moves the check to trait object elaboration, which sees through trait aliases.

Fixes rust-lang#82927.
Fixes rust-lang#84789.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 12, 2022
Rollup of 9 pull requests

Successful merges:

 - rust-lang#100022 (Optimize thread ID generation)
 - rust-lang#100030 (cleanup code w/ pointers in std a little)
 - rust-lang#100229 (add -Zextra-const-ub-checks to enable more UB checking in const-eval)
 - rust-lang#100247 (Generalize trait object generic param check to aliases.)
 - rust-lang#100255 (Adding more verbose documentation for `std::fmt::Write`)
 - rust-lang#100366 (errors: don't fail on broken primary translations)
 - rust-lang#100396 (Suggest const and static for global variable)
 - rust-lang#100409 (rustdoc: don't generate DOM element for operator)
 - rust-lang#100443 (Add two let else regression tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit caac670 into rust-lang:master Aug 12, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 12, 2022
@cjgillot cjgillot deleted the verify-dyn-trait-alias-defaults branch August 13, 2022 08:44
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 2, 2022
Rollup of 7 pull requests

Successful merges:

 - rust-lang#92744 (Check if enum from foreign crate has any non exhaustive variants when attempting a cast)
 - rust-lang#99337 (rustdoc: simplify highlight.rs)
 - rust-lang#100007 (Never inline Windows dtor access)
 - rust-lang#100030 (cleanup code w/ pointers in std a little)
 - rust-lang#100192 ( Remove duplicated temporaries creating during box derefs elaboration)
 - rust-lang#100247 (Generalize trait object generic param check to aliases.)
 - rust-lang#100374 (Improve crate selection on rustdoc search results page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
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
5 participants