remove has_error_field
helper method
This commit is contained in:
parent
fd9bf59436
commit
01aaad3f1f
5 changed files with 9 additions and 40 deletions
|
@ -1745,9 +1745,11 @@ fn check_variances_for_type_defn<'tcx>(
|
||||||
item: &hir::Item<'tcx>,
|
item: &hir::Item<'tcx>,
|
||||||
hir_generics: &hir::Generics<'_>,
|
hir_generics: &hir::Generics<'_>,
|
||||||
) {
|
) {
|
||||||
let ty = tcx.type_of(item.owner_id).subst_identity();
|
let identity_substs = ty::InternalSubsts::identity_for_item(tcx, item.owner_id);
|
||||||
if tcx.has_error_field(ty) {
|
for field in tcx.adt_def(item.owner_id).all_fields() {
|
||||||
return;
|
if field.ty(tcx, identity_substs).references_error() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ty_predicates = tcx.predicates_of(item.owner_id);
|
let ty_predicates = tcx.predicates_of(item.owner_id);
|
||||||
|
|
|
@ -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
|
/// Attempts to returns the deeply last field of nested structures, but
|
||||||
/// does not apply any normalization in its search. Returns the same type
|
/// does not apply any normalization in its search. Returns the same type
|
||||||
/// if input `ty` is not a structure at all.
|
/// if input `ty` is not a structure at all.
|
||||||
|
|
|
@ -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
|
= note: type parameters may not be used in the type of const parameters
|
||||||
|
|
||||||
error[E0392]: parameter `T` is never used
|
error: aborting due to previous error
|
||||||
--> $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
|
For more information about this error, try `rustc --explain E0770`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0392, E0770.
|
|
||||||
For more information about an error, try `rustc --explain E0392`.
|
|
||||||
|
|
|
@ -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
|
= note: type parameters may not be used in the type of const parameters
|
||||||
|
|
||||||
error[E0392]: parameter `T` is never used
|
error: aborting due to previous error
|
||||||
--> $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
|
For more information about this error, try `rustc --explain E0770`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0392, E0770.
|
|
||||||
For more information about an error, try `rustc --explain E0392`.
|
|
||||||
|
|
|
@ -10,6 +10,5 @@
|
||||||
|
|
||||||
pub struct Dependent<T, const X: T>([(); X]);
|
pub struct Dependent<T, const X: T>([(); X]);
|
||||||
//~^ ERROR: the type of const parameters must not depend on other generic parameters
|
//~^ ERROR: the type of const parameters must not depend on other generic parameters
|
||||||
//~| ERROR: parameter `T` is never used
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue