-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add line numbers and columns to error messages spanning multiple files #47780
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[macro_use] | ||
mod underscore; | ||
|
||
fn main() { | ||
underscore!(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected expression, found `_` | ||
--> $DIR/underscore.rs:18:9 | ||
| | ||
18 | _ | ||
| ^ | ||
| | ||
::: $DIR/main.rs:15:5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! =) |
||
| | ||
15 | underscore!(); | ||
| -------------- in this macro invocation | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// We want this file only so we can test cross-file error | ||
// messages, but we don't want it in an external crate. | ||
// ignore-test | ||
#![crate_type = "lib"] | ||
|
||
macro_rules! underscore { | ||
() => ( | ||
_ | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | |
27 | ping!(); | ||
| -------- in this macro invocation | ||
| | ||
::: <ping macros> | ||
::: <ping macros>:1:1 | ||
| | ||
1 | ( ) => { pong ! ( ) ; } | ||
| ------------------------- | ||
|
@@ -42,31 +42,31 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | |
28 | deep!(); | ||
| -------- in this macro invocation (#1) | ||
| | ||
::: <deep macros> | ||
::: <deep macros>:1:1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't really feel like a win here... but I guess it's ok? Is an actual file line reflected here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I was ambivalent about this case: since it didn't seem to be decreasing readability, I decided not to special case it here. The line number is relative to the start of the macro, rather than the file in this case. It's also behind a |
||
| | ||
1 | ( ) => { foo ! ( ) ; } | ||
| ------------------------ | ||
| | | | ||
| | in this macro invocation (#2) | ||
| in this expansion of `deep!` (#1) | ||
| | ||
::: <foo macros> | ||
::: <foo macros>:1:1 | ||
| | ||
1 | ( ) => { bar ! ( ) ; } | ||
| ------------------------ | ||
| | | | ||
| | in this macro invocation (#3) | ||
| in this expansion of `foo!` (#2) | ||
| | ||
::: <bar macros> | ||
::: <bar macros>:1:1 | ||
| | ||
1 | ( ) => { ping ! ( ) ; } | ||
| ------------------------- | ||
| | | | ||
| | in this macro invocation (#4) | ||
| in this expansion of `bar!` (#3) | ||
| | ||
::: <ping macros> | ||
::: <ping macros>:1:1 | ||
| | ||
1 | ( ) => { pong ! ( ) ; } | ||
| ------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave the empty string on it's own line? It is easier to skip the code if the blocks are consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will do!