finishing touches, move fixed ICEs to ui tests

This commit is contained in:
Deadbeef 2024-06-25 10:44:00 +00:00
parent 0a2330630d
commit 8b2fac9612
19 changed files with 182 additions and 65 deletions

View File

@ -877,7 +877,7 @@ fn consider_builtin_effects_min_candidate(
let mut first_non_maybe = None;
let mut non_maybe_count = 0;
for ty in types {
for ty in types.iter() {
if !matches!(ty::EffectKind::try_from_ty(cx, ty), Some(ty::EffectKind::Maybe)) {
first_non_maybe.get_or_insert(ty);
non_maybe_count += 1;
@ -902,7 +902,7 @@ fn consider_builtin_effects_min_candidate(
_ => {
let mut min = ty::EffectKind::Maybe;
for ty in types {
for ty in types.iter() {
let Some(kind) = ty::EffectKind::try_from_ty(cx, ty) else {
return Err(NoSolution);
};

View File

@ -717,7 +717,7 @@ fn consider_builtin_effects_min_candidate(
let cx = ecx.cx();
let maybe_count = types
.into_iter()
.iter()
.filter_map(|ty| ty::EffectKind::try_from_ty(cx, ty))
.filter(|&ty| ty == ty::EffectKind::Maybe)
.count();
@ -727,7 +727,7 @@ fn consider_builtin_effects_min_candidate(
if types.len() - maybe_count > 1 {
let mut min = ty::EffectKind::Maybe;
for ty in types {
for ty in types.iter() {
let Some(kind) = ty::EffectKind::try_from_ty(ecx.cx(), ty) else {
return Err(NoSolution);
};

View File

@ -104,15 +104,18 @@ fn main() {}
struct D;
/* FIXME(effects)
impl const Drop for D {
fn drop(&mut self) {
todo!();
}
}
*/
// Lint this, since it can be dropped in const contexts
// FIXME(effects)
fn d(this: D) {}
//~^ ERROR: this could be a `const fn`
mod msrv {
struct Foo(*const u8, &'static u8);

View File

@ -157,7 +157,13 @@ LL | const fn msrv_1_46() -> i32 {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:122:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:117:1
|
LL | fn d(this: D) {}
| ^^^^^^^^^^^^^^^^
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:125:9
|
LL | / fn deref_ptr_can_be_const(self) -> usize {
LL | |
@ -171,7 +177,7 @@ LL | const fn deref_ptr_can_be_const(self) -> usize {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:127:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:130:9
|
LL | / fn deref_copied_val(self) -> usize {
LL | |
@ -185,7 +191,7 @@ LL | const fn deref_copied_val(self) -> usize {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:138:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:141:5
|
LL | / fn union_access_can_be_const() {
LL | |
@ -200,7 +206,7 @@ LL | const fn union_access_can_be_const() {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:152:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:155:9
|
LL | / pub fn new(strings: Vec<String>) -> Self {
LL | | Self { strings }
@ -213,7 +219,7 @@ LL | pub const fn new(strings: Vec<String>) -> Self {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:157:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:160:9
|
LL | / pub fn empty() -> Self {
LL | | Self { strings: Vec::new() }
@ -226,7 +232,7 @@ LL | pub const fn empty() -> Self {
| +++++
error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:168:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:171:9
|
LL | / pub fn new(text: String) -> Self {
LL | | let vec = Vec::new();
@ -239,5 +245,5 @@ help: make the function `const`
LL | pub const fn new(text: String) -> Self {
| +++++
error: aborting due to 17 previous errors
error: aborting due to 18 previous errors

View File

@ -1,10 +0,0 @@
//@ known-bug: #119717
#![feature(const_trait_impl, effects)]
use std::ops::{FromResidual, Try};
impl const FromResidual for T {
fn from_residual(t: T) -> _ {
t
}
}

View File

@ -1,4 +0,0 @@
//@ known-bug: #123664
#![feature(generic_const_exprs, effects)]
const fn with_positive<F: ~const Fn()>() {}
pub fn main() {}

View File

@ -1,11 +0,0 @@
//@ known-bug: rust-lang/rust#124857
//@ compile-flags: -Znext-solver=coherence
#![feature(effects)]
#[const_trait]
trait Foo {}
impl const Foo for i32 {}
impl<T> const Foo for T where T: ~const Foo {}

View File

@ -1,23 +0,0 @@
//@ known-bug: rust-lang/rust#126148
#![feature(effects)]
use std::ops::{FromResidual, Try};
struct TryMe;
struct Error;
impl const FromResidual<Error> for TryMe {}
impl const Try for TryMe {
type Output = ();
type Residual = Error;
}
const fn t() -> TryMe {
TryMe?;
TryMe
}
const _: () = {
t();
};

View File

@ -8,7 +8,8 @@
//
// FIXME(effects) add `const_trait` to `Fn` so we use `~const`
// FIXME(effects) restore `const_trait` to `Destruct`
#![feature(const_trait_impl)]
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]
#![crate_name = "foo"]
use std::marker::Destruct;

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type-const-bound-usage-1.rs:16:44
--> $DIR/assoc-type-const-bound-usage-1.rs:15:44
|
LL | fn unqualified<T: const Trait>() -> Type<{ T::Assoc::func() }> {
| ^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}`
|
note: required by a bound in `Trait::func`
--> $DIR/assoc-type-const-bound-usage-1.rs:8:1
--> $DIR/assoc-type-const-bound-usage-1.rs:7:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ required by this bound in `Trait::func`
@ -14,13 +14,13 @@ LL | fn func() -> i32;
| ---- required by a bound in this associated function
error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type-const-bound-usage-1.rs:20:42
--> $DIR/assoc-type-const-bound-usage-1.rs:19:42
|
LL | fn qualified<T: const Trait>() -> Type<{ <T as Trait>::Assoc::func() }> {
| ^^^^^^^^^^^^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}`
|
note: required by a bound in `Trait::func`
--> $DIR/assoc-type-const-bound-usage-1.rs:8:1
--> $DIR/assoc-type-const-bound-usage-1.rs:7:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ required by this bound in `Trait::func`

View File

@ -8,7 +8,7 @@ LL | #![feature(const_trait_impl, effects)]
= note: `#[warn(incomplete_features)]` on by default
error[E0277]: the trait bound `Add::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type.rs:40:15
--> $DIR/assoc-type.rs:41:15
|
LL | type Qux: Add;
| ^^^ the trait `Compat` is not implemented for `Add::{synthetic#0}`

View File

@ -0,0 +1,15 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects, try_trait_v2)]
use std::ops::FromResidual;
impl<T> const FromResidual for T {
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
//~| type parameter `T` must be used as the type parameter for some local type
fn from_residual(t: T) -> _ {
//~^ the placeholder `_` is not allowed
t
}
}
fn main() {}

View File

@ -0,0 +1,33 @@
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> $DIR/ice-119717-constant-lifetime.rs:6:15
|
LL | impl<T> const FromResidual for T {
| ^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/ice-119717-constant-lifetime.rs:6:6
|
LL | impl<T> const FromResidual for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
--> $DIR/ice-119717-constant-lifetime.rs:9:31
|
LL | fn from_residual(t: T) -> _ {
| ^ not allowed in type signatures
|
help: try replacing `_` with the type in the corresponding trait method signature
|
LL | fn from_residual(t: T) -> T {
| ~
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0121, E0210.
For more information about an error, try `rustc --explain E0121`.

View File

@ -0,0 +1,7 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs, const_trait_impl, effects)]
const fn with_positive<F: ~const Fn()>() {}
//~^ ERROR `~const` can only be applied to `#[const_trait]` traits
pub fn main() {}

View File

@ -0,0 +1,8 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-123664-unexpected-bound-var.rs:4:34
|
LL | const fn with_positive<F: ~const Fn()>() {}
| ^^^^
error: aborting due to 1 previous error

View File

@ -0,0 +1,14 @@
//@ compile-flags: -Znext-solver=coherence
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Foo {}
impl const Foo for i32 {}
impl<T> const Foo for T where T: ~const Foo {}
//~^ ERROR conflicting implementations of trait `Foo` for type `i32`
fn main() {}

View File

@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `Foo` for type `i32`
--> $DIR/ice-124857-combine-effect-const-infer-vars.rs:11:1
|
LL | impl const Foo for i32 {}
| ---------------------- first implementation here
LL |
LL | impl<T> const Foo for T where T: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.

View File

@ -0,0 +1,28 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects, try_trait_v2, const_try)]
use std::ops::{FromResidual, Try};
struct TryMe;
struct Error;
impl const FromResidual<Error> for TryMe {}
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
//~| ERROR not all trait items implemented
impl const Try for TryMe {
//~^ ERROR const `impl` for trait `Try` which is not marked with `#[const_trait]`
//~| ERROR not all trait items implemented
type Output = ();
type Residual = Error;
}
const fn t() -> TryMe {
TryMe?;
TryMe
}
const _: () = {
t();
};
fn main() {}

View File

@ -0,0 +1,38 @@
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> $DIR/ice-126148-failed-to-normalize.rs:8:12
|
LL | impl const FromResidual<Error> for TryMe {}
| ^^^^^^^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0046]: not all trait items implemented, missing: `from_residual`
--> $DIR/ice-126148-failed-to-normalize.rs:8:1
|
LL | impl const FromResidual<Error> for TryMe {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_residual` in implementation
|
= help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }`
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> $DIR/ice-126148-failed-to-normalize.rs:12:12
|
LL | impl const Try for TryMe {
| ^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0046]: not all trait items implemented, missing: `from_output`, `branch`
--> $DIR/ice-126148-failed-to-normalize.rs:12:1
|
LL | impl const Try for TryMe {
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_output`, `branch` in implementation
|
= help: implement the missing item: `fn from_output(_: <Self as Try>::Output) -> Self { todo!() }`
= help: implement the missing item: `fn branch(self) -> ControlFlow<<Self as Try>::Residual, <Self as Try>::Output> { todo!() }`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0046`.