From a20870bdb9ecce8af7acb2db13177fc52f890f92 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 13:01:04 +0200 Subject: [PATCH 1/3] Comment out unused error codes in error_codes.rs --- compiler/rustc_error_codes/src/error_codes.rs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index c343809179b0a..f82c03a4f8894 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -553,8 +553,8 @@ E0783: include_str!("./error_codes/E0783.md"), E0311, // thing may not live long enough E0313, // lifetime of borrowed pointer outlives lifetime of captured // variable - E0314, // closure outlives stack frame - E0315, // cannot invoke closure outside of its lifetime +// E0314, // closure outlives stack frame +// E0315, // cannot invoke closure outside of its lifetime E0316, // nested quantification of lifetimes // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck @@ -584,21 +584,21 @@ E0783: include_str!("./error_codes/E0783.md"), // E0470, removed // E0471, // constant evaluation error (in pattern) E0472, // llvm_asm! is unsupported on this target - E0473, // dereference of reference outside its lifetime - E0474, // captured variable `..` does not outlive the enclosing closure - E0475, // index of slice outside its lifetime +// E0473, // dereference of reference outside its lifetime +// E0474, // captured variable `..` does not outlive the enclosing closure +// E0475, // index of slice outside its lifetime E0476, // lifetime of the source pointer does not outlive lifetime bound... - E0479, // the type `..` (provided as the value of a type parameter) is... - E0480, // lifetime of method receiver does not outlive the method call - E0481, // lifetime of function argument does not outlive the function call +// E0479, // the type `..` (provided as the value of a type parameter) is... +// E0480, // lifetime of method receiver does not outlive the method call +// E0481, // lifetime of function argument does not outlive the function call E0482, // lifetime of return value does not outlive the function call - E0483, // lifetime of operand does not outlive the operation - E0484, // reference is not valid at the time of borrow - E0485, // automatically reference is not valid at the time of borrow - E0486, // type of expression contains references that are not valid during.. - E0487, // unsafe use of destructor: destructor might be called while... - E0488, // lifetime of variable does not enclose its declaration - E0489, // type/lifetime parameter not in scope here +// E0483, // lifetime of operand does not outlive the operation +// E0484, // reference is not valid at the time of borrow +// E0485, // automatically reference is not valid at the time of borrow +// E0486, // type of expression contains references that are not valid during.. +// E0487, // unsafe use of destructor: destructor might be called while... +// E0488, // lifetime of variable does not enclose its declaration +// E0489, // type/lifetime parameter not in scope here E0490, // a value of type `..` is borrowed for too long E0498, // malformed plugin attribute E0514, // metadata version mismatch From c01d63ab767084eba25bfc317d5aa1f21820836d Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 13:05:17 +0200 Subject: [PATCH 2/3] Add E0316.md --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../src/error_codes/E0316.md | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0316.md diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index f82c03a4f8894..f10efd832361c 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -157,6 +157,7 @@ E0308: include_str!("./error_codes/E0308.md"), E0309: include_str!("./error_codes/E0309.md"), E0310: include_str!("./error_codes/E0310.md"), E0312: include_str!("./error_codes/E0312.md"), +E0316: include_str!("./error_codes/E0316.md"), E0317: include_str!("./error_codes/E0317.md"), E0321: include_str!("./error_codes/E0321.md"), E0322: include_str!("./error_codes/E0322.md"), @@ -555,7 +556,6 @@ E0783: include_str!("./error_codes/E0783.md"), // variable // E0314, // closure outlives stack frame // E0315, // cannot invoke closure outside of its lifetime - E0316, // nested quantification of lifetimes // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck // E0372, // coherence not object safe diff --git a/compiler/rustc_error_codes/src/error_codes/E0316.md b/compiler/rustc_error_codes/src/error_codes/E0316.md new file mode 100644 index 0000000000000..4368c321737b2 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0316.md @@ -0,0 +1,32 @@ +A `where` clause contains a nested quantification over lifetimes. + +Erroneous code example: + +```compile_fail,E0316 +trait Tr<'a, 'b> {} + +fn foo(t: T) +where + for<'a> &'a T: for<'b> Tr<'a, 'b>, // error: nested quantification +{ +} +``` + +Rust syntax allows lifetime quantifications in two places within +`where` clauses: Quantifying over the trait bound only (as in +`Ty: for<'l> Trait<'l>`) and quantifying over the whole clause +(as in `for<'l> &'l Ty: Trait<'l>`). Using both in the same clause +leads to a nested lifetime quantification, which is not supported. + +The following example compiles, because the clause with the nested +quantification has been rewritten to use only one `for<>`: + +``` +trait Tr<'a, 'b> {} + +fn foo(t: T) +where + for<'a, 'b> &'a T: Tr<'a, 'b>, // ok +{ +} +``` From 09307a3e0db0154ac0c37443463a73c32bfe9b5d Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 15:00:47 +0200 Subject: [PATCH 3/3] Bless ui/where-clauses/where-for-self.rs test --- src/test/ui/where-clauses/where-for-self.stderr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/where-clauses/where-for-self.stderr b/src/test/ui/where-clauses/where-for-self.stderr index 84430ffcf887f..d06afc1e42376 100644 --- a/src/test/ui/where-clauses/where-for-self.stderr +++ b/src/test/ui/where-clauses/where-for-self.stderr @@ -6,3 +6,4 @@ LL | where for<'a> &'a T: for<'b> Bar<'b> error: aborting due to previous error +For more information about this error, try `rustc --explain E0316`.