Skip to content

Commit d76058d

Browse files
authored
Rollup merge of #104181 - jackh726:known-bug-tests, r=Mark-Simulacrum
Add a few known-bug tests The labels of these tests should be changed from `S-bug-has-mcve` to `S-bug-has-test` once this is merged. cc: #101518 #99492 #90950 #89196 #104034 #101350 #103705 #103899 I couldn't reproduce the failures in #101962 and #100772 (so either these have started passing, or I didn't repro properly), so leaving those out for now. #102065 was a bit more complicated, since it uses `rustc_private` and I didn't want to mess with that.
2 parents 7c67cb2 + 1bf8f87 commit d76058d

14 files changed

+373
-0
lines changed

src/test/incremental/issue-101518.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// revisions: cfail1
2+
// should-ice
3+
// error-pattern: forcing query
4+
// known-bug: #101518
5+
6+
#[derive(PartialEq, Eq)]
7+
struct Id<'a> {
8+
ns: &'a str,
9+
}
10+
fn visit_struct() {
11+
let id = Id { ns: "random1" };
12+
const FLAG: Id<'static> = Id {
13+
ns: "needs_to_be_the_same",
14+
};
15+
match id {
16+
FLAG => {}
17+
_ => {}
18+
}
19+
}
20+
fn visit_struct2() {
21+
let id = Id { ns: "random2" };
22+
const FLAG: Id<'static> = Id {
23+
ns: "needs_to_be_the_same",
24+
};
25+
match id {
26+
FLAG => {}
27+
_ => {}
28+
}
29+
}
30+
31+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// check-fail
2+
// known-bug: #99492
3+
// edition: 2021
4+
5+
use std::marker::PhantomData;
6+
7+
pub struct Struct<I, T>(PhantomData<fn() -> <Self as It>::Item>)
8+
where
9+
Self: It;
10+
11+
impl<I> It for Struct<I, I::Item>
12+
where
13+
I: It,
14+
{
15+
type Item = ();
16+
}
17+
18+
pub trait It {
19+
type Item;
20+
}
21+
22+
fn f() -> impl Send {
23+
async {
24+
let _x = Struct::<Empty<&'static ()>, _>(PhantomData);
25+
async {}.await;
26+
}
27+
}
28+
29+
pub struct Empty<T>(PhantomData<fn() -> T>);
30+
31+
impl<T> It for Empty<T> {
32+
type Item = T;
33+
}
34+
35+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/async-reference-generality.rs:23:5
3+
|
4+
LL | / async {
5+
LL | | let _x = Struct::<Empty<&'static ()>, _>(PhantomData);
6+
LL | | async {}.await;
7+
LL | | }
8+
| |_____^ one type is more general than the other
9+
|
10+
= note: expected reference `&()`
11+
found reference `&()`
12+
13+
error[E0308]: mismatched types
14+
--> $DIR/async-reference-generality.rs:23:5
15+
|
16+
LL | / async {
17+
LL | | let _x = Struct::<Empty<&'static ()>, _>(PhantomData);
18+
LL | | async {}.await;
19+
LL | | }
20+
| |_____^ one type is more general than the other
21+
|
22+
= note: expected reference `&()`
23+
found reference `&()`
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// check-fail
2+
// known-bug: #90950
3+
4+
trait Yokeable<'a>: 'static {
5+
type Output: 'a;
6+
}
7+
8+
9+
trait IsCovariant<'a> {}
10+
11+
struct Yoke<Y: for<'a> Yokeable<'a>> {
12+
data: Y,
13+
}
14+
15+
16+
// impl<Y: for<'a> Yokeable<'a>> Yoke<Y> {
17+
// fn project<Y2: for<'a> Yokeable<'a>>(
18+
// &self,
19+
// f: for<'a> fn(<Y as Yokeable<'a>>::Output, &'a (),
20+
// ) -> <Y2 as Yokeable<'a>>::Output) -> Yoke<Y2> {
21+
// unimplemented!()
22+
// }
23+
// }
24+
25+
fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where
26+
Y: for<'a> Yokeable<'a>,
27+
for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a>
28+
{
29+
// x.project(|data, _| {
30+
// Box::new(data)
31+
// })
32+
unimplemented!()
33+
}
34+
35+
36+
impl<'a> Yokeable<'a> for Box<dyn IsCovariant<'static> + 'static> {
37+
type Output = Box<dyn IsCovariant<'a> + 'a>;
38+
}
39+
40+
// this impl is mostly an example and unnecessary for the pure repro
41+
use std::borrow::*;
42+
impl<'a, T: ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T> {
43+
type Output = Cow<'a, T>;
44+
}
45+
impl<'a, T: ToOwned + ?Sized> IsCovariant<'a> for Cow<'a, T> {}
46+
47+
48+
49+
fn upcast_yoke(y: Yoke<Cow<'static, str>>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> {
50+
upcast(y)
51+
}
52+
53+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `for<'a> <_ as Yokeable<'a>>::Output: IsCovariant<'a>` is not satisfied
2+
--> $DIR/issue-90950.rs:50:12
3+
|
4+
LL | upcast(y)
5+
| ------ ^ the trait `for<'a> IsCovariant<'a>` is not implemented for `<_ as Yokeable<'a>>::Output`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `IsCovariant<'a>` is implemented for `std::borrow::Cow<'a, T>`
10+
note: required by a bound in `upcast`
11+
--> $DIR/issue-90950.rs:27:42
12+
|
13+
LL | fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where
14+
| ------ required by a bound in this
15+
LL | Y: for<'a> Yokeable<'a>,
16+
LL | for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a>
17+
| ^^^^^^^^^^^^^^^ required by this bound in `upcast`
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-fail
2+
// known-bug: #89196
3+
4+
// Should pass, but we normalize and check bounds before we resolve the generics
5+
// of the function (which we know because of the return type).
6+
7+
trait Trait<'a> {
8+
type Out;
9+
}
10+
11+
impl<'a, T> Trait<'a> for T {
12+
type Out = T;
13+
}
14+
15+
fn weird_bound<X>() -> X
16+
where
17+
for<'a> X: Trait<'a>,
18+
for<'a> <X as Trait<'a>>::Out: Copy
19+
{ todo!() }
20+
21+
fn main() {
22+
let _: () = weird_bound();
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: the trait bound `for<'a> <_ as Trait<'a>>::Out: Copy` is not satisfied
2+
--> $DIR/norm-before-method-resolution.rs:22:17
3+
|
4+
LL | let _: () = weird_bound();
5+
| ^^^^^^^^^^^ the trait `for<'a> Copy` is not implemented for `<_ as Trait<'a>>::Out`
6+
|
7+
note: required by a bound in `weird_bound`
8+
--> $DIR/norm-before-method-resolution.rs:18:40
9+
|
10+
LL | fn weird_bound<X>() -> X
11+
| ----------- required by a bound in this
12+
...
13+
LL | for<'a> <X as Trait<'a>>::Out: Copy
14+
| ^^^^ required by this bound in `weird_bound`
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-fail
2+
// known-bug: #104034
3+
4+
#![feature(exhaustive_patterns, never_type)]
5+
6+
mod inner {
7+
pub struct Wrapper<T>(T);
8+
}
9+
10+
enum Either<A, B> {
11+
A(A),
12+
B(inner::Wrapper<B>),
13+
}
14+
15+
fn foo() -> Either<(), !> {
16+
Either::A(())
17+
}
18+
19+
fn main() {
20+
let Either::A(()) = foo();
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0005]: refutable pattern in local binding: `Either::B(_)` not covered
2+
--> $DIR/exhaustive_patterns.rs:20:9
3+
|
4+
LL | let Either::A(()) = foo();
5+
| ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered
6+
|
7+
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
8+
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
9+
note: `Either<(), !>` defined here
10+
--> $DIR/exhaustive_patterns.rs:12:5
11+
|
12+
LL | enum Either<A, B> {
13+
| ------
14+
LL | A(A),
15+
LL | B(inner::Wrapper<B>),
16+
| ^ not covered
17+
= note: the matched value is of type `Either<(), !>`
18+
help: you might want to use `if let` to ignore the variant that isn't matched
19+
|
20+
LL | if let Either::A(()) = foo() { todo!() }
21+
| ++ ~~~~~~~~~~~
22+
23+
error: aborting due to previous error
24+
25+
For more information about this error, try `rustc --explain E0005`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
// known-bug: #101350
3+
4+
trait Trait {
5+
type Ty;
6+
}
7+
8+
impl Trait for &'static () {
9+
type Ty = ();
10+
}
11+
12+
fn extend<'a>() {
13+
None::<<&'a () as Trait>::Ty>;
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// check-fail
2+
// known-bug: #103705
3+
// normalize-stderr-test "\[closure@.*\]" -> "[closure@]"
4+
// normalize-stderr-test "\+* ~" -> "+++ ~"
5+
6+
// The output of this currently suggests writing a closure in the qualified path.
7+
8+
trait MyTrait<T> {
9+
fn lol<F:FnOnce()>(&self, f:F) -> u16;
10+
}
11+
12+
struct Qqq;
13+
14+
impl MyTrait<u32> for Qqq{
15+
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 5 }
16+
}
17+
impl MyTrait<u64> for Qqq{
18+
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 6 }
19+
}
20+
21+
fn main() {
22+
let q = Qqq;
23+
q.lol(||());
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/suggest-fully-qualified-closure.rs:23:7
3+
|
4+
LL | q.lol(||());
5+
| ^^^
6+
|
7+
help: try using a fully qualified path to specify the expected types
8+
|
9+
LL | <Qqq as MyTrait<T>>::lol::<[closure@]>(&q, ||());
10+
| +++ ~
11+
12+
error[E0283]: type annotations needed
13+
--> $DIR/suggest-fully-qualified-closure.rs:23:7
14+
|
15+
LL | q.lol(||());
16+
| ^^^
17+
|
18+
note: multiple `impl`s satisfying `Qqq: MyTrait<_>` found
19+
--> $DIR/suggest-fully-qualified-closure.rs:14:1
20+
|
21+
LL | impl MyTrait<u32> for Qqq{
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
23+
...
24+
LL | impl MyTrait<u64> for Qqq{
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
26+
help: try using a fully qualified path to specify the expected types
27+
|
28+
LL | <Qqq as MyTrait<T>>::lol::<[closure@]>(&q, ||());
29+
| +++ ~
30+
31+
error: aborting due to 2 previous errors
32+
33+
Some errors have detailed explanations: E0282, E0283.
34+
For more information about an error, try `rustc --explain E0282`.

src/test/ui/typeck/issue-103899.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// check-fail
2+
// failure-status: 101
3+
// normalize-stderr-test "note: .*" -> ""
4+
// normalize-stderr-test "thread 'rustc' .*" -> ""
5+
// normalize-stderr-test " .*\n" -> ""
6+
// normalize-stderr-test " .*\n" -> ""
7+
// known-bug: #103899
8+
9+
trait BaseWithAssoc {
10+
type Assoc;
11+
}
12+
13+
trait WrapperWithAssoc {
14+
type BaseAssoc: BaseWithAssoc;
15+
}
16+
17+
struct Wrapper<B> {
18+
inner: B,
19+
}
20+
21+
struct ProjectToBase<T: BaseWithAssoc> {
22+
data_type_h: T::Assoc,
23+
}
24+
25+
struct DoubleProject<L: WrapperWithAssoc> {
26+
buffer: Wrapper<ProjectToBase<L::BaseAssoc>>,
27+
}
28+
29+
fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
30+
loop {}
31+
}
32+
33+
fn main() {}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
stack
3+
error:
4+
5+
6+
7+
8+
9+
10+
11+
12+
query#0#1end

0 commit comments

Comments
 (0)