Skip to content

Commit d0c8839

Browse files
authored
Rollup merge of #70870 - mark-i-m:de-abuse-err, r=eddyb
Fix abuses of tykind::err r? @eddyb cc #70866
2 parents 1758b7c + daddf4d commit d0c8839

File tree

9 files changed

+24
-16
lines changed

9 files changed

+24
-16
lines changed

src/librustc_codegen_llvm/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
2929

3030
assert!(!instance.substs.needs_infer());
3131
assert!(!instance.substs.has_escaping_bound_vars());
32-
assert!(!instance.substs.has_param_types());
32+
assert!(!instance.substs.has_param_types_or_consts());
3333

3434
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
3535
return llfn;

src/librustc_codegen_llvm/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
4747
visibility: Visibility,
4848
symbol_name: &str,
4949
) {
50-
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types());
50+
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());
5151

5252
let fn_abi = FnAbi::of_instance(self, instance, &[]);
5353
let lldecl = self.declare_fn(symbol_name, &fn_abi);

src/librustc_middle/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
8484
fn references_error(&self) -> bool {
8585
self.has_type_flags(TypeFlags::HAS_TY_ERR)
8686
}
87-
fn has_param_types(&self) -> bool {
87+
fn has_param_types_or_consts(&self) -> bool {
8888
self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
8989
}
9090
fn has_infer_types(&self) -> bool {

src/librustc_middle/ty/instance.rs

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

src/librustc_middle/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15851585
// Ignore layouts that are done with non-empty environments or
15861586
// non-monomorphic layouts, as the user only wants to see the stuff
15871587
// resulting from the final codegen session.
1588-
if layout.ty.has_param_types() || !self.param_env.caller_bounds.is_empty() {
1588+
if layout.ty.has_param_types_or_consts() || !self.param_env.caller_bounds.is_empty() {
15891589
return;
15901590
}
15911591

@@ -1754,7 +1754,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
17541754
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
17551755
match tail.kind {
17561756
ty::Param(_) | ty::Projection(_) => {
1757-
debug_assert!(tail.has_param_types());
1757+
debug_assert!(tail.has_param_types_or_consts());
17581758
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) })
17591759
}
17601760
_ => bug!(

src/librustc_privacy/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
12381238
if !self.in_body {
12391239
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
12401240
// The traits' privacy in bodies is already checked as a part of trait object types.
1241-
let bounds = rustc_typeck::hir_trait_to_predicates(self.tcx, trait_ref);
1241+
let bounds = rustc_typeck::hir_trait_to_predicates(
1242+
self.tcx,
1243+
trait_ref,
1244+
// NOTE: This isn't really right, but the actual type doesn't matter here. It's
1245+
// just required by `ty::TraitRef`.
1246+
self.tcx.types.never,
1247+
);
12421248

12431249
for (trait_predicate, _, _) in bounds.trait_bounds {
12441250
if self.visit_trait(*trait_predicate.skip_binder()) {

src/librustc_typeck/check/wfcheck.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,13 @@ fn check_where_clauses<'tcx, 'fcx>(
706706
return default_ty.into();
707707
}
708708
}
709-
// Mark unwanted params as error.
710-
fcx.tcx.types.err.into()
709+
710+
fcx.tcx.mk_param_from_def(param)
711711
}
712712

713713
GenericParamDefKind::Const => {
714714
// FIXME(const_generics:defaults)
715-
fcx.tcx.consts.err.into()
715+
fcx.tcx.mk_param_from_def(param)
716716
}
717717
}
718718
});
@@ -750,7 +750,10 @@ fn check_where_clauses<'tcx, 'fcx>(
750750
let substituted_pred = pred.subst(fcx.tcx, substs);
751751
// Don't check non-defaulted params, dependent defaults (including lifetimes)
752752
// or preds with multiple params.
753-
if substituted_pred.references_error() || param_count.params.len() > 1 || has_region {
753+
if substituted_pred.has_param_types_or_consts()
754+
|| param_count.params.len() > 1
755+
|| has_region
756+
{
754757
None
755758
} else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
756759
// Avoid duplication of predicates that contain no parameters, for example.

src/librustc_typeck/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
367367
pub fn hir_trait_to_predicates<'tcx>(
368368
tcx: TyCtxt<'tcx>,
369369
hir_trait: &hir::TraitRef<'_>,
370+
self_ty: Ty<'tcx>,
370371
) -> Bounds<'tcx> {
371372
// In case there are any projections, etc., find the "environment"
372373
// def-ID that will be used to determine the traits/predicates in
@@ -380,7 +381,7 @@ pub fn hir_trait_to_predicates<'tcx>(
380381
hir_trait,
381382
DUMMY_SP,
382383
hir::Constness::NotConst,
383-
tcx.types.err,
384+
self_ty,
384385
&mut bounds,
385386
true,
386387
);

src/librustc_typeck/variance/constraints.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
315315
self.add_constraints_from_region(current, r, contra);
316316

317317
if let Some(poly_trait_ref) = data.principal() {
318-
let poly_trait_ref =
319-
poly_trait_ref.with_self_ty(self.tcx(), self.tcx().types.err);
320-
self.add_constraints_from_trait_ref(
318+
self.add_constraints_from_invariant_substs(
321319
current,
322-
*poly_trait_ref.skip_binder(),
320+
poly_trait_ref.skip_binder().substs,
323321
variance,
324322
);
325323
}

0 commit comments

Comments
 (0)