Skip to content

Commit 01af504

Browse files
committed
Auto merge of #102666 - matthiaskrgr:rollup-tuge18t, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #102241 (Package `rust-docs-json` into nightly components (take 3)) - #102488 (Check generic argument compatibility when projecting assoc ty) - #102647 (Only allow ~const bounds for traits with #[const_trait]) - #102648 (Add test for #102605) - #102651 (It's not about types or consts, but the lack of regions) - #102653 (resolve instance: missing value to `delay_span_bug`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 02cd79a + db94aed commit 01af504

File tree

73 files changed

+434
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+434
-201
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
236236
.unwrap();
237237
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
238238
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
239-
if hidden_type.has_infer_types_or_consts() {
239+
if hidden_type.has_non_region_infer() {
240240
infcx.tcx.sess.delay_span_bug(
241241
decl.hidden_type.span,
242242
&format!("could not resolve {:#?}", hidden_type.ty.kind()),

compiler/rustc_hir_analysis/src/check/fn_ctxt/_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9191
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
9292
) -> Ty<'tcx> {
9393
// No Infer()? Nothing needs doing.
94-
if !ty.has_infer_types_or_consts() {
94+
if !ty.has_non_region_infer() {
9595
debug!("no inference var, nothing needs doing");
9696
return ty;
9797
}
9898

9999
// If `ty` is a type variable, see whether we already know what it is.
100100
ty = self.resolve_vars_if_possible(ty);
101-
if !ty.has_infer_types_or_consts() {
101+
if !ty.has_non_region_infer() {
102102
debug!(?ty);
103103
return ty;
104104
}

compiler/rustc_hir_analysis/src/check/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6363
let get_operand_ty = |expr| {
6464
let ty = self.typeck_results.borrow().expr_ty_adjusted(expr);
6565
let ty = self.resolve_vars_if_possible(ty);
66-
if ty.has_infer_types_or_consts() {
66+
if ty.has_non_region_infer() {
6767
assert!(self.is_tainted_by_errors());
6868
self.tcx.ty_error()
6969
} else {

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
149149
target_features: &FxHashSet<Symbol>,
150150
) -> Option<InlineAsmType> {
151151
let ty = (self.get_operand_ty)(expr);
152-
if ty.has_infer_types_or_consts() {
152+
if ty.has_non_region_infer() {
153153
bug!("inference variable in asm operand ty: {:?} {:?}", expr, ty);
154154
}
155155
let asm_ty_isize = match self.tcx.sess.target.pointer_width {

compiler/rustc_hir_analysis/src/check/op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
471471
// This has nothing here because it means we did string
472472
// concatenation (e.g., "Hello " + "World!"). This means
473473
// we don't want the note in the else clause to be emitted
474-
} else if lhs_ty.has_param_types_or_consts() {
474+
} else if lhs_ty.has_non_region_param() {
475475
// Look for a TraitPredicate in the Fulfillment errors,
476476
// and use it to generate a suggestion.
477477
//
@@ -657,7 +657,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
657657
format!("cannot apply unary operator `{}`", op.as_str()),
658658
);
659659

660-
if operand_ty.has_param_types_or_consts() {
660+
if operand_ty.has_non_region_param() {
661661
let predicates = errors.iter().filter_map(|error| {
662662
error.obligation.predicate.to_opt_poly_trait_pred()
663663
});

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14281428
let substituted_pred = predicates.rebind(pred).subst(tcx, substs);
14291429
// Don't check non-defaulted params, dependent defaults (including lifetimes)
14301430
// or preds with multiple params.
1431-
if substituted_pred.has_param_types_or_consts()
1432-
|| param_count.params.len() > 1
1433-
|| has_region
1431+
if substituted_pred.has_non_region_param() || param_count.params.len() > 1 || has_region
14341432
{
14351433
None
14361434
} else if predicates.0.predicates.iter().any(|&(p, _)| p == substituted_pred) {

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
712712
) -> bool {
713713
// Reject any attempt to unify two unevaluated constants that contain inference
714714
// variables, since inference variables in queries lead to ICEs.
715-
if a.substs.has_infer_types_or_consts()
716-
|| b.substs.has_infer_types_or_consts()
717-
|| param_env.has_infer_types_or_consts()
715+
if a.substs.has_non_region_infer()
716+
|| b.substs.has_non_region_infer()
717+
|| param_env.has_non_region_infer()
718718
{
719719
debug!("a or b or param_env contain infer vars in its substs -> cannot unify");
720720
return false;
@@ -1734,7 +1734,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17341734

17351735
// Postpone the evaluation of constants whose substs depend on inference
17361736
// variables
1737-
if substs.has_infer_types_or_consts() {
1737+
if substs.has_non_region_infer() {
17381738
let ac = AbstractConst::new(self.tcx, unevaluated);
17391739
match ac {
17401740
Ok(None) => {
@@ -2072,21 +2072,17 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
20722072
) -> SubstsRef<'tcx> {
20732073
tcx.mk_substs(substs.iter().enumerate().map(|(idx, arg)| {
20742074
match arg.unpack() {
2075-
GenericArgKind::Type(_)
2076-
if arg.has_param_types_or_consts() || arg.has_infer_types_or_consts() =>
2077-
{
2075+
GenericArgKind::Type(_) if arg.has_non_region_param() || arg.has_non_region_infer() => {
20782076
tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
20792077
universe: ty::UniverseIndex::ROOT,
20802078
name: ty::BoundVar::from_usize(idx),
20812079
}))
20822080
.into()
20832081
}
2084-
GenericArgKind::Const(ct)
2085-
if ct.has_infer_types_or_consts() || ct.has_param_types_or_consts() =>
2086-
{
2082+
GenericArgKind::Const(ct) if ct.has_non_region_infer() || ct.has_non_region_param() => {
20872083
let ty = ct.ty();
20882084
// If the type references param or infer, replace that too...
2089-
if ty.has_param_types_or_consts() || ty.has_infer_types_or_consts() {
2085+
if ty.has_non_region_param() || ty.has_non_region_infer() {
20902086
bug!("const `{ct}`'s type should not reference params or types");
20912087
}
20922088
tcx.mk_const(ty::ConstS {

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ where
357357
// In NLL, we don't have type inference variables
358358
// floating around, so we can do this rather imprecise
359359
// variant of the occurs-check.
360-
assert!(!generalized_ty.has_infer_types_or_consts());
360+
assert!(!generalized_ty.has_non_region_infer());
361361
}
362362

363363
self.infcx.inner.borrow_mut().type_variables().instantiate(vid, generalized_ty);

compiler/rustc_infer/src/infer/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
3232
}
3333

3434
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
35-
if !t.has_infer_types_or_consts() {
35+
if !t.has_non_region_infer() {
3636
t // micro-optimize -- if there is nothing in this type that this fold affects...
3737
} else {
3838
let t = self.infcx.shallow_resolve(t);
@@ -41,7 +41,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
4141
}
4242

4343
fn fold_const(&mut self, ct: Const<'tcx>) -> Const<'tcx> {
44-
if !ct.has_infer_types_or_consts() {
44+
if !ct.has_non_region_infer() {
4545
ct // micro-optimize -- if there is nothing in this const that this fold affects...
4646
} else {
4747
let ct = self.infcx.shallow_resolve(ct);

compiler/rustc_middle/src/mir/interpret/queries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'tcx> TyCtxt<'tcx> {
4545
//
4646
// When trying to evaluate constants containing inference variables,
4747
// use `Infcx::const_eval_resolve` instead.
48-
if ct.substs.has_infer_types_or_consts() {
48+
if ct.substs.has_non_region_infer() {
4949
bug!("did not expect inference variables here");
5050
}
5151

@@ -76,7 +76,7 @@ impl<'tcx> TyCtxt<'tcx> {
7676
//
7777
// When trying to evaluate constants containing inference variables,
7878
// use `Infcx::const_eval_resolve` instead.
79-
if ct.substs.has_infer_types_or_consts() {
79+
if ct.substs.has_non_region_infer() {
8080
bug!("did not expect inference variables here");
8181
}
8282

0 commit comments

Comments
 (0)