Skip to content

Commit 39f2657

Browse files
committed
Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous) - #108759 (1.41.1 supported 32-bit Apple targets) - #108839 (Canonicalize root var when making response from new solver) - #108856 (Remove DropAndReplace terminator) - #108882 (Tweak E0740) - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap) - #108911 (Improve rustdoc-gui/tester.js code a bit) - #108916 (Remove an unused return value in `rustc_hir_typeck`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 66a2d62 + a22c5f9 commit 39f2657

File tree

71 files changed

+284
-461
lines changed

Some content is hidden

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

71 files changed

+284
-461
lines changed

Diff for: RELEASES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3861,6 +3861,8 @@ Version 1.41.1 (2020-02-27)
38613861
* [Always check types of static items][69145]
38623862
* [Always check lifetime bounds of `Copy` impls][69145]
38633863
* [Fix miscompilation in callers of `Layout::repeat`][69225]
3864+
* [Rust 1.41.0 was announced as the last Rust release with tier 1 or tier 2 support for 32-bit Apple targets][apple-32bit-drop].
3865+
That announcement did not expect a patch release. 1.41.1 also includes release binaries for these targets.
38643866

38653867
[69225]: https://github.com/rust-lang/rust/issues/69225
38663868
[69145]: https://github.com/rust-lang/rust/pull/69145
@@ -3953,7 +3955,7 @@ Misc
39533955
Compatibility Notes
39543956
-------------------
39553957

3956-
- [As previously announced 1.41.0 will be the last tier 1 release for 32-bit
3958+
- [As previously announced 1.41 will be the last tier 1 release for 32-bit
39573959
Apple targets.][apple-32bit-drop] This means that the source code is still
39583960
available to build, but the targets are no longer being tested and release
39593961
binaries for those platforms will no longer be distributed by the Rust project.

Diff for: compiler/rustc_borrowck/src/invalidation.rs

-9
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
118118
LocalMutationIsAllowed::Yes,
119119
);
120120
}
121-
TerminatorKind::DropAndReplace {
122-
place: drop_place,
123-
value: new_value,
124-
target: _,
125-
unwind: _,
126-
} => {
127-
self.mutate_place(location, *drop_place, Deep);
128-
self.consume_operand(location, new_value);
129-
}
130121
TerminatorKind::Call {
131122
func,
132123
args,

Diff for: compiler/rustc_borrowck/src/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -743,15 +743,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
743743
flow_state,
744744
);
745745
}
746-
TerminatorKind::DropAndReplace {
747-
place: drop_place,
748-
value: new_value,
749-
target: _,
750-
unwind: _,
751-
} => {
752-
self.mutate_place(loc, (*drop_place, span), Deep, flow_state);
753-
self.consume_operand(loc, (new_value, span), flow_state);
754-
}
755746
TerminatorKind::Call {
756747
func,
757748
args,
@@ -866,7 +857,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
866857
| TerminatorKind::Assert { .. }
867858
| TerminatorKind::Call { .. }
868859
| TerminatorKind::Drop { .. }
869-
| TerminatorKind::DropAndReplace { .. }
870860
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
871861
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ }
872862
| TerminatorKind::Goto { .. }

Diff for: compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
435435
//
436436
// What we *actually* generate is a store to a temporary
437437
// for the call (`TMP = call()...`) and then a
438-
// `DropAndReplace` to swap that with `X`
439-
// (`DropAndReplace` has very particular semantics).
438+
// `Drop(X)` followed by `X = TMP` to swap that with `X`.
440439
}
441440
}
442441

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1312,24 +1312,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13121312
// no checks needed for these
13131313
}
13141314

1315-
TerminatorKind::DropAndReplace { place, value, target: _, unwind: _ } => {
1316-
let place_ty = place.ty(body, tcx).ty;
1317-
let rv_ty = value.ty(body, tcx);
1318-
1319-
let locations = term_location.to_locations();
1320-
if let Err(terr) =
1321-
self.sub_types(rv_ty, place_ty, locations, ConstraintCategory::Assignment)
1322-
{
1323-
span_mirbug!(
1324-
self,
1325-
term,
1326-
"bad DropAndReplace ({:?} = {:?}): {:?}",
1327-
place_ty,
1328-
rv_ty,
1329-
terr
1330-
);
1331-
}
1332-
}
13331315
TerminatorKind::SwitchInt { discr, .. } => {
13341316
self.check_operand(discr, term_location);
13351317

@@ -1629,7 +1611,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16291611
}
16301612
TerminatorKind::Unreachable => {}
16311613
TerminatorKind::Drop { target, unwind, .. }
1632-
| TerminatorKind::DropAndReplace { target, unwind, .. }
16331614
| TerminatorKind::Assert { target, cleanup: unwind, .. } => {
16341615
self.assert_iscleanup(body, block_data, target, is_cleanup);
16351616
if let Some(unwind) = unwind {

Diff for: compiler/rustc_borrowck/src/used_muts.rs

-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
7171
TerminatorKind::Call { destination, .. } => {
7272
self.remove_never_initialized_mut_locals(*destination);
7373
}
74-
TerminatorKind::DropAndReplace { place, .. } => {
75-
self.remove_never_initialized_mut_locals(*place);
76-
}
7774
_ => {}
7875
}
7976

Diff for: compiler/rustc_codegen_cranelift/src/base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
499499
TerminatorKind::Yield { .. }
500500
| TerminatorKind::FalseEdge { .. }
501501
| TerminatorKind::FalseUnwind { .. }
502-
| TerminatorKind::DropAndReplace { .. }
503502
| TerminatorKind::GeneratorDrop => {
504503
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
505504
}

Diff for: compiler/rustc_codegen_cranelift/src/constant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
543543
| TerminatorKind::Unreachable
544544
| TerminatorKind::Drop { .. }
545545
| TerminatorKind::Assert { .. } => {}
546-
TerminatorKind::DropAndReplace { .. }
547-
| TerminatorKind::Yield { .. }
546+
TerminatorKind::Yield { .. }
548547
| TerminatorKind::GeneratorDrop
549548
| TerminatorKind::FalseEdge { .. }
550549
| TerminatorKind::FalseUnwind { .. } => unreachable!(),

Diff for: compiler/rustc_codegen_ssa/src/mir/analyze.rs

-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
295295
TerminatorKind::Call { cleanup: unwind, .. }
296296
| TerminatorKind::InlineAsm { cleanup: unwind, .. }
297297
| TerminatorKind::Assert { cleanup: unwind, .. }
298-
| TerminatorKind::DropAndReplace { unwind, .. }
299298
| TerminatorKind::Drop { unwind, .. } => {
300299
if let Some(unwind) = unwind {
301300
debug!(

Diff for: compiler/rustc_codegen_ssa/src/mir/block.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13051305
mergeable_succ(),
13061306
),
13071307

1308-
mir::TerminatorKind::DropAndReplace { .. } => {
1309-
bug!("undesugared DropAndReplace in codegen: {:?}", terminator);
1310-
}
1311-
13121308
mir::TerminatorKind::Call {
13131309
ref func,
13141310
ref args,

Diff for: compiler/rustc_const_eval/src/interpret/terminator.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
171171
Unreachable => throw_ub!(Unreachable),
172172

173173
// These should never occur for MIR we actually run.
174-
DropAndReplace { .. }
175-
| FalseEdge { .. }
176-
| FalseUnwind { .. }
177-
| Yield { .. }
178-
| GeneratorDrop => span_bug!(
174+
FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | GeneratorDrop => span_bug!(
179175
terminator.source_info.span,
180176
"{:#?} should have been eliminated by MIR pass",
181177
terminator.kind

Diff for: compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -985,8 +985,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
985985

986986
// Forbid all `Drop` terminators unless the place being dropped is a local with no
987987
// projections that cannot be `NeedsNonConstDrop`.
988-
TerminatorKind::Drop { place: dropped_place, .. }
989-
| TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
988+
TerminatorKind::Drop { place: dropped_place, .. } => {
990989
// If we are checking live drops after drop-elaboration, don't emit duplicate
991990
// errors here.
992991
if super::post_drop_elaboration::checking_enabled(self.ccx) {

Diff for: compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
8080
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
8181

8282
match &terminator.kind {
83-
mir::TerminatorKind::Drop { place: dropped_place, .. }
84-
| mir::TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
83+
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
8584
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
8685
if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
8786
// Instead of throwing a bug, we just return here. This is because we have to

Diff for: compiler/rustc_const_eval/src/transform/check_consts/resolver.rs

-15
Original file line numberDiff line numberDiff line change
@@ -222,23 +222,8 @@ where
222222
// The effect of assignment to the return place in `TerminatorKind::Call` is not applied
223223
// here; that occurs in `apply_call_return_effect`.
224224

225-
if let mir::TerminatorKind::DropAndReplace { value, place, .. } = &terminator.kind {
226-
let qualif = qualifs::in_operand::<Q, _>(
227-
self.ccx,
228-
&mut |l| self.state.qualif.contains(l),
229-
value,
230-
);
231-
232-
if !place.is_indirect() {
233-
self.assign_qualif_direct(place, qualif);
234-
}
235-
}
236-
237225
// We ignore borrow on drop because custom drop impls are not allowed in consts.
238226
// FIXME: Reconsider if accounting for borrows in drops is necessary for const drop.
239-
240-
// We need to assign qualifs to the dropped location before visiting the operand that
241-
// replaces it since qualifs can be cleared on move.
242227
self.super_terminator(terminator, location);
243228
}
244229
}

Diff for: compiler/rustc_const_eval/src/transform/validate.rs

-12
Original file line numberDiff line numberDiff line change
@@ -846,18 +846,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
846846
self.check_edge(location, *unwind, EdgeKind::Unwind);
847847
}
848848
}
849-
TerminatorKind::DropAndReplace { target, unwind, .. } => {
850-
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) {
851-
self.fail(
852-
location,
853-
"`DropAndReplace` should have been removed during drop elaboration",
854-
);
855-
}
856-
self.check_edge(location, *target, EdgeKind::Normal);
857-
if let Some(unwind) = unwind {
858-
self.check_edge(location, *unwind, EdgeKind::Unwind);
859-
}
860-
}
861849
TerminatorKind::Call { func, args, destination, target, cleanup, .. } => {
862850
let func_ty = func.ty(&self.body.local_decls, self.tcx);
863851
match func_ty.kind() {

Diff for: compiler/rustc_hir_analysis/locales/en-US.ftl

+7
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,10 @@ hir_analysis_pass_to_variadic_function = can't pass `{$ty}` to variadic function
163163
.help = cast the value to `{$cast_ty}`
164164
165165
hir_analysis_cast_thin_pointer_to_fat_pointer = cannot cast thin pointer `{$expr_ty}` to fat pointer `{$cast_ty}`
166+
167+
hir_analysis_invalid_union_field =
168+
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
169+
.note = union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
170+
171+
hir_analysis_invalid_union_field_sugg =
172+
wrap the field type in `ManuallyDrop<...>`

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+11-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::check::intrinsicck::InlineAsmCtxt;
2-
use crate::errors::LinkageType;
2+
use crate::errors::{self, LinkageType};
33

44
use super::compare_impl_item::check_type_bounds;
55
use super::compare_impl_item::{compare_impl_method, compare_impl_ty};
@@ -114,9 +114,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
114114
allowed_union_field(*elem, tcx, param_env)
115115
}
116116
_ => {
117-
// Fallback case: allow `ManuallyDrop` and things that are `Copy`.
117+
// Fallback case: allow `ManuallyDrop` and things that are `Copy`,
118+
// also no need to report an error if the type is unresolved.
118119
ty.ty_adt_def().is_some_and(|adt_def| adt_def.is_manually_drop())
119120
|| ty.is_copy_modulo_regions(tcx, param_env)
121+
|| ty.references_error()
120122
}
121123
}
122124
}
@@ -131,26 +133,14 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
131133
Some(Node::Field(field)) => (field.span, field.ty.span),
132134
_ => unreachable!("mir field has to correspond to hir field"),
133135
};
134-
struct_span_err!(
135-
tcx.sess,
136+
tcx.sess.emit_err(errors::InvalidUnionField {
136137
field_span,
137-
E0740,
138-
"unions cannot contain fields that may need dropping"
139-
)
140-
.note(
141-
"a type is guaranteed not to need dropping \
142-
when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type",
143-
)
144-
.multipart_suggestion_verbose(
145-
"when the type does not implement `Copy`, \
146-
wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped",
147-
vec![
148-
(ty_span.shrink_to_lo(), "std::mem::ManuallyDrop<".into()),
149-
(ty_span.shrink_to_hi(), ">".into()),
150-
],
151-
Applicability::MaybeIncorrect,
152-
)
153-
.emit();
138+
sugg: errors::InvalidUnionFieldSuggestion {
139+
lo: ty_span.shrink_to_lo(),
140+
hi: ty_span.shrink_to_hi(),
141+
},
142+
note: (),
143+
});
154144
return false;
155145
} else if field_ty.needs_drop(tcx, param_env) {
156146
// This should never happen. But we can get here e.g. in case of name resolution errors.

Diff for: compiler/rustc_hir_analysis/src/errors.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::{
55
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
66
MultiSpan,
77
};
8-
use rustc_macros::Diagnostic;
8+
use rustc_macros::{Diagnostic, Subdiagnostic};
99
use rustc_middle::ty::Ty;
1010
use rustc_span::{symbol::Ident, Span, Symbol};
1111

@@ -430,3 +430,23 @@ pub(crate) struct CastThinPointerToFatPointer<'tcx> {
430430
pub expr_ty: Ty<'tcx>,
431431
pub cast_ty: String,
432432
}
433+
434+
#[derive(Diagnostic)]
435+
#[diag(hir_analysis_invalid_union_field, code = "E0740")]
436+
pub(crate) struct InvalidUnionField {
437+
#[primary_span]
438+
pub field_span: Span,
439+
#[subdiagnostic]
440+
pub sugg: InvalidUnionFieldSuggestion,
441+
#[note]
442+
pub note: (),
443+
}
444+
445+
#[derive(Subdiagnostic)]
446+
#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")]
447+
pub(crate) struct InvalidUnionFieldSuggestion {
448+
#[suggestion_part(code = "std::mem::ManuallyDrop<")]
449+
pub lo: Span,
450+
#[suggestion_part(code = ">")]
451+
pub hi: Span,
452+
}

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
301301
span: Span,
302302
def_id: DefId,
303303
substs: SubstsRef<'tcx>,
304-
) -> (ty::InstantiatedPredicates<'tcx>, Vec<Span>) {
304+
) -> ty::InstantiatedPredicates<'tcx> {
305305
let bounds = self.tcx.predicates_of(def_id);
306-
let spans: Vec<Span> = bounds.predicates.iter().map(|(_, span)| *span).collect();
307306
let result = bounds.instantiate(self.tcx, substs);
308307
let result = self.normalize(span, result);
309-
debug!(
310-
"instantiate_bounds(bounds={:?}, substs={:?}) = {:?}, {:?}",
311-
bounds, substs, result, spans,
312-
);
313-
(result, spans)
308+
debug!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}", bounds, substs, result);
309+
result
314310
}
315311

316312
pub(in super::super) fn normalize<T>(&self, span: Span, value: T) -> T
@@ -1389,7 +1385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13891385
}
13901386
_ => false,
13911387
};
1392-
let (bounds, _) = self.instantiate_bounds(span, def_id, &substs);
1388+
let bounds = self.instantiate_bounds(span, def_id, &substs);
13931389

13941390
for mut obligation in traits::predicates_for_generics(
13951391
|idx, predicate_span| {

Diff for: compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+22-4
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,18 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
374374
}
375375
}
376376

377-
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
377+
fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> {
378378
match *t.kind() {
379-
ty::Infer(ty::TyVar(vid)) => {
379+
ty::Infer(ty::TyVar(mut vid)) => {
380+
// We need to canonicalize the *root* of our ty var.
381+
// This is so that our canonical response correctly reflects
382+
// any equated inference vars correctly!
383+
let root_vid = self.infcx.root_var(vid);
384+
if root_vid != vid {
385+
t = self.infcx.tcx.mk_ty_var(root_vid);
386+
vid = root_vid;
387+
}
388+
380389
debug!("canonical: type var found with vid {:?}", vid);
381390
match self.infcx.probe_ty_var(vid) {
382391
// `t` could be a float / int variable; canonicalize that instead.
@@ -467,9 +476,18 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
467476
}
468477
}
469478

470-
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
479+
fn fold_const(&mut self, mut ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
471480
match ct.kind() {
472-
ty::ConstKind::Infer(InferConst::Var(vid)) => {
481+
ty::ConstKind::Infer(InferConst::Var(mut vid)) => {
482+
// We need to canonicalize the *root* of our const var.
483+
// This is so that our canonical response correctly reflects
484+
// any equated inference vars correctly!
485+
let root_vid = self.infcx.root_const_var(vid);
486+
if root_vid != vid {
487+
ct = self.infcx.tcx.mk_const(ty::InferConst::Var(root_vid), ct.ty());
488+
vid = root_vid;
489+
}
490+
473491
debug!("canonical: const var found with vid {:?}", vid);
474492
match self.infcx.probe_const_var(vid) {
475493
Ok(c) => {

0 commit comments

Comments
 (0)