Skip to content

Commit 594b5aa

Browse files
committed
Avoid silencing relevant follow-up errors
1 parent e51e98d commit 594b5aa

File tree

182 files changed

+2686
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+2686
-458
lines changed

compiler/rustc_hir_analysis/src/lib.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
166166

167167
// this ensures that later parts of type checking can assume that items
168168
// have valid types and not error
169-
// FIXME(matthewjasper) We shouldn't need to use `track_errors`.
170-
tcx.sess.track_errors(|| {
171-
tcx.sess.time("type_collecting", || {
172-
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
173-
});
174-
})?;
169+
tcx.sess.time("type_collecting", || {
170+
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
171+
});
175172

176173
if tcx.features().rustc_attrs {
177174
tcx.sess.track_errors(|| {

compiler/rustc_trait_selection/src/traits/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ pub fn normalize_param_env_or_error<'tcx>(
279279
}
280280

281281
fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
282+
// FIXME(return_type_notation): track binders in this normalizer, as
283+
// `ty::Const::normalize` can only work with properly preserved binders.
284+
285+
if c.has_escaping_bound_vars() {
286+
return ty::Const::new_misc_error(self.0, c.ty());
287+
}
282288
// While it is pretty sus to be evaluating things with an empty param env, it
283289
// should actually be okay since without `feature(generic_const_exprs)` the only
284290
// const arguments that have a non-empty param env are array repeat counts. These

tests/ui/associated-inherent-types/issue-109071.no_gate.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | impl<T> Windows {
1313
note: struct defined here, with 1 generic parameter: `T`
1414
--> $DIR/issue-109071.rs:5:8
1515
|
16-
LL | struct Windows<T> {}
16+
LL | struct Windows<T> { t: T }
1717
| ^^^^^^^ -
1818
help: add missing generic argument
1919
|
@@ -30,7 +30,7 @@ LL | type Item = &[T];
3030
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
3131

3232
error[E0223]: ambiguous associated type
33-
--> $DIR/issue-109071.rs:15:22
33+
--> $DIR/issue-109071.rs:16:22
3434
|
3535
LL | fn T() -> Option<Self::Item> {}
3636
| ^^^^^^^^^^

tests/ui/associated-inherent-types/issue-109071.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
#![cfg_attr(with_gate, feature(inherent_associated_types))]
33
#![cfg_attr(with_gate, allow(incomplete_features))]
44

5-
struct Windows<T> {}
5+
struct Windows<T> { t: T }
66

77
impl<T> Windows { //~ ERROR: missing generics for struct `Windows`
88
type Item = &[T]; //~ ERROR: `&` without an explicit lifetime name cannot be used here
99
//[no_gate]~^ ERROR: inherent associated types are unstable
1010

1111
fn next() -> Option<Self::Item> {}
12+
//[with_gate]~^ ERROR type annotations needed
1213
}
1314

1415
impl<T> Windows<T> {
1516
fn T() -> Option<Self::Item> {}
1617
//[no_gate]~^ ERROR: ambiguous associated type
18+
//[with_gate]~^^ ERROR type annotations needed
1719
}
1820

1921
fn main() {}

tests/ui/associated-inherent-types/issue-109071.with_gate.stderr

+15-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,26 @@ LL | impl<T> Windows {
1313
note: struct defined here, with 1 generic parameter: `T`
1414
--> $DIR/issue-109071.rs:5:8
1515
|
16-
LL | struct Windows<T> {}
16+
LL | struct Windows<T> { t: T }
1717
| ^^^^^^^ -
1818
help: add missing generic argument
1919
|
2020
LL | impl<T> Windows<T> {
2121
| +++
2222

23-
error: aborting due to 2 previous errors
23+
error[E0282]: type annotations needed
24+
--> $DIR/issue-109071.rs:11:18
25+
|
26+
LL | fn next() -> Option<Self::Item> {}
27+
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
28+
29+
error[E0282]: type annotations needed
30+
--> $DIR/issue-109071.rs:16:15
31+
|
32+
LL | fn T() -> Option<Self::Item> {}
33+
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
34+
35+
error: aborting due to 4 previous errors
2436

25-
Some errors have detailed explanations: E0107, E0637.
37+
Some errors have detailed explanations: E0107, E0282, E0637.
2638
For more information about an error, try `rustc --explain E0107`.

tests/ui/associated-inherent-types/issue-109299-1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ impl Lexer<i32> {
88
}
99

1010
type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
11+
//~^ ERROR: unconstrained opaque type
1112

1213
fn main() {}

tests/ui/associated-inherent-types/issue-109299-1.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
1010
= note: the associated type was found for
1111
- `Lexer<i32>`
1212

13-
error: aborting due to 1 previous error
13+
error: unconstrained opaque type
14+
--> $DIR/issue-109299-1.rs:10:10
15+
|
16+
LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
|
19+
= note: `X` must be used in combination with a concrete type within the same module
20+
21+
error: aborting due to 2 previous errors
1422

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

tests/ui/associated-inherent-types/issue-109768.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ impl<T> Local { //~ ERROR missing generics for struct `Local`
88
type AssocType3 = T; //~ ERROR inherent associated types are unstable
99

1010
const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper();
11+
//~^ ERROR: this struct takes 1 argument but 0 arguments were supplied
1112
}
1213
//~^ ERROR `main` function not found

tests/ui/associated-inherent-types/issue-109768.stderr

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0601]: `main` function not found in crate `issue_109768`
2-
--> $DIR/issue-109768.rs:11:2
2+
--> $DIR/issue-109768.rs:12:2
33
|
44
LL | }
55
| ^ consider adding a `main` function to `$DIR/issue-109768.rs`
@@ -29,7 +29,23 @@ LL | type AssocType3 = T;
2929
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
3030
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
3131

32-
error: aborting due to 3 previous errors
32+
error[E0061]: this struct takes 1 argument but 0 arguments were supplied
33+
--> $DIR/issue-109768.rs:10:56
34+
|
35+
LL | const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper();
36+
| ^^^^^^^-- an argument is missing
37+
|
38+
note: tuple struct defined here
39+
--> $DIR/issue-109768.rs:3:8
40+
|
41+
LL | struct Wrapper<T>(T);
42+
| ^^^^^^^
43+
help: provide the argument
44+
|
45+
LL | const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(/* value */);
46+
| ~~~~~~~~~~~~~
47+
48+
error: aborting due to 4 previous errors
3349

34-
Some errors have detailed explanations: E0107, E0601, E0658.
35-
For more information about an error, try `rustc --explain E0107`.
50+
Some errors have detailed explanations: E0061, E0107, E0601, E0658.
51+
For more information about an error, try `rustc --explain E0061`.

tests/ui/associated-type-bounds/duplicate.rs

+12
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ where
134134
fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
135135
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
136136
iter::empty()
137+
//~^ ERROR type annotations needed
137138
}
138139
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
139140
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
140141
iter::empty()
142+
//~^ ERROR type annotations needed
141143
}
142144
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
143145
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
144146
iter::empty()
147+
//~^ ERROR type annotations needed
145148
}
146149
fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
147150
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
@@ -194,12 +197,15 @@ trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
194197
trait TRS1: Iterator<Item: Copy, Item: Send> {}
195198
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
196199
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
200+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
197201
trait TRS2: Iterator<Item: Copy, Item: Copy> {}
198202
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
199203
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
204+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
200205
trait TRS3: Iterator<Item: 'static, Item: 'static> {}
201206
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
202207
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
208+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
203209
trait TRW1<T>
204210
where
205211
T: Iterator<Item: Copy, Item: Send>,
@@ -223,29 +229,35 @@ where
223229
Self: Iterator<Item: Copy, Item: Send>,
224230
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
225231
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
232+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
226233
{
227234
}
228235
trait TRSW2
229236
where
230237
Self: Iterator<Item: Copy, Item: Copy>,
231238
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
232239
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
240+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
233241
{
234242
}
235243
trait TRSW3
236244
where
237245
Self: Iterator<Item: 'static, Item: 'static>,
238246
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
239247
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
248+
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
240249
{
241250
}
242251
trait TRA1 {
243252
type A: Iterator<Item: Copy, Item: Send>;
244253
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
254+
//~| ERROR `<<Self as TRA1>::A as Iterator>::Item` cannot be sent between threads safely
255+
//~| ERROR the trait bound `<<Self as TRA1>::A as Iterator>::Item: Copy` is not satisfied
245256
}
246257
trait TRA2 {
247258
type A: Iterator<Item: Copy, Item: Copy>;
248259
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
260+
//~| ERROR the trait bound `<<Self as TRA2>::A as Iterator>::Item: Copy` is not satisfied
249261
}
250262
trait TRA3 {
251263
type A: Iterator<Item: 'static, Item: 'static>;

0 commit comments

Comments
 (0)