Skip to content

Commit 01aaad3

Browse files
committed
remove has_error_field helper method
1 parent fd9bf59 commit 01aaad3

File tree

5 files changed

+9
-40
lines changed

5 files changed

+9
-40
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1745,9 +1745,11 @@ fn check_variances_for_type_defn<'tcx>(
17451745
item: &hir::Item<'tcx>,
17461746
hir_generics: &hir::Generics<'_>,
17471747
) {
1748-
let ty = tcx.type_of(item.owner_id).subst_identity();
1749-
if tcx.has_error_field(ty) {
1750-
return;
1748+
let identity_substs = ty::InternalSubsts::identity_for_item(tcx, item.owner_id);
1749+
for field in tcx.adt_def(item.owner_id).all_fields() {
1750+
if field.ty(tcx, identity_substs).references_error() {
1751+
return;
1752+
}
17511753
}
17521754

17531755
let ty_predicates = tcx.predicates_of(item.owner_id);

compiler/rustc_middle/src/ty/util.rs

-12
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,6 @@ impl<'tcx> TyCtxt<'tcx> {
173173
}
174174
}
175175

176-
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
177-
if let ty::Adt(def, substs) = *ty.kind() {
178-
for field in def.all_fields() {
179-
let field_ty = field.ty(self, substs);
180-
if let ty::Error(_) = field_ty.kind() {
181-
return true;
182-
}
183-
}
184-
}
185-
false
186-
}
187-
188176
/// Attempts to returns the deeply last field of nested structures, but
189177
/// does not apply any normalization in its search. Returns the same type
190178
/// if input `ty` is not a structure at all.

tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
66
|
77
= note: type parameters may not be used in the type of const parameters
88

9-
error[E0392]: parameter `T` is never used
10-
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
11-
|
12-
LL | pub struct Dependent<T, const X: T>([(); X]);
13-
| ^ unused parameter
14-
|
15-
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
16-
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

20-
Some errors have detailed explanations: E0392, E0770.
21-
For more information about an error, try `rustc --explain E0392`.
11+
For more information about this error, try `rustc --explain E0770`.

tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
66
|
77
= note: type parameters may not be used in the type of const parameters
88

9-
error[E0392]: parameter `T` is never used
10-
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
11-
|
12-
LL | pub struct Dependent<T, const X: T>([(); X]);
13-
| ^ unused parameter
14-
|
15-
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
16-
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

20-
Some errors have detailed explanations: E0392, E0770.
21-
For more information about an error, try `rustc --explain E0392`.
11+
For more information about this error, try `rustc --explain E0770`.

tests/ui/const-generics/const-param-type-depends-on-type-param.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
pub struct Dependent<T, const X: T>([(); X]);
1212
//~^ ERROR: the type of const parameters must not depend on other generic parameters
13-
//~| ERROR: parameter `T` is never used
1413

1514
fn main() {}

0 commit comments

Comments
 (0)