]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #1111 - MarkusPettersson98:rustup-1.21-yaml, r=RalfJung
authorbors <bors@rust-lang.org>
Sun, 8 Dec 2019 13:37:35 +0000 (13:37 +0000)
committerbors <bors@rust-lang.org>
Sun, 8 Dec 2019 13:37:35 +0000 (13:37 +0000)
Updated CI config to reflect deprecation of rustup uninstall

In the same spirit as #1110 ðŸ˜„

This PR from the rustup repository brought me here: https://github.com/rust-lang/rustup/issues/2148

TL;DR With rustup 1.21.0 `rustup install` and `rustup uninstall` are being deprecated in favor of `rustup toolchain install` and `rustup toolchain uninstall`. There's plenty of code/documentation out there that needs to be updated to reflect this.

Thought It would be cool to help, however small the change may be. :)

Keep up the great work!

README.md
tests/run-pass/track-caller-attribute.rs [new file with mode: 0644]

index 16eae05973b2adc616010b72d191f0a6de6962da..e505496a69a856cf0163f2953a194c755e0c63c6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -61,7 +61,7 @@ If `rustup` says the `miri` component is unavailable, that's because not all
 nightly releases come with all tools. Check out
 [this website](https://rust-lang.github.io/rustup-components-history) to
 determine a nightly version that comes with Miri and install that using
-`rustup install nightly-YYYY-MM-DD`.
+`rustup toolchain install nightly-YYYY-MM-DD`.
 
 Now you can run your project in Miri:
 
diff --git a/tests/run-pass/track-caller-attribute.rs b/tests/run-pass/track-caller-attribute.rs
new file mode 100644 (file)
index 0000000..68a0c95
--- /dev/null
@@ -0,0 +1,54 @@
+#![feature(track_caller, core_intrinsics)]
+
+use std::panic::Location;
+
+#[track_caller]
+fn tracked() -> &'static Location<'static> {
+    Location::caller() // most importantly, we never get line 7
+}
+
+fn nested_intrinsic() -> &'static Location<'static> {
+    Location::caller()
+}
+
+fn nested_tracked() -> &'static Location<'static> {
+    tracked()
+}
+
+macro_rules! caller_location_from_macro {
+    () => (core::panic::Location::caller());
+}
+
+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(), 11);
+    assert_eq!(nested.column(), 5);
+
+    let contained = nested_tracked();
+    assert_eq!(contained.file(), file!());
+    assert_eq!(contained.line(), 15);
+    assert_eq!(contained.column(), 5);
+
+    // `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
+    // i.e. point to where the macro was invoked, instead of the macro itself.
+    let inmacro = caller_location_from_macro!();
+    assert_eq!(inmacro.file(), file!());
+    assert_eq!(inmacro.line(), 45);
+    assert_eq!(inmacro.column(), 19);
+
+    let intrinsic = core::intrinsics::caller_location();
+    assert_eq!(intrinsic.file(), file!());
+    assert_eq!(intrinsic.line(), 50);
+    assert_eq!(intrinsic.column(), 21);
+}