mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-06 08:36:52 -04:00
bless more than merely diagnostics change
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
//@ known-bug: #101557
|
||||
//@ compile-flags: -Copt-level=0
|
||||
#![feature(generic_const_exprs)]
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait Trait {
|
||||
const CONST: usize;
|
||||
}
|
||||
|
||||
struct A<T: Trait> {
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<const N: usize> Trait for [i8; N] {
|
||||
const CONST: usize = N;
|
||||
}
|
||||
|
||||
impl<const N: usize> From<usize> for A<[i8; N]> {
|
||||
fn from(_: usize) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> {
|
||||
fn from(_: A<[i8; T::CONST]>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn f<T: Trait>() -> A<T>
|
||||
where
|
||||
[(); T::CONST]:,
|
||||
{
|
||||
// Usage of `0` is arbitrary
|
||||
let a = A::<[i8; T::CONST]>::from(0);
|
||||
A::<T>::from(a)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Usage of `1` is arbitrary
|
||||
f::<[i8; 1]>();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
//@ known-bug: #119692
|
||||
//@ compile-flags: -Copt-level=0
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(adt_const_params)]
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)]
|
||||
pub struct Dimension;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
|
||||
pub struct Quantity<S, const D: Dimension>(pub(crate) S);
|
||||
|
||||
impl<const D: Dimension, LHS, RHS> Add<Quantity<RHS, D>> for Quantity<LHS, D>
|
||||
where
|
||||
LHS: Add<RHS>,
|
||||
{
|
||||
type Output = Quantity<<LHS as Add<RHS>>::Output, D>;
|
||||
fn add(self, rhs: Quantity<RHS, D>) -> Self::Output {
|
||||
Quantity(self.0 + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<LHS, RHS> Add<RHS> for Quantity<LHS, { Dimension }>
|
||||
where
|
||||
LHS: Add<RHS>,
|
||||
{
|
||||
type Output = Quantity<<LHS as Add<RHS>>::Output, { Dimension }>;
|
||||
fn add(self, rhs: RHS) -> Self::Output {
|
||||
Quantity(self.0 + rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Quantity<f32, { Dimension }>> for f32 {
|
||||
type Output = Quantity<f32, { Dimension }>;
|
||||
fn add(self, rhs: Quantity<f32, { Dimension }>) -> Self::Output {
|
||||
Quantity(self + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add<const U: Dimension>(x: Quantity<f32, U>, y: Quantity<f32, U>) -> Quantity<f32, U> {
|
||||
x + y
|
||||
}
|
||||
|
||||
fn main() {
|
||||
add(Quantity::<f32, {Dimension}>(1.0), Quantity(2.0));
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//@ known-bug: #136859
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
trait If<const COND: bool> {}
|
||||
impl If<true> for () {}
|
||||
|
||||
trait IsZero<const N: u8> {
|
||||
type Answer;
|
||||
}
|
||||
|
||||
struct True;
|
||||
struct False;
|
||||
|
||||
impl<const N: u8> IsZero<N> for ()
|
||||
where (): If<{N == 0}> {
|
||||
type Msg = True;
|
||||
}
|
||||
|
||||
trait Foobar<const N: u8> {}
|
||||
|
||||
impl<const N: u8> Foobar<N> for ()
|
||||
where (): IsZero<N, Answer = True> {}
|
||||
|
||||
impl<const N: u8> Foobar<{{ N }}> for ()
|
||||
where (): IsZero<N, Answer = False> {}
|
||||
|
||||
fn main() {}
|
||||
+5
-7
@@ -1,12 +1,14 @@
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@ known-bug: #155761
|
||||
//@compile-flags: -Znext-solver
|
||||
|
||||
// A regression test for https://github.com/rust-lang/rust/issues/151329.
|
||||
// Ensures we do not trigger an ICE when normalization fails for a
|
||||
// projection on a trait object, even if the projection has the same
|
||||
// trait id as the object's bound.
|
||||
|
||||
// ICE again after moving to eager normalization in the next solver.
|
||||
// #155761 has a simplified variant which causes ICE without eager normalization.
|
||||
|
||||
trait Foo {
|
||||
type V;
|
||||
}
|
||||
@@ -18,12 +20,8 @@ struct Bar<T: Foo + ?Sized> {
|
||||
}
|
||||
|
||||
impl<T: Foo> Bar<dyn Callback<T>> {
|
||||
//~^ ERROR: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
fn event(&self) {
|
||||
//~^ ERROR: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
(self.callback)(any(), any());
|
||||
//~^ ERROR: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
//~| ERROR: expected function
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
//@ check-pass
|
||||
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct GenericStruct<const T: usize> { val: i64 }
|
||||
|
||||
impl<const T: usize> From<GenericStruct<T>> for GenericStruct<{T + 1}> {
|
||||
//~^ ERROR: conflicting implementations of trait `From<GenericStruct<_>>` for type `GenericStruct<_>`
|
||||
fn from(other: GenericStruct<T>) -> Self {
|
||||
Self { val: other.val }
|
||||
}
|
||||
}
|
||||
|
||||
impl<const T: usize> From<GenericStruct<{T + 1}>> for GenericStruct<T> {
|
||||
//~^ ERROR: conflicting implementations of trait `From<GenericStruct<_>>` for type `GenericStruct<_>`
|
||||
fn from(other: GenericStruct<{T + 1}>) -> Self {
|
||||
Self { val: other.val }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
error[E0119]: conflicting implementations of trait `From<GenericStruct<_>>` for type `GenericStruct<_>`
|
||||
--> $DIR/issue-89304.rs:6:1
|
||||
|
|
||||
LL | impl<const T: usize> From<GenericStruct<T>> for GenericStruct<{T + 1}> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: conflicting implementation in crate `core`:
|
||||
- impl<T> From<T> for T;
|
||||
|
||||
error[E0119]: conflicting implementations of trait `From<GenericStruct<_>>` for type `GenericStruct<_>`
|
||||
--> $DIR/issue-89304.rs:13:1
|
||||
|
|
||||
LL | impl<const T: usize> From<GenericStruct<{T + 1}>> for GenericStruct<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: conflicting implementation in crate `core`:
|
||||
- impl<T> From<T> for T;
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
@@ -0,0 +1,22 @@
|
||||
//@compile-flags: -Znext-solver
|
||||
|
||||
// Regression test for #151308
|
||||
|
||||
#![feature(lazy_type_alias)]
|
||||
trait Trait {
|
||||
type Associated;
|
||||
}
|
||||
|
||||
trait Generic<T> {}
|
||||
|
||||
type TraitObject = dyn Generic<<i32 as Trait>::Associated>;
|
||||
//~^ ERROR: the trait bound `i32: Trait` is not satisfied
|
||||
|
||||
struct Wrap(TraitObject);
|
||||
//~^ ERROR: the trait bound `i32: Trait` is not satisfied
|
||||
|
||||
fn cast(x: *mut Wrap) {
|
||||
x as *mut Wrap;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,27 @@
|
||||
error[E0277]: the trait bound `i32: Trait` is not satisfied
|
||||
--> $DIR/dont-ice-on-normalization-failure.rs:12:32
|
||||
|
|
||||
LL | type TraitObject = dyn Generic<<i32 as Trait>::Associated>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dont-ice-on-normalization-failure.rs:6:1
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `i32: Trait` is not satisfied
|
||||
--> $DIR/dont-ice-on-normalization-failure.rs:15:13
|
||||
|
|
||||
LL | struct Wrap(TraitObject);
|
||||
| ^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dont-ice-on-normalization-failure.rs:6:1
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
@@ -1,58 +0,0 @@
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14
|
||||
|
|
||||
LL | impl<T: Foo> Bar<dyn Callback<T>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Bar`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15
|
||||
|
|
||||
LL | struct Bar<T: Foo + ?Sized> {
|
||||
| ^^^ required by this bound in `Bar`
|
||||
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14
|
||||
|
|
||||
LL | fn event(&self) {
|
||||
| ^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Bar`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15
|
||||
|
|
||||
LL | struct Bar<T: Foo + ?Sized> {
|
||||
| ^^^ required by this bound in `Bar`
|
||||
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9
|
||||
|
|
||||
LL | (self.callback)(any(), any());
|
||||
| ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback<T> + 'static), Output = ()> + 'static)>`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9
|
||||
|
|
||||
LL | (self.callback)(any(), any());
|
||||
| ^^^^^^^^^^^^^^^--------------
|
||||
| |
|
||||
| call expression requires function
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0618.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
@@ -1,58 +0,0 @@
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14
|
||||
|
|
||||
LL | impl<T: Foo> Bar<dyn Callback<T>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Bar`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15
|
||||
|
|
||||
LL | struct Bar<T: Foo + ?Sized> {
|
||||
| ^^^ required by this bound in `Bar`
|
||||
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14
|
||||
|
|
||||
LL | fn event(&self) {
|
||||
| ^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Bar`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15
|
||||
|
|
||||
LL | struct Bar<T: Foo + ?Sized> {
|
||||
| ^^^ required by this bound in `Bar`
|
||||
|
||||
error[E0277]: the trait bound `(dyn Callback<T> + 'static): Foo` is not satisfied
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9
|
||||
|
|
||||
LL | (self.callback)(any(), any());
|
||||
| ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<T> + 'static)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback<T> + 'static), Output = ()> + 'static)>`
|
||||
--> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9
|
||||
|
|
||||
LL | (self.callback)(any(), any());
|
||||
| ^^^^^^^^^^^^^^^--------------
|
||||
| |
|
||||
| call expression requires function
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0618.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
@@ -0,0 +1,24 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// Regression test for the first variant of trait-system-refactor-initiative#191
|
||||
|
||||
trait Indir<T>: FnOnce(T) -> Self::Ret {
|
||||
type Ret;
|
||||
}
|
||||
impl<F, T, R> Indir<T> for F where F: FnOnce(T) -> R {
|
||||
type Ret = R;
|
||||
}
|
||||
|
||||
trait Mirror {
|
||||
type Assoc<'a>;
|
||||
}
|
||||
|
||||
fn needs<T: Mirror>(_: impl for<'a> Indir<T::Assoc<'a>>) {}
|
||||
|
||||
fn test<T>() where for<'a> T: Mirror<Assoc<'a> = i32> {
|
||||
needs::<T>(|x| { x.to_string(); });
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,19 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// Regression test for the third variant of trait-system-refactor-initiative#191
|
||||
|
||||
trait Ref<'a, F> {
|
||||
type Input;
|
||||
}
|
||||
|
||||
impl<'a, F> Ref<'a, F> for u32 {
|
||||
type Input = &'a u32;
|
||||
}
|
||||
|
||||
fn needs_super<F: for<'a> Fn(<u32 as Ref<'a, F>>::Input)>(_: F) {}
|
||||
|
||||
fn main() {
|
||||
needs_super(|_| {});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// Regression test for the fourth variant of trait-system-refactor-initiative#191
|
||||
|
||||
trait Trait<T> {
|
||||
type Assoc<'a>;
|
||||
}
|
||||
|
||||
impl<T> Trait<T> for () {
|
||||
type Assoc<'a> = &'a ();
|
||||
}
|
||||
|
||||
fn foo<T>(x: Option<*mut T>) -> for<'a> fn(<() as Trait<T>>::Assoc<'a>) {
|
||||
|_| ()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = None;
|
||||
let mut y = foo(x);
|
||||
x = Some(&mut y);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time
|
||||
--> $DIR/wf-normalization-sized.rs:19:11
|
||||
|
|
||||
LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = ();
|
||||
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `[[[[[u8]]]]]`
|
||||
= note: slice and array elements must have `Sized` type
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/wf-normalization-sized.rs:21:11
|
||||
|
|
||||
LL | const _: <Vec<str> as WellUnformed>::RequestNormalize = ();
|
||||
| ^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
note: required by an implicit `Sized` bound in `Vec`
|
||||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
@@ -1,8 +1,8 @@
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[current] check-pass
|
||||
//@[current] known-bug: #100041
|
||||
//@ check-pass
|
||||
//@ known-bug: #100041
|
||||
|
||||
// Should fail. Normalization can bypass well-formedness checking.
|
||||
// `[[[[[[u8]]]]]]` is not a well-formed type since size of type `[u8]` cannot
|
||||
@@ -17,8 +17,6 @@ impl<T: ?Sized> WellUnformed for T {
|
||||
}
|
||||
|
||||
const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = ();
|
||||
//[next]~^ ERROR the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time
|
||||
const _: <Vec<str> as WellUnformed>::RequestNormalize = ();
|
||||
//[next]~^ ERROR the size for values of type `str` cannot be known at compilation time
|
||||
|
||||
fn main() {}
|
||||
|
||||
Reference in New Issue
Block a user