-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated forms of elision are not supported.
- Loading branch information
1 parent
df70060
commit 94468da
Showing
18 changed files
with
617 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2017 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. | ||
|
||
#![allow(warnings)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
trait MyTrait<'a> { } | ||
|
||
impl<'a> MyTrait<'a> for &u32 { } | ||
//~^ ERROR missing lifetime specifier | ||
|
||
impl<'a> MyTrait<'_> for &'a f32 { } | ||
//~^ ERROR missing lifetime specifier | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:16:26 | ||
| | ||
LL | impl<'a> MyTrait<'a> for &u32 { } | ||
| ^ expected lifetime parameter | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:19:18 | ||
| | ||
LL | impl<'a> MyTrait<'_> for &'a f32 { } | ||
| ^^ expected lifetime parameter | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0106`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2018 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. | ||
|
||
// Test that we do not yet support elision in associated types, even | ||
// when there is just one name we could take from the impl header. | ||
|
||
#![allow(warnings)] | ||
|
||
#![feature(in_band_lifetimes)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
trait MyTrait { | ||
type Output; | ||
} | ||
|
||
impl MyTrait for &i32 { | ||
type Output = &i32; | ||
//~^ ERROR missing lifetime specifier | ||
} | ||
|
||
impl MyTrait for &u32 { | ||
type Output = &'_ i32; | ||
//~^ ERROR missing lifetime specifier | ||
} | ||
|
||
// This is what you have to do: | ||
impl MyTrait for &'a f32 { | ||
type Output = &'a f32; | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/assoc-type.rs:24:19 | ||
| | ||
LL | type Output = &i32; | ||
| ^ expected lifetime parameter | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/assoc-type.rs:29:20 | ||
| | ||
LL | type Output = &'_ i32; | ||
| ^^ expected lifetime parameter | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0106`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2018 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. | ||
|
||
// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a, | ||
// 'b> MyTrait<'a> for &'b i32`. | ||
|
||
#![allow(warnings)] | ||
|
||
#![feature(dyn_trait)] | ||
#![feature(in_band_lifetimes)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
use std::fmt::Debug; | ||
|
||
// Equivalent to `Box<dyn Debug + 'static>`: | ||
trait StaticTrait { } | ||
impl StaticTrait for Box<dyn Debug> { } | ||
|
||
// Equivalent to `Box<dyn Debug + 'static>`: | ||
trait NotStaticTrait { } | ||
impl NotStaticTrait for Box<dyn Debug + '_> { } | ||
|
||
fn static_val<T: StaticTrait>(_: T) { | ||
} | ||
|
||
fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { | ||
static_val(x); //~ ERROR cannot infer | ||
} | ||
|
||
fn not_static_val<T: NotStaticTrait>(_: T) { | ||
} | ||
|
||
fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) { | ||
not_static_val(x); // OK | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements | ||
--> $DIR/dyn-trait.rs:34:16 | ||
| | ||
LL | static_val(x); //~ ERROR cannot infer | ||
| ^ | ||
| | ||
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 33:1... | ||
--> $DIR/dyn-trait.rs:33:1 | ||
| | ||
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...so that the expression is assignable: | ||
expected std::boxed::Box<std::fmt::Debug> | ||
found std::boxed::Box<std::fmt::Debug + 'a> | ||
= note: but, the lifetime must be valid for the static lifetime... | ||
= note: ...so that the types are compatible: | ||
expected StaticTrait | ||
found StaticTrait | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0495`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018 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. | ||
#![allow(warnings)] | ||
|
||
#![feature(in_band_lifetimes)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
trait MyTrait { } | ||
|
||
struct Foo<'a> { x: &'a u32 } | ||
|
||
impl MyTrait for Foo { | ||
//~^ ERROR missing lifetime specifier | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/path-elided.rs:19:18 | ||
| | ||
LL | impl MyTrait for Foo { | ||
| ^^^ expected lifetime parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0106`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2018 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. | ||
|
||
// Test that `impl MyTrait for Foo<'_>` works. | ||
|
||
// run-pass | ||
|
||
#![allow(warnings)] | ||
|
||
#![feature(in_band_lifetimes)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
trait MyTrait { } | ||
|
||
struct Foo<'a> { x: &'a u32 } | ||
|
||
impl MyTrait for Foo<'_> { | ||
} | ||
|
||
fn impls_my_trait<T: MyTrait>() { } | ||
|
||
fn impls_my_trait_val<T: MyTrait>(_: T) { | ||
impls_my_trait::<T>(); | ||
} | ||
|
||
fn random_where_clause() | ||
where for<'a> Foo<'a>: MyTrait { } | ||
|
||
fn main() { | ||
let x = 22; | ||
let f = Foo { x: &x }; | ||
|
||
// This type is `Foo<'x>` for a local lifetime `'x`; so the impl | ||
// must apply to any lifetime to apply to this. | ||
impls_my_trait_val(f); | ||
|
||
impls_my_trait::<Foo<'static>>(); | ||
|
||
random_where_clause(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2018 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. | ||
|
||
// Test that `impl MyTrait for &i32` works and is equivalent to any lifetime. | ||
|
||
// run-pass | ||
|
||
#![allow(warnings)] | ||
|
||
#![feature(in_band_lifetimes)] | ||
#![feature(underscore_lifetimes)] | ||
|
||
trait MyTrait { } | ||
|
||
impl MyTrait for &i32 { | ||
} | ||
|
||
fn impls_my_trait<T: MyTrait>() { } | ||
|
||
fn impls_my_trait_val<T: MyTrait>(_: T) { | ||
impls_my_trait::<T>(); | ||
} | ||
|
||
fn random_where_clause() | ||
where for<'a> &'a i32: MyTrait { } | ||
|
||
fn main() { | ||
let x = 22; | ||
let f = &x; | ||
|
||
impls_my_trait_val(f); | ||
|
||
impls_my_trait::<&'static i32>(); | ||
|
||
random_where_clause(); | ||
} |
Oops, something went wrong.