Skip to content

Commit 1b905de

Browse files
Auto merge of #149628 - Zalathar:rollup-zh362fl, r=<try>
Rollup of 14 pull requests try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: test-various try-job: armhf-gnu try-job: aarch64-apple try-job: x86_64-gnu-llvm-20-3
2 parents 5325015 + 8aa8ff2 commit 1b905de

File tree

80 files changed

+1516
-725
lines changed

Some content is hidden

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

80 files changed

+1516
-725
lines changed

.mailmap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Andre Bogus <bogusandre@gmail.com>
4343
Andre Bogus <bogusandre@gmail.com> <andre.bogus@aleph-alpha.de>
4444
Andre Bogus <bogusandre@gmail.com> <andre.bogus@ankordata.de>
4545
Andrea Ciliberti <meziu210@icloud.com>
46+
4647
Andreas Gal <gal@mozilla.com> <andreas.gal@gmail.com>
4748
Andreas Jonson <andjo403@users.noreply.github.com>
4849
Andrew Gauger <andygauge@gmail.com>
@@ -87,7 +88,9 @@ bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3@users.noreply.github.c
8788
bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3_gh@protonmail.com>
8889
Björn Steinbrink <bsteinbr@gmail.com> <B.Steinbrink@gmx.de>
8990
blake2-ppc <ulrik.sverdrup@gmail.com> <blake2-ppc>
90-
blyxyas <blyxyas@gmail.com> Alejandra González <blyxyas@gmail.com>
91+
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@gmail.com>
92+
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@goose.love>
93+
Alejandra González <blyxyas@goose.love> Alejandra González <blyxyas@gmail.com>
9194
boolean_coercion <booleancoercion@gmail.com>
9295
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
9396
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>

compiler/rustc_ast_passes/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ ast_passes_c_variadic_must_be_unsafe =
8080
ast_passes_c_variadic_no_extern = `...` is not supported for non-extern functions
8181
.help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
8282
83+
ast_passes_c_variadic_not_supported = the `{$target}` target does not support c-variadic functions
84+
8385
ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
8486
.const = `const` because of this
8587
.variadic = C-variadic because of this

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,14 @@ impl<'a> AstValidator<'a> {
710710
match fn_ctxt {
711711
FnCtxt::Foreign => return,
712712
FnCtxt::Free | FnCtxt::Assoc(_) => {
713+
if !self.sess.target.arch.supports_c_variadic_definitions() {
714+
self.dcx().emit_err(errors::CVariadicNotSupported {
715+
variadic_span: variadic_param.span,
716+
target: &*self.sess.target.llvm_target,
717+
});
718+
return;
719+
}
720+
713721
match sig.header.ext {
714722
Extern::Implicit(_) => {
715723
if !matches!(sig.header.safety, Safety::Unsafe(_)) {

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,14 @@ pub(crate) struct CoroutineAndCVariadic {
733733
pub variadic_span: Span,
734734
}
735735

736+
#[derive(Diagnostic)]
737+
#[diag(ast_passes_c_variadic_not_supported)]
738+
pub(crate) struct CVariadicNotSupported<'a> {
739+
#[primary_span]
740+
pub variadic_span: Span,
741+
pub target: &'a str,
742+
}
743+
736744
#[derive(Diagnostic)]
737745
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
738746
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ pub(crate) fn expand_test_case(
3434
check_builtin_macro_attribute(ecx, meta_item, sym::test_case);
3535
warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case);
3636

37-
if !ecx.ecfg.should_test {
38-
return vec![];
39-
}
40-
4137
let sp = ecx.with_def_site_ctxt(attr_sp);
4238
let (mut item, is_stmt) = match anno_item {
4339
Annotatable::Item(item) => (item, false),
@@ -54,6 +50,10 @@ pub(crate) fn expand_test_case(
5450
}
5551
};
5652

53+
if !ecx.ecfg.should_test {
54+
return vec![];
55+
}
56+
5757
// `#[test_case]` is valid on functions, consts, and statics. Only modify
5858
// the item in those cases.
5959
match &mut item.kind {
@@ -113,29 +113,29 @@ pub(crate) fn expand_test_or_bench(
113113
item: Annotatable,
114114
is_bench: bool,
115115
) -> Vec<Annotatable> {
116-
// If we're not in test configuration, remove the annotated item
117-
if !cx.ecfg.should_test {
118-
return vec![];
119-
}
120-
121116
let (item, is_stmt) = match item {
122117
Annotatable::Item(i) => (i, false),
123118
Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true),
124119
other => {
125-
not_testable_error(cx, attr_sp, None);
120+
not_testable_error(cx, is_bench, attr_sp, None);
126121
return vec![other];
127122
}
128123
};
129124

130125
let ast::ItemKind::Fn(fn_) = &item.kind else {
131-
not_testable_error(cx, attr_sp, Some(&item));
126+
not_testable_error(cx, is_bench, attr_sp, Some(&item));
132127
return if is_stmt {
133128
vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))]
134129
} else {
135130
vec![Annotatable::Item(item)]
136131
};
137132
};
138133

134+
// If we're not in test configuration, remove the annotated item
135+
if !cx.ecfg.should_test {
136+
return vec![];
137+
}
138+
139139
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
140140
cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
141141
testing_span: attr_sp,
@@ -405,9 +405,10 @@ pub(crate) fn expand_test_or_bench(
405405
}
406406
}
407407

408-
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
408+
fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Option<&ast::Item>) {
409409
let dcx = cx.dcx();
410-
let msg = "the `#[test]` attribute may only be used on a non-associated function";
410+
let name = if is_bench { "bench" } else { "test" };
411+
let msg = format!("the `#[{name}]` attribute may only be used on a free function");
411412
let level = match item.map(|i| &i.kind) {
412413
// These were a warning before #92959 and need to continue being that to avoid breaking
413414
// stable user code (#94508).
@@ -426,12 +427,16 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
426427
),
427428
);
428429
}
429-
err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
430-
.with_span_suggestion(attr_sp,
430+
err.span_label(attr_sp, format!("the `#[{name}]` macro causes a function to be run as a test and has no effect on non-functions"));
431+
432+
if !is_bench {
433+
err.with_span_suggestion(attr_sp,
431434
"replace with conditional compilation to make the item only exist when tests are being run",
432435
"#[cfg(test)]",
433-
Applicability::MaybeIncorrect)
434-
.emit();
436+
Applicability::MaybeIncorrect).emit();
437+
} else {
438+
err.emit();
439+
}
435440
}
436441

437442
fn get_location_info(cx: &ExtCtxt<'_>, fn_: &ast::Fn) -> (Symbol, usize, usize, usize, usize) {

compiler/rustc_codegen_ssa/src/traits/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
3636
vtable_byte_offset: u64,
3737
typeid: Self::Metadata,
3838
) -> Self::Value;
39-
/// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in
39+
/// Trait method used to inject `va_start` on the "spoofed" `VaList` in
4040
/// Rust defined C-variadic functions.
4141
fn va_start(&mut self, val: Self::Value) -> Self::Value;
42-
/// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before
42+
/// Trait method used to inject `va_end` on the "spoofed" `VaList` before
4343
/// Rust defined C-variadic functions return.
4444
fn va_end(&mut self, val: Self::Value) -> Self::Value;
4545
}

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use rustc_middle::ty::layout::{
1111
self, FnAbiError, FnAbiOf, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf,
1212
LayoutOfHelpers, TyAndLayout,
1313
};
14-
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypingEnv, Variance};
14+
use rustc_middle::ty::{
15+
self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingEnv, Variance,
16+
};
1517
use rustc_middle::{mir, span_bug};
1618
use rustc_span::Span;
1719
use rustc_target::callconv::FnAbi;
@@ -84,10 +86,31 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> {
8486
#[inline]
8587
fn handle_layout_err(
8688
&self,
87-
err: LayoutError<'tcx>,
89+
mut err: LayoutError<'tcx>,
8890
_: Span,
8991
_: Ty<'tcx>,
9092
) -> InterpErrorKind<'tcx> {
93+
// FIXME(#149283): This is really hacky and is only used to hide type
94+
// system bugs. We use it as a temporary fix for #149081.
95+
//
96+
// While it's expected that we sometimes get ambiguity errors when
97+
// entering another generic environment while the current environment
98+
// itself is still generic, we should never fail to entirely prove
99+
// something.
100+
match err {
101+
LayoutError::NormalizationFailure(ty, _) => {
102+
if ty.has_non_region_param() {
103+
err = LayoutError::TooGeneric(ty);
104+
}
105+
}
106+
107+
LayoutError::Unknown(_)
108+
| LayoutError::SizeOverflow(_)
109+
| LayoutError::InvalidSimd { .. }
110+
| LayoutError::TooGeneric(_)
111+
| LayoutError::ReferencesError(_)
112+
| LayoutError::Cycle(_) => {}
113+
}
91114
err_inval!(Layout(err))
92115
}
93116
}
@@ -112,7 +135,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
112135
/// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span.
113136
/// See [LayoutOf::layout_of] for the original documentation.
114137
#[inline(always)]
115-
pub fn layout_of(&self, ty: Ty<'tcx>) -> <Self as LayoutOfHelpers<'tcx>>::LayoutOfResult {
138+
pub fn layout_of(&self, ty: Ty<'tcx>) -> Result<TyAndLayout<'tcx>, InterpErrorKind<'tcx>> {
116139
let _trace = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind());
117140
LayoutOf::layout_of(self, ty)
118141
}

compiler/rustc_mir_build/messages.ftl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ mir_build_loop_match_unsupported_type =
250250
.note = only integers, floats, bool, char, and enums without fields are supported
251251
252252
mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper =
253-
lower range bound must be less than or equal to upper
253+
lower bound for range pattern must be less than or equal to upper bound
254254
.label = lower bound larger than upper bound
255255
.teach_note = When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range.
256256
257-
mir_build_lower_range_bound_must_be_less_than_upper = lower range bound must be less than upper
257+
mir_build_lower_range_bound_must_be_less_than_upper = lower bound for range pattern must be less than upper bound
258258
259259
mir_build_more_information = for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
260260
@@ -506,6 +506,8 @@ mir_build_unused_unsafe = unnecessary `unsafe` block
506506
507507
mir_build_unused_unsafe_enclosing_block_label = because it's nested under this `unsafe` block
508508
509+
mir_build_upper_range_bound_cannot_be_min = exclusive upper bound for a range bound cannot be the minimum
510+
509511
mir_build_variant_defined_here = not covered
510512
511513
mir_build_wrap_suggestion = consider wrapping the function body in an unsafe block

compiler/rustc_mir_build/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,13 @@ pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
776776
pub(crate) span: Span,
777777
}
778778

779+
#[derive(Diagnostic)]
780+
#[diag(mir_build_upper_range_bound_cannot_be_min, code = E0579)]
781+
pub(crate) struct UpperRangeBoundCannotBeMin {
782+
#[primary_span]
783+
pub(crate) span: Span,
784+
}
785+
779786
#[derive(LintDiagnostic)]
780787
#[diag(mir_build_leading_irrefutable_let_patterns)]
781788
#[note]

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
273273
teach: self.tcx.sess.teach(E0030),
274274
})
275275
}
276+
RangeEnd::Excluded if lo_expr.is_none() => {
277+
self.tcx.dcx().emit_err(UpperRangeBoundCannotBeMin { span })
278+
}
276279
RangeEnd::Excluded => {
277280
self.tcx.dcx().emit_err(LowerRangeBoundMustBeLessThanUpper { span })
278281
}

0 commit comments

Comments
 (0)