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

Spurious unconstrained const parameter warning in impl #60712

Closed
varkor opened this issue May 10, 2019 · 1 comment · Fixed by #60717
Closed

Spurious unconstrained const parameter warning in impl #60712

varkor opened this issue May 10, 2019 · 1 comment · Fixed by #60717
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented May 10, 2019

#![feature(const_generics)]

struct S<const X: u32>;

impl<const X: u32> S<{X}> {} //~ ERROR

produces:

error[E0207]: the const parameter `X` is not constrained by the impl trait, self type, or predicates

which is clearly incorrect.

@varkor varkor added the A-const-generics Area: const generics (parameters and arguments) label May 10, 2019
@Centril Centril added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 10, 2019
@varkor
Copy link
Member Author

varkor commented May 10, 2019

What I believe is happening here is that {X} is no longer treated as a parameter, because it's in brackets. It's a ConstValue::Unevaluated when it gets to

fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
if let ConstValue::Param(data) = c.val {
self.parameters.push(Parameter::from(data));
}
false
}

rather than a parameter.

bors added a commit that referenced this issue May 11, 2019
Fix a bug preventing const parameters from being used in const generic impls

Fixes #60712.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants