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

thread 'main' panicked at 'bad span: .: ``', src/tools/rustfmt/src/source_map.rs:52:13 #5716

Open
matthiaskrgr opened this issue Mar 17, 2023 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 17, 2023

#[derive(Debug)]
struct S(String);

#[derive(Debug)]
struct T(S);


fn no_ref_nested() {
    let mut t = T(S());
    let c = || {
        println!("{:?}", t.0);
        let mut c = move || {
            t.0.10i32 = "new S".into();
            println!("{:?}", t.0.0);
        };
        c();
    };
    c();
}


fn main() {
    no_ref_nested();
}
warning: suffixes on a tuple index are invalid
  --> /tmp/im/2F2289E79BEA4CD52EB15181FD6F33470C0267578597C72C401DEA25348F0F1B.rs:13:15
   |
13 |             t.0.10i32 = "new S".into();
   |               ^^^^^^^ invalid suffix `i32`
   |
   = help: `i32` is *temporarily* accepted on tuple index fields as it was incorrectly accepted on stable for a few releases
   = help: on proc macros, you'll want to use `syn::Index::from` or `proc_macro::Literal::*_unsuffixed` for code that will desugar to tuple field access
   = help: see issue #60210 <https://github.com/rust-lang/rust/issues/60210> for more information

thread 'main' panicked at 'bad span: `.`: ``', src/tools/rustfmt/src/source_map.rs:52:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/std/src/panicking.rs:579:5
   1: core::panicking::panic_fmt
             at /rustc/ab654863c3d50482f260cf862647f1fe0ff5e010/library/core/src/panicking.rs:64:14
   2: <rustfmt_nightly::visitor::SnippetProvider as rustfmt_nightly::source_map::SpanUtils>::span_before
   3: rustfmt_nightly::chains::rewrite_chain
   4: rustfmt_nightly::expr::format_expr
   5: rustfmt_nightly::expr::rewrite_assignment
   6: rustfmt_nightly::expr::format_expr
   7: rustfmt_nightly::stmt::format_stmt
   8: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
   9: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
  10: rustfmt_nightly::expr::rewrite_block_with_visitor
  11: rustfmt_nightly::expr::rewrite_block
  12: rustfmt_nightly::expr::format_expr
  13: rustfmt_nightly::closures::rewrite_closure_expr
  14: rustfmt_nightly::closures::rewrite_closure
  15: rustfmt_nightly::expr::format_expr
  16: rustfmt_nightly::expr::rewrite_assign_rhs_expr::<rustc_ast::ast::Expr>
  17: rustfmt_nightly::expr::rewrite_assign_rhs_with::<alloc::string::String, rustc_ast::ast::Expr>
  18: <rustc_ast::ast::Local as rustfmt_nightly::rewrite::Rewrite>::rewrite
  19: rustfmt_nightly::stmt::format_stmt
  20: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
  21: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
  22: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
  23: rustfmt_nightly::expr::rewrite_block_with_visitor
  24: rustfmt_nightly::expr::rewrite_block
  25: rustfmt_nightly::expr::format_expr
  26: rustfmt_nightly::closures::rewrite_closure_expr
  27: rustfmt_nightly::closures::rewrite_closure
  28: rustfmt_nightly::expr::format_expr
  29: rustfmt_nightly::expr::rewrite_assign_rhs_expr::<rustc_ast::ast::Expr>
  30: rustfmt_nightly::expr::rewrite_assign_rhs_with::<alloc::string::String, rustc_ast::ast::Expr>
  31: <rustc_ast::ast::Local as rustfmt_nightly::rewrite::Rewrite>::rewrite
  32: rustfmt_nightly::stmt::format_stmt
  33: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
  34: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
  35: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
  36: <rustfmt_nightly::visitor::FmtVisitor>::visit_fn
  37: <rustfmt_nightly::visitor::FmtVisitor>::visit_item
  38: <rustfmt_nightly::visitor::FmtVisitor>::visit_items_with_reordering
  39: <rustfmt_nightly::visitor::FmtVisitor>::walk_mod_items
  40: <rustfmt_nightly::visitor::FmtVisitor>::format_separate_mod
  41: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<std::io::stdio::Stdout>>
  42: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
  43: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_span::create_session_if_not_set_then<core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>, <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
  44: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format
  45: rustfmt::format_and_emit_report::<std::io::stdio::Stdout>
  46: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::override_config::<rustfmt::format::{closure#0}, ()>
  47: rustfmt::execute
  48: rustfmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

rustfmt 1.5.2-nightly (ab65486 2023-03-15)
bad_span.zip

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Mar 17, 2023

struct S(String);
struct T(S);

fn no_ref_nested() {
    let mut t = T(S());
    t.0.10i32 = "new S".into();
}

the t.0.10i32 seems to be the problem

@matthiaskrgr
Copy link
Member Author

another one

vec! {
    static DROP_ORDER: RefCell<Vec<usize>> = RefCell::new(Vec::new());
}

@ytmimi ytmimi added the bug Panic, non-idempotency, invalid code, etc. label Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants