diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/indexing/index-bot.rs (renamed from tests/ui/index-bot.rs) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/index-bot.stderr (renamed from tests/ui/index-bot.stderr) | 4 | ||||
-rw-r--r-- | tests/ui/indexing/index-help.rs (renamed from tests/ui/index-help.rs) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/index-help.stderr (renamed from tests/ui/index-help.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/index_message.rs (renamed from tests/ui/index_message.rs) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/index_message.stderr | 9 | ||||
-rw-r--r-- | tests/ui/indexing/indexing-requires-a-uint.rs (renamed from tests/ui/indexing-requires-a-uint.rs) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/indexing-requires-a-uint.stderr (renamed from tests/ui/indexing-requires-a-uint.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/indexing/indexing-spans-caller-location.rs | 27 |
9 files changed, 38 insertions, 2 deletions
diff --git a/tests/ui/index-bot.rs b/tests/ui/indexing/index-bot.rs index e69c4019f..e69c4019f 100644 --- a/tests/ui/index-bot.rs +++ b/tests/ui/indexing/index-bot.rs diff --git a/tests/ui/index-bot.stderr b/tests/ui/indexing/index-bot.stderr index b5d782975..bf231c92c 100644 --- a/tests/ui/index-bot.stderr +++ b/tests/ui/indexing/index-bot.stderr @@ -1,8 +1,8 @@ error[E0608]: cannot index into a value of type `!` - --> $DIR/index-bot.rs:2:5 + --> $DIR/index-bot.rs:2:13 | LL | (return)[0]; - | ^^^^^^^^^^^ + | ^^^ error: aborting due to previous error diff --git a/tests/ui/index-help.rs b/tests/ui/indexing/index-help.rs index 66571ec41..66571ec41 100644 --- a/tests/ui/index-help.rs +++ b/tests/ui/indexing/index-help.rs diff --git a/tests/ui/index-help.stderr b/tests/ui/indexing/index-help.stderr index e020d0298..e020d0298 100644 --- a/tests/ui/index-help.stderr +++ b/tests/ui/indexing/index-help.stderr diff --git a/tests/ui/index_message.rs b/tests/ui/indexing/index_message.rs index 88b848d6f..88b848d6f 100644 --- a/tests/ui/index_message.rs +++ b/tests/ui/indexing/index_message.rs diff --git a/tests/ui/indexing/index_message.stderr b/tests/ui/indexing/index_message.stderr new file mode 100644 index 000000000..80f2bd523 --- /dev/null +++ b/tests/ui/indexing/index_message.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `({integer},)` + --> $DIR/index_message.rs:3:14 + | +LL | let _ = z[0]; + | ^^^ help: to access tuple elements, use: `.0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/indexing-requires-a-uint.rs b/tests/ui/indexing/indexing-requires-a-uint.rs index dbe9b44a1..dbe9b44a1 100644 --- a/tests/ui/indexing-requires-a-uint.rs +++ b/tests/ui/indexing/indexing-requires-a-uint.rs diff --git a/tests/ui/indexing-requires-a-uint.stderr b/tests/ui/indexing/indexing-requires-a-uint.stderr index 7a741cfc7..7a741cfc7 100644 --- a/tests/ui/indexing-requires-a-uint.stderr +++ b/tests/ui/indexing/indexing-requires-a-uint.stderr diff --git a/tests/ui/indexing/indexing-spans-caller-location.rs b/tests/ui/indexing/indexing-spans-caller-location.rs new file mode 100644 index 000000000..2652f0021 --- /dev/null +++ b/tests/ui/indexing/indexing-spans-caller-location.rs @@ -0,0 +1,27 @@ +// run-pass + +// Regression test for https://github.com/rust-lang/rust/issues/114388 + +#[track_caller] +fn caller_line() -> u32 { + std::panic::Location::caller().line() +} + +fn main() { + let prev_line = caller_line(); // first line + (A { prev_line }) // second line + [0]; // third line +} + +struct A { + prev_line: u32, +} +impl std::ops::Index<usize> for A { + type Output = (); + + fn index(&self, _idx: usize) -> &() { + // Use the relative number to make it resistent to header changes. + assert_eq!(caller_line(), self.prev_line + 2); + &() + } +} |