Skip to content

Commit f605b57

Browse files
committed
Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxu
Rollup of 10 pull requests Successful merges: - #145538 (bufreader::Buffer::backshift: don't move the uninit bytes) - #145542 (triagebot: Don't warn no-mentions on subtree updates) - #145549 (Update rust maintainers in openharmony.md) - #145550 (Avoid using `()` in `derive(From)` output.) - #145556 (Allow stability attributes on extern crates) - #145560 (Remove unused `PartialOrd`/`Ord` from bootstrap) - #145568 (ignore frontmatters in `TokenStream::new`) - #145571 (remove myself from some adhoc-groups and pings) - #145576 (Add change tracker entry for `--timings`) - #145578 (Add VEXos "linked files" support to `armv7a-vex-v5`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 05f5a58 + 0811b16 commit f605b57

File tree

22 files changed

+127
-133
lines changed

22 files changed

+127
-133
lines changed

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
5454
Allow(Target::Static),
5555
Allow(Target::ForeignFn),
5656
Allow(Target::ForeignStatic),
57+
Allow(Target::ExternCrate),
5758
]);
5859

5960
#[derive(Default)]

compiler/rustc_builtin_macros/src/deriving/from.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,39 @@ pub(crate) fn expand_deriving_from(
2727
cx.dcx().bug("derive(From) used on something else than an item");
2828
};
2929

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

39-
let from_type = match &field {
40-
Some(field) => Ty::AstTy(field.ty.clone()),
41-
// We don't have a type to put into From<...> if we don't have a single field, so just put
42-
// unit there.
43-
None => Ty::Unit,
35+
// `#[derive(From)]` is currently usable only on structs with exactly one field.
36+
let field = match &item.kind {
37+
ItemKind::Struct(_, _, data) => {
38+
if let [field] = data.fields() {
39+
Ok(field.clone())
40+
} else {
41+
let guar = cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
42+
span: err_span(),
43+
multiple_fields: data.fields().len() > 1,
44+
});
45+
Err(guar)
46+
}
47+
}
48+
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
49+
let guar = cx.dcx().emit_err(errors::DeriveFromWrongTarget {
50+
span: err_span(),
51+
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
52+
});
53+
Err(guar)
54+
}
55+
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
4456
};
57+
58+
let from_type = Ty::AstTy(match field {
59+
Ok(ref field) => field.ty.clone(),
60+
Err(guar) => cx.ty(span, ast::TyKind::Err(guar)),
61+
});
62+
4563
let path =
4664
Path::new_(pathvec_std!(convert::From), vec![Box::new(from_type.clone())], PathKind::Std);
4765

@@ -71,34 +89,17 @@ pub(crate) fn expand_deriving_from(
7189
attributes: thin_vec![cx.attr_word(sym::inline, span)],
7290
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
7391
combine_substructure: combine_substructure(Box::new(|cx, span, substructure| {
74-
let Some(field) = &field else {
75-
let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span);
76-
let err_span = MultiSpan::from_spans(vec![span, item_span]);
77-
let error = match &item.kind {
78-
ItemKind::Struct(_, _, data) => {
79-
cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
80-
span: err_span,
81-
multiple_fields: data.fields().len() > 1,
82-
})
83-
}
84-
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
85-
cx.dcx().emit_err(errors::DeriveFromWrongTarget {
86-
span: err_span,
87-
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
88-
})
89-
}
90-
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
91-
};
92-
93-
return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(error)));
92+
let field = match field {
93+
Ok(ref field) => field,
94+
Err(guar) => {
95+
return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(guar)));
96+
}
9497
};
9598

9699
let self_kw = Ident::new(kw::SelfUpper, span);
97100
let expr: Box<ast::Expr> = match substructure.fields {
98101
SubstructureFields::StaticStruct(variant, _) => match variant {
99-
// Self {
100-
// field: value
101-
// }
102+
// Self { field: value }
102103
VariantData::Struct { .. } => cx.expr_struct_ident(
103104
span,
104105
self_kw,

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,13 @@ fn linker_with_args(
24352435
// Passed after compiler-generated options to support manual overriding when necessary.
24362436
add_user_defined_link_args(cmd, sess);
24372437

2438+
// ------------ Builtin configurable linker scripts ------------
2439+
// The user's link args should be able to overwrite symbols in the compiler's
2440+
// linker script that were weakly defined (i.e. defined with `PROVIDE()`). For this
2441+
// to work correctly, the user needs to be able to specify linker arguments like
2442+
// `--defsym` and `--script` *before* any builtin linker scripts are evaluated.
2443+
add_link_script(cmd, sess, tmpdir, crate_type);
2444+
24382445
// ------------ Object code and libraries, order-dependent ------------
24392446

24402447
// Post-link CRT objects.
@@ -2469,8 +2476,6 @@ fn add_order_independent_options(
24692476

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

2472-
add_link_script(cmd, sess, tmpdir, crate_type);
2473-
24742479
if sess.target.os == "fuchsia"
24752480
&& crate_type == CrateType::Executable
24762481
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ pub(crate) fn lex_token_trees<'psess, 'src>(
4949
mut src: &'src str,
5050
mut start_pos: BytePos,
5151
override_span: Option<Span>,
52+
frontmatter_allowed: FrontmatterAllowed,
5253
) -> Result<TokenStream, Vec<Diag<'psess>>> {
5354
// Skip `#!`, if present.
5455
if let Some(shebang_len) = rustc_lexer::strip_shebang(src) {
5556
src = &src[shebang_len..];
5657
start_pos = start_pos + BytePos::from_usize(shebang_len);
5758
}
5859

59-
let cursor = Cursor::new(src, FrontmatterAllowed::Yes);
60+
let cursor = Cursor::new(src, frontmatter_allowed);
6061
let mut lexer = Lexer {
6162
psess,
6263
start_pos,

compiler/rustc_parse/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_ast::tokenstream::TokenStream;
2020
use rustc_ast::{AttrItem, Attribute, MetaItemInner, token};
2121
use rustc_ast_pretty::pprust;
2222
use rustc_errors::{Diag, EmissionGuarantee, FatalError, PResult, pluralize};
23+
use rustc_lexer::FrontmatterAllowed;
2324
use rustc_session::parse::ParseSess;
2425
use rustc_span::source_map::SourceMap;
2526
use rustc_span::{FileName, SourceFile, Span};
@@ -146,7 +147,7 @@ fn new_parser_from_source_file(
146147
source_file: Arc<SourceFile>,
147148
) -> Result<Parser<'_>, Vec<Diag<'_>>> {
148149
let end_pos = source_file.end_position();
149-
let stream = source_file_to_stream(psess, source_file, None)?;
150+
let stream = source_file_to_stream(psess, source_file, None, FrontmatterAllowed::Yes)?;
150151
let mut parser = Parser::new(psess, stream, None);
151152
if parser.token == token::Eof {
152153
parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None);
@@ -161,7 +162,9 @@ pub fn source_str_to_stream(
161162
override_span: Option<Span>,
162163
) -> Result<TokenStream, Vec<Diag<'_>>> {
163164
let source_file = psess.source_map().new_source_file(name, source);
164-
source_file_to_stream(psess, source_file, override_span)
165+
// used mainly for `proc_macro` and the likes, not for our parsing purposes, so don't parse
166+
// frontmatters as frontmatters.
167+
source_file_to_stream(psess, source_file, override_span, FrontmatterAllowed::No)
165168
}
166169

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

181-
lexer::lex_token_trees(psess, src.as_str(), source_file.start_pos, override_span)
185+
lexer::lex_token_trees(
186+
psess,
187+
src.as_str(),
188+
source_file.start_pos,
189+
override_span,
190+
frontmatter_allowed,
191+
)
182192
}
183193

184194
/// Runs the given subparser `f` on the tokens of the given `attr`'s item.

compiler/rustc_target/src/spec/targets/armv7a_vex_v5_linker_script.ld

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ PROVIDE(__vcodesig_type = 0); /* V5_SIG_TYPE_USER */
1717
PROVIDE(__vcodesig_owner = 2); /* V5_SIG_OWNER_PARTNER */
1818
PROVIDE(__vcodesig_options = 0); /* none (0) */
1919

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

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

2636
PROVIDE(__stack_length = 4M);
27-
PROVIDE(__heap_end = __user_ram_end - __stack_length);
28-
PROVIDE(__user_length = __heap_start - __user_ram_start);
37+
PROVIDE(__stack_top = __linked_file_start);
38+
PROVIDE(__stack_bottom = __linked_file_start - __stack_length);
2939

3040
MEMORY {
3141
USER_RAM (RWX) : ORIGIN = __user_ram_start, LENGTH = __user_ram_length
@@ -44,7 +54,7 @@ SECTIONS {
4454
LONG(__vcodesig_options)
4555

4656
FILL(0)
47-
. = __user_ram_start + __code_signature_length;
57+
. = __user_ram_start + 0x20;
4858
} > USER_RAM
4959

5060
/*
@@ -125,7 +135,8 @@ SECTIONS {
125135
*/
126136
.heap (NOLOAD) : {
127137
__heap_start = .;
128-
. = __heap_end;
138+
. = __stack_bottom;
139+
__heap_end = .;
129140
} > USER_RAM
130141

131142
.stack (NOLOAD) : ALIGN(8) {

library/std/src/io/buffered/bufreader/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Buffer {
122122

123123
/// Remove bytes that have already been read from the buffer.
124124
pub fn backshift(&mut self) {
125-
self.buf.copy_within(self.pos.., 0);
125+
self.buf.copy_within(self.pos..self.filled, 0);
126126
self.filled -= self.pos;
127127
self.pos = 0;
128128
}

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::{
3939
};
4040

4141
/// Build a standard library for the given `target` using the given `build_compiler`.
42-
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
42+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4343
pub struct Std {
4444
pub target: TargetSelection,
4545
/// Compiler that builds the standard library.
@@ -949,7 +949,7 @@ pub struct BuiltRustc {
949949
/// so that it can compile build scripts and proc macros when building this `rustc`.
950950
/// - Makes sure that `build_compiler` has a standard library prepared for `target`,
951951
/// so that the built `rustc` can *link to it* and use it at runtime.
952-
#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
952+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
953953
pub struct Rustc {
954954
/// The target on which rustc will run (its host).
955955
pub target: TargetSelection,
@@ -1960,7 +1960,7 @@ impl Step for Sysroot {
19601960
/// linker wrappers (LLD, LLVM bitcode linker, etc.).
19611961
///
19621962
/// This will assemble a compiler in `build/$target/stage$stage`.
1963-
#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
1963+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
19641964
pub struct Assemble {
19651965
/// The compiler which we will produce in this step. Assemble itself will
19661966
/// take care of ensuring that the necessary prerequisites to do so exist,

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool {
5454
builder.config.tools.as_ref().is_none_or(|tools| tools.contains(tool))
5555
}
5656

57-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
57+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
5858
pub struct Docs {
5959
pub host: TargetSelection,
6060
}
@@ -91,7 +91,7 @@ impl Step for Docs {
9191
}
9292
}
9393

94-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
94+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
9595
pub struct JsonDocs {
9696
build_compiler: Compiler,
9797
target: TargetSelection,
@@ -354,7 +354,7 @@ fn get_cc_search_dirs(
354354
(bin_path, lib_path)
355355
}
356356

357-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
357+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
358358
pub struct Mingw {
359359
pub host: TargetSelection,
360360
}
@@ -394,7 +394,7 @@ impl Step for Mingw {
394394
}
395395
}
396396

397-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
397+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
398398
pub struct Rustc {
399399
pub compiler: Compiler,
400400
}
@@ -730,7 +730,7 @@ fn copy_target_libs(
730730
}
731731
}
732732

733-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
733+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
734734
pub struct Std {
735735
pub compiler: Compiler,
736736
pub target: TargetSelection,
@@ -785,7 +785,7 @@ impl Step for Std {
785785
/// `rust.download-rustc`.
786786
///
787787
/// (Don't confuse this with [`RustDev`], without the `c`!)
788-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
788+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
789789
pub struct RustcDev {
790790
pub compiler: Compiler,
791791
pub target: TargetSelection,
@@ -1026,7 +1026,7 @@ fn copy_src_dirs(
10261026
}
10271027
}
10281028

1029-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1029+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
10301030
pub struct Src;
10311031

10321032
impl Step for Src {
@@ -1087,7 +1087,7 @@ impl Step for Src {
10871087
}
10881088
}
10891089

1090-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1090+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
10911091
pub struct PlainSourceTarball;
10921092

10931093
impl Step for PlainSourceTarball {
@@ -1233,7 +1233,7 @@ impl Step for PlainSourceTarball {
12331233
}
12341234
}
12351235

1236-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1236+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
12371237
pub struct Cargo {
12381238
pub build_compiler: Compiler,
12391239
pub target: TargetSelection,
@@ -1287,7 +1287,7 @@ impl Step for Cargo {
12871287
}
12881288
}
12891289

1290-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1290+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
12911291
pub struct RustAnalyzer {
12921292
pub build_compiler: Compiler,
12931293
pub target: TargetSelection,
@@ -1563,7 +1563,7 @@ impl Step for Rustfmt {
15631563
}
15641564
}
15651565

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

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

0 commit comments

Comments
 (0)