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

ICE: "encountered errors lowering pattern: [ConstEval(ConstEvalErr { ... kind: NonConstPath })]" #43250

Closed
est31 opened this issue Jul 15, 2017 · 9 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@est31
Copy link
Member

est31 commented Jul 15, 2017

Following (wrong) code gives an error on beta 1.19 and stable 1.18, but ICEs on current nightly:

fn main() {
	let mut y;
	macro_rules! m {
		($a:expr) => {
			let $a = 0;
		}
	}
	m!(y);
}

The error (expected behaviour):

error: expected pattern, found `y`

The ICE message (new behaviour):

internal compiler error: /checkout/src/librustc_const_eval/pattern.rs:282: encountered errors lowering pattern: [ConstEval(ConstEvalErr { span: src/main.rs:8:5: 8:6, kind: NonConstPath })]

Nightly (soon beta) regression. Bisected using rust-bisect to #42964 (7acce37).

@est31
Copy link
Member Author

est31 commented Jul 15, 2017

One possible cause is #42886 . cc @durka @petrochenkov

@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@alexcrichton alexcrichton added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2017
@alexcrichton
Copy link
Member

cc @rust-lang/compiler

@Mark-Simulacrum
Copy link
Member

Also cc @eddyb specifically, looks CTFE related.

@eddyb
Copy link
Member

eddyb commented Jul 30, 2017

What's surprising is that there's no name resolution error. Patterns shouldn't be able to refer to variables, even when there's macro treachery afoot.

@arielb1
Copy link
Contributor

arielb1 commented Jul 30, 2017

Why would there be a name-resolution error?

You can reach this in stable with range patterns, but you get an error from const-checking which prevents the ICE. Maybe we should const-check literals too?

fn main() {
	let y: usize = 1;
	let 0...y = 1; //~ ERROR constant evaluation error
}

@eddyb
Copy link
Member

eddyb commented Jul 30, 2017

We solved this in name resolution in other situations, didn't we? Like, if you have an array length that's a variable in scope.

@alexcrichton
Copy link
Member

ping @eddyb and @arielb1, did y'all get any further in taking a look at this?

@eddyb
Copy link
Member

eddyb commented Aug 13, 2017

@alexcrichton We don't agree on the solution. IMO name resolution should not see variables in scope from that position, only constant items.

@alexcrichton
Copy link
Member

Hm ok, I guess in that sense this is a reminder that 1.20 is released in less than 3 weeks now, so the clock is ticking for getting some solution into the compiler.

arielb1 added a commit to arielb1/rust that referenced this issue Aug 13, 2017
Since rust-lang#42886, macros can create "nonstandard" PatKind::Lit patterns,
that contain path expressions instead of the usual literal expr. These
can cause trouble, including ICEs.

We *could* map these nonstandard patterns to PatKind::Path patterns
during HIR lowering, but that would be much effort for little gain, and
I think is too risky for beta. So let's just forbid them during AST
validation.

Fixes rust-lang#43250.
bors added a commit that referenced this issue Aug 14, 2017
ast_validation: forbid "nonstandard" literal patterns

Since #42886, macros can create "nonstandard" PatKind::Lit patterns,
that contain path expressions instead of the usual literal expr. These
can cause trouble, including ICEs.

We *could* map these nonstandard patterns to PatKind::Path patterns
during HIR lowering, but that would be much effort for little gain, and
I think is too risky for beta. So let's just forbid them during AST
validation.

Fixes #43250.

beta-nominating because regression.
r? @eddyb
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue Aug 23, 2017
Since rust-lang#42886, macros can create "nonstandard" PatKind::Lit patterns,
that contain path expressions instead of the usual literal expr. These
can cause trouble, including ICEs.

We *could* map these nonstandard patterns to PatKind::Path patterns
during HIR lowering, but that would be much effort for little gain, and
I think is too risky for beta. So let's just forbid them during AST
validation.

Fixes rust-lang#43250.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants