Skip to content

Backward spans are displayed strangely #42104

Closed
@dtolnay

Description

@dtolnay
macro_rules! m {
    ($a:tt $b:tt) => {
        $b $a;
    }
}

fn main() {
    m!(S struct);
}

This is a regression in 1.18.0-beta but unclear whether it affects anything in practice. We encountered this in #rust-libs discussing #40939.

$ rustc +stable --version
rustc 1.17.0 (56124baa9 2017-04-24)
$ cargo +stable build
   Compiling testing v0.1.0
warning: struct is never used: `S`
 --> src/main.rs:8:10
  |
8 |     m!(S struct);
  |     -----^------- in this macro invocation
  |
  = note: #[warn(dead_code)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.34 secs
$ rustc +beta --version
rustc 1.18.0-beta.2 (f4e8e81c3 2017-05-11)
$ cargo +beta build
   Compiling testing v0.1.0
warning: struct is never used: `S`
 --> src/main.rs:8:10
  |
3 | |         $b $a;
  | |______________^
...
8 |       m!(S struct);
  |  _____-----^-------
  | |     |
  | |     in this macro invocation
  |
  = note: #[warn(dead_code)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.45 secs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions