Skip to content

Commit

Permalink
Unrolled build for rust-lang#122863
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#122863 - matthiaskrgr:teest, r=lcnr

add more ice tests

fixes rust-lang#119275
fixes rust-lang#113017
fixes rust-lang#112824
fixes rust-lang#112823
fixes rust-lang#121472
fixes rust-lang#110696
  • Loading branch information
rust-timer committed Mar 22, 2024
2 parents eff958c + e68cb00 commit 0bdefc6
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// test for ICE "no entry found for key" in generics_of.rs #113017

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

pub fn foo()
where
for<const N: usize = { || {}; 1 }> ():,
//~^ ERROR only lifetime parameters can be used in this context
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
{}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0658]: only lifetime parameters can be used in this context
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:15
|
LL | for<const N: usize = { || {}; 1 }> ():,
| ^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: defaults for generic parameters are not allowed in `for<...>` binders
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:9
|
LL | for<const N: usize = { || {}; 1 }> ():,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// test for ICE #119275 "no entry found for key" in predicates_of.rs

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

fn bug<const N: Nat>(&self)
//~^ ERROR `self` parameter is only allowed in associated functions
//~^^ ERROR cannot find type `Nat` in this scope
where
for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
//~^ ERROR only lifetime parameters can be used in this context
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
//~^^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
//~^^^^ ERROR failed to resolve: use of undeclared type `COT`
{
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error: `self` parameter is only allowed in associated functions
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:22
|
LL | fn bug<const N: Nat>(&self)
| ^^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions

error[E0412]: cannot find type `Nat` in this scope
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:17
|
LL | fn bug<const N: Nat>(&self)
| ^^^ not found in this scope

error[E0658]: only lifetime parameters can be used in this context
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:15
|
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
| ^ ^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: defaults for generic parameters are not allowed in `for<...>` binders
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:9
|
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
| ^^^^^^^^^^^^^^^^^^

error: defaults for generic parameters are not allowed in `for<...>` binders
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:29
|
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
| ^^^^^^^

error[E0433]: failed to resolve: use of undeclared type `COT`
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:43
|
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
| ^^^ use of undeclared type `COT`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0412, E0433, E0658.
For more information about an error, try `rustc --explain E0412`.
20 changes: 20 additions & 0 deletions tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// test for #112824 ICE type mismatching when copying!

pub struct Opcode(pub u8);

pub struct Opcode2(&'a S);
//~^ ERROR use of undeclared lifetime name `'a`
//~^^ ERROR cannot find type `S` in this scope

impl Opcode2 {
pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
}

pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
move |i| match msg_type {
Opcode2::OP2 => unimplemented!(),
//~^ ERROR could not evaluate constant pattern
}
}

pub fn main() {}
29 changes: 29 additions & 0 deletions tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21
|
LL | pub struct Opcode2(&'a S);
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`

error[E0412]: cannot find type `S` in this scope
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24
|
LL | pub struct Opcode2(&'a S);
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | pub struct Opcode2<S>(&'a S);
| +++

error: could not evaluate constant pattern
--> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9
|
LL | Opcode2::OP2 => unimplemented!(),
| ^^^^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0261, E0412.
For more information about an error, try `rustc --explain E0261`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// test for ICE #112823
// Unexpected parameter Type(Repr) when substituting in region

#![feature(impl_trait_in_assoc_type)]

use std::future::Future;

trait Stream {}

trait X {
type LineStream<'a, Repr>
where
Self: 'a;
type LineStreamFut<'a, Repr>
where
Self: 'a;
}

struct Y;

impl X for Y {
type LineStream<'c, 'd> = impl Stream;
//~^ ERROR type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
//~^ ERROR `()` is not a future
//~^^ method `line_stream` is not a member of trait `X`
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0407]: method `line_stream` is not a member of trait `X`
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:5
|
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X`

error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:22:21
|
LL | type LineStream<'a, Repr>
| -- ----
| |
| expected 1 type parameter
...
LL | type LineStream<'c, 'd> = impl Stream;
| ^^ ^^
| |
| found 0 type parameters

error[E0277]: `()` is not a future
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:43
|
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
|
= help: the trait `Future` is not implemented for `()`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0049, E0277, E0407.
For more information about an error, try `rustc --explain E0049`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// test for #110696
// failed to resolve instance for <Scope<()> as MyIndex<()>>::my_index
// ignore-tidy-linelength

#![feature(type_alias_impl_trait)]

use std::marker::PhantomData;


trait MyIndex<T> {
type O;
fn my_index(self) -> Self::O;
}
trait MyFrom<T>: Sized {
type Error;
fn my_from(value: T) -> Result<Self, Self::Error>;
}


trait F {}
impl F for () {}
type DummyT<T> = impl F;
fn _dummy_t<T>() -> DummyT<T> {}

struct Phantom1<T>(PhantomData<T>);
struct Phantom2<T>(PhantomData<T>);
struct Scope<T>(Phantom2<DummyT<T>>);

impl<T> Scope<T> {
fn new() -> Self {
unimplemented!()
}
}

impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
type Error = ();
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
unimplemented!()
}
}

impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
//~^ ERROR the type parameter `T` is not constrained by the impl
type O = T;
fn my_index(self) -> Self::O {
MyFrom::my_from(self.0).ok().unwrap()
}
}

fn main() {
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/ice-failed-to-resolve-instance-for-110696.rs:42:6
|
LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
| ^ unconstrained type parameter

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0207`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// test for ICE #121472 index out of bounds un_derefer.rs
#![feature(type_alias_impl_trait)]

trait T {}

type Alias<'a> = impl T;

struct S;
impl<'a> T for &'a S {}

fn with_positive(fun: impl Fn(Alias<'_>)) {}

fn main() {
with_positive(|&n| ());
//~^ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0308]: mismatched types
--> $DIR/underef-index-out-of-bounds-121472.rs:14:20
|
LL | type Alias<'a> = impl T;
| ------ the expected opaque type
...
LL | with_positive(|&n| ());
| ^^
| |
| expected opaque type, found `&_`
| expected due to this
|
= note: expected opaque type `Alias<'_>`
found reference `&_`
help: consider removing `&` from the pattern
|
LL - with_positive(|&n| ());
LL + with_positive(|n| ());
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 0bdefc6

Please sign in to comment.