Skip to content

Commit 0814a56

Browse files
committed
Auto merge of #3254 - rust-lang:rustup-2024-01-06, r=saethlin
Automatic Rustup
2 parents d334a4b + 46f53c8 commit 0814a56

File tree

768 files changed

+4595
-8012
lines changed

Some content is hidden

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

768 files changed

+4595
-8012
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -546,20 +546,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
546546

547547
fn lower_arm(&mut self, arm: &Arm) -> hir::Arm<'hir> {
548548
let pat = self.lower_pat(&arm.pat);
549-
let guard = arm.guard.as_ref().map(|cond| {
550-
if let ExprKind::Let(pat, scrutinee, span, is_recovered) = &cond.kind {
551-
hir::Guard::IfLet(self.arena.alloc(hir::Let {
552-
hir_id: self.next_id(),
553-
span: self.lower_span(*span),
554-
pat: self.lower_pat(pat),
555-
ty: None,
556-
init: self.lower_expr(scrutinee),
557-
is_recovered: *is_recovered,
558-
}))
559-
} else {
560-
hir::Guard::If(self.lower_expr(cond))
561-
}
562-
});
549+
let guard = arm.guard.as_ref().map(|cond| self.lower_expr(cond));
563550
let hir_id = self.next_id();
564551
let span = self.lower_span(arm.span);
565552
self.lower_attrs(hir_id, &arm.attrs);

compiler/rustc_ast_passes/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ ast_passes_module_nonascii = trying to load file for module `{$name}` with non-a
188188
ast_passes_negative_bound_not_supported =
189189
negative bounds are not supported
190190
191+
ast_passes_negative_bound_with_parenthetical_notation =
192+
parenthetical notation may not be used for negative bounds
193+
191194
ast_passes_nested_impl_trait = nested `impl Trait` is not allowed
192195
.outer = outer `impl Trait`
193196
.inner = nested `impl Trait` here

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,13 +1312,24 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13121312
if let GenericBound::Trait(trait_ref, modifiers) = bound
13131313
&& let BoundPolarity::Negative(_) = modifiers.polarity
13141314
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
1315-
&& let Some(ast::GenericArgs::AngleBracketed(args)) = segment.args.as_deref()
13161315
{
1317-
for arg in &args.args {
1318-
if let ast::AngleBracketedArg::Constraint(constraint) = arg {
1319-
self.dcx()
1320-
.emit_err(errors::ConstraintOnNegativeBound { span: constraint.span });
1316+
match segment.args.as_deref() {
1317+
Some(ast::GenericArgs::AngleBracketed(args)) => {
1318+
for arg in &args.args {
1319+
if let ast::AngleBracketedArg::Constraint(constraint) = arg {
1320+
self.dcx().emit_err(errors::ConstraintOnNegativeBound {
1321+
span: constraint.span,
1322+
});
1323+
}
1324+
}
1325+
}
1326+
// The lowered form of parenthesized generic args contains a type binding.
1327+
Some(ast::GenericArgs::Parenthesized(args)) => {
1328+
self.dcx().emit_err(errors::NegativeBoundWithParentheticalNotation {
1329+
span: args.span,
1330+
});
13211331
}
1332+
None => {}
13221333
}
13231334
}
13241335

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ impl AddToDiagnostic for StableFeature {
725725
rustc_errors::SubdiagnosticMessage,
726726
) -> rustc_errors::SubdiagnosticMessage,
727727
{
728-
diag.set_arg("name", self.name);
729-
diag.set_arg("since", self.since);
728+
diag.arg("name", self.name);
729+
diag.arg("since", self.since);
730730
diag.help(fluent::ast_passes_stable_since);
731731
}
732732
}
@@ -763,6 +763,13 @@ pub struct ConstraintOnNegativeBound {
763763
pub span: Span,
764764
}
765765

766+
#[derive(Diagnostic)]
767+
#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
768+
pub struct NegativeBoundWithParentheticalNotation {
769+
#[primary_span]
770+
pub span: Span,
771+
}
772+
766773
#[derive(Diagnostic)]
767774
#[diag(ast_passes_invalid_unnamed_field_ty)]
768775
pub struct InvalidUnnamedFieldTy {

compiler/rustc_attr/src/session_diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
5555
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
5656
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
5757
let mut diag = DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item);
58-
diag.set_span(self.span);
58+
diag.span(self.span);
5959
diag.code(error_code!(E0541));
60-
diag.set_arg("item", self.item);
61-
diag.set_arg("expected", expected.join(", "));
60+
diag.arg("item", self.item);
61+
diag.arg("expected", expected.join(", "));
6262
diag.span_label(self.span, fluent::attr_label);
6363
diag
6464
}
@@ -215,7 +215,7 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnsupportedLiteral {
215215
}
216216
},
217217
);
218-
diag.set_span(self.span);
218+
diag.span(self.span);
219219
diag.code(error_code!(E0565));
220220
if self.is_bytestr {
221221
diag.span_suggestion(

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
35903590
));
35913591
} else if let Some(guard) = &arm.guard {
35923592
self.errors.push((
3593-
arm.pat.span.to(guard.body().span),
3593+
arm.pat.span.to(guard.span),
35943594
format!(
35953595
"if this pattern and condition are matched, {} is not \
35963596
initialized",

compiler/rustc_borrowck/src/type_check/input_output.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,31 +94,22 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
9494
);
9595
}
9696

97-
debug!(
98-
"equate_inputs_and_outputs: body.yield_ty {:?}, universal_regions.yield_ty {:?}",
99-
body.yield_ty(),
100-
universal_regions.yield_ty
101-
);
102-
103-
// We will not have a universal_regions.yield_ty if we yield (by accident)
104-
// outside of a coroutine and return an `impl Trait`, so emit a span_delayed_bug
105-
// because we don't want to panic in an assert here if we've already got errors.
106-
if body.yield_ty().is_some() != universal_regions.yield_ty.is_some() {
107-
self.tcx().dcx().span_delayed_bug(
108-
body.span,
109-
format!(
110-
"Expected body to have yield_ty ({:?}) iff we have a UR yield_ty ({:?})",
111-
body.yield_ty(),
112-
universal_regions.yield_ty,
113-
),
97+
if let Some(mir_yield_ty) = body.yield_ty() {
98+
let yield_span = body.local_decls[RETURN_PLACE].source_info.span;
99+
self.equate_normalized_input_or_output(
100+
universal_regions.yield_ty.unwrap(),
101+
mir_yield_ty,
102+
yield_span,
114103
);
115104
}
116105

117-
if let (Some(mir_yield_ty), Some(ur_yield_ty)) =
118-
(body.yield_ty(), universal_regions.yield_ty)
119-
{
106+
if let Some(mir_resume_ty) = body.resume_ty() {
120107
let yield_span = body.local_decls[RETURN_PLACE].source_info.span;
121-
self.equate_normalized_input_or_output(ur_yield_ty, mir_yield_ty, yield_span);
108+
self.equate_normalized_input_or_output(
109+
universal_regions.resume_ty.unwrap(),
110+
mir_resume_ty,
111+
yield_span,
112+
);
122113
}
123114

124115
// Return types are a bit more complex. They may contain opaque `impl Trait` types.

compiler/rustc_borrowck/src/type_check/liveness/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for LiveVariablesVisitor<'cx, 'tcx> {
183183
match ty_context {
184184
TyContext::ReturnTy(SourceInfo { span, .. })
185185
| TyContext::YieldTy(SourceInfo { span, .. })
186+
| TyContext::ResumeTy(SourceInfo { span, .. })
186187
| TyContext::UserTy(span)
187188
| TyContext::LocalDecl { source_info: SourceInfo { span, .. }, .. } => {
188189
span_bug!(span, "should not be visiting outside of the CFG: {:?}", ty_context);

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,13 +1450,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14501450
}
14511451
}
14521452
}
1453-
TerminatorKind::Yield { value, .. } => {
1453+
TerminatorKind::Yield { value, resume_arg, .. } => {
14541454
self.check_operand(value, term_location);
14551455

1456-
let value_ty = value.ty(body, tcx);
14571456
match body.yield_ty() {
14581457
None => span_mirbug!(self, term, "yield in non-coroutine"),
14591458
Some(ty) => {
1459+
let value_ty = value.ty(body, tcx);
14601460
if let Err(terr) = self.sub_types(
14611461
value_ty,
14621462
ty,
@@ -1474,6 +1474,28 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14741474
}
14751475
}
14761476
}
1477+
1478+
match body.resume_ty() {
1479+
None => span_mirbug!(self, term, "yield in non-coroutine"),
1480+
Some(ty) => {
1481+
let resume_ty = resume_arg.ty(body, tcx);
1482+
if let Err(terr) = self.sub_types(
1483+
ty,
1484+
resume_ty.ty,
1485+
term_location.to_locations(),
1486+
ConstraintCategory::Yield,
1487+
) {
1488+
span_mirbug!(
1489+
self,
1490+
term,
1491+
"type of resume place is {:?}, but the resume type is {:?}: {:?}",
1492+
resume_ty,
1493+
ty,
1494+
terr
1495+
);
1496+
}
1497+
}
1498+
}
14771499
}
14781500
}
14791501
}

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub struct UniversalRegions<'tcx> {
7676
pub unnormalized_input_tys: &'tcx [Ty<'tcx>],
7777

7878
pub yield_ty: Option<Ty<'tcx>>,
79+
80+
pub resume_ty: Option<Ty<'tcx>>,
7981
}
8082

8183
/// The "defining type" for this MIR. The key feature of the "defining
@@ -525,9 +527,12 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
525527
debug!("build: extern regions = {}..{}", first_extern_index, first_local_index);
526528
debug!("build: local regions = {}..{}", first_local_index, num_universals);
527529

528-
let yield_ty = match defining_ty {
529-
DefiningTy::Coroutine(_, args) => Some(args.as_coroutine().yield_ty()),
530-
_ => None,
530+
let (resume_ty, yield_ty) = match defining_ty {
531+
DefiningTy::Coroutine(_, args) => {
532+
let tys = args.as_coroutine();
533+
(Some(tys.resume_ty()), Some(tys.yield_ty()))
534+
}
535+
_ => (None, None),
531536
};
532537

533538
UniversalRegions {
@@ -541,6 +546,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
541546
unnormalized_output_ty: *unnormalized_output_ty,
542547
unnormalized_input_tys,
543548
yield_ty,
549+
resume_ty,
544550
}
545551
}
546552

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMe
454454
reason = "cannot translate user-provided messages"
455455
)]
456456
let mut diag = DiagnosticBuilder::new(dcx, level, self.msg_from_user.to_string());
457-
diag.set_span(self.span);
457+
diag.span(self.span);
458458
diag
459459
}
460460
}
@@ -618,7 +618,7 @@ impl AddToDiagnostic for FormatUnusedArg {
618618
rustc_errors::SubdiagnosticMessage,
619619
) -> rustc_errors::SubdiagnosticMessage,
620620
{
621-
diag.set_arg("named", self.named);
621+
diag.arg("named", self.named);
622622
let msg = f(diag, crate::fluent_generated::builtin_macros_format_unused_arg.into());
623623
diag.span_label(self.span, msg);
624624
}
@@ -808,7 +808,7 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
808808
level,
809809
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
810810
);
811-
diag.set_span(self.spans.clone());
811+
diag.span(self.spans.clone());
812812
// eager translation as `span_labels` takes `AsRef<str>`
813813
let lbl1 = dcx.eagerly_translate_to_string(
814814
crate::fluent_generated::builtin_macros_asm_clobber_abi,

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
395395
// These were a warning before #92959 and need to continue being that to avoid breaking
396396
// stable user code (#94508).
397397
Some(ast::ItemKind::MacCall(_)) => Level::Warning(None),
398-
_ => Level::Error { lint: false },
398+
_ => Level::Error,
399399
};
400400
let mut err = DiagnosticBuilder::<()>::new(dcx, level, msg);
401-
err.set_span(attr_sp);
401+
err.span(attr_sp);
402402
if let Some(item) = item {
403403
err.span_label(
404404
item.span,

compiler/rustc_codegen_gcc/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnabl
119119
fluent::codegen_gcc_target_feature_disable_or_enable
120120
);
121121
if let Some(span) = self.span {
122-
diag.set_span(span);
122+
diag.span(span);
123123
};
124124
if let Some(missing_features) = self.missing_features {
125125
diag.subdiagnostic(missing_features);
126126
}
127-
diag.set_arg("features", self.features.join(", "));
127+
diag.arg("features", self.features.join(", "));
128128
diag
129129
}
130130
}

compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::type_::Type;
66
use crate::type_of::LayoutLlvmExt;
77
use crate::value::Value;
88

9-
use rustc_codegen_ssa::mir::operand::OperandValue;
9+
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
1010
use rustc_codegen_ssa::mir::place::PlaceRef;
1111
use rustc_codegen_ssa::traits::*;
1212
use rustc_codegen_ssa::MemFlags;
@@ -253,7 +253,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
253253
bx.lifetime_end(llscratch, scratch_size);
254254
}
255255
} else {
256-
OperandValue::Immediate(val).store(bx, dst);
256+
OperandRef::from_immediate_or_packed_pair(bx, val, self.layout).val.store(bx, dst);
257257
}
258258
}
259259

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ fn report_inline_asm(
416416
cookie = 0;
417417
}
418418
let level = match level {
419-
llvm::DiagnosticLevel::Error => Level::Error { lint: false },
419+
llvm::DiagnosticLevel::Error => Level::Error,
420420
llvm::DiagnosticLevel::Warning => Level::Warning(None),
421421
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
422422
};

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,17 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
558558
OperandValue::Immediate(self.to_immediate(llval, place.layout))
559559
} else if let abi::Abi::ScalarPair(a, b) = place.layout.abi {
560560
let b_offset = a.size(self).align_to(b.align(self).abi);
561-
let pair_ty = place.layout.llvm_type(self);
562561

563562
let mut load = |i, scalar: abi::Scalar, layout, align, offset| {
564-
let llptr = self.struct_gep(pair_ty, place.llval, i as u64);
563+
let llptr = if i == 0 {
564+
place.llval
565+
} else {
566+
self.inbounds_gep(
567+
self.type_i8(),
568+
place.llval,
569+
&[self.const_usize(b_offset.bytes())],
570+
)
571+
};
565572
let llty = place.layout.scalar_pair_element_llvm_type(self, i, false);
566573
let load = self.load(llty, llptr, align);
567574
scalar_load_metadata(self, load, scalar, layout, offset);

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ParseTargetMachineConfig<'_
107107

108108
let mut diag =
109109
DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config);
110-
diag.set_arg("error", message);
110+
diag.arg("error", message);
111111
diag
112112
}
113113
}
@@ -130,12 +130,12 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnabl
130130
fluent::codegen_llvm_target_feature_disable_or_enable,
131131
);
132132
if let Some(span) = self.span {
133-
diag.set_span(span);
133+
diag.span(span);
134134
};
135135
if let Some(missing_features) = self.missing_features {
136136
diag.subdiagnostic(missing_features);
137137
}
138-
diag.set_arg("features", self.features.join(", "));
138+
diag.arg("features", self.features.join(", "));
139139
diag
140140
}
141141
}
@@ -205,8 +205,8 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
205205
ParseBitcode => fluent::codegen_llvm_parse_bitcode_with_llvm_err,
206206
};
207207
let mut diag = self.0.into_diagnostic(dcx, level);
208-
diag.set_primary_message(msg_with_llvm_err);
209-
diag.set_arg("llvm_err", self.1);
208+
diag.primary_message(msg_with_llvm_err);
209+
diag.arg("llvm_err", self.1);
210210
diag
211211
}
212212
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
179179
unsafe {
180180
llvm::LLVMSetAlignment(load, align);
181181
}
182-
self.to_immediate(load, self.layout_of(tp_ty))
182+
if !result.layout.is_zst() {
183+
self.store(load, result.llval, result.align);
184+
}
185+
return;
183186
}
184187
sym::volatile_store => {
185188
let dst = args[0].deref(self.cx());

0 commit comments

Comments
 (0)