forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rust-lang#848
- Loading branch information
Showing
8 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Based on https://github.com/anp/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs | ||
|
||
// run-pass | ||
|
||
#![feature(track_caller)] | ||
|
||
use std::panic::Location; | ||
|
||
#[track_caller] | ||
fn tracked() -> &'static Location<'static> { | ||
Location::caller() | ||
} | ||
|
||
fn nested_intrinsic() -> &'static Location<'static> { | ||
Location::caller() | ||
} | ||
|
||
fn nested_tracked() -> &'static Location<'static> { | ||
tracked() | ||
} | ||
|
||
fn main() { | ||
let location = Location::caller(); | ||
assert_eq!(location.file(), file!()); | ||
assert_eq!(location.line(), 23); | ||
assert_eq!(location.column(), 20); | ||
|
||
let tracked = tracked(); | ||
assert_eq!(tracked.file(), file!()); | ||
assert_eq!(tracked.line(), 28); | ||
assert_eq!(tracked.column(), 19); | ||
|
||
let nested = nested_intrinsic(); | ||
assert_eq!(nested.file(), file!()); | ||
assert_eq!(nested.line(), 15); | ||
assert_eq!(nested.column(), 5); | ||
|
||
let contained = nested_tracked(); | ||
assert_eq!(contained.file(), file!()); | ||
assert_eq!(contained.line(), 19); | ||
assert_eq!(contained.column(), 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters