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: Span must not be empty and have no suggestion #133917

Closed
wxie7 opened this issue Dec 5, 2024 · 1 comment
Closed

ICE: Span must not be empty and have no suggestion #133917

wxie7 opened this issue Dec 5, 2024 · 1 comment
Labels
C-bug Category: This is a bug. requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way

Comments

@wxie7
Copy link

wxie7 commented Dec 5, 2024

I tried this code:

#![allow(unused_must_use)]
#![allow(dead_code)]
#![allow(unused_mut)]
#![allow(non_camel_case_types)]
use square::{bot, closed_lift, earth, empty, lambda, open_lift, rock, wall};
use std::fmt;
use std::io::prelude::*;
enum square {
    bot,
}
impl fmt::Debug for square {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "{}",
            match *self {
                _ => {
                    "R".to_string()
                }
            }
        )
    }
}
fn square_from_char(c: char) -> square {
    match c {
        _ => {
            panic!()
        }
    }
}
fn read_board_grid<rdr: 'static + Read>(mut input: rdr) -> Vec<Vec<square>> {
    let mut input: &mut dyn Read = &mut input;
    let mut grid = Vec::new();
    let mut line = [0; 10];
    input.read(&mut line);
    let mut row = Vec::new();
    for c in &line {
        row.push(square_from_char(*c as char))
    }
    grid.push(row);
    let width = {
        format_args!(bar!());
    };
    for row in &grid {
        assert_eq!(row.len(), width)
    }
    grid
}

It mutates from the following code, but the following code will not cause a ICE.

#![allow(unused_must_use)]
#![allow(dead_code)]
#![allow(unused_mut)]
#![allow(non_camel_case_types)]

use square::{bot, closed_lift, earth, empty, lambda, open_lift, rock, wall};
use std::fmt;
use std::io::prelude::*;

enum square {
    bot,
    wall,
    rock,
    lambda,
    closed_lift,
    open_lift,
    earth,
    empty,
}

impl fmt::Debug for square {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "{}",
            match *self {
                bot => {
                    "R".to_string()
                }
                wall => {
                    "#".to_string()
                }
                rock => {
                    "*".to_string()
                }
                lambda => {
                    "\\".to_string()
                }
                closed_lift => {
                    "L".to_string()
                }
                open_lift => {
                    "O".to_string()
                }
                earth => {
                    ".".to_string()
                }
                empty => {
                    " ".to_string()
                }
            }
        )
    }
}

fn square_from_char(c: char) -> square {
    match c {
        'R' => bot,
        '#' => wall,
        '*' => rock,
        '\\' => lambda,
        'L' => closed_lift,
        'O' => open_lift,
        '.' => earth,
        ' ' => empty,
        _ => {
            println!("invalid square: {}", c);
            panic!()
        }
    }
}

fn read_board_grid<rdr: 'static + Read>(mut input: rdr) -> Vec<Vec<square>> {
    let mut input: &mut dyn Read = &mut input;
    let mut grid = Vec::new();
    let mut line = [0; 10];
    input.read(&mut line);
    let mut row = Vec::new();
    for c in &line {
        row.push(square_from_char(*c as char))
    }
    grid.push(row);
    let width = grid[0].len();
    for row in &grid {
        assert_eq!(row.len(), width)
    }
    grid
}

mod test {
    #[test]
    pub fn trivial_to_string() {
        assert_eq!(lambda.to_string(), "\\")
    }
}

pub fn main() {}

Meta

commit id: acabb52

require debug assertions

Backtrace

error: cannot find macro `foo` in this scope
  --> mutant.rs:11:9
   |
11 |         foo!(-2);
   |         ^^^

error: cannot find macro `bar` in this scope
  --> mutant.rs:12:9
   |
12 |         bar!(-2);
   |         ^^^

error[E0601]: `main` function not found in crate `mutant`
  --> mutant.rs:15:2
   |
15 | }
   |  ^ consider adding a `main` function to `mutant.rs`

thread 'rustc' panicked at /home/xieym/exp/rustc/test_data/rust-latest-src/compiler/rustc_errors/src/diagnostic.rs:1006:9:
Span must not be empty and have no suggestion
stack backtrace:
   0:     0x73f1d0b27ced - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h51e5276f25f67
   1:     0x73f1d0ba68a3 - core::fmt::write::h0a73bee6158cdbf1
   2:     0x73f1d0b5a8c9 - std::io::Write::write_fmt::h206d582822858877
   3:     0x73f1d0b27b93 - std::sys::backtrace::BacktraceLock::print::h84a9a4c750ade733
   4:     0x73f1d0af661c - std::panicking::default_hook::{{closure}}::h216e29259e3d5cff
   5:     0x73f1d0af63e5 - std::panicking::default_hook::h03ce982d60640bc4
   6:     0x73f1cc377342 - <alloc[7c2d8435141f8e1e]::boxed::Box<rustc_driver_impl[d7b86d9e63f9aaed]::install_ice_hook::{closure#0}>
   7:     0x73f1d0af6d88 - std::panicking::rust_panic_with_hook::h88b680004200a63a
   8:     0x73f1d0b2827a - std::panicking::begin_panic_handler::{{closure}}::ha56090df9488ab86
   9:     0x73f1d0b27fa9 - std::sys::backtrace::__rust_end_short_backtrace::h8833a10924a5c2d2
  10:     0x73f1d0af670d - rust_begin_unwind
  11:     0x73f1d0baea90 - core::panicking::panic_fmt::h57d6d212ea0ce749
  12:     0x73f1ccbf40cc - <rustc_errors[20cbecb65c2fd5d8]::diagnostic::Diag>::span_suggestion_with_style::<&str, &str>
  13:     0x73f1cca57ed6 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  14:     0x73f1ccaec0f8 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::demand_coerce_diag
  15:     0x73f1cca5ffec - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_struct_fields
  16:     0x73f1ccaef775 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_kind
  17:     0x73f1cca5b0ef - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18:     0x73f1ccaec625 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation
  19:     0x73f1cca81933 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_argument_types
  20:     0x73f1cca3bb4d - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::confirm_builtin_call
  21:     0x73f1ccaf2d4b - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_kind
  22:     0x73f1cca5b0ef - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x73f1ccaec625 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation
  24:     0x73f1cca8cd03 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_decl
  25:     0x73f1cca8d3f7 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_block
  26:     0x73f1ccaee1e2 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_kind
  27:     0x73f1cca5b0ef - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x73f1ccaec625 - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_expr_with_expectation
  29:     0x73f1cca5c6cf - <rustc_hir_typeck[c5136c63f534b988]::fn_ctxt::FnCtxt>::check_return_or_body_tail
  30:     0x73f1cce16854 - rustc_hir_typeck[c5136c63f534b988]::check::check_fn
  31:     0x73f1cce0f3ef - rustc_hir_typeck[c5136c63f534b988]::typeck
  32:     0x73f1cebb8e95 - rustc_query_impl[bec2af351405b693]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bec2af3514
  33:     0x73f1ceb283c5 - <rustc_query_impl[bec2af351405b693]::query_impl::typeck::dynamic_query::{closure#2} as core[dcda4f281d99
  34:     0x73f1cea86324 - rustc_query_system[1b6cbf762e62559d]::query::plumbing::try_execute_query::<rustc_query_impl[bec2af351405
  35:     0x73f1cedd836b - rustc_query_impl[bec2af351405b693]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:     0x73f1cd0b1074 - <rustc_middle[e6c5fc1c8185df83]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[beef3382d6061d7f]:
  37:     0x73f1cd0c459c - rustc_hir_analysis[beef3382d6061d7f]::check_crate
  38:     0x73f1cc60f1f1 - rustc_interface[3a875bb8a3a01a82]::passes::analysis
  39:     0x73f1cebb94b3 - rustc_query_impl[bec2af351405b693]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bec2af3514
  40:     0x73f1ceb28ef1 - <rustc_query_impl[bec2af351405b693]::query_impl::analysis::dynamic_query::{closure#2} as core[dcda4f281d
  41:     0x73f1ce9d3eec - rustc_query_system[1b6cbf762e62559d]::query::plumbing::try_execute_query::<rustc_query_impl[bec2af351405
  42:     0x73f1ceed8c08 - rustc_query_impl[bec2af351405b693]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x73f1cc3505eb - <rustc_middle[e6c5fc1c8185df83]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[d7b86d9e63f9aaed]::
  44:     0x73f1cc3888ad - <rustc_interface[3a875bb8a3a01a82]::queries::QueryResult<&rustc_middle[e6c5fc1c8185df83]::ty::context::G
  45:     0x73f1cc388e85 - <rustc_interface[3a875bb8a3a01a82]::interface::Compiler>::enter::<rustc_driver_impl[d7b86d9e63f9aaed]::r
  46:     0x73f1cc3340f2 - <scoped_tls[46415f2badf08390]::ScopedKey<rustc_span[37f46e797e36bb53]::SessionGlobals>>::set::<rustc_int
  47:     0x73f1cc30495c - rustc_span[37f46e797e36bb53]::create_session_globals_then::<core[dcda4f281d996093]::result::Result<(), re[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  48:     0x73f1cc33dc72 - std[31742bae037c253]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3a875bb8a3a01a82]::util::run_in_thread_with_globals<rustc_interface[3a875bb8a3a01a82]::util::run_in_thread_pool_with_globals<rustc_interface[3a875bb8a3a01a82]::interface::run_compiler<core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>, rustc_driver_impl[d7b86d9e63f9aaed]::run_compiler::{closure#0}>::{closure#1}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#0}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>
  49:     0x73f1cc3116d4 - <<std[31742bae037c253]::thread::Builder>::spawn_unchecked_<rustc_interface[3a875bb8a3a01a82]::util::run_in_thread_with_globals<rustc_interface[3a875bb8a3a01a82]::util::run_in_thread_pool_with_globals<rustc_interface[3a875bb8a3a01a82]::interface::run_compiler<core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>, rustc_driver_impl[d7b86d9e63f9aaed]::run_compiler::{closure#0}>::{closure#1}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#0}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcda4f281d996093]::result::Result<(), rustc_span[37f46e797e36bb53]::ErrorGuaranteed>>::{closure#1} as core[dcda4f281d996093]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x73f1d0aff91d - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc538cfe9cf5a97c8
  51:     0x73f1d0b2c32b - std::sys::pal::unix::thread::Thread::new::thread_start::h7a196e16c036c2e2
  52:     0x73f1ca094ac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  53:     0x73f1ca126850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  54:                0x0 - <unknown>

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

@rustbot label +requires-debug-assertions
@wxie7 wxie7 added the C-bug Category: This is a bug. label Dec 5, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way labels Dec 5, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Dec 5, 2024

This is a duplicate of #133834.

@jieyouxu jieyouxu closed this as completed Dec 5, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 5, 2024
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. requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way
Projects
None yet
Development

No branches or pull requests

3 participants