diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-10 13:12:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 13:12:30 +0100 |
| commit | 2dbc9f55f76aac46c0e9ed31b60d8c2960d2f5f0 (patch) | |
| tree | 215cc30e18a679380a599d372603b0a35ebb7e60 | |
| parent | 83544703f5050ca80984b1ae9f7ad6f59aab8bac (diff) | |
| parent | bb60ded24b6e4a8dfbcf8533b58c1a35b87bbb8b (diff) | |
| download | rust-2dbc9f55f76aac46c0e9ed31b60d8c2960d2f5f0.tar.gz rust-2dbc9f55f76aac46c0e9ed31b60d8c2960d2f5f0.zip | |
Rollup merge of #120859 - nnethercote:fix-120856, r=oli-obk
Loosen an assertion to account for stashed errors. The meaning of this assertion changed in #120828 when the meaning of `has_errors` changed to exclude stashed errors. Evidently the new meaning is too restrictive. Fixes #120856. r? ```@oli-obk```
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 3 | ||||
| -rw-r--r-- | tests/ui/typeck/issue-120856.rs | 5 | ||||
| -rw-r--r-- | tests/ui/typeck/issue-120856.stderr | 21 |
3 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 50809a571b8..7250dc81faf 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1283,7 +1283,8 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD let ty = tcx.type_of(def_id).instantiate_identity(); if ty.references_error() { // If there is already another error, do not emit an error for not using a type parameter. - assert!(tcx.dcx().has_errors().is_some()); + // Without the `stashed_err_count` part this can fail (#120856). + assert!(tcx.dcx().has_errors().is_some() || tcx.dcx().stashed_err_count() > 0); return; } diff --git a/tests/ui/typeck/issue-120856.rs b/tests/ui/typeck/issue-120856.rs new file mode 100644 index 00000000000..e435a0f9d8e --- /dev/null +++ b/tests/ui/typeck/issue-120856.rs @@ -0,0 +1,5 @@ +pub type Archived<T> = <m::Alias as n::Trait>::Archived; +//~^ ERROR failed to resolve: use of undeclared crate or module `m` +//~| ERROR failed to resolve: use of undeclared crate or module `n` + +fn main() {} diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr new file mode 100644 index 00000000000..1fc8b200473 --- /dev/null +++ b/tests/ui/typeck/issue-120856.stderr @@ -0,0 +1,21 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `n` + --> $DIR/issue-120856.rs:1:37 + | +LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; + | ^ + | | + | use of undeclared crate or module `n` + | help: a trait with a similar name exists: `Fn` + +error[E0433]: failed to resolve: use of undeclared crate or module `m` + --> $DIR/issue-120856.rs:1:25 + | +LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; + | ^ + | | + | use of undeclared crate or module `m` + | help: a type parameter with a similar name exists: `T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. |
