Skip to content

Commit e8626a3

Browse files
authored
Merge pull request rust-lang#4553 from rust-lang/rustup-2025-09-01
Automatic Rustup
2 parents 1f0216e + 4cc7cca commit e8626a3

File tree

100 files changed

+2677
-982
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2677
-982
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub enum TargetDataLayoutErrors<'a> {
315315
MissingAlignment { cause: &'a str },
316316
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
317317
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
318-
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
318+
InconsistentTargetPointerWidth { pointer_size: u64, target: u16 },
319319
InvalidBitsSize { err: String },
320320
UnknownPointerSpecification { err: String },
321321
}

compiler/rustc_ast_ir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl IntTy {
6969
})
7070
}
7171

72-
pub fn normalize(&self, target_width: u32) -> Self {
72+
pub fn normalize(&self, target_width: u16) -> Self {
7373
match self {
7474
IntTy::Isize => match target_width {
7575
16 => IntTy::I16,
@@ -148,7 +148,7 @@ impl UintTy {
148148
})
149149
}
150150

151-
pub fn normalize(&self, target_width: u32) -> Self {
151+
pub fn normalize(&self, target_width: u16) -> Self {
152152
match self {
153153
UintTy::Usize => match target_width {
154154
16 => UintTy::U16,

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
5858
Allow(Target::AssocTy),
5959
Allow(Target::AssocConst),
6060
Allow(Target::Variant),
61-
Allow(Target::Impl { of_trait: false }), //FIXME This does not make sense
61+
Allow(Target::Impl { of_trait: false }),
6262
Allow(Target::Crate),
6363
Error(Target::WherePredicate),
6464
]);

compiler/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"unix"
2323
],
2424
"target-mcount": "_mcount",
25-
"target-pointer-width": "32"
25+
"target-pointer-width": 32
2626
}

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,10 +2309,10 @@ declare_lint! {
23092309
/// ### Example
23102310
///
23112311
/// ```rust
2312-
/// #![feature(sanitize)]
2312+
/// #![cfg_attr(not(bootstrap), feature(sanitize))]
23132313
///
23142314
/// #[inline(always)]
2315-
/// #[sanitize(address = "off")]
2315+
/// #[cfg_attr(not(bootstrap), sanitize(address = "off"))]
23162316
/// fn x() {}
23172317
///
23182318
/// fn main() {
@@ -4832,13 +4832,16 @@ declare_lint! {
48324832
///
48334833
/// ### Example
48344834
///
4835-
/// ```rust,compile_fail
4835+
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
4836+
#[cfg_attr(bootstrap, doc = "```rust")]
48364837
/// #![doc = in_root!()]
48374838
///
48384839
/// macro_rules! in_root { () => { "" } }
48394840
///
48404841
/// fn main() {}
4841-
/// ```
4842+
#[cfg_attr(not(bootstrap), doc = "```")]
4843+
#[cfg_attr(bootstrap, doc = "```")]
4844+
// ^ Needed to avoid tidy warning about odd number of backticks
48424845
///
48434846
/// {{produces}}
48444847
///

compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(assert_matches)]
77
#![feature(box_patterns)]
88
#![feature(debug_closure_helpers)]
9+
#![feature(default_field_values)]
910
#![feature(if_let_guard)]
1011
#![feature(iter_intersperse)]
1112
#![recursion_limit = "256"]

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ast::Label;
66
use rustc_ast as ast;
77
use rustc_ast::token::{self, Delimiter, InvisibleOrigin, MetaVarKind, TokenKind};
88
use rustc_ast::util::classify::{self, TrailingBrace};
9+
use rustc_ast::visit::{Visitor, walk_expr};
910
use rustc_ast::{
1011
AttrStyle, AttrVec, Block, BlockCheckMode, DUMMY_NODE_ID, Expr, ExprKind, HasAttrs, Local,
1112
LocalKind, MacCall, MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind,
@@ -783,6 +784,100 @@ impl<'a> Parser<'a> {
783784
Ok(self.mk_block(stmts, s, lo.to(self.prev_token.span)))
784785
}
785786

787+
fn recover_missing_let_else(&mut self, err: &mut Diag<'_>, pat: &ast::Pat, stmt_span: Span) {
788+
if self.token.kind != token::OpenBrace {
789+
return;
790+
}
791+
match pat.kind {
792+
ast::PatKind::Ident(..) | ast::PatKind::Missing | ast::PatKind::Wild => {
793+
// Not if let or let else
794+
return;
795+
}
796+
_ => {}
797+
}
798+
let snapshot = self.create_snapshot_for_diagnostic();
799+
let block_span = self.token.span;
800+
let (if_let, let_else) = match self.parse_block() {
801+
Ok(block) => {
802+
let mut idents = vec![];
803+
pat.walk(&mut |pat: &ast::Pat| {
804+
if let ast::PatKind::Ident(_, ident, _) = pat.kind {
805+
idents.push(ident);
806+
}
807+
true
808+
});
809+
810+
struct IdentFinder {
811+
idents: Vec<Ident>,
812+
/// If a block references one of the bindings introduced by the let pattern,
813+
/// we likely meant to use `if let`.
814+
/// This is pre-expansion, so if we encounter
815+
/// `let Some(x) = foo() { println!("{x}") }` we won't find it.
816+
references_ident: bool = false,
817+
/// If a block has a `return`, then we know with high certainty that it was
818+
/// meant to be let-else.
819+
has_return: bool = false,
820+
}
821+
822+
impl<'a> Visitor<'a> for IdentFinder {
823+
fn visit_ident(&mut self, ident: &Ident) {
824+
for i in &self.idents {
825+
if ident.name == i.name {
826+
self.references_ident = true;
827+
}
828+
}
829+
}
830+
fn visit_expr(&mut self, node: &'a Expr) {
831+
if let ExprKind::Ret(..) = node.kind {
832+
self.has_return = true;
833+
}
834+
walk_expr(self, node);
835+
}
836+
}
837+
838+
// Collect all bindings in pattern and see if they appear in the block. Likely meant
839+
// to write `if let`. See if the block has a return. Likely meant to write
840+
// `let else`.
841+
let mut visitor = IdentFinder { idents, .. };
842+
visitor.visit_block(&block);
843+
844+
(visitor.references_ident, visitor.has_return)
845+
}
846+
Err(e) => {
847+
e.cancel();
848+
self.restore_snapshot(snapshot);
849+
(false, false)
850+
}
851+
};
852+
853+
let mut alternatively = "";
854+
if if_let || !let_else {
855+
alternatively = "alternatively, ";
856+
err.span_suggestion_verbose(
857+
stmt_span.shrink_to_lo(),
858+
"you might have meant to use `if let`",
859+
"if ".to_string(),
860+
if if_let {
861+
Applicability::MachineApplicable
862+
} else {
863+
Applicability::MaybeIncorrect
864+
},
865+
);
866+
}
867+
if let_else || !if_let {
868+
err.span_suggestion_verbose(
869+
block_span.shrink_to_lo(),
870+
format!("{alternatively}you might have meant to use `let else`"),
871+
"else ".to_string(),
872+
if let_else {
873+
Applicability::MachineApplicable
874+
} else {
875+
Applicability::MaybeIncorrect
876+
},
877+
);
878+
}
879+
}
880+
786881
fn recover_missing_dot(&mut self, err: &mut Diag<'_>) {
787882
let Some((ident, _)) = self.token.ident() else {
788883
return;
@@ -977,6 +1072,7 @@ impl<'a> Parser<'a> {
9771072
self.check_mistyped_turbofish_with_multiple_type_params(e, expr).map_err(
9781073
|mut e| {
9791074
self.recover_missing_dot(&mut e);
1075+
self.recover_missing_let_else(&mut e, &local.pat, stmt.span);
9801076
e
9811077
},
9821078
)?;

compiler/rustc_parse_format/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,9 @@ impl<'input> Parser<'input> {
858858
self.errors.insert(
859859
0,
860860
ParseError {
861-
description: "expected format parameter to occur after `:`".to_owned(),
861+
description:
862+
"expected alignment specifier after `:` in format string; example: `{:>?}`"
863+
.to_owned(),
862864
note: None,
863865
label: format!("expected `{}` to occur after `:`", alignment),
864866
span: range,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{RelroLevel, TargetOptions, cvs};
2+
3+
pub(crate) fn opts() -> TargetOptions {
4+
TargetOptions {
5+
os: "managarm".into(),
6+
env: "mlibc".into(),
7+
dynamic_linking: true,
8+
executables: true,
9+
families: cvs!["unix"],
10+
has_rpath: true,
11+
position_independent_executables: true,
12+
relro_level: RelroLevel::Full,
13+
has_thread_local: true,
14+
crt_static_respected: true,
15+
..Default::default()
16+
}
17+
}

compiler/rustc_target/src/spec/base/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) mod linux_ohos;
2020
pub(crate) mod linux_uclibc;
2121
pub(crate) mod linux_wasm;
2222
pub(crate) mod lynxos178;
23+
pub(crate) mod managarm_mlibc;
2324
pub(crate) mod msvc;
2425
pub(crate) mod netbsd;
2526
pub(crate) mod nto_qnx;

0 commit comments

Comments
 (0)