Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4acf3ba
libtest: expose --fail-fast
sourcefrog Jun 20, 2025
547c729
Make fail-fast unstable
sourcefrog Jun 20, 2025
b5a4e5d
remove gates
Kivooeo Aug 3, 2025
9fd57df
add tests, some with incorrect lifetime extension behavior
dianne Aug 13, 2025
0976d6c
don't extend non-extended `super let` initializers' block tail temps
dianne Aug 25, 2025
d5b5a4a
additional tests
dianne Aug 25, 2025
1ebf69d
initial implementation of the darwin_objc unstable feature
jbatez Jun 5, 2025
9405e76
Detect attempt to use var-args in closure
estebank Sep 15, 2025
0e290e4
Silence inference error on `PatKind::Err`
estebank Sep 15, 2025
a84c8de
Fix existing test
estebank Sep 15, 2025
53b58b3
tests/run-make: Update list of statically linked musl targets
Gelbpunkt Sep 15, 2025
fa7e474
remove FIXME from `has_significant_drop`, replaced with checking non_…
tnuha Sep 15, 2025
d66fb49
Suggest removing Box::new
camsteffen Sep 6, 2025
c89b6a9
Iterator repeat: no infinite loop for `last` and `count`
hkBst Sep 10, 2025
c916e88
fmt
estebank Sep 16, 2025
ed85f98
remove redundant test
estebank Sep 16, 2025
8306a2f
Reword note
estebank Sep 16, 2025
e9270e3
Detect top-level `...` in argument type
estebank Sep 16, 2025
580b489
Update the minimum external LLVM to 20
cuviper Aug 7, 2025
e54602c
Merge similar output checks in assembly-llvm/x86_64-cmp
cuviper Aug 8, 2025
88bef49
Update the FIXME comments in the generic three_way_compare
cuviper Aug 8, 2025
d81872a
add Readme.md to tidy
simp4t7 Sep 12, 2025
53b91ea
Remove Rvalue::Len.
cjgillot Sep 14, 2025
f018b46
Update docs.
cjgillot Sep 16, 2025
de73af9
Add test.
cjgillot Sep 16, 2025
40d879a
Add test.
cjgillot Sep 14, 2025
fe3a784
Do not renumber resume local.
cjgillot Sep 14, 2025
eddd755
Bless ui.
cjgillot Sep 16, 2025
5419896
Use `LLVMDIBuilderCreateSubroutineType`
Zalathar Sep 16, 2025
2552deb
Use `LLVMDIBuilderCreateUnionType`
Zalathar Sep 16, 2025
bef8f64
Use `LLVMDIBuilderCreateArrayType`
Zalathar Sep 16, 2025
3e9048d
Use `LLVMDIBuilderCreateBasicType`
Zalathar Sep 16, 2025
bae6fde
Use `LLVMDIBuilderCreatePointerType`
Zalathar Sep 16, 2025
af88d14
Use `LLVMDIBuilderCreateStructType`
Zalathar Sep 16, 2025
9d93fab
Rollup merge of #142807 - sourcefrog:failfast, r=dtolnay
Zalathar Sep 17, 2025
feeb68e
Rollup merge of #144871 - Kivooeo:btree_entry_insert-stabilize, r=jhp…
Zalathar Sep 17, 2025
f104ecf
Rollup merge of #145071 - cuviper:min-llvm-20, r=nikic
Zalathar Sep 17, 2025
f21a9c9
Rollup merge of #145181 - Borgerr:remove-fixme-from-has-sigdrop, r=lcnr
Zalathar Sep 17, 2025
6ad9875
Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,…
Zalathar Sep 17, 2025
c2e8264
Rollup merge of #145838 - dianne:non-extending-super-let, r=jackh726,…
Zalathar Sep 17, 2025
79f8acb
Rollup merge of #146259 - camsteffen:remove-the-box, r=jackh726
Zalathar Sep 17, 2025
cefd932
Rollup merge of #146410 - hkBst:repeat-1, r=jhpratt
Zalathar Sep 17, 2025
c7af12e
Rollup merge of #146460 - simp4t7:add-tidy-readme, r=clubby789
Zalathar Sep 17, 2025
577f18f
Rollup merge of #146552 - cjgillot:resume-noremap, r=jackh726
Zalathar Sep 17, 2025
6473a0f
Rollup merge of #146564 - cjgillot:mir-nolen, r=scottmcm
Zalathar Sep 17, 2025
61f5358
Rollup merge of #146581 - estebank:issue-146489, r=lcnr
Zalathar Sep 17, 2025
76f1159
Rollup merge of #146588 - Gelbpunkt:musl-default-linking-test, r=jiey…
Zalathar Sep 17, 2025
4e6640b
Rollup merge of #146631 - Zalathar:di-builder, r=nnethercote
Zalathar Sep 17, 2025
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
8 changes: 8 additions & 0 deletions compiler/rustc_attr_parsing/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ attr_parsing_null_on_export = `export_name` may not contain null characters

attr_parsing_null_on_link_section = `link_section` may not contain null characters

attr_parsing_null_on_objc_class = `objc::class!` may not contain null characters

attr_parsing_null_on_objc_selector = `objc::selector!` may not contain null characters

attr_parsing_objc_class_expected_string_literal = `objc::class!` expected a string literal

attr_parsing_objc_selector_expected_string_literal = `objc::selector!` expected a string literal

attr_parsing_repr_ident =
meta item in `repr` must be an identifier

Expand Down
69 changes: 68 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use rustc_hir::attrs::{CoverageAttrKind, OptimizeAttr, SanitizerSet, UsedBy};
use rustc_session::parse::feature_err;

use super::prelude::*;
use crate::session_diagnostics::{NakedFunctionIncompatibleAttribute, NullOnExport};
use crate::session_diagnostics::{
NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass, NullOnObjcSelector,
ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
};

pub(crate) struct OptimizeParser;

Expand Down Expand Up @@ -150,6 +153,70 @@ impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
}
}

pub(crate) struct ObjcClassParser;

impl<S: Stage> SingleAttributeParser<S> for ObjcClassParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_class];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "ClassName");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(cx.attr_span, None);
return None;
};
let Some(classname) = nv.value_as_str() else {
// `#[rustc_objc_class = ...]` is expected to be used as an implementatioin detail
// inside a standard library macro, but `cx.expected_string_literal` exposes too much.
// Use a custom error message instead.
cx.emit_err(ObjcClassExpectedStringLiteral { span: nv.value_span });
return None;
};
if classname.as_str().contains('\0') {
// `#[rustc_objc_class = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
cx.emit_err(NullOnObjcClass { span: nv.value_span });
return None;
}
Some(AttributeKind::ObjcClass { classname, span: cx.attr_span })
}
}

pub(crate) struct ObjcSelectorParser;

impl<S: Stage> SingleAttributeParser<S> for ObjcSelectorParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_selector];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "methodName");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(cx.attr_span, None);
return None;
};
let Some(methname) = nv.value_as_str() else {
// `#[rustc_objc_selector = ...]` is expected to be used as an implementatioin detail
// inside a standard library macro, but `cx.expected_string_literal` exposes too much.
// Use a custom error message instead.
cx.emit_err(ObjcSelectorExpectedStringLiteral { span: nv.value_span });
return None;
};
if methname.as_str().contains('\0') {
// `#[rustc_objc_selector = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
cx.emit_err(NullOnObjcSelector { span: nv.value_span });
return None;
}
Some(AttributeKind::ObjcSelector { methname, span: cx.attr_span })
}
}

#[derive(Default)]
pub(crate) struct NakedParser {
span: Option<Span>,
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::attributes::allow_unstable::{
use crate::attributes::body::CoroutineParser;
use crate::attributes::codegen_attrs::{
ColdParser, CoverageParser, ExportNameParser, ForceTargetFeatureParser, NakedParser,
NoMangleParser, OptimizeParser, SanitizeParser, TargetFeatureParser, TrackCallerParser,
UsedParser,
NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser, SanitizeParser,
TargetFeatureParser, TrackCallerParser, UsedParser,
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::crate_level::{
Expand Down Expand Up @@ -185,6 +185,8 @@ attribute_parsers!(
Single<LinkageParser>,
Single<MoveSizeLimitParser>,
Single<MustUseParser>,
Single<ObjcClassParser>,
Single<ObjcSelectorParser>,
Single<OptimizeParser>,
Single<PathAttributeParser>,
Single<PatternComplexityLimitParser>,
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,34 @@ pub(crate) struct NullOnLinkSection {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_null_on_objc_class)]
pub(crate) struct NullOnObjcClass {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_null_on_objc_selector)]
pub(crate) struct NullOnObjcSelector {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_objc_class_expected_string_literal)]
pub(crate) struct ObjcClassExpectedStringLiteral {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_objc_selector_expected_string_literal)]
pub(crate) struct ObjcSelectorExpectedStringLiteral {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_stability_outside_std, code = E0734)]
pub(crate) struct StabilityOutsideStd {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
);
}

&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
&Rvalue::Discriminant(place) => {
let af = match *rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,11 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
self.consume_operand(location, op);
}

&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
let af = match rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
&Rvalue::Discriminant(place) => {
self.access_place(
location,
place,
(Shallow(af), Read(ReadKind::Copy)),
(Shallow(None), Read(ReadKind::Copy)),
LocalMutationIsAllowed::No,
);
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
| Rvalue::BinaryOp(..)
| Rvalue::RawPtr(..)
| Rvalue::ThreadLocalRef(..)
| Rvalue::Len(..)
| Rvalue::Discriminant(..)
| Rvalue::NullaryOp(NullOp::OffsetOf(..), _) => {}
}
Expand Down Expand Up @@ -2201,7 +2200,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
| Rvalue::Repeat(..)
| Rvalue::Ref(..)
| Rvalue::RawPtr(..)
| Rvalue::Len(..)
| Rvalue::Cast(..)
| Rvalue::ShallowInitBox(..)
| Rvalue::BinaryOp(..)
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
fx.bcx.ins().nop();
}
}
Rvalue::Len(place) => {
let place = codegen_place(fx, place);
let usize_layout = fx.layout_of(fx.tcx.types.usize);
let len = codegen_array_len(fx, place);
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
}
Rvalue::ShallowInitBox(ref operand, content_ty) => {
let content_ty = fx.monomorphize(content_ty);
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
Expand Down
24 changes: 21 additions & 3 deletions compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,36 @@ pub(crate) fn compile_codegen_unit(
attributes::apply_to_llfn(entry, llvm::AttributePlace::Function, &attrs);
}

// Define Objective-C module info and module flags. Note, the module info will
// also be added to the `llvm.compiler.used` variable, created later.
//
// These are only necessary when we need the linker to do its Objective-C-specific
// magic. We could theoretically do it unconditionally, but at a slight cost to linker
// performance in the common case where it's unnecessary.
if !cx.objc_classrefs.borrow().is_empty() || !cx.objc_selrefs.borrow().is_empty() {
if cx.objc_abi_version() == 1 {
cx.define_objc_module_info();
}
cx.add_objc_module_flags();
}

// Finalize code coverage by injecting the coverage map. Note, the coverage map will
// also be added to the `llvm.compiler.used` variable, created next.
if cx.sess().instrument_coverage() {
cx.coverageinfo_finalize();
}

// Create the llvm.used and llvm.compiler.used variables.
// Create the llvm.used variable.
if !cx.used_statics.is_empty() {
cx.create_used_variable_impl(c"llvm.used", &cx.used_statics);
}
if !cx.compiler_used_statics.is_empty() {
cx.create_used_variable_impl(c"llvm.compiler.used", &cx.compiler_used_statics);

// Create the llvm.compiler.used variable.
{
let compiler_used_statics = cx.compiler_used_statics.borrow();
if !compiler_used_statics.is_empty() {
cx.create_used_variable_impl(c"llvm.compiler.used", &compiler_used_statics);
}
}

// Run replace-all-uses-with for statics that need it. This must
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,16 +1091,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
ty: Ty<'tcx>,
lhs: Self::Value,
rhs: Self::Value,
) -> Option<Self::Value> {
// FIXME: See comment on the definition of `three_way_compare`.
if crate::llvm_util::get_version() < (20, 0, 0) {
return None;
}

) -> Self::Value {
let size = ty.primitive_size(self.tcx);
let name = if ty.is_signed() { "llvm.scmp" } else { "llvm.ucmp" };

Some(self.call_intrinsic(name, &[self.type_i8(), self.type_ix(size.bits())], &[lhs, rhs]))
self.call_intrinsic(name, &[self.type_i8(), self.type_ix(size.bits())], &[lhs, rhs])
}

/* Miscellaneous instructions */
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
bytes_in_context(self.llcx(), bytes)
}

pub(crate) fn null_terminate_const_bytes(&self, bytes: &[u8]) -> &'ll Value {
null_terminate_bytes_in_context(self.llcx(), bytes)
}

pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
unsafe {
let idx = c_uint::try_from(idx).expect("LLVMGetAggregateElement index overflow");
Expand Down Expand Up @@ -381,6 +385,16 @@ pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &
}
}

pub(crate) fn null_terminate_bytes_in_context<'ll>(
llcx: &'ll llvm::Context,
bytes: &[u8],
) -> &'ll Value {
unsafe {
let ptr = bytes.as_ptr() as *const c_char;
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), FALSE)
}
}

pub(crate) fn named_struct<'ll>(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
let len = c_uint::try_from(elts.len()).expect("LLVMConstStructInContext elements len overflow");
unsafe { llvm::LLVMConstNamedStruct(ty, elts.as_ptr(), len) }
Expand Down
Loading
Loading