mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Add a test and several known bugs
This commit is contained in:
parent
77ea90ec71
commit
6eb6455c46
23
tests/ui/associated-inherent-types/bugs/ice-substitution.rs
Normal file
23
tests/ui/associated-inherent-types/bugs/ice-substitution.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// known-bug: unknown
|
||||
// failure-status: 101
|
||||
// normalize-stderr-test "note: .*\n\n" -> ""
|
||||
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||
// rustc-env:RUST_BACKTRACE=0
|
||||
|
||||
// FIXME: I presume a type variable that couldn't be solved by `resolve_vars_if_possible`
|
||||
// escapes the InferCtxt snapshot.
|
||||
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Cont<T>(T);
|
||||
|
||||
impl<T: Copy> Cont<T> {
|
||||
type Out = Vec<T>;
|
||||
}
|
||||
|
||||
pub fn weird<T: Copy>(x: T) {
|
||||
let _: Cont<_>::Out = vec![true];
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,6 @@
|
||||
error: the compiler unexpectedly panicked. this is a bug.
|
||||
|
||||
query stack during panic:
|
||||
#0 [typeck] type-checking `weird`
|
||||
#1 [typeck_item_bodies] type-checking all item bodies
|
||||
end of query stack
|
15
tests/ui/associated-inherent-types/bugs/inference-fail.rs
Normal file
15
tests/ui/associated-inherent-types/bugs/inference-fail.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// known-bug: unknown
|
||||
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
impl S<()> {
|
||||
type P = i128;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// We fail to infer `_ == ()` here.
|
||||
let _: S<_>::P;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/inference-fail.rs:14:14
|
||||
|
|
||||
LL | let _: S<_>::P;
|
||||
| ^ cannot infer type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
19
tests/ui/associated-inherent-types/bugs/lack-of-regionck.rs
Normal file
19
tests/ui/associated-inherent-types/bugs/lack-of-regionck.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// known-bug: unknown
|
||||
// check-pass
|
||||
|
||||
// We currently don't region-check inherent associated type projections at all.
|
||||
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features, dead_code)]
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
impl S<&'static ()> {
|
||||
type T = ();
|
||||
}
|
||||
|
||||
fn usr<'a>() {
|
||||
let _: S::<&'a ()>::T; // this should *fail* but it doesn't!
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,31 @@
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// Check that it's okay to report “[inherent] associated type […] not found” for inherent associated
|
||||
// type candidates that are not applicable (due to unsuitable Self type) even if there exists a
|
||||
// “shadowed” associated type from a trait with the same name since its use would be ambiguous
|
||||
// anyway if the IAT didn't exist.
|
||||
// FIXME(inherent_associated_types): Figure out which error would be more helpful here.
|
||||
|
||||
// revisions: shadowed uncovered
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
trait Tr {
|
||||
type Pr;
|
||||
}
|
||||
|
||||
impl<T> Tr for S<T> {
|
||||
type Pr = ();
|
||||
}
|
||||
|
||||
#[cfg(shadowed)]
|
||||
impl S<()> {
|
||||
type Pr = i32;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: S::<bool>::Pr = ();
|
||||
//[shadowed]~^ ERROR associated type `Pr` not found
|
||||
//[uncovered]~^^ ERROR ambiguous associated type
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
error[E0220]: associated type `Pr` not found for `S<bool>` in the current scope
|
||||
--> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:23
|
||||
|
|
||||
LL | struct S<T>(T);
|
||||
| ----------- associated item `Pr` not found for this struct
|
||||
...
|
||||
LL | let _: S::<bool>::Pr = ();
|
||||
| ^^ associated item not found in `S<bool>`
|
||||
|
|
||||
= note: the associated type was found for
|
||||
- `S<()>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0220`.
|
@ -0,0 +1,9 @@
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12
|
||||
|
|
||||
LL | let _: S::<bool>::Pr = ();
|
||||
| ^^^^^^^^^^^^^ help: use the fully-qualified path: `<S<bool> as Tr>::Pr`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0223`.
|
Loading…
Reference in New Issue
Block a user