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: cat_expr_errd #52443

Closed
DutchGhost opened this issue Jul 16, 2018 · 3 comments · Fixed by #52568
Closed

ICE: cat_expr_errd #52443

DutchGhost opened this issue Jul 16, 2018 · 3 comments · Fixed by #52568
Assignees
Labels
A-const-eval Area: constant evaluation (mir interpretation) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Jul 16, 2018

The following only ICE's on nightly:

fn main() {
    [(); & { loop { continue } } ]
}

playground: https://play.rust-lang.org/?gist=5301f1ed6aea057aa9f5c921e3ea2f1e&version=nightly&mode=release&edition=2015

Backtrace:

warning: unreachable expression
   --> src\lib.rs:169:14
    |
169 |         [(); & { loop { continue } } ]
    |              ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(unreachable_code)] on by default

error: internal compiler error: cat_expr Errd
   --> src\lib.rs:169:9
    |
169 |         [(); & { loop { continue } } ]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `test_bugs`.

To learn more, run the command again with --verbose.

Backtrace variable is set, this was all I got. (I also got no backtrace for #52442 when compiling in nightly, perhaps they are related)

@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. A-const-eval Area: constant evaluation (mir interpretation) labels Jul 16, 2018
@DutchGhost
Copy link
Contributor Author

DutchGhost commented Jul 17, 2018

Even a slightly smaller example:

fn main() {
    
    [(); loop { break }]
}

With some more brackets, a while loop also ICE's:

fn main() {
    
    [(); {while true {break}; 0}];
}

and for loops as well:

fn main() {
    
    [(); { for _ in 0usize.. {}; 0}];
}

@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. P-high High priority labels Jul 19, 2018
@pnkfelix
Copy link
Member

triage: P-high

@oli-obk
Copy link
Contributor

oli-obk commented Jul 19, 2018

So... there's some very weird stuff going on wrt the ! type and blocks:

DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: >> typechecking: expr=expr(15: [(); ]) expected=NoExpectation
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::collect: explicit_predicates_of(def_id=DefId(0/1:9 ~ issue_52443[317d]::main[0]::{{constant}}[0]))
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: >> typechecking: expr=expr(14: &{ loop  { continue  } }) expected=ExpectHasType(usize)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: >> typechecking: expr=expr(13: { loop  { continue  } }) expected=NoExpectation
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: >> typechecking: expr=expr(12: loop  { continue  }) expected=NoExpectation
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: >> typechecking: expr=expr(11: continue) expected=ExpectHasType(())
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(3) }, [type error]) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: type of expr continue (id=11) is...
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: ... [type error], expected is ExpectHasType(())
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(4) }, [type error]) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(5) }, !) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: type of expr loop  { continue  } (id=12) is...
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: ... !, expected is NoExpectation
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations(ty=!)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations: ty=!
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::coercion: coercion::try(expr(12: loop  { continue  }): ! -> _)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::coercion: Coerce.tys(! => _)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: register_predicate(Obligation(predicate=Binder(SubtypePredicate { a_is_expected: false, a: _, b: _ }),depth=0))
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: apply_adjustments(expr=expr(12: loop  { continue  }), adj=[NeverToAny -> _])
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(6) }, [type error]) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(7) }, [type error]) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: type of expr { loop  { continue  } } (id=13) is...
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: ... [type error], expected is NoExpectation
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: warn_if_unreachable: id=NodeId(14) span=/home/oliver/Projects/rust/rust4/src/test/ui/const-eval/issue-52443.rs:12:10: 12:33 kind=expression
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: write_ty(HirId { owner: DefIndex(0:3), local_id: ItemLocalId(8) }, [type error]) in fcx 0x7ffe425f2ea8
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: type of expr &{ loop  { continue  } } (id=14) is...
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: ... [type error], expected is ExpectHasType(usize)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations(ty=usize)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations: ty=usize
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations(ty=[type error])
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: resolve_type_vars_with_obligations: ty=[type error]
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::coercion: coercion::try(expr(14: &{ loop  { continue  } }): [type error] -> usize)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::coercion: Coerce.tys([type error] => usize)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: apply_adjustments(expr=expr(14: &{ loop  { continue  } }), adj=[])
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: default_type_parameters: defaulting `_` to `[type error]`
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: default_type_parameters: defaulting `_` to `[type error]`
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: default_type_parameters: defaulting `_` to `[type error]`
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check: select_all_obligations_or_error
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::regionck: regionck::visit_expr(e=expr(14: &{ loop  { continue  } }), repeating_scope=14)
DEBUG 2018-07-19T16:49:23Z: rustc_typeck::check::regionck: constrain_adjustments(expr=expr(14: &{ loop  { continue  } }))
error: internal compiler error: cat_expr Err ()
  --> /home/oliver/Projects/rust/rust4/src/test/ui/const-eval/issue-52443.rs:12:10
   |
LL |     [(); & { loop { continue } } ];
   |          ^^^^^^^^^^^^^^^^^^^^^^^

It appears that somehow & { loop { continue } } produces an error type, but only if the expression is inside an array length or an enum initializer. Inside a constant that is used for an array length, everything is fine. So I presume this is AnonConst related.

cc @eddyb stable-to-nightly ICE on weird expressions inside AnonConst

bors added a commit that referenced this issue Jul 23, 2018
Fix loop label resolution around constants

And make `delay_span_bug` a little more helpful

r? @varkor

fixes #52442
fixes #52443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

4 participants