Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b930202
hir_analysis: add `#![rustc_no_implicit_bounds]`
davidtwco Jun 18, 2025
625f8ee
Fix documentation of validate_operand
Stypox Jun 26, 2025
d1f3136
Only args in main diag are saved and restored without removing the ne…
xizheyin Jun 26, 2025
3b259ad
rustdoc js: several typechecking improvments
lolbinarycat Jun 9, 2025
94e9973
Add Ident::is_non_reserved_ident
compiler-errors Jun 26, 2025
e639212
Make recovery for enum with struct field a bit more accurate
compiler-errors Jun 26, 2025
4e51e67
Better recovery
compiler-errors Jun 26, 2025
1fd13fd
tests: add #![rustc_no_implicit_bounds]
davidtwco Jun 27, 2025
1365d3b
codegen_fn_attrs: make comment more precise
RalfJung Jun 25, 2025
9e35684
Port `#[used]` to new attribute parsing infrastructure
JonathanBrouwer Jun 25, 2025
c51f05b
Report infer ty errors during hir ty lowering
oli-obk Jun 6, 2025
89a636f
Add tracing to validate_operand
Stypox Jun 26, 2025
5e10828
Add tracing for instantiate_from_frame_and_normalize_erasing_regions
Stypox May 20, 2025
708dc15
Add InterpCx::layout_of with tracing, shadowing LayoutOf
Stypox Jun 27, 2025
ed4f01e
const-eval: error when initializing a static writes to that static
RalfJung Jun 27, 2025
5d2417e
Rollup merge of #142270 - lolbinarycat:rustdoc-search-Results-type, r…
GuillaumeGomez Jun 27, 2025
aab2c20
Rollup merge of #142420 - oli-obk:infer-ty-coalescing, r=compiler-errors
GuillaumeGomez Jun 27, 2025
80f20c9
Rollup merge of #142671 - davidtwco:no-default-bounds-attr, r=lcnr
GuillaumeGomez Jun 27, 2025
6d8f74d
Rollup merge of #142721 - Stypox:tracing-layout-of, r=RalfJung
GuillaumeGomez Jun 27, 2025
3c3a174
Rollup merge of #142818 - JonathanBrouwer:used_new_parser, r=jdonszel…
GuillaumeGomez Jun 27, 2025
599a061
Rollup merge of #143020 - RalfJung:codegen_fn_attrs, r=oli-obk
GuillaumeGomez Jun 27, 2025
8256a75
Rollup merge of #143051 - Stypox:tracing-validity, r=RalfJung
GuillaumeGomez Jun 27, 2025
8e5fd99
Rollup merge of #143060 - xizheyin:simplify-diag, r=oli-obk
GuillaumeGomez Jun 27, 2025
8e7b0b5
Rollup merge of #143065 - compiler-errors:enum-recovery, r=oli-obk
GuillaumeGomez Jun 27, 2025
0bbeeff
Rollup merge of #143084 - RalfJung:const-eval-recursive-static-write,…
GuillaumeGomez Jun 27, 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
Prev Previous commit
Next Next commit
Add Ident::is_non_reserved_ident
  • Loading branch information
compiler-errors committed Jun 26, 2025
commit 94e9973b92c481d20e5fe1466bbc47f818101d5f
6 changes: 5 additions & 1 deletion compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ impl Token {
|| self.is_qpath_start()
|| matches!(self.is_metavar_seq(), Some(MetaVarKind::Path))
|| self.is_path_segment_keyword()
|| self.is_ident() && !self.is_reserved_ident()
|| self.is_non_reserved_ident()
}

/// Returns `true` if the token is a given keyword, `kw`.
Expand Down Expand Up @@ -937,6 +937,10 @@ impl Token {
self.is_non_raw_ident_where(Ident::is_reserved)
}

pub fn is_non_reserved_ident(&self) -> bool {
self.ident().is_some_and(|(id, raw)| raw == IdentIsRaw::Yes || !Ident::is_reserved(id))
}

/// 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())
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,8 @@ impl TokenStream {
(
TokenTree::Token(token_left, Spacing::Alone),
TokenTree::Token(token_right, _),
) if ((token_left.is_ident() && !token_left.is_reserved_ident())
|| token_left.is_lit())
&& ((token_right.is_ident() && !token_right.is_reserved_ident())
|| token_right.is_lit()) =>
) if (token_left.is_non_reserved_ident() || token_left.is_lit())
&& (token_right.is_non_reserved_ident() || token_right.is_lit()) =>
{
token_left.span
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,7 @@ impl<'a> Parser<'a> {
return first_pat;
}
if !matches!(first_pat.kind, PatKind::Ident(_, _, None) | PatKind::Path(..))
|| !self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident())
|| !self.look_ahead(1, |token| token.is_non_reserved_ident())
{
let mut snapshot_type = self.create_snapshot_for_diagnostic();
snapshot_type.bump(); // `:`
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3875,8 +3875,7 @@ impl<'a> Parser<'a> {
// Check if a colon exists one ahead. This means we're parsing a fieldname.
let is_shorthand = !this.look_ahead(1, |t| t == &token::Colon || t == &token::Eq);
// Proactively check whether parsing the field will be incorrect.
let is_wrong = this.token.is_ident()
&& !this.token.is_reserved_ident()
let is_wrong = this.token.is_non_reserved_ident()
&& !this.look_ahead(1, |t| {
t == &token::Colon
|| t == &token::Eq
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl<'a> Parser<'a> {

/// Is the given keyword `kw` followed by a non-reserved identifier?
fn is_kw_followed_by_ident(&self, kw: Symbol) -> bool {
self.token.is_keyword(kw) && self.look_ahead(1, |t| t.is_ident() && !t.is_reserved_ident())
self.token.is_keyword(kw) && self.look_ahead(1, |t| t.is_non_reserved_ident())
}

#[inline]
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'a> Parser<'a> {
/// ```
fn recover_colon_before_qpath_proj(&mut self) -> bool {
if !self.check_noexpect(&TokenKind::Colon)
|| self.look_ahead(1, |t| !t.is_ident() || t.is_reserved_ident())
|| self.look_ahead(1, |t| !t.is_non_reserved_ident())
{
return false;
}
Expand Down Expand Up @@ -260,7 +260,7 @@ impl<'a> Parser<'a> {
if self.may_recover()
&& style == PathStyle::Expr // (!)
&& self.token == token::Colon
&& self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident())
&& self.look_ahead(1, |token| token.is_non_reserved_ident())
{
// Emit a special error message for `a::b:c` to help users
// otherwise, `a: c` might have meant to introduce a new binding
Expand Down Expand Up @@ -334,9 +334,7 @@ impl<'a> Parser<'a> {
self.expect_gt().map_err(|mut err| {
// Try to recover a `:` into a `::`
if self.token == token::Colon
&& self.look_ahead(1, |token| {
token.is_ident() && !token.is_reserved_ident()
})
&& self.look_ahead(1, |token| token.is_non_reserved_ident())
{
err.cancel();
err = self.dcx().create_err(PathSingleColon {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ impl<'a> Parser<'a> {
}
if self.prev_token.is_reserved_ident() && self.prev_token.is_ident_named(kw::Await) {
// Likely `foo.await bar`
} else if !self.prev_token.is_reserved_ident() && self.prev_token.is_ident() {
} else if self.prev_token.is_non_reserved_ident() {
// Likely `foo bar`
} else if self.prev_token.kind == token::Question {
// `foo? bar`
Expand Down