Skip to content

Commit

Permalink
Rollup merge of rust-lang#70870 - mark-i-m:de-abuse-err, r=eddyb
Browse files Browse the repository at this point in the history
Fix abuses of tykind::err

r? @eddyb

cc rust-lang#70866
  • Loading branch information
Dylan-DPC committed Apr 8, 2020
2 parents 1758b7c + daddf4d commit d0c8839
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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!(
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
});
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
);
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/variance/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down

0 comments on commit d0c8839

Please sign in to comment.