Skip to content

Commit f2b449c

Browse files
committed
Auto merge of rust-lang#126710 - jieyouxu:rollup-3hmke71, r=jieyouxu
Rollup of 7 pull requests Successful merges: - rust-lang#124807 (Migrate `run-make/rustdoc-io-error` to `rmake.rs`) - rust-lang#126095 (Migrate `link-args-order`, `ls-metadata` and `lto-readonly-lib` `run-make` tests to `rmake`) - rust-lang#126308 (Ban `ArrayToPointer` and `MutToConstPointer` from runtime MIR) - rust-lang#126620 (Actually taint InferCtxt when a fulfillment error is emitted) - rust-lang#126629 (Migrate `run-make/compressed-debuginfo` to `rmake.rs`) - rust-lang#126644 (Rewrite `extern-flag-rename-transitive`. `debugger-visualizer-dep-info`, `metadata-flag-frobs-symbols`, `extern-overrides-distribution` and `forced-unwind-terminate-pof` `run-make` tests to rmake) - rust-lang#126650 (Rename a bunch of things in the new solver and `rustc_type_ir`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d8a38b0 + 5d6bebd commit f2b449c

File tree

145 files changed

+1435
-970
lines changed

Some content is hidden

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

145 files changed

+1435
-970
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11101110
tcx: TyCtxt<'tcx>,
11111111
}
11121112
impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for OpaqueFolder<'tcx> {
1113-
fn interner(&self) -> TyCtxt<'tcx> {
1113+
fn cx(&self) -> TyCtxt<'tcx> {
11141114
self.tcx
11151115
}
11161116
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_codegen_cranelift/src/base.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -677,21 +677,22 @@ fn codegen_stmt<'tcx>(
677677
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
678678
ref operand,
679679
to_ty,
680-
)
681-
| Rvalue::Cast(
682-
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer),
683-
ref operand,
684-
to_ty,
685-
)
686-
| Rvalue::Cast(
687-
CastKind::PointerCoercion(PointerCoercion::ArrayToPointer),
688-
ref operand,
689-
to_ty,
690680
) => {
691681
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
692682
let operand = codegen_operand(fx, operand);
693683
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
694684
}
685+
Rvalue::Cast(
686+
CastKind::PointerCoercion(
687+
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
688+
),
689+
..,
690+
) => {
691+
bug!(
692+
"{:?} is for borrowck, and should never appear in codegen",
693+
to_place_and_rval.1
694+
);
695+
}
695696
Rvalue::Cast(
696697
CastKind::IntToInt
697698
| CastKind::FloatToFloat

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
456456
base::unsize_ptr(bx, lldata, operand.layout.ty, cast.ty, llextra);
457457
OperandValue::Pair(lldata, llextra)
458458
}
459-
mir::CastKind::PointerCoercion(PointerCoercion::MutToConstPointer)
460-
| mir::CastKind::PtrToPtr
459+
mir::CastKind::PointerCoercion(
460+
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
461+
) => {
462+
bug!("{kind:?} is for borrowck, and should never appear in codegen");
463+
}
464+
mir::CastKind::PtrToPtr
461465
if bx.cx().is_backend_scalar_pair(operand.layout) =>
462466
{
463467
if let OperandValue::Pair(data_ptr, meta) = operand.val {
@@ -477,9 +481,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
477481
base::cast_to_dyn_star(bx, lldata, operand.layout, cast.ty, llextra);
478482
OperandValue::Pair(lldata, llextra)
479483
}
480-
mir::CastKind::PointerCoercion(
481-
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
482-
)
483484
| mir::CastKind::IntToInt
484485
| mir::CastKind::FloatToInt
485486
| mir::CastKind::FloatToFloat

compiler/rustc_const_eval/src/interpret/cast.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
7070
CastKind::PointerCoercion(
7171
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
7272
) => {
73-
// These are NOPs, but can be wide pointers.
74-
let v = self.read_immediate(src)?;
75-
self.write_immediate(*v, dest)?;
73+
bug!("{cast_kind:?} casts are for borrowck only, not runtime MIR");
7674
}
7775

7876
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ struct RemapLateBound<'a, 'tcx> {
397397
}
398398

399399
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
400-
fn interner(&self) -> TyCtxt<'tcx> {
400+
fn cx(&self) -> TyCtxt<'tcx> {
401401
self.tcx
402402
}
403403

@@ -790,13 +790,13 @@ impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E
790790
where
791791
E: 'tcx,
792792
{
793-
fn interner(&self) -> TyCtxt<'tcx> {
793+
fn cx(&self) -> TyCtxt<'tcx> {
794794
self.ocx.infcx.tcx
795795
}
796796

797797
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
798798
if let ty::Alias(ty::Projection, proj) = ty.kind()
799-
&& self.interner().is_impl_trait_in_trait(proj.def_id)
799+
&& self.cx().is_impl_trait_in_trait(proj.def_id)
800800
{
801801
if let Some((ty, _)) = self.types.get(&proj.def_id) {
802802
return *ty;
@@ -810,9 +810,9 @@ where
810810
self.types.insert(proj.def_id, (infer_ty, proj.args));
811811
// Recurse into bounds
812812
for (pred, pred_span) in self
813-
.interner()
813+
.cx()
814814
.explicit_item_bounds(proj.def_id)
815-
.iter_instantiated_copied(self.interner(), proj.args)
815+
.iter_instantiated_copied(self.cx(), proj.args)
816816
{
817817
let pred = pred.fold_with(self);
818818
let pred = self.ocx.normalize(
@@ -822,7 +822,7 @@ where
822822
);
823823

824824
self.ocx.register_obligation(traits::Obligation::new(
825-
self.interner(),
825+
self.cx(),
826826
ObligationCause::new(
827827
self.span,
828828
self.body_id,
@@ -853,7 +853,7 @@ struct RemapHiddenTyRegions<'tcx> {
853853
impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
854854
type Error = ErrorGuaranteed;
855855

856-
fn interner(&self) -> TyCtxt<'tcx> {
856+
fn cx(&self) -> TyCtxt<'tcx> {
857857
self.tcx
858858
}
859859

@@ -2072,7 +2072,7 @@ struct ReplaceTy<'tcx> {
20722072
}
20732073

20742074
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceTy<'tcx> {
2075-
fn interner(&self) -> TyCtxt<'tcx> {
2075+
fn cx(&self) -> TyCtxt<'tcx> {
20762076
self.tcx
20772077
}
20782078

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ struct Anonymize<'tcx> {
322322
}
323323

324324
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
325-
fn interner(&self) -> TyCtxt<'tcx> {
325+
fn cx(&self) -> TyCtxt<'tcx> {
326326
self.tcx
327327
}
328328

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,7 @@ where
119119

120120
let errors = wfcx.select_all_or_error();
121121
if !errors.is_empty() {
122-
let err = infcx.err_ctxt().report_fulfillment_errors(errors);
123-
if tcx.dcx().has_errors().is_some() {
124-
return Err(err);
125-
} else {
126-
// HACK(oli-obk): tests/ui/specialization/min_specialization/specialize_on_type_error.rs
127-
// causes an delayed bug during normalization, without reporting an error, so we need
128-
// to act as if no error happened, in order to let our callers continue and report an
129-
// error later in check_impl_items_against_trait.
130-
return Ok(());
131-
}
122+
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
132123
}
133124

134125
debug!(?assumed_wf_types);

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ struct TyVarReplacer<'cx, 'tcx> {
539539
}
540540

541541
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for TyVarReplacer<'cx, 'tcx> {
542-
fn interner(&self) -> TyCtxt<'tcx> {
542+
fn cx(&self) -> TyCtxt<'tcx> {
543543
self.infcx.tcx
544544
}
545545

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct AssocTyToOpaque<'tcx> {
203203
}
204204

205205
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx> {
206-
fn interner(&self) -> TyCtxt<'tcx> {
206+
fn cx(&self) -> TyCtxt<'tcx> {
207207
self.tcx
208208
}
209209

compiler/rustc_hir_typeck/src/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
793793
}
794794

795795
fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
796-
if let Some(guar) = self.fcx.dcx().has_errors() {
796+
if let Some(guar) = self.fcx.tainted_by_errors() {
797797
guar
798798
} else {
799799
self.fcx
@@ -847,7 +847,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
847847
}
848848

849849
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
850-
fn interner(&self) -> TyCtxt<'tcx> {
850+
fn cx(&self) -> TyCtxt<'tcx> {
851851
self.fcx.tcx
852852
}
853853

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct Canonicalizer<'cx, 'tcx> {
304304
}
305305

306306
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
307-
fn interner(&self) -> TyCtxt<'tcx> {
307+
fn cx(&self) -> TyCtxt<'tcx> {
308308
self.tcx
309309
}
310310

@@ -773,7 +773,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
773773
) -> ty::Region<'tcx> {
774774
let var = self.canonical_var(info, r.into());
775775
let br = ty::BoundRegion { var, kind: ty::BrAnon };
776-
ty::Region::new_bound(self.interner(), self.binder_index, br)
776+
ty::Region::new_bound(self.cx(), self.binder_index, br)
777777
}
778778

779779
/// Given a type variable `ty_var` of the given kind, first check

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct ClosureEraser<'tcx> {
158158
}
159159

160160
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx> {
161-
fn interner(&self) -> TyCtxt<'tcx> {
161+
fn cx(&self) -> TyCtxt<'tcx> {
162162
self.tcx
163163
}
164164

compiler/rustc_infer/src/infer/freshen.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
100100
}
101101

102102
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
103-
fn interner(&self) -> TyCtxt<'tcx> {
103+
fn cx(&self) -> TyCtxt<'tcx> {
104104
self.infcx.tcx
105105
}
106106

@@ -117,7 +117,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
117117
| ty::RePlaceholder(..)
118118
| ty::ReStatic
119119
| ty::ReError(_)
120-
| ty::ReErased => self.interner().lifetimes.re_erased,
120+
| ty::ReErased => self.cx().lifetimes.re_erased,
121121
}
122122
}
123123

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ struct InferenceLiteralEraser<'tcx> {
17191719
}
17201720

17211721
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
1722-
fn interner(&self) -> TyCtxt<'tcx> {
1722+
fn cx(&self) -> TyCtxt<'tcx> {
17231723
self.tcx
17241724
}
17251725

@@ -1859,7 +1859,7 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
18591859
}
18601860

18611861
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
1862-
fn interner(&self) -> TyCtxt<'tcx> {
1862+
fn cx(&self) -> TyCtxt<'tcx> {
18631863
self.tcx
18641864
}
18651865

compiler/rustc_infer/src/infer/resolve.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
2424
}
2525

2626
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
27-
fn interner(&self) -> TyCtxt<'tcx> {
27+
fn cx(&self) -> TyCtxt<'tcx> {
2828
self.infcx.tcx
2929
}
3030

@@ -66,7 +66,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
6666
}
6767

6868
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
69-
fn interner(&self) -> TyCtxt<'tcx> {
69+
fn cx(&self) -> TyCtxt<'tcx> {
7070
self.infcx.tcx
7171
}
7272

@@ -85,7 +85,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
8585
.inner
8686
.borrow_mut()
8787
.unwrap_region_constraints()
88-
.opportunistic_resolve_var(TypeFolder::interner(self), vid),
88+
.opportunistic_resolve_var(TypeFolder::cx(self), vid),
8989
_ => r,
9090
}
9191
}
@@ -121,7 +121,7 @@ struct FullTypeResolver<'a, 'tcx> {
121121
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
122122
type Error = FixupError;
123123

124-
fn interner(&self) -> TyCtxt<'tcx> {
124+
fn cx(&self) -> TyCtxt<'tcx> {
125125
self.infcx.tcx
126126
}
127127

compiler/rustc_infer/src/infer/snapshot/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub struct InferenceFudger<'a, 'tcx> {
183183
}
184184

185185
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
186-
fn interner(&self) -> TyCtxt<'tcx> {
186+
fn cx(&self) -> TyCtxt<'tcx> {
187187
self.infcx.tcx
188188
}
189189

compiler/rustc_lint/src/non_local_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ struct ReplaceLocalTypesWithInfer<'a, 'tcx, F: FnMut(DefId) -> bool> {
390390
impl<'a, 'tcx, F: FnMut(DefId) -> bool> TypeFolder<TyCtxt<'tcx>>
391391
for ReplaceLocalTypesWithInfer<'a, 'tcx, F>
392392
{
393-
fn interner(&self) -> TyCtxt<'tcx> {
393+
fn cx(&self) -> TyCtxt<'tcx> {
394394
self.infcx.tcx
395395
}
396396

compiler/rustc_middle/src/mir/syntax.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ pub enum AnalysisPhase {
127127
/// * [`StatementKind::AscribeUserType`]
128128
/// * [`StatementKind::Coverage`] with [`CoverageKind::BlockMarker`] or [`CoverageKind::SpanMarker`]
129129
/// * [`Rvalue::Ref`] with `BorrowKind::Fake`
130+
/// * [`CastKind::PointerCoercion`] with any of the following:
131+
/// * [`PointerCoercion::ArrayToPointer`]
132+
/// * [`PointerCoercion::MutToConstPointer`]
130133
///
131134
/// Furthermore, `Deref` projections must be the first projection within any place (if they
132135
/// appear at all)
@@ -1284,8 +1287,7 @@ pub enum Rvalue<'tcx> {
12841287
///
12851288
/// This allows for casts from/to a variety of types.
12861289
///
1287-
/// **FIXME**: Document exactly which `CastKind`s allow which types of casts. Figure out why
1288-
/// `ArrayToPointer` and `MutToConstPointer` are special.
1290+
/// **FIXME**: Document exactly which `CastKind`s allow which types of casts.
12891291
Cast(CastKind, Operand<'tcx>, Ty<'tcx>),
12901292

12911293
/// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
@@ -1365,6 +1367,13 @@ pub enum CastKind {
13651367
PointerWithExposedProvenance,
13661368
/// Pointer related casts that are done by coercions. Note that reference-to-raw-ptr casts are
13671369
/// translated into `&raw mut/const *r`, i.e., they are not actually casts.
1370+
///
1371+
/// The following are allowed in [`AnalysisPhase::Initial`] as they're needed for borrowck,
1372+
/// but after that are forbidden (including in all phases of runtime MIR):
1373+
/// * [`PointerCoercion::ArrayToPointer`]
1374+
/// * [`PointerCoercion::MutToConstPointer`]
1375+
///
1376+
/// Both are runtime nops, so should be [`CastKind::PtrToPtr`] instead in runtime MIR.
13681377
PointerCoercion(PointerCoercion),
13691378
/// Cast into a dyn* object.
13701379
DynStar,

0 commit comments

Comments
 (0)