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

PlaceBuilder ICE, Part 2 #88118

Closed
nikomatsakis opened this issue Aug 17, 2021 · 11 comments · Fixed by #88266 or #89282
Closed

PlaceBuilder ICE, Part 2 #88118

nikomatsakis opened this issue Aug 17, 2021 · 11 comments · Fixed by #88266 or #89282
Labels
A-closures Area: closures (`|args| { .. }`) A-edition-2021 Area: The 2021 edition I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Aug 17, 2021

#88039 fixed #87987 but this issue still fails:

#![feature(capture_disjoint_fields)]

fn foo<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
    Box::new(move |value| {
        (|_| handler.clone()())(value);
        None
    }) as Box<dyn Fn(i32) -> Option<i32>>;
}

fn main() {}

Found trying to migrate seed 0.8.0.

Let me know if you need any more information.

Originally posted by @ehuss in #87987 (comment)

@nikomatsakis
Copy link
Contributor Author

@rustbot assign @roxelo

@rustbot rustbot self-assigned this Aug 17, 2021
@roxelo
Copy link
Member

roxelo commented Aug 17, 2021

@roxelo
Copy link
Member

roxelo commented Aug 19, 2021

@arora-aman Let me know how I can provide assistance on this one

@roxelo
Copy link
Member

roxelo commented Aug 19, 2021

@rustbot label +A-closures +A-edition-2021 +T-compiler +I-ICE

@rustbot rustbot added A-closures Area: closures (`|args| { .. }`) A-edition-2021 Area: The 2021 edition I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 19, 2021
@arora-aman
Copy link
Member

@rustbot claim

@rustbot rustbot assigned arora-aman and unassigned rustbot Aug 19, 2021
@arora-aman
Copy link
Member

This seems like a similar problem as #87814. We end up at a point where we fail to determine type of a variable and end up returning early without possibly capturing.

@nikomatsakis
Copy link
Contributor Author

@rustbot release-assignment

@nikomatsakis
Copy link
Contributor Author

@rustbot claim

@Mark-Simulacrum
Copy link
Member

Reopening -- I was able to trigger this on rustc_errors:

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: PlaceBuilder { base: Upvar { var_hir_id: HirId { owner: DefId(0:1099 ~ rustc_errors[2427]::{impl#11}::print_error_count), local_id: 4 }, closure_def_id: DefId(0:1100 ~ rustc_errors[2427]::{impl#11}::print_error_count::{closure#0}), closure_kind: FnMut }, projection: [Deref] }', compiler/rustc_mir_build/src/build/expr/as_place.rs:306:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-beta.1 (e784c962e 2021-09-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -Z binary-dep-depinfo -Z unstable-options -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_built] building MIR for `<impl at compiler/rustc_errors/src/lib.rs:917:1: 1190:2>::print_error_count::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `<impl at compiler/rustc_errors/src/lib.rs:917:1: 1190:2>::print_error_count::{closure#0}`

Going to try to minify...

@Mark-Simulacrum
Copy link
Member

Triggers with the following (rustc --edition=2021), both on beta and nightly. I think this requires if let guards, though.

#![feature(if_let_guard)]

fn print_error_count(registry: &Registry) {
    |x: &Registry| {
        match &x {
            Registry if let _ = registry.try_find_description() => { }
            _ => {}
        }
    };
}

struct Registry;
impl Registry {
    pub fn try_find_description(self) {
        unimplemented!()
    }
}

fn main() {}

@roxelo
Copy link
Member

roxelo commented Sep 26, 2021

We ICE after attempting to resolve the PlaceBuilder for registry here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/build/expr/into.rs#L509.
I believe we recently added the option to have if let in pattern matching arms, but we never consumed the IfLet expression when "visiting" the arm leading us to not "read" registry and hence not being able to resolve it.

cc: @arora-aman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: closures (`|args| { .. }`) A-edition-2021 Area: The 2021 edition I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants