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

Fn traits with array args no longer work with const_generics enabled #67753

Closed
Manishearth opened this issue Dec 31, 2019 · 9 comments · Fixed by #68312
Closed

Fn traits with array args no longer work with const_generics enabled #67753

Manishearth opened this issue Dec 31, 2019 · 9 comments · Fixed by #68312
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: lazy normalization (tracking issue: #60471) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Manishearth
Copy link
Member

#![feature(const_generics)]

fn main() {
    takes_closure_of_array_3(|[x, y, z]| {
        println!("args: x={}, y={}, z={}", x, y, z);
    });
}

fn takes_closure_of_array_3<F>(f: F)
where
    F: Fn([i32; 3]),
{
    f([1, 2, 3]);
}

(playpen)

Gives the error:

   Compiling playground v0.0.1 (/playground)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> src/main.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error[E0391]: cycle detected when const-evaluating + checking `takes_closure_of_array_3::{{constant}}#0`
  --> src/main.rs:11:17
   |
11 |     F: Fn([i32; 3]),
   |                 ^
   |
note: ...which requires const-evaluating + checking `takes_closure_of_array_3::{{constant}}#0`...
  --> src/main.rs:11:17
   |
11 |     F: Fn([i32; 3]),
   |                 ^
......................
9  | / fn takes_closure_of_array_3<F>(f: F)
10 | | where
11 | |     F: Fn([i32; 3]),
12 | | {
13 | |     f([1, 2, 3]);
14 | | }
   | |_^

This compiles fine with const_generics not enabled, and is a regression

cc @Centril @oli-obk

@Manishearth Manishearth added the A-const-generics Area: const generics (parameters and arguments) label Dec 31, 2019
@Manishearth
Copy link
Member Author

(discovered by @jcoglan)

@jonas-schievink jonas-schievink added A-lazy-normalization Area: lazy normalization (tracking issue: #60471) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 31, 2019
@JohnTitor JohnTitor added the F-const_generics `#![feature(const_generics)]` label Dec 31, 2019
@Centril Centril added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Dec 31, 2019
@Centril
Copy link
Contributor

Centril commented Dec 31, 2019

cc @nikomatsakis @eddyb @varkor

Simplified:

#![feature(const_generics)]

fn main() {
    takes_closure_of_array(|_| {});
}

fn takes_closure_of_array<F>(f: F)
where
    F: FnOnce([i32; 0]),
{
    f([]);
}

@Centril Centril added I-nominated P-high High priority labels Dec 31, 2019
@jonas-schievink
Copy link
Contributor

Isn't this expected fallout?

@varkor
Copy link
Member

varkor commented Dec 31, 2019

This is an expected consequence of #66883.

@Manishearth
Copy link
Member Author

Seems like #60471 is what's supposed to eventually fix this?

@pnkfelix
Copy link
Member

pnkfelix commented Jan 2, 2020

triage: P-medium (nightly-only regression on feature that is known to have bugs)

@pnkfelix pnkfelix added the P-medium Medium priority label Jan 2, 2020
@eddyb
Copy link
Member

eddyb commented Jan 16, 2020

@varkor @oli-obk I think we've discussed this before, but what do you think of special-casing literals, to unblock at least some common usecases like this?

@oli-obk
Copy link
Contributor

oli-obk commented Jan 17, 2020

I can't reproduce on master, this may have gotten fixed? (Note that the playground is severely outdated, a fix is underway for that though)

@varkor varkor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 17, 2020
@varkor
Copy link
Member

varkor commented Jan 17, 2020

@eddyb pointed out that #68118 most likely fixed this.

@oli-obk oli-obk removed P-medium Medium priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. requires-nightly This issue requires a nightly compiler in some way. labels Jan 17, 2020
tmandry added a commit to tmandry/rust that referenced this issue Jan 17, 2020
…ntril

Add regression test for integer literals in generic arguments in where clauses

Closes rust-lang#67753.
tmandry added a commit to tmandry/rust that referenced this issue Jan 18, 2020
…ntril

Add regression test for integer literals in generic arguments in where clauses

Closes rust-lang#67753.
@bors bors closed this as completed in 9d9c8c6 Jan 18, 2020
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) A-lazy-normalization Area: lazy normalization (tracking issue: #60471) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-const_generics `#![feature(const_generics)]` 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.

8 participants