Skip to content

Commit 7f6f741

Browse files
authored
Merge pull request rust-lang#4541 from rust-lang/rustup-2025-08-24
Automatic Rustup
2 parents fe7892b + 9e18b7b commit 7f6f741

File tree

615 files changed

+10800
-5433
lines changed

Some content is hidden

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

615 files changed

+10800
-5433
lines changed

Cargo.lock

Lines changed: 118 additions & 140 deletions
Large diffs are not rendered by default.

compiler/rustc_ast/src/token.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub use NtPatKind::*;
77
pub use TokenKind::*;
88
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
99
use rustc_span::edition::Edition;
10+
use rustc_span::symbol::IdentPrintMode;
1011
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym};
1112
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
1213
#[allow(hidden_glob_reexports)]
@@ -344,15 +345,24 @@ pub enum IdentIsRaw {
344345
Yes,
345346
}
346347

347-
impl From<bool> for IdentIsRaw {
348-
fn from(b: bool) -> Self {
349-
if b { Self::Yes } else { Self::No }
348+
impl IdentIsRaw {
349+
pub fn to_print_mode_ident(self) -> IdentPrintMode {
350+
match self {
351+
IdentIsRaw::No => IdentPrintMode::Normal,
352+
IdentIsRaw::Yes => IdentPrintMode::RawIdent,
353+
}
354+
}
355+
pub fn to_print_mode_lifetime(self) -> IdentPrintMode {
356+
match self {
357+
IdentIsRaw::No => IdentPrintMode::Normal,
358+
IdentIsRaw::Yes => IdentPrintMode::RawLifetime,
359+
}
350360
}
351361
}
352362

353-
impl From<IdentIsRaw> for bool {
354-
fn from(is_raw: IdentIsRaw) -> bool {
355-
matches!(is_raw, IdentIsRaw::Yes)
363+
impl From<bool> for IdentIsRaw {
364+
fn from(b: bool) -> Self {
365+
if b { Self::Yes } else { Self::No }
356366
}
357367
}
358368

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15961596
let safety = self.lower_safety(h.safety, default_safety);
15971597

15981598
// Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so.
1599-
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { .. })
1599+
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. })
16001600
&& safety.is_safe()
16011601
&& !self.tcx.sess.target.is_like_wasm
16021602
{

compiler/rustc_ast_passes/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rustc_errors = { path = "../rustc_errors" }
1515
rustc_feature = { path = "../rustc_feature" }
1616
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1717
rustc_macros = { path = "../rustc_macros" }
18-
rustc_parse = { path = "../rustc_parse" }
1918
rustc_session = { path = "../rustc_session" }
2019
rustc_span = { path = "../rustc_span" }
2120
rustc_target = { path = "../rustc_target" }

compiler/rustc_ast_passes/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ ast_passes_extern_without_abi = `extern` declarations without an explicit ABI ar
113113
.suggestion = specify an ABI
114114
.help = prior to Rust 2024, a default ABI was inferred
115115
116+
ast_passes_extern_without_abi_sugg = `extern` declarations without an explicit ABI are deprecated
117+
.label = ABI should be specified here
118+
.suggestion = explicitly specify the {$default_abi} ABI
119+
116120
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
117121
.suggestion = remove the attribute
118122
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ use rustc_abi::{CanonAbi, ExternAbi, InterruptKind};
2525
use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list};
2626
use rustc_ast::*;
2727
use rustc_ast_pretty::pprust::{self, State};
28+
use rustc_attr_parsing::validate_attr;
2829
use rustc_data_structures::fx::FxIndexMap;
29-
use rustc_errors::DiagCtxtHandle;
30+
use rustc_errors::{DiagCtxtHandle, LintBuffer};
3031
use rustc_feature::Features;
31-
use rustc_parse::validate_attr;
3232
use rustc_session::Session;
33+
use rustc_session::lint::BuiltinLintDiag;
3334
use rustc_session::lint::builtin::{
3435
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN,
3536
PATTERNS_IN_FNS_WITHOUT_BODY,
3637
};
37-
use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
3838
use rustc_span::{Ident, Span, kw, sym};
3939
use rustc_target::spec::{AbiMap, AbiMapping};
4040
use thin_vec::thin_vec;
@@ -876,7 +876,7 @@ impl<'a> AstValidator<'a> {
876876
MISSING_ABI,
877877
id,
878878
span,
879-
BuiltinLintDiag::MissingAbi(span, ExternAbi::FALLBACK),
879+
errors::MissingAbiSugg { span, default_abi: ExternAbi::FALLBACK },
880880
)
881881
}
882882
}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_abi::ExternAbi;
44
use rustc_ast::ParamKindOrd;
55
use rustc_errors::codes::*;
66
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
7-
use rustc_macros::{Diagnostic, Subdiagnostic};
7+
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
88
use rustc_span::{Ident, Span, Symbol};
99

1010
use crate::fluent_generated as fluent;
@@ -815,6 +815,14 @@ pub(crate) struct MissingAbi {
815815
pub span: Span,
816816
}
817817

818+
#[derive(LintDiagnostic)]
819+
#[diag(ast_passes_extern_without_abi_sugg)]
820+
pub(crate) struct MissingAbiSugg {
821+
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
822+
pub span: Span,
823+
pub default_abi: ExternAbi,
824+
}
825+
818826
#[derive(Diagnostic)]
819827
#[diag(ast_passes_abi_custom_safe_foreign_function)]
820828
pub(crate) struct AbiCustomSafeForeignFunction {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::borrow::Cow;
1010
use std::sync::Arc;
1111

1212
use rustc_ast::attr::AttrIdGenerator;
13-
use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind};
13+
use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
1414
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1515
use rustc_ast::util::classify;
1616
use rustc_ast::util::comments::{Comment, CommentStyle};
@@ -441,7 +441,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
441441
fn print_generic_args(&mut self, args: &ast::GenericArgs, colons_before_params: bool);
442442

443443
fn print_ident(&mut self, ident: Ident) {
444-
self.word(IdentPrinter::for_ast_ident(ident, ident.is_raw_guess()).to_string());
444+
self.word(IdentPrinter::for_ast_ident(ident, ident.guess_print_mode()).to_string());
445445
self.ann_post(ident)
446446
}
447447

@@ -1015,17 +1015,16 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
10151015

10161016
/* Name components */
10171017
token::Ident(name, is_raw) => {
1018-
IdentPrinter::new(name, is_raw.into(), convert_dollar_crate).to_string().into()
1018+
IdentPrinter::new(name, is_raw.to_print_mode_ident(), convert_dollar_crate)
1019+
.to_string()
1020+
.into()
10191021
}
10201022
token::NtIdent(ident, is_raw) => {
1021-
IdentPrinter::for_ast_ident(ident, is_raw.into()).to_string().into()
1023+
IdentPrinter::for_ast_ident(ident, is_raw.to_print_mode_ident()).to_string().into()
10221024
}
10231025

1024-
token::Lifetime(name, IdentIsRaw::No)
1025-
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::No) => name.to_string().into(),
1026-
token::Lifetime(name, IdentIsRaw::Yes)
1027-
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::Yes) => {
1028-
format!("'r#{}", &name.as_str()[1..]).into()
1026+
token::Lifetime(name, is_raw) | token::NtLifetime(Ident { name, .. }, is_raw) => {
1027+
IdentPrinter::new(name, is_raw.to_print_mode_lifetime(), None).to_string().into()
10291028
}
10301029

10311030
/* Other */

compiler/rustc_attr_parsing/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1414
rustc_hir = { path = "../rustc_hir" }
1515
rustc_lexer = { path = "../rustc_lexer" }
1616
rustc_macros = { path = "../rustc_macros" }
17+
rustc_parse = { path = "../rustc_parse" }
1718
rustc_session = { path = "../rustc_session" }
1819
rustc_span = { path = "../rustc_span" }
1920
thin-vec = "0.2.12"

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,22 @@ attr_parsing_unused_multiple =
170170
171171
-attr_parsing_previously_accepted =
172172
this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
173+
174+
attr_parsing_meta_bad_delim = wrong meta list delimiters
175+
attr_parsing_meta_bad_delim_suggestion = the delimiters should be `(` and `)`
176+
177+
attr_parsing_unsafe_attr_outside_unsafe = unsafe attribute used without unsafe
178+
.label = usage of unsafe attribute
179+
attr_parsing_unsafe_attr_outside_unsafe_suggestion = wrap the attribute in `unsafe(...)`
180+
181+
attr_parsing_invalid_attr_unsafe = `{$name}` is not an unsafe attribute
182+
.label = this is not an unsafe attribute
183+
.suggestion = remove the `unsafe(...)`
184+
.note = extraneous unsafe is not allowed in attributes
185+
186+
attr_parsing_invalid_meta_item = expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found {$descr}
187+
.remove_neg_sugg = negative numbers are not literals, try removing the `-` sign
188+
.quote_ident_sugg = surround the identifier with quotation marks to make it into a string literal
189+
190+
attr_parsing_suffixed_literal_in_attribute = suffixed literals are not allowed in attributes
191+
.help = instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)

0 commit comments

Comments
 (0)