Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 054c15b

Browse files
committedDec 4, 2024·
Avoid opaque type not constrained errors in the presence of other errors
1 parent ec3424a commit 054c15b

24 files changed

+73
-153
lines changed
 

‎compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,18 @@ impl TaitConstraintLocator<'_> {
226226
constrained = true;
227227

228228
if !opaque_types_defined_by.contains(&self.def_id) {
229-
self.tcx.dcx().emit_err(TaitForwardCompat {
229+
let guar = self.tcx.dcx().emit_err(TaitForwardCompat {
230230
span: hidden_type.span,
231231
item_span: self
232232
.tcx
233233
.def_ident_span(item_def_id)
234234
.unwrap_or_else(|| self.tcx.def_span(item_def_id)),
235235
});
236+
// Avoid "opaque type not constrained" errors on the opaque itself.
237+
self.found = Some(ty::OpaqueHiddenType {
238+
span: DUMMY_SP,
239+
ty: Ty::new_error(self.tcx, guar),
240+
});
236241
}
237242
let concrete_type =
238243
self.tcx.erase_regions(hidden_type.remap_generic_params_to_declaration_params(
@@ -248,14 +253,19 @@ impl TaitConstraintLocator<'_> {
248253
if !constrained {
249254
debug!("no constraints in typeck results");
250255
if opaque_types_defined_by.contains(&self.def_id) {
251-
self.tcx.dcx().emit_err(TaitForwardCompat2 {
256+
let guar = self.tcx.dcx().emit_err(TaitForwardCompat2 {
252257
span: self
253258
.tcx
254259
.def_ident_span(item_def_id)
255260
.unwrap_or_else(|| self.tcx.def_span(item_def_id)),
256261
opaque_type_span: self.tcx.def_span(self.def_id),
257262
opaque_type: self.tcx.def_path_str(self.def_id),
258263
});
264+
// Avoid "opaque type not constrained" errors on the opaque itself.
265+
self.found = Some(ty::OpaqueHiddenType {
266+
span: DUMMY_SP,
267+
ty: Ty::new_error(self.tcx, guar),
268+
});
259269
}
260270
return;
261271
};

‎compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
24122412
match self.tcx().type_of_opaque(def_id) {
24132413
Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]),
24142414
Err(_) => {
2415+
// TODO: check if this is still reachable
24152416
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
24162417
}
24172418
}

‎tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0284]: type annotations needed: cannot satisfy `Foo == _`
2-
--> $DIR/norm-before-method-resolution-opaque-type.rs:16:19
2+
--> $DIR/norm-before-method-resolution-opaque-type.rs:15:19
33
|
44
LL | fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X
55
| ^ cannot satisfy `Foo == _`
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: item does not constrain `Foo::{opaque#0}`, but has it in its signature
2-
--> $DIR/norm-before-method-resolution-opaque-type.rs:16:4
2+
--> $DIR/norm-before-method-resolution-opaque-type.rs:15:4
33
|
44
LL | fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X
55
| ^^^^^^^^^^^
@@ -11,16 +11,8 @@ note: this opaque type is in the signature
1111
LL | type Foo = impl Sized;
1212
| ^^^^^^^^^^
1313

14-
error: unconstrained opaque type
15-
--> $DIR/norm-before-method-resolution-opaque-type.rs:13:12
16-
|
17-
LL | type Foo = impl Sized;
18-
| ^^^^^^^^^^
19-
|
20-
= note: `Foo` must be used in combination with a concrete type within the same module
21-
2214
error[E0507]: cannot move out of `*x` which is behind a shared reference
23-
--> $DIR/norm-before-method-resolution-opaque-type.rs:23:13
15+
--> $DIR/norm-before-method-resolution-opaque-type.rs:22:13
2416
|
2517
LL | let x = *x;
2618
| ^^ move occurs because `*x` has type `<X as Trait<'_>>::Out<Foo>`, which does not implement the `Copy` trait
@@ -31,6 +23,6 @@ LL - let x = *x;
3123
LL + let x = x;
3224
|
3325

34-
error: aborting due to 3 previous errors
26+
error: aborting due to 2 previous errors
3527

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

‎tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ impl<'a, T> Trait<'a> for T {
1111
}
1212

1313
type Foo = impl Sized;
14-
//[old]~^ ERROR: unconstrained opaque type
1514

1615
fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X
1716
//[old]~^ ERROR: item does not constrain

‎tests/ui/impl-trait/issues/issue-86800.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,28 @@
44

55
use std::future::Future;
66

7-
struct Connection {
8-
}
7+
struct Connection {}
98

10-
trait Transaction {
11-
}
9+
trait Transaction {}
1210

1311
struct TestTransaction<'conn> {
14-
conn: &'conn Connection
12+
conn: &'conn Connection,
1513
}
1614

17-
impl<'conn> Transaction for TestTransaction<'conn> {
18-
}
15+
impl<'conn> Transaction for TestTransaction<'conn> {}
1916

20-
struct Context {
21-
}
17+
struct Context {}
2218

2319
type TransactionResult<O> = Result<O, ()>;
2420

2521
type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
26-
//~^ ERROR unconstrained opaque type
2722

2823
fn execute_transaction_fut<'f, F, O>(
2924
//~^ ERROR: item does not constrain
3025
f: F,
3126
) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
3227
where
33-
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f
28+
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f,
3429
{
3530
f
3631
//~^ ERROR expected generic lifetime parameter, found `'_`
@@ -39,9 +34,9 @@ where
3934
impl Context {
4035
async fn do_transaction<O>(
4136
//~^ ERROR: item does not constrain
42-
&self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
43-
) -> TransactionResult<O>
44-
{
37+
&self,
38+
f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>,
39+
) -> TransactionResult<O> {
4540
//~^ ERROR expected generic lifetime parameter, found `'_`
4641
//~| ERROR: item does not constrain
4742
let mut conn = Connection {};
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature
2-
--> $DIR/issue-86800.rs:28:4
2+
--> $DIR/issue-86800.rs:23:4
33
|
44
LL | fn execute_transaction_fut<'f, F, O>(
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: consider moving the opaque type's declaration and defining uses into a separate module
88
note: this opaque type is in the signature
9-
--> $DIR/issue-86800.rs:25:34
9+
--> $DIR/issue-86800.rs:21:34
1010
|
1111
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

1414
error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature
15-
--> $DIR/issue-86800.rs:40:14
15+
--> $DIR/issue-86800.rs:35:14
1616
|
1717
LL | async fn do_transaction<O>(
1818
| ^^^^^^^^^^^^^^
1919
|
2020
= note: consider moving the opaque type's declaration and defining uses into a separate module
2121
note: this opaque type is in the signature
22-
--> $DIR/issue-86800.rs:25:34
22+
--> $DIR/issue-86800.rs:21:34
2323
|
2424
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

2727
error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature
28-
--> $DIR/issue-86800.rs:44:5
28+
--> $DIR/issue-86800.rs:39:31
2929
|
30-
LL | / {
30+
LL | ) -> TransactionResult<O> {
31+
| _______________________________^
3132
LL | |
3233
LL | |
3334
LL | | let mut conn = Connection {};
@@ -38,21 +39,13 @@ LL | | }
3839
|
3940
= note: consider moving the opaque type's declaration and defining uses into a separate module
4041
note: this opaque type is in the signature
41-
--> $DIR/issue-86800.rs:25:34
42+
--> $DIR/issue-86800.rs:21:34
4243
|
4344
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
4445
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4546

46-
error: unconstrained opaque type
47-
--> $DIR/issue-86800.rs:25:34
48-
|
49-
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51-
|
52-
= note: `TransactionFuture` must be used in combination with a concrete type within the same module
53-
5447
error[E0792]: expected generic lifetime parameter, found `'_`
55-
--> $DIR/issue-86800.rs:35:5
48+
--> $DIR/issue-86800.rs:30:5
5649
|
5750
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
5851
| --- this generic parameter must be used with a generic lifetime parameter
@@ -61,12 +54,13 @@ LL | f
6154
| ^
6255

6356
error[E0792]: expected generic lifetime parameter, found `'_`
64-
--> $DIR/issue-86800.rs:44:5
57+
--> $DIR/issue-86800.rs:39:31
6558
|
6659
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
6760
| --- this generic parameter must be used with a generic lifetime parameter
6861
...
69-
LL | / {
62+
LL | ) -> TransactionResult<O> {
63+
| _______________________________^
7064
LL | |
7165
LL | |
7266
LL | | let mut conn = Connection {};
@@ -75,6 +69,6 @@ LL | | f(&mut transaction).await
7569
LL | | }
7670
| |_____^
7771

78-
error: aborting due to 6 previous errors
72+
error: aborting due to 5 previous errors
7973

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

‎tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
mod a {
44
type Foo = impl PartialEq<(Foo, i32)>;
5-
//~^ ERROR: unconstrained opaque type
65

76
struct Bar;
87

‎tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0053]: method `eq` has an incompatible type for trait
2-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:30
2+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:9:30
33
|
44
LL | type Foo = impl PartialEq<(Foo, i32)>;
55
| -------------------------- the found opaque type
@@ -15,7 +15,7 @@ LL | fn eq(&self, _other: &(a::Bar, i32)) -> bool {
1515
| ~~~~~~~~~~~~~~
1616

1717
error: item does not constrain `a::Foo::{opaque#0}`, but has it in its signature
18-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12
18+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:9:12
1919
|
2020
LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
2121
| ^^
@@ -27,16 +27,8 @@ note: this opaque type is in the signature
2727
LL | type Foo = impl PartialEq<(Foo, i32)>;
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2929

30-
error: unconstrained opaque type
31-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16
32-
|
33-
LL | type Foo = impl PartialEq<(Foo, i32)>;
34-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
35-
|
36-
= note: `Foo` must be used in combination with a concrete type within the same module
37-
3830
error[E0053]: method `eq` has an incompatible type for trait
39-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:30
31+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:30
4032
|
4133
LL | type Foo = impl PartialEq<(Foo, i32)>;
4234
| -------------------------- the expected opaque type
@@ -47,7 +39,7 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
4739
= note: expected signature `fn(&b::Bar, &(b::Foo, _)) -> _`
4840
found signature `fn(&b::Bar, &(b::Bar, _)) -> _`
4941
note: this item must have the opaque type in its signature in order to be able to register hidden types
50-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:12
42+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:12
5143
|
5244
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
5345
| ^^
@@ -57,13 +49,13 @@ LL | fn eq(&self, _other: &(b::Foo, i32)) -> bool {
5749
| ~~~~~~~~~~~~~~
5850

5951
error: unconstrained opaque type
60-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16
52+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16
6153
|
6254
LL | type Foo = impl PartialEq<(Foo, i32)>;
6355
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6456
|
6557
= note: `Foo` must be used in combination with a concrete type within the same module
6658

67-
error: aborting due to 5 previous errors
59+
error: aborting due to 4 previous errors
6860

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

‎tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ note: this opaque type is in the signature
1111
LL | type A = impl Foo;
1212
| ^^^^^^^^
1313

14-
error: unconstrained opaque type
15-
--> $DIR/two_tait_defining_each_other2.rs:6:10
16-
|
17-
LL | type A = impl Foo;
18-
| ^^^^^^^^
19-
|
20-
= note: `A` must be used in combination with a concrete type within the same module
21-
2214
error: opaque type's hidden type cannot be another opaque type from the same scope
2315
--> $DIR/two_tait_defining_each_other2.rs:14:5
2416
|
@@ -36,5 +28,5 @@ note: opaque type being used as hidden type
3628
LL | type A = impl Foo;
3729
| ^^^^^^^^
3830

39-
error: aborting due to 3 previous errors
31+
error: aborting due to 2 previous errors
4032

‎tests/ui/impl-trait/two_tait_defining_each_other2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@[next] compile-flags: -Znext-solver
44
#![feature(type_alias_impl_trait)]
55

6-
type A = impl Foo; //[current]~ ERROR unconstrained opaque type
6+
type A = impl Foo;
77
type B = impl Foo;
88

99
trait Foo {}

‎tests/ui/self/arbitrary-self-opaque.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
struct Foo;
33

44
type Bar = impl Sized;
5-
//~^ ERROR unconstrained opaque type
65

76
impl Foo {
87
fn foo(self: Bar) {}
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0307]: invalid `self` parameter type: `Bar`
2-
--> $DIR/arbitrary-self-opaque.rs:8:18
2+
--> $DIR/arbitrary-self-opaque.rs:7:18
33
|
44
LL | fn foo(self: Bar) {}
55
| ^^^
@@ -8,7 +8,7 @@ LL | fn foo(self: Bar) {}
88
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
99

1010
error: item does not constrain `Bar::{opaque#0}`, but has it in its signature
11-
--> $DIR/arbitrary-self-opaque.rs:8:8
11+
--> $DIR/arbitrary-self-opaque.rs:7:8
1212
|
1313
LL | fn foo(self: Bar) {}
1414
| ^^^
@@ -20,14 +20,6 @@ note: this opaque type is in the signature
2020
LL | type Bar = impl Sized;
2121
| ^^^^^^^^^^
2222

23-
error: unconstrained opaque type
24-
--> $DIR/arbitrary-self-opaque.rs:4:12
25-
|
26-
LL | type Bar = impl Sized;
27-
| ^^^^^^^^^^
28-
|
29-
= note: `Bar` must be used in combination with a concrete type within the same module
30-
31-
error: aborting due to 3 previous errors
23+
error: aborting due to 2 previous errors
3224

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

‎tests/ui/type-alias-impl-trait/bad-tait-no-substs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(type_alias_impl_trait)]
44
trait Trait<T> {}
55
type Alias<'a, U> = impl Trait<U>;
6-
//~^ ERROR unconstrained opaque type
76

87
pub enum UninhabitedVariants {
98
Tuple(Alias),

‎tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/bad-tait-no-substs.rs:9:11
2+
--> $DIR/bad-tait-no-substs.rs:8:11
33
|
44
LL | Tuple(Alias),
55
| ^^^^^ expected named lifetime parameter
@@ -11,7 +11,7 @@ LL ~ Tuple(Alias<'a>),
1111
|
1212

1313
error[E0107]: missing generics for type alias `Alias`
14-
--> $DIR/bad-tait-no-substs.rs:9:11
14+
--> $DIR/bad-tait-no-substs.rs:8:11
1515
|
1616
LL | Tuple(Alias),
1717
| ^^^^^ expected 1 generic argument
@@ -27,7 +27,7 @@ LL | Tuple(Alias<U>),
2727
| +++
2828

2929
error[E0792]: non-defining opaque type use in defining scope
30-
--> $DIR/bad-tait-no-substs.rs:9:11
30+
--> $DIR/bad-tait-no-substs.rs:8:11
3131
|
3232
LL | Tuple(Alias),
3333
| ^^^^^ argument `'_` is not a generic parameter
@@ -39,7 +39,7 @@ LL | type Alias<'a, U> = impl Trait<U>;
3939
| ^^^^^^^^^^^^^
4040

4141
error: item does not constrain `Alias::{opaque#0}`, but has it in its signature
42-
--> $DIR/bad-tait-no-substs.rs:15:4
42+
--> $DIR/bad-tait-no-substs.rs:14:4
4343
|
4444
LL | fn uwu(x: UninhabitedVariants) {
4545
| ^^^
@@ -51,22 +51,14 @@ note: this opaque type is in the signature
5151
LL | type Alias<'a, U> = impl Trait<U>;
5252
| ^^^^^^^^^^^^^
5353

54-
error: unconstrained opaque type
55-
--> $DIR/bad-tait-no-substs.rs:5:21
56-
|
57-
LL | type Alias<'a, U> = impl Trait<U>;
58-
| ^^^^^^^^^^^^^
59-
|
60-
= note: `Alias` must be used in combination with a concrete type within the same module
61-
6254
error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` not covered
63-
--> $DIR/bad-tait-no-substs.rs:17:11
55+
--> $DIR/bad-tait-no-substs.rs:16:11
6456
|
6557
LL | match x {}
6658
| ^ pattern `UninhabitedVariants::Tuple(_)` not covered
6759
|
6860
note: `UninhabitedVariants` defined here
69-
--> $DIR/bad-tait-no-substs.rs:8:10
61+
--> $DIR/bad-tait-no-substs.rs:7:10
7062
|
7163
LL | pub enum UninhabitedVariants {
7264
| ^^^^^^^^^^^^^^^^^^^
@@ -80,7 +72,7 @@ LL + UninhabitedVariants::Tuple(_) => todo!(),
8072
LL + }
8173
|
8274

83-
error: aborting due to 6 previous errors
75+
error: aborting due to 5 previous errors
8476

8577
Some errors have detailed explanations: E0004, E0106, E0107, E0792.
8678
For more information about an error, try `rustc --explain E0004`.

‎tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `Bar` is forbidden as the type of a const generic parameter
2-
--> $DIR/const_generic_type.rs:8:24
2+
--> $DIR/const_generic_type.rs:7:24
33
|
44
LL | async fn test<const N: crate::Bar>() {
55
| ^^^^^^^^^^

‎tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: `Bar` is forbidden as the type of a const generic parameter
2-
--> $DIR/const_generic_type.rs:8:24
2+
--> $DIR/const_generic_type.rs:7:24
33
|
44
LL | async fn test<const N: crate::Bar>() {
55
| ^^^^^^^^^^
66
|
77
= note: the only supported types are integers, `bool`, and `char`
88

99
error: item does not constrain `Bar::{opaque#0}`, but has it in its signature
10-
--> $DIR/const_generic_type.rs:8:10
10+
--> $DIR/const_generic_type.rs:7:10
1111
|
1212
LL | async fn test<const N: crate::Bar>() {
1313
| ^^^^
@@ -20,7 +20,7 @@ LL | type Bar = impl std::fmt::Display;
2020
| ^^^^^^^^^^^^^^^^^^^^^^
2121

2222
error: item does not constrain `Bar::{opaque#0}`, but has it in its signature
23-
--> $DIR/const_generic_type.rs:8:38
23+
--> $DIR/const_generic_type.rs:7:38
2424
|
2525
LL | async fn test<const N: crate::Bar>() {
2626
| ______________________________________^
@@ -39,13 +39,5 @@ note: this opaque type is in the signature
3939
LL | type Bar = impl std::fmt::Display;
4040
| ^^^^^^^^^^^^^^^^^^^^^^
4141

42-
error: unconstrained opaque type
43-
--> $DIR/const_generic_type.rs:5:12
44-
|
45-
LL | type Bar = impl std::fmt::Display;
46-
| ^^^^^^^^^^^^^^^^^^^^^^
47-
|
48-
= note: `Bar` must be used in combination with a concrete type within the same module
49-
50-
error: aborting due to 4 previous errors
42+
error: aborting due to 3 previous errors
5143

‎tests/ui/type-alias-impl-trait/const_generic_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#![feature(type_alias_impl_trait)]
55
type Bar = impl std::fmt::Display;
6-
//[no_infer]~^ ERROR: unconstrained opaque type
76

87
async fn test<const N: crate::Bar>() {
98
//~^ ERROR: `Bar` is forbidden as the type of a const generic parameter

‎tests/ui/type-alias-impl-trait/hkl_forbidden4.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use std::future::Future;
99

1010
type FutNothing<'a> = impl 'a + Future<Output = ()>;
11-
//~^ ERROR: unconstrained opaque type
1211

1312
async fn operation(_: &mut ()) -> () {
1413
//~^ ERROR: concrete type differs from previous

‎tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature
2-
--> $DIR/hkl_forbidden4.rs:19:10
2+
--> $DIR/hkl_forbidden4.rs:18:10
33
|
44
LL | async fn call<F>(_f: F)
55
| ^^^^
@@ -12,7 +12,7 @@ LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

1414
error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature
15-
--> $DIR/hkl_forbidden4.rs:23:1
15+
--> $DIR/hkl_forbidden4.rs:22:1
1616
|
1717
LL | / {
1818
LL | |
@@ -27,16 +27,8 @@ note: this opaque type is in the signature
2727
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2929

30-
error: unconstrained opaque type
31-
--> $DIR/hkl_forbidden4.rs:10:23
32-
|
33-
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
34-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35-
|
36-
= note: `FutNothing` must be used in combination with a concrete type within the same module
37-
3830
error[E0792]: expected generic lifetime parameter, found `'any`
39-
--> $DIR/hkl_forbidden4.rs:15:5
31+
--> $DIR/hkl_forbidden4.rs:14:5
4032
|
4133
LL | async fn operation(_: &mut ()) -> () {
4234
| - this generic parameter must be used with a generic lifetime parameter
@@ -45,19 +37,19 @@ LL | call(operation).await
4537
| ^^^^^^^^^^^^^^^
4638

4739
error: concrete type differs from previous defining opaque type use
48-
--> $DIR/hkl_forbidden4.rs:13:1
40+
--> $DIR/hkl_forbidden4.rs:12:1
4941
|
5042
LL | async fn operation(_: &mut ()) -> () {
5143
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FutNothing<'_>`, got `{async fn body of operation()}`
5244
|
5345
note: previous use here
54-
--> $DIR/hkl_forbidden4.rs:15:5
46+
--> $DIR/hkl_forbidden4.rs:14:5
5547
|
5648
LL | call(operation).await
5749
| ^^^^^^^^^^^^^^^
5850

5951
error[E0792]: expected generic lifetime parameter, found `'any`
60-
--> $DIR/hkl_forbidden4.rs:23:1
52+
--> $DIR/hkl_forbidden4.rs:22:1
6153
|
6254
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
6355
| -- this generic parameter must be used with a generic lifetime parameter
@@ -68,6 +60,6 @@ LL | |
6860
LL | | }
6961
| |_^
7062

71-
error: aborting due to 6 previous errors
63+
error: aborting due to 5 previous errors
7264

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

‎tests/ui/type-alias-impl-trait/nested-tait-inference3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::fmt::Debug;
55

66
type FooX = impl Debug;
7-
//~^ ERROR unconstrained opaque type
87

98
trait Foo<A> {}
109

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: item does not constrain `FooX::{opaque#0}`, but has it in its signature
2-
--> $DIR/nested-tait-inference3.rs:13:4
2+
--> $DIR/nested-tait-inference3.rs:12:4
33
|
44
LL | fn foo() -> impl Foo<FooX> {
55
| ^^^
@@ -11,13 +11,5 @@ note: this opaque type is in the signature
1111
LL | type FooX = impl Debug;
1212
| ^^^^^^^^^^
1313

14-
error: unconstrained opaque type
15-
--> $DIR/nested-tait-inference3.rs:6:13
16-
|
17-
LL | type FooX = impl Debug;
18-
| ^^^^^^^^^^
19-
|
20-
= note: `FooX` must be used in combination with a concrete type within the same module
21-
22-
error: aborting due to 2 previous errors
14+
error: aborting due to 1 previous error
2315

‎tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
mod foo {
77
pub type Foo = impl Copy;
8-
//~^ ERROR unconstrained opaque type
98

109
// make compiler happy about using 'Foo'
1110
pub fn bar(x: Foo) -> Foo {
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: item does not constrain `Foo::{opaque#0}`, but has it in its signature
2-
--> $DIR/no_inferrable_concrete_type.rs:11:12
2+
--> $DIR/no_inferrable_concrete_type.rs:10:12
33
|
44
LL | pub fn bar(x: Foo) -> Foo {
55
| ^^^
@@ -11,13 +11,5 @@ note: this opaque type is in the signature
1111
LL | pub type Foo = impl Copy;
1212
| ^^^^^^^^^
1313

14-
error: unconstrained opaque type
15-
--> $DIR/no_inferrable_concrete_type.rs:7:20
16-
|
17-
LL | pub type Foo = impl Copy;
18-
| ^^^^^^^^^
19-
|
20-
= note: `Foo` must be used in combination with a concrete type within the same module
21-
22-
error: aborting due to 2 previous errors
14+
error: aborting due to 1 previous error
2315

0 commit comments

Comments
 (0)
Please sign in to comment.