Name higher-ranked lifetimes properly while displaying
Now they don't shadow other lifetimes.
This commit is contained in:
parent
108706f13a
commit
9b0480bec6
5 changed files with 229 additions and 21 deletions
40
src/test/ui/anonymous-higher-ranked-lifetime.rs
Normal file
40
src/test/ui/anonymous-higher-ranked-lifetime.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
f1(|_: (), _: ()| {});
|
||||
f2(|_: (), _: ()| {});
|
||||
f3(|_: (), _: ()| {});
|
||||
f4(|_: (), _: ()| {});
|
||||
f5(|_: (), _: ()| {});
|
||||
g1(|_: (), _: ()| {});
|
||||
g2(|_: (), _: ()| {});
|
||||
g3(|_: (), _: ()| {});
|
||||
g4(|_: (), _: ()| {});
|
||||
h1(|_: (), _: (), _: (), _: ()| {});
|
||||
h2(|_: (), _: (), _: (), _: ()| {});
|
||||
}
|
||||
|
||||
// Basic
|
||||
fn f1<F>(_: F) where F: Fn(&(), &()) {}
|
||||
fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
|
||||
fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
|
||||
fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
|
||||
fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
|
||||
|
||||
// Nested
|
||||
fn g1<F>(_: F) where F: Fn(&(), Box<Fn(&())>) {}
|
||||
fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
|
||||
fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<Fn(&())>) {}
|
||||
fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
|
||||
|
||||
// Mixed
|
||||
fn h1<F>(_: F) where F: Fn(&(), Box<Fn(&())>, &(), fn(&(), &())) {}
|
||||
fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &())) {}
|
||||
112
src/test/ui/anonymous-higher-ranked-lifetime.stderr
Normal file
112
src/test/ui/anonymous-higher-ranked-lifetime.stderr
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
|
||||
|
|
||||
12 | f1(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _`
|
||||
|
|
||||
= note: required by `f1`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:13:5
|
||||
|
|
||||
13 | f2(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _`
|
||||
|
|
||||
= note: required by `f2`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:14:5
|
||||
|
|
||||
14 | f3(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r> fn(&(), &'r ()) -> _`
|
||||
|
|
||||
= note: required by `f3`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:15:5
|
||||
|
|
||||
15 | f4(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _`
|
||||
|
|
||||
= note: required by `f4`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:5
|
||||
|
|
||||
16 | f5(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r> fn(&'r (), &'r ()) -> _`
|
||||
|
|
||||
= note: required by `f5`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:17:5
|
||||
|
|
||||
17 | g1(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r> fn(&'r (), std::boxed::Box<for<'s> std::ops::Fn(&'s ()) + 'static>) -> _`
|
||||
|
|
||||
= note: required by `g1`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:5
|
||||
|
|
||||
18 | g2(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _`
|
||||
|
|
||||
= note: required by `g2`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:19:5
|
||||
|
|
||||
19 | g3(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'s> fn(&'s (), std::boxed::Box<for<'r> std::ops::Fn(&'r ()) + 'static>) -> _`
|
||||
|
|
||||
= note: required by `g3`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:20:5
|
||||
|
|
||||
20 | g4(|_: (), _: ()| {});
|
||||
| ^^ ----------------- found signature of `fn((), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _`
|
||||
|
|
||||
= note: required by `g4`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:21:5
|
||||
|
|
||||
21 | h1(|_: (), _: (), _: (), _: ()| {});
|
||||
| ^^ ------------------------------- found signature of `fn((), (), (), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box<for<'t0> std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _`
|
||||
|
|
||||
= note: required by `h1`
|
||||
|
||||
error[E0631]: type mismatch in closure arguments
|
||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:22:5
|
||||
|
|
||||
22 | h2(|_: (), _: (), _: (), _: ()| {});
|
||||
| ^^ ------------------------------- found signature of `fn((), (), (), ()) -> _`
|
||||
| |
|
||||
| expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box<for<'s> std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _`
|
||||
|
|
||||
= note: required by `h2`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ error[E0308]: mismatched types
|
|||
51 | want_F(bar); //~ ERROR E0308
|
||||
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
|
||||
|
|
||||
= note: expected type `fn(&'cx S) -> &'cx S`
|
||||
= note: expected type `for<'cx> fn(&'cx S) -> &'cx S`
|
||||
found type `fn(&'a S) -> &S {bar::<'_>}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue