Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

regression: ICE -- bad ConstKind after monomorphizing #94502

Closed
Mark-Simulacrum opened this issue Mar 1, 2022 · 6 comments
Closed

regression: ICE -- bad ConstKind after monomorphizing #94502

Mark-Simulacrum opened this issue Mar 1, 2022 · 6 comments
Assignees
Labels
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.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Mar 1, 2022

Crater picked up this issue in a number of crates:

May be a duplicate of #93002, but filing this as a dedicated bug with a rough list of affected crates in Crater.

ty::ConstKind::Error constructed but no error reported (we should check, may be a distinct bug; maybe #94506):

[INFO] [stdout] error: internal compiler error: /rustc/0a4f984a87c7ba6c74ec3e78442fec955a419e32/compiler/rustc_codegen_ssa/src/mir/constant.rs:42:20: encountered bad ConstKind after monomorphizing: Error(DelaySpanBugEmitted(()))
[INFO] [stdout]   --> parse/src/day02.rs:21:73
[INFO] [stdout]    |
[INFO] [stdout] 21 |     let char_count = count_dict.get(&password_rule.character).unwrap_or(&0);
[INFO] [stdout]    |                                                                         ^^
[INFO] [stdout] 
@Mark-Simulacrum Mark-Simulacrum added 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. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Mar 1, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.60.0 milestone Mar 1, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 1, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Mar 2, 2022

cc @b-naber @lcnr does this ring a bell wrt recent const representation changes in MIR?

@b-naber
Copy link
Contributor

b-naber commented Mar 2, 2022

cc @b-naber @lcnr does this ring a bell wrt recent const representation changes in MIR?

Does a crater run use nightly?

None of the changes we made are in nightly right now. Only one PR was merged, but that was later reverted.

@matthiaskrgr
Copy link
Member

Reduced a bit from https://github.com/deaz/adventofcode-2018:

use std::collections::HashMap;

pub fn f(input: &str) {
    input
        .lines()
        .map(|s| -> (u32) { (1) })
        .fold(HashMap::new(), |mut map, (x)| {
            let prev = map.get(&(0, x)).unwrap_or(&0);
            map.insert((0, x), prev + 1);
            map
        });
}

pub fn main() {
    let _ = f("");
}

This crashes on beta but not on stable or nightly.

@lcnr
Copy link
Contributor

lcnr commented Mar 3, 2022

minimalized

struct Repro;
impl Repro {
    fn get(&self) -> &i32 {
        &3
    }

    fn insert(&mut self, _: i32) {}
}

fn main() {
    let x = &0;
    let mut conflict = Repro;
    let prev = conflict.get();
    conflict.insert(*prev + *x);
}

the issue is that body.tainted_by_errors is also set when only emitting a lint

@lcnr lcnr self-assigned this Mar 3, 2022
@eddyb
Copy link
Member

eddyb commented Mar 3, 2022

Sounds like this comment might be relevant: #93368 (comment) - i.e. that PR ended up doing a drive-by fix because conflating errors and warnings became a type mismatch at the DiagnosticBuilder level.

So you can probably confirm that nightly was broken between #93691 landing (nightly-2022-02-13?) and #93368 landing (nightly-2022-02-26?), and I guess beta branched between the two?

EDIT: heh, @lcnr already opened the fix/backport PR as I was writing this.

lcnr added a commit to lcnr/rust that referenced this issue Mar 3, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 3, 2022
lcnr added a commit to lcnr/rust that referenced this issue Mar 7, 2022
lcnr added a commit to lcnr/rust that referenced this issue Mar 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 7, 2022
[beta] backport fix for rust-lang#94502

this issue was fixed as part of rust-lang#93368, so i extracted the change from there

closes rust-lang#94502
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 7, 2022
…askrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#94553 (add tests for rust-lang#94502)
 - rust-lang#94614 (Remove ordering traits from `rustc_span::hygiene::LocalExpnId`)
 - rust-lang#94685 (interpret: move saturating_add/sub into (pub) helper method)
 - rust-lang#94688 (Erase regions when checking for missing Copy predicates)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@pietroalbini
Copy link
Member

Should be fixed by #94552.

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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

9 participants