Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
76323c8
[draft] Link to proposed LLM policy
jyn514 Apr 17, 2026
f32e5d8
add guidance for working with LLMs
jyn514 May 23, 2026
e07d7cc
Suggest using an LLM to generate tools, rather than making the LLM th…
jyn514 Jun 6, 2026
baf98d4
add note that LLMs prefer their own output
jyn514 Jun 11, 2026
32c4dcb
extend llm guidance
jyn514 Jun 18, 2026
2685fec
extend LLM guidance with a summary of the policy
jyn514 Jul 28, 2026
7da7cd0
flesh out author guidance
jyn514 Jul 29, 2026
500f94c
more author guidance; cross-references
jyn514 Jul 29, 2026
ac6af39
change tone from policy to mentorship
jyn514 Jul 29, 2026
ef9670c
add "maintainable code" section
jyn514 Jul 29, 2026
cebbf10
split authoring and reviewing sections
jyn514 Jul 29, 2026
7cef419
be more clear about what i mean around linters
jyn514 Jul 29, 2026
49d14d6
add more links
jyn514 Jul 29, 2026
4fb41b1
move correctness suggestions to a better chapter
jyn514 Jul 29, 2026
6b52bda
address Sasha's review comments
jyn514 Jul 29, 2026
ff5a4a4
fix links
jyn514 Jul 29, 2026
df4f543
tweaks
jyn514 Jul 29, 2026
beca161
headings
jyn514 Jul 29, 2026
a2d28af
don't treat model names as a good example of disclosure
jyn514 Jul 30, 2026
daafdb5
Document `./x build --timings`
joshtriplett Aug 2, 2026
851876f
Merge pull request #2951 from joshtriplett/timings
joshtriplett Aug 2, 2026
fbaa034
document that commit messages must be human-authored
jyn514 Aug 2, 2026
f55e223
Merge pull request #2835 from jyn514/llm-policy
jyn514 Aug 5, 2026
77a8b9f
move index file up to make external links to ".../llm-guidance.html" …
steffahn Aug 5, 2026
142707e
Update relative links
steffahn Aug 5, 2026
ead361d
Merge pull request #2953 from steffahn/fix-llm-guidance-link
Kobzol Aug 5, 2026
fb0210d
PowerPC inline ASM: Fix scalar floats being in the wrong vector lane …
beetrees Aug 3, 2026
a669f67
derive(Diagnostic): #[note] etc also work on bool fields
RalfJung Aug 6, 2026
4ee0e67
remove derives from SVE macros
folkertdev Aug 6, 2026
909d601
forward rustflags to rustdoc
folkertdev Aug 5, 2026
32deaa2
Fix wasm CI
adamgemmell Aug 6, 2026
dc0c3cb
Point wasmtime into the new build-dir layout
adamgemmell Aug 6, 2026
ad73022
Fix stdarch-test wasm disassembly for the new deps layout
adamgemmell Aug 6, 2026
cf87891
Speculative x86_64-pc-windows-msvc fix
adamgemmell Aug 6, 2026
b0a0023
amdgpu doc comment fix
folkertdev Aug 7, 2026
11114b4
use doc(cfg) on some x86 types with examples
folkertdev Aug 7, 2026
2a018f4
ignore example code blocks on nvptx and amdgpu
folkertdev Aug 9, 2026
64f0b1f
use cfg to only compile/run x86 examples on x86
folkertdev Aug 9, 2026
f4d4ee7
allocator: refactor for stabilisation
nia-e Jun 4, 2026
7cab1f0
here's your damn trait name
nia-e Aug 9, 2026
7ed549a
Prepare for merging from rust-lang/rust
invalid-email-address Aug 10, 2026
a7b80e9
Merge ref '969b803cbe1d' from rust-lang/rust
invalid-email-address Aug 10, 2026
25c1ae6
stability.md: add missing brackets to `unstable_removed` attribute
DanielEScherzer Aug 10, 2026
a5c4966
Merge pull request #2956 from DanielEScherzer/stability-brackets
fmease Aug 10, 2026
0ece90b
Add assumptions on binders shorthand to the glossary
fallible-algebra Aug 10, 2026
882ed23
Merge pull request #2957 from fallible-algebra/glossary/assbind
BoxyUwU Aug 10, 2026
d087f53
Merge pull request #2952 from rust-lang/rustc-pull
tshepang Aug 11, 2026
3b8174d
Merge pull request #2955 from RalfJung/derive-diagnostic
tshepang Aug 11, 2026
98cb632
Prepare for merging from rust-lang/rust
invalid-email-address Aug 11, 2026
d3a2176
Merge ref 'e64c8a664d9d' from rust-lang/rust
invalid-email-address Aug 11, 2026
3b87406
Merge pull request #2960 from rust-lang/rustc-pull
tshepang Aug 11, 2026
9b06d77
fix attribute links
mejrs Aug 11, 2026
1745a93
vectorcall fix
folkertdev Aug 11, 2026
b4ea05e
update aarch64/arm64ec assembly tests
folkertdev Aug 9, 2026
3af5adf
Merge pull request #2201 from folkertdev/rustdocflags
sayantn Aug 12, 2026
eb750a7
give layout errors from `size_of_val` and `align_of_val` a span
Albab-Hasan Aug 12, 2026
4f9e971
skip the debuginfo revision on the gcc backend
Albab-Hasan Aug 12, 2026
644a826
sve: re-enable `sveorv` testing after LLVM upgrade
davidtwco Aug 5, 2026
6680880
Simplify scalable vector testing
sayantn Jul 13, 2026
7b40a5d
Merge pull request #2204 from davidtwco/sve-sveorv-testing
davidtwco Aug 12, 2026
2372ea0
Merge pull request #2188 from sayantn/intrinsic-test-refactors
davidtwco Aug 12, 2026
761241c
Add preferred assumptions on binders shorthand to the glossary
fallible-algebra Aug 12, 2026
c452783
Merge pull request #2961 from fallible-algebra/glossary/abby
BoxyUwU Aug 12, 2026
5097d8b
clippy::manual_isolate_lowest_one
ChrisDenton Aug 12, 2026
03e4d31
Allow some noisy clippy lints
ChrisDenton Aug 12, 2026
0e48853
Merge pull request #2206 from ChrisDenton/clippy
folkertdev Aug 12, 2026
742c085
Use 2 word unwinder_private_data on Emscripten
bjorn3 Jul 19, 2026
1890b82
Move wasi libunwind link block to crate root
bjorn3 Aug 3, 2026
e08ce7f
Avoid defining dummy personality function for Motor OS
bjorn3 Jul 24, 2026
37831ee
Use dummy panic_unwind impl for Hermit
bjorn3 Jul 28, 2026
29d3b9e
Port stdarch-gen-arm to stdarch-gen-common
xonx4l Aug 4, 2026
78f8980
std: map ERROR_NEGATIVE_SEEK to ErrorKind::InvalidInput on Windows
valentynkit Aug 12, 2026
5cdd04f
Fix mentions of "`ai-assisted`" label in llm guidance docs
steffahn Aug 12, 2026
fd86d6d
x86_64-win: Enable f128 on LLVM 23+
tgross35 Jul 7, 2026
55650a2
Add regression test for try block label suggestions
chenyukang Aug 13, 2026
c48651a
io: Use `NonNull` for all `Custom` API related to `Box`
tgross35 Aug 12, 2026
54a6391
Fix invalid suggestion from try unlabled block
chenyukang Aug 13, 2026
57b5019
io: Improve internal documentation for `Custom` error
tgross35 Aug 12, 2026
2b08302
Merge pull request #2962 from steffahn/llm-assisted-label
jyn514 Aug 13, 2026
ec787d8
Merge pull request #2959 from mejrs/attrs
tshepang Aug 13, 2026
adc30eb
Add `feedable` query modifier
blyxyas Jul 23, 2026
e543bab
Merge pull request #2942 from blyxyas/feedable-query-mod
tshepang Aug 13, 2026
6a823d3
sembr src/queries/incremental-compilation-in-detail.md
tshepang Aug 13, 2026
fa6c1ba
align
tshepang Aug 13, 2026
66cf603
sembr src/llm-guidance/reviewing.md
tshepang Aug 13, 2026
3aba612
sembr src/llm-guidance/writing.md
tshepang Aug 13, 2026
b011266
sembr src/opaque-types-type-alias-impl-trait.md
tshepang Aug 13, 2026
c47f10a
sembr src/hir/attribute-parsing.md
tshepang Aug 13, 2026
e8d39b8
sembr src/diagnostics/error-guaranteed.md
tshepang Aug 13, 2026
8b93983
improve src/stability.md
tshepang Aug 13, 2026
6bf26fb
sembr src/debuginfo/testing.md
tshepang Aug 13, 2026
24b66a7
sembr src/tests/stdlib-semver-check.md
tshepang Aug 13, 2026
fd1d77f
improve tests/stdlib-semver-check.md
tshepang Aug 13, 2026
5f4b091
Optimize CStr backing slice bounds checks
SomeFlyingThing Aug 13, 2026
c490377
reflow
tshepang Aug 13, 2026
cda814c
sembr src/profile-guided-optimization.md
tshepang Aug 13, 2026
60a903d
Merge pull request #2200 from xonx4l/port-stdarch-gen-arm-to-common
folkertdev Aug 13, 2026
ca1b034
disallow `#[cold]` on `extern "custom"` functions
folkertdev Aug 12, 2026
03b98be
Prepare for merging from rust-lang/rust
folkertdev Aug 13, 2026
11e98c7
Merge ref '1e5ee3563742' from rust-lang/rust
folkertdev Aug 13, 2026
bba2a59
Merge pull request #2207 from folkertdev/rustc-sync-2026-09-13
folkertdev Aug 13, 2026
28ff895
improve profile-guided-optimization.md
tshepang Aug 13, 2026
eee684e
sembr src/guides/editions.md
tshepang Aug 13, 2026
e8fe604
not a blog post
tshepang Aug 13, 2026
5d82d7e
sembr src/incrcomp-debugging.md
tshepang Aug 13, 2026
5f249e4
whitespace
tshepang Aug 13, 2026
84fb23f
sembr src/memory.md
tshepang Aug 13, 2026
0b6995a
improve memory.md
tshepang Aug 13, 2026
ac129e9
sembr src/return-position-impl-trait-in-trait.md
tshepang Aug 13, 2026
b4f722c
was 3 years ago
tshepang Aug 13, 2026
8f7fc50
reflow
tshepang Aug 13, 2026
499d68c
sembr src/traits/implied-bounds.md
tshepang Aug 13, 2026
9ac8fe6
improve traits/implied-bounds.md
tshepang Aug 13, 2026
1df30e6
Merge pull request #2963 from rust-lang/tshepang/misc
tshepang Aug 13, 2026
948b5ab
tidy: Update Python version requirements to 3.11
marcoieni Aug 13, 2026
dfb5bab
Enable unrolling feature of bors
Kobzol Aug 13, 2026
6ef144d
rustdoc: use anonymous constant for primitives/keywords/attribute docs
mejrs Aug 4, 2026
4449de3
ensure anon consts themselves are not documented
mejrs Aug 11, 2026
00a552f
check `mut`-restriction when tuple constructor is used as a value
im-lunex Aug 13, 2026
a89abc8
Fix link title attribute value when field of enum variants
GuillaumeGomez Aug 13, 2026
944271a
Rollup merge of #161045 - folkertdev:stdarch-sync-2026-09-13, r=folke…
JonathanBrouwer Aug 13, 2026
c339295
Rollup merge of #157428 - nia-e:allocator-refactor, r=clarfonthey
JonathanBrouwer Aug 13, 2026
05eef37
Rollup merge of #158918 - tgross35:win64-f128-updates, r=folkertdev
JonathanBrouwer Aug 13, 2026
5125abd
Rollup merge of #160288 - mejrs:anon_const_attr_docs, r=GuillaumeGomez
JonathanBrouwer Aug 13, 2026
e60f623
Rollup merge of #160440 - bjorn3:refactor_unwind4, r=Mark-Simulacrum
JonathanBrouwer Aug 13, 2026
dda9842
Rollup merge of #160441 - beetrees:inline-asm-fix-powerpc64le, r=Amanieu
JonathanBrouwer Aug 13, 2026
b819648
Rollup merge of #160896 - marcoieni:tidy-python-3.11, r=jieyouxu
JonathanBrouwer Aug 13, 2026
3bd9ffb
Rollup merge of #160972 - valentynkit:windows-seek-invalid-input, r=J…
JonathanBrouwer Aug 13, 2026
f0bb316
Rollup merge of #161040 - SomeFlyingThing:agent/audit-codegen-hints, …
JonathanBrouwer Aug 13, 2026
6f34452
Rollup merge of #160928 - im-lunex:fix_#160891, r=Urgau
JonathanBrouwer Aug 13, 2026
f5eda41
Rollup merge of #160969 - Albab-Hasan:span-for-size-of-val-layout-err…
JonathanBrouwer Aug 13, 2026
680c06b
Rollup merge of #161002 - folkertdev:custom-error-on-cold, r=tgross35
JonathanBrouwer Aug 13, 2026
7de0dbd
Rollup merge of #161016 - chenyukang:yukang-fix-160987-try-block-labe…
JonathanBrouwer Aug 13, 2026
5da32cc
Rollup merge of #161020 - tgross35:io-error-updates, r=clarfonthey
JonathanBrouwer Aug 13, 2026
def38fa
Rollup merge of #161044 - tshepang:rdg-sync, r=tshepang
JonathanBrouwer Aug 13, 2026
37b9c21
Rollup merge of #161046 - Kobzol:bors-unroll, r=Kobzol
JonathanBrouwer Aug 13, 2026
48e03f7
Rollup merge of #161054 - GuillaumeGomez:enum-variant-field-title, r=…
JonathanBrouwer Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use rustc_session::lint::builtin::{
use rustc_span::{Ident, Span, Symbol, kw, sym};
use rustc_target::spec::{AbiMap, AbiMapping};

use crate::diagnostics::{self, TildeConstReason};
use crate::diagnostics::{self, AbiCustomCannotBeCold, AbiCustomMustBeNaked, TildeConstReason};

/// Is `self` allowed semantically as the first parameter in an `FnDecl`?
enum SelfSemantic {
Expand Down Expand Up @@ -899,6 +899,44 @@ impl<'a> AstValidator<'a> {
}
}

/// Check the attributes on an `extern "custom"` function:
///
/// - require `#[naked]`
/// - reject `#[cold]` (these functions cannot be called so `#[cold]` is meaningless)
fn check_extern_custom(&self, fk: FnKind<'_>, attrs: &AttrVec) {
let FnKind::Fn(fn_ctxt, _, Fn { sig, body: Some(_), .. }) = fk else {
return;
};

match fn_ctxt {
FnCtxt::Foreign => return,
FnCtxt::Free | FnCtxt::Assoc(_) => { /* fall through */ }
}

let Extern::Explicit(StrLit { symbol_unescaped, .. }, ext_span) = sig.header.ext else {
return;
};

let Ok(ExternAbi::Custom) = ExternAbi::from_str(symbol_unescaped.as_str()) else {
return;
};

if !attr::contains_name(attrs, sym::naked) {
self.dcx().emit_err(AbiCustomMustBeNaked {
span: sig.span,
naked_span: sig.span.shrink_to_lo(),
});
}

if let Some(cold) = attr::find_by_name(attrs, sym::cold) {
self.dcx().emit_err(AbiCustomCannotBeCold {
span: sig.span,
abi_span: ext_span,
cold_span: cold.span,
});
}
}

/// Reject invalid C-variadic types.
///
/// C-variadics must be:
Expand Down Expand Up @@ -1937,6 +1975,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
}

self.check_extern_custom(fk, attrs);
self.check_c_variadic_type(fk, attrs);

// Functions cannot both be `const async` or `const gen`
Expand Down
34 changes: 34 additions & 0 deletions compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,3 +1264,37 @@ pub(crate) struct VarargsWithoutPattern {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(
"an `extern \"custom\"` function can only be declared externally or defined via naked functions"
)]
pub(crate) struct AbiCustomMustBeNaked {
#[primary_span]
pub span: Span,
#[suggestion(
"convert this to an `#[unsafe(naked)]` function",
applicability = "maybe-incorrect",
code = "#[unsafe(naked)]\n",
style = "short"
)]
pub naked_span: Span,
}

#[derive(Diagnostic)]
#[diag("an `extern \"custom\"` function cannot be marked `#[cold]`")]
pub(crate) struct AbiCustomCannotBeCold {
#[primary_span]
pub span: Span,

#[suggestion(
"remove the `#[cold]` attribute",
applicability = "maybe-incorrect",
code = "",
style = "short"
)]
pub cold_span: Span,

#[label("`extern \"custom\"` because of this")]
pub abi_span: Span,
}
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ pub(crate) struct RustcDocPrimitiveParser;

impl SingleAttributeParser for RustcDocPrimitiveParser {
const PATH: &[Symbol] = &[sym::rustc_doc_primitive];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Mod)]);
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Const)]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "primitive name");
const STABILITY: AttributeStability = unstable!(
rustc_attrs,
Expand Down
56 changes: 23 additions & 33 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::assert_matches;
use std::fmt::Write;

use rustc_abi::{BackendRepr, Float, Integer, Primitive, Scalar, Size};
use rustc_abi::{BackendRepr, Endian, Float, Integer, Primitive, Scalar, Size};
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::mir::operand::OperandValue;
use rustc_codegen_ssa::traits::*;
Expand All @@ -12,6 +12,7 @@ use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::{bug, span_bug};
use rustc_span::{Pos, Span, Symbol, sym};
use rustc_target::asm::*;
use rustc_target::spec::HasTargetSpec;
use smallvec::SmallVec;
use tracing::debug;

Expand Down Expand Up @@ -1244,24 +1245,16 @@ fn llvm_fixup_input<'ll, 'tcx>(
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F32) => {
let value = bx.insert_element(
bx.const_undef(bx.type_vector(bx.type_f32(), 4)),
) if let Primitive::Float(float @ (Float::F32 | Float::F64)) = s.primitive() => {
let num_lanes = 16 / float.size().bytes();
bx.insert_element(
bx.const_undef(bx.type_vector(bx.type_from_float(float), num_lanes)),
value,
bx.const_usize(0),
);
bx.bitcast(value, bx.type_vector(bx.type_f32(), 4))
}
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F64) => {
let value = bx.insert_element(
bx.const_undef(bx.type_vector(bx.type_f64(), 2)),
value,
bx.const_usize(0),
);
bx.bitcast(value, bx.type_vector(bx.type_f64(), 2))
bx.const_usize(match bx.target_spec().endian {
Endian::Little => num_lanes - 1,
Endian::Big => 0,
}),
)
}
_ => value,
}
Expand Down Expand Up @@ -1416,16 +1409,15 @@ fn llvm_fixup_output<'ll, 'tcx>(
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F32) => {
let value = bx.bitcast(value, bx.type_vector(bx.type_f32(), 4));
bx.extract_element(value, bx.const_usize(0))
}
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F64) => {
let value = bx.bitcast(value, bx.type_vector(bx.type_f64(), 2));
bx.extract_element(value, bx.const_usize(0))
) if let Primitive::Float(float @ (Float::F32 | Float::F64)) = s.primitive() => {
let num_lanes = 16 / float.size().bytes();
bx.extract_element(
value,
bx.const_usize(match bx.target_spec().endian {
Endian::Little => num_lanes - 1,
Endian::Big => 0,
}),
)
}
_ => value,
}
Expand Down Expand Up @@ -1566,11 +1558,9 @@ fn llvm_fixup_output_type<'ll, 'tcx>(
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F32) => cx.type_vector(cx.type_f32(), 4),
(
PowerPC(PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg),
BackendRepr::Scalar(s),
) if s.primitive() == Primitive::Float(Float::F64) => cx.type_vector(cx.type_f64(), 2),
) if let Primitive::Float(float @ (Float::F32 | Float::F64)) = s.primitive() => {
cx.type_vector(cx.type_from_float(float), 16 / float.size().bytes())
}
_ => layout.llvm_type(cx),
}
}
9 changes: 5 additions & 4 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
ptr_type: Ty<'tcx>,
pointee_type: Ty<'tcx>,
unique_type_id: UniqueTypeId<'tcx>,
span: Span,
) -> DINodeCreationResult<'ll> {
// The debuginfo generated by this function is only valid if `ptr_type` is really just
// a (wide) pointer. Make sure it is not called for e.g. `Box<T, NonZSTAllocator>`.
Expand All @@ -153,7 +154,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(

let pointee_type_di_node = match pointee_type.kind() {
// `&[T]` will look like `{ data_ptr: *const T, length: usize }`
ty::Slice(element_type) => type_di_node(cx, *element_type),
ty::Slice(element_type) => spanned_type_di_node(cx, *element_type, span),
// `&str` will look like `{ data_ptr: *const u8, length: usize }`
ty::Str => type_di_node(cx, cx.tcx.types.u8),

Expand All @@ -163,7 +164,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
// and thin pointers `&Foo` will just look like `*const Foo`.
//
// in all those cases, we just use the pointee_type
_ => type_di_node(cx, pointee_type),
_ => spanned_type_di_node(cx, pointee_type, span),
};

return_if_di_node_created_in_meantime!(cx, unique_type_id);
Expand Down Expand Up @@ -468,7 +469,7 @@ pub(crate) fn spanned_type_di_node<'ll, 'tcx>(
ty::Dynamic(..) => build_dyn_type_di_node(cx, t, unique_type_id),
ty::Foreign(..) => build_foreign_type_di_node(cx, t, unique_type_id),
ty::RawPtr(pointee_type, _) | ty::Ref(_, pointee_type, _) => {
build_pointer_or_reference_di_node(cx, t, pointee_type, unique_type_id)
build_pointer_or_reference_di_node(cx, t, pointee_type, unique_type_id, span)
}
// Some `Box` are newtyped pointers, make debuginfo aware of that.
// Only works if the allocator argument is a 1-ZST and hence irrelevant for layout
Expand All @@ -477,7 +478,7 @@ pub(crate) fn spanned_type_di_node<'ll, 'tcx>(
if def.is_box()
&& args.get(1).is_none_or(|arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
{
build_pointer_or_reference_di_node(cx, t, t.expect_boxed_ty(), unique_type_id)
build_pointer_or_reference_di_node(cx, t, t.expect_boxed_ty(), unique_type_id, span)
}
ty::FnDef(..) | ty::FnPtr(..) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'ll, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
let file_metadata = file_metadata(self, &loc.file);

let function_type_metadata =
create_subroutine_type(self, &get_function_signature(self, fn_abi));
create_subroutine_type(self, &get_function_signature(self, fn_abi, span));

let mut name = String::with_capacity(64);
type_names::push_item_name(tcx, def_id, false, &mut name);
Expand Down Expand Up @@ -233,6 +233,7 @@ impl<'ll, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
fn get_function_signature<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
span: Span,
) -> Vec<Option<&'ll llvm::Metadata>> {
if cx.sess().opts.debuginfo != DebugInfo::Full {
return vec![];
Expand All @@ -244,7 +245,7 @@ impl<'ll, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
signature.push(if fn_abi.ret.is_ignore() {
None
} else {
Some(type_di_node(cx, fn_abi.ret.layout.ty))
Some(spanned_type_di_node(cx, fn_abi.ret.layout.ty, span))
});

// Arguments types
Expand All @@ -269,11 +270,15 @@ impl<'ll, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
}
_ => t,
};
Some(type_di_node(cx, t))
Some(spanned_type_di_node(cx, t, span))
}));
} else {
signature
.extend(fn_abi.args.iter().map(|arg| Some(type_di_node(cx, arg.layout.ty))));
signature.extend(
fn_abi
.args
.iter()
.map(|arg| Some(spanned_type_di_node(cx, arg.layout.ty, span))),
);
}

signature
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
cfg.has_reliable_f16 = match (target_arch, target_os) {
// Unsupported <https://github.com/llvm/llvm-project/issues/94434> (fixed in llvm22)
(Arch::Arm64EC, _) if major < 22 => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054> resolved in GCC 16
// but our toolchain hasn't been updated.
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != CfgAbi::Llvm => {
false
}
Expand All @@ -401,8 +402,10 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
(Arch::PowerPC | Arch::PowerPC64, _) => false,
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838> (fixed in llvm22)
(Arch::Sparc, _) if major < 22 => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != CfgAbi::Llvm => {
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054> (fixed in llvm23)
(Arch::X86_64, Os::Windows)
if *target_env == Env::Gnu && *target_abi != CfgAbi::Llvm && major < 23 =>
{
false
}
// There are no known problems on other platforms, so the only requirement is that symbols
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
sym::size_of_val => {
let tp_ty = fn_args.type_at(0);
let (_, meta) = args[0].val.pointer_parts();
let (llsize, _) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);
let (llsize, _) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta, span);
OperandValue::Immediate(llsize)
}
sym::align_of_val => {
let tp_ty = fn_args.type_at(0);
let (_, meta) = args[0].val.pointer_parts();
let (_, llalign) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);
let (_, llalign) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta, span);
OperandValue::Immediate(llalign)
}
sym::vtable_size | sym::vtable_align => {
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rustc_middle::mir::interpret::Scalar;
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Ty};
use rustc_middle::{bug, mir};
use rustc_span::DUMMY_SP;
use tracing::{debug, instrument};

use super::operand::OperandValue;
Expand Down Expand Up @@ -227,8 +228,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {

let unaligned_offset = bx.cx().const_usize(offset.bytes());

// Get the alignment of the field
let (_, mut unsized_align) = size_of_val::size_and_align_of_dst(bx, field.ty, meta);
// Get the alignment of the field. No span is available here to blame a layout error on.
let (_, mut unsized_align) =
size_of_val::size_and_align_of_dst(bx, field.ty, meta, DUMMY_SP);

// For packed types, we need to cap alignment.
if let ty::Adt(def, _) = self.layout.ty.kind()
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_ssa/src/size_of_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_middle::ty::{self, Ty};
use rustc_span::DUMMY_SP;
use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, trace};

use crate::common::IntPredicate;
Expand All @@ -16,8 +16,9 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
t: Ty<'tcx>,
info: Option<Bx::Value>,
span: Span,
) -> (Bx::Value, Bx::Value) {
let layout = bx.layout_of(t);
let layout = bx.spanned_layout_of(t, span);
trace!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
if layout.is_sized() {
let size = bx.const_usize(layout.size.bytes());
Expand Down Expand Up @@ -107,7 +108,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// Recurse to get the size of the dynamically sized field (must be
// the last field).
let field_ty = layout.field(bx, i).ty;
let (unsized_size, mut unsized_align) = size_and_align_of_dst(bx, field_ty, info);
let (unsized_size, mut unsized_align) = size_and_align_of_dst(bx, field_ty, info, span);

// # First compute the dynamic alignment

Expand Down
Loading
Loading