Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 333aab4

Browse files
committed
Avoid silencing relevant follow-up errors
1 parent 22b2712 commit 333aab4

File tree

210 files changed

+2874
-448
lines changed

Some content is hidden

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

210 files changed

+2874
-448
lines changed

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
168168

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

178175
if tcx.features().rustc_attrs {
179176
tcx.sess.track_errors(|| {

compiler/rustc_hir_analysis/src/outlives/test.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
88
// attribute and report an error with various results if found.
99
if tcx.has_attr(id.owner_id, sym::rustc_outlives) {
1010
let inferred_outlives_of = tcx.inferred_outlives_of(id.owner_id);
11-
struct_span_err!(
12-
tcx.sess,
13-
tcx.def_span(id.owner_id),
14-
E0640,
15-
"{:?}",
16-
inferred_outlives_of
17-
)
18-
.emit();
11+
let mut err =
12+
struct_span_err!(tcx.sess, tcx.def_span(id.owner_id), E0640, "rustc_outlives");
13+
for &(clause, span) in inferred_outlives_of {
14+
err.span_note(span, format!("{clause}"));
15+
}
16+
err.emit();
1917
}
2018
}
2119
}

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 6 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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
| ^^^^^^^^^^ help: use fully-qualified syntax: `<Windows<T> as IntoIterator>::Item`

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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 15 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 9 additions & 1 deletion
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 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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 20 additions & 4 deletions
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`.

0 commit comments

Comments
 (0)