Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #19379 from Veykril/push-nwmqsvtqpnko
chore: Bump `Edition::CURRENT` to 2024
Lukas Wirth 2025-03-17
parent facaf8b · parent a505420 · commit b03af79
-rw-r--r--bench_data/numerous_macro_rules2
-rw-r--r--crates/edition/src/lib.rs4
-rw-r--r--crates/hir-def/src/expander.rs2
-rw-r--r--crates/hir-def/src/item_tree/tests.rs2
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe.rs24
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe/matching.rs27
-rw-r--r--crates/hir-def/src/macro_expansion_tests/proc_macros.rs6
-rw-r--r--crates/hir-expand/src/builtin/quote.rs4
-rw-r--r--crates/hir-ty/src/tests/coercion.rs4
-rw-r--r--crates/ide-completion/src/tests/special.rs2
-rw-r--r--crates/ide-db/src/test_data/test_doc_alias.txt14
-rw-r--r--crates/ide-db/src/test_data/test_symbol_index_collection.txt60
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_unsafe.rs8
-rw-r--r--crates/ide-diagnostics/src/handlers/mutability_errors.rs2
-rw-r--r--crates/ide/src/goto_definition.rs8
-rw-r--r--crates/ide/src/runnables.rs24
-rw-r--r--crates/mbe/src/tests.rs160
-rw-r--r--crates/parser/src/grammar/items.rs2
-rw-r--r--crates/parser/test_data/generated/runner.rs7
-rw-r--r--crates/parser/test_data/parser/inline/err/gen_fn.rast8
-rw-r--r--crates/parser/test_data/parser/inline/err/gen_fn.rs1
-rw-r--r--crates/proc-macro-srv/src/tests/mod.rs130
-rw-r--r--crates/test-fixture/src/lib.rs4
-rw-r--r--crates/test-utils/src/minicore.rs16
24 files changed, 277 insertions, 244 deletions
diff --git a/bench_data/numerous_macro_rules b/bench_data/numerous_macro_rules
index 7610a3ae1e..60997065b2 100644
--- a/bench_data/numerous_macro_rules
+++ b/bench_data/numerous_macro_rules
@@ -528,7 +528,7 @@ macro_rules! __ra_macro_fixture526 {($expr : expr )=>{|| -> _ { Some ($expr )}(
macro_rules! __ra_macro_fixture527 {($($arg : tt )*)=>($crate :: io :: _print ($crate :: format_args ! ($($arg )*))); }
macro_rules! __ra_macro_fixture528 {($fmt : literal , $($tt : tt ),*)=>{ mbe :: ExpandError :: ProcMacroError ( tt :: ExpansionError :: Unknown ( format ! ($fmt , $($tt ),*)))}; ($fmt : literal )=>{ mbe :: ExpandError :: ProcMacroError ( tt :: ExpansionError :: Unknown ($fmt . to_string ()))}}
macro_rules! __ra_macro_fixture529 {($($tt : tt )* )=>{$crate :: quote :: IntoTt :: to_subtree ($crate :: __quote ! ($($tt )*))}}
-macro_rules! __ra_macro_fixture530 {()=>{ Vec ::< tt :: TokenTree >:: new ()}; (@ SUBTREE $delim : ident $($tt : tt )* )=>{{ let children = $crate :: __quote ! ($($tt )*); tt :: Subtree { delimiter : Some ( tt :: Delimiter { kind : tt :: DelimiterKind ::$delim , id : tt :: TokenId :: unspecified (), }), token_trees : $crate :: quote :: IntoTt :: to_tokens ( children ), }}}; (@ PUNCT $first : literal )=>{{ vec ! [ tt :: Leaf :: Punct ( tt :: Punct { char : $first , spacing : tt :: Spacing :: Alone , id : tt :: TokenId :: unspecified (), }). into ()]}}; (@ PUNCT $first : literal , $sec : literal )=>{{ vec ! [ tt :: Leaf :: Punct ( tt :: Punct { char : $first , spacing : tt :: Spacing :: Joint , id : tt :: TokenId :: unspecified (), }). into (), tt :: Leaf :: Punct ( tt :: Punct { char : $sec , spacing : tt :: Spacing :: Alone , id : tt :: TokenId :: unspecified (), }). into ()]}}; (# $first : ident $($tail : tt )* )=>{{ let token = $crate :: quote :: ToTokenTree :: to_token ($first ); let mut tokens = vec ! [ token . into ()]; let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; (## $first : ident $($tail : tt )* )=>{{ let mut tokens = $first . into_iter (). map ($crate :: quote :: ToTokenTree :: to_token ). collect ::< Vec < tt :: TokenTree >> (); let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; ({$($tt : tt )* })=>{$crate :: __quote ! (@ SUBTREE Brace $($tt )*)}; ([$($tt : tt )* ])=>{$crate :: __quote ! (@ SUBTREE Bracket $($tt )*)}; (($($tt : tt )* ))=>{$crate :: __quote ! (@ SUBTREE Parenthesis $($tt )*)}; ($tt : literal )=>{ vec ! [$crate :: quote :: ToTokenTree :: to_token ($tt ). into ()]}; ($tt : ident )=>{ vec ! [{ tt :: Leaf :: Ident ( tt :: Ident { text : stringify ! ($tt ). into (), id : tt :: TokenId :: unspecified (), }). into ()}]}; (-> )=>{$crate :: __quote ! (@ PUNCT '-' , '>' )}; (& )=>{$crate :: __quote ! (@ PUNCT '&' )}; (, )=>{$crate :: __quote ! (@ PUNCT ',' )}; (: )=>{$crate :: __quote ! (@ PUNCT ':' )}; (; )=>{$crate :: __quote ! (@ PUNCT ';' )}; (:: )=>{$crate :: __quote ! (@ PUNCT ':' , ':' )}; (. )=>{$crate :: __quote ! (@ PUNCT '.' )}; (< )=>{$crate :: __quote ! (@ PUNCT '<' )}; (> )=>{$crate :: __quote ! (@ PUNCT '>' )}; ($first : tt $($tail : tt )+ )=>{{ let mut tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($first )); let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; }
+macro_rules! __ra_macro_fixture530 {()=>{ Vec ::< tt :: TokenTree >:: new ()}; (@ SUBTREE $delim : ident $($tt : tt )* )=>{{ let children = $crate :: __quote ! ($($tt )*); tt :: Subtree { delimiter : Some ( tt :: Delimiter { kind : tt :: DelimiterKind ::$delim , id : tt :: TokenId :: unspecified (), }), token_trees : $crate :: quote :: IntoTt :: to_tokens ( children ), }}}; (@ PUNCT $first : literal )=>{{ vec ! [ tt :: Leaf :: Punct ( tt :: Punct { char : $first , spacing : tt :: Spacing :: Alone , id : tt :: TokenId :: unspecified (), }). into ()]}}; (@ PUNCT $first : literal , $sec : literal )=>{{ vec ! [ tt :: Leaf :: Punct ( tt :: Punct { char : $first , spacing : tt :: Spacing :: Joint , id : tt :: TokenId :: unspecified (), }). into (), tt :: Leaf :: Punct ( tt :: Punct { char : $sec , spacing : tt :: Spacing :: Alone , id : tt :: TokenId :: unspecified (), }). into ()]}}; (# $first : ident $($tail : tt )* )=>{{ let token = $crate :: quote :: ToTokenTree :: to_token ($first ); let mut tokens = vec ! [ token . into ()]; let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; (# # $first : ident $($tail : tt )* )=>{{ let mut tokens = $first . into_iter (). map ($crate :: quote :: ToTokenTree :: to_token ). collect ::< Vec < tt :: TokenTree >> (); let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; ({$($tt : tt )* })=>{$crate :: __quote ! (@ SUBTREE Brace $($tt )*)}; ([$($tt : tt )* ])=>{$crate :: __quote ! (@ SUBTREE Bracket $($tt )*)}; (($($tt : tt )* ))=>{$crate :: __quote ! (@ SUBTREE Parenthesis $($tt )*)}; ($tt : literal )=>{ vec ! [$crate :: quote :: ToTokenTree :: to_token ($tt ). into ()]}; ($tt : ident )=>{ vec ! [{ tt :: Leaf :: Ident ( tt :: Ident { text : stringify ! ($tt ). into (), id : tt :: TokenId :: unspecified (), }). into ()}]}; (-> )=>{$crate :: __quote ! (@ PUNCT '-' , '>' )}; (& )=>{$crate :: __quote ! (@ PUNCT '&' )}; (, )=>{$crate :: __quote ! (@ PUNCT ',' )}; (: )=>{$crate :: __quote ! (@ PUNCT ':' )}; (; )=>{$crate :: __quote ! (@ PUNCT ';' )}; (:: )=>{$crate :: __quote ! (@ PUNCT ':' , ':' )}; (. )=>{$crate :: __quote ! (@ PUNCT '.' )}; (< )=>{$crate :: __quote ! (@ PUNCT '<' )}; (> )=>{$crate :: __quote ! (@ PUNCT '>' )}; ($first : tt $($tail : tt )+ )=>{{ let mut tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($first )); let mut tail_tokens = $crate :: quote :: IntoTt :: to_tokens ($crate :: __quote ! ($($tail )*)); tokens . append (& mut tail_tokens ); tokens }}; }
macro_rules! __ra_macro_fixture531 {($($name : ident )*)=>{$(if let Some ( it )= & self .$name { f . field ( stringify ! ($name ), it ); })*}}
macro_rules! __ra_macro_fixture532 {($fmt : expr )=>{ RenameError ( format ! ($fmt ))}; ($fmt : expr , $($arg : tt )+)=>{ RenameError ( format ! ($fmt , $($arg )+))}}
macro_rules! __ra_macro_fixture533 {($($tokens : tt )*)=>{ return Err ( format_err ! ($($tokens )*))}}
diff --git a/crates/edition/src/lib.rs b/crates/edition/src/lib.rs
index 04e65fc378..f1a1fe5964 100644
--- a/crates/edition/src/lib.rs
+++ b/crates/edition/src/lib.rs
@@ -15,9 +15,9 @@ pub enum Edition {
impl Edition {
pub const DEFAULT: Edition = Edition::Edition2015;
pub const LATEST: Edition = Edition::Edition2024;
- pub const CURRENT: Edition = Edition::Edition2021;
+ pub const CURRENT: Edition = Edition::Edition2024;
/// The current latest stable edition, note this is usually not the right choice in code.
- pub const CURRENT_FIXME: Edition = Edition::Edition2021;
+ pub const CURRENT_FIXME: Edition = Edition::Edition2024;
pub fn from_u32(u32: u32) -> Edition {
match u32 {
diff --git a/crates/hir-def/src/expander.rs b/crates/hir-def/src/expander.rs
index 16cf969b88..7c182a4aba 100644
--- a/crates/hir-def/src/expander.rs
+++ b/crates/hir-def/src/expander.rs
@@ -56,7 +56,7 @@ impl Expander {
pub fn syntax_context(&self) -> SyntaxContext {
// FIXME:
- SyntaxContext::root(Edition::CURRENT)
+ SyntaxContext::root(Edition::CURRENT_FIXME)
}
pub fn enter_expand<T: ast::AstNode>(
diff --git a/crates/hir-def/src/item_tree/tests.rs b/crates/hir-def/src/item_tree/tests.rs
index 0651a5ed55..584fe98ee2 100644
--- a/crates/hir-def/src/item_tree/tests.rs
+++ b/crates/hir-def/src/item_tree/tests.rs
@@ -270,7 +270,7 @@ m!();
// AstId: 2
pub macro m2 { ... }
- // AstId: 3, SyntaxContextId: ROOT2021, ExpandTo: Items
+ // AstId: 3, SyntaxContextId: ROOT2024, ExpandTo: Items
m!(...);
"#]],
);
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe.rs b/crates/hir-def/src/macro_expansion_tests/mbe.rs
index bf0902a7e5..ddf1a213d7 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe.rs
@@ -35,7 +35,7 @@ macro_rules! f {
};
}
-struct#0:[email protected]#20480# MyTraitMap2#0:[email protected]#ROOT2021# {#0:[email protected]#20480#
+struct#0:[email protected]#20480# MyTraitMap2#0:[email protected]#ROOT2024# {#0:[email protected]#20480#
map#0:[email protected]#20480#:#0:[email protected]#20480# #0:[email protected]#20480#::#0:[email protected]#20480#std#0:[email protected]#20480#::#0:[email protected]#20480#collections#0:[email protected]#20480#::#0:[email protected]#20480#HashSet#0:[email protected]#20480#<#0:[email protected]#20480#(#0:[email protected]#20480#)#0:[email protected]#20480#>#0:[email protected]#20480#,#0:[email protected]#20480#
}#0:[email protected]#20480#
"#]],
@@ -75,12 +75,12 @@ macro_rules! f {
};
}
-fn#0:[email protected]#ROOT2021# main#0:[email protected]#ROOT2021#(#0:[email protected]#ROOT2021#)#0:[email protected]#ROOT2021# {#0:[email protected]#ROOT2021#
- 1#0:[email protected]#ROOT2021#;#0:[email protected]#ROOT2021#
- 1.0#0:[email protected]#ROOT2021#;#0:[email protected]#ROOT2021#
- (#0:[email protected]#ROOT2021#(#0:[email protected]#ROOT2021#1#0:[email protected]#ROOT2021#,#0:[email protected]#ROOT2021# )#0:[email protected]#ROOT2021#,#0:[email protected]#ROOT2021# )#0:[email protected]#ROOT2021#.#0:[email protected]#ROOT2021#0#0:[email protected]#ROOT2021#.#0:[email protected]#ROOT2021#0#0:[email protected]#ROOT2021#;#0:[email protected]#ROOT2021#
- let#0:[email protected]#ROOT2021# x#0:[email protected]#ROOT2021# =#0:[email protected]#ROOT2021# 1#0:[email protected]#ROOT2021#;#0:[email protected]#ROOT2021#
-}#0:[email protected]#ROOT2021#
+fn#0:[email protected]#ROOT2024# main#0:[email protected]#ROOT2024#(#0:[email protected]#ROOT2024#)#0:[email protected]#ROOT2024# {#0:[email protected]#ROOT2024#
+ 1#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ 1.0#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ (#0:[email protected]#ROOT2024#(#0:[email protected]#ROOT2024#1#0:[email protected]#ROOT2024#,#0:[email protected]#ROOT2024# )#0:[email protected]#ROOT2024#,#0:[email protected]#ROOT2024# )#0:[email protected]#ROOT2024#.#0:[email protected]#ROOT2024#0#0:[email protected]#ROOT2024#.#0:[email protected]#ROOT2024#0#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+ let#0:[email protected]#ROOT2024# x#0:[email protected]#ROOT2024# =#0:[email protected]#ROOT2024# 1#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+}#0:[email protected]#ROOT2024#
"#]],
@@ -171,7 +171,7 @@ fn main(foo: ()) {
}
fn main(foo: ()) {
- /* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#ROOT2021#;
+ /* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#ROOT2024#;
}
}
@@ -197,7 +197,7 @@ macro_rules! mk_struct {
#[macro_use]
mod foo;
-struct#1:[email protected]#20480# Foo#0:[email protected]#ROOT2021#(#1:[email protected]#20480#u32#0:[email protected]#ROOT2021#)#1:[email protected]#20480#;#1:[email protected]#20480#
+struct#1:[email protected]#20480# Foo#0:[email protected]#ROOT2024#(#1:[email protected]#20480#u32#0:[email protected]#ROOT2024#)#1:[email protected]#20480#;#1:[email protected]#20480#
"#]],
);
}
@@ -424,8 +424,8 @@ macro_rules! m {
($($i:ident),*) => ( impl Bar { $(fn $i() {})* } );
}
impl#\20480# Bar#\20480# {#\20480#
- fn#\20480# foo#\ROOT2021#(#\20480#)#\20480# {#\20480#}#\20480#
- fn#\20480# bar#\ROOT2021#(#\20480#)#\20480# {#\20480#}#\20480#
+ fn#\20480# foo#\ROOT2024#(#\20480#)#\20480# {#\20480#}#\20480#
+ fn#\20480# bar#\ROOT2024#(#\20480#)#\20480# {#\20480#}#\20480#
}#\20480#
"#]],
);
@@ -1408,7 +1408,7 @@ ok!();
macro_rules! m2 {
($($a:expr => $b:ident)* _ => $c:expr) => { ok!(); }
}
-ok!();
+/* error: unexpected token in input */ok!();
"#]],
);
}
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
index e9a977da91..e33a366769 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
@@ -162,9 +162,10 @@ fn test() {
}
#[test]
-fn expr_dont_match_inline_const() {
+fn expr_inline_const() {
check(
r#"
+//- /lib.rs edition:2021
macro_rules! foo {
($e:expr) => { $e }
}
@@ -183,6 +184,30 @@ fn test() {
}
"#]],
);
+ check(
+ r#"
+//- /lib.rs edition:2024
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ foo!(const { 3 });
+}
+"#,
+ expect![[r#"
+macro_rules! foo {
+ ($e:expr) => { $e }
+}
+
+fn test() {
+ (const {
+ 3
+ }
+ );
+}
+"#]],
+ );
}
#[test]
diff --git a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
index 3009b72499..b2e1adc365 100644
--- a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
+++ b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
@@ -181,9 +181,9 @@ fn foo(&self) {
self.0. 1;
}
-fn#0:[email protected]#ROOT2021# foo#0:[email protected]#ROOT2021#(#0:[email protected]#ROOT2021#&#0:[email protected]#ROOT2021#self#0:[email protected]#ROOT2021# )#0:[email protected]#ROOT2021# {#0:[email protected]#ROOT2021#
- self#0:[email protected]#ROOT2021# .#0:[email protected]#ROOT2021#0#0:[email protected]#ROOT2021#.#0:[email protected]#ROOT2021#1#0:[email protected]#ROOT2021#;#0:[email protected]#ROOT2021#
-}#0:[email protected]#ROOT2021#"#]],
+fn#0:[email protected]#ROOT2024# foo#0:[email protected]#ROOT2024#(#0:[email protected]#ROOT2024#&#0:[email protected]#ROOT2024#self#0:[email protected]#ROOT2024# )#0:[email protected]#ROOT2024# {#0:[email protected]#ROOT2024#
+ self#0:[email protected]#ROOT2024# .#0:[email protected]#ROOT2024#0#0:[email protected]#ROOT2024#.#0:[email protected]#ROOT2024#1#0:[email protected]#ROOT2024#;#0:[email protected]#ROOT2024#
+}#0:[email protected]#ROOT2024#"#]],
);
}
diff --git a/crates/hir-expand/src/builtin/quote.rs b/crates/hir-expand/src/builtin/quote.rs
index 7e159d999d..f19edacbe3 100644
--- a/crates/hir-expand/src/builtin/quote.rs
+++ b/crates/hir-expand/src/builtin/quote.rs
@@ -277,8 +277,8 @@ mod tests {
assert_eq!(quoted.to_string(), "hello");
let t = format!("{quoted:#?}");
expect![[r#"
- SUBTREE $$ 937550:[email protected]#ROOT2021 937550:[email protected]#ROOT2021
- IDENT hello 937550:[email protected]#ROOT2021"#]]
+ SUBTREE $$ 937550:[email protected]#ROOT2024 937550:[email protected]#ROOT2024
+ IDENT hello 937550:[email protected]#ROOT2024"#]]
.assert_eq(&t);
}
diff --git a/crates/hir-ty/src/tests/coercion.rs b/crates/hir-ty/src/tests/coercion.rs
index 7e7c1f835c..eeaacbf12e 100644
--- a/crates/hir-ty/src/tests/coercion.rs
+++ b/crates/hir-ty/src/tests/coercion.rs
@@ -22,9 +22,9 @@ struct S<T> { a: T }
fn f<T>(_: &[T]) -> T { loop {} }
fn g<T>(_: S<&[T]>) -> T { loop {} }
-fn gen<T>() -> *mut [T; 2] { loop {} }
+fn generate<T>() -> *mut [T; 2] { loop {} }
fn test1<U>() -> *mut [U] {
- gen()
+ generate()
}
fn test2() {
diff --git a/crates/ide-completion/src/tests/special.rs b/crates/ide-completion/src/tests/special.rs
index 355f04bf0a..afb41cf613 100644
--- a/crates/ide-completion/src/tests/special.rs
+++ b/crates/ide-completion/src/tests/special.rs
@@ -105,7 +105,7 @@ mod macros {
fn completes_std_prelude_if_core_is_defined() {
check_no_kw(
r#"
-//- /main.rs crate:main deps:core,std
+//- /main.rs crate:main deps:core,std edition:2021
fn foo() { let x: $0 }
//- /core/lib.rs crate:core
diff --git a/crates/ide-db/src/test_data/test_doc_alias.txt b/crates/ide-db/src/test_data/test_doc_alias.txt
index a527ce19d2..ea50745d67 100644
--- a/crates/ide-db/src/test_data/test_doc_alias.txt
+++ b/crates/ide-db/src/test_data/test_doc_alias.txt
@@ -26,7 +26,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -59,7 +59,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -92,7 +92,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -125,7 +125,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -158,7 +158,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -191,7 +191,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -224,7 +224,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
diff --git a/crates/ide-db/src/test_data/test_symbol_index_collection.txt b/crates/ide-db/src/test_data/test_symbol_index_collection.txt
index 82440d7c1e..d2d24262f0 100644
--- a/crates/ide-db/src/test_data/test_symbol_index_collection.txt
+++ b/crates/ide-db/src/test_data/test_symbol_index_collection.txt
@@ -24,7 +24,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: TYPE_ALIAS,
@@ -55,7 +55,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: CONST,
@@ -86,7 +86,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: CONST,
@@ -119,7 +119,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: ENUM,
@@ -152,7 +152,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -185,7 +185,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: MACRO_DEF,
@@ -216,7 +216,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STATIC,
@@ -249,7 +249,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -312,7 +312,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -347,7 +347,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -382,7 +382,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -415,7 +415,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -446,7 +446,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: TRAIT,
@@ -479,7 +479,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -512,7 +512,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: UNION,
@@ -547,7 +547,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: MODULE,
@@ -582,7 +582,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: MODULE,
@@ -615,7 +615,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: MACRO_RULES,
@@ -646,7 +646,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: FN,
@@ -679,7 +679,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: FN,
@@ -714,7 +714,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: MACRO_RULES,
@@ -745,7 +745,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: FN,
@@ -778,7 +778,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -809,7 +809,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: FN,
@@ -857,7 +857,7 @@
FileId(
0,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -901,7 +901,7 @@
FileId(
1,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -934,7 +934,7 @@
FileId(
1,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -967,7 +967,7 @@
FileId(
1,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: STRUCT,
@@ -1000,7 +1000,7 @@
FileId(
1,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
@@ -1033,7 +1033,7 @@
FileId(
1,
),
- Edition2021,
+ Edition2024,
),
ptr: SyntaxNodePtr {
kind: USE_TREE,
diff --git a/crates/ide-diagnostics/src/handlers/missing_unsafe.rs b/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
index e2690c2dcd..a9b481f899 100644
--- a/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
@@ -137,13 +137,13 @@ struct HasUnsafe;
impl HasUnsafe {
unsafe fn unsafe_fn(&self) {
let x = &5_usize as *const usize;
- let _y = *x;
+ let _y = unsafe {*x};
}
}
unsafe fn unsafe_fn() {
let x = &5_usize as *const usize;
- let _y = *x;
+ let _y = unsafe {*x};
}
fn main() {
@@ -337,7 +337,7 @@ struct S(usize);
impl S {
unsafe fn func(&self) {
let x = &self.0 as *const usize;
- let _z = *x;
+ let _z = unsafe { *x };
}
}
fn main() {
@@ -350,7 +350,7 @@ struct S(usize);
impl S {
unsafe fn func(&self) {
let x = &self.0 as *const usize;
- let _z = *x;
+ let _z = unsafe { *x };
}
}
fn main() {
diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
index c9c5531c6d..4f528dea55 100644
--- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs
+++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
@@ -1258,7 +1258,7 @@ fn foo(mut foo: Foo) {
pub struct A {}
pub unsafe fn foo(a: *mut A) {
- let mut b = || -> *mut A { &mut *a };
+ let mut b = || -> *mut A { unsafe { &mut *a } };
//^^^^^ 💡 warn: variable does not need to be mutable
let _ = b();
}
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index e920ff5ab4..fe8295ca2d 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -2192,8 +2192,8 @@ where T : Bound
struct A;
impl Bound for A{}
fn f() {
- let gen = Gen::<A>(A);
- gen.g$0();
+ let g = Gen::<A>(A);
+ g.g$0();
}
"#,
);
@@ -2218,8 +2218,8 @@ where T : Bound
struct A;
impl Bound for A{}
fn f() {
- let gen = Gen::<A>(A);
- gen.g$0();
+ let g = Gen::<A>(A);
+ g.g$0();
}
"#,
);
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 44dd38ed9c..fac690c27e 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -1210,13 +1210,13 @@ impl Foo {
r#"
//- /lib.rs
$0
-macro_rules! gen {
+macro_rules! generate {
() => {
#[test]
fn foo_test() {}
}
}
-macro_rules! gen2 {
+macro_rules! generate2 {
() => {
mod tests2 {
#[test]
@@ -1224,25 +1224,25 @@ macro_rules! gen2 {
}
}
}
-macro_rules! gen_main {
+macro_rules! generate_main {
() => {
fn main() {}
}
}
mod tests {
- gen!();
+ generate!();
}
-gen2!();
-gen_main!();
+generate2!();
+generate_main!();
"#,
expect![[r#"
[
- "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 0..315, name: \"\", kind: Module })",
- "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 267..292, focus_range: 271..276, name: \"tests\", kind: Module, description: \"mod tests\" })",
- "(Test, NavigationTarget { file_id: FileId(0), full_range: 283..290, name: \"foo_test\", kind: Function })",
- "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 293..301, name: \"tests2\", kind: Module, description: \"mod tests2\" }, true)",
- "(Test, NavigationTarget { file_id: FileId(0), full_range: 293..301, name: \"foo_test2\", kind: Function }, true)",
- "(Bin, NavigationTarget { file_id: FileId(0), full_range: 302..314, name: \"main\", kind: Function })",
+ "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 0..345, name: \"\", kind: Module })",
+ "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 282..312, focus_range: 286..291, name: \"tests\", kind: Module, description: \"mod tests\" })",
+ "(Test, NavigationTarget { file_id: FileId(0), full_range: 298..310, name: \"foo_test\", kind: Function })",
+ "(TestMod, NavigationTarget { file_id: FileId(0), full_range: 313..326, name: \"tests2\", kind: Module, description: \"mod tests2\" }, true)",
+ "(Test, NavigationTarget { file_id: FileId(0), full_range: 313..326, name: \"foo_test2\", kind: Function }, true)",
+ "(Bin, NavigationTarget { file_id: FileId(0), full_range: 327..344, name: \"main\", kind: Function })",
]
"#]],
);
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index 763ec14052..a5672e4e05 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -109,8 +109,8 @@ fn unbalanced_brace() {
"#,
r#""#,
expect![[r#"
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- SUBTREE {} 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ SUBTREE {} 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
{}"#]],
);
@@ -132,25 +132,25 @@ fn token_mapping_smoke_test() {
struct MyTraitMap2
"#,
expect![[r#"
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- IDENT struct 0:[email protected]#ROOT2021
- IDENT MyTraitMap2 1:[email protected]#ROOT2021
- SUBTREE {} 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- IDENT map 0:[email protected]#ROOT2021
- PUNCH : [alone] 0:[email protected]#ROOT2021
- PUNCH : [joint] 0:[email protected]#ROOT2021
- PUNCH : [alone] 0:[email protected]#ROOT2021
- IDENT std 0:[email protected]#ROOT2021
- PUNCH : [joint] 0:[email protected]#ROOT2021
- PUNCH : [alone] 0:[email protected]#ROOT2021
- IDENT collections 0:[email protected]#ROOT2021
- PUNCH : [joint] 0:[email protected]#ROOT2021
- PUNCH : [alone] 0:[email protected]#ROOT2021
- IDENT HashSet 0:[email protected]#ROOT2021
- PUNCH < [alone] 0:[email protected]#ROOT2021
- SUBTREE () 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- PUNCH > [joint] 0:[email protected]#ROOT2021
- PUNCH , [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ IDENT struct 0:[email protected]#ROOT2024
+ IDENT MyTraitMap2 1:[email protected]#ROOT2024
+ SUBTREE {} 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ IDENT map 0:[email protected]#ROOT2024
+ PUNCH : [alone] 0:[email protected]#ROOT2024
+ PUNCH : [joint] 0:[email protected]#ROOT2024
+ PUNCH : [alone] 0:[email protected]#ROOT2024
+ IDENT std 0:[email protected]#ROOT2024
+ PUNCH : [joint] 0:[email protected]#ROOT2024
+ PUNCH : [alone] 0:[email protected]#ROOT2024
+ IDENT collections 0:[email protected]#ROOT2024
+ PUNCH : [joint] 0:[email protected]#ROOT2024
+ PUNCH : [alone] 0:[email protected]#ROOT2024
+ IDENT HashSet 0:[email protected]#ROOT2024
+ PUNCH < [alone] 0:[email protected]#ROOT2024
+ SUBTREE () 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ PUNCH > [joint] 0:[email protected]#ROOT2024
+ PUNCH , [alone] 0:[email protected]#ROOT2024
struct MyTraitMap2 {
map: ::std::collections::HashSet<()>,
@@ -179,28 +179,28 @@ fn main() {
}
"#,
expect![[r#"
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- IDENT fn 1:[email protected]#ROOT2021
- IDENT main 1:[email protected]#ROOT2021
- SUBTREE () 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- SUBTREE {} 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- LITERAL Integer 1 1:[email protected]#ROOT2021
- PUNCH ; [alone] 1:[email protected]#ROOT2021
- LITERAL Float 1.0 1:[email protected]#ROOT2021
- PUNCH ; [alone] 1:[email protected]#ROOT2021
- SUBTREE () 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- SUBTREE () 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- LITERAL Integer 1 1:[email protected]#ROOT2021
- PUNCH , [alone] 1:[email protected]#ROOT2021
- PUNCH , [alone] 1:[email protected]#ROOT2021
- PUNCH . [alone] 1:[email protected]#ROOT2021
- LITERAL Float 0.0 1:[email protected]#ROOT2021
- PUNCH ; [alone] 1:[email protected]#ROOT2021
- IDENT let 1:[email protected]#ROOT2021
- IDENT x 1:[email protected]#ROOT2021
- PUNCH = [alone] 1:[email protected]#ROOT2021
- LITERAL Integer 1 1:[email protected]#ROOT2021
- PUNCH ; [alone] 1:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ IDENT fn 1:[email protected]#ROOT2024
+ IDENT main 1:[email protected]#ROOT2024
+ SUBTREE () 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ SUBTREE {} 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ LITERAL Integer 1 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 1:[email protected]#ROOT2024
+ LITERAL Float 1.0 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 1:[email protected]#ROOT2024
+ SUBTREE () 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ SUBTREE () 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ LITERAL Integer 1 1:[email protected]#ROOT2024
+ PUNCH , [alone] 1:[email protected]#ROOT2024
+ PUNCH , [alone] 1:[email protected]#ROOT2024
+ PUNCH . [alone] 1:[email protected]#ROOT2024
+ LITERAL Float 0.0 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 1:[email protected]#ROOT2024
+ IDENT let 1:[email protected]#ROOT2024
+ IDENT x 1:[email protected]#ROOT2024
+ PUNCH = [alone] 1:[email protected]#ROOT2024
+ LITERAL Integer 1 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 1:[email protected]#ROOT2024
fn main(){
1;
@@ -226,14 +226,14 @@ fn expr_2021() {
const { 1 },
"#,
expect![[r#"
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- IDENT _ 1:[email protected]#ROOT2021
- PUNCH ; [joint] 0:[email protected]#ROOT2021
- SUBTREE () 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- IDENT const 1:[email protected]#ROOT2021
- SUBTREE {} 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- LITERAL Integer 1 1:[email protected]#ROOT2021
- PUNCH ; [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ IDENT _ 1:[email protected]#ROOT2024
+ PUNCH ; [joint] 0:[email protected]#ROOT2024
+ SUBTREE () 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ IDENT const 1:[email protected]#ROOT2024
+ SUBTREE {} 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ LITERAL Integer 1 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 0:[email protected]#ROOT2024
_;
(const {
@@ -254,13 +254,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
- 1:[email protected]#ROOT2021,
+ 1:[email protected]#ROOT2024,
NoMatchingRule,
),
}
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- PUNCH ; [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 0:[email protected]#ROOT2024
;"#]],
);
@@ -278,13 +278,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
- 1:[email protected]#ROOT2021,
+ 1:[email protected]#ROOT2024,
NoMatchingRule,
),
}
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- PUNCH ; [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 0:[email protected]#ROOT2024
;"#]],
);
@@ -304,26 +304,26 @@ fn expr_2021() {
break 'foo bar,
"#,
expect![[r#"
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- LITERAL Integer 4 1:[email protected]#ROOT2021
- PUNCH ; [joint] 0:[email protected]#ROOT2021
- LITERAL Str literal 1:[email protected]#ROOT2021
- PUNCH ; [joint] 0:[email protected]#ROOT2021
- SUBTREE () 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- IDENT funcall 1:[email protected]#ROOT2021
- SUBTREE () 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- PUNCH ; [joint] 0:[email protected]#ROOT2021
- SUBTREE () 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- IDENT future 1:[email protected]#ROOT2021
- PUNCH . [alone] 1:[email protected]#ROOT2021
- IDENT await 1:[email protected]#ROOT2021
- PUNCH ; [joint] 0:[email protected]#ROOT2021
- SUBTREE () 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021
- IDENT break 1:[email protected]#ROOT2021
- PUNCH ' [joint] 1:[email protected]#ROOT2021
- IDENT foo 1:[email protected]#ROOT2021
- IDENT bar 1:[email protected]#ROOT2021
- PUNCH ; [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ LITERAL Integer 4 1:[email protected]#ROOT2024
+ PUNCH ; [joint] 0:[email protected]#ROOT2024
+ LITERAL Str literal 1:[email protected]#ROOT2024
+ PUNCH ; [joint] 0:[email protected]#ROOT2024
+ SUBTREE () 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ IDENT funcall 1:[email protected]#ROOT2024
+ SUBTREE () 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ PUNCH ; [joint] 0:[email protected]#ROOT2024
+ SUBTREE () 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ IDENT future 1:[email protected]#ROOT2024
+ PUNCH . [alone] 1:[email protected]#ROOT2024
+ IDENT await 1:[email protected]#ROOT2024
+ PUNCH ; [joint] 0:[email protected]#ROOT2024
+ SUBTREE () 0:[email protected]#ROOT2024 0:[email protected]#ROOT2024
+ IDENT break 1:[email protected]#ROOT2024
+ PUNCH ' [joint] 1:[email protected]#ROOT2024
+ IDENT foo 1:[email protected]#ROOT2024
+ IDENT bar 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 0:[email protected]#ROOT2024
4;
"literal";
@@ -345,13 +345,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
- 1:[email protected]#ROOT2021,
+ 1:[email protected]#ROOT2024,
NoMatchingRule,
),
}
- SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
- PUNCH ; [alone] 0:[email protected]#ROOT2021
+ SUBTREE $$ 1:[email protected]#ROOT2024 1:[email protected]#ROOT2024
+ PUNCH ; [alone] 0:[email protected]#ROOT2024
;"#]],
);
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 0ac11371c5..f5f003be48 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -132,7 +132,7 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker, is_in_extern: bool) -> Res
has_mods = true;
}
- // test_err gen_fn
+ // test_err gen_fn 2021
// gen fn gen_fn() {}
// async gen fn async_gen_fn() {}
if p.at(T![gen]) && p.nth(1) == T![fn] {
diff --git a/crates/parser/test_data/generated/runner.rs b/crates/parser/test_data/generated/runner.rs
index 1a74773158..2ea29345ed 100644
--- a/crates/parser/test_data/generated/runner.rs
+++ b/crates/parser/test_data/generated/runner.rs
@@ -745,7 +745,12 @@ mod err {
run_and_expect_errors("test_data/parser/inline/err/fn_pointer_type_missing_fn.rs");
}
#[test]
- fn gen_fn() { run_and_expect_errors("test_data/parser/inline/err/gen_fn.rs"); }
+ fn gen_fn() {
+ run_and_expect_errors_with_edition(
+ "test_data/parser/inline/err/gen_fn.rs",
+ crate::Edition::Edition2021,
+ );
+ }
#[test]
fn generic_arg_list_recover() {
run_and_expect_errors("test_data/parser/inline/err/generic_arg_list_recover.rs");
diff --git a/crates/parser/test_data/parser/inline/err/gen_fn.rast b/crates/parser/test_data/parser/inline/err/gen_fn.rast
index f8a7d0e552..b6fd5a5d99 100644
--- a/crates/parser/test_data/parser/inline/err/gen_fn.rast
+++ b/crates/parser/test_data/parser/inline/err/gen_fn.rast
@@ -1,4 +1,6 @@
SOURCE_FILE
+ COMMENT "// 2021"
+ WHITESPACE "\n"
ERROR
PATH
PATH_SEGMENT
@@ -42,6 +44,6 @@ SOURCE_FILE
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
-error 3: expected an item
-error 24: expected fn, trait or impl
-error 28: expected an item
+error 11: expected an item
+error 32: expected fn, trait or impl
+error 36: expected an item
diff --git a/crates/parser/test_data/parser/inline/err/gen_fn.rs b/crates/parser/test_data/parser/inline/err/gen_fn.rs
index 80882e0a40..778693ca95 100644
--- a/crates/parser/test_data/parser/inline/err/gen_fn.rs
+++ b/crates/parser/test_data/parser/inline/err/gen_fn.rs
@@ -1,2 +1,3 @@
+// 2021
gen fn gen_fn() {}
async gen fn async_gen_fn() {}
diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs
index b2ffa4ca80..a81fea7bec 100644
--- a/crates/proc-macro-srv/src/tests/mod.rs
+++ b/crates/proc-macro-srv/src/tests/mod.rs
@@ -12,7 +12,7 @@ fn test_derive_empty() {
"DeriveEmpty",
r#"struct S;"#,
expect!["SUBTREE $$ 1 1"],
- expect!["SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021"],
+ expect!["SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024"],
);
}
@@ -29,12 +29,12 @@ fn test_derive_error() {
LITERAL Str #[derive(DeriveError)] struct S ; 1
PUNCH ; [alone] 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT compile_error 42:[email protected]#ROOT2021
- PUNCH ! [alone] 42:[email protected]#ROOT2021
- SUBTREE () 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- LITERAL Str #[derive(DeriveError)] struct S ; 42:[email protected]#ROOT2021
- PUNCH ; [alone] 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT compile_error 42:[email protected]#ROOT2024
+ PUNCH ! [alone] 42:[email protected]#ROOT2024
+ SUBTREE () 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ LITERAL Str #[derive(DeriveError)] struct S ; 42:[email protected]#ROOT2024
+ PUNCH ; [alone] 42:[email protected]#ROOT2024"#]],
);
}
@@ -53,14 +53,14 @@ fn test_fn_like_macro_noop() {
PUNCH , [alone] 1
SUBTREE [] 1 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT ident 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Integer 0 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Integer 1 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- SUBTREE [] 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT ident 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Integer 0 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Integer 1 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ SUBTREE [] 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024"#]],
);
}
@@ -75,10 +75,10 @@ fn test_fn_like_macro_clone_ident_subtree() {
PUNCH , [alone] 1
SUBTREE [] 1 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT ident 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- SUBTREE [] 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT ident 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ SUBTREE [] 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024"#]],
);
}
@@ -91,8 +91,8 @@ fn test_fn_like_macro_clone_raw_ident() {
SUBTREE $$ 1 1
IDENT r#async 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT r#async 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT r#async 42:[email protected]#ROOT2024"#]],
);
}
@@ -105,8 +105,8 @@ fn test_fn_like_fn_like_span_join() {
SUBTREE $$ 1 1
IDENT r#joined 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT r#joined 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT r#joined 42:[email protected]#ROOT2024"#]],
);
}
@@ -121,10 +121,10 @@ fn test_fn_like_fn_like_span_ops() {
IDENT resolved_at_def_site 1
IDENT start_span 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT set_def_site 41:[email protected]#ROOT2021
- IDENT resolved_at_def_site 42:[email protected]#ROOT2021
- IDENT start_span 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT set_def_site 41:[email protected]#ROOT2024
+ IDENT resolved_at_def_site 42:[email protected]#ROOT2024
+ IDENT start_span 42:[email protected]#ROOT2024"#]],
);
}
@@ -143,14 +143,14 @@ fn test_fn_like_mk_literals() {
LITERAL Integer 123i64 1
LITERAL Integer 123 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- LITERAL ByteStr byte_string 42:[email protected]#ROOT2021
- LITERAL Char c 42:[email protected]#ROOT2021
- LITERAL Str string 42:[email protected]#ROOT2021
- LITERAL Float 3.14f64 42:[email protected]#ROOT2021
- LITERAL Float 3.14 42:[email protected]#ROOT2021
- LITERAL Integer 123i64 42:[email protected]#ROOT2021
- LITERAL Integer 123 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ LITERAL ByteStr byte_string 42:[email protected]#ROOT2024
+ LITERAL Char c 42:[email protected]#ROOT2024
+ LITERAL Str string 42:[email protected]#ROOT2024
+ LITERAL Float 3.14f64 42:[email protected]#ROOT2024
+ LITERAL Float 3.14 42:[email protected]#ROOT2024
+ LITERAL Integer 123i64 42:[email protected]#ROOT2024
+ LITERAL Integer 123 42:[email protected]#ROOT2024"#]],
);
}
@@ -164,9 +164,9 @@ fn test_fn_like_mk_idents() {
IDENT standard 1
IDENT r#raw 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT standard 42:[email protected]#ROOT2021
- IDENT r#raw 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT standard 42:[email protected]#ROOT2024
+ IDENT r#raw 42:[email protected]#ROOT2024"#]],
);
}
@@ -198,27 +198,27 @@ fn test_fn_like_macro_clone_literals() {
PUNCH , [alone] 1
LITERAL CStr null 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- LITERAL Integer 1u16 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Integer 2_u32 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- PUNCH - [alone] 42:[email protected]#ROOT2021
- LITERAL Integer 4i64 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Float 3.14f32 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Str hello bridge 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Str suffixedsuffix 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL StrRaw(2) raw 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Char a 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL Byte b 42:[email protected]#ROOT2021
- PUNCH , [alone] 42:[email protected]#ROOT2021
- LITERAL CStr null 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ LITERAL Integer 1u16 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Integer 2_u32 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ PUNCH - [alone] 42:[email protected]#ROOT2024
+ LITERAL Integer 4i64 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Float 3.14f32 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Str hello bridge 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Str suffixedsuffix 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL StrRaw(2) raw 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Char a 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL Byte b 42:[email protected]#ROOT2024
+ PUNCH , [alone] 42:[email protected]#ROOT2024
+ LITERAL CStr null 42:[email protected]#ROOT2024"#]],
);
}
@@ -239,12 +239,12 @@ fn test_attr_macro() {
LITERAL Str #[attr_error(some arguments)] mod m {} 1
PUNCH ; [alone] 1"#]],
expect![[r#"
- SUBTREE $$ 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- IDENT compile_error 42:[email protected]#ROOT2021
- PUNCH ! [alone] 42:[email protected]#ROOT2021
- SUBTREE () 42:[email protected]#ROOT2021 42:[email protected]#ROOT2021
- LITERAL Str #[attr_error(some arguments)] mod m {} 42:[email protected]#ROOT2021
- PUNCH ; [alone] 42:[email protected]#ROOT2021"#]],
+ SUBTREE $$ 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ IDENT compile_error 42:[email protected]#ROOT2024
+ PUNCH ! [alone] 42:[email protected]#ROOT2024
+ SUBTREE () 42:[email protected]#ROOT2024 42:[email protected]#ROOT2024
+ LITERAL Str #[attr_error(some arguments)] mod m {} 42:[email protected]#ROOT2024
+ PUNCH ; [alone] 42:[email protected]#ROOT2024"#]],
);
}
diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs
index 3fea49d1f6..f0b85b4ab3 100644
--- a/crates/test-fixture/src/lib.rs
+++ b/crates/test-fixture/src/lib.rs
@@ -145,6 +145,7 @@ impl ChangeFixture {
let mut crates = FxHashMap::default();
let mut crate_deps = Vec::new();
let mut default_crate_root: Option<FileId> = None;
+ let mut default_edition = Edition::CURRENT;
let mut default_cfg = CfgOptions::default();
let mut default_env = Env::from_iter([(
String::from("__ra_is_test_fixture"),
@@ -228,6 +229,7 @@ impl ChangeFixture {
} else if meta.path == "/main.rs" || meta.path == "/lib.rs" {
assert!(default_crate_root.is_none());
default_crate_root = Some(file_id);
+ default_edition = meta.edition;
default_cfg.extend(meta.cfg.into_iter());
default_env.extend_from_other(&meta.env);
}
@@ -244,7 +246,7 @@ impl ChangeFixture {
.expect("missing default crate root, specify a main.rs or lib.rs");
crate_graph.add_crate_root(
crate_root,
- Edition::CURRENT,
+ default_edition,
Some(CrateName::new("ra_test_fixture").unwrap().into()),
None,
default_cfg.clone(),
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index bf53e58d70..4a2896ab14 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -423,10 +423,12 @@ pub mod ptr {
unsafe { drop_in_place(to_drop) }
}
pub const unsafe fn read<T>(src: *const T) -> T {
- *src
+ unsafe { *src }
}
pub const unsafe fn write<T>(dst: *mut T, src: T) {
- *dst = src;
+ unsafe {
+ *dst = src;
+ }
}
// endregion:drop
@@ -1480,9 +1482,9 @@ pub mod iter {
}
}
}
- pub use self::repeat::{repeat, Repeat};
+ pub use self::repeat::{Repeat, repeat};
}
- pub use self::sources::{repeat, Repeat};
+ pub use self::sources::{Repeat, repeat};
// endregion:iterators
mod traits {
@@ -1811,11 +1813,7 @@ pub mod num {
#[lang = "bool"]
impl bool {
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
- if self {
- Some(f())
- } else {
- None
- }
+ if self { Some(f()) } else { None }
}
}
// endregion:bool_impl