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 with instrument #1472

Open
mibac138 opened this issue Jul 15, 2021 · 3 comments
Open

ICE with instrument #1472

mibac138 opened this issue Jul 15, 2021 · 3 comments

Comments

@mibac138
Copy link

Bug Report

Version

tracing = "0.1"

Description

This code (playground):

pub struct Foo;
impl Foo {
    #[tracing::instrument(skip(_))]
    pub fn read_from(_: () {
   // missing close paren ^
    }
}

Causes an ICE that's not present without #[tracing::instrument].
Output:

error: expected one of `)` or `,`, found `{`
 --> src/lib.rs:5:28
  |
5 |     pub fn read_from(_: () {
  |                     -     -^
  |                     |     |
  |                     |     help: `)` may belong here
  |                     unclosed delimiter

error: non-item in item list
 --> src/lib.rs:7:1
  |
3 | impl Foo {
  |          - item list starts here
...
7 | }
  | ^
  | |
  | non-item starts here
  | item list ends here

thread 'rustc' panicked at 'Stack should be empty: final_buf=FrameData { open: src/lib.rs:5:21: 5:22 (#0), open_delim: Paren, inner: [(Token(Token { kind: Ident("_", false), span: src/lib.rs:5:22: 5:23 (#0) }), Joint), (Token(Token { kind: Colon, span: src/lib.rs:5:23: 5:24 (#0) }), Alone), (Delimited(DelimSpan { open: src/lib.rs:5:25: 5:26 (#0), close: src/lib.rs:5:26: 5:27 (#0) }, Paren, AttrAnnotatedTokenStream([])), Alone), (Delimited(DelimSpan { open: src/lib.rs:5:28: 5:29 (#0), close: src/lib.rs:6:5: 6:6 (#0) }, Brace, AttrAnnotatedTokenStream([])), Alone)] } stack=[FrameData { open: no-location (#0), open_delim: NoDelim, inner: [(Token(Token { kind: Ident("pub", false), span: src/lib.rs:5:5: 5:8 (#0) }), Alone), (Token(Token { kind: Ident("fn", false), span: src/lib.rs:5:9: 5:11 (#0) }), Alone), (Token(Token { kind: Ident("read_from", false), span: src/lib.rs:5:12: 5:21 (#0) }), Alone)] }]', compiler/rustc_parse/src/parser/attr_wrapper.rs:501:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (3e1c75c6e 2021-07-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: aborting due to 2 previous errors
@hawkw
Copy link
Member

hawkw commented Jul 16, 2021

Huh. That's interesting!

I think this is probably worth opening an issue against the Rust compiler, if you haven't already. We should be able to use cargo expand to get the output that the instrument macro expands to here, and try to minimize that to the smallest code necessary to trigger the ICE.

@leftwo
Copy link

leftwo commented Sep 14, 2021

I'm seeing the same behavior with a very similar bit of code (Also missing a close paren):

use tracing::instrument;

struct Al;

impl Al {
    #[instrument]
    fn ox(&mut self {
    }   
}

Tracing version: 0.1.27
I attempt to use cargo expand to see what is being generated, and that also panic's rustc without giving me any generated output.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=ca1b7429a01fd10757c8f0dc87d944d1

It fails with nightly, beta, and stable compiler options.
The problem goes away if I remove the #[instrument]

@leftwo
Copy link

leftwo commented Sep 14, 2021

This might possibly be the issue: rust-lang/rust#80447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants