Skip to content

Rollup of 10 pull requests #145601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ab19755
bufreader::Buffer::backshift: don't move the uninit bytes
lolbinarycat Aug 17, 2025
479e31e
Don't warn no-mentions on subtree updates
blyxyas Aug 17, 2025
8074d4f
Update rust maintainers in openharmony.md
huaihuaidelulu Aug 18, 2025
abcfa43
remove myself from some adhoc-groups and pings
davidtwco Aug 18, 2025
d417503
Allow stability attributes on extern crates
JonathanBrouwer Aug 18, 2025
e31aea8
Remove unused `PartialOrd`/`Ord` from bootstrap
Kobzol Aug 18, 2025
c335d57
ignore frontmatters in `TokenStream::new`
fee1-dead Aug 18, 2025
d2e1264
Add change tracker entry for `--timings`
jieyouxu Aug 18, 2025
dbb8190
Add VEXos "linked files" support to `armv7a-vex-v5`
lewisfm Aug 9, 2025
0e47f19
Specify linker scripts after user link args
lewisfm Aug 9, 2025
ebfac4e
Avoid using `()` in `derive(From)` output.
nnethercote Aug 18, 2025
bb4af94
Rollup merge of #145538 - lolbinarycat:std-bufreader-buffer-backshift…
jieyouxu Aug 19, 2025
c318e14
Rollup merge of #145542 - blyxyas:no-mentions-subtree, r=Urgau
jieyouxu Aug 19, 2025
cd597ae
Rollup merge of #145549 - huaihuaidelulu:patch-2, r=Amanieu,jieyouxu
jieyouxu Aug 19, 2025
e462a7d
Rollup merge of #145550 - nnethercote:derive_from-no-unit, r=Kobzol
jieyouxu Aug 19, 2025
9561591
Rollup merge of #145556 - JonathanBrouwer:extern-crate-stable, r=jdon…
jieyouxu Aug 19, 2025
07518a7
Rollup merge of #145560 - Kobzol:bootstrap-remove-ord, r=jieyouxu
jieyouxu Aug 19, 2025
3e1a63d
Rollup merge of #145568 - fee1-dead-contrib:push-uvsonuzxmkus, r=fmease
jieyouxu Aug 19, 2025
9d957a8
Rollup merge of #145571 - davidtwco:davidtwco-remove-from-groups, r=lqd
jieyouxu Aug 19, 2025
4a4247a
Rollup merge of #145576 - jieyouxu:bootstrap-timings, r=Kobzol
jieyouxu Aug 19, 2025
0811b16
Rollup merge of #145578 - vexide:armv7a-vex-v5+linked-files, r=davidtwco
jieyouxu Aug 19, 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: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/attributes/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Static),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::ExternCrate),
]);

#[derive(Default)]
Expand Down
71 changes: 36 additions & 35 deletions compiler/rustc_builtin_macros/src/deriving/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,39 @@ pub(crate) fn expand_deriving_from(
cx.dcx().bug("derive(From) used on something else than an item");
};

// #[derive(From)] is currently usable only on structs with exactly one field.
let field = if let ItemKind::Struct(_, _, data) = &item.kind
&& let [field] = data.fields()
{
Some(field.clone())
} else {
None
let err_span = || {
let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span);
MultiSpan::from_spans(vec![span, item_span])
};

let from_type = match &field {
Some(field) => Ty::AstTy(field.ty.clone()),
// We don't have a type to put into From<...> if we don't have a single field, so just put
// unit there.
None => Ty::Unit,
// `#[derive(From)]` is currently usable only on structs with exactly one field.
let field = match &item.kind {
ItemKind::Struct(_, _, data) => {
if let [field] = data.fields() {
Ok(field.clone())
} else {
let guar = cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
span: err_span(),
multiple_fields: data.fields().len() > 1,
});
Err(guar)
}
}
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
let guar = cx.dcx().emit_err(errors::DeriveFromWrongTarget {
span: err_span(),
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
});
Err(guar)
}
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
};

let from_type = Ty::AstTy(match field {
Ok(ref field) => field.ty.clone(),
Err(guar) => cx.ty(span, ast::TyKind::Err(guar)),
});

let path =
Path::new_(pathvec_std!(convert::From), vec![Box::new(from_type.clone())], PathKind::Std);

Expand Down Expand Up @@ -71,34 +89,17 @@ pub(crate) fn expand_deriving_from(
attributes: thin_vec![cx.attr_word(sym::inline, span)],
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
combine_substructure: combine_substructure(Box::new(|cx, span, substructure| {
let Some(field) = &field else {
let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span);
let err_span = MultiSpan::from_spans(vec![span, item_span]);
let error = match &item.kind {
ItemKind::Struct(_, _, data) => {
cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
span: err_span,
multiple_fields: data.fields().len() > 1,
})
}
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
cx.dcx().emit_err(errors::DeriveFromWrongTarget {
span: err_span,
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
})
}
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
};

return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(error)));
let field = match field {
Ok(ref field) => field,
Err(guar) => {
return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(guar)));
}
};

let self_kw = Ident::new(kw::SelfUpper, span);
let expr: Box<ast::Expr> = match substructure.fields {
SubstructureFields::StaticStruct(variant, _) => match variant {
// Self {
// field: value
// }
// Self { field: value }
VariantData::Struct { .. } => cx.expr_struct_ident(
span,
self_kw,
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,13 @@ fn linker_with_args(
// Passed after compiler-generated options to support manual overriding when necessary.
add_user_defined_link_args(cmd, sess);

// ------------ Builtin configurable linker scripts ------------
// The user's link args should be able to overwrite symbols in the compiler's
// linker script that were weakly defined (i.e. defined with `PROVIDE()`). For this
// to work correctly, the user needs to be able to specify linker arguments like
// `--defsym` and `--script` *before* any builtin linker scripts are evaluated.
add_link_script(cmd, sess, tmpdir, crate_type);

// ------------ Object code and libraries, order-dependent ------------

// Post-link CRT objects.
Expand Down Expand Up @@ -2469,8 +2476,6 @@ fn add_order_independent_options(

let apple_sdk_root = add_apple_sdk(cmd, sess, flavor);

add_link_script(cmd, sess, tmpdir, crate_type);

if sess.target.os == "fuchsia"
&& crate_type == CrateType::Executable
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ pub(crate) fn lex_token_trees<'psess, 'src>(
mut src: &'src str,
mut start_pos: BytePos,
override_span: Option<Span>,
frontmatter_allowed: FrontmatterAllowed,
) -> Result<TokenStream, Vec<Diag<'psess>>> {
// Skip `#!`, if present.
if let Some(shebang_len) = rustc_lexer::strip_shebang(src) {
src = &src[shebang_len..];
start_pos = start_pos + BytePos::from_usize(shebang_len);
}

let cursor = Cursor::new(src, FrontmatterAllowed::Yes);
let cursor = Cursor::new(src, frontmatter_allowed);
let mut lexer = Lexer {
psess,
start_pos,
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AttrItem, Attribute, MetaItemInner, token};
use rustc_ast_pretty::pprust;
use rustc_errors::{Diag, EmissionGuarantee, FatalError, PResult, pluralize};
use rustc_lexer::FrontmatterAllowed;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::SourceMap;
use rustc_span::{FileName, SourceFile, Span};
Expand Down Expand Up @@ -146,7 +147,7 @@ fn new_parser_from_source_file(
source_file: Arc<SourceFile>,
) -> Result<Parser<'_>, Vec<Diag<'_>>> {
let end_pos = source_file.end_position();
let stream = source_file_to_stream(psess, source_file, None)?;
let stream = source_file_to_stream(psess, source_file, None, FrontmatterAllowed::Yes)?;
let mut parser = Parser::new(psess, stream, None);
if parser.token == token::Eof {
parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None);
Expand All @@ -161,7 +162,9 @@ pub fn source_str_to_stream(
override_span: Option<Span>,
) -> Result<TokenStream, Vec<Diag<'_>>> {
let source_file = psess.source_map().new_source_file(name, source);
source_file_to_stream(psess, source_file, override_span)
// used mainly for `proc_macro` and the likes, not for our parsing purposes, so don't parse
// frontmatters as frontmatters.
source_file_to_stream(psess, source_file, override_span, FrontmatterAllowed::No)
}

/// Given a source file, produces a sequence of token trees. Returns any buffered errors from
Expand All @@ -170,6 +173,7 @@ fn source_file_to_stream<'psess>(
psess: &'psess ParseSess,
source_file: Arc<SourceFile>,
override_span: Option<Span>,
frontmatter_allowed: FrontmatterAllowed,
) -> Result<TokenStream, Vec<Diag<'psess>>> {
let src = source_file.src.as_ref().unwrap_or_else(|| {
psess.dcx().bug(format!(
Expand All @@ -178,7 +182,13 @@ fn source_file_to_stream<'psess>(
));
});

lexer::lex_token_trees(psess, src.as_str(), source_file.start_pos, override_span)
lexer::lex_token_trees(
psess,
src.as_str(),
source_file.start_pos,
override_span,
frontmatter_allowed,
)
}

/// Runs the given subparser `f` on the tokens of the given `attr`'s item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ PROVIDE(__vcodesig_type = 0); /* V5_SIG_TYPE_USER */
PROVIDE(__vcodesig_owner = 2); /* V5_SIG_OWNER_PARTNER */
PROVIDE(__vcodesig_options = 0); /* none (0) */

PROVIDE(__user_ram_start = 0x03800000);
PROVIDE(__user_ram_length = 48M);
PROVIDE(__user_ram_end = __user_ram_start + __user_ram_length); /* 0x8000000 */
__user_ram_start = 0x03800000;
__user_ram_end = 0x08000000;
/* (0x48 =) 72 MiB length */
__user_ram_length = __user_ram_start - __user_ram_end;

PROVIDE(__code_signature_length = 0x20);
/*
* VEXos provides a method for pre-loading a "linked file" at a specified
* address in User RAM, conventionally near the end, after the primary
* program binary. We need to be sure not to place any data in that location,
* so we allow the user of this linker script to inform the start address of
* this blob.
*/
PROVIDE(__linked_file_length = 0);
PROVIDE(__linked_file_end = __user_ram_end);
PROVIDE(__linked_file_start = __linked_file_end - __linked_file_length);

PROVIDE(__stack_length = 4M);
PROVIDE(__heap_end = __user_ram_end - __stack_length);
PROVIDE(__user_length = __heap_start - __user_ram_start);
PROVIDE(__stack_top = __linked_file_start);
PROVIDE(__stack_bottom = __linked_file_start - __stack_length);

MEMORY {
USER_RAM (RWX) : ORIGIN = __user_ram_start, LENGTH = __user_ram_length
Expand All @@ -44,7 +54,7 @@ SECTIONS {
LONG(__vcodesig_options)

FILL(0)
. = __user_ram_start + __code_signature_length;
. = __user_ram_start + 0x20;
} > USER_RAM

/*
Expand Down Expand Up @@ -125,7 +135,8 @@ SECTIONS {
*/
.heap (NOLOAD) : {
__heap_start = .;
. = __heap_end;
. = __stack_bottom;
__heap_end = .;
} > USER_RAM

.stack (NOLOAD) : ALIGN(8) {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/buffered/bufreader/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Buffer {

/// Remove bytes that have already been read from the buffer.
pub fn backshift(&mut self) {
self.buf.copy_within(self.pos.., 0);
self.buf.copy_within(self.pos..self.filled, 0);
self.filled -= self.pos;
self.pos = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{
};

/// Build a standard library for the given `target` using the given `build_compiler`.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Std {
pub target: TargetSelection,
/// Compiler that builds the standard library.
Expand Down Expand Up @@ -948,7 +948,7 @@ pub struct BuiltRustc {
/// so that it can compile build scripts and proc macros when building this `rustc`.
/// - Makes sure that `build_compiler` has a standard library prepared for `target`,
/// so that the built `rustc` can *link to it* and use it at runtime.
#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Rustc {
/// The target on which rustc will run (its host).
pub target: TargetSelection,
Expand Down Expand Up @@ -1959,7 +1959,7 @@ impl Step for Sysroot {
/// linker wrappers (LLD, LLVM bitcode linker, etc.).
///
/// This will assemble a compiler in `build/$target/stage$stage`.
#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Assemble {
/// The compiler which we will produce in this step. Assemble itself will
/// take care of ensuring that the necessary prerequisites to do so exist,
Expand Down
24 changes: 12 additions & 12 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool {
builder.config.tools.as_ref().is_none_or(|tools| tools.contains(tool))
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Docs {
pub host: TargetSelection,
}
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Step for Docs {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct JsonDocs {
build_compiler: Compiler,
target: TargetSelection,
Expand Down Expand Up @@ -354,7 +354,7 @@ fn get_cc_search_dirs(
(bin_path, lib_path)
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Mingw {
pub host: TargetSelection,
}
Expand Down Expand Up @@ -394,7 +394,7 @@ impl Step for Mingw {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Rustc {
pub compiler: Compiler,
}
Expand Down Expand Up @@ -730,7 +730,7 @@ fn copy_target_libs(
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Std {
pub compiler: Compiler,
pub target: TargetSelection,
Expand Down Expand Up @@ -785,7 +785,7 @@ impl Step for Std {
/// `rust.download-rustc`.
///
/// (Don't confuse this with [`RustDev`], without the `c`!)
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct RustcDev {
pub compiler: Compiler,
pub target: TargetSelection,
Expand Down Expand Up @@ -1026,7 +1026,7 @@ fn copy_src_dirs(
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Src;

impl Step for Src {
Expand Down Expand Up @@ -1087,7 +1087,7 @@ impl Step for Src {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct PlainSourceTarball;

impl Step for PlainSourceTarball {
Expand Down Expand Up @@ -1233,7 +1233,7 @@ impl Step for PlainSourceTarball {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Cargo {
pub build_compiler: Compiler,
pub target: TargetSelection,
Expand Down Expand Up @@ -1287,7 +1287,7 @@ impl Step for Cargo {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct RustAnalyzer {
pub build_compiler: Compiler,
pub target: TargetSelection,
Expand Down Expand Up @@ -1563,7 +1563,7 @@ impl Step for Rustfmt {
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Extended {
stage: u32,
host: TargetSelection,
Expand Down Expand Up @@ -2404,7 +2404,7 @@ impl Step for LlvmTools {

/// Distributes the `llvm-bitcode-linker` tool so that it can be used by a compiler whose host
/// is `target`.
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct LlvmBitcodeLinker {
/// The linker will be compiled by this compiler.
pub build_compiler: Compiler,
Expand Down
Loading
Loading