-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d43134
commit 14c9ab8
Showing
24 changed files
with
333 additions
and
1 deletion.
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
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
8 changes: 8 additions & 0 deletions
8
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
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,8 @@ | ||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/feature-gate.rs:11:29 | ||
| | ||
LL | const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST } | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
15 changes: 15 additions & 0 deletions
15
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs
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 @@ | ||
// revisions: stock gated | ||
// gate-test-const_trait_bound_opt_out | ||
|
||
#![cfg_attr(gated, feature(const_trait_bound_opt_out))] | ||
#![allow(incomplete_features)] | ||
|
||
trait T { | ||
const CONST: i32; | ||
} | ||
|
||
const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST } | ||
//[stock]~^ ERROR `?const` on trait bounds is experimental | ||
//[stock,gated]~^^ ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.stock.stderr
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,18 @@ | ||
error[E0658]: `?const` on trait bounds is experimental | ||
--> $DIR/feature-gate.rs:11:29 | ||
| | ||
LL | const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST } | ||
| ^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/67794 | ||
= help: add `#![feature(const_trait_bound_opt_out)]` to the crate attributes to enable | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/feature-gate.rs:11:29 | ||
| | ||
LL | const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST } | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
25 changes: 25 additions & 0 deletions
25
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.rs
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,25 @@ | ||
#![feature(const_trait_bound_opt_out)] | ||
#![feature(associated_type_bounds)] | ||
#![allow(incomplete_features)] | ||
|
||
trait T {} | ||
struct S; | ||
impl T for S {} | ||
|
||
fn rpit() -> impl ?const T { S } | ||
//~^ ERROR `?const` is not permitted in `impl Trait` | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn apit(_: impl ?const T) {} | ||
//~^ ERROR `?const` is not permitted in `impl Trait` | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn rpit_assoc_bound() -> impl IntoIterator<Item: ?const T> { Some(S) } | ||
//~^ ERROR `?const` is not permitted in `impl Trait` | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn apit_assoc_bound(_: impl IntoIterator<Item: ?const T>) {} | ||
//~^ ERROR `?const` is not permitted in `impl Trait` | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn main() {} |
50 changes: 50 additions & 0 deletions
50
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.stderr
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,50 @@ | ||
error: `?const` is not permitted in `impl Trait` | ||
--> $DIR/in-impl-trait.rs:9:19 | ||
| | ||
LL | fn rpit() -> impl ?const T { S } | ||
| ^^^^^^^^ | ||
|
||
error: `?const` is not permitted in `impl Trait` | ||
--> $DIR/in-impl-trait.rs:13:17 | ||
| | ||
LL | fn apit(_: impl ?const T) {} | ||
| ^^^^^^^^ | ||
|
||
error: `?const` is not permitted in `impl Trait` | ||
--> $DIR/in-impl-trait.rs:17:50 | ||
| | ||
LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ?const T> { Some(S) } | ||
| ^^^^^^^^ | ||
|
||
error: `?const` is not permitted in `impl Trait` | ||
--> $DIR/in-impl-trait.rs:21:48 | ||
| | ||
LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ?const T>) {} | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-impl-trait.rs:9:19 | ||
| | ||
LL | fn rpit() -> impl ?const T { S } | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-impl-trait.rs:13:17 | ||
| | ||
LL | fn apit(_: impl ?const T) {} | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-impl-trait.rs:17:50 | ||
| | ||
LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ?const T> { Some(S) } | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-impl-trait.rs:21:48 | ||
| | ||
LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ?const T>) {} | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 8 previous errors | ||
|
9 changes: 9 additions & 0 deletions
9
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.rs
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 @@ | ||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Super {} | ||
trait T: ?const Super {} | ||
//~^ ERROR `?const` is not permitted in supertraits | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.stderr
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,14 @@ | ||
error: `?const` is not permitted in supertraits | ||
--> $DIR/in-trait-bounds.rs:5:10 | ||
| | ||
LL | trait T: ?const Super {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-trait-bounds.rs:5:10 | ||
| | ||
LL | trait T: ?const Super {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.rs
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,18 @@ | ||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(bare_trait_objects)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S; | ||
trait T {} | ||
impl T for S {} | ||
|
||
// An inherent impl for the trait object `?const T`. | ||
impl ?const T {} | ||
//~^ ERROR `?const` is not permitted in trait objects | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn trait_object() -> &'static dyn ?const T { &S } | ||
//~^ ERROR `?const` is not permitted in trait objects | ||
//~| ERROR `?const` on trait bounds is not yet implemented | ||
|
||
fn main() {} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.stderr
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,26 @@ | ||
error: `?const` is not permitted in trait objects | ||
--> $DIR/in-trait-object.rs:10:6 | ||
| | ||
LL | impl ?const T {} | ||
| ^^^^^^^^ | ||
|
||
error: `?const` is not permitted in trait objects | ||
--> $DIR/in-trait-object.rs:14:35 | ||
| | ||
LL | fn trait_object() -> &'static dyn ?const T { &S } | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-trait-object.rs:10:6 | ||
| | ||
LL | impl ?const T {} | ||
| ^^^^^^^^ | ||
|
||
error: `?const` on trait bounds is not yet implemented | ||
--> $DIR/in-trait-object.rs:14:35 | ||
| | ||
LL | fn trait_object() -> &'static dyn ?const T { &S } | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
8 changes: 8 additions & 0 deletions
8
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.rs
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,8 @@ | ||
// compile-flags: -Z parse-only | ||
|
||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S<T: ?const ?const Tr>; | ||
//~^ ERROR expected identifier, found keyword `const` | ||
//~| ERROR expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>` |
14 changes: 14 additions & 0 deletions
14
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.stderr
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,14 @@ | ||
error: expected identifier, found keyword `const` | ||
--> $DIR/opt-out-twice.rs:6:21 | ||
| | ||
LL | struct S<T: ?const ?const Tr>; | ||
| ^^^^^ expected identifier, found keyword | ||
|
||
error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr` | ||
--> $DIR/opt-out-twice.rs:6:27 | ||
| | ||
LL | struct S<T: ?const ?const Tr>; | ||
| ^^ expected one of 7 possible tokens | ||
|
||
error: aborting due to 2 previous errors | ||
|
10 changes: 10 additions & 0 deletions
10
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/syntax.rs
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,10 @@ | ||
// compile-flags: -Z parse-only | ||
// check-pass | ||
|
||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S< | ||
T: ?const ?for<'a> Tr<'a> + 'static + ?const std::ops::Add, | ||
T: ?const ?for<'a: 'b> m::Trait<'a>, | ||
>; |
7 changes: 7 additions & 0 deletions
7
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.rs
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,7 @@ | ||
// compile-flags: -Z parse-only | ||
|
||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S<T: const Tr>; | ||
//~^ ERROR expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, lifetime, or path |
8 changes: 8 additions & 0 deletions
8
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.stderr
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,8 @@ | ||
error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, lifetime, or path, found keyword `const` | ||
--> $DIR/without-question-mark.rs:6:13 | ||
| | ||
LL | struct S<T: const Tr>; | ||
| ^^^^^ expected one of 9 possible tokens | ||
|
||
error: aborting due to previous error | ||
|
8 changes: 8 additions & 0 deletions
8
src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr
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,8 @@ | ||
error: const trait impls are not yet implemented | ||
--> $DIR/feature-gate.rs:9:1 | ||
| | ||
LL | impl const T for S {} | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,13 @@ | ||
// revisions: stock gated | ||
// gate-test-const_trait_impl | ||
|
||
#![cfg_attr(gated, feature(const_trait_impl))] | ||
#![allow(incomplete_features)] | ||
|
||
struct S; | ||
trait T {} | ||
impl const T for S {} | ||
//[stock]~^ ERROR const trait impls are experimental | ||
//[stock,gated]~^^ ERROR const trait impls are not yet implemented | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr
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,18 @@ | ||
error[E0658]: const trait impls are experimental | ||
--> $DIR/feature-gate.rs:9:6 | ||
| | ||
LL | impl const T for S {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/67792 | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
|
||
error: const trait impls are not yet implemented | ||
--> $DIR/feature-gate.rs:9:1 | ||
| | ||
LL | impl const T for S {} | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
11 changes: 11 additions & 0 deletions
11
src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.rs
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,11 @@ | ||
#![feature(const_trait_bound_opt_out)] | ||
#![feature(const_trait_impl)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S; | ||
trait T {} | ||
|
||
impl ?const T for S {} | ||
//~^ ERROR expected a trait, found type | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.stderr
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,8 @@ | ||
error: expected a trait, found type | ||
--> $DIR/impl-opt-out-trait.rs:8:6 | ||
| | ||
LL | impl ?const T for S {} | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,14 @@ | ||
// compile-flags: -Z parse-only | ||
|
||
#![feature(const_trait_impl)] | ||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
#![allow(bare_trait_objects)] | ||
|
||
struct S; | ||
trait T {} | ||
|
||
impl const T {} | ||
//~^ ERROR `const` cannot modify an inherent impl | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr
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,10 @@ | ||
error: `const` cannot modify an inherent impl | ||
--> $DIR/inherent-impl.rs:11:6 | ||
| | ||
LL | impl const T {} | ||
| ^^^^^ | ||
| | ||
= help: only a trait impl can be `const` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
// compile-flags: -Z parse-only | ||
// check-pass | ||
|
||
#![feature(const_trait_bound_opt_out)] | ||
#![feature(const_trait_impl)] | ||
#![allow(incomplete_features)] | ||
|
||
// For now, this parses since an error does not occur until AST lowering. | ||
impl ?const T {} |