about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-29 10:17:11 +0100
committerGitHub <noreply@github.com>2021-12-29 10:17:11 +0100
commitc82b2bc590a39694948b685ca1f715a9ad0ecc08 (patch)
treee60564c74a4b106e4268c2ba3b4232a066b6cde9
parent0e4119488d908ae84ddc794b5ae73c5358199e7e (diff)
parent406d6d4028260f6c5ff02562831c137c41e0bb95 (diff)
downloadrust-c82b2bc590a39694948b685ca1f715a9ad0ecc08.tar.gz
rust-c82b2bc590a39694948b685ca1f715a9ad0ecc08.zip
Rollup merge of #92351 - TmLev:master, r=GuillaumeGomez
Add long error explanation for E0227

Part of the #61137.
-rw-r--r--compiler/rustc_error_codes/src/error_codes.rs2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0227.md33
-rw-r--r--src/test/ui/error-codes/E0227.rs12
-rw-r--r--src/test/ui/error-codes/E0227.stderr9
-rw-r--r--src/tools/tidy/src/error_codes_check.rs4
5 files changed, 57 insertions, 3 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs
index ce26ff62235..79d9c55b547 100644
--- a/compiler/rustc_error_codes/src/error_codes.rs
+++ b/compiler/rustc_error_codes/src/error_codes.rs
@@ -120,6 +120,7 @@ E0223: include_str!("./error_codes/E0223.md"),
 E0224: include_str!("./error_codes/E0224.md"),
 E0225: include_str!("./error_codes/E0225.md"),
 E0226: include_str!("./error_codes/E0226.md"),
+E0227: include_str!("./error_codes/E0227.md"),
 E0228: include_str!("./error_codes/E0228.md"),
 E0229: include_str!("./error_codes/E0229.md"),
 E0230: include_str!("./error_codes/E0230.md"),
@@ -530,7 +531,6 @@ E0786: include_str!("./error_codes/E0786.md"),
 //  E0217, // ambiguous associated type, defined in multiple supertraits
 //  E0218, // no associated type defined
 //  E0219, // associated type defined in higher-ranked supertrait
-    E0227, // ambiguous lifetime bound, explicit lifetime bound required
 //  E0233,
 //  E0234,
 //  E0235, // structure constructor specifies a structure of type but
diff --git a/compiler/rustc_error_codes/src/error_codes/E0227.md b/compiler/rustc_error_codes/src/error_codes/E0227.md
new file mode 100644
index 00000000000..f68614723d4
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0227.md
@@ -0,0 +1,33 @@
+This error indicates that the compiler is unable to determine whether there is
+exactly one unique region in the set of derived region bounds.
+
+Example of erroneous code:
+
+```compile_fail,E0227
+trait Foo<'foo>: 'foo {}
+trait Bar<'bar>: 'bar {}
+
+trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}
+
+struct Baz<'foo, 'bar> {
+    baz: dyn FooBar<'foo, 'bar>,
+}
+```
+
+Here, `baz` can have either `'foo` or `'bar` lifetimes.
+
+To resolve this error, provide an explicit lifetime:
+
+```rust
+trait Foo<'foo>: 'foo {}
+trait Bar<'bar>: 'bar {}
+
+trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}
+
+struct Baz<'foo, 'bar, 'baz>
+where
+    'baz: 'foo + 'bar,
+{
+    obj: dyn FooBar<'foo, 'bar> + 'baz,
+}
+```
diff --git a/src/test/ui/error-codes/E0227.rs b/src/test/ui/error-codes/E0227.rs
new file mode 100644
index 00000000000..0f0a781d2f9
--- /dev/null
+++ b/src/test/ui/error-codes/E0227.rs
@@ -0,0 +1,12 @@
+trait Foo<'foo>: 'foo {}
+trait Bar<'bar>: 'bar {}
+
+trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}
+
+struct Baz<'foo, 'bar> {
+    baz: dyn FooBar<'foo, 'bar>,
+    //~^ ERROR ambiguous lifetime bound, explicit lifetime bound required
+}
+
+fn main() {
+}
diff --git a/src/test/ui/error-codes/E0227.stderr b/src/test/ui/error-codes/E0227.stderr
new file mode 100644
index 00000000000..26de5b4c400
--- /dev/null
+++ b/src/test/ui/error-codes/E0227.stderr
@@ -0,0 +1,9 @@
+error[E0227]: ambiguous lifetime bound, explicit lifetime bound required
+  --> $DIR/E0227.rs:7:10
+   |
+LL |     baz: dyn FooBar<'foo, 'bar>,
+   |          ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0227`.
diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs
index 6d3e470bf43..8ea6bb308b7 100644
--- a/src/tools/tidy/src/error_codes_check.rs
+++ b/src/tools/tidy/src/error_codes_check.rs
@@ -10,8 +10,8 @@ use regex::Regex;
 
 // A few of those error codes can't be tested but all the others can and *should* be tested!
 const EXEMPTED_FROM_TEST: &[&str] = &[
-    "E0227", "E0279", "E0280", "E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0514",
-    "E0519", "E0523", "E0554", "E0640", "E0717", "E0729",
+    "E0279", "E0280", "E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0514", "E0519",
+    "E0523", "E0554", "E0640", "E0717", "E0729",
 ];
 
 // Some error codes don't have any tests apparently...