MaikKlein / rlsl

Rust to SPIR-V compiler
Apache License 2.0
557 stars 14 forks source link

Investigate recent ICE on nightly #38

Closed MaikKlein closed 6 years ago

MaikKlein commented 6 years ago

error: internal compiler error: librustc/infer/canonical.rs:695: failed to lift QueryResult { var_values: CanonicalVarValues { var_values: ['?0, '?1, '?2] }, region_constraints: [Binder(OutlivesPredicate('?0, '?0)), Binder(OutlivesPredicate('?0, '?0)), Binder(OutlivesPredicate('?0, '?0)), Binder(OutlivesPredicate('?0, '?0)), Binder(OutlivesPredicate(ReStatic, '?2))], certainty: Proven, value: NormalizationResult { normalized_ty: Input<'_> } }, canonicalized from QueryResult { var_values: CanonicalVarValues { var_values: ['_#0r, '_#1r, '_#2r] }, region_constraints: [Binder(OutlivesPredicate('_#0r, '_#3r)), Binder(OutlivesPredicate('_#0r, '_#4r)), Binder(OutlivesPredicate('_#3r, '_#0r)), Binder(OutlivesPredicate('_#4r, '_#0r)), Binder(OutlivesPredicate(ReStatic, '_#2r))], certainty: Proven, value: NormalizationResult { normalized_ty: Input<'_> } }

MaikKlein commented 6 years ago

env RUSTFLAGS="-Z treat-err-as-bug" RUST_BACKTRACE=1 cargo build revealed that it is most likely the impl trait that causes this error. Sadly I use the impl trait feature pretty often.

MaikKlein commented 6 years ago

0 [normalize_projection_ty] normalizing Canonical { variables: Slice([CanonicalVarInfo { kind: Region }, CanonicalVarInfo { kind: Region }, CanonicalVarInfo { kind: Region }]), value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: Slice([]), reveal: UserFacing }, value: ProjectionTy { substs: Slice([std::iter::FlatMap<std::slice::Iter<'_, EntryPoint<'_, '_>>, impl std::iter::Iterator, fn(&'_ EntryPoint<'_, '_>) -> impl std::iter::Iterator {EntryPoint<'_, '_>::input_iter}>]), item_def_id: DefId(2/0:1904 ~ core[fc79]::iter[0]::iterator[0]::Iterator[0]::Item[0]) } } }

1 [mir_const] processing <Entry<'tcx, Input<'tcx>>>::input

2 [mir_validated] processing <Entry<'tcx, Input<'tcx>>>::input

3 [borrowck] processing <Entry<'tcx, Input<'tcx>>>::input

MaikKlein commented 6 years ago

After a long debugging session, I could reduce the error to the following lines

    let set: HashSet<_> = entry_points
        .iter()
        .flat_map(EntryPoint::input_iter)
        .collect();

Where input_iter uses the impl trait

MaikKlein commented 6 years ago

Hm this seems to fix the error

    let set: HashSet<_> = entry_points
        .iter()
        .flat_map(|entry| EntryPoint::input_iter(entry))
        .collect();
MaikKlein commented 6 years ago

Fixed by https://github.com/MaikKlein/rlsl/commit/eaf9edfa7ddfd782694d24a780dd35cc1a72120c