Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions crates/edition/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ impl Edition {
self >= Edition::Edition2018
}

pub fn number(&self) -> usize {
match self {
Edition::Edition2015 => 2015,
Edition::Edition2018 => 2018,
Edition::Edition2021 => 2021,
Edition::Edition2024 => 2024,
}
}

pub fn iter() -> impl Iterator<Item = Edition> {
[Edition::Edition2015, Edition::Edition2018, Edition::Edition2021, Edition::Edition2024]
.iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/item_tree/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ m!();
// AstId: 2
pub macro m2 { ... }
// AstId: 3, SyntaxContextId: 4294967037, ExpandTo: Items
// AstId: 3, SyntaxContextId: ROOT2021, ExpandTo: Items
m!(...);
"#]],
);
Expand Down
22 changes: 11 additions & 11 deletions crates/hir-def/src/macro_expansion_tests/mbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! f {
};
}
struct#0:[email protected]#20480# MyTraitMap2#0:[email protected]#4294967037# {#0:[email protected]#20480#
struct#0:[email protected]#20480# MyTraitMap2#0:[email protected]#ROOT2021# {#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#
"#]],
Expand Down Expand Up @@ -75,12 +75,12 @@ macro_rules! f {
};
}
fn#0:[email protected]#4294967037# main#0:[email protected]#4294967037#(#0:[email protected]#4294967037#)#0:[email protected]#4294967037# {#0:[email protected]#4294967037#
1#0:[email protected]#4294967037#;#0:[email protected]#4294967037#
1.0#0:[email protected]#4294967037#;#0:[email protected]#4294967037#
(#0:[email protected]#4294967037#(#0:[email protected]#4294967037#1#0:[email protected]#4294967037#,#0:[email protected]#4294967037# )#0:[email protected]#4294967037#,#0:[email protected]#4294967037# )#0:[email protected]#4294967037#.#0:[email protected]#4294967037#0#0:[email protected]#4294967037#.#0:[email protected]#4294967037#0#0:[email protected]#4294967037#;#0:[email protected]#4294967037#
let#0:[email protected]#4294967037# x#0:[email protected]#4294967037# =#0:[email protected]#4294967037# 1#0:[email protected]#4294967037#;#0:[email protected]#4294967037#
}#0:[email protected]#4294967037#
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#
"#]],
Expand Down Expand Up @@ -171,7 +171,7 @@ fn main(foo: ()) {
}
fn main(foo: ()) {
/* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#4294967037#;
/* error: unresolved macro unresolved */"helloworld!"#0:[email protected]#ROOT2021#;
}
}
Expand All @@ -197,7 +197,7 @@ macro_rules! mk_struct {
#[macro_use]
mod foo;
struct#1:[email protected]#20480# Foo#0:[email protected]#4294967037#(#1:[email protected]#20480#u32#0:[email protected]#4294967037#)#1:[email protected]#20480#;#1:[email protected]#20480#
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#
"#]],
);
}
Expand Down Expand Up @@ -424,8 +424,8 @@ macro_rules! m {
($($i:ident),*) => ( impl Bar { $(fn $i() {})* } );
}
impl#\20480# Bar#\20480# {#\20480#
fn#\20480# foo#\4294967037#(#\20480#)#\20480# {#\20480#}#\20480#
fn#\20480# bar#\4294967037#(#\20480#)#\20480# {#\20480#}#\20480#
fn#\20480# foo#\ROOT2021#(#\20480#)#\20480# {#\20480#}#\20480#
fn#\20480# bar#\ROOT2021#(#\20480#)#\20480# {#\20480#}#\20480#
}#\20480#
"#]],
);
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-def/src/macro_expansion_tests/proc_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ fn foo(&self) {
self.0. 1;
}
fn#0:[email protected]#4294967037# foo#0:[email protected]#4294967037#(#0:[email protected]#4294967037#&#0:[email protected]#4294967037#self#0:[email protected]#4294967037# )#0:[email protected]#4294967037# {#0:[email protected]#4294967037#
self#0:[email protected]#4294967037# .#0:[email protected]#4294967037#0#0:[email protected]#4294967037#.#0:[email protected]#4294967037#1#0:[email protected]#4294967037#;#0:[email protected]#4294967037#
}#0:[email protected]#4294967037#"#]],
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#"#]],
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/hir-expand/src/builtin/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ mod tests {
assert_eq!(quoted.to_string(), "hello");
let t = format!("{quoted:#?}");
expect![[r#"
SUBTREE $$ 937550:[email protected]#4294967037 937550:[email protected]#4294967037
IDENT hello 937550:[email protected]#4294967037"#]]
SUBTREE $$ 937550:[email protected]#ROOT2021 937550:[email protected]#ROOT2021
IDENT hello 937550:[email protected]#ROOT2021"#]]
.assert_eq(&t);
}

Expand Down
6 changes: 4 additions & 2 deletions crates/hir-expand/src/proc_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ impl ProcMacrosBuilder {
if let Ok(proc_macros) = &mut proc_macro {
// Sort proc macros to improve incrementality when only their order has changed (ideally the build system
// will not change their order, but just to be sure).
proc_macros
.sort_unstable_by_key(|proc_macro| (proc_macro.name.clone(), proc_macro.kind));
proc_macros.sort_unstable_by(|proc_macro, proc_macro2| {
(proc_macro.name.as_str(), proc_macro.kind)
.cmp(&(proc_macro2.name.as_str(), proc_macro2.kind))
});
}
self.0.insert(
proc_macros_crate,
Expand Down
14 changes: 1 addition & 13 deletions crates/intern/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ struct TaggedArcPtr {
unsafe impl Send for TaggedArcPtr {}
unsafe impl Sync for TaggedArcPtr {}

impl Ord for TaggedArcPtr {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.as_str().cmp(other.as_str())
}
}

impl PartialOrd for TaggedArcPtr {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl TaggedArcPtr {
const BOOL_BITS: usize = true as usize;

Expand Down Expand Up @@ -125,7 +113,7 @@ impl TaggedArcPtr {
}
}

#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(PartialEq, Eq, Hash)]
pub struct Symbol {
repr: TaggedArcPtr,
}
Expand Down
160 changes: 80 additions & 80 deletions crates/mbe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ fn unbalanced_brace() {
"#,
r#""#,
expect![[r#"
SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
SUBTREE {} 0:[email protected]#4294967037 0:[email protected]#4294967037
SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
SUBTREE {} 0:[email protected]#ROOT2021 0:[email protected]#ROOT2021

{}"#]],
);
Expand All @@ -132,25 +132,25 @@ fn token_mapping_smoke_test() {
struct MyTraitMap2
"#,
expect![[r#"
SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
IDENT struct 0:[email protected]#4294967037
IDENT MyTraitMap2 1:[email protected]#4294967037
SUBTREE {} 0:[email protected]#4294967037 0:[email protected]#4294967037
IDENT map 0:[email protected]#4294967037
PUNCH : [alone] 0:[email protected]#4294967037
PUNCH : [joint] 0:[email protected]#4294967037
PUNCH : [alone] 0:[email protected]#4294967037
IDENT std 0:[email protected]#4294967037
PUNCH : [joint] 0:[email protected]#4294967037
PUNCH : [alone] 0:[email protected]#4294967037
IDENT collections 0:[email protected]#4294967037
PUNCH : [joint] 0:[email protected]#4294967037
PUNCH : [alone] 0:[email protected]#4294967037
IDENT HashSet 0:[email protected]#4294967037
PUNCH < [alone] 0:[email protected]#4294967037
SUBTREE () 0:[email protected]#4294967037 0:[email protected]#4294967037
PUNCH > [joint] 0:[email protected]#4294967037
PUNCH , [alone] 0:[email protected]#4294967037
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

struct MyTraitMap2 {
map: ::std::collections::HashSet<()>,
Expand Down Expand Up @@ -179,28 +179,28 @@ fn main() {
}
"#,
expect![[r#"
SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
IDENT fn 1:[email protected]#4294967037
IDENT main 1:[email protected]#4294967037
SUBTREE () 1:[email protected]#4294967037 1:[email protected]#4294967037
SUBTREE {} 1:[email protected]#4294967037 1:[email protected]#4294967037
LITERAL Integer 1 1:[email protected]#4294967037
PUNCH ; [alone] 1:[email protected]#4294967037
LITERAL Float 1.0 1:[email protected]#4294967037
PUNCH ; [alone] 1:[email protected]#4294967037
SUBTREE () 1:[email protected]#4294967037 1:[email protected]#4294967037
SUBTREE () 1:[email protected]#4294967037 1:[email protected]#4294967037
LITERAL Integer 1 1:[email protected]#4294967037
PUNCH , [alone] 1:[email protected]#4294967037
PUNCH , [alone] 1:[email protected]#4294967037
PUNCH . [alone] 1:[email protected]#4294967037
LITERAL Float 0.0 1:[email protected]#4294967037
PUNCH ; [alone] 1:[email protected]#4294967037
IDENT let 1:[email protected]#4294967037
IDENT x 1:[email protected]#4294967037
PUNCH = [alone] 1:[email protected]#4294967037
LITERAL Integer 1 1:[email protected]#4294967037
PUNCH ; [alone] 1:[email protected]#4294967037
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

fn main(){
1;
Expand All @@ -226,14 +226,14 @@ fn expr_2021() {
const { 1 },
"#,
expect![[r#"
SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
IDENT _ 1:[email protected]#4294967037
PUNCH ; [joint] 0:[email protected]#4294967037
SUBTREE () 0:[email protected]#4294967037 0:[email protected]#4294967037
IDENT const 1:[email protected]#4294967037
SUBTREE {} 1:[email protected]#4294967037 1:[email protected]#4294967037
LITERAL Integer 1 1:[email protected]#4294967037
PUNCH ; [alone] 0:[email protected]#4294967037
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

_;
(const {
Expand All @@ -254,13 +254,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:[email protected]#4294967037,
1:[email protected]#ROOT2021,
NoMatchingRule,
),
}

SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
PUNCH ; [alone] 0:[email protected]#4294967037
SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
PUNCH ; [alone] 0:[email protected]#ROOT2021

;"#]],
);
Expand All @@ -278,13 +278,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:[email protected]#4294967037,
1:[email protected]#ROOT2021,
NoMatchingRule,
),
}

SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
PUNCH ; [alone] 0:[email protected]#4294967037
SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
PUNCH ; [alone] 0:[email protected]#ROOT2021

;"#]],
);
Expand All @@ -304,26 +304,26 @@ fn expr_2021() {
break 'foo bar,
"#,
expect![[r#"
SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
LITERAL Integer 4 1:[email protected]#4294967037
PUNCH ; [joint] 0:[email protected]#4294967037
LITERAL Str literal 1:[email protected]#4294967037
PUNCH ; [joint] 0:[email protected]#4294967037
SUBTREE () 0:[email protected]#4294967037 0:[email protected]#4294967037
IDENT funcall 1:[email protected]#4294967037
SUBTREE () 1:[email protected]#4294967037 1:[email protected]#4294967037
PUNCH ; [joint] 0:[email protected]#4294967037
SUBTREE () 0:[email protected]#4294967037 0:[email protected]#4294967037
IDENT future 1:[email protected]#4294967037
PUNCH . [alone] 1:[email protected]#4294967037
IDENT await 1:[email protected]#4294967037
PUNCH ; [joint] 0:[email protected]#4294967037
SUBTREE () 0:[email protected]#4294967037 0:[email protected]#4294967037
IDENT break 1:[email protected]#4294967037
PUNCH ' [joint] 1:[email protected]#4294967037
IDENT foo 1:[email protected]#4294967037
IDENT bar 1:[email protected]#4294967037
PUNCH ; [alone] 0:[email protected]#4294967037
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

4;
"literal";
Expand All @@ -345,13 +345,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:[email protected]#4294967037,
1:[email protected]#ROOT2021,
NoMatchingRule,
),
}

SUBTREE $$ 1:[email protected]#4294967037 1:[email protected]#4294967037
PUNCH ; [alone] 0:[email protected]#4294967037
SUBTREE $$ 1:[email protected]#ROOT2021 1:[email protected]#ROOT2021
PUNCH ; [alone] 0:[email protected]#ROOT2021

;"#]],
);
Expand Down
Loading