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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cb9f55c
Adds expr_2024 migration lit
vincenzopalazzo May 25, 2024
9b22110
Add powerpc-unknown-openbsd maintaince status
ChrisDenton Jun 14, 2024
c4ddc86
Print the tested value in int_log tests
tgross35 Jun 18, 2024
b6d20d1
Add the target-features
sayantn Jun 18, 2024
1e1b3fc
Fix stderr cases
sayantn Jun 18, 2024
6366acc
tests: adds cargo fix tests
vincenzopalazzo May 25, 2024
50d1efa
Add a test demonstrating the problem
compiler-errors Jun 19, 2024
3e8898a
Allow naming expr_2021 in all editions
compiler-errors Jun 19, 2024
a656bb6
Specify target for inaccessible-temp-dir rmake test
Hoverbear Jun 19, 2024
108b3f2
Properly gate `safe` keyword in pre-expansion
compiler-errors Jun 20, 2024
bc12972
Slightly refactor the dumping of HIR analysis data
fmease Jun 19, 2024
9092473
Add `#[rustc_dump_{predicates,item_bounds}]`
fmease Jun 19, 2024
cdf9a41
Rollup merge of #125627 - vincenzopalazzo:macros/cargo-fix-expr2024, …
matthiaskrgr Jun 20, 2024
a8d641f
Rollup merge of #126481 - ChrisDenton:powerpc-unkown-openbsd, r=ehuss
matthiaskrgr Jun 20, 2024
5376a54
Rollup merge of #126613 - tgross35:log-test-update, r=cuviper
matthiaskrgr Jun 20, 2024
651ed0f
Rollup merge of #126617 - sayantn:veorq, r=workingjubilee
matthiaskrgr Jun 20, 2024
2700fc8
Rollup merge of #126686 - fmease:dump-preds-n-item-bounds, r=compiler…
matthiaskrgr Jun 20, 2024
250a3e5
Rollup merge of #126700 - compiler-errors:fragment, r=fmease
matthiaskrgr Jun 20, 2024
6e624ff
Rollup merge of #126707 - ferrocene:hoverbear/fix-inaccessible-temp-d…
matthiaskrgr Jun 20, 2024
3319aae
Rollup merge of #126757 - compiler-errors:safe, r=spastorino
matthiaskrgr Jun 20, 2024
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
19 changes: 14 additions & 5 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,11 @@ pub enum NonterminalKind {
PatWithOr,
Expr,
/// Matches an expression using the rules from edition 2021 and earlier.
Expr2021,
Expr2021 {
/// Keep track of whether the user used `:expr` or `:expr_2021` and we inferred it from the
/// edition of the span. This is used for diagnostics AND feature gating.
inferred: bool,
},
Ty,
Ident,
Lifetime,
Expand Down Expand Up @@ -929,8 +933,13 @@ impl NonterminalKind {
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
},
sym::pat_param => NonterminalKind::PatParam { inferred: false },
sym::expr => NonterminalKind::Expr,
sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021,
sym::expr => match edition() {
Edition::Edition2015 | Edition::Edition2018 | Edition::Edition2021 => {
NonterminalKind::Expr2021 { inferred: true }
}
Edition::Edition2024 => NonterminalKind::Expr,
},
sym::expr_2021 => NonterminalKind::Expr2021 { inferred: false },
sym::ty => NonterminalKind::Ty,
sym::ident => NonterminalKind::Ident,
sym::lifetime => NonterminalKind::Lifetime,
Expand All @@ -949,8 +958,8 @@ impl NonterminalKind {
NonterminalKind::Stmt => sym::stmt,
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat,
NonterminalKind::Expr => sym::expr,
NonterminalKind::Expr2021 => sym::expr_2021,
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: true } => sym::expr,
NonterminalKind::Expr2021 { inferred: false } => sym::expr_2021,
NonterminalKind::Ty => sym::ty,
NonterminalKind::Ident => sym::ident,
NonterminalKind::Lifetime => sym::lifetime,
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
// maintain
IsInFollow::Yes
}
NonterminalKind::Stmt | NonterminalKind::Expr | NonterminalKind::Expr2021 => {
NonterminalKind::Stmt
| NonterminalKind::Expr
| NonterminalKind::Expr2021 { inferred: _ } => {
const TOKENS: &[&str] = &["`=>`", "`,`", "`;`"];
match tok {
TokenTree::Token(token) => match token.kind {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ pub(super) fn parse(
);
token::NonterminalKind::Ident
});
if kind == token::NonterminalKind::Expr2021
if kind
== (token::NonterminalKind::Expr2021 { inferred: false })
&& !features.expr_fragment_specifier_2024
{
rustc_session::parse::feature_err(
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_parse/src/parser/nonterminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> Parser<'a> {
}

match kind {
NonterminalKind::Expr2021 => {
NonterminalKind::Expr2021 { inferred: _ } => {
token.can_begin_expr()
// This exception is here for backwards compatibility.
&& !token.is_keyword(kw::Let)
Expand All @@ -47,7 +47,6 @@ impl<'a> Parser<'a> {
token.can_begin_expr()
// This exception is here for backwards compatibility.
&& !token.is_keyword(kw::Let)
&& (!token.is_keyword(kw::Const) || token.span.edition().at_least_rust_2024())
}
NonterminalKind::Ty => token.can_begin_type(),
NonterminalKind::Ident => get_macro_ident(token).is_some(),
Expand Down Expand Up @@ -149,7 +148,7 @@ impl<'a> Parser<'a> {
})?)
}

NonterminalKind::Expr | NonterminalKind::Expr2021 => {
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: _ } => {
NtExpr(self.parse_expr_force_collect()?)
}
NonterminalKind::Literal => {
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/macros/auxiliary/expr_2021_implicit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ edition:2021

#[macro_export]
macro_rules! m {
($expr:expr) => {
compile_error!("did not expect an expression to be parsed");
};
(const { }) => {};
}
12 changes: 12 additions & 0 deletions tests/ui/macros/expr_2021_implicit_in_2024.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ compile-flags: --edition=2024 -Zunstable-options
//@ aux-build:expr_2021_implicit.rs

//@ check-pass

extern crate expr_2021_implicit;

// Makes sure that a `:expr` fragment matcher defined in a edition 2021 crate
// still parses like an `expr_2021` fragment matcher in a 2024 user crate.
expr_2021_implicit::m!(const {});

fn main() {}
13 changes: 0 additions & 13 deletions tests/ui/macros/expr_2021_old_edition.rs

This file was deleted.

26 changes: 0 additions & 26 deletions tests/ui/macros/expr_2021_old_edition.stderr

This file was deleted.