1
Fork 0

Rollup merge of #70870 - mark-i-m:de-abuse-err, r=eddyb

Fix abuses of tykind::err

r? @eddyb

cc https://github.com/rust-lang/rust/issues/70866
This commit is contained in:
Dylan DPC 2020-04-08 23:33:43 +02:00 committed by GitHub
commit d0c88396e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 16 deletions

View file

@ -29,7 +29,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
assert!(!instance.substs.needs_infer());
assert!(!instance.substs.has_escaping_bound_vars());
assert!(!instance.substs.has_param_types());
assert!(!instance.substs.has_param_types_or_consts());
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
return llfn;

View file

@ -47,7 +47,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
visibility: Visibility,
symbol_name: &str,
) {
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types());
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());
let fn_abi = FnAbi::of_instance(self, instance, &[]);
let lldecl = self.declare_fn(symbol_name, &fn_abi);

View file

@ -84,7 +84,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
fn references_error(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_ERR)
}
fn has_param_types(&self) -> bool {
fn has_param_types_or_consts(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
}
fn has_infer_types(&self) -> bool {

View file

@ -91,7 +91,7 @@ impl<'tcx> Instance<'tcx> {
// There shouldn't be any params - if there are, then
// Instance.ty_env should have been used to provide the proper
// ParamEnv
if self.substs.has_param_types() {
if self.substs.has_param_types_or_consts() {
bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs);
}
tcx.subst_and_normalize_erasing_regions(self.substs, ty::ParamEnv::reveal_all(), &ty)

View file

@ -1585,7 +1585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Ignore layouts that are done with non-empty environments or
// non-monomorphic layouts, as the user only wants to see the stuff
// resulting from the final codegen session.
if layout.ty.has_param_types() || !self.param_env.caller_bounds.is_empty() {
if layout.ty.has_param_types_or_consts() || !self.param_env.caller_bounds.is_empty() {
return;
}
@ -1754,7 +1754,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
match tail.kind {
ty::Param(_) | ty::Projection(_) => {
debug_assert!(tail.has_param_types());
debug_assert!(tail.has_param_types_or_consts());
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) })
}
_ => bug!(

View file

@ -1238,7 +1238,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
if !self.in_body {
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
// The traits' privacy in bodies is already checked as a part of trait object types.
let bounds = rustc_typeck::hir_trait_to_predicates(self.tcx, trait_ref);
let bounds = rustc_typeck::hir_trait_to_predicates(
self.tcx,
trait_ref,
// NOTE: This isn't really right, but the actual type doesn't matter here. It's
// just required by `ty::TraitRef`.
self.tcx.types.never,
);
for (trait_predicate, _, _) in bounds.trait_bounds {
if self.visit_trait(*trait_predicate.skip_binder()) {

View file

@ -706,13 +706,13 @@ fn check_where_clauses<'tcx, 'fcx>(
return default_ty.into();
}
}
// Mark unwanted params as error.
fcx.tcx.types.err.into()
fcx.tcx.mk_param_from_def(param)
}
GenericParamDefKind::Const => {
// FIXME(const_generics:defaults)
fcx.tcx.consts.err.into()
fcx.tcx.mk_param_from_def(param)
}
}
});
@ -750,7 +750,10 @@ fn check_where_clauses<'tcx, 'fcx>(
let substituted_pred = pred.subst(fcx.tcx, substs);
// Don't check non-defaulted params, dependent defaults (including lifetimes)
// or preds with multiple params.
if substituted_pred.references_error() || param_count.params.len() > 1 || has_region {
if substituted_pred.has_param_types_or_consts()
|| param_count.params.len() > 1
|| has_region
{
None
} else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
// Avoid duplication of predicates that contain no parameters, for example.

View file

@ -367,6 +367,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
pub fn hir_trait_to_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
hir_trait: &hir::TraitRef<'_>,
self_ty: Ty<'tcx>,
) -> Bounds<'tcx> {
// In case there are any projections, etc., find the "environment"
// def-ID that will be used to determine the traits/predicates in
@ -380,7 +381,7 @@ pub fn hir_trait_to_predicates<'tcx>(
hir_trait,
DUMMY_SP,
hir::Constness::NotConst,
tcx.types.err,
self_ty,
&mut bounds,
true,
);

View file

@ -315,11 +315,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
self.add_constraints_from_region(current, r, contra);
if let Some(poly_trait_ref) = data.principal() {
let poly_trait_ref =
poly_trait_ref.with_self_ty(self.tcx(), self.tcx().types.err);
self.add_constraints_from_trait_ref(
self.add_constraints_from_invariant_substs(
current,
*poly_trait_ref.skip_binder(),
poly_trait_ref.skip_binder().substs,
variance,
);
}