about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-28 18:04:53 +0000
committerbors <bors@rust-lang.org>2023-05-28 18:04:53 +0000
commit1c53407e8c7cc922d718bde61ca34f47b6d2120f (patch)
treecb51d4703b9467f6794bdee1a94df3909c2017b1 /compiler/rustc_monomorphize/src
parent3fae1b9fc35fc449186e2138bdf8ee75dac78dae (diff)
parentc29c212f8dc80e40f099b6dbc9da3111177ba7bf (diff)
downloadrust-1c53407e8c7cc922d718bde61ca34f47b6d2120f.tar.gz
rust-1c53407e8c7cc922d718bde61ca34f47b6d2120f.zip
Auto merge of #112006 - kylematsuda:earlybinder-private, r=jackh726
Make `EarlyBinder`'s inner value private

Currently, `EarlyBinder(T)`'s inner value is public, which allows implicitly skipping the binder by indexing into the tuple struct (i.e., `x.0`). `@lcnr` suggested making `EarlyBinder`'s inner value private so users are required to explicitly call `skip_binder` (https://github.com/rust-lang/rust/issues/105779#issuecomment-1549933424) .

This PR makes the inner value private, adds `EarlyBinder::new` for constructing a new instance, and replaces uses of `x.0` with `x.skip_binder()` (or similar). It also adds some documentation to `EarlyBinder::skip_binder` explaining how to skip the binder of `&EarlyBinder<T>` to get `&T` now that the inner value is private (since previously we could just do `&x.0`).

r? `@lcnr`
Diffstat (limited to 'compiler/rustc_monomorphize/src')
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs2
-rw-r--r--compiler/rustc_monomorphize/src/util.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index 35b154b7b34..8874aa7d3ca 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -677,7 +677,7 @@ impl<'a, 'tcx> MirNeighborCollector<'a, 'tcx> {
         self.instance.subst_mir_and_normalize_erasing_regions(
             self.tcx,
             ty::ParamEnv::reveal_all(),
-            ty::EarlyBinder(value),
+            ty::EarlyBinder::new(value),
         )
     }
 }
diff --git a/compiler/rustc_monomorphize/src/util.rs b/compiler/rustc_monomorphize/src/util.rs
index d12bfc6f6bb..772f1520153 100644
--- a/compiler/rustc_monomorphize/src/util.rs
+++ b/compiler/rustc_monomorphize/src/util.rs
@@ -29,12 +29,12 @@ pub(crate) fn dump_closure_profile<'tcx>(tcx: TyCtxt<'tcx>, closure_instance: In
         let before_feature_tys = tcx.subst_and_normalize_erasing_regions(
             closure_instance.substs,
             param_env,
-            ty::EarlyBinder(before_feature_tys),
+            ty::EarlyBinder::new(before_feature_tys),
         );
         let after_feature_tys = tcx.subst_and_normalize_erasing_regions(
             closure_instance.substs,
             param_env,
-            ty::EarlyBinder(after_feature_tys),
+            ty::EarlyBinder::new(after_feature_tys),
         );
 
         let new_size = tcx