-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
~const trait or projection bounds do not imply non-const bounds
- Loading branch information
1 parent
75c68cf
commit 6203fca
Showing
11 changed files
with
213 additions
and
82 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
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
86 changes: 86 additions & 0 deletions
86
tests/ui/rfcs/rfc-2632-const-trait-impl/const-fns-are-early-bound.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,86 @@ | ||
// check-pass | ||
|
||
#![crate_type = "lib"] | ||
#![allow(internal_features)] | ||
#![no_std] | ||
#![no_core] | ||
#![feature( | ||
auto_traits, | ||
const_trait_impl, | ||
effects, | ||
lang_items, | ||
no_core, | ||
staged_api, | ||
unboxed_closures | ||
)] | ||
#![stable(feature = "minicore", since = "1.0.0")] | ||
|
||
fn test() { | ||
fn is_const_fn<F>(_: F) | ||
where | ||
F: const FnOnce<()>, | ||
{ | ||
} | ||
|
||
const fn foo() {} | ||
|
||
is_const_fn(foo); | ||
} | ||
|
||
/// ---------------------------------------------------------------------- /// | ||
/// Const fn trait definitions | ||
#[const_trait] | ||
#[lang = "fn"] | ||
#[rustc_paren_sugar] | ||
trait Fn<Args: Tuple>: ~const FnMut<Args> { | ||
extern "rust-call" fn call(&self, args: Args) -> Self::Output; | ||
} | ||
|
||
#[const_trait] | ||
#[lang = "fn_mut"] | ||
#[rustc_paren_sugar] | ||
trait FnMut<Args: Tuple>: ~const FnOnce<Args> { | ||
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; | ||
} | ||
|
||
#[const_trait] | ||
#[lang = "fn_once"] | ||
#[rustc_paren_sugar] | ||
trait FnOnce<Args: Tuple> { | ||
#[lang = "fn_once_output"] | ||
type Output; | ||
|
||
extern "rust-call" fn call_once(self, args: Args) -> Self::Output; | ||
} | ||
|
||
/// ---------------------------------------------------------------------- /// | ||
/// All this other stuff needed for core. Unrelated to test. | ||
#[lang = "destruct"] | ||
#[const_trait] | ||
trait Destruct {} | ||
|
||
#[lang = "freeze"] | ||
unsafe auto trait Freeze {} | ||
|
||
#[lang = "drop"] | ||
#[const_trait] | ||
trait Drop { | ||
fn drop(&mut self); | ||
} | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
#[lang = "tuple_trait"] | ||
trait Tuple {} | ||
|
||
#[lang = "receiver"] | ||
trait Receiver {} | ||
|
||
impl<T: ?Sized> Receiver for &T {} | ||
|
||
impl<T: ?Sized> Receiver for &mut T {} |
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
65 changes: 65 additions & 0 deletions
65
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/project.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,65 @@ | ||
error[E0277]: the trait bound `Self: Uwu` is not satisfied | ||
--> $DIR/project.rs:12:1 | ||
| | ||
LL | pub trait Uwu: Owo { | ||
| ^^^^^^^^^^^^^^^^^^ the trait `Uwu` is not implemented for `Self` | ||
| | ||
help: consider further restricting `Self` | ||
| | ||
LL | pub trait Uwu: Owo + Uwu { | ||
| +++++ | ||
|
||
error[E0277]: the trait bound `Self: Uwu` is not satisfied | ||
--> $DIR/project.rs:12:1 | ||
| | ||
LL | / pub trait Uwu: Owo { | ||
LL | | type T; | ||
LL | | } | ||
| |_^ the trait `Uwu` is not implemented for `Self` | ||
| | ||
help: consider further restricting `Self` | ||
| | ||
LL | pub trait Uwu: Owo + Uwu { | ||
| +++++ | ||
|
||
error[E0277]: the trait bound `Self: Uwu` is not satisfied | ||
--> $DIR/project.rs:12:16 | ||
| | ||
LL | pub trait Uwu: Owo { | ||
| ^^^ the trait `Uwu` is not implemented for `Self` | ||
| | ||
note: required by a bound in `Owo` | ||
--> $DIR/project.rs:9:15 | ||
| | ||
LL | pub trait Owo<X = <Self as /* FIXME: ~const */ Uwu>::T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Owo` | ||
help: consider further restricting `Self` | ||
| | ||
LL | pub trait Uwu: Owo + Uwu { | ||
| +++++ | ||
|
||
error[E0277]: the trait bound `Self: Uwu` is not satisfied | ||
--> $DIR/project.rs:13:5 | ||
| | ||
LL | type T; | ||
| ^^^^^^ the trait `Uwu` is not implemented for `Self` | ||
| | ||
help: consider further restricting `Self` | ||
| | ||
LL | pub trait Uwu: Owo + Uwu { | ||
| +++++ | ||
|
||
error[E0277]: the trait bound `Self: Uwu` is not satisfied | ||
--> $DIR/project.rs:13:5 | ||
| | ||
LL | type T; | ||
| ^^^^^^^ the trait `Uwu` is not implemented for `Self` | ||
| | ||
help: consider further restricting `Self` | ||
| | ||
LL | pub trait Uwu: Owo + Uwu { | ||
| +++++ | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
34 changes: 24 additions & 10 deletions
34
tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.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 |
---|---|---|
@@ -1,21 +1,35 @@ | ||
error[E0308]: mismatched types | ||
error[E0277]: the trait bound `T: ~const Bar` is not satisfied | ||
--> $DIR/trait-where-clause-const.rs:21:5 | ||
| | ||
LL | T::b(); | ||
| ^^^^^^ expected `host`, found `true` | ||
| ^ the trait `~const Bar` is not implemented for `T` | ||
| | ||
= note: expected constant `host` | ||
found constant `true` | ||
note: required by a bound in `Foo::b` | ||
--> $DIR/trait-where-clause-const.rs:15:24 | ||
| | ||
LL | fn b() where Self: ~const Bar; | ||
| ^^^^^^^^^^ required by this bound in `Foo::b` | ||
help: consider further restricting this bound | ||
| | ||
LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { | ||
| ++++++++++++ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/trait-where-clause-const.rs:23:5 | ||
error[E0277]: the trait bound `T: ~const Bar` is not satisfied | ||
--> $DIR/trait-where-clause-const.rs:23:12 | ||
| | ||
LL | T::c::<T>(); | ||
| ^^^^^^^^^^^ expected `host`, found `true` | ||
| ^ the trait `~const Bar` is not implemented for `T` | ||
| | ||
note: required by a bound in `Foo::c` | ||
--> $DIR/trait-where-clause-const.rs:16:13 | ||
| | ||
LL | fn c<T: ~const Bar>(); | ||
| ^^^^^^^^^^ required by this bound in `Foo::c` | ||
help: consider further restricting this bound | ||
| | ||
= note: expected constant `host` | ||
found constant `true` | ||
LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { | ||
| ++++++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. | ||
For more information about this error, try `rustc --explain E0277`. |
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