diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index a36314448b170..9db5c40c8e362 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -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; diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index 29389b44adc27..486ea7f22dfff 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -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); diff --git a/src/librustc_middle/ty/fold.rs b/src/librustc_middle/ty/fold.rs index 7b23460eb6e4c..9989e3fba730e 100644 --- a/src/librustc_middle/ty/fold.rs +++ b/src/librustc_middle/ty/fold.rs @@ -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 { diff --git a/src/librustc_middle/ty/instance.rs b/src/librustc_middle/ty/instance.rs index cf0222370f288..894f9070ce154 100644 --- a/src/librustc_middle/ty/instance.rs +++ b/src/librustc_middle/ty/instance.rs @@ -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) diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 5740f8cc091c4..1bb338d43ad0a 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -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!( diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 567022fe4052f..34470c2ded5f9 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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()) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b0ff17ad56d7c..e18508eeeb18e 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -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. diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 7ea6c1c17869a..69d0b3723b0ad 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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, ); diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 2871fa606b570..afa6e49a05cf1 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -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, ); }