Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove TyCtxt::has_error_field helper method #112340

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,9 +1745,11 @@ fn check_variances_for_type_defn<'tcx>(
item: &hir::Item<'tcx>,
hir_generics: &hir::Generics<'_>,
) {
let ty = tcx.type_of(item.owner_id).subst_identity();
if tcx.has_error_field(ty) {
return;
let identity_substs = ty::InternalSubsts::identity_for_item(tcx, item.owner_id);
for field in tcx.adt_def(item.owner_id).all_fields() {
if field.ty(tcx, identity_substs).references_error() {
return;
}
}

let ty_predicates = tcx.predicates_of(item.owner_id);
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
if let ty::Adt(def, substs) = *ty.kind() {
for field in def.all_fields() {
let field_ty = field.ty(self, substs);
if let ty::Error(_) = field_ty.kind() {
return true;
}
}
}
false
}

/// Attempts to returns the deeply last field of nested structures, but
/// does not apply any normalization in its search. Returns the same type
/// if input `ty` is not a structure at all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
|
= note: type parameters may not be used in the type of const parameters

error[E0392]: parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: usize` instead

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0392, E0770.
For more information about an error, try `rustc --explain E0392`.
For more information about this error, try `rustc --explain E0770`.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
|
= note: type parameters may not be used in the type of const parameters

error[E0392]: parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: usize` instead

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0392, E0770.
For more information about an error, try `rustc --explain E0392`.
For more information about this error, try `rustc --explain E0770`.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@

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

fn main() {}