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

rustc_typeck: gate AnonConst's generics on feature(const_generics). #66883

Merged
merged 2 commits into from
Dec 1, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Nov 29, 2019

This PR employs the fix for #43408 when #![feature(const_generics)] is enabled, making the feature-gate the opt-in for all the possible breakage this may incur.

For example, if this PR lands, this will cause a cycle error (due to #60471):

#![feature(const_generics)]

fn foo<T: Into<[u8; 4]>>() {}

And so will anything with type-level const expressions, in its bounds.
Surprisingly, impls don't seem to be affected (if they were, even libcore wouldn't compile).

One thing I'm worried about is not knowing how much unstable code out there, using const-generics, will be broken. But types like Foo<{N+1}> never really worked, and do after this PR, just not in bounds - so ironically, it's type-level const expressions that don't depend on generics, which will break (in bounds).

Also, if we do this, we'll have effectively blocked stabilization of const generics on #60471.

r? @oli-obk cc @varkor @yodaldevoid @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 29, 2019
@varkor varkor added the F-const_generics `#![feature(const_generics)]` label Nov 30, 2019
@varkor
Copy link
Member

varkor commented Nov 30, 2019

Also, if we do this, we'll have effectively blocked stabilization of const generics on #60471.

I think we've always implicitly understood this would be the case, so I have no issue making that explicit.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 30, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Nov 30, 2019

📌 Commit 584ede5 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Nov 30, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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 Nov 30, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 30, 2019
…li-obk

rustc_typeck: gate AnonConst's generics on feature(const_generics).

This PR employs the fix for rust-lang#43408 when `#![feature(const_generics)]` is enabled, making the feature-gate the opt-in for all the possible breakage this may incur.

For example, if this PR lands, this will cause a cycle error (due to rust-lang#60471):
```rust
#![feature(const_generics)]

fn foo<T: Into<[u8; 4]>>() {}
```
And so will anything with type-level const expressions, in its bounds.
Surprisingly, `impl`s don't seem to be affected (if they were, even libcore wouldn't compile).

One thing I'm worried about is not knowing how much unstable code out there, using const-generics, will be broken. But types like `Foo<{N+1}>` never really worked, and do after this PR, just not in bounds - so ironically, it's type-level const expressions that don't depend on generics, which will break (in bounds).

Also, if we do this, we'll have effectively blocked stabilization of const generics on rust-lang#60471.

r? @oli-obk cc @varkor @yodaldevoid @nikomatsakis
// HACK(eddyb) when substs contain e.g. inference variables,
// attempt using identity substs instead, that will succeed
// when the expression doesn't depend on any parameters.
// FIXME(eddyb) make `const_eval` a canonical query instead,

Choose a reason for hiding this comment

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

I also discovered that we need to make const_eval a canonical query as part of my work on lazy normalization(https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics/near/180906840). That's also partly my motivation behind #66877.

bors added a commit that referenced this pull request Dec 1, 2019
Rollup of 9 pull requests

Successful merges:

 - #66612 (Initial implementation of or-pattern usefulness checking)
 - #66705 (Atomic as_mut_ptr)
 - #66759 (impl TrustedLen for vec::Drain)
 - #66858 (Use LLVMAddAnalysisPasses instead of Rust's wrapper)
 - #66870 (SimplifyArmIdentity only for locals with the same type)
 - #66883 (rustc_typeck: gate AnonConst's generics on feature(const_generics).)
 - #66889 (Make python-generated source files compatible with rustfmt)
 - #66894 (Remove unneeded prelude imports in libcore tests)
 - #66895 (Feature gating *declarations* => new crate `rustc_feature`)

Failed merges:

 - #66905 (rustc_plugin: Remove some remaining plugin features)

r? @ghost
@bors bors merged commit 584ede5 into rust-lang:master Dec 1, 2019
@eddyb eddyb deleted the we-cant-have-nice-things branch December 1, 2019 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_generics `#![feature(const_generics)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants