about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-05-29 11:29:49 +0900
committerYuki Okushi <jtitor@2k36.org>2022-05-29 11:29:49 +0900
commit5a4e9363a3fe142d5c7ea7acb8c61985fe34e704 (patch)
treed9502b7302e8f0baa06a9f8603030497015fa66c /src
parent14f477e78adb9960f760e9bac812673f993d8dc2 (diff)
downloadrust-5a4e9363a3fe142d5c7ea7acb8c61985fe34e704.tar.gz
rust-5a4e9363a3fe142d5c7ea7acb8c61985fe34e704.zip
Ensure source file present when calculating max line number
Co-authored-by: Ross MacArthur <ross@macarthur.io>
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/span/issue-71363.rs10
-rw-r--r--src/test/ui/span/issue-71363.stderr27
2 files changed, 37 insertions, 0 deletions
diff --git a/src/test/ui/span/issue-71363.rs b/src/test/ui/span/issue-71363.rs
new file mode 100644
index 00000000000..3e85559caf9
--- /dev/null
+++ b/src/test/ui/span/issue-71363.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no
+// only-x86_64-unknown-linux-gnu
+//---^ Limiting target as the above unstable flags don't play well on some environment.
+
+struct MyError;
+impl std::error::Error for MyError {}
+//~^ ERROR: `MyError` doesn't implement `std::fmt::Display`
+//~| ERROR: `MyError` doesn't implement `Debug`
+
+fn main() {}
diff --git a/src/test/ui/span/issue-71363.stderr b/src/test/ui/span/issue-71363.stderr
new file mode 100644
index 00000000000..d54f21752b8
--- /dev/null
+++ b/src/test/ui/span/issue-71363.stderr
@@ -0,0 +1,27 @@
+error[E0277]: `MyError` doesn't implement `std::fmt::Display`
+ --> $DIR/issue-71363.rs:6:6
+  |
+6 | impl std::error::Error for MyError {}
+  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
+  |
+  = help: the trait `std::fmt::Display` is not implemented for `MyError`
+  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `std::error::Error`
+
+error[E0277]: `MyError` doesn't implement `Debug`
+ --> $DIR/issue-71363.rs:6:6
+  |
+6 | impl std::error::Error for MyError {}
+  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
+  |
+  = help: the trait `Debug` is not implemented for `MyError`
+  = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
+note: required by a bound in `std::error::Error`
+help: consider annotating `MyError` with `#[derive(Debug)]`
+  |
+5 | #[derive(Debug)]
+  |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.