Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0bc6945
give a better example why `std` modules named like primitives are needed
cyrgani Oct 5, 2025
a11fe5d
Add diagnostic items for `pub mod consts` of FP types
samueltardieu Oct 6, 2025
03cdcb5
bootstrap: add `Builder::rustc_cmd` that includes the lib path
cuviper Oct 6, 2025
594f9c6
Clarify how to remediate the panic_immediate_abort error
ia0 Oct 8, 2025
973ddd8
Do not invalidate CFG caches in CtfeLimit.
cjgillot Oct 8, 2025
d4ecd71
format: some small cleanup
hkBst Oct 8, 2025
45ca537
Port the Miri implementations of SIMD intrinsics to `rustc_const_eval`
sayantn Oct 8, 2025
730221e
Fix double error for `#[no_mangle]` on closures
JonathanBrouwer Oct 8, 2025
c050bfb
Fix double error for `#[no_mangle]` on consts
JonathanBrouwer Oct 8, 2025
1654cce
prefer to use repeat_n over repeat and take
chenyukang Oct 8, 2025
affaf53
referring to repeat_n in std::iter::repeat
chenyukang Oct 8, 2025
53c79f4
bless format
chenyukang Oct 8, 2025
99ab27f
specialize slice::fill to use memset when possible
the8472 Oct 3, 2025
036ab3a
refactor: Remove `LLVMRustInsertPrivateGlobal` and `define_private_gl…
AMS21 Oct 8, 2025
8f08156
compiletest: Isolate APIs used by rustdoc-gui-test
Zalathar Oct 9, 2025
b4f64fd
compiletest: Isolate APIs used by `bin/main.rs`
Zalathar Oct 9, 2025
ce4699d
compiletest: Make all other modules non-public
Zalathar Oct 9, 2025
fd6546d
Rollup merge of #146568 - sayantn:simd-shuffle, r=RalfJung
Zalathar Oct 9, 2025
800bc95
Rollup merge of #147373 - cyrgani:cyrgani-patch-1, r=ibraheemdev
Zalathar Oct 9, 2025
68f9b3b
Rollup merge of #147419 - cuviper:bootstrap-rustc-libs, r=Zalathar,ji…
Zalathar Oct 9, 2025
473a74a
Rollup merge of #147420 - samueltardieu:diag-items/consts-mod, r=joboet
Zalathar Oct 9, 2025
4e3e7ce
Rollup merge of #147457 - the8472:slice_fill_memset2, r=RalfJung,joboet
Zalathar Oct 9, 2025
216be29
Rollup merge of #147467 - JonathanBrouwer:double_warnings, r=Jonathan…
Zalathar Oct 9, 2025
8e363d3
Rollup merge of #147470 - ia0:immediate-abort, r=Mark-Simulacrum
Zalathar Oct 9, 2025
18d470e
Rollup merge of #147480 - cjgillot:invalidate-ctfelimit, r=tmiasko
Zalathar Oct 9, 2025
8fd2a12
Rollup merge of #147481 - hkBst:format-1, r=jackh726
Zalathar Oct 9, 2025
4dfd977
Rollup merge of #147488 - AMS21:remove_llvm_rust_insert_private_globa…
Zalathar Oct 9, 2025
9ace0de
Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooe…
Zalathar Oct 9, 2025
76d4f37
Rollup merge of #147506 - Zalathar:isolate, r=jieyouxu
Zalathar Oct 9, 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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4805,7 +4805,6 @@ name = "rustdoc-gui-test"
version = "0.1.0"
dependencies = [
"build_helper",
"camino",
"compiletest",
"getopts",
"walkdir",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,11 +881,11 @@ impl Token {
}

pub fn is_qpath_start(&self) -> bool {
self == &Lt || self == &Shl
matches!(self.kind, Lt | Shl)
}

pub fn is_path_start(&self) -> bool {
self == &PathSep
self.kind == PathSep
|| self.is_qpath_start()
|| matches!(self.is_metavar_seq(), Some(MetaVarKind::Path))
|| self.is_path_segment_keyword()
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::session_diagnostics::{
NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass, NullOnObjcSelector,
ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
};
use crate::target_checking::Policy::AllowSilent;

pub(crate) struct OptimizeParser;

Expand Down Expand Up @@ -362,6 +363,8 @@ impl<S: Stage> NoArgsAttributeParser<S> for NoMangleParser {
Allow(Target::Static),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::TraitImpl)),
AllowSilent(Target::Const), // Handled in the `InvalidNoMangleItems` pass
Error(Target::Closure),
]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoMangle;
}
Expand Down
17 changes: 15 additions & 2 deletions compiler/rustc_attr_parsing/src/target_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ impl AllowedTargets {
pub(crate) fn is_allowed(&self, target: Target) -> AllowedResult {
match self {
AllowedTargets::AllowList(list) => {
if list.contains(&Policy::Allow(target)) {
if list.contains(&Policy::Allow(target))
|| list.contains(&Policy::AllowSilent(target))
{
AllowedResult::Allowed
} else if list.contains(&Policy::Warn(target)) {
AllowedResult::Warn
Expand All @@ -40,7 +42,9 @@ impl AllowedTargets {
}
}
AllowedTargets::AllowListWarnRest(list) => {
if list.contains(&Policy::Allow(target)) {
if list.contains(&Policy::Allow(target))
|| list.contains(&Policy::AllowSilent(target))
{
AllowedResult::Allowed
} else if list.contains(&Policy::Error(target)) {
AllowedResult::Error
Expand All @@ -61,17 +65,26 @@ impl AllowedTargets {
.iter()
.filter_map(|target| match target {
Policy::Allow(target) => Some(*target),
Policy::AllowSilent(_) => None, // Not listed in possible targets
Policy::Warn(_) => None,
Policy::Error(_) => None,
})
.collect()
}
}

/// This policy determines what diagnostics should be emitted based on the `Target` of the attribute.
#[derive(Debug, Eq, PartialEq)]
pub(crate) enum Policy {
/// A target that is allowed.
Allow(Target),
/// A target that is allowed and not listed in the possible targets.
/// This is useful if the target is checked elsewhere.
AllowSilent(Target),
/// Emits a FCW on this target.
/// This is useful if the target was previously allowed but should not be.
Warn(Target),
/// Emits an error on this target.
Error(Target),
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ fn expand_preparsed_asm(
if args.options.contains(ast::InlineAsmOptions::RAW) {
template.push(ast::InlineAsmTemplatePiece::String(template_str.to_string().into()));
let template_num_lines = 1 + template_str.matches('\n').count();
line_spans.extend(std::iter::repeat(template_sp).take(template_num_lines));
line_spans.extend(std::iter::repeat_n(template_sp, template_num_lines));
continue;
}

Expand Down Expand Up @@ -523,7 +523,7 @@ fn expand_preparsed_asm(

if parser.line_spans.is_empty() {
let template_num_lines = 1 + template_str.matches('\n').count();
line_spans.extend(std::iter::repeat(template_sp).take(template_num_lines));
line_spans.extend(std::iter::repeat_n(template_sp, template_num_lines));
} else {
line_spans.extend(
parser
Expand Down
37 changes: 17 additions & 20 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,26 @@ struct MacroInput {
/// Ok((fmtstr, parsed arguments))
/// ```
fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
let mut args = FormatArguments::new();

let mut p = ecx.new_parser_from_tts(tts);

if p.token == token::Eof {
return Err(ecx.dcx().create_err(errors::FormatRequiresString { span: sp }));
}

let first_token = &p.token;

let fmtstr = if let token::Literal(lit) = first_token.kind
&& matches!(lit.kind, token::Str | token::StrRaw(_))
{
// parse the format string
let fmtstr = match p.token.kind {
token::Eof => return Err(ecx.dcx().create_err(errors::FormatRequiresString { span: sp })),
// This allows us to properly handle cases when the first comma
// after the format string is mistakenly replaced with any operator,
// which cause the expression parser to eat too much tokens.
p.parse_literal_maybe_minus()?
} else {
token::Literal(token::Lit { kind: token::Str | token::StrRaw(_), .. }) => {
p.parse_literal_maybe_minus()?
}
// Otherwise, we fall back to the expression parser.
p.parse_expr()?
_ => p.parse_expr()?,
};

// Only allow implicit captures to be used when the argument is a direct literal
// instead of a macro expanding to one.
let is_direct_literal = matches!(fmtstr.kind, ExprKind::Lit(_));

// parse comma FormatArgument pairs
let mut args = FormatArguments::new();
let mut first = true;

while p.token != token::Eof {
// parse a comma, or else report an error
if !p.eat(exp!(Comma)) {
if first {
p.clear_expected_token_types();
Expand All @@ -120,9 +111,11 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
}
}
first = false;
// accept a trailing comma
if p.token == token::Eof {
break;
} // accept trailing commas
}
// parse a FormatArgument
match p.token.ident() {
Some((ident, _)) if p.look_ahead(1, |t| *t == token::Eq) => {
p.bump();
Expand Down Expand Up @@ -156,6 +149,10 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
}
}
}

// Only allow implicit captures for direct literals
let is_direct_literal = matches!(fmtstr.kind, ExprKind::Lit(_));

Ok(MacroInput { fmtstr, args, is_direct_literal })
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ fn data_id_for_static(
let mut data = DataDescription::new();
data.set_align(align);
let data_gv = module.declare_data_in_data(data_id, &mut data);
data.define(std::iter::repeat(0).take(pointer_ty(tcx).bytes() as usize).collect());
data.define(std::iter::repeat_n(0, pointer_ty(tcx).bytes() as usize).collect());
data.write_data_addr(0, data_gv, 0);
match module.define_data(ref_data_id, &data) {
// Every time the static is referenced there will be another definition of this global,
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ impl<'ll> CodegenCx<'ll, '_> {
let gv = self.define_global(&name, self.val_ty(cv)).unwrap_or_else(|| {
bug!("symbol `{}` is already defined", name);
});
llvm::set_linkage(gv, llvm::Linkage::PrivateLinkage);
gv
}
_ => self.define_private_global(self.val_ty(cv)),
_ => self.define_global("", self.val_ty(cv)).unwrap_or_else(|| {
bug!("anonymous global symbol is already defined");
}),
};
llvm::set_linkage(gv, llvm::Linkage::PrivateLinkage);
llvm::set_initializer(gv, cv);
set_global_alignment(self, gv, align);
llvm::set_unnamed_address(gv, llvm::UnnamedAddr::Global);
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_llvm/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
}
}

/// Declare a private global
///
/// Use this function when you intend to define a global without a name.
pub(crate) fn define_private_global(&self, ty: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMRustInsertPrivateGlobal(self.llmod(), ty) }
}

/// Gets declared value by name.
pub(crate) fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
debug!("get_declared_value(name={:?})", name);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,6 @@ unsafe extern "C" {
NameLen: size_t,
T: &'a Type,
) -> &'a Value;
pub(crate) fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
pub(crate) fn LLVMRustGetNamedValue(
M: &Module,
Name: *const c_char,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple time
codegen_ssa_no_field = no field `{$name}`
codegen_ssa_no_mangle_nameless = `#[no_mangle]` cannot be used on {$definition} as it has no name
codegen_ssa_no_module_named =
no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
Expand Down
13 changes: 4 additions & 9 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use rustc_span::{Ident, Span, sym};
use rustc_target::spec::SanitizerSet;

use crate::errors;
use crate::errors::NoMangleNameless;
use crate::target_features::{
check_target_feature_trait_unsafe, check_tied_features, from_target_feature_attr,
};
Expand Down Expand Up @@ -182,14 +181,10 @@ fn process_builtin_attrs(
if tcx.opt_item_name(did.to_def_id()).is_some() {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
} else {
tcx.dcx().emit_err(NoMangleNameless {
span: *attr_span,
definition: format!(
"{} {}",
tcx.def_descr_article(did.to_def_id()),
tcx.def_descr(did.to_def_id())
),
});
tcx.dcx().span_delayed_bug(
*attr_span,
"no_mangle should be on a named function",
);
}
}
AttributeKind::Optimize(optimize, _) => codegen_fn_attrs.optimize = *optimize,
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,14 +1284,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_
}
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_no_mangle_nameless)]
pub(crate) struct NoMangleNameless {
#[primary_span]
pub span: Span,
pub definition: String,
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_feature_not_valid)]
pub(crate) struct FeatureNotValid<'a> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/const_eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn get_span_and_frames<'tcx>(
if frame.times < 3 {
let times = frame.times;
frame.times = 0;
frames.extend(std::iter::repeat(frame).take(times as usize));
frames.extend(std::iter::repeat_n(frame, times as usize));
} else {
frames.push(frame);
}
Expand Down
Loading
Loading