Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a451894
add case mapping fast paths for Latin-1
ywxt Sep 14, 2026
01da50f
Account for split text events in bare urls lint
notriddle Sep 16, 2026
8e4f287
Account for nested parens in bare urls lint
notriddle Sep 16, 2026
459ba37
Account for the separator between host and path
notriddle Sep 17, 2026
a83dd65
Account for URLs with accidental formatting
notriddle Sep 17, 2026
172ae8c
Declare multi-kind constants for MacroKinds
Zalathar Sep 18, 2026
27ed2ed
Introduce LockedDir type
bjorn3 Sep 18, 2026
6e7ebbe
Depend on lockfiles to prevent GC of the current session
bjorn3 Sep 18, 2026
ae2ecf5
Avoid integer underflow in CStr::count_bytes()
Darksonn Sep 19, 2026
bc5fd06
Dir: fix fallback impl for remove_dir
RalfJung Sep 19, 2026
ea2fa3e
Add regression tests for runtime range pattern endpoints
chenyukang Sep 13, 2026
64695f1
Diagnose runtime range endpoints before reporting unsupported types
chenyukang Sep 13, 2026
70854cd
Use verbose suggestion for `mut binding` instead of `&mut binding`
estebank Sep 20, 2026
f1e9e5e
When error from local macro, include macro def span
estebank Aug 13, 2026
5c0fee6
When compiling without a specified `--edition`, emit a note
estebank Jun 18, 2026
2784d28
Use `eprintln!()` instead of a note for unspecified `--edition`
estebank Sep 20, 2026
35ec478
Use x30 register name with LLVM 23+
malezjaa Sep 20, 2026
3de0624
Use r14 register name with LLVM 23+
malezjaa Sep 20, 2026
81d8904
Fix ArgAttributes mismatches in ABI UI tests for LoongArch64 and RiscV64
heiher Sep 20, 2026
21d6920
Test windows `access_mode` override
ChrisDenton Sep 20, 2026
ac5ff45
Windows: don't error if `access_mode` is set
ChrisDenton Sep 20, 2026
39f76c9
Refactor access_mode case out of match
ChrisDenton Sep 20, 2026
aceae2d
Replace `IdentIsRaw` with `IdentKind`
fmease Aug 25, 2026
3caa23d
Introduce helper `Token::non_raw_ident`
fmease Aug 25, 2026
ebf08b9
enable `f128` from `u64`/`i64` test
folkertdev Sep 20, 2026
93c8966
Remove `TypeChecker::root_cx`
nnethercote Sep 7, 2026
28fe133
Do not continue past `rustc_resolve` when encountering duplicated types
estebank Sep 15, 2026
7fac56c
Fix graphviz label
nnethercote Aug 18, 2026
259bee6
Remove duplicated trait bound
nnethercote Aug 18, 2026
90dd142
Remove two unnecessary `try` blocks
nnethercote Aug 18, 2026
266da35
Remove `regex!` macro
nnethercote Aug 18, 2026
dfd1a7d
Streamline `write_node_label`
nnethercote Aug 18, 2026
c0d4983
Rollup merge of #161051 - estebank:macro_backtrace, r=adwinwhite
JonathanBrouwer Sep 21, 2026
9f46ccb
Rollup merge of #161629 - nnethercote:StateDiffCollector, r=cjgillot
JonathanBrouwer Sep 21, 2026
9d6494a
Rollup merge of #162750 - ywxt:ascii_char_to_uppercase, r=Amanieu
JonathanBrouwer Sep 21, 2026
2d4dbab
Rollup merge of #162831 - estebank:duplicated-items, r=petrochenkov
JonathanBrouwer Sep 21, 2026
d16d663
Rollup merge of #162835 - notriddle:notriddle/parens-bare-url, r=lolb…
JonathanBrouwer Sep 21, 2026
9e850b1
Rollup merge of #162952 - bjorn3:incr_comp_locking_change, r=khyperia
JonathanBrouwer Sep 21, 2026
c20afc2
Rollup merge of #163044 - chenyukang:yukang-fix-131327-runtime-range-…
JonathanBrouwer Sep 21, 2026
c965b24
Rollup merge of #163062 - malezjaa:remove-aarch64-x30-asm-workaround,…
JonathanBrouwer Sep 21, 2026
55d7fdd
Rollup merge of #158102 - estebank:note-default-edition, r=jieyouxu
JonathanBrouwer Sep 21, 2026
ceb8fb2
Rollup merge of #162939 - Zalathar:combo-macro-kinds, r=khyperia
JonathanBrouwer Sep 21, 2026
58c37be
Rollup merge of #162984 - ChrisDenton:access-allowed, r=clarfonthey
JonathanBrouwer Sep 21, 2026
ad9e00b
Rollup merge of #163005 - Darksonn:cstr-count-bytes, r=Mark-Simulacrum
JonathanBrouwer Sep 21, 2026
eaab0e9
Rollup merge of #163019 - fmease:prepare-kay-hash, r=petrochenkov
JonathanBrouwer Sep 21, 2026
24dfd0a
Rollup merge of #163020 - RalfJung:dir-remove-dir-fallback, r=Mark-Si…
JonathanBrouwer Sep 21, 2026
62957f8
Rollup merge of #163047 - estebank:mut-binding, r=adwinwhite
JonathanBrouwer Sep 21, 2026
0faffe7
Rollup merge of #163075 - heiher:fix-argattrs, r=folkertdev
JonathanBrouwer Sep 21, 2026
31cb8a7
Rollup merge of #163079 - folkertdev:f128-from-int-tests, r=tgross35
JonathanBrouwer Sep 21, 2026
2b32d64
Rollup merge of #163082 - nnethercote:rm-TypeChecker-root_cx, r=cheny…
JonathanBrouwer Sep 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
113 changes: 55 additions & 58 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ impl Lit {
/// `Parser::eat_token_lit` (excluding unary negation).
pub fn from_token(token: &Token) -> Option<Lit> {
match token.uninterpolate().kind {
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)),
Ident(name, IdentKind::Normal) if name.is_bool_lit() => {
Some(Lit::new(Bool, name, None))
}
Literal(token_lit) => Some(token_lit),
OpenInvisible(InvisibleOrigin::MetaVar(
MetaVarKind::Literal | MetaVarKind::Expr { .. },
Expand Down Expand Up @@ -307,11 +309,11 @@ impl LitKind {
}
}

pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
pub fn ident_can_begin_expr(name: Symbol, span: Span, kind: IdentKind) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `expr` nonterminal which is user observable.

let ident_token = Token::new(Ident(name, is_raw), span);
let ident_token = Token::new(Ident(name, kind), span);

// FIXME: Remove `box` from this list given we officially no longer support box expressions
// (#108471) (needs lang FCP as it affects stable macro matching behavior).
Expand Down Expand Up @@ -344,11 +346,11 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> boo
.contains(&name)
}

fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
fn ident_can_begin_type(name: Symbol, span: Span, kind: IdentKind) -> bool {
// WARNING: Take care when modifying this function! It will change the stable(!) set of
// tokens that are allowed to match an `ty` nonterminal which is user observable.

let ident_token = Token::new(Ident(name, is_raw), span);
let ident_token = Token::new(Ident(name, kind), span);

!ident_token.is_reserved_ident()
|| ident_token.is_path_segment_keyword()
Expand All @@ -357,32 +359,26 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
}

#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, StableHash)]
pub enum IdentIsRaw {
No,
Yes,
pub enum IdentKind {
Normal,
Raw,
}

impl IdentIsRaw {
impl IdentKind {
pub fn to_print_mode_ident(self) -> IdentPrintMode {
match self {
IdentIsRaw::No => IdentPrintMode::Normal,
IdentIsRaw::Yes => IdentPrintMode::RawIdent,
IdentKind::Normal => IdentPrintMode::Normal,
IdentKind::Raw => IdentPrintMode::RawIdent,
}
}
pub fn to_print_mode_lifetime(self) -> IdentPrintMode {
match self {
IdentIsRaw::No => IdentPrintMode::Normal,
IdentIsRaw::Yes => IdentPrintMode::RawLifetime,
IdentKind::Normal => IdentPrintMode::Normal,
IdentKind::Raw => IdentPrintMode::RawLifetime,
}
}
}

impl From<bool> for IdentIsRaw {
fn from(b: bool) -> Self {
if b { Self::Yes } else { Self::No }
}
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)]
pub enum TokenKind {
/* Expression-operator symbols. */
Expand Down Expand Up @@ -507,22 +503,22 @@ pub enum TokenKind {
/// It's recommended to use `Token::{ident,uninterpolate}` and
/// `Parser::token_uninterpolated_span` to treat regular and interpolated
/// identifiers in the same way.
Ident(Symbol, IdentIsRaw),
Ident(Symbol, IdentKind),
/// This identifier (and its span) is the identifier passed to the
/// declarative macro. The span in the surrounding `Token` is the span of
/// the `ident` metavariable in the macro's RHS.
NtIdent(sp::Ident, IdentIsRaw),
NtIdent(sp::Ident, IdentKind),

/// Lifetime identifier token.
/// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
/// It's recommended to use `Token::{ident,uninterpolate}` and
/// `Parser::token_uninterpolated_span` to treat regular and interpolated
/// identifiers in the same way.
Lifetime(Symbol, IdentIsRaw),
Lifetime(Symbol, IdentKind),
/// This identifier (and its span) is the lifetime passed to the
/// declarative macro. The span in the surrounding `Token` is the span of
/// the `lifetime` metavariable in the macro's RHS.
NtLifetime(sp::Ident, IdentIsRaw),
NtLifetime(sp::Ident, IdentKind),

/// A doc comment token.
/// `Symbol` is the doc comment's data excluding its "quotes" (`///`, `/**`, etc)
Expand Down Expand Up @@ -643,7 +639,8 @@ impl Token {

/// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary.
pub fn from_ast_ident(ident: sp::Ident) -> Self {
Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span)
let kind = if ident.is_raw_guess() { IdentKind::Raw } else { IdentKind::Normal };
Token::new(Ident(ident.name, kind), ident.span)
}

pub fn is_range_separator(&self) -> bool {
Expand Down Expand Up @@ -674,8 +671,8 @@ impl Token {
// tokens that are allowed to match an `expr` nonterminal which is user observable.

match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
Ident(name, kind) =>
ident_can_begin_expr(name, self.span, kind), // value name or keyword
OpenParen | // tuple
OpenBrace | // block
OpenBracket | // array
Expand Down Expand Up @@ -743,8 +740,8 @@ impl Token {
// object types (consider `use<>+` and `use<T> + Trait` for example).

match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_type(name, self.span, is_raw), // type name or keyword
Ident(name, kind) =>
ident_can_begin_type(name, self.span, kind), // type name or keyword
OpenParen // tuple
| OpenBracket // array
| Bang // never
Expand All @@ -766,7 +763,7 @@ impl Token {
pub fn can_begin_const_arg(&self) -> bool {
match self.kind {
OpenBrace | Literal(..) | Minus => true,
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
Ident(name, IdentKind::Normal) if name.is_bool_lit() => true,
OpenInvisible(InvisibleOrigin::MetaVar(
MetaVarKind::Expr { .. } | MetaVarKind::Block | MetaVarKind::Literal,
)) => true,
Expand Down Expand Up @@ -815,7 +812,7 @@ impl Token {
pub fn can_begin_literal_maybe_minus(&self) -> bool {
match self.uninterpolate().kind {
Literal(..) | Minus => true,
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
Ident(name, IdentKind::Normal) if name.is_bool_lit() => true,
OpenInvisible(InvisibleOrigin::MetaVar(mv_kind)) => match mv_kind {
MetaVarKind::Literal => true,
MetaVarKind::Expr { can_begin_literal_maybe_minus, .. } => {
Expand Down Expand Up @@ -845,32 +842,32 @@ impl Token {
/// otherwise returns the original token.
pub fn uninterpolate(&self) -> Cow<'_, Token> {
match self.kind {
NtIdent(ident, is_raw) => Cow::Owned(Token::new(Ident(ident.name, is_raw), ident.span)),
NtLifetime(ident, is_raw) => {
Cow::Owned(Token::new(Lifetime(ident.name, is_raw), ident.span))
NtIdent(ident, kind) => Cow::Owned(Token::new(Ident(ident.name, kind), ident.span)),
NtLifetime(ident, kind) => {
Cow::Owned(Token::new(Lifetime(ident.name, kind), ident.span))
}
_ => Cow::Borrowed(self),
}
}

/// Returns an identifier if this token is an identifier.
#[inline]
pub fn ident(&self) -> Option<(sp::Ident, IdentIsRaw)> {
pub fn ident(&self) -> Option<(sp::Ident, IdentKind)> {
// We avoid using `Token::uninterpolate` here because it's slow.
match self.kind {
Ident(name, is_raw) => Some((sp::Ident::new(name, self.span), is_raw)),
NtIdent(ident, is_raw) => Some((ident, is_raw)),
Ident(name, kind) => Some((sp::Ident::new(name, self.span), kind)),
NtIdent(ident, kind) => Some((ident, kind)),
_ => None,
}
}

/// Returns a lifetime identifier if this token is a lifetime.
#[inline]
pub fn lifetime(&self) -> Option<(sp::Ident, IdentIsRaw)> {
pub fn lifetime(&self) -> Option<(sp::Ident, IdentKind)> {
// We avoid using `Token::uninterpolate` here because it's slow.
match self.kind {
Lifetime(name, is_raw) => Some((sp::Ident::new(name, self.span), is_raw)),
NtLifetime(ident, is_raw) => Some((ident, is_raw)),
Lifetime(name, kind) => Some((sp::Ident::new(name, self.span), kind)),
NtLifetime(ident, kind) => Some((ident, kind)),
_ => None,
}
}
Expand Down Expand Up @@ -929,43 +926,43 @@ impl Token {

/// Returns `true` if the token is a given keyword, `kw`.
pub fn is_keyword(&self, kw: Symbol) -> bool {
self.is_non_raw_ident_where(|id| id.name == kw)
self.non_raw_ident().is_some_and(|id| id.name == kw)
}

/// Returns `true` if the token is a given keyword, `kw` or if `case` is `Insensitive` and this
/// token is an identifier equal to `kw` ignoring the case.
pub fn is_keyword_case(&self, kw: Symbol, case: Case) -> bool {
self.is_keyword(kw)
|| (case == Case::Insensitive
&& self.is_non_raw_ident_where(|id| {
&& self.non_raw_ident().is_some_and(|id| {
// Do an ASCII case-insensitive match, because all keywords are ASCII.
id.name.as_str().eq_ignore_ascii_case(kw.as_str())
}))
}

pub fn is_path_segment_keyword(&self) -> bool {
self.is_non_raw_ident_where(sp::Ident::is_path_segment_keyword)
self.non_raw_ident().is_some_and(sp::Ident::is_path_segment_keyword)
}

/// Returns true for reserved identifiers used internally for elided lifetimes,
/// unnamed method parameters, crate root module, error recovery etc.
pub fn is_special_ident(&self) -> bool {
self.is_non_raw_ident_where(sp::Ident::is_special)
self.non_raw_ident().is_some_and(sp::Ident::is_special)
}

/// Returns `true` if the token is a keyword used in the language.
pub fn is_used_keyword(&self) -> bool {
self.is_non_raw_ident_where(sp::Ident::is_used_keyword)
self.non_raw_ident().is_some_and(sp::Ident::is_used_keyword)
}

/// Returns `true` if the token is a keyword reserved for possible future use.
pub fn is_unused_keyword(&self) -> bool {
self.is_non_raw_ident_where(sp::Ident::is_unused_keyword)
self.non_raw_ident().is_some_and(sp::Ident::is_unused_keyword)
}

/// Returns `true` if the token is either a special identifier or a keyword.
pub fn is_reserved_ident(&self) -> bool {
self.is_non_raw_ident_where(sp::Ident::is_reserved)
self.non_raw_ident().is_some_and(sp::Ident::is_reserved)
}

pub fn is_non_reserved_ident(&self) -> bool {
Expand All @@ -974,13 +971,21 @@ impl Token {

pub fn non_reserved_ident(&self) -> Option<sp::Ident> {
self.ident()
.filter(|&(id, raw)| raw == IdentIsRaw::Yes || !sp::Ident::is_reserved(id))
.filter(|&(id, kind)| kind == IdentKind::Raw || !id.is_reserved())
.map(|(id, _)| id)
}

/// If this token is a non-raw identifier, return the identifier in question.
pub fn non_raw_ident(&self) -> Option<sp::Ident> {
match self.ident() {
Some((id, IdentKind::Normal)) => Some(id),
_ => None,
}
}

/// Returns `true` if the token is the identifier `true` or `false`.
pub fn is_bool_lit(&self) -> bool {
self.is_non_raw_ident_where(|id| id.name.is_bool_lit())
self.non_raw_ident().is_some_and(|id| id.name.is_bool_lit())
}

pub fn is_numeric_lit(&self) -> bool {
Expand All @@ -995,14 +1000,6 @@ impl Token {
matches!(self.kind, Literal(Lit { kind: LitKind::Integer, .. }))
}

/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(sp::Ident) -> bool) -> bool {
match self.ident() {
Some((id, IdentIsRaw::No)) => pred(id),
_ => false,
}
}

/// Is this an invisible open delimiter at the start of a token sequence
/// from an expanded metavar?
pub fn is_metavar_seq(&self) -> Option<MetaVarKind> {
Expand Down Expand Up @@ -1076,8 +1073,8 @@ impl Token {
(Colon, Colon) => PathSep,
(Colon, _) => return None,

(SingleQuote, Ident(name, is_raw)) => {
Lifetime(Symbol::intern(&format!("'{name}")), *is_raw)
(SingleQuote, Ident(name, kind)) => {
Lifetime(Symbol::intern(&format!("'{name}")), *kind)
}
(SingleQuote, _) => return None,

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl TokenStream {
DelimSpacing::new(Spacing::JointHidden, Spacing::Alone),
Delimiter::Bracket,
[
TokenTree::token_alone(token::Ident(sym::doc, token::IdentIsRaw::No), span),
TokenTree::token_alone(token::Ident(sym::doc, token::IdentKind::Normal), span),
TokenTree::token_alone(token::Eq, span),
TokenTree::token_alone(
TokenKind::lit(token::StrRaw(num_of_hashes), data, None),
Expand Down
22 changes: 10 additions & 12 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,18 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {

// IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if`
(
Tok(tk::Token { kind: tk::Ident(sym, is_raw), span }, _),
Tok(tk::Token { kind: tk::Ident(sym, kind), span }, _),
Tok(tk::Token { kind: tk::Bang, .. }, _),
) if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, tk::IdentIsRaw::Yes) => {
false
}
) if !Ident::new(*sym, *span).is_reserved() || matches!(kind, tk::IdentKind::Raw) => false,

// IDENT|`fn`|`Self`|`pub` + `(`: `f(3)`, `fn(x: u8)`, `Self()`, `pub(crate)`,
// but `let (a, b) = (1, 2)` needs a space after the `let`
(Tok(tk::Token { kind: tk::Ident(sym, is_raw), span }, _), Del(_, _, Parenthesis, _))
(Tok(tk::Token { kind: tk::Ident(sym, kind), span }, _), Del(_, _, Parenthesis, _))
if !Ident::new(*sym, *span).is_reserved()
|| *sym == kw::Fn
|| *sym == kw::SelfUpper
|| *sym == kw::Pub
|| matches!(is_raw, tk::IdentIsRaw::Yes) =>
|| matches!(kind, tk::IdentKind::Raw) =>
{
false
}
Expand Down Expand Up @@ -1076,17 +1074,17 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
tk::Literal(lit) => literal_to_string(lit).into(),

/* Name components */
tk::Ident(name, is_raw) => {
IdentPrinter::new(name, is_raw.to_print_mode_ident(), convert_dollar_crate)
tk::Ident(name, kind) => {
IdentPrinter::new(name, kind.to_print_mode_ident(), convert_dollar_crate)
.to_string()
.into()
}
tk::NtIdent(ident, is_raw) => {
IdentPrinter::for_ast_ident(ident, is_raw.to_print_mode_ident()).to_string().into()
tk::NtIdent(ident, kind) => {
IdentPrinter::for_ast_ident(ident, kind.to_print_mode_ident()).to_string().into()
}

tk::Lifetime(name, is_raw) | tk::NtLifetime(Ident { name, .. }, is_raw) => {
IdentPrinter::new(name, is_raw.to_print_mode_lifetime(), None).to_string().into()
tk::Lifetime(name, kind) | tk::NtLifetime(Ident { name, .. }, kind) => {
IdentPrinter::new(name, kind.to_print_mode_lifetime(), None).to_string().into()
}

/* Other */
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ fn borrowck_collect_region_constraints<'tcx>(
deferred_closure_requirements,
polonius_context,
} = type_check::type_check(
root_cx,
&infcx,
body,
&promoted,
Expand Down
Loading
Loading