Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75f4ee8

Browse files
committedDec 22, 2022
Auto merge of rust-lang#106025 - matthiaskrgr:rollup-vz5rqah, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#105837 (Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity) - rust-lang#105932 (Correct branch-protection ModFlagBehavior for Aarch64 on LLVM-15) - rust-lang#105960 (Various cleanups) - rust-lang#105985 (Method chain nitpicks) - rust-lang#105996 (Test that async blocks are `UnwindSafe`) - rust-lang#106012 (Clarify that raw retags are not permitted in Mir) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8574880 + d0d0ccd commit 75f4ee8

File tree

24 files changed

+181
-99
lines changed

24 files changed

+181
-99
lines changed
 

‎compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,29 +280,35 @@ pub unsafe fn create_module<'ll>(
280280
}
281281

282282
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
283+
let behavior = if llvm_version >= (15, 0, 0) {
284+
llvm::LLVMModFlagBehavior::Min
285+
} else {
286+
llvm::LLVMModFlagBehavior::Error
287+
};
288+
283289
if sess.target.arch == "aarch64" {
284290
llvm::LLVMRustAddModuleFlag(
285291
llmod,
286-
llvm::LLVMModFlagBehavior::Error,
292+
behavior,
287293
"branch-target-enforcement\0".as_ptr().cast(),
288294
bti.into(),
289295
);
290296
llvm::LLVMRustAddModuleFlag(
291297
llmod,
292-
llvm::LLVMModFlagBehavior::Error,
298+
behavior,
293299
"sign-return-address\0".as_ptr().cast(),
294300
pac_ret.is_some().into(),
295301
);
296302
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
297303
llvm::LLVMRustAddModuleFlag(
298304
llmod,
299-
llvm::LLVMModFlagBehavior::Error,
305+
behavior,
300306
"sign-return-address-all\0".as_ptr().cast(),
301307
pac_opts.leaf.into(),
302308
);
303309
llvm::LLVMRustAddModuleFlag(
304310
llmod,
305-
llvm::LLVMModFlagBehavior::Error,
311+
behavior,
306312
"sign-return-address-with-bkey\0".as_ptr().cast(),
307313
u32::from(pac_opts.key == PAuthKey::B),
308314
);

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub enum LLVMModFlagBehavior {
7979
Append = 5,
8080
AppendUnique = 6,
8181
Max = 7,
82+
Min = 8,
8283
}
8384

8485
// Consts for the LLVM CallConv type, pre-cast to usize.

‎compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_middle::mir::visit::{PlaceContext, Visitor};
99
use rustc_middle::mir::{
1010
traversal, AggregateKind, BasicBlock, BinOp, Body, BorrowKind, CastKind, CopyNonOverlapping,
1111
Local, Location, MirPass, MirPhase, NonDivergingIntrinsic, Operand, Place, PlaceElem, PlaceRef,
12-
ProjectionElem, RuntimePhase, Rvalue, SourceScope, Statement, StatementKind, Terminator,
13-
TerminatorKind, UnOp, START_BLOCK,
12+
ProjectionElem, RetagKind, RuntimePhase, Rvalue, SourceScope, Statement, StatementKind,
13+
Terminator, TerminatorKind, UnOp, START_BLOCK,
1414
};
1515
use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitable};
1616
use rustc_mir_dataflow::impls::MaybeStorageLive;
@@ -667,10 +667,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
667667
self.fail(location, "`Deinit`is not allowed until deaggregation");
668668
}
669669
}
670-
StatementKind::Retag(_, _) => {
670+
StatementKind::Retag(kind, _) => {
671671
// FIXME(JakobDegen) The validator should check that `self.mir_phase <
672672
// DropsLowered`. However, this causes ICEs with generation of drop shims, which
673673
// seem to fail to set their `MirPhase` correctly.
674+
if *kind == RetagKind::Raw || *kind == RetagKind::TwoPhase {
675+
self.fail(location, format!("explicit `{:?}` is forbidden", kind));
676+
}
674677
}
675678
StatementKind::StorageLive(..)
676679
| StatementKind::StorageDead(..)

‎compiler/rustc_hir_typeck/src/generator_interior/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,7 @@ fn check_must_not_suspend_ty<'tcx>(
607607
ty::Tuple(fields) => {
608608
let mut has_emitted = false;
609609
let comps = match data.expr.map(|e| &e.kind) {
610-
Some(hir::ExprKind::Tup(comps)) => {
611-
debug_assert_eq!(comps.len(), fields.len());
612-
Some(comps)
613-
}
610+
Some(hir::ExprKind::Tup(comps)) if comps.len() == fields.len() => Some(comps),
614611
_ => None,
615612
};
616613
for (i, ty) in fields.iter().enumerate() {

‎compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ impl<'hir> Map<'hir> {
170170
}
171171

172172
#[inline]
173+
#[track_caller]
173174
pub fn local_def_id(self, hir_id: HirId) -> LocalDefId {
174175
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
175176
bug!(
@@ -310,6 +311,7 @@ impl<'hir> Map<'hir> {
310311
}
311312
}
312313

314+
#[track_caller]
313315
pub fn get_parent_node(self, hir_id: HirId) -> HirId {
314316
self.find_parent_node(hir_id)
315317
.unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id)))
@@ -334,12 +336,14 @@ impl<'hir> Map<'hir> {
334336
}
335337

336338
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
339+
#[track_caller]
337340
pub fn get(self, id: HirId) -> Node<'hir> {
338341
self.find(id).unwrap_or_else(|| bug!("couldn't find hir id {} in the HIR map", id))
339342
}
340343

341344
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
342345
#[inline]
346+
#[track_caller]
343347
pub fn get_by_def_id(self, id: LocalDefId) -> Node<'hir> {
344348
self.find_by_def_id(id).unwrap_or_else(|| bug!("couldn't find {:?} in the HIR map", id))
345349
}
@@ -377,6 +381,7 @@ impl<'hir> Map<'hir> {
377381
self.tcx.hir_owner_nodes(id.hir_id.owner).unwrap().bodies[&id.hir_id.local_id]
378382
}
379383

384+
#[track_caller]
380385
pub fn fn_decl_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
381386
if let Some(node) = self.find(hir_id) {
382387
node.fn_decl()
@@ -385,6 +390,7 @@ impl<'hir> Map<'hir> {
385390
}
386391
}
387392

393+
#[track_caller]
388394
pub fn fn_sig_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
389395
if let Some(node) = self.find(hir_id) {
390396
node.fn_sig()
@@ -393,6 +399,7 @@ impl<'hir> Map<'hir> {
393399
}
394400
}
395401

402+
#[track_caller]
396403
pub fn enclosing_body_owner(self, hir_id: HirId) -> LocalDefId {
397404
for (_, node) in self.parent_iter(hir_id) {
398405
if let Some(body) = associated_body(node) {
@@ -408,7 +415,7 @@ impl<'hir> Map<'hir> {
408415
/// item (possibly associated), a closure, or a `hir::AnonConst`.
409416
pub fn body_owner(self, BodyId { hir_id }: BodyId) -> HirId {
410417
let parent = self.get_parent_node(hir_id);
411-
assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)));
418+
assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)), "{hir_id:?}");
412419
parent
413420
}
414421

@@ -419,10 +426,11 @@ impl<'hir> Map<'hir> {
419426
/// Given a `LocalDefId`, returns the `BodyId` associated with it,
420427
/// if the node is a body owner, otherwise returns `None`.
421428
pub fn maybe_body_owned_by(self, id: LocalDefId) -> Option<BodyId> {
422-
self.get_if_local(id.to_def_id()).map(associated_body).flatten()
429+
self.find_by_def_id(id).and_then(associated_body)
423430
}
424431

425432
/// Given a body owner's id, returns the `BodyId` associated with it.
433+
#[track_caller]
426434
pub fn body_owned_by(self, id: LocalDefId) -> BodyId {
427435
self.maybe_body_owned_by(id).unwrap_or_else(|| {
428436
let hir_id = self.local_def_id_to_hir_id(id);

‎compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ pub enum StatementKind<'tcx> {
320320
/// <https://internals.rust-lang.org/t/stacked-borrows-an-aliasing-model-for-rust/8153/> for
321321
/// more details.
322322
///
323-
/// For code that is not specific to stacked borrows, you should consider retags to read
324-
/// and modify the place in an opaque way.
323+
/// For code that is not specific to stacked borrows, you should consider retags to read and
324+
/// modify the place in an opaque way.
325+
///
326+
/// Only `RetagKind::Default` and `RetagKind::FnEntry` are permitted.
325327
Retag(RetagKind, Box<Place<'tcx>>),
326328

327329
/// Encodes a user's type ascription. These need to be preserved

‎compiler/rustc_middle/src/ty/generics.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ impl GenericParamDef {
7070
}
7171
}
7272

73-
pub fn has_default(&self) -> bool {
74-
match self.kind {
75-
GenericParamDefKind::Type { has_default, .. }
76-
| GenericParamDefKind::Const { has_default } => has_default,
77-
GenericParamDefKind::Lifetime => false,
78-
}
79-
}
80-
8173
pub fn is_anonymous_lifetime(&self) -> bool {
8274
match self.kind {
8375
GenericParamDefKind::Lifetime => {

‎compiler/rustc_middle/src/ty/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'tcx> InternalSubsts<'tcx> {
348348
substs.reserve(defs.params.len());
349349
for param in &defs.params {
350350
let kind = mk_kind(param, substs);
351-
assert_eq!(param.index as usize, substs.len());
351+
assert_eq!(param.index as usize, substs.len(), "{substs:#?}, {defs:#?}");
352352
substs.push(kind);
353353
}
354354
}

‎compiler/rustc_middle/src/ty/visit.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
8888
self.has_vars_bound_at_or_above(ty::INNERMOST)
8989
}
9090

91-
#[instrument(level = "trace", ret)]
9291
fn has_type_flags(&self, flags: TypeFlags) -> bool {
93-
self.visit_with(&mut HasTypeFlagsVisitor { flags }).break_value() == Some(FoundFlags)
92+
let res =
93+
self.visit_with(&mut HasTypeFlagsVisitor { flags }).break_value() == Some(FoundFlags);
94+
trace!(?self, ?flags, ?res, "has_type_flags");
95+
res
9496
}
9597
fn has_projections(&self) -> bool {
9698
self.has_type_flags(TypeFlags::HAS_PROJECTION)
@@ -560,10 +562,8 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
560562
type BreakTy = FoundFlags;
561563

562564
#[inline]
563-
#[instrument(skip(self), level = "trace", ret)]
564565
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
565566
let flags = t.flags();
566-
trace!(t.flags=?t.flags());
567567
if flags.intersects(self.flags) {
568568
ControlFlow::Break(FoundFlags)
569569
} else {
@@ -572,10 +572,8 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
572572
}
573573

574574
#[inline]
575-
#[instrument(skip(self), level = "trace", ret)]
576575
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
577576
let flags = r.type_flags();
578-
trace!(r.flags=?flags);
579577
if flags.intersects(self.flags) {
580578
ControlFlow::Break(FoundFlags)
581579
} else {
@@ -584,7 +582,6 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
584582
}
585583

586584
#[inline]
587-
#[instrument(level = "trace", ret)]
588585
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
589586
let flags = FlagComputation::for_const(c);
590587
trace!(r.flags=?flags);
@@ -596,14 +593,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
596593
}
597594

598595
#[inline]
599-
#[instrument(level = "trace", ret)]
600596
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
601-
debug!(
602-
"HasTypeFlagsVisitor: predicate={:?} predicate.flags={:?} self.flags={:?}",
603-
predicate,
604-
predicate.flags(),
605-
self.flags
606-
);
607597
if predicate.flags().intersects(self.flags) {
608598
ControlFlow::Break(FoundFlags)
609599
} else {

‎compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
1515
@call("mir_retag", args) => {
1616
Ok(StatementKind::Retag(RetagKind::Default, Box::new(self.parse_place(args[0])?)))
1717
},
18-
@call("mir_retag_raw", args) => {
19-
Ok(StatementKind::Retag(RetagKind::Raw, Box::new(self.parse_place(args[0])?)))
20-
},
2118
@call("mir_set_discriminant", args) => {
2219
let place = self.parse_place(args[0])?;
2320
let var = self.parse_integer_literal(args[1])? as u32;

‎compiler/rustc_trait_selection/src/traits/error_reporting/method_chain.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
1414
fn tag(&self) -> &'static str {
1515
"CollectAllMismatches"
1616
}
17+
1718
fn tcx(&self) -> TyCtxt<'tcx> {
1819
self.infcx.tcx
1920
}
21+
2022
fn intercrate(&self) -> bool {
2123
false
2224
}
25+
2326
fn param_env(&self) -> ty::ParamEnv<'tcx> {
2427
self.param_env
2528
}
29+
2630
fn a_is_expected(&self) -> bool {
2731
true
28-
} // irrelevant
32+
}
33+
2934
fn mark_ambiguous(&mut self) {
3035
bug!()
3136
}
37+
3238
fn relate_with_variance<T: Relate<'tcx>>(
3339
&mut self,
3440
_: ty::Variance,
@@ -38,22 +44,28 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
3844
) -> RelateResult<'tcx, T> {
3945
self.relate(a, b)
4046
}
47+
4148
fn regions(
4249
&mut self,
4350
a: ty::Region<'tcx>,
4451
_b: ty::Region<'tcx>,
4552
) -> RelateResult<'tcx, ty::Region<'tcx>> {
4653
Ok(a)
4754
}
55+
4856
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
49-
if a == b || matches!(a.kind(), ty::Infer(_)) || matches!(b.kind(), ty::Infer(_)) {
50-
return Ok(a);
51-
}
52-
relate::super_relate_tys(self, a, b).or_else(|e| {
53-
self.errors.push(e);
54-
Ok(a)
57+
self.infcx.probe(|_| {
58+
if a.is_ty_infer() || b.is_ty_infer() {
59+
Ok(a)
60+
} else {
61+
self.infcx.super_combine_tys(self, a, b).or_else(|e| {
62+
self.errors.push(e);
63+
Ok(a)
64+
})
65+
}
5566
})
5667
}
68+
5769
fn consts(
5870
&mut self,
5971
a: ty::Const<'tcx>,
@@ -64,6 +76,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
6476
}
6577
relate::super_relate_consts(self, a, b) // could do something similar here for constants!
6678
}
79+
6780
fn binders<T: Relate<'tcx>>(
6881
&mut self,
6982
a: ty::Binder<'tcx, T>,

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub trait TypeErrCtxtExt<'tcx> {
335335
err: &mut Diagnostic,
336336
trait_pred: ty::PolyTraitPredicate<'tcx>,
337337
);
338-
fn function_argument_obligation(
338+
fn note_function_argument_obligation(
339339
&self,
340340
arg_hir_id: HirId,
341341
err: &mut Diagnostic,
@@ -2909,7 +2909,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29092909
ref parent_code,
29102910
..
29112911
} => {
2912-
self.function_argument_obligation(
2912+
self.note_function_argument_obligation(
29132913
arg_hir_id,
29142914
err,
29152915
parent_code,
@@ -3141,23 +3141,20 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31413141
);
31423142
}
31433143
}
3144-
fn function_argument_obligation(
3144+
fn note_function_argument_obligation(
31453145
&self,
31463146
arg_hir_id: HirId,
31473147
err: &mut Diagnostic,
31483148
parent_code: &ObligationCauseCode<'tcx>,
31493149
param_env: ty::ParamEnv<'tcx>,
3150-
predicate: ty::Predicate<'tcx>,
3150+
failed_pred: ty::Predicate<'tcx>,
31513151
call_hir_id: HirId,
31523152
) {
31533153
let tcx = self.tcx;
31543154
let hir = tcx.hir();
3155-
if let Some(Node::Expr(expr)) = hir.find(arg_hir_id) {
3156-
let parent_id = hir.get_parent_item(arg_hir_id);
3157-
let typeck_results: &TypeckResults<'tcx> = match &self.typeck_results {
3158-
Some(t) if t.hir_owner == parent_id => t,
3159-
_ => self.tcx.typeck(parent_id.def_id),
3160-
};
3155+
if let Some(Node::Expr(expr)) = hir.find(arg_hir_id)
3156+
&& let Some(typeck_results) = &self.typeck_results
3157+
{
31613158
if let hir::Expr { kind: hir::ExprKind::Block(..), .. } = expr {
31623159
let expr = expr.peel_blocks();
31633160
let ty = typeck_results.expr_ty_adjusted_opt(expr).unwrap_or(tcx.ty_error());
@@ -3182,37 +3179,29 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31823179
let mut type_diffs = vec![];
31833180

31843181
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
3185-
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
3186-
&& let Some(pred) = predicates.predicates.get(*idx)
3182+
&& let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id)
3183+
&& let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs)
3184+
&& let Some(where_pred) = where_clauses.predicates.get(*idx)
31873185
{
3188-
if let Ok(trait_pred) = pred.kind().try_map_bound(|pred| match pred {
3189-
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => Ok(trait_pred),
3190-
_ => Err(()),
3191-
})
3192-
&& let Ok(trait_predicate) = predicate.kind().try_map_bound(|pred| match pred {
3193-
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => Ok(trait_pred),
3194-
_ => Err(()),
3195-
})
3186+
if let Some(where_pred) = where_pred.to_opt_poly_trait_pred()
3187+
&& let Some(failed_pred) = failed_pred.to_opt_poly_trait_pred()
31963188
{
31973189
let mut c = CollectAllMismatches {
31983190
infcx: self.infcx,
31993191
param_env,
32003192
errors: vec![],
32013193
};
3202-
if let Ok(_) = c.relate(trait_pred, trait_predicate) {
3194+
if let Ok(_) = c.relate(where_pred, failed_pred) {
32033195
type_diffs = c.errors;
32043196
}
3205-
} else if let ty::PredicateKind::Clause(
3206-
ty::Clause::Projection(proj)
3207-
) = pred.kind().skip_binder()
3208-
&& let ty::PredicateKind::Clause(
3209-
ty::Clause::Projection(projection)
3210-
) = predicate.kind().skip_binder()
3197+
} else if let Some(where_pred) = where_pred.to_opt_poly_projection_pred()
3198+
&& let Some(failed_pred) = failed_pred.to_opt_poly_projection_pred()
3199+
&& let Some(found) = failed_pred.skip_binder().term.ty()
32113200
{
32123201
type_diffs = vec![
32133202
Sorts(ty::error::ExpectedFound {
3214-
expected: self.tcx.mk_ty(ty::Alias(ty::Projection, proj.projection_ty)),
3215-
found: projection.term.ty().unwrap(),
3203+
expected: self.tcx.mk_ty(ty::Alias(ty::Projection, where_pred.skip_binder().projection_ty)),
3204+
found,
32163205
}),
32173206
];
32183207
}
@@ -3227,9 +3216,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
32273216
// If the expression we're calling on is a binding, we want to point at the
32283217
// `let` when talking about the type. Otherwise we'll point at every part
32293218
// of the method chain with the type.
3230-
self.point_at_chain(binding_expr, typeck_results, type_diffs, param_env, err);
3219+
self.point_at_chain(binding_expr, &typeck_results, type_diffs, param_env, err);
32313220
} else {
3232-
self.point_at_chain(expr, typeck_results, type_diffs, param_env, err);
3221+
self.point_at_chain(expr, &typeck_results, type_diffs, param_env, err);
32333222
}
32343223
}
32353224
let call_node = hir.find(call_hir_id);

‎library/core/src/const_closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ macro_rules! impl_fn_mut_tuple {
5151
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
5252
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
5353
where
54-
Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue+ ~const Destruct,
54+
Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue + ~const Destruct,
5555
{
5656
type Output = ClosureReturnValue;
5757

@@ -64,7 +64,7 @@ macro_rules! impl_fn_mut_tuple {
6464
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
6565
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
6666
where
67-
Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue,
67+
Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue + ~const Destruct,
6868
{
6969
extern "rust-call" fn call_mut(&mut self, args: ClosureArguments) -> Self::Output {
7070
#[allow(non_snake_case)]

‎library/core/src/hash/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub trait Hash {
199199
/// println!("Hash is {:x}!", hasher.finish());
200200
/// ```
201201
#[stable(feature = "rust1", since = "1.0.0")]
202-
fn hash<H: Hasher>(&self, state: &mut H);
202+
fn hash<H: ~const Hasher>(&self, state: &mut H);
203203

204204
/// Feeds a slice of this type into the given [`Hasher`].
205205
///
@@ -980,7 +980,7 @@ mod impls {
980980
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
981981
impl<T: ?Sized + ~const Hash> const Hash for &mut T {
982982
#[inline]
983-
fn hash<H: Hasher>(&self, state: &mut H) {
983+
fn hash<H: ~const Hasher>(&self, state: &mut H) {
984984
(**self).hash(state);
985985
}
986986
}

‎library/core/src/intrinsics/mir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ define!("mir_drop", fn Drop<T>(place: T, goto: BasicBlock));
259259
define!("mir_drop_and_replace", fn DropAndReplace<T>(place: T, value: T, goto: BasicBlock));
260260
define!("mir_call", fn Call<T>(place: T, goto: BasicBlock, call: T));
261261
define!("mir_retag", fn Retag<T>(place: T));
262-
define!("mir_retag_raw", fn RetagRaw<T>(place: T));
263262
define!("mir_move", fn Move<T>(place: T) -> T);
264263
define!("mir_static", fn Static<T>(s: T) -> &'static T);
265264
define!("mir_static_mut", fn StaticMut<T>(s: T) -> *mut T);

‎library/core/src/ops/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#ind
165165
#[doc(alias = "]")]
166166
#[doc(alias = "[]")]
167167
#[const_trait]
168-
pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
168+
pub trait IndexMut<Idx: ?Sized>: ~const Index<Idx> {
169169
/// Performs the mutable indexing (`container[index]`) operation.
170170
///
171171
/// # Panics

‎src/test/mir-opt/building/custom/references.immut_ref.built.after.mir

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ fn immut_ref(_1: &i32) -> &i32 {
66

77
bb0: {
88
_2 = &raw const (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:29
9-
Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24
10-
_0 = &(*_2); // scope 0 at $DIR/references.rs:+7:13: +7:23
11-
Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23
12-
return; // scope 0 at $DIR/references.rs:+9:13: +9:21
9+
_0 = &(*_2); // scope 0 at $DIR/references.rs:+6:13: +6:23
10+
Retag(_0); // scope 0 at $DIR/references.rs:+7:13: +7:23
11+
return; // scope 0 at $DIR/references.rs:+8:13: +8:21
1312
}
1413
}

‎src/test/mir-opt/building/custom/references.mut_ref.built.after.mir

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ fn mut_ref(_1: &mut i32) -> &mut i32 {
66

77
bb0: {
88
_2 = &raw mut (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:33
9-
Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24
10-
_0 = &mut (*_2); // scope 0 at $DIR/references.rs:+7:13: +7:26
11-
Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23
12-
return; // scope 0 at $DIR/references.rs:+9:13: +9:21
9+
_0 = &mut (*_2); // scope 0 at $DIR/references.rs:+6:13: +6:26
10+
Retag(_0); // scope 0 at $DIR/references.rs:+7:13: +7:23
11+
return; // scope 0 at $DIR/references.rs:+8:13: +8:21
1312
}
1413
}

‎src/test/mir-opt/building/custom/references.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub fn mut_ref(x: &mut i32) -> &mut i32 {
1212

1313
{
1414
t = addr_of_mut!(*x);
15-
RetagRaw(t);
1615
RET = &mut *t;
1716
Retag(RET);
1817
Return()
@@ -28,7 +27,6 @@ pub fn immut_ref(x: &i32) -> &i32 {
2827

2928
{
3029
t = addr_of!(*x);
31-
RetagRaw(t);
3230
RET = & *t;
3331
Retag(RET);
3432
Return()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// edition:2018
2+
3+
fn is_unwindsafe(_: impl std::panic::UnwindSafe) {}
4+
5+
fn main() {
6+
// A normal future created by an async block takes a `&mut Context<'_>` argument.
7+
// That should not leak through to the whole async block.
8+
is_unwindsafe(async {
9+
async {}.await; // this needs an inner await point
10+
});
11+
12+
is_unwindsafe(async {
13+
//~^ ERROR the type `&mut Context<'_>` may not be safely transferred across an unwind boundary
14+
use std::ptr::null;
15+
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
16+
let waker = unsafe {
17+
Waker::from_raw(RawWaker::new(
18+
null(),
19+
&RawWakerVTable::new(|_| todo!(), |_| todo!(), |_| todo!(), |_| todo!()),
20+
))
21+
};
22+
let mut cx = Context::from_waker(&waker);
23+
let cx_ref = &mut cx;
24+
25+
async {}.await; // this needs an inner await point
26+
27+
// in this case, `&mut Context<'_>` is *truly* alive across an await point
28+
drop(cx_ref);
29+
});
30+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error[E0277]: the type `&mut Context<'_>` may not be safely transferred across an unwind boundary
2+
--> $DIR/async-is-unwindsafe.rs:12:19
3+
|
4+
LL | is_unwindsafe(async {
5+
| ___________________^
6+
LL | |
7+
LL | | use std::ptr::null;
8+
LL | | use std::task::{Context, RawWaker, RawWakerVTable, Waker};
9+
... |
10+
LL | | drop(cx_ref);
11+
LL | | });
12+
| | ^
13+
| | |
14+
| |_____`&mut Context<'_>` may not be safely transferred across an unwind boundary
15+
| within this `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`
16+
|
17+
= help: within `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`
18+
= note: `UnwindSafe` is implemented for `&std::task::Context<'_>`, but not for `&mut std::task::Context<'_>`
19+
note: future does not implement `UnwindSafe` as this value is used across an await
20+
--> $DIR/async-is-unwindsafe.rs:25:17
21+
|
22+
LL | let cx_ref = &mut cx;
23+
| ------ has type `&mut Context<'_>` which does not implement `UnwindSafe`
24+
LL |
25+
LL | async {}.await; // this needs an inner await point
26+
| ^^^^^^ await occurs here, with `cx_ref` maybe used later
27+
...
28+
LL | });
29+
| - `cx_ref` is later dropped here
30+
note: required by a bound in `is_unwindsafe`
31+
--> $DIR/async-is-unwindsafe.rs:3:26
32+
|
33+
LL | fn is_unwindsafe(_: impl std::panic::UnwindSafe) {}
34+
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_unwindsafe`
35+
36+
error: aborting due to previous error
37+
38+
For more information about this error, try `rustc --explain E0277`.

‎src/test/ui/iterators/invalid-iterator-chain.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ LL | .sum::<i32>(),
5252
<i32 as Sum<&'a i32>>
5353
<i32 as Sum>
5454
note: the method call chain might not have had the expected associated types
55-
--> $DIR/invalid-iterator-chain.rs:20:14
55+
--> $DIR/invalid-iterator-chain.rs:25:14
5656
|
5757
LL | vec![0, 1]
5858
| ---------- this expression has type `Vec<{integer}>`
5959
LL | .iter()
6060
| ------ `Iterator::Item` is `&{integer}` here
6161
LL | .map(|x| x * 2)
62-
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here
62+
| -------------- `Iterator::Item` changed to `{integer}` here
6363
LL | .map(|x| x as f64)
6464
| ----------------- `Iterator::Item` changed to `f64` here
6565
LL | .map(|x| x as i64)
@@ -84,14 +84,14 @@ LL | .sum::<i32>(),
8484
<i32 as Sum<&'a i32>>
8585
<i32 as Sum>
8686
note: the method call chain might not have had the expected associated types
87-
--> $DIR/invalid-iterator-chain.rs:32:14
87+
--> $DIR/invalid-iterator-chain.rs:33:14
8888
|
8989
LL | vec![0, 1]
9090
| ---------- this expression has type `Vec<{integer}>`
9191
LL | .iter()
9292
| ------ `Iterator::Item` is `&{integer}` here
9393
LL | .map(|x| x * 2)
94-
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here
94+
| -------------- `Iterator::Item` changed to `{integer}` here
9595
LL | .map(|x| x as f64)
9696
| ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
9797
LL | .filter(|x| *x > 0.0)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(generators)]
2+
3+
fn main() {
4+
let _generator = || {
5+
yield ((), ((), ()));
6+
yield ((), ());
7+
//~^ ERROR mismatched types
8+
};
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/tuple-mismatch.rs:6:20
3+
|
4+
LL | yield ((), ());
5+
| ^^ expected tuple, found `()`
6+
|
7+
= note: expected tuple `((), ())`
8+
found unit type `()`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
This repository has been archived.