Skip to content

Commit ef934d9

Browse files
committed
Auto merge of #107811 - matthiaskrgr:rollup-rpjzshk, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #105641 (Implement cursors for BTreeMap) - #107271 (Treat Drop as a rmw operation) - #107710 (Update strip-ansi-escapes and vte) - #107758 (Change `arena_cache` to not alter the declared query result) - #107777 (Make `derive_const` derive properly const-if-const impls) - #107780 (Rename `replace_bound_vars_with_*` to `instantiate_binder_with_*`) - #107793 (Add missing tracking issue for `RawOsError`) - #107807 (Fix small debug typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9433ba6 + 3eea052 commit ef934d9

File tree

53 files changed

+1248
-210
lines changed

Some content is hidden

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

53 files changed

+1248
-210
lines changed

Cargo.lock

+28-10
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ version = "1.0.3"
127127
source = "registry+https://github.com/rust-lang/crates.io-index"
128128
checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271"
129129

130+
[[package]]
131+
name = "arrayvec"
132+
version = "0.5.2"
133+
source = "registry+https://github.com/rust-lang/crates.io-index"
134+
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
135+
130136
[[package]]
131137
name = "arrayvec"
132138
version = "0.7.0"
@@ -791,7 +797,7 @@ dependencies = [
791797
name = "clippy_utils"
792798
version = "0.1.69"
793799
dependencies = [
794-
"arrayvec",
800+
"arrayvec 0.7.0",
795801
"if_chain",
796802
"itertools",
797803
"rustc-semver",
@@ -3912,7 +3918,7 @@ dependencies = [
39123918
name = "rustc_data_structures"
39133919
version = "0.0.0"
39143920
dependencies = [
3915-
"arrayvec",
3921+
"arrayvec 0.7.0",
39163922
"bitflags",
39173923
"cfg-if",
39183924
"ena",
@@ -4169,7 +4175,7 @@ dependencies = [
41694175
name = "rustc_index"
41704176
version = "0.0.0"
41714177
dependencies = [
4172-
"arrayvec",
4178+
"arrayvec 0.7.0",
41734179
"rustc_macros",
41744180
"rustc_serialize",
41754181
"smallvec",
@@ -4866,7 +4872,7 @@ dependencies = [
48664872
name = "rustdoc"
48674873
version = "0.0.0"
48684874
dependencies = [
4869-
"arrayvec",
4875+
"arrayvec 0.7.0",
48704876
"askama",
48714877
"expect-test",
48724878
"itertools",
@@ -5375,9 +5381,9 @@ dependencies = [
53755381

53765382
[[package]]
53775383
name = "strip-ansi-escapes"
5378-
version = "0.1.0"
5384+
version = "0.1.1"
53795385
source = "registry+https://github.com/rust-lang/crates.io-index"
5380-
checksum = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee"
5386+
checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8"
53815387
dependencies = [
53825388
"vte",
53835389
]
@@ -6089,9 +6095,9 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
60896095

60906096
[[package]]
60916097
name = "utf8parse"
6092-
version = "0.1.1"
6098+
version = "0.2.0"
60936099
source = "registry+https://github.com/rust-lang/crates.io-index"
6094-
checksum = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d"
6100+
checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372"
60956101

60966102
[[package]]
60976103
name = "uuid"
@@ -6122,11 +6128,23 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
61226128

61236129
[[package]]
61246130
name = "vte"
6125-
version = "0.3.3"
6131+
version = "0.10.1"
61266132
source = "registry+https://github.com/rust-lang/crates.io-index"
6127-
checksum = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf"
6133+
checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983"
61286134
dependencies = [
6135+
"arrayvec 0.5.2",
61296136
"utf8parse",
6137+
"vte_generate_state_changes",
6138+
]
6139+
6140+
[[package]]
6141+
name = "vte_generate_state_changes"
6142+
version = "0.1.1"
6143+
source = "registry+https://github.com/rust-lang/crates.io-index"
6144+
checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
6145+
dependencies = [
6146+
"proc-macro2",
6147+
"quote",
61306148
]
61316149

61326150
[[package]]

compiler/rustc_ast_pretty/src/pprust/state.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,18 @@ impl<'a> State<'a> {
15671567

15681568
match bound {
15691569
GenericBound::Trait(tref, modifier) => {
1570-
if modifier == &TraitBoundModifier::Maybe {
1571-
self.word("?");
1570+
match modifier {
1571+
TraitBoundModifier::None => {}
1572+
TraitBoundModifier::Maybe => {
1573+
self.word("?");
1574+
}
1575+
TraitBoundModifier::MaybeConst => {
1576+
self.word_space("~const");
1577+
}
1578+
TraitBoundModifier::MaybeConstMaybe => {
1579+
self.word_space("~const");
1580+
self.word("?");
1581+
}
15721582
}
15731583
self.print_poly_trait_ref(tref);
15741584
}

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11391139
if let ty::Adt(def, substs) = ty.kind()
11401140
&& Some(def.did()) == tcx.lang_items().pin_type()
11411141
&& let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()
1142-
&& let self_ty = infcx.replace_bound_vars_with_fresh_vars(
1142+
&& let self_ty = infcx.instantiate_binder_with_fresh_vars(
11431143
fn_call_span,
11441144
LateBoundRegionConversionTime::FnCall,
11451145
tcx.fn_sig(method_did).subst(tcx, method_substs).input(0),

compiler/rustc_borrowck/src/type_check/input_output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
3838
// so that they represent the view from "inside" the closure.
3939
let user_provided_sig = self
4040
.instantiate_canonical_with_fresh_inference_vars(body.span, &user_provided_poly_sig);
41-
let user_provided_sig = self.infcx.replace_bound_vars_with_fresh_vars(
41+
let user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
4242
body.span,
4343
LateBoundRegionConversionTime::FnCall,
4444
user_provided_sig,

compiler/rustc_builtin_macros/src/deriving/debug.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
153153
let path_debug = cx.path_global(span, cx.std_path(&[sym::fmt, sym::Debug]));
154154
let ty_dyn_debug = cx.ty(
155155
span,
156-
ast::TyKind::TraitObject(vec![cx.trait_bound(path_debug)], ast::TraitObjectSyntax::Dyn),
156+
ast::TyKind::TraitObject(
157+
vec![cx.trait_bound(path_debug, false)],
158+
ast::TraitObjectSyntax::Dyn,
159+
),
157160
);
158161
let ty_slice = cx.ty(
159162
span,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -605,18 +605,26 @@ impl<'a> TraitDef<'a> {
605605
let bounds: Vec<_> = self
606606
.additional_bounds
607607
.iter()
608-
.map(|p| cx.trait_bound(p.to_path(cx, self.span, type_ident, generics)))
608+
.map(|p| {
609+
cx.trait_bound(
610+
p.to_path(cx, self.span, type_ident, generics),
611+
self.is_const,
612+
)
613+
})
609614
.chain(
610615
// Add a bound for the current trait.
611616
self.skip_path_as_bound
612617
.not()
613-
.then(|| cx.trait_bound(trait_path.clone())),
618+
.then(|| cx.trait_bound(trait_path.clone(), self.is_const)),
614619
)
615620
.chain({
616621
// Add a `Copy` bound if required.
617622
if is_packed && self.needs_copy_as_bound_if_packed {
618623
let p = deriving::path_std!(marker::Copy);
619-
Some(cx.trait_bound(p.to_path(cx, self.span, type_ident, generics)))
624+
Some(cx.trait_bound(
625+
p.to_path(cx, self.span, type_ident, generics),
626+
self.is_const,
627+
))
620628
} else {
621629
None
622630
}
@@ -694,18 +702,24 @@ impl<'a> TraitDef<'a> {
694702
let mut bounds: Vec<_> = self
695703
.additional_bounds
696704
.iter()
697-
.map(|p| cx.trait_bound(p.to_path(cx, self.span, type_ident, generics)))
705+
.map(|p| {
706+
cx.trait_bound(
707+
p.to_path(cx, self.span, type_ident, generics),
708+
self.is_const,
709+
)
710+
})
698711
.collect();
699712

700713
// Require the current trait.
701-
bounds.push(cx.trait_bound(trait_path.clone()));
714+
bounds.push(cx.trait_bound(trait_path.clone(), self.is_const));
702715

703716
// Add a `Copy` bound if required.
704717
if is_packed && self.needs_copy_as_bound_if_packed {
705718
let p = deriving::path_std!(marker::Copy);
706-
bounds.push(
707-
cx.trait_bound(p.to_path(cx, self.span, type_ident, generics)),
708-
);
719+
bounds.push(cx.trait_bound(
720+
p.to_path(cx, self.span, type_ident, generics),
721+
self.is_const,
722+
));
709723
}
710724

711725
let predicate = ast::WhereBoundPredicate {

compiler/rustc_builtin_macros/src/deriving/generic/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn mk_ty_param(
154154
.iter()
155155
.map(|b| {
156156
let path = b.to_path(cx, span, self_ident, self_generics);
157-
cx.trait_bound(path)
157+
cx.trait_bound(path, false)
158158
})
159159
.collect();
160160
cx.typaram(span, Ident::new(name, span), bounds, None)

compiler/rustc_expand/src/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ impl<'a> ExtCtxt<'a> {
131131
}
132132
}
133133

134-
pub fn trait_bound(&self, path: ast::Path) -> ast::GenericBound {
134+
pub fn trait_bound(&self, path: ast::Path, is_const: bool) -> ast::GenericBound {
135135
ast::GenericBound::Trait(
136136
self.poly_trait_ref(path.span, path),
137-
ast::TraitBoundModifier::None,
137+
if is_const {
138+
ast::TraitBoundModifier::MaybeConst
139+
} else {
140+
ast::TraitBoundModifier::None
141+
},
138142
)
139143
}
140144

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn compare_method_predicate_entailment<'tcx>(
246246

247247
let mut wf_tys = FxIndexSet::default();
248248

249-
let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars(
249+
let unnormalized_impl_sig = infcx.instantiate_binder_with_fresh_vars(
250250
impl_m_span,
251251
infer::HigherRankedType,
252252
tcx.fn_sig(impl_m.def_id).subst_identity(),
@@ -640,7 +640,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
640640
let impl_sig = ocx.normalize(
641641
&norm_cause,
642642
param_env,
643-
infcx.replace_bound_vars_with_fresh_vars(
643+
infcx.instantiate_binder_with_fresh_vars(
644644
return_span,
645645
infer::HigherRankedType,
646646
tcx.fn_sig(impl_m.def_id).subst_identity(),

compiler/rustc_hir_typeck/src/callee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
156156
// fnmut vs fnonce. If so, we have to defer further processing.
157157
if self.closure_kind(substs).is_none() {
158158
let closure_sig = substs.as_closure().sig();
159-
let closure_sig = self.replace_bound_vars_with_fresh_vars(
159+
let closure_sig = self.instantiate_binder_with_fresh_vars(
160160
call_expr.span,
161161
infer::FnCall,
162162
closure_sig,
@@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
437437
// renormalize the associated types at this point, since they
438438
// previously appeared within a `Binder<>` and hence would not
439439
// have been normalized before.
440-
let fn_sig = self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
440+
let fn_sig = self.instantiate_binder_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
441441
let fn_sig = self.normalize(call_expr.span, fn_sig);
442442

443443
// Call the generic checker.

compiler/rustc_hir_typeck/src/closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
544544
)
545545
.map(|(hir_ty, &supplied_ty)| {
546546
// Instantiate (this part of..) S to S', i.e., with fresh variables.
547-
self.replace_bound_vars_with_fresh_vars(
547+
self.instantiate_binder_with_fresh_vars(
548548
hir_ty.span,
549549
LateBoundRegionConversionTime::FnCall,
550550
// (*) binder moved to here
@@ -566,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
566566
all_obligations.extend(obligations);
567567
}
568568

569-
let supplied_output_ty = self.replace_bound_vars_with_fresh_vars(
569+
let supplied_output_ty = self.instantiate_binder_with_fresh_vars(
570570
decl.output.span(),
571571
LateBoundRegionConversionTime::FnCall,
572572
supplied_sig.output(),

compiler/rustc_hir_typeck/src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
568568
// placeholder lifetimes with probing, we just replace higher lifetimes
569569
// with fresh vars.
570570
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
571-
let input = self.replace_bound_vars_with_fresh_vars(
571+
let input = self.instantiate_binder_with_fresh_vars(
572572
span,
573573
infer::LateBoundRegionConversionTime::FnCall,
574574
fn_sig.input(i),
@@ -586,7 +586,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
586586
// Also, as we just want to check sizedness, instead of introducing
587587
// placeholder lifetimes with probing, we just replace higher lifetimes
588588
// with fresh vars.
589-
let output = self.replace_bound_vars_with_fresh_vars(
589+
let output = self.instantiate_binder_with_fresh_vars(
590590
expr.span,
591591
infer::LateBoundRegionConversionTime::FnCall,
592592
fn_sig.output(),

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
289289
item_segment: &hir::PathSegment<'_>,
290290
poly_trait_ref: ty::PolyTraitRef<'tcx>,
291291
) -> Ty<'tcx> {
292-
let trait_ref = self.replace_bound_vars_with_fresh_vars(
292+
let trait_ref = self.instantiate_binder_with_fresh_vars(
293293
span,
294294
infer::LateBoundRegionConversionTime::AssocTypeProjection(item_def_id),
295295
poly_trait_ref,

compiler/rustc_hir_typeck/src/method/confirm.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
262262
let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty);
263263
let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id);
264264
let upcast_trait_ref =
265-
this.replace_bound_vars_with_fresh_vars(upcast_poly_trait_ref);
265+
this.instantiate_binder_with_fresh_vars(upcast_poly_trait_ref);
266266
debug!(
267267
"original_poly_trait_ref={:?} upcast_trait_ref={:?} target_trait={:?}",
268268
original_poly_trait_ref, upcast_trait_ref, trait_def_id
@@ -285,7 +285,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
285285
probe::WhereClausePick(poly_trait_ref) => {
286286
// Where clauses can have bound regions in them. We need to instantiate
287287
// those to convert from a poly-trait-ref to a trait-ref.
288-
self.replace_bound_vars_with_fresh_vars(poly_trait_ref).substs
288+
self.instantiate_binder_with_fresh_vars(poly_trait_ref).substs
289289
}
290290
}
291291
}
@@ -506,7 +506,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
506506
let sig = self.tcx.fn_sig(def_id).subst(self.tcx, all_substs);
507507
debug!("type scheme substituted, sig={:?}", sig);
508508

509-
let sig = self.replace_bound_vars_with_fresh_vars(sig);
509+
let sig = self.instantiate_binder_with_fresh_vars(sig);
510510
debug!("late-bound lifetimes from method instantiated, sig={:?}", sig);
511511

512512
(sig, method_predicates)
@@ -625,10 +625,10 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
625625
upcast_trait_refs.into_iter().next().unwrap()
626626
}
627627

628-
fn replace_bound_vars_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
628+
fn instantiate_binder_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
629629
where
630630
T: TypeFoldable<'tcx> + Copy,
631631
{
632-
self.fcx.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, value)
632+
self.fcx.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, value)
633633
}
634634
}

compiler/rustc_hir_typeck/src/method/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
401401
// with bound regions.
402402
let fn_sig = tcx.fn_sig(def_id).subst(self.tcx, substs);
403403
let fn_sig =
404-
self.replace_bound_vars_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);
404+
self.instantiate_binder_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);
405405

406406
let InferOk { value, obligations: o } =
407407
self.at(&obligation.cause, self.param_env).normalize(fn_sig);

compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
924924
ty::AssocKind::Fn => self.probe(|_| {
925925
let substs = self.fresh_substs_for_item(self.span, method.def_id);
926926
let fty = self.tcx.fn_sig(method.def_id).subst(self.tcx, substs);
927-
let fty = self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty);
927+
let fty = self.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, fty);
928928

929929
if let Some(self_ty) = self_ty {
930930
if self

compiler/rustc_infer/src/infer/equate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
129129
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
130130
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
131131
if a_types.bound_vars() == b_types.bound_vars() {
132-
let (a_types, b_types) = infcx.replace_bound_vars_with_placeholders(
132+
let (a_types, b_types) = infcx.instantiate_binder_with_placeholders(
133133
a_types.map_bound(|a_types| (a_types, b_types.skip_binder())),
134134
);
135135
for (a, b) in std::iter::zip(a_types, b_types) {

0 commit comments

Comments
 (0)