Skip to content

Commit 2b68104

Browse files
committed
Auto merge of #119603 - matthiaskrgr:rollup-ulep7qk, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #118680 (Add support for shell argfiles) - #119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - #119216 (Use diagnostic namespace in stdlib) - #119350 (Imply outlives-bounds on lazy type aliases) - #119538 (Cleanup error handlers: round 5) - #119563 (Check yield terminator's resume type in borrowck) - #119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - #119591 (rustc_mir_transform: Make DestinationPropagation stable for queries) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5113ed2 + e147a1b commit 2b68104

File tree

119 files changed

+1221
-775
lines changed

Some content is hidden

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

119 files changed

+1221
-775
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3738,6 +3738,7 @@ dependencies = [
37383738
"rustc_trait_selection",
37393739
"rustc_ty_utils",
37403740
"serde_json",
3741+
"shlex",
37413742
"time",
37423743
"tracing",
37433744
"windows",

compiler/rustc_ast_passes/src/errors.rs

+2-2
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
}

compiler/rustc_attr/src/session_diagnostics.rs

+4-4
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/type_check/input_output.rs

+12-21
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

+1
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

+24-2
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

+9-3
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

+3-3
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

+2-2
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

+2-2
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/back/write.rs

+1-1
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/errors.rs

+5-5
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_ssa/src/back/write.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1848,9 +1848,9 @@ impl SharedEmitterMain {
18481848
}
18491849
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => {
18501850
let err_level = match level {
1851-
Level::Error { lint: false } => rustc_errors::Level::Error { lint: false },
1852-
Level::Warning(_) => rustc_errors::Level::Warning(None),
1853-
Level::Note => rustc_errors::Level::Note,
1851+
Level::Error => Level::Error,
1852+
Level::Warning(_) => Level::Warning(None),
1853+
Level::Note => Level::Note,
18541854
_ => bug!("Invalid inline asm diagnostic level"),
18551855
};
18561856
let msg = msg.strip_prefix("error: ").unwrap_or(&msg).to_string();
@@ -1860,7 +1860,7 @@ impl SharedEmitterMain {
18601860
if cookie != 0 {
18611861
let pos = BytePos::from_u32(cookie);
18621862
let span = Span::with_root_ctxt(pos, pos);
1863-
err.set_span(span);
1863+
err.span(span);
18641864
};
18651865

18661866
// Point to the generated assembly if it is available.

0 commit comments

Comments
 (0)