Skip to content

Commit cc7d11e

Browse files
authored
Rollup merge of rust-lang#93953 - jackh726:known_bug, r=Mark-Simulacrum
Add the `known-bug` test directive, use it, and do some cleanup cc rust-lang/compiler-team#476 Now tests can be annotated with `known-bug`, which should indicate that the test *should* pass (or at least that the current output is a bug). Adding it relaxes the requirement to add error annotations to the test (though it is still allowed). In the future, this could be extended with further relaxations - with the goal to make adding these tests need minimal effort. I've used this attribute for the GAT tests added in rust-lang#93757. Finally, I've also cleaned up `header.rs` in compiletest a bit, by extracting out a bit of common logic. I've also split out some of the directives into their own consts. This removes a lot of very similar functions from `Config` and makes `TestProps::load_from` read nicer. I've split these into separate commits, so I in theory could split these into separate PRs if they're controversial, but I think they're pretty straightforward. r? `@Mark-Simulacrum`
2 parents 393fdc1 + 36cf48b commit cc7d11e

22 files changed

+218
-248
lines changed

src/test/ui/generic-associated-types/bugs/issue-80626.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but it requires `Sized` to be coinductive.
45

@@ -11,7 +12,6 @@ trait Allocator {
1112
enum LinkedList<A: Allocator> {
1213
Head,
1314
Next(A::Allocated<Self>)
14-
//~^ overflow
1515
}
1616

1717
fn main() {}

src/test/ui/generic-associated-types/bugs/issue-80626.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
2-
--> $DIR/issue-80626.rs:13:10
2+
--> $DIR/issue-80626.rs:14:10
33
|
44
LL | Next(A::Allocated<Self>)
55
| ^^^^^^^^^^^^^^^^^^

src/test/ui/generic-associated-types/bugs/issue-86218.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but seems to run into a TAIT issue.
45

@@ -20,7 +21,6 @@ trait Yay<AdditionalValue> {
2021

2122
impl<'a> Yay<&'a ()> for () {
2223
type InnerStream<'s> = impl Stream<Item = i32> + 's;
23-
//~^ the type
2424
fn foo<'s>() -> Self::InnerStream<'s> { todo!() }
2525
}
2626

src/test/ui/generic-associated-types/bugs/issue-86218.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0477]: the type `impl Stream<Item = i32>` does not fulfill the required lifetime
2-
--> $DIR/issue-86218.rs:22:28
2+
--> $DIR/issue-86218.rs:23:28
33
|
44
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: type must outlive the lifetime `'s` as defined here as required by this binding
8-
--> $DIR/issue-86218.rs:22:22
8+
--> $DIR/issue-86218.rs:23:22
99
|
1010
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
1111
| ^^

src/test/ui/generic-associated-types/bugs/issue-87735.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but we need an extension of implied bounds (probably).
45

@@ -23,7 +24,7 @@ struct Foo<T>(T);
2324
#[derive(Debug)]
2425
struct FooRef<'a, U>(&'a [U]);
2526

26-
impl<'b, T, U> AsRef2 for Foo<T> //~ the type parameter
27+
impl<'b, T, U> AsRef2 for Foo<T>
2728
where
2829
// * `for<'b, 'c> T: AsRef2<Output<'b> = &'c [U]>>` does not work
2930
//

src/test/ui/generic-associated-types/bugs/issue-87735.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/issue-87735.rs:26:13
2+
--> $DIR/issue-87735.rs:27:13
33
|
44
LL | impl<'b, T, U> AsRef2 for Foo<T>
55
| ^ unconstrained type parameter

src/test/ui/generic-associated-types/bugs/issue-87748.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but unnormalized input args aren't treated as implied.
45

@@ -14,7 +15,7 @@ struct Foo;
1415
impl MyTrait for Foo {
1516
type Assoc<'a, 'b> where 'b: 'a = u32;
1617

17-
fn do_sth(_: u32) {} //~ lifetime bound
18+
fn do_sth(_: u32) {}
1819
// fn do_sth(_: Self::Assoc<'static, 'static>) {}
1920
// fn do_sth(_: Self::Assoc<'_, '_>) {}
2021
}

src/test/ui/generic-associated-types/bugs/issue-87748.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
error[E0478]: lifetime bound not satisfied
2-
--> $DIR/issue-87748.rs:17:5
2+
--> $DIR/issue-87748.rs:18:5
33
|
44
LL | fn do_sth(_: u32) {}
55
| ^^^^^^^^^^^^^^^^^
66
|
77
note: lifetime parameter instantiated with the anonymous lifetime #2 defined here
8-
--> $DIR/issue-87748.rs:17:5
8+
--> $DIR/issue-87748.rs:18:5
99
|
1010
LL | fn do_sth(_: u32) {}
1111
| ^^^^^^^^^^^^^^^^^
1212
note: but lifetime parameter must outlive the anonymous lifetime #1 defined here
13-
--> $DIR/issue-87748.rs:17:5
13+
--> $DIR/issue-87748.rs:18:5
1414
|
1515
LL | fn do_sth(_: u32) {}
1616
| ^^^^^^^^^^^^^^^^^

src/test/ui/generic-associated-types/bugs/issue-87755.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass.
45

@@ -15,7 +16,6 @@ struct Bar;
1516

1617
impl Foo for Bar {
1718
type Ass = Bar;
18-
//~^ overflow
1919
}
2020

2121
fn main() {}

src/test/ui/generic-associated-types/bugs/issue-87755.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
2-
--> $DIR/issue-87755.rs:17:16
2+
--> $DIR/issue-87755.rs:18:16
33
|
44
LL | type Ass = Bar;
55
| ^^^

src/test/ui/generic-associated-types/bugs/issue-87803.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but using a type alias vs a reference directly
45
// changes late-bound -> early-bound.
@@ -18,7 +19,7 @@ impl Scanner for IdScanner {
1819
type Input<'a> = &'a str;
1920
type Token<'a> = &'a str;
2021

21-
fn scan<'a>(&mut self, s : &'a str) -> &'a str { //~ lifetime parameters
22+
fn scan<'a>(&mut self, s : &'a str) -> &'a str {
2223
s
2324
}
2425
}

src/test/ui/generic-associated-types/bugs/issue-87803.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0195]: lifetime parameters or bounds on method `scan` do not match the trait declaration
2-
--> $DIR/issue-87803.rs:21:12
2+
--> $DIR/issue-87803.rs:22:12
33
|
44
LL | fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
55
| ---- lifetimes in impl do not match this method in trait

src/test/ui/generic-associated-types/bugs/issue-88382.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but has a missed normalization due to HRTB.
45

@@ -25,7 +26,6 @@ fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>))
2526
fn main() {
2627
do_something(SomeImplementation(), |_| ());
2728
do_something(SomeImplementation(), test);
28-
//~^ type mismatch
2929
}
3030

3131
fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}

src/test/ui/generic-associated-types/bugs/issue-88382.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0631]: type mismatch in function arguments
2-
--> $DIR/issue-88382.rs:27:40
2+
--> $DIR/issue-88382.rs:28:40
33
|
44
LL | do_something(SomeImplementation(), test);
55
| ------------ ^^^^ expected signature of `for<'a> fn(&mut <SomeImplementation as Iterable>::Iterator<'a>) -> _`
@@ -10,7 +10,7 @@ LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
1010
| ------------------------------------------------- found signature of `for<'r> fn(&'r mut std::iter::Empty<usize>) -> _`
1111
|
1212
note: required by a bound in `do_something`
13-
--> $DIR/issue-88382.rs:21:56
13+
--> $DIR/issue-88382.rs:22:56
1414
|
1515
LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something`

src/test/ui/generic-associated-types/bugs/issue-88460.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but has a missed normalization due to HRTB.
45

@@ -27,5 +28,4 @@ impl Trait for Foo {
2728

2829
fn main() {
2930
test(Foo);
30-
//~^ the trait bound
3131
}

src/test/ui/generic-associated-types/bugs/issue-88460.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied
2-
--> $DIR/issue-88460.rs:29:5
2+
--> $DIR/issue-88460.rs:30:5
33
|
44
LL | test(Foo);
55
| ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>`
66
|
77
note: required by a bound in `test`
8-
--> $DIR/issue-88460.rs:16:27
8+
--> $DIR/issue-88460.rs:17:27
99
|
1010
LL | fn test<T>(value: T)
1111
| ---- required by a bound in this

src/test/ui/generic-associated-types/bugs/issue-88526.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-fail
2+
// known-bug
23

34
// This should pass, but requires more logic.
45

@@ -23,7 +24,7 @@ struct TestB<Q, F>
2324
f: F,
2425
}
2526

26-
impl<'q, Q, I, F> A for TestB<Q, F> //~ the type parameter
27+
impl<'q, Q, I, F> A for TestB<Q, F>
2728
where
2829
Q: A<I<'q> = &'q I>,
2930
F: Fn(I),

src/test/ui/generic-associated-types/bugs/issue-88526.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/issue-88526.rs:26:13
2+
--> $DIR/issue-88526.rs:27:13
33
|
44
LL | impl<'q, Q, I, F> A for TestB<Q, F>
55
| ^ unconstrained type parameter

src/test/ui/generic-associated-types/bugs/issue-89008.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// check-fail
22
// edition:2021
3+
// known-bug
34

45
// This should pass, but seems to run into a TAIT bug.
56

@@ -31,11 +32,11 @@ trait X {
3132
struct Y;
3233

3334
impl X for Y {
34-
type LineStream<'a, Repr> = impl Stream<Item = Repr>; //~ could not find
35+
type LineStream<'a, Repr> = impl Stream<Item = Repr>;
3536

3637
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
3738

38-
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { //~ type mismatch
39+
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
3940
async {empty()}
4041
}
4142
}

src/test/ui/generic-associated-types/bugs/issue-89008.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == impl Stream<Item = Repr>`
2-
--> $DIR/issue-89008.rs:38:43
2+
--> $DIR/issue-89008.rs:39:43
33
|
44
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
55
| ------------------------ the expected opaque type
@@ -11,7 +11,7 @@ LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
1111
found struct `Empty<_>`
1212

1313
error: could not find defining uses
14-
--> $DIR/issue-89008.rs:34:33
14+
--> $DIR/issue-89008.rs:35:33
1515
|
1616
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)