about summary refs log tree commit diff
path: root/src/test/parse-fail
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-09 10:45:29 +0000
committerbors <bors@rust-lang.org>2018-03-09 10:45:29 +0000
commitfedce67cd21dc08ece5a484fe1a060346acac98a (patch)
tree2cc26079f1d4ee58c1bc38e326585013e52f7e6b /src/test/parse-fail
parent2079a084df08c38eb4dbfc5c8de5c0245170c3d9 (diff)
parent780b544a391fb2dc42d814ce8cb7e6ad3633fa39 (diff)
downloadrust-fedce67cd21dc08ece5a484fe1a060346acac98a.tar.gz
rust-fedce67cd21dc08ece5a484fe1a060346acac98a.zip
Auto merge of #48326 - RalfJung:generic-bounds, r=petrochenkov
Warn about ignored generic bounds in `for`

This adds a new lint to fix #42181. For consistency and to avoid code duplication, I also moved the existing "bounds in type aliases are ignored" here.

Questions to the reviewer:
* Is it okay to just remove a diagnostic error code like this? Should I instead keep the warning about type aliases where it is? The old code provided a detailed explanation of what's going on when asked, that information is now lost. On the other hand, `span_warn!` seems deprecated (after this patch, it has exactly one user left!).
* Did I miss any syntactic construct that can appear as `for` in the surface syntax? I covered function types (`for<'a> fn(...)`), generic traits (`for <'a> Fn(...)`, can appear both as bounds as as trait objects) and bounds (`for<'a> F: ...`).
* For the sake of backwards compatibility, this adds a warning, not an error. @nikomatsakis suggested an error in https://github.com/rust-lang/rust/issues/42181#issuecomment-306924389, but I feel that can only happen in a new epoch -- right?

Cc @eddyb
Diffstat (limited to 'src/test/parse-fail')
-rw-r--r--src/test/parse-fail/bounds-lifetime.rs11
-rw-r--r--src/test/parse-fail/bounds-type.rs2
2 files changed, 6 insertions, 7 deletions
diff --git a/src/test/parse-fail/bounds-lifetime.rs b/src/test/parse-fail/bounds-lifetime.rs
index 5113a6b4803..88db205310c 100644
--- a/src/test/parse-fail/bounds-lifetime.rs
+++ b/src/test/parse-fail/bounds-lifetime.rs
@@ -8,17 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// compile-flags: -Z parse-only -Z continue-parse-after-error
+// compile-flags: -Z parse-only
 
-type A = for<'a: 'b + 'c> fn(); // OK
-type A = for<'a: 'b,> fn(); // OK
 type A = for<'a:> fn(); // OK
 type A = for<'a:,> fn(); // OK
 type A = for<'a> fn(); // OK
 type A = for<> fn(); // OK
-type A = for<'a: 'b +> fn(); // OK
-
-type A = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context
+type A = for<'a: 'b + 'c> fn(); // OK (rejected later by ast_validation)
+type A = for<'a: 'b,> fn(); // OK(rejected later by ast_validation)
+type A = for<'a: 'b +> fn(); // OK (rejected later by ast_validation)
+type A = for<'a, T> fn(); // OK (rejected later by ast_validation)
 type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
 
 fn main() {}
diff --git a/src/test/parse-fail/bounds-type.rs b/src/test/parse-fail/bounds-type.rs
index c224b44a14b..0ebe7fde0a6 100644
--- a/src/test/parse-fail/bounds-type.rs
+++ b/src/test/parse-fail/bounds-type.rs
@@ -15,7 +15,7 @@ struct S<
     T: Tr + 'a, // OK
     T: 'a, // OK
     T:, // OK
-    T: ?for<'a: 'b + 'c> Trait, // OK
+    T: ?for<'a> Trait, // OK
     T: Tr +, // OK
     T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
 >;