-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
335c47d
commit 1eb7baa
Showing
20 changed files
with
450 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//@ compile-flags: -Znext-solver | ||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Foo { | ||
fn foo(); | ||
} | ||
|
||
const fn foo<T: ~const Foo>() { | ||
const { T::foo() } | ||
//~^ ERROR the trait bound `T: const Foo` is not satisfied | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/traits/const-traits/call-const-in-tilde-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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/call-const-in-tilde-const.rs:2:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0277]: the trait bound `T: const Foo` is not satisfied | ||
--> $DIR/call-const-in-tilde-const.rs:10:13 | ||
| | ||
LL | const { T::foo() } | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Foo { | ||
fn foo(); | ||
} | ||
|
||
fn foo<T: const Foo>() { | ||
const { T::foo() } | ||
} | ||
|
||
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,11 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/const-bound-in-host.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Trait { | ||
fn method(); | ||
} | ||
|
||
const fn foo<T: Trait>() { | ||
let _ = || { | ||
// Make sure this doesn't enforce `T: ~const Trait` | ||
T::method(); | ||
}; | ||
} | ||
|
||
fn bar<T: const Trait>() { | ||
let _ = || { | ||
// Make sure unconditionally const bounds propagate from parent. | ||
const { T::method(); }; | ||
}; | ||
} | ||
|
||
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,11 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/const-in-closure.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,12 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
const fn opaque() -> impl Sized {} | ||
|
||
fn main() { | ||
let mut x = const { opaque() }; | ||
x = opaque(); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/traits/const-traits/dont-observe-host-opaque.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,11 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/dont-observe-host-opaque.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] | ||
trait Trait { | ||
fn method() {} | ||
} | ||
|
||
impl const Trait for () {} | ||
|
||
fn main() { | ||
let mut x = const { | ||
let x = <()>::method; | ||
x(); | ||
x | ||
}; | ||
let y = <()>::method; | ||
y(); | ||
x = y; | ||
} |
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 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/dont-observe-host.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,20 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
const fn foo() {} | ||
const fn bar() {} | ||
fn baz() {} | ||
|
||
const fn caller(branch: bool) { | ||
let mut x = if branch { | ||
foo | ||
} else { | ||
bar | ||
}; | ||
x = baz; | ||
} | ||
|
||
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,11 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/fn-ptr-lub.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
31 changes: 31 additions & 0 deletions
31
tests/ui/traits/const-traits/item-bound-entailment-fails.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,31 @@ | ||
//@ compile-flags: -Znext-solver | ||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Foo { | ||
type Assoc<T>: ~const Bar | ||
where | ||
T: ~const Bar; | ||
} | ||
|
||
#[const_trait] trait Bar {} | ||
struct N<T>(T); | ||
impl<T> Bar for N<T> where T: Bar {} | ||
struct C<T>(T); | ||
impl<T> const Bar for C<T> where T: ~const Bar {} | ||
|
||
impl const Foo for u32 { | ||
type Assoc<T> = N<T> | ||
//~^ ERROR the trait bound `N<T>: ~const Bar` is not satisfied | ||
where | ||
T: ~const Bar; | ||
} | ||
|
||
impl const Foo for i32 { | ||
type Assoc<T> = C<T> | ||
//~^ ERROR the trait bound `T: ~const Bar` is not satisfied | ||
where | ||
T: Bar; | ||
} | ||
|
||
fn main() {} |
36 changes: 36 additions & 0 deletions
36
tests/ui/traits/const-traits/item-bound-entailment-fails.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,36 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/item-bound-entailment-fails.rs:2:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0277]: the trait bound `N<T>: ~const Bar` is not satisfied | ||
--> $DIR/item-bound-entailment-fails.rs:18:21 | ||
| | ||
LL | type Assoc<T> = N<T> | ||
| ^^^^ | ||
| | ||
note: required by a bound in `Foo::Assoc` | ||
--> $DIR/item-bound-entailment-fails.rs:6:20 | ||
| | ||
LL | type Assoc<T>: ~const Bar | ||
| ^^^^^^^^^^ required by this bound in `Foo::Assoc` | ||
|
||
error[E0277]: the trait bound `T: ~const Bar` is not satisfied | ||
--> $DIR/item-bound-entailment-fails.rs:25:21 | ||
| | ||
LL | type Assoc<T> = C<T> | ||
| ^^^^ | ||
| | ||
note: required by a bound in `Foo::Assoc` | ||
--> $DIR/item-bound-entailment-fails.rs:6:20 | ||
| | ||
LL | type Assoc<T>: ~const Bar | ||
| ^^^^^^^^^^ required by this bound in `Foo::Assoc` | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Foo { | ||
type Assoc<T>: ~const Bar | ||
where | ||
T: ~const Bar; | ||
} | ||
|
||
#[const_trait] trait Bar {} | ||
struct N<T>(T); | ||
impl<T> Bar for N<T> where T: Bar {} | ||
struct C<T>(T); | ||
impl<T> const Bar for C<T> where T: ~const Bar {} | ||
|
||
impl Foo for u32 { | ||
type Assoc<T> = N<T> | ||
where | ||
T: Bar; | ||
} | ||
|
||
impl const Foo for i32 { | ||
type Assoc<T> = C<T> | ||
where | ||
T: ~const Bar; | ||
} | ||
|
||
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,11 @@ | ||
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/item-bound-entailment.rs:4:30 | ||
| | ||
LL | #![feature(const_trait_impl, effects)] | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
43 changes: 43 additions & 0 deletions
43
tests/ui/traits/const-traits/predicate-entailment-fails.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,43 @@ | ||
//@ compile-flags: -Znext-solver | ||
#![feature(const_trait_impl, effects)] | ||
//~^ WARN the feature `effects` is incomplete | ||
|
||
#[const_trait] trait Bar {} | ||
impl const Bar for () {} | ||
|
||
|
||
#[const_trait] trait TildeConst { | ||
type Bar<T> where T: ~const Bar; | ||
|
||
fn foo<T>() where T: ~const Bar; | ||
} | ||
impl TildeConst for () { | ||
type Bar<T> = () where T: const Bar; | ||
//~^ ERROR impl has stricter requirements than trait | ||
|
||
fn foo<T>() where T: const Bar {} | ||
//~^ ERROR impl has stricter requirements than trait | ||
} | ||
|
||
|
||
#[const_trait] trait NeverConst { | ||
type Bar<T> where T: Bar; | ||
|
||
fn foo<T>() where T: Bar; | ||
} | ||
impl NeverConst for i32 { | ||
type Bar<T> = () where T: const Bar; | ||
//~^ ERROR impl has stricter requirements than trait | ||
|
||
fn foo<T>() where T: const Bar {} | ||
//~^ ERROR impl has stricter requirements than trait | ||
} | ||
impl const NeverConst for u32 { | ||
type Bar<T> = () where T: ~const Bar; | ||
//~^ ERROR impl has stricter requirements than trait | ||
|
||
fn foo<T>() where T: ~const Bar {} | ||
//~^ ERROR impl has stricter requirements than trait | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.