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

no errors encountered even though delay_span_bug issued #93282

Closed
WaffleLapkin opened this issue Jan 24, 2022 · 9 comments · Fixed by #93303
Closed

no errors encountered even though delay_span_bug issued #93282

WaffleLapkin opened this issue Jan 24, 2022 · 9 comments · Fixed by #93303
Assignees
Labels
glacier ICE tracked in rust-lang/glacier.

Comments

@WaffleLapkin
Copy link
Member

WaffleLapkin commented Jan 24, 2022

Reproducible at teloxide-core#828ab071.

; cargo +nightly-2022-01-24 fmt
thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Backtrace

; cargo +nightly-2022-01-24 fmt
thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/84322efad553c7a79c80189f2d1b9197c1aa005f/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/84322efad553c7a79c80189f2d1b9197c1aa005f/library/core/src/panicking.rs:135:14
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: <rustfmt_nightly::parse::session::ParseSess>::set_silent_emitter
   6: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<alloc::vec::Vec<u8>>>
   7: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustfmt_nightly::Session<alloc::vec::Vec<u8>>>::format_input_inner::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
   8: <rustfmt_nightly::Session<alloc::vec::Vec<u8>>>::format_input_inner
   9: std::panicking::try::<core::option::Option<rustfmt_nightly::FormattedSnippet>, rustfmt_nightly::format_snippet::{closure#0}>
  10: rustfmt_nightly::format_snippet
  11: rustfmt_nightly::format_code_block
  12: <rustfmt_nightly::macros::MacroBranch>::rewrite
  13: <rustfmt_nightly::lists::ListItems<core::slice::iter::Iter<rustfmt_nightly::macros::MacroBranch>, rustfmt_nightly::macros::rewrite_macro_def::{closure#1}, rustfmt_nightly::macros::rewrite_macro_def::{closure#2}, rustfmt_nightly::macros::rewrite_macro_def::{closure#3}> as core::iter::traits::iterator::Iterator>::next
  14: <alloc::vec::Vec<rustfmt_nightly::lists::ListItem> as alloc::vec::spec_from_iter::SpecFromIter<rustfmt_nightly::lists::ListItem, rustfmt_nightly::lists::ListItems<core::slice::iter::Iter<rustfmt_nightly::macros::MacroBranch>, rustfmt_nightly::macros::rewrite_macro_def::{closure#1}, rustfmt_nightly::macros::rewrite_macro_def::{closure#2}, rustfmt_nightly::macros::rewrite_macro_def::{closure#3}>>>::from_iter
  15: rustfmt_nightly::macros::rewrite_macro_def
  16: <rustfmt_nightly::visitor::FmtVisitor>::visit_item
  17: <rustfmt_nightly::visitor::FmtVisitor>::visit_items_with_reordering
  18: <rustfmt_nightly::visitor::FmtVisitor>::format_separate_mod
  19: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<std::io::stdio::Stdout>>
  20: <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>>
  21: <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>>
  22: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format
  23: rustfmt::format_and_emit_report::<std::io::stdio::Stdout>
  24: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::override_config::<rustfmt::format::{closure#0}, ()>
  25: rustfmt::execute
  26: rustfmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@WaffleLapkin
Copy link
Member Author

Seems to be introduced in nightly-2022-01-18:

; cargo +nightly-2022-01-17 fmt && echo "(just fine)"
(just fine)
; cargo +nightly-2022-01-18 fmt                      
thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@calebcartwright
Copy link
Member

Thanks for the report! A compiler panic is probably best reported in rust-lang/rust, even though it's being surfaced by a dev tool. I'll check with infra to see if it makes sense to move the issue

We actually haven't made any changes to rustfmt in that window and the minimal changes that were applied by folks working on the compiler were highly minimal and certainly don't strike me as anything that would be the root cause.

As such I suspect this is due to changes made elsewhere within the compiler mods, and would at least like for those folks to be aware (even if we need to make changes on the rustfmt side to address/work around)

Would you be up for trying to boil it down to a more simple repro case?

@Mark-Simulacrum Mark-Simulacrum transferred this issue from rust-lang/rustfmt Jan 24, 2022
@WaffleLapkin
Copy link
Member Author

Sure! Here is a MRE:

macro_rules! a { () => { A<'a,> }; }
; bat ./tt.rs --style="plain"
macro_rules! a { () => { A<'a,> }; }
; rustfmt +nightly-2022-01-18 ./tt.rs
thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@ehuss
Copy link
Contributor

ehuss commented Jan 25, 2022

I have bisected to #92876. cc @compiler-errors

@calebcartwright I noticed that rustfmt is exiting with 0 even though it panicked. Is that normal?

@compiler-errors
Copy link
Member

I'll look into it today or tomorrow!

@rustbot claim

@calebcartwright
Copy link
Member

@calebcartwright I noticed that rustfmt is exiting with 0 even though it panicked. Is that normal?

Outside a macro, no, (as was the case in the original full repro), but yes within the context of a macro as in the minimal rerpo. We have our calls to rustc_parse internals wrapped in catch_unwind so the panic isn't really surfacing here, but rustfmt is still displaying the underlying error text prior to emitting formatting.

This is done partly due to the fact that there are scenarios where those internals panic that we want to wrap to an error type, and partly due to there being some scenarios we want to ignore for the purposes of formatting due to how we attempt to deal with macros in the pre-expansion world where rustfmt lives. The latter being a result of limited macro support and leaving macros it can't handle alone, while carrying on formatting the rest of the file/crate/workspace

@Samzyre
Copy link

Samzyre commented Feb 2, 2022

It looks like I'm still getting this error with
rustc 1.60.0-nightly (2681f253b 2022-02-01)
rustfmt 1.4.38-nightly (2681f253 2022-02-01)

(Coming from rust-lang/rustfmt#5208 that was closed due to this one)

Playground seems to produce it also:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=28266fbea1b847f180f6e3adbc99e4f4

@compiler-errors
Copy link
Member

I'll take another look then.

@compiler-errors
Copy link
Member

Yeah, this continues to ICE even in rustc. Fixed in another PR.

fn bar(a: usize, b: usize) -> usize {
    a+ b
} 

fn main() {
    let x = 1;
    bar('a, x);
}

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2022
…, r=jackh726

fix ICE when parsing lifetime as function argument

I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs...

cc: rust-lang#93282 (comment)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2022
…, r=jackh726

fix ICE when parsing lifetime as function argument

I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs...

cc: rust-lang#93282 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
glacier ICE tracked in rust-lang/glacier.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants