Skip to content

Commit 53180d1

Browse files
authored
Unrolled build for rust-lang#120859
Rollup merge of rust-lang#120859 - nnethercote:fix-120856, r=oli-obk Loosen an assertion to account for stashed errors. The meaning of this assertion changed in rust-lang#120828 when the meaning of `has_errors` changed to exclude stashed errors. Evidently the new meaning is too restrictive. Fixes rust-lang#120856. r? ```@oli-obk```
2 parents 232919c + bb60ded commit 53180d1

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,8 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
12831283
let ty = tcx.type_of(def_id).instantiate_identity();
12841284
if ty.references_error() {
12851285
// If there is already another error, do not emit an error for not using a type parameter.
1286-
assert!(tcx.dcx().has_errors().is_some());
1286+
// Without the `stashed_err_count` part this can fail (#120856).
1287+
assert!(tcx.dcx().has_errors().is_some() || tcx.dcx().stashed_err_count() > 0);
12871288
return;
12881289
}
12891290

tests/ui/typeck/issue-120856.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub type Archived<T> = <m::Alias as n::Trait>::Archived;
2+
//~^ ERROR failed to resolve: use of undeclared crate or module `m`
3+
//~| ERROR failed to resolve: use of undeclared crate or module `n`
4+
5+
fn main() {}

tests/ui/typeck/issue-120856.stderr

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0433]: failed to resolve: use of undeclared crate or module `n`
2+
--> $DIR/issue-120856.rs:1:37
3+
|
4+
LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived;
5+
| ^
6+
| |
7+
| use of undeclared crate or module `n`
8+
| help: a trait with a similar name exists: `Fn`
9+
10+
error[E0433]: failed to resolve: use of undeclared crate or module `m`
11+
--> $DIR/issue-120856.rs:1:25
12+
|
13+
LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived;
14+
| ^
15+
| |
16+
| use of undeclared crate or module `m`
17+
| help: a type parameter with a similar name exists: `T`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)