about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-03-04 20:01:09 +0900
committerGitHub <noreply@github.com>2021-03-04 20:01:09 +0900
commitc3988713417ecde47e176920924517ae21b3fb3b (patch)
tree071eef6d4c684a93a8454a1b8bcea7b433c392a1 /src/test
parent761ceab467a0a8c42bfeed03842a352f3b039026 (diff)
parent5d0697b1be074a0774f521baf97492260e2a0737 (diff)
Rollup merge of #82717 - estebank:issue-70152, r=lcnr
Account for macros when suggesting adding lifetime

Fix #70152.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.rs16
-rw-r--r--src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr40
2 files changed, 56 insertions, 0 deletions
diff --git a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.rs b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.rs
new file mode 100644
index 00000000000..cc29f9de7fb
--- /dev/null
+++ b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.rs
@@ -0,0 +1,16 @@
+#[derive(Eq, PartialEq)]
+struct Test {
+    a: &'b str,
+    //~^ ERROR use of undeclared lifetime name `'b`
+    //~| ERROR use of undeclared lifetime name `'b`
+}
+
+trait T {
+    fn foo(&'static self) {}
+}
+
+impl T for Test {
+    fn foo(&'b self) {} //~ ERROR use of undeclared lifetime name `'b`
+}
+
+fn main() {}
diff --git a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr
new file mode 100644
index 00000000000..30142e24cd5
--- /dev/null
+++ b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr
@@ -0,0 +1,40 @@
+error[E0261]: use of undeclared lifetime name `'b`
+  --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:13:13
+   |
+LL |     fn foo(&'b self) {}
+   |             ^^ undeclared lifetime
+   |
+   = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
+help: consider introducing lifetime `'b` here
+   |
+LL | impl<'b> T for Test {
+   |     ^^^^
+help: consider introducing lifetime `'b` here
+   |
+LL |     fn foo<'b>(&'b self) {}
+   |           ^^^^
+
+error[E0261]: use of undeclared lifetime name `'b`
+  --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9
+   |
+LL | struct Test {
+   |            - help: consider introducing lifetime `'b` here: `<'b>`
+LL |     a: &'b str,
+   |         ^^ undeclared lifetime
+   |
+   = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
+
+error[E0261]: use of undeclared lifetime name `'b`
+  --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9
+   |
+LL | #[derive(Eq, PartialEq)]
+   |          -- lifetime `'b` is missing in item created through this procedural macro
+LL | struct Test {
+LL |     a: &'b str,
+   |         ^^ undeclared lifetime
+   |
+   = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0261`.