diff options
461 files changed, 27116 insertions, 27153 deletions
diff --git a/Cargo.lock b/Cargo.lock index d966ebe61..20e6cd540 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1180,7 +1180,7 @@ dependencies = [ | |||
1180 | name = "ra_text_edit" | 1180 | name = "ra_text_edit" |
1181 | version = "0.1.0" | 1181 | version = "0.1.0" |
1182 | dependencies = [ | 1182 | dependencies = [ |
1183 | "text_unit", | 1183 | "text-size", |
1184 | ] | 1184 | ] |
1185 | 1185 | ||
1186 | [[package]] | 1186 | [[package]] |
@@ -1322,13 +1322,13 @@ dependencies = [ | |||
1322 | 1322 | ||
1323 | [[package]] | 1323 | [[package]] |
1324 | name = "rowan" | 1324 | name = "rowan" |
1325 | version = "0.9.1" | 1325 | version = "0.10.0" |
1326 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1326 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1327 | checksum = "1ea7cadf87a9d8432e85cb4eb86bd2e765ace60c24ef86e79084dcae5d1c5a19" | 1327 | checksum = "1e081ed6eacce09e243b619ab90f069c27b0cff8a6d0eb8ad2ec935b65853798" |
1328 | dependencies = [ | 1328 | dependencies = [ |
1329 | "rustc-hash", | 1329 | "rustc-hash", |
1330 | "smol_str", | 1330 | "smol_str", |
1331 | "text_unit", | 1331 | "text-size", |
1332 | "thin-dst", | 1332 | "thin-dst", |
1333 | ] | 1333 | ] |
1334 | 1334 | ||
@@ -1620,14 +1620,14 @@ version = "0.1.0" | |||
1620 | dependencies = [ | 1620 | dependencies = [ |
1621 | "difference", | 1621 | "difference", |
1622 | "serde_json", | 1622 | "serde_json", |
1623 | "text_unit", | 1623 | "text-size", |
1624 | ] | 1624 | ] |
1625 | 1625 | ||
1626 | [[package]] | 1626 | [[package]] |
1627 | name = "text_unit" | 1627 | name = "text-size" |
1628 | version = "0.1.10" | 1628 | version = "1.0.0" |
1629 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1629 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1630 | checksum = "20431e104bfecc1a40872578dbc390e10290a0e9c35fffe3ce6f73c15a9dbfc2" | 1630 | checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" |
1631 | 1631 | ||
1632 | [[package]] | 1632 | [[package]] |
1633 | name = "thin-dst" | 1633 | name = "thin-dst" |
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index 279163257..2fe7c3de3 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -5,7 +5,7 @@ use ra_fmt::{leading_indent, reindent}; | |||
5 | use ra_ide_db::RootDatabase; | 5 | use ra_ide_db::RootDatabase; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | algo::{self, find_covering_element, find_node_at_offset}, | 7 | algo::{self, find_covering_element, find_node_at_offset}, |
8 | AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextUnit, | 8 | AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, |
9 | TokenAtOffset, | 9 | TokenAtOffset, |
10 | }; | 10 | }; |
11 | use ra_text_edit::TextEditBuilder; | 11 | use ra_text_edit::TextEditBuilder; |
@@ -178,7 +178,7 @@ impl<'a> AssistGroup<'a> { | |||
178 | #[derive(Default)] | 178 | #[derive(Default)] |
179 | pub(crate) struct ActionBuilder { | 179 | pub(crate) struct ActionBuilder { |
180 | edit: TextEditBuilder, | 180 | edit: TextEditBuilder, |
181 | cursor_position: Option<TextUnit>, | 181 | cursor_position: Option<TextSize>, |
182 | target: Option<TextRange>, | 182 | target: Option<TextRange>, |
183 | file: AssistFile, | 183 | file: AssistFile, |
184 | } | 184 | } |
@@ -211,12 +211,12 @@ impl ActionBuilder { | |||
211 | } | 211 | } |
212 | 212 | ||
213 | /// Append specified `text` at the given `offset` | 213 | /// Append specified `text` at the given `offset` |
214 | pub(crate) fn insert(&mut self, offset: TextUnit, text: impl Into<String>) { | 214 | pub(crate) fn insert(&mut self, offset: TextSize, text: impl Into<String>) { |
215 | self.edit.insert(offset, text.into()) | 215 | self.edit.insert(offset, text.into()) |
216 | } | 216 | } |
217 | 217 | ||
218 | /// Specify desired position of the cursor after the assist is applied. | 218 | /// Specify desired position of the cursor after the assist is applied. |
219 | pub(crate) fn set_cursor(&mut self, offset: TextUnit) { | 219 | pub(crate) fn set_cursor(&mut self, offset: TextSize) { |
220 | self.cursor_position = Some(offset) | 220 | self.cursor_position = Some(offset) |
221 | } | 221 | } |
222 | 222 | ||
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 15f9b216b..4ea26a550 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -2,7 +2,7 @@ use ra_syntax::{ | |||
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | Direction, SmolStr, | 3 | Direction, SmolStr, |
4 | SyntaxKind::{IDENT, WHITESPACE}, | 4 | SyntaxKind::{IDENT, WHITESPACE}, |
5 | TextRange, TextUnit, | 5 | TextRange, TextSize, |
6 | }; | 6 | }; |
7 | use stdx::SepBy; | 7 | use stdx::SepBy; |
8 | 8 | ||
@@ -60,7 +60,6 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
60 | .collect::<Vec<SmolStr>>(); | 60 | .collect::<Vec<SmolStr>>(); |
61 | let has_more_derives = !new_attr_input.is_empty(); | 61 | let has_more_derives = !new_attr_input.is_empty(); |
62 | let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string(); | 62 | let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string(); |
63 | let new_attr_input_len = new_attr_input.len(); | ||
64 | 63 | ||
65 | let mut buf = String::new(); | 64 | let mut buf = String::new(); |
66 | buf.push_str("\n\nimpl "); | 65 | buf.push_str("\n\nimpl "); |
@@ -70,8 +69,9 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
70 | buf.push_str(" {\n"); | 69 | buf.push_str(" {\n"); |
71 | 70 | ||
72 | let cursor_delta = if has_more_derives { | 71 | let cursor_delta = if has_more_derives { |
72 | let delta = input.syntax().text_range().len() - TextSize::of(&new_attr_input); | ||
73 | edit.replace(input.syntax().text_range(), new_attr_input); | 73 | edit.replace(input.syntax().text_range(), new_attr_input); |
74 | input.syntax().text_range().len() - TextUnit::from_usize(new_attr_input_len) | 74 | delta |
75 | } else { | 75 | } else { |
76 | let attr_range = attr.syntax().text_range(); | 76 | let attr_range = attr.syntax().text_range(); |
77 | edit.delete(attr_range); | 77 | edit.delete(attr_range); |
@@ -81,13 +81,13 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
81 | .next_sibling_or_token() | 81 | .next_sibling_or_token() |
82 | .filter(|t| t.kind() == WHITESPACE) | 82 | .filter(|t| t.kind() == WHITESPACE) |
83 | .map(|t| t.text_range()) | 83 | .map(|t| t.text_range()) |
84 | .unwrap_or_else(|| TextRange::from_to(TextUnit::from(0), TextUnit::from(0))); | 84 | .unwrap_or_else(|| TextRange::new(TextSize::from(0), TextSize::from(0))); |
85 | edit.delete(line_break_range); | 85 | edit.delete(line_break_range); |
86 | 86 | ||
87 | attr_range.len() + line_break_range.len() | 87 | attr_range.len() + line_break_range.len() |
88 | }; | 88 | }; |
89 | 89 | ||
90 | edit.set_cursor(start_offset + TextUnit::of_str(&buf) - cursor_delta); | 90 | edit.set_cursor(start_offset + TextSize::of(&buf) - cursor_delta); |
91 | buf.push_str("\n}"); | 91 | buf.push_str("\n}"); |
92 | edit.insert(start_offset, buf); | 92 | edit.insert(start_offset, buf); |
93 | }) | 93 | }) |
diff --git a/crates/ra_assists/src/handlers/add_derive.rs b/crates/ra_assists/src/handlers/add_derive.rs index b0d1a0a80..6254eb7c4 100644 --- a/crates/ra_assists/src/handlers/add_derive.rs +++ b/crates/ra_assists/src/handlers/add_derive.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, AttrsOwner}, | 2 | ast::{self, AstNode, AttrsOwner}, |
3 | SyntaxKind::{COMMENT, WHITESPACE}, | 3 | SyntaxKind::{COMMENT, WHITESPACE}, |
4 | TextUnit, | 4 | TextSize, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use crate::{Assist, AssistCtx, AssistId}; | 7 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -37,9 +37,9 @@ pub(crate) fn add_derive(ctx: AssistCtx) -> Option<Assist> { | |||
37 | let offset = match derive_attr { | 37 | let offset = match derive_attr { |
38 | None => { | 38 | None => { |
39 | edit.insert(node_start, "#[derive()]\n"); | 39 | edit.insert(node_start, "#[derive()]\n"); |
40 | node_start + TextUnit::of_str("#[derive(") | 40 | node_start + TextSize::of("#[derive(") |
41 | } | 41 | } |
42 | Some(tt) => tt.syntax().text_range().end() - TextUnit::of_char(')'), | 42 | Some(tt) => tt.syntax().text_range().end() - TextSize::of(')'), |
43 | }; | 43 | }; |
44 | edit.target(nominal.syntax().text_range()); | 44 | edit.target(nominal.syntax().text_range()); |
45 | edit.set_cursor(offset) | 45 | edit.set_cursor(offset) |
@@ -47,7 +47,7 @@ pub(crate) fn add_derive(ctx: AssistCtx) -> Option<Assist> { | |||
47 | } | 47 | } |
48 | 48 | ||
49 | // Insert `derive` after doc comments. | 49 | // Insert `derive` after doc comments. |
50 | fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextUnit> { | 50 | fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextSize> { |
51 | let non_ws_child = nominal | 51 | let non_ws_child = nominal |
52 | .syntax() | 52 | .syntax() |
53 | .children_with_tokens() | 53 | .children_with_tokens() |
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 6c56d93d8..bc313782b 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -37,8 +37,8 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> { | |||
37 | let stmt_range = stmt.syntax().text_range(); | 37 | let stmt_range = stmt.syntax().text_range(); |
38 | let eq_range = stmt.eq_token()?.text_range(); | 38 | let eq_range = stmt.eq_token()?.text_range(); |
39 | // Assist should only be applicable if cursor is between 'let' and '=' | 39 | // Assist should only be applicable if cursor is between 'let' and '=' |
40 | let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); | 40 | let let_range = TextRange::new(stmt_range.start(), eq_range.start()); |
41 | let cursor_in_range = ctx.frange.range.is_subrange(&let_range); | 41 | let cursor_in_range = let_range.contains_range(ctx.frange.range); |
42 | if !cursor_in_range { | 42 | if !cursor_in_range { |
43 | return None; | 43 | return None; |
44 | } | 44 | } |
diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs index 0621487e8..03806724a 100644 --- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, NameOwner}, | 2 | ast::{self, AstNode, NameOwner}, |
3 | TextUnit, | 3 | TextSize, |
4 | }; | 4 | }; |
5 | use stdx::format_to; | 5 | use stdx::format_to; |
6 | 6 | ||
@@ -65,7 +65,7 @@ impl From<{0}> for {1} {{ | |||
65 | variant_name | 65 | variant_name |
66 | ); | 66 | ); |
67 | edit.insert(start_offset, buf); | 67 | edit.insert(start_offset, buf); |
68 | edit.set_cursor(start_offset + TextUnit::of_str("\n\n")); | 68 | edit.set_cursor(start_offset + TextSize::of("\n\n")); |
69 | }, | 69 | }, |
70 | ) | 70 | ) |
71 | } | 71 | } |
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index f185cffdb..6c7456579 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | SyntaxKind, SyntaxNode, TextUnit, | 3 | SyntaxKind, SyntaxNode, TextSize, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crate::{Assist, AssistCtx, AssistFile, AssistId}; | 6 | use crate::{Assist, AssistCtx, AssistFile, AssistId}; |
@@ -69,8 +69,8 @@ pub(crate) fn add_function(ctx: AssistCtx) -> Option<Assist> { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | struct FunctionTemplate { | 71 | struct FunctionTemplate { |
72 | insert_offset: TextUnit, | 72 | insert_offset: TextSize, |
73 | cursor_offset: TextUnit, | 73 | cursor_offset: TextSize, |
74 | fn_def: ast::SourceFile, | 74 | fn_def: ast::SourceFile, |
75 | file: AssistFile, | 75 | file: AssistFile, |
76 | } | 76 | } |
@@ -129,7 +129,7 @@ impl FunctionBuilder { | |||
129 | let fn_def = indent_once.increase_indent(fn_def); | 129 | let fn_def = indent_once.increase_indent(fn_def); |
130 | let fn_def = ast::make::add_trailing_newlines(1, fn_def); | 130 | let fn_def = ast::make::add_trailing_newlines(1, fn_def); |
131 | let fn_def = indent.increase_indent(fn_def); | 131 | let fn_def = indent.increase_indent(fn_def); |
132 | (fn_def, it.syntax().text_range().start() + TextUnit::from_usize(1)) | 132 | (fn_def, it.syntax().text_range().start() + TextSize::of('{')) |
133 | } | 133 | } |
134 | }; | 134 | }; |
135 | 135 | ||
diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 6622eadb2..d26f8b93d 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, | 2 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, |
3 | TextUnit, | 3 | TextSize, |
4 | }; | 4 | }; |
5 | use stdx::{format_to, SepBy}; | 5 | use stdx::{format_to, SepBy}; |
6 | 6 | ||
@@ -51,7 +51,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> { | |||
51 | format_to!(buf, "<{}>", generic_params) | 51 | format_to!(buf, "<{}>", generic_params) |
52 | } | 52 | } |
53 | buf.push_str(" {\n"); | 53 | buf.push_str(" {\n"); |
54 | edit.set_cursor(start_offset + TextUnit::of_str(&buf)); | 54 | edit.set_cursor(start_offset + TextSize::of(&buf)); |
55 | buf.push_str("\n}"); | 55 | buf.push_str("\n}"); |
56 | edit.insert(start_offset, buf); | 56 | edit.insert(start_offset, buf); |
57 | }) | 57 | }) |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 240b19fa3..0f9174a29 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ | |||
3 | ast::{ | 3 | ast::{ |
4 | self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, | 4 | self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, |
5 | }, | 5 | }, |
6 | TextUnit, T, | 6 | TextSize, T, |
7 | }; | 7 | }; |
8 | use stdx::{format_to, SepBy}; | 8 | use stdx::{format_to, SepBy}; |
9 | 9 | ||
@@ -77,16 +77,16 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { | |||
77 | .text_range() | 77 | .text_range() |
78 | .end(); | 78 | .end(); |
79 | 79 | ||
80 | Some((start, TextUnit::from_usize(1))) | 80 | Some((start, TextSize::of("\n"))) |
81 | }) | 81 | }) |
82 | .unwrap_or_else(|| { | 82 | .unwrap_or_else(|| { |
83 | buf = generate_impl_text(&strukt, &buf); | 83 | buf = generate_impl_text(&strukt, &buf); |
84 | let start = strukt.syntax().text_range().end(); | 84 | let start = strukt.syntax().text_range().end(); |
85 | 85 | ||
86 | (start, TextUnit::from_usize(3)) | 86 | (start, TextSize::of("\n}\n")) |
87 | }); | 87 | }); |
88 | 88 | ||
89 | edit.set_cursor(start_offset + TextUnit::of_str(&buf) - end_offset); | 89 | edit.set_cursor(start_offset + TextSize::of(&buf) - end_offset); |
90 | edit.insert(start_offset, buf); | 90 | edit.insert(start_offset, buf); |
91 | }) | 91 | }) |
92 | } | 92 | } |
diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs index 239807e24..260b9e073 100644 --- a/crates/ra_assists/src/handlers/apply_demorgan.rs +++ b/crates/ra_assists/src/handlers/apply_demorgan.rs | |||
@@ -26,7 +26,7 @@ pub(crate) fn apply_demorgan(ctx: AssistCtx) -> Option<Assist> { | |||
26 | let op = expr.op_kind()?; | 26 | let op = expr.op_kind()?; |
27 | let op_range = expr.op_token()?.text_range(); | 27 | let op_range = expr.op_token()?.text_range(); |
28 | let opposite_op = opposite_logic_op(op)?; | 28 | let opposite_op = opposite_logic_op(op)?; |
29 | let cursor_in_range = ctx.frange.range.is_subrange(&op_range); | 29 | let cursor_in_range = op_range.contains_range(ctx.frange.range); |
30 | if !cursor_in_range { | 30 | if !cursor_in_range { |
31 | return None; | 31 | return None; |
32 | } | 32 | } |
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index cd6d1ee6c..44f6a1dae 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -5,7 +5,7 @@ use ra_syntax::{ | |||
5 | ATTR, COMMENT, CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | 5 | ATTR, COMMENT, CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY, |
6 | WHITESPACE, | 6 | WHITESPACE, |
7 | }, | 7 | }, |
8 | SyntaxNode, TextUnit, T, | 8 | SyntaxNode, TextSize, T, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{Assist, AssistCtx, AssistId}; | 11 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -67,7 +67,7 @@ fn add_vis(ctx: AssistCtx) -> Option<Assist> { | |||
67 | }) | 67 | }) |
68 | } | 68 | } |
69 | 69 | ||
70 | fn vis_offset(node: &SyntaxNode) -> TextUnit { | 70 | fn vis_offset(node: &SyntaxNode) -> TextSize { |
71 | node.children_with_tokens() | 71 | node.children_with_tokens() |
72 | .skip_while(|it| match it.kind() { | 72 | .skip_while(|it| match it.kind() { |
73 | WHITESPACE | COMMENT | ATTR => true, | 73 | WHITESPACE | COMMENT | ATTR => true, |
diff --git a/crates/ra_assists/src/handlers/flip_binexpr.rs b/crates/ra_assists/src/handlers/flip_binexpr.rs index bfcc09e90..8030efb35 100644 --- a/crates/ra_assists/src/handlers/flip_binexpr.rs +++ b/crates/ra_assists/src/handlers/flip_binexpr.rs | |||
@@ -23,7 +23,7 @@ pub(crate) fn flip_binexpr(ctx: AssistCtx) -> Option<Assist> { | |||
23 | let rhs = expr.rhs()?.syntax().clone(); | 23 | let rhs = expr.rhs()?.syntax().clone(); |
24 | let op_range = expr.op_token()?.text_range(); | 24 | let op_range = expr.op_token()?.text_range(); |
25 | // The assist should be applied only if the cursor is on the operator | 25 | // The assist should be applied only if the cursor is on the operator |
26 | let cursor_in_range = ctx.frange.range.is_subrange(&op_range); | 26 | let cursor_in_range = op_range.contains_range(ctx.frange.range); |
27 | if !cursor_in_range { | 27 | if !cursor_in_range { |
28 | return None; | 28 | return None; |
29 | } | 29 | } |
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index c4fb425b0..f5702f6e0 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs | |||
@@ -52,7 +52,7 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> { | |||
52 | .next_sibling_or_token() | 52 | .next_sibling_or_token() |
53 | .and_then(|it| ast::Whitespace::cast(it.as_token()?.clone())) | 53 | .and_then(|it| ast::Whitespace::cast(it.as_token()?.clone())) |
54 | { | 54 | { |
55 | TextRange::from_to( | 55 | TextRange::new( |
56 | let_stmt.syntax().text_range().start(), | 56 | let_stmt.syntax().text_range().start(), |
57 | whitespace.syntax().text_range().end(), | 57 | whitespace.syntax().text_range().end(), |
58 | ) | 58 | ) |
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index 8c09e6bcd..eda9ac296 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs | |||
@@ -4,7 +4,7 @@ use ra_syntax::{ | |||
4 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, | 4 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, |
5 | WHITESPACE, | 5 | WHITESPACE, |
6 | }, | 6 | }, |
7 | SyntaxNode, TextUnit, | 7 | SyntaxNode, TextSize, |
8 | }; | 8 | }; |
9 | use stdx::format_to; | 9 | use stdx::format_to; |
10 | use test_utils::tested_by; | 10 | use test_utils::tested_by; |
@@ -47,10 +47,10 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> { | |||
47 | 47 | ||
48 | let cursor_offset = if wrap_in_block { | 48 | let cursor_offset = if wrap_in_block { |
49 | buf.push_str("{ let var_name = "); | 49 | buf.push_str("{ let var_name = "); |
50 | TextUnit::of_str("{ let ") | 50 | TextSize::of("{ let ") |
51 | } else { | 51 | } else { |
52 | buf.push_str("let var_name = "); | 52 | buf.push_str("let var_name = "); |
53 | TextUnit::of_str("let ") | 53 | TextSize::of("let ") |
54 | }; | 54 | }; |
55 | format_to!(buf, "{}", expr.syntax()); | 55 | format_to!(buf, "{}", expr.syntax()); |
56 | let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone()); | 56 | let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone()); |
diff --git a/crates/ra_assists/src/handlers/invert_if.rs b/crates/ra_assists/src/handlers/invert_if.rs index 4c5716868..682e08512 100644 --- a/crates/ra_assists/src/handlers/invert_if.rs +++ b/crates/ra_assists/src/handlers/invert_if.rs | |||
@@ -28,7 +28,7 @@ pub(crate) fn invert_if(ctx: AssistCtx) -> Option<Assist> { | |||
28 | let if_keyword = ctx.find_token_at_offset(T![if])?; | 28 | let if_keyword = ctx.find_token_at_offset(T![if])?; |
29 | let expr = ast::IfExpr::cast(if_keyword.parent())?; | 29 | let expr = ast::IfExpr::cast(if_keyword.parent())?; |
30 | let if_range = if_keyword.text_range(); | 30 | let if_range = if_keyword.text_range(); |
31 | let cursor_in_range = ctx.frange.range.is_subrange(&if_range); | 31 | let cursor_in_range = if_range.contains_range(ctx.frange.range); |
32 | if !cursor_in_range { | 32 | if !cursor_in_range { |
33 | return None; | 33 | return None; |
34 | } | 34 | } |
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index eb967ab92..5a77d3dbc 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -3,7 +3,7 @@ use std::iter::successors; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::neighbor, | 4 | algo::neighbor, |
5 | ast::{self, AstNode}, | 5 | ast::{self, AstNode}, |
6 | Direction, TextUnit, | 6 | Direction, TextSize, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{Assist, AssistCtx, AssistId, TextRange}; | 9 | use crate::{Assist, AssistCtx, AssistId, TextRange}; |
@@ -42,8 +42,8 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { | |||
42 | let current_text_range = current_arm.syntax().text_range(); | 42 | let current_text_range = current_arm.syntax().text_range(); |
43 | 43 | ||
44 | enum CursorPos { | 44 | enum CursorPos { |
45 | InExpr(TextUnit), | 45 | InExpr(TextSize), |
46 | InPat(TextUnit), | 46 | InPat(TextSize), |
47 | } | 47 | } |
48 | let cursor_pos = ctx.frange.range.start(); | 48 | let cursor_pos = ctx.frange.range.start(); |
49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { | 49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { |
@@ -89,10 +89,10 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { | |||
89 | 89 | ||
90 | edit.target(current_text_range); | 90 | edit.target(current_text_range); |
91 | edit.set_cursor(match cursor_pos { | 91 | edit.set_cursor(match cursor_pos { |
92 | CursorPos::InExpr(back_offset) => start + TextUnit::from_usize(arm.len()) - back_offset, | 92 | CursorPos::InExpr(back_offset) => start + TextSize::of(&arm) - back_offset, |
93 | CursorPos::InPat(offset) => offset, | 93 | CursorPos::InPat(offset) => offset, |
94 | }); | 94 | }); |
95 | edit.replace(TextRange::from_to(start, end), arm); | 95 | edit.replace(TextRange::new(start, end), arm); |
96 | }) | 96 | }) |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs index 1cc498638..d5ccdd91c 100644 --- a/crates/ra_assists/src/handlers/move_guard.rs +++ b/crates/ra_assists/src/handlers/move_guard.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast, | 2 | ast, |
3 | ast::{AstNode, AstToken, IfExpr, MatchArm}, | 3 | ast::{AstNode, AstToken, IfExpr, MatchArm}, |
4 | TextUnit, | 4 | TextSize, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use crate::{Assist, AssistCtx, AssistId}; | 7 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -49,16 +49,16 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> { | |||
49 | edit.delete(ele); | 49 | edit.delete(ele); |
50 | ele.len() | 50 | ele.len() |
51 | } else { | 51 | } else { |
52 | TextUnit::from(0) | 52 | TextSize::from(0) |
53 | } | 53 | } |
54 | } | 54 | } |
55 | _ => TextUnit::from(0), | 55 | _ => TextSize::from(0), |
56 | }; | 56 | }; |
57 | 57 | ||
58 | edit.delete(guard.syntax().text_range()); | 58 | edit.delete(guard.syntax().text_range()); |
59 | edit.replace_node_and_indent(arm_expr.syntax(), buf); | 59 | edit.replace_node_and_indent(arm_expr.syntax(), buf); |
60 | edit.set_cursor( | 60 | edit.set_cursor( |
61 | arm_expr.syntax().text_range().start() + TextUnit::from(3) - offseting_amount, | 61 | arm_expr.syntax().text_range().start() + TextSize::from(3) - offseting_amount, |
62 | ); | 62 | ); |
63 | }) | 63 | }) |
64 | } | 64 | } |
@@ -123,7 +123,7 @@ pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> Option<Assist> { | |||
123 | } | 123 | } |
124 | 124 | ||
125 | edit.insert(match_pat.syntax().text_range().end(), buf); | 125 | edit.insert(match_pat.syntax().text_range().end(), buf); |
126 | edit.set_cursor(match_pat.syntax().text_range().end() + TextUnit::from(1)); | 126 | edit.set_cursor(match_pat.syntax().text_range().end() + TextSize::from(1)); |
127 | }, | 127 | }, |
128 | ) | 128 | ) |
129 | } | 129 | } |
diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs index 7e4b83f13..567400b9c 100644 --- a/crates/ra_assists/src/handlers/raw_string.rs +++ b/crates/ra_assists/src/handlers/raw_string.rs | |||
@@ -2,7 +2,7 @@ use ra_syntax::{ | |||
2 | ast::{self, HasStringValue}, | 2 | ast::{self, HasStringValue}, |
3 | AstToken, | 3 | AstToken, |
4 | SyntaxKind::{RAW_STRING, STRING}, | 4 | SyntaxKind::{RAW_STRING, STRING}, |
5 | TextUnit, | 5 | TextSize, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{Assist, AssistCtx, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -81,7 +81,7 @@ pub(crate) fn add_hash(ctx: AssistCtx) -> Option<Assist> { | |||
81 | let token = ctx.find_token_at_offset(RAW_STRING)?; | 81 | let token = ctx.find_token_at_offset(RAW_STRING)?; |
82 | ctx.add_assist(AssistId("add_hash"), "Add # to raw string", |edit| { | 82 | ctx.add_assist(AssistId("add_hash"), "Add # to raw string", |edit| { |
83 | edit.target(token.text_range()); | 83 | edit.target(token.text_range()); |
84 | edit.insert(token.text_range().start() + TextUnit::of_char('r'), "#"); | 84 | edit.insert(token.text_range().start() + TextSize::of('r'), "#"); |
85 | edit.insert(token.text_range().end(), "#"); | 85 | edit.insert(token.text_range().end(), "#"); |
86 | }) | 86 | }) |
87 | } | 87 | } |
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs index 5085649b4..4e5eb4350 100644 --- a/crates/ra_assists/src/handlers/remove_dbg.rs +++ b/crates/ra_assists/src/handlers/remove_dbg.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | TextUnit, T, | 3 | TextSize, T, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crate::{Assist, AssistCtx, AssistId}; | 6 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -38,9 +38,9 @@ pub(crate) fn remove_dbg(ctx: AssistCtx) -> Option<Assist> { | |||
38 | let offset_start = file_range | 38 | let offset_start = file_range |
39 | .start() | 39 | .start() |
40 | .checked_sub(macro_range.start()) | 40 | .checked_sub(macro_range.start()) |
41 | .unwrap_or_else(|| TextUnit::from(0)); | 41 | .unwrap_or_else(|| TextSize::from(0)); |
42 | 42 | ||
43 | let dbg_size = TextUnit::of_str("dbg!("); | 43 | let dbg_size = TextSize::of("dbg!("); |
44 | 44 | ||
45 | if offset_start > dbg_size { | 45 | if offset_start > dbg_size { |
46 | file_range.start() - dbg_size | 46 | file_range.start() - dbg_size |
@@ -53,7 +53,7 @@ pub(crate) fn remove_dbg(ctx: AssistCtx) -> Option<Assist> { | |||
53 | let macro_args = macro_call.token_tree()?.syntax().clone(); | 53 | let macro_args = macro_call.token_tree()?.syntax().clone(); |
54 | 54 | ||
55 | let text = macro_args.text(); | 55 | let text = macro_args.text(); |
56 | let without_parens = TextUnit::of_char('(')..text.len() - TextUnit::of_char(')'); | 56 | let without_parens = TextSize::of('(')..text.len() - TextSize::of(')'); |
57 | text.slice(without_parens).to_string() | 57 | text.slice(without_parens).to_string() |
58 | }; | 58 | }; |
59 | 59 | ||
diff --git a/crates/ra_assists/src/handlers/remove_mut.rs b/crates/ra_assists/src/handlers/remove_mut.rs index 6884830eb..e598023b2 100644 --- a/crates/ra_assists/src/handlers/remove_mut.rs +++ b/crates/ra_assists/src/handlers/remove_mut.rs | |||
@@ -27,6 +27,6 @@ pub(crate) fn remove_mut(ctx: AssistCtx) -> Option<Assist> { | |||
27 | 27 | ||
28 | ctx.add_assist(AssistId("remove_mut"), "Remove `mut` keyword", |edit| { | 28 | ctx.add_assist(AssistId("remove_mut"), "Remove `mut` keyword", |edit| { |
29 | edit.set_cursor(delete_from); | 29 | edit.set_cursor(delete_from); |
30 | edit.delete(TextRange::from_to(delete_from, delete_to)); | 30 | edit.delete(TextRange::new(delete_from, delete_to)); |
31 | }) | 31 | }) |
32 | } | 32 | } |
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index 94f5d6c50..2f02df303 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -43,7 +43,7 @@ pub(crate) fn replace_qualified_name_with_use(ctx: AssistCtx) -> Option<Assist> | |||
43 | if let Some(last) = path.segment() { | 43 | if let Some(last) = path.segment() { |
44 | // Here we are assuming the assist will provide a correct use statement | 44 | // Here we are assuming the assist will provide a correct use statement |
45 | // so we can delete the path qualifier | 45 | // so we can delete the path qualifier |
46 | edit.delete(TextRange::from_to( | 46 | edit.delete(TextRange::new( |
47 | path.syntax().text_range().start(), | 47 | path.syntax().text_range().start(), |
48 | last.syntax().text_range().start(), | 48 | last.syntax().text_range().start(), |
49 | )); | 49 | )); |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index ccc95735f..64bd87afb 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -19,7 +19,7 @@ pub mod ast_transform; | |||
19 | 19 | ||
20 | use ra_db::{FileId, FileRange}; | 20 | use ra_db::{FileId, FileRange}; |
21 | use ra_ide_db::RootDatabase; | 21 | use ra_ide_db::RootDatabase; |
22 | use ra_syntax::{TextRange, TextUnit}; | 22 | use ra_syntax::{TextRange, TextSize}; |
23 | use ra_text_edit::TextEdit; | 23 | use ra_text_edit::TextEdit; |
24 | 24 | ||
25 | pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler}; | 25 | pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler}; |
@@ -51,7 +51,7 @@ impl AssistLabel { | |||
51 | #[derive(Debug, Clone)] | 51 | #[derive(Debug, Clone)] |
52 | pub struct AssistAction { | 52 | pub struct AssistAction { |
53 | pub edit: TextEdit, | 53 | pub edit: TextEdit, |
54 | pub cursor_position: Option<TextUnit>, | 54 | pub cursor_position: Option<TextSize>, |
55 | // FIXME: This belongs to `AssistLabel` | 55 | // FIXME: This belongs to `AssistLabel` |
56 | pub target: Option<TextRange>, | 56 | pub target: Option<TextRange>, |
57 | pub file: AssistFile, | 57 | pub file: AssistFile, |
@@ -104,7 +104,7 @@ pub fn resolved_assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssi | |||
104 | .flat_map(|it| it.0) | 104 | .flat_map(|it| it.0) |
105 | .map(|it| it.into_resolved().unwrap()) | 105 | .map(|it| it.into_resolved().unwrap()) |
106 | .collect::<Vec<_>>(); | 106 | .collect::<Vec<_>>(); |
107 | a.sort_by_key(|it| it.action.target.map_or(TextUnit::from(!0u32), |it| it.len())); | 107 | a.sort_by_key(|it| it.action.target.map_or(TextSize::from(!0u32), |it| it.len())); |
108 | a | 108 | a |
109 | } | 109 | } |
110 | 110 | ||
@@ -308,8 +308,7 @@ mod tests { | |||
308 | let before = "struct Foo { <|>bar: u32 }"; | 308 | let before = "struct Foo { <|>bar: u32 }"; |
309 | let (before_cursor_pos, before) = extract_offset(before); | 309 | let (before_cursor_pos, before) = extract_offset(before); |
310 | let (db, file_id) = helpers::with_single_file(&before); | 310 | let (db, file_id) = helpers::with_single_file(&before); |
311 | let frange = | 311 | let frange = FileRange { file_id, range: TextRange::empty(before_cursor_pos) }; |
312 | FileRange { file_id, range: TextRange::offset_len(before_cursor_pos, 0.into()) }; | ||
313 | let assists = resolved_assists(&db, frange); | 312 | let assists = resolved_assists(&db, frange); |
314 | let mut assists = assists.iter(); | 313 | let mut assists = assists.iter(); |
315 | 314 | ||
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index a06f59c14..fd4280de2 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -6,7 +6,7 @@ pub mod fixture; | |||
6 | use std::{panic, sync::Arc}; | 6 | use std::{panic, sync::Arc}; |
7 | 7 | ||
8 | use ra_prof::profile; | 8 | use ra_prof::profile; |
9 | use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit}; | 9 | use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize}; |
10 | 10 | ||
11 | pub use crate::{ | 11 | pub use crate::{ |
12 | cancellation::Canceled, | 12 | cancellation::Canceled, |
@@ -75,7 +75,7 @@ impl<T: salsa::Database> CheckCanceled for T { | |||
75 | #[derive(Clone, Copy, Debug)] | 75 | #[derive(Clone, Copy, Debug)] |
76 | pub struct FilePosition { | 76 | pub struct FilePosition { |
77 | pub file_id: FileId, | 77 | pub file_id: FileId, |
78 | pub offset: TextUnit, | 78 | pub offset: TextSize, |
79 | } | 79 | } |
80 | 80 | ||
81 | #[derive(Clone, Copy, Debug)] | 81 | #[derive(Clone, Copy, Debug)] |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 43f932e20..3f645a1dd 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -13,8 +13,8 @@ use hir_def::{ | |||
13 | resolver::{HasResolver, Resolver}, | 13 | resolver::{HasResolver, Resolver}, |
14 | type_ref::{Mutability, TypeRef}, | 14 | type_ref::{Mutability, TypeRef}, |
15 | AdtId, AssocContainerId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, | 15 | AdtId, AssocContainerId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, |
16 | ImplId, LocalEnumVariantId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, | 16 | ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId, Lookup, ModuleId, StaticId, StructId, |
17 | StructId, TraitId, TypeAliasId, TypeParamId, UnionId, | 17 | TraitId, TypeAliasId, TypeParamId, UnionId, |
18 | }; | 18 | }; |
19 | use hir_expand::{ | 19 | use hir_expand::{ |
20 | diagnostics::DiagnosticSink, | 20 | diagnostics::DiagnosticSink, |
@@ -294,9 +294,9 @@ impl Module { | |||
294 | } | 294 | } |
295 | 295 | ||
296 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 296 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
297 | pub struct StructField { | 297 | pub struct Field { |
298 | pub(crate) parent: VariantDef, | 298 | pub(crate) parent: VariantDef, |
299 | pub(crate) id: LocalStructFieldId, | 299 | pub(crate) id: LocalFieldId, |
300 | } | 300 | } |
301 | 301 | ||
302 | #[derive(Debug, PartialEq, Eq)] | 302 | #[derive(Debug, PartialEq, Eq)] |
@@ -305,7 +305,7 @@ pub enum FieldSource { | |||
305 | Pos(ast::TupleFieldDef), | 305 | Pos(ast::TupleFieldDef), |
306 | } | 306 | } |
307 | 307 | ||
308 | impl StructField { | 308 | impl Field { |
309 | pub fn name(&self, db: &dyn HirDatabase) -> Name { | 309 | pub fn name(&self, db: &dyn HirDatabase) -> Name { |
310 | self.parent.variant_data(db).fields()[self.id].name.clone() | 310 | self.parent.variant_data(db).fields()[self.id].name.clone() |
311 | } | 311 | } |
@@ -331,7 +331,7 @@ impl StructField { | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | impl HasVisibility for StructField { | 334 | impl HasVisibility for Field { |
335 | fn visibility(&self, db: &dyn HirDatabase) -> Visibility { | 335 | fn visibility(&self, db: &dyn HirDatabase) -> Visibility { |
336 | let variant_data = self.parent.variant_data(db); | 336 | let variant_data = self.parent.variant_data(db); |
337 | let visibility = &variant_data.fields()[self.id].visibility; | 337 | let visibility = &variant_data.fields()[self.id].visibility; |
@@ -358,12 +358,12 @@ impl Struct { | |||
358 | db.struct_data(self.id).name.clone() | 358 | db.struct_data(self.id).name.clone() |
359 | } | 359 | } |
360 | 360 | ||
361 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { | 361 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> { |
362 | db.struct_data(self.id) | 362 | db.struct_data(self.id) |
363 | .variant_data | 363 | .variant_data |
364 | .fields() | 364 | .fields() |
365 | .iter() | 365 | .iter() |
366 | .map(|(id, _)| StructField { parent: self.into(), id }) | 366 | .map(|(id, _)| Field { parent: self.into(), id }) |
367 | .collect() | 367 | .collect() |
368 | } | 368 | } |
369 | 369 | ||
@@ -394,12 +394,12 @@ impl Union { | |||
394 | Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) | 394 | Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) |
395 | } | 395 | } |
396 | 396 | ||
397 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { | 397 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> { |
398 | db.union_data(self.id) | 398 | db.union_data(self.id) |
399 | .variant_data | 399 | .variant_data |
400 | .fields() | 400 | .fields() |
401 | .iter() | 401 | .iter() |
402 | .map(|(id, _)| StructField { parent: self.into(), id }) | 402 | .map(|(id, _)| Field { parent: self.into(), id }) |
403 | .collect() | 403 | .collect() |
404 | } | 404 | } |
405 | 405 | ||
@@ -457,11 +457,11 @@ impl EnumVariant { | |||
457 | db.enum_data(self.parent.id).variants[self.id].name.clone() | 457 | db.enum_data(self.parent.id).variants[self.id].name.clone() |
458 | } | 458 | } |
459 | 459 | ||
460 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { | 460 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> { |
461 | self.variant_data(db) | 461 | self.variant_data(db) |
462 | .fields() | 462 | .fields() |
463 | .iter() | 463 | .iter() |
464 | .map(|(id, _)| StructField { parent: self.into(), id }) | 464 | .map(|(id, _)| Field { parent: self.into(), id }) |
465 | .collect() | 465 | .collect() |
466 | } | 466 | } |
467 | 467 | ||
@@ -527,7 +527,7 @@ pub enum VariantDef { | |||
527 | impl_froms!(VariantDef: Struct, Union, EnumVariant); | 527 | impl_froms!(VariantDef: Struct, Union, EnumVariant); |
528 | 528 | ||
529 | impl VariantDef { | 529 | impl VariantDef { |
530 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { | 530 | pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> { |
531 | match self { | 531 | match self { |
532 | VariantDef::Struct(it) => it.fields(db), | 532 | VariantDef::Struct(it) => it.fields(db), |
533 | VariantDef::Union(it) => it.fields(db), | 533 | VariantDef::Union(it) => it.fields(db), |
@@ -1148,7 +1148,7 @@ impl Type { | |||
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(StructField, Type)> { | 1151 | pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> { |
1152 | if let Ty::Apply(a_ty) = &self.ty.value { | 1152 | if let Ty::Apply(a_ty) = &self.ty.value { |
1153 | if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { | 1153 | if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { |
1154 | let var_def = s.into(); | 1154 | let var_def = s.into(); |
@@ -1156,7 +1156,7 @@ impl Type { | |||
1156 | .field_types(var_def) | 1156 | .field_types(var_def) |
1157 | .iter() | 1157 | .iter() |
1158 | .map(|(local_id, ty)| { | 1158 | .map(|(local_id, ty)| { |
1159 | let def = StructField { parent: var_def.into(), id: local_id }; | 1159 | let def = Field { parent: var_def.into(), id: local_id }; |
1160 | let ty = ty.clone().subst(&a_ty.parameters); | 1160 | let ty = ty.clone().subst(&a_ty.parameters); |
1161 | (def, self.derived(ty)) | 1161 | (def, self.derived(ty)) |
1162 | }) | 1162 | }) |
@@ -1352,7 +1352,7 @@ impl ScopeDef { | |||
1352 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 1352 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
1353 | pub enum AttrDef { | 1353 | pub enum AttrDef { |
1354 | Module(Module), | 1354 | Module(Module), |
1355 | StructField(StructField), | 1355 | Field(Field), |
1356 | Adt(Adt), | 1356 | Adt(Adt), |
1357 | Function(Function), | 1357 | Function(Function), |
1358 | EnumVariant(EnumVariant), | 1358 | EnumVariant(EnumVariant), |
@@ -1365,7 +1365,7 @@ pub enum AttrDef { | |||
1365 | 1365 | ||
1366 | impl_froms!( | 1366 | impl_froms!( |
1367 | AttrDef: Module, | 1367 | AttrDef: Module, |
1368 | StructField, | 1368 | Field, |
1369 | Adt(Struct, Enum, Union), | 1369 | Adt(Struct, Enum, Union), |
1370 | EnumVariant, | 1370 | EnumVariant, |
1371 | Static, | 1371 | Static, |
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 62fb52e72..679ae8121 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs | |||
@@ -4,13 +4,13 @@ | |||
4 | //! are splitting the hir. | 4 | //! are splitting the hir. |
5 | 5 | ||
6 | use hir_def::{ | 6 | use hir_def::{ |
7 | expr::PatId, AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, GenericDefId, | 7 | expr::PatId, AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, FieldId, |
8 | ModuleDefId, StructFieldId, VariantId, | 8 | GenericDefId, ModuleDefId, VariantId, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | code_model::ItemInNs, Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, GenericDef, Local, | 12 | code_model::ItemInNs, Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, Field, GenericDef, |
13 | MacroDef, ModuleDef, StructField, VariantDef, | 13 | Local, MacroDef, ModuleDef, VariantDef, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | macro_rules! from_id { | 16 | macro_rules! from_id { |
@@ -184,15 +184,15 @@ impl From<VariantDef> for VariantId { | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | impl From<StructField> for StructFieldId { | 187 | impl From<Field> for FieldId { |
188 | fn from(def: StructField) -> Self { | 188 | fn from(def: Field) -> Self { |
189 | StructFieldId { parent: def.parent.into(), local_id: def.id } | 189 | FieldId { parent: def.parent.into(), local_id: def.id } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | impl From<StructFieldId> for StructField { | 193 | impl From<FieldId> for Field { |
194 | fn from(def: StructFieldId) -> Self { | 194 | fn from(def: FieldId) -> Self { |
195 | StructField { parent: def.parent.into(), id: def.local_id } | 195 | Field { parent: def.parent.into(), id: def.local_id } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
@@ -200,7 +200,7 @@ impl From<AttrDef> for AttrDefId { | |||
200 | fn from(def: AttrDef) -> Self { | 200 | fn from(def: AttrDef) -> Self { |
201 | match def { | 201 | match def { |
202 | AttrDef::Module(it) => AttrDefId::ModuleId(it.id), | 202 | AttrDef::Module(it) => AttrDefId::ModuleId(it.id), |
203 | AttrDef::StructField(it) => AttrDefId::StructFieldId(it.into()), | 203 | AttrDef::Field(it) => AttrDefId::FieldId(it.into()), |
204 | AttrDef::Adt(it) => AttrDefId::AdtId(it.into()), | 204 | AttrDef::Adt(it) => AttrDefId::AdtId(it.into()), |
205 | AttrDef::Function(it) => AttrDefId::FunctionId(it.id), | 205 | AttrDef::Function(it) => AttrDefId::FunctionId(it.id), |
206 | AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()), | 206 | AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()), |
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 129764e0a..63b8fd369 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs | |||
@@ -9,8 +9,8 @@ use hir_def::{ | |||
9 | use ra_syntax::ast; | 9 | use ra_syntax::ast; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::HirDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module, | 12 | db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef, |
13 | Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, | 13 | Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | pub use hir_expand::InFile; | 16 | pub use hir_expand::InFile; |
@@ -37,7 +37,7 @@ impl Module { | |||
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | impl HasSource for StructField { | 40 | impl HasSource for Field { |
41 | type Ast = FieldSource; | 41 | type Ast = FieldSource; |
42 | fn source(self, db: &dyn HirDatabase) -> InFile<FieldSource> { | 42 | fn source(self, db: &dyn HirDatabase) -> InFile<FieldSource> { |
43 | let var = VariantId::from(self.parent); | 43 | let var = VariantId::from(self.parent); |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 5af7e5d6d..312ef3814 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -52,9 +52,9 @@ mod has_source; | |||
52 | pub use crate::{ | 52 | pub use crate::{ |
53 | code_model::{ | 53 | code_model::{ |
54 | Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, | 54 | Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, |
55 | DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, | 55 | DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource, Function, GenericDef, HasAttrs, |
56 | HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, | 56 | HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, |
57 | StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, | 57 | Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, |
58 | }, | 58 | }, |
59 | has_source::HasSource, | 59 | has_source::HasSource, |
60 | semantics::{original_range, PathResolution, Semantics, SemanticsScope}, | 60 | semantics::{original_range, PathResolution, Semantics, SemanticsScope}, |
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 5d6edc45c..86bfb416c 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -14,7 +14,7 @@ use ra_db::{FileId, FileRange}; | |||
14 | use ra_prof::profile; | 14 | use ra_prof::profile; |
15 | use ra_syntax::{ | 15 | use ra_syntax::{ |
16 | algo::{find_node_at_offset, skip_trivia_token}, | 16 | algo::{find_node_at_offset, skip_trivia_token}, |
17 | ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextUnit, | 17 | ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize, |
18 | }; | 18 | }; |
19 | use rustc_hash::{FxHashMap, FxHashSet}; | 19 | use rustc_hash::{FxHashMap, FxHashSet}; |
20 | 20 | ||
@@ -23,8 +23,8 @@ use crate::{ | |||
23 | diagnostics::Diagnostic, | 23 | diagnostics::Diagnostic, |
24 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, | 24 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, |
25 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, | 25 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, |
26 | AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name, | 26 | AssocItem, Field, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, |
27 | Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, | 27 | Name, Origin, Path, ScopeDef, Trait, Type, TypeParam, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | #[derive(Debug, Clone, PartialEq, Eq)] | 30 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -95,7 +95,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
95 | let token = successors(Some(parent.with_value(token)), |token| { | 95 | let token = successors(Some(parent.with_value(token)), |token| { |
96 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; | 96 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; |
97 | let tt = macro_call.token_tree()?; | 97 | let tt = macro_call.token_tree()?; |
98 | if !token.value.text_range().is_subrange(&tt.syntax().text_range()) { | 98 | if !tt.syntax().text_range().contains_range(token.value.text_range()) { |
99 | return None; | 99 | return None; |
100 | } | 100 | } |
101 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; | 101 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; |
@@ -114,7 +114,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
114 | pub fn descend_node_at_offset<N: ast::AstNode>( | 114 | pub fn descend_node_at_offset<N: ast::AstNode>( |
115 | &self, | 115 | &self, |
116 | node: &SyntaxNode, | 116 | node: &SyntaxNode, |
117 | offset: TextUnit, | 117 | offset: TextSize, |
118 | ) -> Option<N> { | 118 | ) -> Option<N> { |
119 | // Handle macro token cases | 119 | // Handle macro token cases |
120 | node.token_at_offset(offset) | 120 | node.token_at_offset(offset) |
@@ -142,7 +142,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
142 | pub fn ancestors_at_offset_with_macros( | 142 | pub fn ancestors_at_offset_with_macros( |
143 | &self, | 143 | &self, |
144 | node: &SyntaxNode, | 144 | node: &SyntaxNode, |
145 | offset: TextUnit, | 145 | offset: TextSize, |
146 | ) -> impl Iterator<Item = SyntaxNode> + '_ { | 146 | ) -> impl Iterator<Item = SyntaxNode> + '_ { |
147 | node.token_at_offset(offset) | 147 | node.token_at_offset(offset) |
148 | .map(|token| self.ancestors_with_macros(token.parent())) | 148 | .map(|token| self.ancestors_with_macros(token.parent())) |
@@ -154,7 +154,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
154 | pub fn find_node_at_offset_with_macros<N: AstNode>( | 154 | pub fn find_node_at_offset_with_macros<N: AstNode>( |
155 | &self, | 155 | &self, |
156 | node: &SyntaxNode, | 156 | node: &SyntaxNode, |
157 | offset: TextUnit, | 157 | offset: TextSize, |
158 | ) -> Option<N> { | 158 | ) -> Option<N> { |
159 | self.ancestors_at_offset_with_macros(node, offset).find_map(N::cast) | 159 | self.ancestors_at_offset_with_macros(node, offset).find_map(N::cast) |
160 | } | 160 | } |
@@ -164,7 +164,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
164 | pub fn find_node_at_offset_with_descend<N: AstNode>( | 164 | pub fn find_node_at_offset_with_descend<N: AstNode>( |
165 | &self, | 165 | &self, |
166 | node: &SyntaxNode, | 166 | node: &SyntaxNode, |
167 | offset: TextUnit, | 167 | offset: TextSize, |
168 | ) -> Option<N> { | 168 | ) -> Option<N> { |
169 | if let Some(it) = find_node_at_offset(&node, offset) { | 169 | if let Some(it) = find_node_at_offset(&node, offset) { |
170 | return Some(it); | 170 | return Some(it); |
@@ -184,18 +184,15 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
184 | self.analyze(call.syntax()).resolve_method_call(self.db, call) | 184 | self.analyze(call.syntax()).resolve_method_call(self.db, call) |
185 | } | 185 | } |
186 | 186 | ||
187 | pub fn resolve_field(&self, field: &ast::FieldExpr) -> Option<StructField> { | 187 | pub fn resolve_field(&self, field: &ast::FieldExpr) -> Option<Field> { |
188 | self.analyze(field.syntax()).resolve_field(self.db, field) | 188 | self.analyze(field.syntax()).resolve_field(self.db, field) |
189 | } | 189 | } |
190 | 190 | ||
191 | pub fn resolve_record_field( | 191 | pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { |
192 | &self, | ||
193 | field: &ast::RecordField, | ||
194 | ) -> Option<(StructField, Option<Local>)> { | ||
195 | self.analyze(field.syntax()).resolve_record_field(self.db, field) | 192 | self.analyze(field.syntax()).resolve_record_field(self.db, field) |
196 | } | 193 | } |
197 | 194 | ||
198 | pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<StructField> { | 195 | pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> { |
199 | self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) | 196 | self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) |
200 | } | 197 | } |
201 | 198 | ||
@@ -216,19 +213,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
216 | // FIXME: use this instead? | 213 | // FIXME: use this instead? |
217 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; | 214 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; |
218 | 215 | ||
219 | pub fn record_literal_missing_fields( | 216 | pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { |
220 | &self, | ||
221 | literal: &ast::RecordLit, | ||
222 | ) -> Vec<(StructField, Type)> { | ||
223 | self.analyze(literal.syntax()) | 217 | self.analyze(literal.syntax()) |
224 | .record_literal_missing_fields(self.db, literal) | 218 | .record_literal_missing_fields(self.db, literal) |
225 | .unwrap_or_default() | 219 | .unwrap_or_default() |
226 | } | 220 | } |
227 | 221 | ||
228 | pub fn record_pattern_missing_fields( | 222 | pub fn record_pattern_missing_fields(&self, pattern: &ast::RecordPat) -> Vec<(Field, Type)> { |
229 | &self, | ||
230 | pattern: &ast::RecordPat, | ||
231 | ) -> Vec<(StructField, Type)> { | ||
232 | self.analyze(pattern.syntax()) | 223 | self.analyze(pattern.syntax()) |
233 | .record_pattern_missing_fields(self.db, pattern) | 224 | .record_pattern_missing_fields(self.db, pattern) |
234 | .unwrap_or_default() | 225 | .unwrap_or_default() |
@@ -255,7 +246,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
255 | SemanticsScope { db: self.db, resolver } | 246 | SemanticsScope { db: self.db, resolver } |
256 | } | 247 | } |
257 | 248 | ||
258 | pub fn scope_at_offset(&self, node: &SyntaxNode, offset: TextUnit) -> SemanticsScope<'db, DB> { | 249 | pub fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db, DB> { |
259 | let node = self.find_file(node.clone()); | 250 | let node = self.find_file(node.clone()); |
260 | let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver; | 251 | let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver; |
261 | SemanticsScope { db: self.db, resolver } | 252 | SemanticsScope { db: self.db, resolver } |
@@ -271,7 +262,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
271 | self.analyze2(src.as_ref(), None) | 262 | self.analyze2(src.as_ref(), None) |
272 | } | 263 | } |
273 | 264 | ||
274 | fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextUnit>) -> SourceAnalyzer { | 265 | fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextSize>) -> SourceAnalyzer { |
275 | let _p = profile("Semantics::analyze2"); | 266 | let _p = profile("Semantics::analyze2"); |
276 | 267 | ||
277 | let container = match self.with_ctx(|ctx| ctx.find_container(src)) { | 268 | let container = match self.with_ctx(|ctx| ctx.find_container(src)) { |
@@ -359,8 +350,8 @@ to_def_impls![ | |||
359 | (crate::Const, ast::ConstDef, const_to_def), | 350 | (crate::Const, ast::ConstDef, const_to_def), |
360 | (crate::Static, ast::StaticDef, static_to_def), | 351 | (crate::Static, ast::StaticDef, static_to_def), |
361 | (crate::Function, ast::FnDef, fn_to_def), | 352 | (crate::Function, ast::FnDef, fn_to_def), |
362 | (crate::StructField, ast::RecordFieldDef, record_field_to_def), | 353 | (crate::Field, ast::RecordFieldDef, record_field_to_def), |
363 | (crate::StructField, ast::TupleFieldDef, tuple_field_to_def), | 354 | (crate::Field, ast::TupleFieldDef, tuple_field_to_def), |
364 | (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), | 355 | (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), |
365 | (crate::TypeParam, ast::TypeParam, type_param_to_def), | 356 | (crate::TypeParam, ast::TypeParam, type_param_to_def), |
366 | (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros | 357 | (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros |
@@ -463,7 +454,7 @@ fn original_range_opt( | |||
463 | return None; | 454 | return None; |
464 | } | 455 | } |
465 | 456 | ||
466 | Some(first.with_value(first.value.text_range().extend_to(&last.value.text_range()))) | 457 | Some(first.with_value(first.value.text_range().cover(last.value.text_range()))) |
467 | })?) | 458 | })?) |
468 | } | 459 | } |
469 | 460 | ||
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 66724919b..6f3b5b2da 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs | |||
@@ -5,8 +5,8 @@ use hir_def::{ | |||
5 | dyn_map::DynMap, | 5 | dyn_map::DynMap, |
6 | expr::PatId, | 6 | expr::PatId, |
7 | keys::{self, Key}, | 7 | keys::{self, Key}, |
8 | ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId, ImplId, ModuleId, | 8 | ConstId, DefWithBodyId, EnumId, EnumVariantId, FieldId, FunctionId, GenericDefId, ImplId, |
9 | StaticId, StructFieldId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, | 9 | ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, |
10 | }; | 10 | }; |
11 | use hir_expand::{name::AsName, AstId, MacroDefKind}; | 11 | use hir_expand::{name::AsName, AstId, MacroDefKind}; |
12 | use ra_db::FileId; | 12 | use ra_db::FileId; |
@@ -97,13 +97,13 @@ impl SourceToDefCtx<'_, '_> { | |||
97 | pub(super) fn record_field_to_def( | 97 | pub(super) fn record_field_to_def( |
98 | &mut self, | 98 | &mut self, |
99 | src: InFile<ast::RecordFieldDef>, | 99 | src: InFile<ast::RecordFieldDef>, |
100 | ) -> Option<StructFieldId> { | 100 | ) -> Option<FieldId> { |
101 | self.to_def(src, keys::RECORD_FIELD) | 101 | self.to_def(src, keys::RECORD_FIELD) |
102 | } | 102 | } |
103 | pub(super) fn tuple_field_to_def( | 103 | pub(super) fn tuple_field_to_def( |
104 | &mut self, | 104 | &mut self, |
105 | src: InFile<ast::TupleFieldDef>, | 105 | src: InFile<ast::TupleFieldDef>, |
106 | ) -> Option<StructFieldId> { | 106 | ) -> Option<FieldId> { |
107 | self.to_def(src, keys::TUPLE_FIELD) | 107 | self.to_def(src, keys::TUPLE_FIELD) |
108 | } | 108 | } |
109 | pub(super) fn enum_variant_to_def( | 109 | pub(super) fn enum_variant_to_def( |
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 0ed6d0958..74d64c97d 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs | |||
@@ -14,7 +14,7 @@ use hir_def::{ | |||
14 | }, | 14 | }, |
15 | expr::{ExprId, Pat, PatId}, | 15 | expr::{ExprId, Pat, PatId}, |
16 | resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs}, | 16 | resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs}, |
17 | AsMacroCall, DefWithBodyId, LocalStructFieldId, StructFieldId, VariantId, | 17 | AsMacroCall, DefWithBodyId, FieldId, LocalFieldId, VariantId, |
18 | }; | 18 | }; |
19 | use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; | 19 | use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; |
20 | use hir_ty::{ | 20 | use hir_ty::{ |
@@ -23,12 +23,12 @@ use hir_ty::{ | |||
23 | }; | 23 | }; |
24 | use ra_syntax::{ | 24 | use ra_syntax::{ |
25 | ast::{self, AstNode}, | 25 | ast::{self, AstNode}, |
26 | SyntaxNode, TextRange, TextUnit, | 26 | SyntaxNode, TextRange, TextSize, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | use crate::{ | 29 | use crate::{ |
30 | db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Function, Local, MacroDef, | 30 | db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Field, Function, Local, |
31 | ModPath, ModuleDef, Path, PathKind, Static, Struct, StructField, Trait, Type, TypeAlias, | 31 | MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, |
32 | TypeParam, | 32 | TypeParam, |
33 | }; | 33 | }; |
34 | use ra_db::CrateId; | 34 | use ra_db::CrateId; |
@@ -50,7 +50,7 @@ impl SourceAnalyzer { | |||
50 | db: &dyn HirDatabase, | 50 | db: &dyn HirDatabase, |
51 | def: DefWithBodyId, | 51 | def: DefWithBodyId, |
52 | node: InFile<&SyntaxNode>, | 52 | node: InFile<&SyntaxNode>, |
53 | offset: Option<TextUnit>, | 53 | offset: Option<TextSize>, |
54 | ) -> SourceAnalyzer { | 54 | ) -> SourceAnalyzer { |
55 | let (body, source_map) = db.body_with_source_map(def); | 55 | let (body, source_map) = db.body_with_source_map(def); |
56 | let scopes = db.expr_scopes(def); | 56 | let scopes = db.expr_scopes(def); |
@@ -140,7 +140,7 @@ impl SourceAnalyzer { | |||
140 | &self, | 140 | &self, |
141 | db: &dyn HirDatabase, | 141 | db: &dyn HirDatabase, |
142 | field: &ast::FieldExpr, | 142 | field: &ast::FieldExpr, |
143 | ) -> Option<StructField> { | 143 | ) -> Option<Field> { |
144 | let expr_id = self.expr_id(db, &field.clone().into())?; | 144 | let expr_id = self.expr_id(db, &field.clone().into())?; |
145 | self.infer.as_ref()?.field_resolution(expr_id).map(|it| it.into()) | 145 | self.infer.as_ref()?.field_resolution(expr_id).map(|it| it.into()) |
146 | } | 146 | } |
@@ -149,7 +149,7 @@ impl SourceAnalyzer { | |||
149 | &self, | 149 | &self, |
150 | db: &dyn HirDatabase, | 150 | db: &dyn HirDatabase, |
151 | field: &ast::RecordField, | 151 | field: &ast::RecordField, |
152 | ) -> Option<(StructField, Option<Local>)> { | 152 | ) -> Option<(Field, Option<Local>)> { |
153 | let expr = field.expr()?; | 153 | let expr = field.expr()?; |
154 | let expr_id = self.expr_id(db, &expr)?; | 154 | let expr_id = self.expr_id(db, &expr)?; |
155 | let local = if field.name_ref().is_some() { | 155 | let local = if field.name_ref().is_some() { |
@@ -172,7 +172,7 @@ impl SourceAnalyzer { | |||
172 | &self, | 172 | &self, |
173 | _db: &dyn HirDatabase, | 173 | _db: &dyn HirDatabase, |
174 | field: &ast::RecordFieldPat, | 174 | field: &ast::RecordFieldPat, |
175 | ) -> Option<StructField> { | 175 | ) -> Option<Field> { |
176 | let pat_id = self.pat_id(&field.pat()?)?; | 176 | let pat_id = self.pat_id(&field.pat()?)?; |
177 | let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; | 177 | let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; |
178 | Some(struct_field.into()) | 178 | Some(struct_field.into()) |
@@ -232,7 +232,7 @@ impl SourceAnalyzer { | |||
232 | &self, | 232 | &self, |
233 | db: &dyn HirDatabase, | 233 | db: &dyn HirDatabase, |
234 | literal: &ast::RecordLit, | 234 | literal: &ast::RecordLit, |
235 | ) -> Option<Vec<(StructField, Type)>> { | 235 | ) -> Option<Vec<(Field, Type)>> { |
236 | let krate = self.resolver.krate()?; | 236 | let krate = self.resolver.krate()?; |
237 | let body = self.body.as_ref()?; | 237 | let body = self.body.as_ref()?; |
238 | let infer = self.infer.as_ref()?; | 238 | let infer = self.infer.as_ref()?; |
@@ -253,7 +253,7 @@ impl SourceAnalyzer { | |||
253 | &self, | 253 | &self, |
254 | db: &dyn HirDatabase, | 254 | db: &dyn HirDatabase, |
255 | pattern: &ast::RecordPat, | 255 | pattern: &ast::RecordPat, |
256 | ) -> Option<Vec<(StructField, Type)>> { | 256 | ) -> Option<Vec<(Field, Type)>> { |
257 | let krate = self.resolver.krate()?; | 257 | let krate = self.resolver.krate()?; |
258 | let body = self.body.as_ref()?; | 258 | let body = self.body.as_ref()?; |
259 | let infer = self.infer.as_ref()?; | 259 | let infer = self.infer.as_ref()?; |
@@ -276,14 +276,14 @@ impl SourceAnalyzer { | |||
276 | krate: CrateId, | 276 | krate: CrateId, |
277 | substs: &Substs, | 277 | substs: &Substs, |
278 | variant: VariantId, | 278 | variant: VariantId, |
279 | missing_fields: Vec<LocalStructFieldId>, | 279 | missing_fields: Vec<LocalFieldId>, |
280 | ) -> Vec<(StructField, Type)> { | 280 | ) -> Vec<(Field, Type)> { |
281 | let field_types = db.field_types(variant); | 281 | let field_types = db.field_types(variant); |
282 | 282 | ||
283 | missing_fields | 283 | missing_fields |
284 | .into_iter() | 284 | .into_iter() |
285 | .map(|local_id| { | 285 | .map(|local_id| { |
286 | let field = StructFieldId { parent: variant, local_id }; | 286 | let field = FieldId { parent: variant, local_id }; |
287 | let ty = field_types[local_id].clone().subst(substs); | 287 | let ty = field_types[local_id].clone().subst(substs); |
288 | (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) | 288 | (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) |
289 | }) | 289 | }) |
@@ -318,7 +318,7 @@ fn scope_for_offset( | |||
318 | db: &dyn HirDatabase, | 318 | db: &dyn HirDatabase, |
319 | scopes: &ExprScopes, | 319 | scopes: &ExprScopes, |
320 | source_map: &BodySourceMap, | 320 | source_map: &BodySourceMap, |
321 | offset: InFile<TextUnit>, | 321 | offset: InFile<TextSize>, |
322 | ) -> Option<ScopeId> { | 322 | ) -> Option<ScopeId> { |
323 | scopes | 323 | scopes |
324 | .scope_by_expr() | 324 | .scope_by_expr() |
@@ -354,7 +354,7 @@ fn adjust( | |||
354 | source_map: &BodySourceMap, | 354 | source_map: &BodySourceMap, |
355 | expr_range: TextRange, | 355 | expr_range: TextRange, |
356 | file_id: HirFileId, | 356 | file_id: HirFileId, |
357 | offset: TextUnit, | 357 | offset: TextSize, |
358 | ) -> Option<ScopeId> { | 358 | ) -> Option<ScopeId> { |
359 | let child_scopes = scopes | 359 | let child_scopes = scopes |
360 | .scope_by_expr() | 360 | .scope_by_expr() |
@@ -369,15 +369,15 @@ fn adjust( | |||
369 | let node = source.value.to_node(&root); | 369 | let node = source.value.to_node(&root); |
370 | Some((node.syntax().text_range(), scope)) | 370 | Some((node.syntax().text_range(), scope)) |
371 | }) | 371 | }) |
372 | .filter(|(range, _)| { | 372 | .filter(|&(range, _)| { |
373 | range.start() <= offset && range.is_subrange(&expr_range) && *range != expr_range | 373 | range.start() <= offset && expr_range.contains_range(range) && range != expr_range |
374 | }); | 374 | }); |
375 | 375 | ||
376 | child_scopes | 376 | child_scopes |
377 | .max_by(|(r1, _), (r2, _)| { | 377 | .max_by(|&(r1, _), &(r2, _)| { |
378 | if r2.is_subrange(&r1) { | 378 | if r1.contains_range(r2) { |
379 | std::cmp::Ordering::Greater | 379 | std::cmp::Ordering::Greater |
380 | } else if r1.is_subrange(&r2) { | 380 | } else if r2.contains_range(r1) { |
381 | std::cmp::Ordering::Less | 381 | std::cmp::Ordering::Less |
382 | } else { | 382 | } else { |
383 | r1.start().cmp(&r2.start()) | 383 | r1.start().cmp(&r2.start()) |
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 7c0d93691..753becc3d 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -14,7 +14,7 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | |||
14 | use crate::{ | 14 | use crate::{ |
15 | body::CfgExpander, db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, | 15 | body::CfgExpander, db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, |
16 | type_ref::TypeRef, visibility::RawVisibility, EnumId, HasModule, LocalEnumVariantId, | 16 | type_ref::TypeRef, visibility::RawVisibility, EnumId, HasModule, LocalEnumVariantId, |
17 | LocalStructFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, | 17 | LocalFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | /// Note that we use `StructData` for unions as well! | 20 | /// Note that we use `StructData` for unions as well! |
@@ -38,14 +38,14 @@ pub struct EnumVariantData { | |||
38 | 38 | ||
39 | #[derive(Debug, Clone, PartialEq, Eq)] | 39 | #[derive(Debug, Clone, PartialEq, Eq)] |
40 | pub enum VariantData { | 40 | pub enum VariantData { |
41 | Record(Arena<StructFieldData>), | 41 | Record(Arena<FieldData>), |
42 | Tuple(Arena<StructFieldData>), | 42 | Tuple(Arena<FieldData>), |
43 | Unit, | 43 | Unit, |
44 | } | 44 | } |
45 | 45 | ||
46 | /// A single field of an enum variant or struct | 46 | /// A single field of an enum variant or struct |
47 | #[derive(Debug, Clone, PartialEq, Eq)] | 47 | #[derive(Debug, Clone, PartialEq, Eq)] |
48 | pub struct StructFieldData { | 48 | pub struct FieldData { |
49 | pub name: Name, | 49 | pub name: Name, |
50 | pub type_ref: TypeRef, | 50 | pub type_ref: TypeRef, |
51 | pub visibility: RawVisibility, | 51 | pub visibility: RawVisibility, |
@@ -133,15 +133,15 @@ impl VariantData { | |||
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | pub fn fields(&self) -> &Arena<StructFieldData> { | 136 | pub fn fields(&self) -> &Arena<FieldData> { |
137 | const EMPTY: &Arena<StructFieldData> = &Arena::new(); | 137 | const EMPTY: &Arena<FieldData> = &Arena::new(); |
138 | match &self { | 138 | match &self { |
139 | VariantData::Record(fields) | VariantData::Tuple(fields) => fields, | 139 | VariantData::Record(fields) | VariantData::Tuple(fields) => fields, |
140 | _ => EMPTY, | 140 | _ => EMPTY, |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | pub fn field(&self, name: &Name) -> Option<LocalStructFieldId> { | 144 | pub fn field(&self, name: &Name) -> Option<LocalFieldId> { |
145 | self.fields().iter().find_map(|(id, data)| if &data.name == name { Some(id) } else { None }) | 145 | self.fields().iter().find_map(|(id, data)| if &data.name == name { Some(id) } else { None }) |
146 | } | 146 | } |
147 | 147 | ||
@@ -155,7 +155,7 @@ impl VariantData { | |||
155 | } | 155 | } |
156 | 156 | ||
157 | impl HasChildSource for VariantId { | 157 | impl HasChildSource for VariantId { |
158 | type ChildId = LocalStructFieldId; | 158 | type ChildId = LocalFieldId; |
159 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; | 159 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; |
160 | 160 | ||
161 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { | 161 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { |
@@ -195,7 +195,7 @@ pub enum StructKind { | |||
195 | fn lower_struct( | 195 | fn lower_struct( |
196 | db: &dyn DefDatabase, | 196 | db: &dyn DefDatabase, |
197 | expander: &mut CfgExpander, | 197 | expander: &mut CfgExpander, |
198 | trace: &mut Trace<StructFieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, | 198 | trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, |
199 | ast: &InFile<ast::StructKind>, | 199 | ast: &InFile<ast::StructKind>, |
200 | ) -> StructKind { | 200 | ) -> StructKind { |
201 | match &ast.value { | 201 | match &ast.value { |
@@ -208,7 +208,7 @@ fn lower_struct( | |||
208 | 208 | ||
209 | trace.alloc( | 209 | trace.alloc( |
210 | || Either::Left(fd.clone()), | 210 | || Either::Left(fd.clone()), |
211 | || StructFieldData { | 211 | || FieldData { |
212 | name: Name::new_tuple_field(i), | 212 | name: Name::new_tuple_field(i), |
213 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), | 213 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), |
214 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 214 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
@@ -226,7 +226,7 @@ fn lower_struct( | |||
226 | 226 | ||
227 | trace.alloc( | 227 | trace.alloc( |
228 | || Either::Right(fd.clone()), | 228 | || Either::Right(fd.clone()), |
229 | || StructFieldData { | 229 | || FieldData { |
230 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), | 230 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), |
231 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), | 231 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), |
232 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 232 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 2f2e3e5ba..714a66b02 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -43,7 +43,7 @@ impl Attrs { | |||
43 | }; | 43 | }; |
44 | Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) | 44 | Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) |
45 | } | 45 | } |
46 | AttrDefId::StructFieldId(it) => { | 46 | AttrDefId::FieldId(it) => { |
47 | let src = it.parent.child_source(db); | 47 | let src = it.parent.child_source(db); |
48 | match &src.value[it.local_id] { | 48 | match &src.value[it.local_id] { |
49 | Either::Left(_tuple) => Attrs::default(), | 49 | Either::Left(_tuple) => Attrs::default(), |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 5b36a7cc1..86f953c80 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -194,7 +194,7 @@ mod tests { | |||
194 | let (off, code) = extract_offset(code); | 194 | let (off, code) = extract_offset(code); |
195 | let code = { | 195 | let code = { |
196 | let mut buf = String::new(); | 196 | let mut buf = String::new(); |
197 | let off = off.to_usize(); | 197 | let off: usize = off.into(); |
198 | buf.push_str(&code[..off]); | 198 | buf.push_str(&code[..off]); |
199 | buf.push_str("marker"); | 199 | buf.push_str("marker"); |
200 | buf.push_str(&code[off..]); | 200 | buf.push_str(&code[off..]); |
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs index 7009f21d1..a885ec96d 100644 --- a/crates/ra_hir_def/src/child_by_source.rs +++ b/crates/ra_hir_def/src/child_by_source.rs | |||
@@ -12,8 +12,8 @@ use crate::{ | |||
12 | item_scope::ItemScope, | 12 | item_scope::ItemScope, |
13 | keys, | 13 | keys, |
14 | src::{HasChildSource, HasSource}, | 14 | src::{HasChildSource, HasSource}, |
15 | AdtId, AssocItemId, DefWithBodyId, EnumId, EnumVariantId, ImplId, Lookup, ModuleDefId, | 15 | AdtId, AssocItemId, DefWithBodyId, EnumId, EnumVariantId, FieldId, ImplId, Lookup, ModuleDefId, |
16 | ModuleId, StructFieldId, TraitId, VariantId, | 16 | ModuleId, TraitId, VariantId, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | pub trait ChildBySource { | 19 | pub trait ChildBySource { |
@@ -140,7 +140,7 @@ impl ChildBySource for VariantId { | |||
140 | let arena_map = self.child_source(db); | 140 | let arena_map = self.child_source(db); |
141 | let arena_map = arena_map.as_ref(); | 141 | let arena_map = arena_map.as_ref(); |
142 | for (local_id, source) in arena_map.value.iter() { | 142 | for (local_id, source) in arena_map.value.iter() { |
143 | let id = StructFieldId { parent: *self, local_id }; | 143 | let id = FieldId { parent: *self, local_id }; |
144 | match source { | 144 | match source { |
145 | Either::Left(source) => { | 145 | Either::Left(source) => { |
146 | res[keys::TUPLE_FIELD].insert(arena_map.with_value(source.clone()), id) | 146 | res[keys::TUPLE_FIELD].insert(arena_map.with_value(source.clone()), id) |
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 0539a77d4..b221ae1ce 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs | |||
@@ -43,7 +43,7 @@ impl Documentation { | |||
43 | let src = def_map[module.local_id].declaration_source(db)?; | 43 | let src = def_map[module.local_id].declaration_source(db)?; |
44 | docs_from_ast(&src.value) | 44 | docs_from_ast(&src.value) |
45 | } | 45 | } |
46 | AttrDefId::StructFieldId(it) => { | 46 | AttrDefId::FieldId(it) => { |
47 | let src = it.parent.child_source(db); | 47 | let src = it.parent.child_source(db); |
48 | match &src.value[it.local_id] { | 48 | match &src.value[it.local_id] { |
49 | Either::Left(_tuple) => None, | 49 | Either::Left(_tuple) => None, |
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index 8cd70eb9a..a7349a21d 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs | |||
@@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; | |||
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | dyn_map::{DynMap, Policy}, | 10 | dyn_map::{DynMap, Policy}, |
11 | ConstId, EnumId, EnumVariantId, FunctionId, ImplId, StaticId, StructFieldId, StructId, TraitId, | 11 | ConstId, EnumId, EnumVariantId, FieldId, FunctionId, ImplId, StaticId, StructId, TraitId, |
12 | TypeAliasId, TypeParamId, UnionId, | 12 | TypeAliasId, TypeParamId, UnionId, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -25,8 +25,8 @@ pub const UNION: Key<ast::UnionDef, UnionId> = Key::new(); | |||
25 | pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new(); | 25 | pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new(); |
26 | 26 | ||
27 | pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); | 27 | pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); |
28 | pub const TUPLE_FIELD: Key<ast::TupleFieldDef, StructFieldId> = Key::new(); | 28 | pub const TUPLE_FIELD: Key<ast::TupleFieldDef, FieldId> = Key::new(); |
29 | pub const RECORD_FIELD: Key<ast::RecordFieldDef, StructFieldId> = Key::new(); | 29 | pub const RECORD_FIELD: Key<ast::RecordFieldDef, FieldId> = Key::new(); |
30 | pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); | 30 | pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); |
31 | 31 | ||
32 | pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new(); | 32 | pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new(); |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 2d27bbdf8..518772e8a 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -133,12 +133,12 @@ pub struct EnumVariantId { | |||
133 | pub type LocalEnumVariantId = Idx<adt::EnumVariantData>; | 133 | pub type LocalEnumVariantId = Idx<adt::EnumVariantData>; |
134 | 134 | ||
135 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 135 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
136 | pub struct StructFieldId { | 136 | pub struct FieldId { |
137 | pub parent: VariantId, | 137 | pub parent: VariantId, |
138 | pub local_id: LocalStructFieldId, | 138 | pub local_id: LocalFieldId, |
139 | } | 139 | } |
140 | 140 | ||
141 | pub type LocalStructFieldId = Idx<adt::StructFieldData>; | 141 | pub type LocalFieldId = Idx<adt::FieldData>; |
142 | 142 | ||
143 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 143 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
144 | pub struct ConstId(salsa::InternId); | 144 | pub struct ConstId(salsa::InternId); |
@@ -299,7 +299,7 @@ impl From<AssocItemId> for GenericDefId { | |||
299 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 299 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
300 | pub enum AttrDefId { | 300 | pub enum AttrDefId { |
301 | ModuleId(ModuleId), | 301 | ModuleId(ModuleId), |
302 | StructFieldId(StructFieldId), | 302 | FieldId(FieldId), |
303 | AdtId(AdtId), | 303 | AdtId(AdtId), |
304 | FunctionId(FunctionId), | 304 | FunctionId(FunctionId), |
305 | EnumVariantId(EnumVariantId), | 305 | EnumVariantId(EnumVariantId), |
@@ -313,7 +313,7 @@ pub enum AttrDefId { | |||
313 | 313 | ||
314 | impl_froms!( | 314 | impl_froms!( |
315 | AttrDefId: ModuleId, | 315 | AttrDefId: ModuleId, |
316 | StructFieldId, | 316 | FieldId, |
317 | AdtId(StructId, EnumId, UnionId), | 317 | AdtId(StructId, EnumId, UnionId), |
318 | EnumVariantId, | 318 | EnumVariantId, |
319 | StaticId, | 319 | StaticId, |
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 3da137f2e..e0fef613d 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | use crate::db::AstDatabase; | 2 | use crate::db::AstDatabase; |
3 | use crate::{ | 3 | use crate::{ |
4 | ast::{self, AstToken, HasStringValue}, | 4 | ast::{self, AstToken, HasStringValue}, |
5 | name, AstId, CrateId, MacroDefId, MacroDefKind, TextUnit, | 5 | name, AstId, CrateId, MacroDefId, MacroDefKind, TextSize, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{quote, EagerMacroId, LazyMacroId, MacroCallId}; | 8 | use crate::{quote, EagerMacroId, LazyMacroId, MacroCallId}; |
@@ -127,7 +127,7 @@ fn stringify_expand( | |||
127 | let arg = loc.kind.arg(db).ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; | 127 | let arg = loc.kind.arg(db).ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; |
128 | let macro_args = arg; | 128 | let macro_args = arg; |
129 | let text = macro_args.text(); | 129 | let text = macro_args.text(); |
130 | let without_parens = TextUnit::of_char('(')..text.len() - TextUnit::of_char(')'); | 130 | let without_parens = TextSize::of('(')..text.len() - TextSize::of(')'); |
131 | text.slice(without_parens).to_string() | 131 | text.slice(without_parens).to_string() |
132 | }; | 132 | }; |
133 | 133 | ||
@@ -358,7 +358,7 @@ fn env_expand( | |||
358 | // However, we cannot use an empty string here, because for | 358 | // However, we cannot use an empty string here, because for |
359 | // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become | 359 | // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become |
360 | // `include!("foo.rs"), which might go to infinite loop | 360 | // `include!("foo.rs"), which might go to infinite loop |
361 | let s = get_env_inner(db, arg_id, &key).unwrap_or("__RA_UNIMPLEMENTATED__".to_string()); | 361 | let s = get_env_inner(db, arg_id, &key).unwrap_or_else(|| "__RA_UNIMPLEMENTATED__".to_string()); |
362 | let expanded = quote! { #s }; | 362 | let expanded = quote! { #s }; |
363 | 363 | ||
364 | Ok((expanded, FragmentKind::Expr)) | 364 | Ok((expanded, FragmentKind::Expr)) |
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 86299459f..754a0f005 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -22,7 +22,7 @@ use ra_db::{impl_intern_key, salsa, CrateId, FileId}; | |||
22 | use ra_syntax::{ | 22 | use ra_syntax::{ |
23 | algo, | 23 | algo, |
24 | ast::{self, AstNode}, | 24 | ast::{self, AstNode}, |
25 | SyntaxNode, SyntaxToken, TextUnit, | 25 | SyntaxNode, SyntaxToken, TextSize, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | use crate::ast_id_map::FileAstId; | 28 | use crate::ast_id_map::FileAstId; |
@@ -348,7 +348,7 @@ impl<N: AstNode> AstId<N> { | |||
348 | /// | 348 | /// |
349 | /// * `InFile<SyntaxNode>` -- syntax node in a file | 349 | /// * `InFile<SyntaxNode>` -- syntax node in a file |
350 | /// * `InFile<ast::FnDef>` -- ast node in a file | 350 | /// * `InFile<ast::FnDef>` -- ast node in a file |
351 | /// * `InFile<TextUnit>` -- offset in a file | 351 | /// * `InFile<TextSize>` -- offset in a file |
352 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] | 352 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] |
353 | pub struct InFile<T> { | 353 | pub struct InFile<T> { |
354 | pub file_id: HirFileId, | 354 | pub file_id: HirFileId, |
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 9e5dfeab3..fdb49560b 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use hir_def::{ | 5 | use hir_def::{ |
6 | db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, TypeParamId, | 6 | db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalFieldId, TraitId, TypeParamId, |
7 | VariantId, | 7 | VariantId, |
8 | }; | 8 | }; |
9 | use ra_arena::map::ArenaMap; | 9 | use ra_arena::map::ArenaMap; |
@@ -43,7 +43,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { | |||
43 | fn impl_trait(&self, def: ImplId) -> Option<Binders<TraitRef>>; | 43 | fn impl_trait(&self, def: ImplId) -> Option<Binders<TraitRef>>; |
44 | 44 | ||
45 | #[salsa::invoke(crate::lower::field_types_query)] | 45 | #[salsa::invoke(crate::lower::field_types_query)] |
46 | fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Binders<Ty>>>; | 46 | fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>; |
47 | 47 | ||
48 | #[salsa::invoke(crate::callable_item_sig)] | 48 | #[salsa::invoke(crate::callable_item_sig)] |
49 | fn callable_item_signature(&self, def: CallableDef) -> PolyFnSig; | 49 | fn callable_item_signature(&self, def: CallableDef) -> PolyFnSig; |
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index fd59f4320..f04968e14 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs | |||
@@ -24,7 +24,7 @@ pub use hir_def::{ | |||
24 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, | 24 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, |
25 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp, | 25 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp, |
26 | }, | 26 | }, |
27 | LocalStructFieldId, VariantId, | 27 | LocalFieldId, VariantId, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | pub struct ExprValidator<'a, 'b: 'a> { | 30 | pub struct ExprValidator<'a, 'b: 'a> { |
@@ -83,7 +83,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
83 | id: ExprId, | 83 | id: ExprId, |
84 | db: &dyn HirDatabase, | 84 | db: &dyn HirDatabase, |
85 | variant_def: VariantId, | 85 | variant_def: VariantId, |
86 | missed_fields: Vec<LocalStructFieldId>, | 86 | missed_fields: Vec<LocalFieldId>, |
87 | ) { | 87 | ) { |
88 | // XXX: only look at source_map if we do have missing fields | 88 | // XXX: only look at source_map if we do have missing fields |
89 | let (_, source_map) = db.body_with_source_map(self.func.into()); | 89 | let (_, source_map) = db.body_with_source_map(self.func.into()); |
@@ -112,7 +112,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
112 | id: PatId, | 112 | id: PatId, |
113 | db: &dyn HirDatabase, | 113 | db: &dyn HirDatabase, |
114 | variant_def: VariantId, | 114 | variant_def: VariantId, |
115 | missed_fields: Vec<LocalStructFieldId>, | 115 | missed_fields: Vec<LocalFieldId>, |
116 | ) { | 116 | ) { |
117 | // XXX: only look at source_map if we do have missing fields | 117 | // XXX: only look at source_map if we do have missing fields |
118 | let (_, source_map) = db.body_with_source_map(self.func.into()); | 118 | let (_, source_map) = db.body_with_source_map(self.func.into()); |
@@ -256,7 +256,7 @@ pub fn record_literal_missing_fields( | |||
256 | infer: &InferenceResult, | 256 | infer: &InferenceResult, |
257 | id: ExprId, | 257 | id: ExprId, |
258 | expr: &Expr, | 258 | expr: &Expr, |
259 | ) -> Option<(VariantId, Vec<LocalStructFieldId>, /*exhaustive*/ bool)> { | 259 | ) -> Option<(VariantId, Vec<LocalFieldId>, /*exhaustive*/ bool)> { |
260 | let (fields, exhausitve) = match expr { | 260 | let (fields, exhausitve) = match expr { |
261 | Expr::RecordLit { path: _, fields, spread } => (fields, spread.is_none()), | 261 | Expr::RecordLit { path: _, fields, spread } => (fields, spread.is_none()), |
262 | _ => return None, | 262 | _ => return None, |
@@ -270,7 +270,7 @@ pub fn record_literal_missing_fields( | |||
270 | let variant_data = variant_data(db.upcast(), variant_def); | 270 | let variant_data = variant_data(db.upcast(), variant_def); |
271 | 271 | ||
272 | let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); | 272 | let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); |
273 | let missed_fields: Vec<LocalStructFieldId> = variant_data | 273 | let missed_fields: Vec<LocalFieldId> = variant_data |
274 | .fields() | 274 | .fields() |
275 | .iter() | 275 | .iter() |
276 | .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) | 276 | .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) |
@@ -286,7 +286,7 @@ pub fn record_pattern_missing_fields( | |||
286 | infer: &InferenceResult, | 286 | infer: &InferenceResult, |
287 | id: PatId, | 287 | id: PatId, |
288 | pat: &Pat, | 288 | pat: &Pat, |
289 | ) -> Option<(VariantId, Vec<LocalStructFieldId>, /*exhaustive*/ bool)> { | 289 | ) -> Option<(VariantId, Vec<LocalFieldId>, /*exhaustive*/ bool)> { |
290 | let (fields, exhaustive) = match pat { | 290 | let (fields, exhaustive) = match pat { |
291 | Pat::Record { path: _, args, ellipsis } => (args, !ellipsis), | 291 | Pat::Record { path: _, args, ellipsis } => (args, !ellipsis), |
292 | _ => return None, | 292 | _ => return None, |
@@ -300,7 +300,7 @@ pub fn record_pattern_missing_fields( | |||
300 | let variant_data = variant_data(db.upcast(), variant_def); | 300 | let variant_data = variant_data(db.upcast(), variant_def); |
301 | 301 | ||
302 | let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); | 302 | let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); |
303 | let missed_fields: Vec<LocalStructFieldId> = variant_data | 303 | let missed_fields: Vec<LocalFieldId> = variant_data |
304 | .fields() | 304 | .fields() |
305 | .iter() | 305 | .iter() |
306 | .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) | 306 | .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) |
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index dfb6a435f..6a53be621 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -28,7 +28,7 @@ use hir_def::{ | |||
28 | path::{path, Path}, | 28 | path::{path, Path}, |
29 | resolver::{HasResolver, Resolver, TypeNs}, | 29 | resolver::{HasResolver, Resolver, TypeNs}, |
30 | type_ref::{Mutability, TypeRef}, | 30 | type_ref::{Mutability, TypeRef}, |
31 | AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TraitId, TypeAliasId, VariantId, | 31 | AdtId, AssocItemId, DefWithBodyId, FieldId, FunctionId, TraitId, TypeAliasId, VariantId, |
32 | }; | 32 | }; |
33 | use hir_expand::{diagnostics::DiagnosticSink, name::name}; | 33 | use hir_expand::{diagnostics::DiagnosticSink, name::name}; |
34 | use ra_arena::map::ArenaMap; | 34 | use ra_arena::map::ArenaMap; |
@@ -124,10 +124,10 @@ pub struct InferenceResult { | |||
124 | /// For each method call expr, records the function it resolves to. | 124 | /// For each method call expr, records the function it resolves to. |
125 | method_resolutions: FxHashMap<ExprId, FunctionId>, | 125 | method_resolutions: FxHashMap<ExprId, FunctionId>, |
126 | /// For each field access expr, records the field it resolves to. | 126 | /// For each field access expr, records the field it resolves to. |
127 | field_resolutions: FxHashMap<ExprId, StructFieldId>, | 127 | field_resolutions: FxHashMap<ExprId, FieldId>, |
128 | /// For each field in record literal, records the field it resolves to. | 128 | /// For each field in record literal, records the field it resolves to. |
129 | record_field_resolutions: FxHashMap<ExprId, StructFieldId>, | 129 | record_field_resolutions: FxHashMap<ExprId, FieldId>, |
130 | record_field_pat_resolutions: FxHashMap<PatId, StructFieldId>, | 130 | record_field_pat_resolutions: FxHashMap<PatId, FieldId>, |
131 | /// For each struct literal, records the variant it resolves to. | 131 | /// For each struct literal, records the variant it resolves to. |
132 | variant_resolutions: FxHashMap<ExprOrPatId, VariantId>, | 132 | variant_resolutions: FxHashMap<ExprOrPatId, VariantId>, |
133 | /// For each associated item record what it resolves to | 133 | /// For each associated item record what it resolves to |
@@ -142,13 +142,13 @@ impl InferenceResult { | |||
142 | pub fn method_resolution(&self, expr: ExprId) -> Option<FunctionId> { | 142 | pub fn method_resolution(&self, expr: ExprId) -> Option<FunctionId> { |
143 | self.method_resolutions.get(&expr).copied() | 143 | self.method_resolutions.get(&expr).copied() |
144 | } | 144 | } |
145 | pub fn field_resolution(&self, expr: ExprId) -> Option<StructFieldId> { | 145 | pub fn field_resolution(&self, expr: ExprId) -> Option<FieldId> { |
146 | self.field_resolutions.get(&expr).copied() | 146 | self.field_resolutions.get(&expr).copied() |
147 | } | 147 | } |
148 | pub fn record_field_resolution(&self, expr: ExprId) -> Option<StructFieldId> { | 148 | pub fn record_field_resolution(&self, expr: ExprId) -> Option<FieldId> { |
149 | self.record_field_resolutions.get(&expr).copied() | 149 | self.record_field_resolutions.get(&expr).copied() |
150 | } | 150 | } |
151 | pub fn record_field_pat_resolution(&self, pat: PatId) -> Option<StructFieldId> { | 151 | pub fn record_field_pat_resolution(&self, pat: PatId) -> Option<FieldId> { |
152 | self.record_field_pat_resolutions.get(&pat).copied() | 152 | self.record_field_pat_resolutions.get(&pat).copied() |
153 | } | 153 | } |
154 | pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> { | 154 | pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> { |
@@ -249,7 +249,7 @@ impl<'a> InferenceContext<'a> { | |||
249 | self.result.method_resolutions.insert(expr, func); | 249 | self.result.method_resolutions.insert(expr, func); |
250 | } | 250 | } |
251 | 251 | ||
252 | fn write_field_resolution(&mut self, expr: ExprId, field: StructFieldId) { | 252 | fn write_field_resolution(&mut self, expr: ExprId, field: FieldId) { |
253 | self.result.field_resolutions.insert(expr, field); | 253 | self.result.field_resolutions.insert(expr, field); |
254 | } | 254 | } |
255 | 255 | ||
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 1fdb235a0..83f946eee 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -8,7 +8,7 @@ use hir_def::{ | |||
8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, | 8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, |
9 | path::{GenericArg, GenericArgs}, | 9 | path::{GenericArg, GenericArgs}, |
10 | resolver::resolver_for_expr, | 10 | resolver::resolver_for_expr, |
11 | AdtId, AssocContainerId, Lookup, StructFieldId, | 11 | AdtId, AssocContainerId, FieldId, Lookup, |
12 | }; | 12 | }; |
13 | use hir_expand::name::Name; | 13 | use hir_expand::name::Name; |
14 | use ra_syntax::ast::RangeOp; | 14 | use ra_syntax::ast::RangeOp; |
@@ -216,9 +216,7 @@ impl<'a> InferenceContext<'a> { | |||
216 | for (field_idx, field) in fields.iter().enumerate() { | 216 | for (field_idx, field) in fields.iter().enumerate() { |
217 | let field_def = | 217 | let field_def = |
218 | variant_data.as_ref().and_then(|it| match it.field(&field.name) { | 218 | variant_data.as_ref().and_then(|it| match it.field(&field.name) { |
219 | Some(local_id) => { | 219 | Some(local_id) => Some(FieldId { parent: def_id.unwrap(), local_id }), |
220 | Some(StructFieldId { parent: def_id.unwrap(), local_id }) | ||
221 | } | ||
222 | None => { | 220 | None => { |
223 | self.push_diagnostic(InferenceDiagnostic::NoSuchField { | 221 | self.push_diagnostic(InferenceDiagnostic::NoSuchField { |
224 | expr: tgt_expr, | 222 | expr: tgt_expr, |
@@ -257,7 +255,7 @@ impl<'a> InferenceContext<'a> { | |||
257 | .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), | 255 | .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), |
258 | TypeCtor::Adt(AdtId::StructId(s)) => { | 256 | TypeCtor::Adt(AdtId::StructId(s)) => { |
259 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { | 257 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { |
260 | let field = StructFieldId { parent: s.into(), local_id }; | 258 | let field = FieldId { parent: s.into(), local_id }; |
261 | self.write_field_resolution(tgt_expr, field); | 259 | self.write_field_resolution(tgt_expr, field); |
262 | self.db.field_types(s.into())[field.local_id] | 260 | self.db.field_types(s.into())[field.local_id] |
263 | .clone() | 261 | .clone() |
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 7c2ad4384..54ec870df 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs | |||
@@ -7,7 +7,7 @@ use hir_def::{ | |||
7 | expr::{BindingAnnotation, Pat, PatId, RecordFieldPat}, | 7 | expr::{BindingAnnotation, Pat, PatId, RecordFieldPat}, |
8 | path::Path, | 8 | path::Path, |
9 | type_ref::Mutability, | 9 | type_ref::Mutability, |
10 | StructFieldId, | 10 | FieldId, |
11 | }; | 11 | }; |
12 | use hir_expand::name::Name; | 12 | use hir_expand::name::Name; |
13 | use test_utils::tested_by; | 13 | use test_utils::tested_by; |
@@ -69,7 +69,7 @@ impl<'a> InferenceContext<'a> { | |||
69 | for subpat in subpats { | 69 | for subpat in subpats { |
70 | let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); | 70 | let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); |
71 | if let Some(local_id) = matching_field { | 71 | if let Some(local_id) = matching_field { |
72 | let field_def = StructFieldId { parent: def.unwrap(), local_id }; | 72 | let field_def = FieldId { parent: def.unwrap(), local_id }; |
73 | self.result.record_field_pat_resolutions.insert(subpat.pat, field_def); | 73 | self.result.record_field_pat_resolutions.insert(subpat.pat, field_def); |
74 | } | 74 | } |
75 | 75 | ||
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index c2812e178..b57214296 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -18,8 +18,8 @@ use hir_def::{ | |||
18 | resolver::{HasResolver, Resolver, TypeNs}, | 18 | resolver::{HasResolver, Resolver, TypeNs}, |
19 | type_ref::{TypeBound, TypeRef}, | 19 | type_ref::{TypeBound, TypeRef}, |
20 | AdtId, AssocContainerId, ConstId, EnumId, EnumVariantId, FunctionId, GenericDefId, HasModule, | 20 | AdtId, AssocContainerId, ConstId, EnumId, EnumVariantId, FunctionId, GenericDefId, HasModule, |
21 | ImplId, LocalStructFieldId, Lookup, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, | 21 | ImplId, LocalFieldId, Lookup, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, |
22 | UnionId, VariantId, | 22 | VariantId, |
23 | }; | 23 | }; |
24 | use ra_arena::map::ArenaMap; | 24 | use ra_arena::map::ArenaMap; |
25 | use ra_db::CrateId; | 25 | use ra_db::CrateId; |
@@ -682,7 +682,7 @@ pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig { | |||
682 | pub(crate) fn field_types_query( | 682 | pub(crate) fn field_types_query( |
683 | db: &dyn HirDatabase, | 683 | db: &dyn HirDatabase, |
684 | variant_id: VariantId, | 684 | variant_id: VariantId, |
685 | ) -> Arc<ArenaMap<LocalStructFieldId, Binders<Ty>>> { | 685 | ) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>> { |
686 | let var_data = variant_data(db.upcast(), variant_id); | 686 | let var_data = variant_data(db.upcast(), variant_id); |
687 | let (resolver, def): (_, GenericDefId) = match variant_id { | 687 | let (resolver, def): (_, GenericDefId) = match variant_id { |
688 | VariantId::StructId(it) => (it.resolver(db.upcast()), it.into()), | 688 | VariantId::StructId(it) => (it.resolver(db.upcast()), it.into()), |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 846005baa..b6a96bb5c 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -117,7 +117,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { | |||
117 | let macro_prefix = if node.file_id != file_id.into() { "!" } else { "" }; | 117 | let macro_prefix = if node.file_id != file_id.into() { "!" } else { "" }; |
118 | format_to!( | 118 | format_to!( |
119 | buf, | 119 | buf, |
120 | "{}{} '{}': {}\n", | 120 | "{}{:?} '{}': {}\n", |
121 | macro_prefix, | 121 | macro_prefix, |
122 | range, | 122 | range, |
123 | ellipsize(text, 15), | 123 | ellipsize(text, 15), |
@@ -134,7 +134,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { | |||
134 | let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; | 134 | let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; |
135 | format_to!( | 135 | format_to!( |
136 | buf, | 136 | buf, |
137 | "{}{}: expected {}, got {}\n", | 137 | "{}{:?}: expected {}, got {}\n", |
138 | macro_prefix, | 138 | macro_prefix, |
139 | range, | 139 | range, |
140 | mismatch.expected.display(&db), | 140 | mismatch.expected.display(&db), |
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs index b2c971f02..e6fb3e123 100644 --- a/crates/ra_hir_ty/src/tests/coercion.rs +++ b/crates/ra_hir_ty/src/tests/coercion.rs | |||
@@ -29,10 +29,10 @@ fn test() { | |||
29 | } | 29 | } |
30 | "#), | 30 | "#), |
31 | @r###" | 31 | @r###" |
32 | [11; 41) '{ ...4 }; }': () | 32 | 11..41 '{ ...4 }; }': () |
33 | [21; 22) 'a': i32 | 33 | 21..22 'a': i32 |
34 | [30; 38) '{ 1i64 }': i64 | 34 | 30..38 '{ 1i64 }': i64 |
35 | [32; 36) '1i64': i64 | 35 | 32..36 '1i64': i64 |
36 | "###); | 36 | "###); |
37 | } | 37 | } |
38 | 38 | ||
@@ -63,50 +63,50 @@ fn test2() { | |||
63 | } | 63 | } |
64 | "#), | 64 | "#), |
65 | @r###" | 65 | @r###" |
66 | [31; 32) '_': &[T] | 66 | 31..32 '_': &[T] |
67 | [45; 56) '{ loop {} }': T | 67 | 45..56 '{ loop {} }': T |
68 | [47; 54) 'loop {}': ! | 68 | 47..54 'loop {}': ! |
69 | [52; 54) '{}': () | 69 | 52..54 '{}': () |
70 | [65; 66) '_': S<&[T]> | 70 | 65..66 '_': S<&[T]> |
71 | [82; 93) '{ loop {} }': T | 71 | 82..93 '{ loop {} }': T |
72 | [84; 91) 'loop {}': ! | 72 | 84..91 'loop {}': ! |
73 | [89; 91) '{}': () | 73 | 89..91 '{}': () |
74 | [122; 133) '{ loop {} }': *mut [T; _] | 74 | 122..133 '{ loop {} }': *mut [T; _] |
75 | [124; 131) 'loop {}': ! | 75 | 124..131 'loop {}': ! |
76 | [129; 131) '{}': () | 76 | 129..131 '{}': () |
77 | [160; 173) '{ gen() }': *mut [U] | 77 | 160..173 '{ gen() }': *mut [U] |
78 | [166; 169) 'gen': fn gen<U>() -> *mut [U; _] | 78 | 166..169 'gen': fn gen<U>() -> *mut [U; _] |
79 | [166; 171) 'gen()': *mut [U; _] | 79 | 166..171 'gen()': *mut [U; _] |
80 | [186; 420) '{ ...rr); }': () | 80 | 186..420 '{ ...rr); }': () |
81 | [196; 199) 'arr': &[u8; _] | 81 | 196..199 'arr': &[u8; _] |
82 | [212; 216) '&[1]': &[u8; _] | 82 | 212..216 '&[1]': &[u8; _] |
83 | [213; 216) '[1]': [u8; _] | 83 | 213..216 '[1]': [u8; _] |
84 | [214; 215) '1': u8 | 84 | 214..215 '1': u8 |
85 | [227; 228) 'a': &[u8] | 85 | 227..228 'a': &[u8] |
86 | [237; 240) 'arr': &[u8; _] | 86 | 237..240 'arr': &[u8; _] |
87 | [250; 251) 'b': u8 | 87 | 250..251 'b': u8 |
88 | [254; 255) 'f': fn f<u8>(&[u8]) -> u8 | 88 | 254..255 'f': fn f<u8>(&[u8]) -> u8 |
89 | [254; 260) 'f(arr)': u8 | 89 | 254..260 'f(arr)': u8 |
90 | [256; 259) 'arr': &[u8; _] | 90 | 256..259 'arr': &[u8; _] |
91 | [270; 271) 'c': &[u8] | 91 | 270..271 'c': &[u8] |
92 | [280; 287) '{ arr }': &[u8] | 92 | 280..287 '{ arr }': &[u8] |
93 | [282; 285) 'arr': &[u8; _] | 93 | 282..285 'arr': &[u8; _] |
94 | [297; 298) 'd': u8 | 94 | 297..298 'd': u8 |
95 | [301; 302) 'g': fn g<u8>(S<&[u8]>) -> u8 | 95 | 301..302 'g': fn g<u8>(S<&[u8]>) -> u8 |
96 | [301; 316) 'g(S { a: arr })': u8 | 96 | 301..316 'g(S { a: arr })': u8 |
97 | [303; 315) 'S { a: arr }': S<&[u8]> | 97 | 303..315 'S { a: arr }': S<&[u8]> |
98 | [310; 313) 'arr': &[u8; _] | 98 | 310..313 'arr': &[u8; _] |
99 | [326; 327) 'e': [&[u8]; _] | 99 | 326..327 'e': [&[u8]; _] |
100 | [341; 346) '[arr]': [&[u8]; _] | 100 | 341..346 '[arr]': [&[u8]; _] |
101 | [342; 345) 'arr': &[u8; _] | 101 | 342..345 'arr': &[u8; _] |
102 | [356; 357) 'f': [&[u8]; _] | 102 | 356..357 'f': [&[u8]; _] |
103 | [371; 379) '[arr; 2]': [&[u8]; _] | 103 | 371..379 '[arr; 2]': [&[u8]; _] |
104 | [372; 375) 'arr': &[u8; _] | 104 | 372..375 'arr': &[u8; _] |
105 | [377; 378) '2': usize | 105 | 377..378 '2': usize |
106 | [389; 390) 'g': (&[u8], &[u8]) | 106 | 389..390 'g': (&[u8], &[u8]) |
107 | [407; 417) '(arr, arr)': (&[u8], &[u8]) | 107 | 407..417 '(arr, arr)': (&[u8], &[u8]) |
108 | [408; 411) 'arr': &[u8; _] | 108 | 408..411 'arr': &[u8; _] |
109 | [413; 416) 'arr': &[u8; _] | 109 | 413..416 'arr': &[u8; _] |
110 | "### | 110 | "### |
111 | ); | 111 | ); |
112 | } | 112 | } |
@@ -120,11 +120,11 @@ fn test() { | |||
120 | } | 120 | } |
121 | "#), | 121 | "#), |
122 | @r###" | 122 | @r###" |
123 | [11; 40) '{ ...[1]; }': () | 123 | 11..40 '{ ...[1]; }': () |
124 | [21; 22) 'x': &[i32] | 124 | 21..22 'x': &[i32] |
125 | [33; 37) '&[1]': &[i32; _] | 125 | 33..37 '&[1]': &[i32; _] |
126 | [34; 37) '[1]': [i32; _] | 126 | 34..37 '[1]': [i32; _] |
127 | [35; 36) '1': i32 | 127 | 35..36 '1': i32 |
128 | "###); | 128 | "###); |
129 | } | 129 | } |
130 | 130 | ||
@@ -150,31 +150,31 @@ fn test(a: A<[u8; 2]>, b: B<[u8; 2]>, c: C<[u8; 2]>) { | |||
150 | } | 150 | } |
151 | "#), | 151 | "#), |
152 | @r###" | 152 | @r###" |
153 | [258; 259) 'x': A<[T]> | 153 | 258..259 'x': A<[T]> |
154 | [279; 284) '{ x }': A<[T]> | 154 | 279..284 '{ x }': A<[T]> |
155 | [281; 282) 'x': A<[T]> | 155 | 281..282 'x': A<[T]> |
156 | [296; 297) 'x': B<[T]> | 156 | 296..297 'x': B<[T]> |
157 | [317; 322) '{ x }': B<[T]> | 157 | 317..322 '{ x }': B<[T]> |
158 | [319; 320) 'x': B<[T]> | 158 | 319..320 'x': B<[T]> |
159 | [334; 335) 'x': C<[T]> | 159 | 334..335 'x': C<[T]> |
160 | [355; 360) '{ x }': C<[T]> | 160 | 355..360 '{ x }': C<[T]> |
161 | [357; 358) 'x': C<[T]> | 161 | 357..358 'x': C<[T]> |
162 | [370; 371) 'a': A<[u8; _]> | 162 | 370..371 'a': A<[u8; _]> |
163 | [385; 386) 'b': B<[u8; _]> | 163 | 385..386 'b': B<[u8; _]> |
164 | [400; 401) 'c': C<[u8; _]> | 164 | 400..401 'c': C<[u8; _]> |
165 | [415; 481) '{ ...(c); }': () | 165 | 415..481 '{ ...(c); }': () |
166 | [425; 426) 'd': A<[{unknown}]> | 166 | 425..426 'd': A<[{unknown}]> |
167 | [429; 433) 'foo1': fn foo1<{unknown}>(A<[{unknown}]>) -> A<[{unknown}]> | 167 | 429..433 'foo1': fn foo1<{unknown}>(A<[{unknown}]>) -> A<[{unknown}]> |
168 | [429; 436) 'foo1(a)': A<[{unknown}]> | 168 | 429..436 'foo1(a)': A<[{unknown}]> |
169 | [434; 435) 'a': A<[u8; _]> | 169 | 434..435 'a': A<[u8; _]> |
170 | [446; 447) 'e': B<[u8]> | 170 | 446..447 'e': B<[u8]> |
171 | [450; 454) 'foo2': fn foo2<u8>(B<[u8]>) -> B<[u8]> | 171 | 450..454 'foo2': fn foo2<u8>(B<[u8]>) -> B<[u8]> |
172 | [450; 457) 'foo2(b)': B<[u8]> | 172 | 450..457 'foo2(b)': B<[u8]> |
173 | [455; 456) 'b': B<[u8; _]> | 173 | 455..456 'b': B<[u8; _]> |
174 | [467; 468) 'f': C<[u8]> | 174 | 467..468 'f': C<[u8]> |
175 | [471; 475) 'foo3': fn foo3<u8>(C<[u8]>) -> C<[u8]> | 175 | 471..475 'foo3': fn foo3<u8>(C<[u8]>) -> C<[u8]> |
176 | [471; 478) 'foo3(c)': C<[u8]> | 176 | 471..478 'foo3(c)': C<[u8]> |
177 | [476; 477) 'c': C<[u8; _]> | 177 | 476..477 'c': C<[u8; _]> |
178 | "### | 178 | "### |
179 | ); | 179 | ); |
180 | } | 180 | } |
@@ -193,24 +193,24 @@ fn test() { | |||
193 | } | 193 | } |
194 | "#), | 194 | "#), |
195 | @r###" | 195 | @r###" |
196 | [11; 12) 'x': &[T] | 196 | 11..12 'x': &[T] |
197 | [28; 39) '{ loop {} }': &[T] | 197 | 28..39 '{ loop {} }': &[T] |
198 | [30; 37) 'loop {}': ! | 198 | 30..37 'loop {}': ! |
199 | [35; 37) '{}': () | 199 | 35..37 '{}': () |
200 | [50; 126) '{ ... }; }': () | 200 | 50..126 '{ ... }; }': () |
201 | [60; 61) 'x': &[i32] | 201 | 60..61 'x': &[i32] |
202 | [64; 123) 'if tru... }': &[i32] | 202 | 64..123 'if tru... }': &[i32] |
203 | [67; 71) 'true': bool | 203 | 67..71 'true': bool |
204 | [72; 97) '{ ... }': &[i32] | 204 | 72..97 '{ ... }': &[i32] |
205 | [82; 85) 'foo': fn foo<i32>(&[i32]) -> &[i32] | 205 | 82..85 'foo': fn foo<i32>(&[i32]) -> &[i32] |
206 | [82; 91) 'foo(&[1])': &[i32] | 206 | 82..91 'foo(&[1])': &[i32] |
207 | [86; 90) '&[1]': &[i32; _] | 207 | 86..90 '&[1]': &[i32; _] |
208 | [87; 90) '[1]': [i32; _] | 208 | 87..90 '[1]': [i32; _] |
209 | [88; 89) '1': i32 | 209 | 88..89 '1': i32 |
210 | [103; 123) '{ ... }': &[i32; _] | 210 | 103..123 '{ ... }': &[i32; _] |
211 | [113; 117) '&[1]': &[i32; _] | 211 | 113..117 '&[1]': &[i32; _] |
212 | [114; 117) '[1]': [i32; _] | 212 | 114..117 '[1]': [i32; _] |
213 | [115; 116) '1': i32 | 213 | 115..116 '1': i32 |
214 | "### | 214 | "### |
215 | ); | 215 | ); |
216 | } | 216 | } |
@@ -229,24 +229,24 @@ fn test() { | |||
229 | } | 229 | } |
230 | "#), | 230 | "#), |
231 | @r###" | 231 | @r###" |
232 | [11; 12) 'x': &[T] | 232 | 11..12 'x': &[T] |
233 | [28; 39) '{ loop {} }': &[T] | 233 | 28..39 '{ loop {} }': &[T] |
234 | [30; 37) 'loop {}': ! | 234 | 30..37 'loop {}': ! |
235 | [35; 37) '{}': () | 235 | 35..37 '{}': () |
236 | [50; 126) '{ ... }; }': () | 236 | 50..126 '{ ... }; }': () |
237 | [60; 61) 'x': &[i32] | 237 | 60..61 'x': &[i32] |
238 | [64; 123) 'if tru... }': &[i32] | 238 | 64..123 'if tru... }': &[i32] |
239 | [67; 71) 'true': bool | 239 | 67..71 'true': bool |
240 | [72; 92) '{ ... }': &[i32; _] | 240 | 72..92 '{ ... }': &[i32; _] |
241 | [82; 86) '&[1]': &[i32; _] | 241 | 82..86 '&[1]': &[i32; _] |
242 | [83; 86) '[1]': [i32; _] | 242 | 83..86 '[1]': [i32; _] |
243 | [84; 85) '1': i32 | 243 | 84..85 '1': i32 |
244 | [98; 123) '{ ... }': &[i32] | 244 | 98..123 '{ ... }': &[i32] |
245 | [108; 111) 'foo': fn foo<i32>(&[i32]) -> &[i32] | 245 | 108..111 'foo': fn foo<i32>(&[i32]) -> &[i32] |
246 | [108; 117) 'foo(&[1])': &[i32] | 246 | 108..117 'foo(&[1])': &[i32] |
247 | [112; 116) '&[1]': &[i32; _] | 247 | 112..116 '&[1]': &[i32; _] |
248 | [113; 116) '[1]': [i32; _] | 248 | 113..116 '[1]': [i32; _] |
249 | [114; 115) '1': i32 | 249 | 114..115 '1': i32 |
250 | "### | 250 | "### |
251 | ); | 251 | ); |
252 | } | 252 | } |
@@ -265,31 +265,31 @@ fn test(i: i32) { | |||
265 | } | 265 | } |
266 | "#), | 266 | "#), |
267 | @r###" | 267 | @r###" |
268 | [11; 12) 'x': &[T] | 268 | 11..12 'x': &[T] |
269 | [28; 39) '{ loop {} }': &[T] | 269 | 28..39 '{ loop {} }': &[T] |
270 | [30; 37) 'loop {}': ! | 270 | 30..37 'loop {}': ! |
271 | [35; 37) '{}': () | 271 | 35..37 '{}': () |
272 | [48; 49) 'i': i32 | 272 | 48..49 'i': i32 |
273 | [56; 150) '{ ... }; }': () | 273 | 56..150 '{ ... }; }': () |
274 | [66; 67) 'x': &[i32] | 274 | 66..67 'x': &[i32] |
275 | [70; 147) 'match ... }': &[i32] | 275 | 70..147 'match ... }': &[i32] |
276 | [76; 77) 'i': i32 | 276 | 76..77 'i': i32 |
277 | [88; 89) '2': i32 | 277 | 88..89 '2': i32 |
278 | [88; 89) '2': i32 | 278 | 88..89 '2': i32 |
279 | [93; 96) 'foo': fn foo<i32>(&[i32]) -> &[i32] | 279 | 93..96 'foo': fn foo<i32>(&[i32]) -> &[i32] |
280 | [93; 102) 'foo(&[2])': &[i32] | 280 | 93..102 'foo(&[2])': &[i32] |
281 | [97; 101) '&[2]': &[i32; _] | 281 | 97..101 '&[2]': &[i32; _] |
282 | [98; 101) '[2]': [i32; _] | 282 | 98..101 '[2]': [i32; _] |
283 | [99; 100) '2': i32 | 283 | 99..100 '2': i32 |
284 | [112; 113) '1': i32 | 284 | 112..113 '1': i32 |
285 | [112; 113) '1': i32 | 285 | 112..113 '1': i32 |
286 | [117; 121) '&[1]': &[i32; _] | 286 | 117..121 '&[1]': &[i32; _] |
287 | [118; 121) '[1]': [i32; _] | 287 | 118..121 '[1]': [i32; _] |
288 | [119; 120) '1': i32 | 288 | 119..120 '1': i32 |
289 | [131; 132) '_': i32 | 289 | 131..132 '_': i32 |
290 | [136; 140) '&[3]': &[i32; _] | 290 | 136..140 '&[3]': &[i32; _] |
291 | [137; 140) '[3]': [i32; _] | 291 | 137..140 '[3]': [i32; _] |
292 | [138; 139) '3': i32 | 292 | 138..139 '3': i32 |
293 | "### | 293 | "### |
294 | ); | 294 | ); |
295 | } | 295 | } |
@@ -308,31 +308,31 @@ fn test(i: i32) { | |||
308 | } | 308 | } |
309 | "#), | 309 | "#), |
310 | @r###" | 310 | @r###" |
311 | [11; 12) 'x': &[T] | 311 | 11..12 'x': &[T] |
312 | [28; 39) '{ loop {} }': &[T] | 312 | 28..39 '{ loop {} }': &[T] |
313 | [30; 37) 'loop {}': ! | 313 | 30..37 'loop {}': ! |
314 | [35; 37) '{}': () | 314 | 35..37 '{}': () |
315 | [48; 49) 'i': i32 | 315 | 48..49 'i': i32 |
316 | [56; 150) '{ ... }; }': () | 316 | 56..150 '{ ... }; }': () |
317 | [66; 67) 'x': &[i32] | 317 | 66..67 'x': &[i32] |
318 | [70; 147) 'match ... }': &[i32] | 318 | 70..147 'match ... }': &[i32] |
319 | [76; 77) 'i': i32 | 319 | 76..77 'i': i32 |
320 | [88; 89) '1': i32 | 320 | 88..89 '1': i32 |
321 | [88; 89) '1': i32 | 321 | 88..89 '1': i32 |
322 | [93; 97) '&[1]': &[i32; _] | 322 | 93..97 '&[1]': &[i32; _] |
323 | [94; 97) '[1]': [i32; _] | 323 | 94..97 '[1]': [i32; _] |
324 | [95; 96) '1': i32 | 324 | 95..96 '1': i32 |
325 | [107; 108) '2': i32 | 325 | 107..108 '2': i32 |
326 | [107; 108) '2': i32 | 326 | 107..108 '2': i32 |
327 | [112; 115) 'foo': fn foo<i32>(&[i32]) -> &[i32] | 327 | 112..115 'foo': fn foo<i32>(&[i32]) -> &[i32] |
328 | [112; 121) 'foo(&[2])': &[i32] | 328 | 112..121 'foo(&[2])': &[i32] |
329 | [116; 120) '&[2]': &[i32; _] | 329 | 116..120 '&[2]': &[i32; _] |
330 | [117; 120) '[2]': [i32; _] | 330 | 117..120 '[2]': [i32; _] |
331 | [118; 119) '2': i32 | 331 | 118..119 '2': i32 |
332 | [131; 132) '_': i32 | 332 | 131..132 '_': i32 |
333 | [136; 140) '&[3]': &[i32; _] | 333 | 136..140 '&[3]': &[i32; _] |
334 | [137; 140) '[3]': [i32; _] | 334 | 137..140 '[3]': [i32; _] |
335 | [138; 139) '3': i32 | 335 | 138..139 '3': i32 |
336 | "### | 336 | "### |
337 | ); | 337 | ); |
338 | } | 338 | } |
@@ -353,24 +353,24 @@ fn test() { | |||
353 | } | 353 | } |
354 | "#), | 354 | "#), |
355 | @r###" | 355 | @r###" |
356 | [11; 145) '{ ... }; }': () | 356 | 11..145 '{ ... }; }': () |
357 | [21; 22) 't': &mut i32 | 357 | 21..22 't': &mut i32 |
358 | [25; 31) '&mut 1': &mut i32 | 358 | 25..31 '&mut 1': &mut i32 |
359 | [30; 31) '1': i32 | 359 | 30..31 '1': i32 |
360 | [41; 42) 'x': *const i32 | 360 | 41..42 'x': *const i32 |
361 | [45; 142) 'match ... }': *const i32 | 361 | 45..142 'match ... }': *const i32 |
362 | [51; 52) '1': i32 | 362 | 51..52 '1': i32 |
363 | [63; 64) '1': i32 | 363 | 63..64 '1': i32 |
364 | [63; 64) '1': i32 | 364 | 63..64 '1': i32 |
365 | [68; 69) 't': &mut i32 | 365 | 68..69 't': &mut i32 |
366 | [68; 81) 't as *mut i32': *mut i32 | 366 | 68..81 't as *mut i32': *mut i32 |
367 | [91; 92) '2': i32 | 367 | 91..92 '2': i32 |
368 | [91; 92) '2': i32 | 368 | 91..92 '2': i32 |
369 | [96; 97) 't': &mut i32 | 369 | 96..97 't': &mut i32 |
370 | [96; 105) 't as &i32': &i32 | 370 | 96..105 't as &i32': &i32 |
371 | [115; 116) '_': i32 | 371 | 115..116 '_': i32 |
372 | [120; 121) 't': &mut i32 | 372 | 120..121 't': &mut i32 |
373 | [120; 135) 't as *const i32': *const i32 | 373 | 120..135 't as *const i32': *const i32 |
374 | "### | 374 | "### |
375 | ); | 375 | ); |
376 | } | 376 | } |
@@ -384,9 +384,9 @@ fn foo() -> u32 { | |||
384 | } | 384 | } |
385 | "#, true), | 385 | "#, true), |
386 | @r###" | 386 | @r###" |
387 | [17; 40) '{ ...own; }': ! | 387 | 17..40 '{ ...own; }': ! |
388 | [23; 37) 'return unknown': ! | 388 | 23..37 'return unknown': ! |
389 | [30; 37) 'unknown': u32 | 389 | 30..37 'unknown': u32 |
390 | "### | 390 | "### |
391 | ); | 391 | ); |
392 | } | 392 | } |
@@ -404,24 +404,24 @@ fn test() { | |||
404 | } | 404 | } |
405 | "#, true), | 405 | "#, true), |
406 | @r###" | 406 | @r###" |
407 | [30; 31) 'x': &Foo | 407 | 30..31 'x': &Foo |
408 | [39; 41) '{}': () | 408 | 39..41 '{}': () |
409 | [52; 133) '{ ...oo); }': () | 409 | 52..133 '{ ...oo); }': () |
410 | [58; 71) 'takes_ref_foo': fn takes_ref_foo(&Foo) | 410 | 58..71 'takes_ref_foo': fn takes_ref_foo(&Foo) |
411 | [58; 77) 'takes_...(&Foo)': () | 411 | 58..77 'takes_...(&Foo)': () |
412 | [72; 76) '&Foo': &Foo | 412 | 72..76 '&Foo': &Foo |
413 | [73; 76) 'Foo': Foo | 413 | 73..76 'Foo': Foo |
414 | [83; 96) 'takes_ref_foo': fn takes_ref_foo(&Foo) | 414 | 83..96 'takes_ref_foo': fn takes_ref_foo(&Foo) |
415 | [83; 103) 'takes_...&&Foo)': () | 415 | 83..103 'takes_...&&Foo)': () |
416 | [97; 102) '&&Foo': &&Foo | 416 | 97..102 '&&Foo': &&Foo |
417 | [98; 102) '&Foo': &Foo | 417 | 98..102 '&Foo': &Foo |
418 | [99; 102) 'Foo': Foo | 418 | 99..102 'Foo': Foo |
419 | [109; 122) 'takes_ref_foo': fn takes_ref_foo(&Foo) | 419 | 109..122 'takes_ref_foo': fn takes_ref_foo(&Foo) |
420 | [109; 130) 'takes_...&&Foo)': () | 420 | 109..130 'takes_...&&Foo)': () |
421 | [123; 129) '&&&Foo': &&&Foo | 421 | 123..129 '&&&Foo': &&&Foo |
422 | [124; 129) '&&Foo': &&Foo | 422 | 124..129 '&&Foo': &&Foo |
423 | [125; 129) '&Foo': &Foo | 423 | 125..129 '&Foo': &Foo |
424 | [126; 129) 'Foo': Foo | 424 | 126..129 'Foo': Foo |
425 | "### | 425 | "### |
426 | ); | 426 | ); |
427 | } | 427 | } |
@@ -439,26 +439,26 @@ fn test() { | |||
439 | } | 439 | } |
440 | "#, true), | 440 | "#, true), |
441 | @r###" | 441 | @r###" |
442 | [29; 30) 'x': &T | 442 | 29..30 'x': &T |
443 | [41; 47) '{ *x }': T | 443 | 41..47 '{ *x }': T |
444 | [43; 45) '*x': T | 444 | 43..45 '*x': T |
445 | [44; 45) 'x': &T | 445 | 44..45 'x': &T |
446 | [58; 127) '{ ...oo); }': () | 446 | 58..127 '{ ...oo); }': () |
447 | [64; 73) 'takes_ref': fn takes_ref<Foo>(&Foo) -> Foo | 447 | 64..73 'takes_ref': fn takes_ref<Foo>(&Foo) -> Foo |
448 | [64; 79) 'takes_ref(&Foo)': Foo | 448 | 64..79 'takes_ref(&Foo)': Foo |
449 | [74; 78) '&Foo': &Foo | 449 | 74..78 '&Foo': &Foo |
450 | [75; 78) 'Foo': Foo | 450 | 75..78 'Foo': Foo |
451 | [85; 94) 'takes_ref': fn takes_ref<&Foo>(&&Foo) -> &Foo | 451 | 85..94 'takes_ref': fn takes_ref<&Foo>(&&Foo) -> &Foo |
452 | [85; 101) 'takes_...&&Foo)': &Foo | 452 | 85..101 'takes_...&&Foo)': &Foo |
453 | [95; 100) '&&Foo': &&Foo | 453 | 95..100 '&&Foo': &&Foo |
454 | [96; 100) '&Foo': &Foo | 454 | 96..100 '&Foo': &Foo |
455 | [97; 100) 'Foo': Foo | 455 | 97..100 'Foo': Foo |
456 | [107; 116) 'takes_ref': fn takes_ref<&&Foo>(&&&Foo) -> &&Foo | 456 | 107..116 'takes_ref': fn takes_ref<&&Foo>(&&&Foo) -> &&Foo |
457 | [107; 124) 'takes_...&&Foo)': &&Foo | 457 | 107..124 'takes_...&&Foo)': &&Foo |
458 | [117; 123) '&&&Foo': &&&Foo | 458 | 117..123 '&&&Foo': &&&Foo |
459 | [118; 123) '&&Foo': &&Foo | 459 | 118..123 '&&Foo': &&Foo |
460 | [119; 123) '&Foo': &Foo | 460 | 119..123 '&Foo': &Foo |
461 | [120; 123) 'Foo': Foo | 461 | 120..123 'Foo': Foo |
462 | "### | 462 | "### |
463 | ); | 463 | ); |
464 | } | 464 | } |
@@ -478,18 +478,18 @@ fn test() { | |||
478 | } | 478 | } |
479 | "#, true), | 479 | "#, true), |
480 | @r###" | 480 | @r###" |
481 | [127; 128) 'x': &str | 481 | 127..128 'x': &str |
482 | [136; 138) '{}': () | 482 | 136..138 '{}': () |
483 | [169; 180) '{ loop {} }': String | 483 | 169..180 '{ loop {} }': String |
484 | [171; 178) 'loop {}': ! | 484 | 171..178 'loop {}': ! |
485 | [176; 178) '{}': () | 485 | 176..178 '{}': () |
486 | [191; 236) '{ ... }); }': () | 486 | 191..236 '{ ... }); }': () |
487 | [197; 210) 'takes_ref_str': fn takes_ref_str(&str) | 487 | 197..210 'takes_ref_str': fn takes_ref_str(&str) |
488 | [197; 233) 'takes_...g() })': () | 488 | 197..233 'takes_...g() })': () |
489 | [211; 232) '&{ ret...ng() }': &String | 489 | 211..232 '&{ ret...ng() }': &String |
490 | [212; 232) '{ retu...ng() }': String | 490 | 212..232 '{ retu...ng() }': String |
491 | [214; 228) 'returns_string': fn returns_string() -> String | 491 | 214..228 'returns_string': fn returns_string() -> String |
492 | [214; 230) 'return...ring()': String | 492 | 214..230 'return...ring()': String |
493 | "### | 493 | "### |
494 | ); | 494 | ); |
495 | } | 495 | } |
@@ -508,19 +508,19 @@ fn foo() { | |||
508 | } | 508 | } |
509 | "#, true), | 509 | "#, true), |
510 | @r###" | 510 | @r###" |
511 | [10; 106) '{ ... }; }': () | 511 | 10..106 '{ ... }; }': () |
512 | [20; 21) 'x': || -> &u32 | 512 | 20..21 'x': || -> &u32 |
513 | [24; 103) '|| { ... }': || -> &u32 | 513 | 24..103 '|| { ... }': || -> &u32 |
514 | [27; 103) '{ ... }': &u32 | 514 | 27..103 '{ ... }': &u32 |
515 | [37; 82) 'if tru... }': () | 515 | 37..82 'if tru... }': () |
516 | [40; 44) 'true': bool | 516 | 40..44 'true': bool |
517 | [45; 82) '{ ... }': ! | 517 | 45..82 '{ ... }': ! |
518 | [59; 71) 'return &1u32': ! | 518 | 59..71 'return &1u32': ! |
519 | [66; 71) '&1u32': &u32 | 519 | 66..71 '&1u32': &u32 |
520 | [67; 71) '1u32': u32 | 520 | 67..71 '1u32': u32 |
521 | [91; 97) '&&1u32': &&u32 | 521 | 91..97 '&&1u32': &&u32 |
522 | [92; 97) '&1u32': &u32 | 522 | 92..97 '&1u32': &u32 |
523 | [93; 97) '1u32': u32 | 523 | 93..97 '1u32': u32 |
524 | "### | 524 | "### |
525 | ); | 525 | ); |
526 | } | 526 | } |
@@ -535,12 +535,12 @@ fn test() { | |||
535 | } | 535 | } |
536 | "#, true), | 536 | "#, true), |
537 | @r###" | 537 | @r###" |
538 | [8; 9) 'x': u32 | 538 | 8..9 'x': u32 |
539 | [25; 30) '{ 1 }': isize | 539 | 25..30 '{ 1 }': isize |
540 | [27; 28) '1': isize | 540 | 27..28 '1': isize |
541 | [41; 79) '{ ...foo; }': () | 541 | 41..79 '{ ...foo; }': () |
542 | [51; 52) 'f': fn(u32) -> isize | 542 | 51..52 'f': fn(u32) -> isize |
543 | [73; 76) 'foo': fn foo(u32) -> isize | 543 | 73..76 'foo': fn foo(u32) -> isize |
544 | "### | 544 | "### |
545 | ); | 545 | ); |
546 | } | 546 | } |
@@ -554,12 +554,12 @@ fn test() { | |||
554 | } | 554 | } |
555 | "#, true), | 555 | "#, true), |
556 | @r###" | 556 | @r###" |
557 | [11; 55) '{ ...1 }; }': () | 557 | 11..55 '{ ...1 }; }': () |
558 | [21; 22) 'f': fn(u32) -> isize | 558 | 21..22 'f': fn(u32) -> isize |
559 | [43; 52) '|x| { 1 }': |u32| -> isize | 559 | 43..52 '|x| { 1 }': |u32| -> isize |
560 | [44; 45) 'x': u32 | 560 | 44..45 'x': u32 |
561 | [47; 52) '{ 1 }': isize | 561 | 47..52 '{ 1 }': isize |
562 | [49; 50) '1': isize | 562 | 49..50 '1': isize |
563 | "### | 563 | "### |
564 | ); | 564 | ); |
565 | } | 565 | } |
@@ -577,11 +577,11 @@ impl<TT> S<TT> { | |||
577 | } | 577 | } |
578 | "#, true), | 578 | "#, true), |
579 | @r###" | 579 | @r###" |
580 | [51; 55) 'self': &S<TT> | 580 | 51..55 'self': &S<TT> |
581 | [64; 87) '{ ... }': &TT | 581 | 64..87 '{ ... }': &TT |
582 | [74; 81) '&self.t': &TT | 582 | 74..81 '&self.t': &TT |
583 | [75; 79) 'self': &S<TT> | 583 | 75..79 'self': &S<TT> |
584 | [75; 81) 'self.t': TT | 584 | 75..81 'self.t': TT |
585 | "### | 585 | "### |
586 | ); | 586 | ); |
587 | } | 587 | } |
@@ -602,13 +602,13 @@ fn test() { | |||
602 | } | 602 | } |
603 | "#, true), | 603 | "#, true), |
604 | @r###" | 604 | @r###" |
605 | [162; 199) '{ ... 3]; }': () | 605 | 162..199 '{ ... 3]; }': () |
606 | [172; 173) 'f': &[usize] | 606 | 172..173 'f': &[usize] |
607 | [186; 196) '&[1, 2, 3]': &[usize; _] | 607 | 186..196 '&[1, 2, 3]': &[usize; _] |
608 | [187; 196) '[1, 2, 3]': [usize; _] | 608 | 187..196 '[1, 2, 3]': [usize; _] |
609 | [188; 189) '1': usize | 609 | 188..189 '1': usize |
610 | [191; 192) '2': usize | 610 | 191..192 '2': usize |
611 | [194; 195) '3': usize | 611 | 194..195 '3': usize |
612 | "### | 612 | "### |
613 | ); | 613 | ); |
614 | } | 614 | } |
@@ -642,19 +642,19 @@ fn test() { | |||
642 | } | 642 | } |
643 | "#, true), | 643 | "#, true), |
644 | @r###" | 644 | @r###" |
645 | [388; 573) '{ ...bj2; }': () | 645 | 388..573 '{ ...bj2; }': () |
646 | [398; 401) 'obj': &dyn Baz<i8, i16> | 646 | 398..401 'obj': &dyn Baz<i8, i16> |
647 | [423; 425) '&S': &S<i8, i16> | 647 | 423..425 '&S': &S<i8, i16> |
648 | [424; 425) 'S': S<i8, i16> | 648 | 424..425 'S': S<i8, i16> |
649 | [435; 438) 'obj': &dyn Bar<usize, i8, i16> | 649 | 435..438 'obj': &dyn Bar<usize, i8, i16> |
650 | [460; 463) 'obj': &dyn Baz<i8, i16> | 650 | 460..463 'obj': &dyn Baz<i8, i16> |
651 | [473; 476) 'obj': &dyn Foo<i8, usize> | 651 | 473..476 'obj': &dyn Foo<i8, usize> |
652 | [495; 498) 'obj': &dyn Bar<usize, i8, i16> | 652 | 495..498 'obj': &dyn Bar<usize, i8, i16> |
653 | [508; 512) 'obj2': &dyn Baz<i8, i16> | 653 | 508..512 'obj2': &dyn Baz<i8, i16> |
654 | [534; 536) '&S': &S<i8, i16> | 654 | 534..536 '&S': &S<i8, i16> |
655 | [535; 536) 'S': S<i8, i16> | 655 | 535..536 'S': S<i8, i16> |
656 | [546; 547) '_': &dyn Foo<i8, usize> | 656 | 546..547 '_': &dyn Foo<i8, usize> |
657 | [566; 570) 'obj2': &dyn Baz<i8, i16> | 657 | 566..570 'obj2': &dyn Baz<i8, i16> |
658 | "### | 658 | "### |
659 | ); | 659 | ); |
660 | } | 660 | } |
@@ -687,12 +687,12 @@ fn test() { | |||
687 | } | 687 | } |
688 | "#, true), | 688 | "#, true), |
689 | @r###" | 689 | @r###" |
690 | [292; 348) '{ ...obj; }': () | 690 | 292..348 '{ ...obj; }': () |
691 | [302; 305) 'obj': &dyn D | 691 | 302..305 'obj': &dyn D |
692 | [316; 318) '&S': &S | 692 | 316..318 '&S': &S |
693 | [317; 318) 'S': S | 693 | 317..318 'S': S |
694 | [328; 331) 'obj': &dyn A | 694 | 328..331 'obj': &dyn A |
695 | [342; 345) 'obj': &dyn D | 695 | 342..345 'obj': &dyn D |
696 | "### | 696 | "### |
697 | ); | 697 | ); |
698 | } | 698 | } |
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index f2a9b1c40..6b5267232 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -67,12 +67,12 @@ fn main() { | |||
67 | } | 67 | } |
68 | "#), | 68 | "#), |
69 | @r###" | 69 | @r###" |
70 | ![0; 17) '{Foo(v...,2,])}': Foo | 70 | !0..17 '{Foo(v...,2,])}': Foo |
71 | ![1; 4) 'Foo': Foo({unknown}) -> Foo | 71 | !1..4 'Foo': Foo({unknown}) -> Foo |
72 | ![1; 16) 'Foo(vec![1,2,])': Foo | 72 | !1..16 'Foo(vec![1,2,])': Foo |
73 | ![5; 15) 'vec![1,2,]': {unknown} | 73 | !5..15 'vec![1,2,]': {unknown} |
74 | [156; 182) '{ ...,2); }': () | 74 | 156..182 '{ ...,2); }': () |
75 | [166; 167) 'x': Foo | 75 | 166..167 'x': Foo |
76 | "### | 76 | "### |
77 | ); | 77 | ); |
78 | } | 78 | } |
@@ -100,14 +100,14 @@ fn main() { | |||
100 | } | 100 | } |
101 | "#), | 101 | "#), |
102 | @r###" | 102 | @r###" |
103 | ![0; 17) '{Foo(v...,2,])}': Foo | 103 | !0..17 '{Foo(v...,2,])}': Foo |
104 | ![1; 4) 'Foo': Foo({unknown}) -> Foo | 104 | !1..4 'Foo': Foo({unknown}) -> Foo |
105 | ![1; 16) 'Foo(vec![1,2,])': Foo | 105 | !1..16 'Foo(vec![1,2,])': Foo |
106 | ![5; 15) 'vec![1,2,]': {unknown} | 106 | !5..15 'vec![1,2,]': {unknown} |
107 | [195; 251) '{ ...,2); }': () | 107 | 195..251 '{ ...,2); }': () |
108 | [205; 206) 'x': Foo | 108 | 205..206 'x': Foo |
109 | [228; 229) 'y': {unknown} | 109 | 228..229 'y': {unknown} |
110 | [232; 248) 'crate:...!(1,2)': {unknown} | 110 | 232..248 'crate:...!(1,2)': {unknown} |
111 | "### | 111 | "### |
112 | ); | 112 | ); |
113 | } | 113 | } |
@@ -131,11 +131,11 @@ fn main() { | |||
131 | } | 131 | } |
132 | "#), | 132 | "#), |
133 | @r###" | 133 | @r###" |
134 | ![0; 5) '42i32': i32 | 134 | !0..5 '42i32': i32 |
135 | ![0; 5) '42i32': i32 | 135 | !0..5 '42i32': i32 |
136 | [111; 164) '{ ...!(); }': () | 136 | 111..164 '{ ...!(); }': () |
137 | [121; 122) 'x': i32 | 137 | 121..122 'x': i32 |
138 | [148; 149) 'y': i32 | 138 | 148..149 'y': i32 |
139 | "### | 139 | "### |
140 | ); | 140 | ); |
141 | } | 141 | } |
@@ -172,51 +172,51 @@ fn spam() { | |||
172 | } | 172 | } |
173 | "#), | 173 | "#), |
174 | @r###" | 174 | @r###" |
175 | ![0; 6) '1isize': isize | 175 | !0..6 '1isize': isize |
176 | ![0; 6) '1isize': isize | 176 | !0..6 '1isize': isize |
177 | ![0; 6) '1isize': isize | 177 | !0..6 '1isize': isize |
178 | ![0; 6) '1isize': isize | 178 | !0..6 '1isize': isize |
179 | ![0; 6) '1isize': isize | 179 | !0..6 '1isize': isize |
180 | ![0; 6) '1isize': isize | 180 | !0..6 '1isize': isize |
181 | ![0; 6) '1isize': isize | 181 | !0..6 '1isize': isize |
182 | ![0; 6) '1isize': isize | 182 | !0..6 '1isize': isize |
183 | ![0; 6) '1isize': isize | 183 | !0..6 '1isize': isize |
184 | ![0; 6) '1isize': isize | 184 | !0..6 '1isize': isize |
185 | ![0; 6) '1isize': isize | 185 | !0..6 '1isize': isize |
186 | ![0; 6) '1isize': isize | 186 | !0..6 '1isize': isize |
187 | ![0; 6) '1isize': isize | 187 | !0..6 '1isize': isize |
188 | ![0; 6) '1isize': isize | 188 | !0..6 '1isize': isize |
189 | ![0; 6) '1isize': isize | 189 | !0..6 '1isize': isize |
190 | ![0; 6) '1isize': isize | 190 | !0..6 '1isize': isize |
191 | ![0; 6) '1isize': isize | 191 | !0..6 '1isize': isize |
192 | ![0; 6) '1isize': isize | 192 | !0..6 '1isize': isize |
193 | ![0; 6) '1isize': isize | 193 | !0..6 '1isize': isize |
194 | ![0; 6) '1isize': isize | 194 | !0..6 '1isize': isize |
195 | ![0; 6) '1isize': isize | 195 | !0..6 '1isize': isize |
196 | ![0; 6) '1isize': isize | 196 | !0..6 '1isize': isize |
197 | ![0; 6) '1isize': isize | 197 | !0..6 '1isize': isize |
198 | ![0; 6) '1isize': isize | 198 | !0..6 '1isize': isize |
199 | ![0; 6) '1isize': isize | 199 | !0..6 '1isize': isize |
200 | [54; 457) '{ ...!(); }': ! | 200 | 54..457 '{ ...!(); }': ! |
201 | [88; 109) 'spam!(...am!())': {unknown} | 201 | 88..109 'spam!(...am!())': {unknown} |
202 | [115; 134) 'for _ ...!() {}': () | 202 | 115..134 'for _ ...!() {}': () |
203 | [119; 120) '_': {unknown} | 203 | 119..120 '_': {unknown} |
204 | [132; 134) '{}': () | 204 | 132..134 '{}': () |
205 | [139; 149) '|| spam!()': || -> isize | 205 | 139..149 '|| spam!()': || -> isize |
206 | [155; 171) 'while ...!() {}': () | 206 | 155..171 'while ...!() {}': () |
207 | [169; 171) '{}': () | 207 | 169..171 '{}': () |
208 | [176; 189) 'break spam!()': ! | 208 | 176..189 'break spam!()': ! |
209 | [195; 209) 'return spam!()': ! | 209 | 195..209 'return spam!()': ! |
210 | [215; 269) 'match ... }': isize | 210 | 215..269 'match ... }': isize |
211 | [239; 240) '_': isize | 211 | 239..240 '_': isize |
212 | [274; 290) 'spam!(...am!())': {unknown} | 212 | 274..290 'spam!(...am!())': {unknown} |
213 | [296; 318) 'Spam {...m!() }': {unknown} | 213 | 296..318 'Spam {...m!() }': {unknown} |
214 | [324; 340) 'spam!(...am!()]': {unknown} | 214 | 324..340 'spam!(...am!()]': {unknown} |
215 | [365; 381) 'spam!(... usize': usize | 215 | 365..381 'spam!(... usize': usize |
216 | [387; 395) '&spam!()': &isize | 216 | 387..395 '&spam!()': &isize |
217 | [401; 409) '-spam!()': isize | 217 | 401..409 '-spam!()': isize |
218 | [415; 431) 'spam!(...pam!()': {unknown} | 218 | 415..431 'spam!(...pam!()': {unknown} |
219 | [437; 454) 'spam!(...pam!()': isize | 219 | 437..454 'spam!(...pam!()': isize |
220 | "### | 220 | "### |
221 | ); | 221 | ); |
222 | } | 222 | } |
@@ -244,9 +244,9 @@ fn foo() { | |||
244 | } | 244 | } |
245 | "#), | 245 | "#), |
246 | @r###" | 246 | @r###" |
247 | ![0; 5) '42i32': i32 | 247 | !0..5 '42i32': i32 |
248 | [171; 206) '{ ...32); }': () | 248 | 171..206 '{ ...32); }': () |
249 | [181; 184) 'foo': i32 | 249 | 181..184 'foo': i32 |
250 | "### | 250 | "### |
251 | ); | 251 | ); |
252 | } | 252 | } |
@@ -357,12 +357,12 @@ fn main() { | |||
357 | } | 357 | } |
358 | "#), | 358 | "#), |
359 | @r###" | 359 | @r###" |
360 | [159; 164) '{ 0 }': u64 | 360 | 159..164 '{ 0 }': u64 |
361 | [161; 162) '0': u64 | 361 | 161..162 '0': u64 |
362 | [175; 197) '{ ...f(); }': () | 362 | 175..197 '{ ...f(); }': () |
363 | [185; 187) '_a': u64 | 363 | 185..187 '_a': u64 |
364 | [191; 192) 'f': fn f() -> u64 | 364 | 191..192 'f': fn f() -> u64 |
365 | [191; 194) 'f()': u64 | 365 | 191..194 'f()': u64 |
366 | "### | 366 | "### |
367 | ); | 367 | ); |
368 | } | 368 | } |
@@ -379,10 +379,10 @@ fn main() { | |||
379 | } | 379 | } |
380 | "#), | 380 | "#), |
381 | @r###" | 381 | @r###" |
382 | ![0; 6) '1usize': usize | 382 | !0..6 '1usize': usize |
383 | [11; 90) '{ ...!(); }': () | 383 | 11..90 '{ ...!(); }': () |
384 | [17; 66) 'macro_... }': {unknown} | 384 | 17..66 'macro_... }': {unknown} |
385 | [75; 77) '_a': usize | 385 | 75..77 '_a': usize |
386 | "### | 386 | "### |
387 | ); | 387 | ); |
388 | } | 388 | } |
@@ -399,9 +399,9 @@ fn main() { | |||
399 | } | 399 | } |
400 | "#), | 400 | "#), |
401 | @r###" | 401 | @r###" |
402 | ![0; 1) '0': i32 | 402 | !0..1 '0': i32 |
403 | [64; 88) '{ ...!(); }': () | 403 | 64..88 '{ ...!(); }': () |
404 | [74; 75) 'x': i32 | 404 | 74..75 'x': i32 |
405 | "### | 405 | "### |
406 | ); | 406 | ); |
407 | } | 407 | } |
@@ -418,9 +418,9 @@ fn main() { | |||
418 | } | 418 | } |
419 | "#), | 419 | "#), |
420 | @r###" | 420 | @r###" |
421 | ![0; 2) '""': &str | 421 | !0..2 '""': &str |
422 | [64; 88) '{ ...!(); }': () | 422 | 64..88 '{ ...!(); }': () |
423 | [74; 75) 'x': &str | 423 | 74..75 'x': &str |
424 | "### | 424 | "### |
425 | ); | 425 | ); |
426 | } | 426 | } |
@@ -437,9 +437,9 @@ fn main() { | |||
437 | } | 437 | } |
438 | "#), | 438 | "#), |
439 | @r###" | 439 | @r###" |
440 | ![0; 1) '0': i32 | 440 | !0..1 '0': i32 |
441 | [66; 92) '{ ...!(); }': () | 441 | 66..92 '{ ...!(); }': () |
442 | [76; 77) 'x': i32 | 442 | 76..77 'x': i32 |
443 | "### | 443 | "### |
444 | ); | 444 | ); |
445 | } | 445 | } |
@@ -456,9 +456,9 @@ fn main() { | |||
456 | } | 456 | } |
457 | "#), | 457 | "#), |
458 | @r###" | 458 | @r###" |
459 | ![0; 13) '"helloworld!"': &str | 459 | !0..13 '"helloworld!"': &str |
460 | [66; 122) '{ ...")); }': () | 460 | 66..122 '{ ...")); }': () |
461 | [76; 77) 'x': &str | 461 | 76..77 'x': &str |
462 | "### | 462 | "### |
463 | ); | 463 | ); |
464 | } | 464 | } |
@@ -591,9 +591,9 @@ fn main() { | |||
591 | } | 591 | } |
592 | "#), | 592 | "#), |
593 | @r###" | 593 | @r###" |
594 | ![0; 13) '"helloworld!"': &str | 594 | !0..13 '"helloworld!"': &str |
595 | [104; 161) '{ ...")); }': () | 595 | 104..161 '{ ...")); }': () |
596 | [114; 115) 'x': &str | 596 | 114..115 'x': &str |
597 | "### | 597 | "### |
598 | ); | 598 | ); |
599 | } | 599 | } |
@@ -611,9 +611,9 @@ fn main() { | |||
611 | } | 611 | } |
612 | "#), | 612 | "#), |
613 | @r###" | 613 | @r###" |
614 | ![0; 5) '"bar"': &str | 614 | !0..5 '"bar"': &str |
615 | [88; 116) '{ ...o"); }': () | 615 | 88..116 '{ ...o"); }': () |
616 | [98; 99) 'x': &str | 616 | 98..99 'x': &str |
617 | "### | 617 | "### |
618 | ); | 618 | ); |
619 | } | 619 | } |
@@ -703,12 +703,12 @@ fn main() { | |||
703 | } | 703 | } |
704 | "#), | 704 | "#), |
705 | @r###" | 705 | @r###" |
706 | [52; 111) '{ ... }; }': () | 706 | 52..111 '{ ... }; }': () |
707 | [62; 63) 'x': u32 | 707 | 62..63 'x': u32 |
708 | [66; 108) 'match ... }': u32 | 708 | 66..108 'match ... }': u32 |
709 | [72; 74) '()': () | 709 | 72..74 '()': () |
710 | [85; 92) 'unit!()': () | 710 | 85..92 'unit!()': () |
711 | [96; 101) '92u32': u32 | 711 | 96..101 '92u32': u32 |
712 | "### | 712 | "### |
713 | ); | 713 | ); |
714 | } | 714 | } |
diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/ra_hir_ty/src/tests/method_resolution.rs index af3e5b12c..ab87f598a 100644 --- a/crates/ra_hir_ty/src/tests/method_resolution.rs +++ b/crates/ra_hir_ty/src/tests/method_resolution.rs | |||
@@ -22,14 +22,14 @@ fn test() { | |||
22 | } | 22 | } |
23 | "#), | 23 | "#), |
24 | @r###" | 24 | @r###" |
25 | [45; 49) 'self': &[T] | 25 | 45..49 'self': &[T] |
26 | [56; 79) '{ ... }': T | 26 | 56..79 '{ ... }': T |
27 | [66; 73) 'loop {}': ! | 27 | 66..73 'loop {}': ! |
28 | [71; 73) '{}': () | 28 | 71..73 '{}': () |
29 | [133; 160) '{ ...o"); }': () | 29 | 133..160 '{ ...o"); }': () |
30 | [139; 149) '<[_]>::foo': fn foo<u8>(&[u8]) -> u8 | 30 | 139..149 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8 |
31 | [139; 157) '<[_]>:..."foo")': u8 | 31 | 139..157 '<[_]>:..."foo")': u8 |
32 | [150; 156) 'b"foo"': &[u8] | 32 | 150..156 'b"foo"': &[u8] |
33 | "### | 33 | "### |
34 | ); | 34 | ); |
35 | } | 35 | } |
@@ -51,15 +51,15 @@ fn test() { | |||
51 | } | 51 | } |
52 | "#), | 52 | "#), |
53 | @r###" | 53 | @r###" |
54 | [49; 75) '{ ... }': A | 54 | 49..75 '{ ... }': A |
55 | [59; 69) 'A { x: 0 }': A | 55 | 59..69 'A { x: 0 }': A |
56 | [66; 67) '0': u32 | 56 | 66..67 '0': u32 |
57 | [88; 122) '{ ...a.x; }': () | 57 | 88..122 '{ ...a.x; }': () |
58 | [98; 99) 'a': A | 58 | 98..99 'a': A |
59 | [102; 108) 'A::new': fn new() -> A | 59 | 102..108 'A::new': fn new() -> A |
60 | [102; 110) 'A::new()': A | 60 | 102..110 'A::new()': A |
61 | [116; 117) 'a': A | 61 | 116..117 'a': A |
62 | [116; 119) 'a.x': u32 | 62 | 116..119 'a.x': u32 |
63 | "### | 63 | "### |
64 | ); | 64 | ); |
65 | } | 65 | } |
@@ -86,19 +86,19 @@ fn test() { | |||
86 | } | 86 | } |
87 | "#), | 87 | "#), |
88 | @r###" | 88 | @r###" |
89 | [47; 67) '{ ... }': A | 89 | 47..67 '{ ... }': A |
90 | [57; 61) 'A::B': A | 90 | 57..61 'A::B': A |
91 | [88; 108) '{ ... }': A | 91 | 88..108 '{ ... }': A |
92 | [98; 102) 'A::C': A | 92 | 98..102 'A::C': A |
93 | [121; 178) '{ ... c; }': () | 93 | 121..178 '{ ... c; }': () |
94 | [131; 132) 'a': A | 94 | 131..132 'a': A |
95 | [135; 139) 'A::b': fn b() -> A | 95 | 135..139 'A::b': fn b() -> A |
96 | [135; 141) 'A::b()': A | 96 | 135..141 'A::b()': A |
97 | [147; 148) 'a': A | 97 | 147..148 'a': A |
98 | [158; 159) 'c': A | 98 | 158..159 'c': A |
99 | [162; 166) 'A::c': fn c() -> A | 99 | 162..166 'A::c': fn c() -> A |
100 | [162; 168) 'A::c()': A | 100 | 162..168 'A::c()': A |
101 | [174; 175) 'c': A | 101 | 174..175 'c': A |
102 | "### | 102 | "### |
103 | ); | 103 | ); |
104 | } | 104 | } |
@@ -130,22 +130,22 @@ fn test() { | |||
130 | } | 130 | } |
131 | "#), | 131 | "#), |
132 | @r###" | 132 | @r###" |
133 | [56; 64) '{ A {} }': A | 133 | 56..64 '{ A {} }': A |
134 | [58; 62) 'A {}': A | 134 | 58..62 'A {}': A |
135 | [126; 132) '{ 99 }': u32 | 135 | 126..132 '{ 99 }': u32 |
136 | [128; 130) '99': u32 | 136 | 128..130 '99': u32 |
137 | [202; 210) '{ C {} }': C | 137 | 202..210 '{ C {} }': C |
138 | [204; 208) 'C {}': C | 138 | 204..208 'C {}': C |
139 | [241; 325) '{ ...g(); }': () | 139 | 241..325 '{ ...g(); }': () |
140 | [251; 252) 'x': A | 140 | 251..252 'x': A |
141 | [255; 266) 'a::A::thing': fn thing() -> A | 141 | 255..266 'a::A::thing': fn thing() -> A |
142 | [255; 268) 'a::A::thing()': A | 142 | 255..268 'a::A::thing()': A |
143 | [278; 279) 'y': u32 | 143 | 278..279 'y': u32 |
144 | [282; 293) 'b::B::thing': fn thing() -> u32 | 144 | 282..293 'b::B::thing': fn thing() -> u32 |
145 | [282; 295) 'b::B::thing()': u32 | 145 | 282..295 'b::B::thing()': u32 |
146 | [305; 306) 'z': C | 146 | 305..306 'z': C |
147 | [309; 320) 'c::C::thing': fn thing() -> C | 147 | 309..320 'c::C::thing': fn thing() -> C |
148 | [309; 322) 'c::C::thing()': C | 148 | 309..322 'c::C::thing()': C |
149 | "### | 149 | "### |
150 | ); | 150 | ); |
151 | } | 151 | } |
@@ -169,15 +169,15 @@ fn test() { | |||
169 | } | 169 | } |
170 | "#), | 170 | "#), |
171 | @r###" | 171 | @r###" |
172 | [64; 67) 'val': T | 172 | 64..67 'val': T |
173 | [82; 109) '{ ... }': Gen<T> | 173 | 82..109 '{ ... }': Gen<T> |
174 | [92; 103) 'Gen { val }': Gen<T> | 174 | 92..103 'Gen { val }': Gen<T> |
175 | [98; 101) 'val': T | 175 | 98..101 'val': T |
176 | [123; 155) '{ ...32); }': () | 176 | 123..155 '{ ...32); }': () |
177 | [133; 134) 'a': Gen<u32> | 177 | 133..134 'a': Gen<u32> |
178 | [137; 146) 'Gen::make': fn make<u32>(u32) -> Gen<u32> | 178 | 137..146 'Gen::make': fn make<u32>(u32) -> Gen<u32> |
179 | [137; 152) 'Gen::make(0u32)': Gen<u32> | 179 | 137..152 'Gen::make(0u32)': Gen<u32> |
180 | [147; 151) '0u32': u32 | 180 | 147..151 '0u32': u32 |
181 | "### | 181 | "### |
182 | ); | 182 | ); |
183 | } | 183 | } |
@@ -201,13 +201,13 @@ fn test() { | |||
201 | } | 201 | } |
202 | "#), | 202 | "#), |
203 | @r###" | 203 | @r###" |
204 | [80; 104) '{ ... }': Gen<T> | 204 | 80..104 '{ ... }': Gen<T> |
205 | [90; 98) 'loop { }': ! | 205 | 90..98 'loop { }': ! |
206 | [95; 98) '{ }': () | 206 | 95..98 '{ }': () |
207 | [118; 146) '{ ...e(); }': () | 207 | 118..146 '{ ...e(); }': () |
208 | [128; 129) 'a': Gen<u32> | 208 | 128..129 'a': Gen<u32> |
209 | [132; 141) 'Gen::make': fn make<u32>() -> Gen<u32> | 209 | 132..141 'Gen::make': fn make<u32>() -> Gen<u32> |
210 | [132; 143) 'Gen::make()': Gen<u32> | 210 | 132..143 'Gen::make()': Gen<u32> |
211 | "### | 211 | "### |
212 | ); | 212 | ); |
213 | } | 213 | } |
@@ -255,13 +255,13 @@ fn test() { | |||
255 | } | 255 | } |
256 | "#), | 256 | "#), |
257 | @r###" | 257 | @r###" |
258 | [76; 100) '{ ... }': Gen<T> | 258 | 76..100 '{ ... }': Gen<T> |
259 | [86; 94) 'loop { }': ! | 259 | 86..94 'loop { }': ! |
260 | [91; 94) '{ }': () | 260 | 91..94 '{ }': () |
261 | [114; 149) '{ ...e(); }': () | 261 | 114..149 '{ ...e(); }': () |
262 | [124; 125) 'a': Gen<u32> | 262 | 124..125 'a': Gen<u32> |
263 | [128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<u32> | 263 | 128..144 'Gen::<...::make': fn make<u32>() -> Gen<u32> |
264 | [128; 146) 'Gen::<...make()': Gen<u32> | 264 | 128..146 'Gen::<...make()': Gen<u32> |
265 | "### | 265 | "### |
266 | ); | 266 | ); |
267 | } | 267 | } |
@@ -286,13 +286,13 @@ fn test() { | |||
286 | } | 286 | } |
287 | "#), | 287 | "#), |
288 | @r###" | 288 | @r###" |
289 | [102; 126) '{ ... }': Gen<u32, T> | 289 | 102..126 '{ ... }': Gen<u32, T> |
290 | [112; 120) 'loop { }': ! | 290 | 112..120 'loop { }': ! |
291 | [117; 120) '{ }': () | 291 | 117..120 '{ }': () |
292 | [140; 180) '{ ...e(); }': () | 292 | 140..180 '{ ...e(); }': () |
293 | [150; 151) 'a': Gen<u32, u64> | 293 | 150..151 'a': Gen<u32, u64> |
294 | [154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, u64> | 294 | 154..175 'Gen::<...::make': fn make<u64>() -> Gen<u32, u64> |
295 | [154; 177) 'Gen::<...make()': Gen<u32, u64> | 295 | 154..177 'Gen::<...make()': Gen<u32, u64> |
296 | "### | 296 | "### |
297 | ); | 297 | ); |
298 | } | 298 | } |
@@ -340,13 +340,13 @@ fn test() { | |||
340 | } | 340 | } |
341 | "#), | 341 | "#), |
342 | @r###" | 342 | @r###" |
343 | [31; 35) 'self': &Self | 343 | 31..35 'self': &Self |
344 | [110; 114) 'self': &Self | 344 | 110..114 'self': &Self |
345 | [170; 228) '{ ...i128 }': () | 345 | 170..228 '{ ...i128 }': () |
346 | [176; 178) 'S1': S1 | 346 | 176..178 'S1': S1 |
347 | [176; 187) 'S1.method()': u32 | 347 | 176..187 'S1.method()': u32 |
348 | [203; 205) 'S2': S2 | 348 | 203..205 'S2': S2 |
349 | [203; 214) 'S2.method()': i128 | 349 | 203..214 'S2.method()': i128 |
350 | "### | 350 | "### |
351 | ); | 351 | ); |
352 | } | 352 | } |
@@ -387,14 +387,14 @@ mod bar_test { | |||
387 | } | 387 | } |
388 | "#), | 388 | "#), |
389 | @r###" | 389 | @r###" |
390 | [63; 67) 'self': &Self | 390 | 63..67 'self': &Self |
391 | [169; 173) 'self': &Self | 391 | 169..173 'self': &Self |
392 | [300; 337) '{ ... }': () | 392 | 300..337 '{ ... }': () |
393 | [310; 311) 'S': S | 393 | 310..311 'S': S |
394 | [310; 320) 'S.method()': u32 | 394 | 310..320 'S.method()': u32 |
395 | [416; 454) '{ ... }': () | 395 | 416..454 '{ ... }': () |
396 | [426; 427) 'S': S | 396 | 426..427 'S': S |
397 | [426; 436) 'S.method()': i128 | 397 | 426..436 'S.method()': i128 |
398 | "### | 398 | "### |
399 | ); | 399 | ); |
400 | } | 400 | } |
@@ -414,10 +414,10 @@ fn test() { | |||
414 | } | 414 | } |
415 | "#), | 415 | "#), |
416 | @r###" | 416 | @r###" |
417 | [33; 37) 'self': &Self | 417 | 33..37 'self': &Self |
418 | [92; 111) '{ ...d(); }': () | 418 | 92..111 '{ ...d(); }': () |
419 | [98; 99) 'S': S | 419 | 98..99 'S': S |
420 | [98; 108) 'S.method()': u32 | 420 | 98..108 'S.method()': u32 |
421 | "### | 421 | "### |
422 | ); | 422 | ); |
423 | } | 423 | } |
@@ -443,17 +443,17 @@ fn test() { | |||
443 | } | 443 | } |
444 | "#), | 444 | "#), |
445 | @r###" | 445 | @r###" |
446 | [43; 47) 'self': &Self | 446 | 43..47 'self': &Self |
447 | [82; 86) 'self': &Self | 447 | 82..86 'self': &Self |
448 | [210; 361) '{ ..., i8 }': () | 448 | 210..361 '{ ..., i8 }': () |
449 | [216; 218) 'S1': S1 | 449 | 216..218 'S1': S1 |
450 | [216; 228) 'S1.method1()': (u8, u16, u32) | 450 | 216..228 'S1.method1()': (u8, u16, u32) |
451 | [250; 252) 'S1': S1 | 451 | 250..252 'S1': S1 |
452 | [250; 262) 'S1.method2()': (u32, u16, u8) | 452 | 250..262 'S1.method2()': (u32, u16, u8) |
453 | [284; 286) 'S2': S2 | 453 | 284..286 'S2': S2 |
454 | [284; 296) 'S2.method1()': (i8, i16, {unknown}) | 454 | 284..296 'S2.method1()': (i8, i16, {unknown}) |
455 | [324; 326) 'S2': S2 | 455 | 324..326 'S2': S2 |
456 | [324; 336) 'S2.method2()': ({unknown}, i16, i8) | 456 | 324..336 'S2.method2()': ({unknown}, i16, i8) |
457 | "### | 457 | "### |
458 | ); | 458 | ); |
459 | } | 459 | } |
@@ -473,12 +473,12 @@ fn test() { | |||
473 | } | 473 | } |
474 | "#), | 474 | "#), |
475 | @r###" | 475 | @r###" |
476 | [33; 37) 'self': &Self | 476 | 33..37 'self': &Self |
477 | [102; 127) '{ ...d(); }': () | 477 | 102..127 '{ ...d(); }': () |
478 | [108; 109) 'S': S<u32>(u32) -> S<u32> | 478 | 108..109 'S': S<u32>(u32) -> S<u32> |
479 | [108; 115) 'S(1u32)': S<u32> | 479 | 108..115 'S(1u32)': S<u32> |
480 | [108; 124) 'S(1u32...thod()': u32 | 480 | 108..124 'S(1u32...thod()': u32 |
481 | [110; 114) '1u32': u32 | 481 | 110..114 '1u32': u32 |
482 | "### | 482 | "### |
483 | ); | 483 | ); |
484 | } | 484 | } |
@@ -499,16 +499,16 @@ fn test() { | |||
499 | } | 499 | } |
500 | "#), | 500 | "#), |
501 | @r###" | 501 | @r###" |
502 | [87; 193) '{ ...t(); }': () | 502 | 87..193 '{ ...t(); }': () |
503 | [97; 99) 's1': S | 503 | 97..99 's1': S |
504 | [105; 121) 'Defaul...efault': fn default<S>() -> S | 504 | 105..121 'Defaul...efault': fn default<S>() -> S |
505 | [105; 123) 'Defaul...ault()': S | 505 | 105..123 'Defaul...ault()': S |
506 | [133; 135) 's2': S | 506 | 133..135 's2': S |
507 | [138; 148) 'S::default': fn default<S>() -> S | 507 | 138..148 'S::default': fn default<S>() -> S |
508 | [138; 150) 'S::default()': S | 508 | 138..150 'S::default()': S |
509 | [160; 162) 's3': S | 509 | 160..162 's3': S |
510 | [165; 188) '<S as ...efault': fn default<S>() -> S | 510 | 165..188 '<S as ...efault': fn default<S>() -> S |
511 | [165; 190) '<S as ...ault()': S | 511 | 165..190 '<S as ...ault()': S |
512 | "### | 512 | "### |
513 | ); | 513 | ); |
514 | } | 514 | } |
@@ -531,16 +531,16 @@ fn test() { | |||
531 | } | 531 | } |
532 | "#), | 532 | "#), |
533 | @r###" | 533 | @r###" |
534 | [127; 211) '{ ...e(); }': () | 534 | 127..211 '{ ...e(); }': () |
535 | [137; 138) 'a': u32 | 535 | 137..138 'a': u32 |
536 | [141; 148) 'S::make': fn make<S, u32>() -> u32 | 536 | 141..148 'S::make': fn make<S, u32>() -> u32 |
537 | [141; 150) 'S::make()': u32 | 537 | 141..150 'S::make()': u32 |
538 | [160; 161) 'b': u64 | 538 | 160..161 'b': u64 |
539 | [164; 178) 'G::<u64>::make': fn make<G<u64>, u64>() -> u64 | 539 | 164..178 'G::<u64>::make': fn make<G<u64>, u64>() -> u64 |
540 | [164; 180) 'G::<u6...make()': u64 | 540 | 164..180 'G::<u6...make()': u64 |
541 | [190; 191) 'c': f64 | 541 | 190..191 'c': f64 |
542 | [199; 206) 'G::make': fn make<G<f64>, f64>() -> f64 | 542 | 199..206 'G::make': fn make<G<f64>, f64>() -> f64 |
543 | [199; 208) 'G::make()': f64 | 543 | 199..208 'G::make()': f64 |
544 | "### | 544 | "### |
545 | ); | 545 | ); |
546 | } | 546 | } |
@@ -565,22 +565,22 @@ fn test() { | |||
565 | } | 565 | } |
566 | "#), | 566 | "#), |
567 | @r###" | 567 | @r###" |
568 | [135; 313) '{ ...e(); }': () | 568 | 135..313 '{ ...e(); }': () |
569 | [145; 146) 'a': (u32, i64) | 569 | 145..146 'a': (u32, i64) |
570 | [149; 163) 'S::make::<i64>': fn make<S, u32, i64>() -> (u32, i64) | 570 | 149..163 'S::make::<i64>': fn make<S, u32, i64>() -> (u32, i64) |
571 | [149; 165) 'S::mak...i64>()': (u32, i64) | 571 | 149..165 'S::mak...i64>()': (u32, i64) |
572 | [175; 176) 'b': (u32, i64) | 572 | 175..176 'b': (u32, i64) |
573 | [189; 196) 'S::make': fn make<S, u32, i64>() -> (u32, i64) | 573 | 189..196 'S::make': fn make<S, u32, i64>() -> (u32, i64) |
574 | [189; 198) 'S::make()': (u32, i64) | 574 | 189..198 'S::make()': (u32, i64) |
575 | [208; 209) 'c': (u32, i64) | 575 | 208..209 'c': (u32, i64) |
576 | [212; 233) 'G::<u3...:<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) | 576 | 212..233 'G::<u3...:<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) |
577 | [212; 235) 'G::<u3...i64>()': (u32, i64) | 577 | 212..235 'G::<u3...i64>()': (u32, i64) |
578 | [245; 246) 'd': (u32, i64) | 578 | 245..246 'd': (u32, i64) |
579 | [259; 273) 'G::make::<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) | 579 | 259..273 'G::make::<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) |
580 | [259; 275) 'G::mak...i64>()': (u32, i64) | 580 | 259..275 'G::mak...i64>()': (u32, i64) |
581 | [285; 286) 'e': (u32, i64) | 581 | 285..286 'e': (u32, i64) |
582 | [301; 308) 'G::make': fn make<G<u32>, u32, i64>() -> (u32, i64) | 582 | 301..308 'G::make': fn make<G<u32>, u32, i64>() -> (u32, i64) |
583 | [301; 310) 'G::make()': (u32, i64) | 583 | 301..310 'G::make()': (u32, i64) |
584 | "### | 584 | "### |
585 | ); | 585 | ); |
586 | } | 586 | } |
@@ -599,10 +599,10 @@ fn test() { | |||
599 | } | 599 | } |
600 | "#), | 600 | "#), |
601 | @r###" | 601 | @r###" |
602 | [101; 127) '{ ...e(); }': () | 602 | 101..127 '{ ...e(); }': () |
603 | [111; 112) 'a': (S<i32>, i64) | 603 | 111..112 'a': (S<i32>, i64) |
604 | [115; 122) 'S::make': fn make<S<i32>, i64>() -> (S<i32>, i64) | 604 | 115..122 'S::make': fn make<S<i32>, i64>() -> (S<i32>, i64) |
605 | [115; 124) 'S::make()': (S<i32>, i64) | 605 | 115..124 'S::make()': (S<i32>, i64) |
606 | "### | 606 | "### |
607 | ); | 607 | ); |
608 | } | 608 | } |
@@ -623,13 +623,13 @@ fn test() { | |||
623 | } | 623 | } |
624 | "#), | 624 | "#), |
625 | @r###" | 625 | @r###" |
626 | [131; 203) '{ ...e(); }': () | 626 | 131..203 '{ ...e(); }': () |
627 | [141; 142) 'a': (S<u64>, i64) | 627 | 141..142 'a': (S<u64>, i64) |
628 | [158; 165) 'S::make': fn make<S<u64>, i64>() -> (S<u64>, i64) | 628 | 158..165 'S::make': fn make<S<u64>, i64>() -> (S<u64>, i64) |
629 | [158; 167) 'S::make()': (S<u64>, i64) | 629 | 158..167 'S::make()': (S<u64>, i64) |
630 | [177; 178) 'b': (S<u32>, i32) | 630 | 177..178 'b': (S<u32>, i32) |
631 | [191; 198) 'S::make': fn make<S<u32>, i32>() -> (S<u32>, i32) | 631 | 191..198 'S::make': fn make<S<u32>, i32>() -> (S<u32>, i32) |
632 | [191; 200) 'S::make()': (S<u32>, i32) | 632 | 191..200 'S::make()': (S<u32>, i32) |
633 | "### | 633 | "### |
634 | ); | 634 | ); |
635 | } | 635 | } |
@@ -649,13 +649,13 @@ fn test() { | |||
649 | } | 649 | } |
650 | "#), | 650 | "#), |
651 | @r###" | 651 | @r###" |
652 | [107; 211) '{ ...>(); }': () | 652 | 107..211 '{ ...>(); }': () |
653 | [117; 118) 'a': (S<u64>, i64, u8) | 653 | 117..118 'a': (S<u64>, i64, u8) |
654 | [121; 150) '<S as ...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) | 654 | 121..150 '<S as ...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) |
655 | [121; 152) '<S as ...<u8>()': (S<u64>, i64, u8) | 655 | 121..152 '<S as ...<u8>()': (S<u64>, i64, u8) |
656 | [162; 163) 'b': (S<u64>, i64, u8) | 656 | 162..163 'b': (S<u64>, i64, u8) |
657 | [182; 206) 'Trait:...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) | 657 | 182..206 'Trait:...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) |
658 | [182; 208) 'Trait:...<u8>()': (S<u64>, i64, u8) | 658 | 182..208 'Trait:...<u8>()': (S<u64>, i64, u8) |
659 | "### | 659 | "### |
660 | ); | 660 | ); |
661 | } | 661 | } |
@@ -672,11 +672,11 @@ fn test<T: Trait>(t: T) { | |||
672 | } | 672 | } |
673 | "#), | 673 | "#), |
674 | @r###" | 674 | @r###" |
675 | [30; 34) 'self': &Self | 675 | 30..34 'self': &Self |
676 | [64; 65) 't': T | 676 | 64..65 't': T |
677 | [70; 89) '{ ...d(); }': () | 677 | 70..89 '{ ...d(); }': () |
678 | [76; 77) 't': T | 678 | 76..77 't': T |
679 | [76; 86) 't.method()': u32 | 679 | 76..86 't.method()': u32 |
680 | "### | 680 | "### |
681 | ); | 681 | ); |
682 | } | 682 | } |
@@ -693,11 +693,11 @@ fn test<U, T: Trait<U>>(t: T) { | |||
693 | } | 693 | } |
694 | "#), | 694 | "#), |
695 | @r###" | 695 | @r###" |
696 | [33; 37) 'self': &Self | 696 | 33..37 'self': &Self |
697 | [71; 72) 't': T | 697 | 71..72 't': T |
698 | [77; 96) '{ ...d(); }': () | 698 | 77..96 '{ ...d(); }': () |
699 | [83; 84) 't': T | 699 | 83..84 't': T |
700 | [83; 93) 't.method()': U | 700 | 83..93 't.method()': U |
701 | "### | 701 | "### |
702 | ); | 702 | ); |
703 | } | 703 | } |
@@ -719,18 +719,18 @@ fn test() { | |||
719 | } | 719 | } |
720 | "#), | 720 | "#), |
721 | @r###" | 721 | @r###" |
722 | [29; 33) 'self': Self | 722 | 29..33 'self': Self |
723 | [111; 202) '{ ...(S); }': () | 723 | 111..202 '{ ...(S); }': () |
724 | [121; 122) 'x': u32 | 724 | 121..122 'x': u32 |
725 | [130; 131) 'S': S | 725 | 130..131 'S': S |
726 | [130; 138) 'S.into()': u32 | 726 | 130..138 'S.into()': u32 |
727 | [148; 149) 'y': u64 | 727 | 148..149 'y': u64 |
728 | [157; 158) 'S': S | 728 | 157..158 'S': S |
729 | [157; 165) 'S.into()': u64 | 729 | 157..165 'S.into()': u64 |
730 | [175; 176) 'z': u64 | 730 | 175..176 'z': u64 |
731 | [179; 196) 'Into::...::into': fn into<S, u64>(S) -> u64 | 731 | 179..196 'Into::...::into': fn into<S, u64>(S) -> u64 |
732 | [179; 199) 'Into::...nto(S)': u64 | 732 | 179..199 'Into::...nto(S)': u64 |
733 | [197; 198) 'S': S | 733 | 197..198 'S': S |
734 | "### | 734 | "### |
735 | ); | 735 | ); |
736 | } | 736 | } |
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/ra_hir_ty/src/tests/patterns.rs index 6ea51d5d3..af291092d 100644 --- a/crates/ra_hir_ty/src/tests/patterns.rs +++ b/crates/ra_hir_ty/src/tests/patterns.rs | |||
@@ -30,54 +30,54 @@ fn test(x: &i32) { | |||
30 | } | 30 | } |
31 | "#), | 31 | "#), |
32 | @r###" | 32 | @r###" |
33 | [9; 10) 'x': &i32 | 33 | 9..10 'x': &i32 |
34 | [18; 369) '{ ...o_x; }': () | 34 | 18..369 '{ ...o_x; }': () |
35 | [28; 29) 'y': &i32 | 35 | 28..29 'y': &i32 |
36 | [32; 33) 'x': &i32 | 36 | 32..33 'x': &i32 |
37 | [43; 45) '&z': &i32 | 37 | 43..45 '&z': &i32 |
38 | [44; 45) 'z': i32 | 38 | 44..45 'z': i32 |
39 | [48; 49) 'x': &i32 | 39 | 48..49 'x': &i32 |
40 | [59; 60) 'a': i32 | 40 | 59..60 'a': i32 |
41 | [63; 64) 'z': i32 | 41 | 63..64 'z': i32 |
42 | [74; 80) '(c, d)': (i32, &str) | 42 | 74..80 '(c, d)': (i32, &str) |
43 | [75; 76) 'c': i32 | 43 | 75..76 'c': i32 |
44 | [78; 79) 'd': &str | 44 | 78..79 'd': &str |
45 | [83; 95) '(1, "hello")': (i32, &str) | 45 | 83..95 '(1, "hello")': (i32, &str) |
46 | [84; 85) '1': i32 | 46 | 84..85 '1': i32 |
47 | [87; 94) '"hello"': &str | 47 | 87..94 '"hello"': &str |
48 | [102; 152) 'for (e... }': () | 48 | 102..152 'for (e... }': () |
49 | [106; 112) '(e, f)': ({unknown}, {unknown}) | 49 | 106..112 '(e, f)': ({unknown}, {unknown}) |
50 | [107; 108) 'e': {unknown} | 50 | 107..108 'e': {unknown} |
51 | [110; 111) 'f': {unknown} | 51 | 110..111 'f': {unknown} |
52 | [116; 125) 'some_iter': {unknown} | 52 | 116..125 'some_iter': {unknown} |
53 | [126; 152) '{ ... }': () | 53 | 126..152 '{ ... }': () |
54 | [140; 141) 'g': {unknown} | 54 | 140..141 'g': {unknown} |
55 | [144; 145) 'e': {unknown} | 55 | 144..145 'e': {unknown} |
56 | [158; 205) 'if let... }': () | 56 | 158..205 'if let... }': () |
57 | [165; 170) '[val]': [{unknown}] | 57 | 165..170 '[val]': [{unknown}] |
58 | [166; 169) 'val': {unknown} | 58 | 166..169 'val': {unknown} |
59 | [173; 176) 'opt': [{unknown}] | 59 | 173..176 'opt': [{unknown}] |
60 | [177; 205) '{ ... }': () | 60 | 177..205 '{ ... }': () |
61 | [191; 192) 'h': {unknown} | 61 | 191..192 'h': {unknown} |
62 | [195; 198) 'val': {unknown} | 62 | 195..198 'val': {unknown} |
63 | [215; 221) 'lambda': |u64, u64, i32| -> i32 | 63 | 215..221 'lambda': |u64, u64, i32| -> i32 |
64 | [224; 256) '|a: u6...b; c }': |u64, u64, i32| -> i32 | 64 | 224..256 '|a: u6...b; c }': |u64, u64, i32| -> i32 |
65 | [225; 226) 'a': u64 | 65 | 225..226 'a': u64 |
66 | [233; 234) 'b': u64 | 66 | 233..234 'b': u64 |
67 | [236; 237) 'c': i32 | 67 | 236..237 'c': i32 |
68 | [244; 256) '{ a + b; c }': i32 | 68 | 244..256 '{ a + b; c }': i32 |
69 | [246; 247) 'a': u64 | 69 | 246..247 'a': u64 |
70 | [246; 251) 'a + b': u64 | 70 | 246..251 'a + b': u64 |
71 | [250; 251) 'b': u64 | 71 | 250..251 'b': u64 |
72 | [253; 254) 'c': i32 | 72 | 253..254 'c': i32 |
73 | [267; 279) 'ref ref_to_x': &&i32 | 73 | 267..279 'ref ref_to_x': &&i32 |
74 | [282; 283) 'x': &i32 | 74 | 282..283 'x': &i32 |
75 | [293; 302) 'mut mut_x': &i32 | 75 | 293..302 'mut mut_x': &i32 |
76 | [305; 306) 'x': &i32 | 76 | 305..306 'x': &i32 |
77 | [316; 336) 'ref mu...f_to_x': &mut &i32 | 77 | 316..336 'ref mu...f_to_x': &mut &i32 |
78 | [339; 340) 'x': &i32 | 78 | 339..340 'x': &i32 |
79 | [350; 351) 'k': &mut &i32 | 79 | 350..351 'k': &mut &i32 |
80 | [354; 366) 'mut_ref_to_x': &mut &i32 | 80 | 354..366 'mut_ref_to_x': &mut &i32 |
81 | "### | 81 | "### |
82 | ); | 82 | ); |
83 | } | 83 | } |
@@ -97,47 +97,47 @@ fn test(x: &i32) { | |||
97 | } | 97 | } |
98 | "#, true), | 98 | "#, true), |
99 | @r###" | 99 | @r###" |
100 | [18; 29) '{ loop {} }': T | 100 | 18..29 '{ loop {} }': T |
101 | [20; 27) 'loop {}': ! | 101 | 20..27 'loop {}': ! |
102 | [25; 27) '{}': () | 102 | 25..27 '{}': () |
103 | [38; 39) 'x': &i32 | 103 | 38..39 'x': &i32 |
104 | [47; 209) '{ ...) {} }': () | 104 | 47..209 '{ ...) {} }': () |
105 | [53; 76) 'if let...y() {}': () | 105 | 53..76 'if let...y() {}': () |
106 | [60; 65) '"foo"': &str | 106 | 60..65 '"foo"': &str |
107 | [60; 65) '"foo"': &str | 107 | 60..65 '"foo"': &str |
108 | [68; 71) 'any': fn any<&str>() -> &str | 108 | 68..71 'any': fn any<&str>() -> &str |
109 | [68; 73) 'any()': &str | 109 | 68..73 'any()': &str |
110 | [74; 76) '{}': () | 110 | 74..76 '{}': () |
111 | [81; 100) 'if let...y() {}': () | 111 | 81..100 'if let...y() {}': () |
112 | [88; 89) '1': i32 | 112 | 88..89 '1': i32 |
113 | [88; 89) '1': i32 | 113 | 88..89 '1': i32 |
114 | [92; 95) 'any': fn any<i32>() -> i32 | 114 | 92..95 'any': fn any<i32>() -> i32 |
115 | [92; 97) 'any()': i32 | 115 | 92..97 'any()': i32 |
116 | [98; 100) '{}': () | 116 | 98..100 '{}': () |
117 | [105; 127) 'if let...y() {}': () | 117 | 105..127 'if let...y() {}': () |
118 | [112; 116) '1u32': u32 | 118 | 112..116 '1u32': u32 |
119 | [112; 116) '1u32': u32 | 119 | 112..116 '1u32': u32 |
120 | [119; 122) 'any': fn any<u32>() -> u32 | 120 | 119..122 'any': fn any<u32>() -> u32 |
121 | [119; 124) 'any()': u32 | 121 | 119..124 'any()': u32 |
122 | [125; 127) '{}': () | 122 | 125..127 '{}': () |
123 | [132; 154) 'if let...y() {}': () | 123 | 132..154 'if let...y() {}': () |
124 | [139; 143) '1f32': f32 | 124 | 139..143 '1f32': f32 |
125 | [139; 143) '1f32': f32 | 125 | 139..143 '1f32': f32 |
126 | [146; 149) 'any': fn any<f32>() -> f32 | 126 | 146..149 'any': fn any<f32>() -> f32 |
127 | [146; 151) 'any()': f32 | 127 | 146..151 'any()': f32 |
128 | [152; 154) '{}': () | 128 | 152..154 '{}': () |
129 | [159; 180) 'if let...y() {}': () | 129 | 159..180 'if let...y() {}': () |
130 | [166; 169) '1.0': f64 | 130 | 166..169 '1.0': f64 |
131 | [166; 169) '1.0': f64 | 131 | 166..169 '1.0': f64 |
132 | [172; 175) 'any': fn any<f64>() -> f64 | 132 | 172..175 'any': fn any<f64>() -> f64 |
133 | [172; 177) 'any()': f64 | 133 | 172..177 'any()': f64 |
134 | [178; 180) '{}': () | 134 | 178..180 '{}': () |
135 | [185; 207) 'if let...y() {}': () | 135 | 185..207 'if let...y() {}': () |
136 | [192; 196) 'true': bool | 136 | 192..196 'true': bool |
137 | [192; 196) 'true': bool | 137 | 192..196 'true': bool |
138 | [199; 202) 'any': fn any<bool>() -> bool | 138 | 199..202 'any': fn any<bool>() -> bool |
139 | [199; 204) 'any()': bool | 139 | 199..204 'any()': bool |
140 | [205; 207) '{}': () | 140 | 205..207 '{}': () |
141 | "### | 141 | "### |
142 | ); | 142 | ); |
143 | } | 143 | } |
@@ -152,16 +152,16 @@ fn test(x: &i32) { | |||
152 | } | 152 | } |
153 | "#, true), | 153 | "#, true), |
154 | @r###" | 154 | @r###" |
155 | [9; 10) 'x': &i32 | 155 | 9..10 'x': &i32 |
156 | [18; 76) '{ ...2 {} }': () | 156 | 18..76 '{ ...2 {} }': () |
157 | [24; 46) 'if let...u32 {}': () | 157 | 24..46 'if let...u32 {}': () |
158 | [31; 36) '1..76': u32 | 158 | 31..36 '1..76': u32 |
159 | [39; 43) '2u32': u32 | 159 | 39..43 '2u32': u32 |
160 | [44; 46) '{}': () | 160 | 44..46 '{}': () |
161 | [51; 74) 'if let...u32 {}': () | 161 | 51..74 'if let...u32 {}': () |
162 | [58; 64) '1..=76': u32 | 162 | 58..64 '1..=76': u32 |
163 | [67; 71) '2u32': u32 | 163 | 67..71 '2u32': u32 |
164 | [72; 74) '{}': () | 164 | 72..74 '{}': () |
165 | "### | 165 | "### |
166 | ); | 166 | ); |
167 | } | 167 | } |
@@ -178,19 +178,19 @@ fn test() { | |||
178 | } | 178 | } |
179 | "#), | 179 | "#), |
180 | @r###" | 180 | @r###" |
181 | [28; 79) '{ ...(1); }': () | 181 | 28..79 '{ ...(1); }': () |
182 | [38; 42) 'A(n)': A<i32> | 182 | 38..42 'A(n)': A<i32> |
183 | [40; 41) 'n': &i32 | 183 | 40..41 'n': &i32 |
184 | [45; 50) '&A(1)': &A<i32> | 184 | 45..50 '&A(1)': &A<i32> |
185 | [46; 47) 'A': A<i32>(i32) -> A<i32> | 185 | 46..47 'A': A<i32>(i32) -> A<i32> |
186 | [46; 50) 'A(1)': A<i32> | 186 | 46..50 'A(1)': A<i32> |
187 | [48; 49) '1': i32 | 187 | 48..49 '1': i32 |
188 | [60; 64) 'A(n)': A<i32> | 188 | 60..64 'A(n)': A<i32> |
189 | [62; 63) 'n': &mut i32 | 189 | 62..63 'n': &mut i32 |
190 | [67; 76) '&mut A(1)': &mut A<i32> | 190 | 67..76 '&mut A(1)': &mut A<i32> |
191 | [72; 73) 'A': A<i32>(i32) -> A<i32> | 191 | 72..73 'A': A<i32>(i32) -> A<i32> |
192 | [72; 76) 'A(1)': A<i32> | 192 | 72..76 'A(1)': A<i32> |
193 | [74; 75) '1': i32 | 193 | 74..75 '1': i32 |
194 | "### | 194 | "### |
195 | ); | 195 | ); |
196 | } | 196 | } |
@@ -206,18 +206,18 @@ fn test() { | |||
206 | } | 206 | } |
207 | "#), | 207 | "#), |
208 | @r###" | 208 | @r###" |
209 | [11; 57) '{ ...= v; }': () | 209 | 11..57 '{ ...= v; }': () |
210 | [21; 22) 'v': &(i32, &i32) | 210 | 21..22 'v': &(i32, &i32) |
211 | [25; 33) '&(1, &2)': &(i32, &i32) | 211 | 25..33 '&(1, &2)': &(i32, &i32) |
212 | [26; 33) '(1, &2)': (i32, &i32) | 212 | 26..33 '(1, &2)': (i32, &i32) |
213 | [27; 28) '1': i32 | 213 | 27..28 '1': i32 |
214 | [30; 32) '&2': &i32 | 214 | 30..32 '&2': &i32 |
215 | [31; 32) '2': i32 | 215 | 31..32 '2': i32 |
216 | [43; 50) '(_, &w)': (i32, &i32) | 216 | 43..50 '(_, &w)': (i32, &i32) |
217 | [44; 45) '_': i32 | 217 | 44..45 '_': i32 |
218 | [47; 49) '&w': &i32 | 218 | 47..49 '&w': &i32 |
219 | [48; 49) 'w': i32 | 219 | 48..49 'w': i32 |
220 | [53; 54) 'v': &(i32, &i32) | 220 | 53..54 'v': &(i32, &i32) |
221 | "### | 221 | "### |
222 | ); | 222 | ); |
223 | } | 223 | } |
@@ -242,30 +242,30 @@ fn test() { | |||
242 | } | 242 | } |
243 | "#), | 243 | "#), |
244 | @r###" | 244 | @r###" |
245 | [11; 210) '{ ... } }': () | 245 | 11..210 '{ ... } }': () |
246 | [21; 26) 'slice': &[f64] | 246 | 21..26 'slice': &[f64] |
247 | [37; 43) '&[0.0]': &[f64; _] | 247 | 37..43 '&[0.0]': &[f64; _] |
248 | [38; 43) '[0.0]': [f64; _] | 248 | 38..43 '[0.0]': [f64; _] |
249 | [39; 42) '0.0': f64 | 249 | 39..42 '0.0': f64 |
250 | [49; 208) 'match ... }': () | 250 | 49..208 'match ... }': () |
251 | [55; 60) 'slice': &[f64] | 251 | 55..60 'slice': &[f64] |
252 | [71; 74) '&[]': &[f64] | 252 | 71..74 '&[]': &[f64] |
253 | [72; 74) '[]': [f64] | 253 | 72..74 '[]': [f64] |
254 | [78; 80) '{}': () | 254 | 78..80 '{}': () |
255 | [90; 94) '&[a]': &[f64] | 255 | 90..94 '&[a]': &[f64] |
256 | [91; 94) '[a]': [f64] | 256 | 91..94 '[a]': [f64] |
257 | [92; 93) 'a': f64 | 257 | 92..93 'a': f64 |
258 | [98; 124) '{ ... }': () | 258 | 98..124 '{ ... }': () |
259 | [112; 113) 'a': f64 | 259 | 112..113 'a': f64 |
260 | [134; 141) '&[b, c]': &[f64] | 260 | 134..141 '&[b, c]': &[f64] |
261 | [135; 141) '[b, c]': [f64] | 261 | 135..141 '[b, c]': [f64] |
262 | [136; 137) 'b': f64 | 262 | 136..137 'b': f64 |
263 | [139; 140) 'c': f64 | 263 | 139..140 'c': f64 |
264 | [145; 186) '{ ... }': () | 264 | 145..186 '{ ... }': () |
265 | [159; 160) 'b': f64 | 265 | 159..160 'b': f64 |
266 | [174; 175) 'c': f64 | 266 | 174..175 'c': f64 |
267 | [195; 196) '_': &[f64] | 267 | 195..196 '_': &[f64] |
268 | [200; 202) '{}': () | 268 | 200..202 '{}': () |
269 | "### | 269 | "### |
270 | ); | 270 | ); |
271 | } | 271 | } |
@@ -288,25 +288,25 @@ fn test() { | |||
288 | } | 288 | } |
289 | "#), | 289 | "#), |
290 | @r###" | 290 | @r###" |
291 | [11; 180) '{ ... } }': () | 291 | 11..180 '{ ... } }': () |
292 | [21; 24) 'arr': [f64; _] | 292 | 21..24 'arr': [f64; _] |
293 | [37; 47) '[0.0, 1.0]': [f64; _] | 293 | 37..47 '[0.0, 1.0]': [f64; _] |
294 | [38; 41) '0.0': f64 | 294 | 38..41 '0.0': f64 |
295 | [43; 46) '1.0': f64 | 295 | 43..46 '1.0': f64 |
296 | [53; 178) 'match ... }': () | 296 | 53..178 'match ... }': () |
297 | [59; 62) 'arr': [f64; _] | 297 | 59..62 'arr': [f64; _] |
298 | [73; 81) '[1.0, a]': [f64; _] | 298 | 73..81 '[1.0, a]': [f64; _] |
299 | [74; 77) '1.0': f64 | 299 | 74..77 '1.0': f64 |
300 | [74; 77) '1.0': f64 | 300 | 74..77 '1.0': f64 |
301 | [79; 80) 'a': f64 | 301 | 79..80 'a': f64 |
302 | [85; 111) '{ ... }': () | 302 | 85..111 '{ ... }': () |
303 | [99; 100) 'a': f64 | 303 | 99..100 'a': f64 |
304 | [121; 127) '[b, c]': [f64; _] | 304 | 121..127 '[b, c]': [f64; _] |
305 | [122; 123) 'b': f64 | 305 | 122..123 'b': f64 |
306 | [125; 126) 'c': f64 | 306 | 125..126 'c': f64 |
307 | [131; 172) '{ ... }': () | 307 | 131..172 '{ ... }': () |
308 | [145; 146) 'b': f64 | 308 | 145..146 'b': f64 |
309 | [160; 161) 'c': f64 | 309 | 160..161 'c': f64 |
310 | "### | 310 | "### |
311 | ); | 311 | ); |
312 | } | 312 | } |
@@ -339,31 +339,31 @@ fn test() { | |||
339 | } | 339 | } |
340 | "#), | 340 | "#), |
341 | @r###" | 341 | @r###" |
342 | [68; 289) '{ ... d; }': () | 342 | 68..289 '{ ... d; }': () |
343 | [78; 79) 'e': E | 343 | 78..79 'e': E |
344 | [82; 95) 'E::A { x: 3 }': E | 344 | 82..95 'E::A { x: 3 }': E |
345 | [92; 93) '3': usize | 345 | 92..93 '3': usize |
346 | [106; 113) 'S(y, z)': S | 346 | 106..113 'S(y, z)': S |
347 | [108; 109) 'y': u32 | 347 | 108..109 'y': u32 |
348 | [111; 112) 'z': E | 348 | 111..112 'z': E |
349 | [116; 119) 'foo': S | 349 | 116..119 'foo': S |
350 | [129; 148) 'E::A {..._var }': E | 350 | 129..148 'E::A {..._var }': E |
351 | [139; 146) 'new_var': usize | 351 | 139..146 'new_var': usize |
352 | [151; 152) 'e': E | 352 | 151..152 'e': E |
353 | [159; 245) 'match ... }': usize | 353 | 159..245 'match ... }': usize |
354 | [165; 166) 'e': E | 354 | 165..166 'e': E |
355 | [177; 187) 'E::A { x }': E | 355 | 177..187 'E::A { x }': E |
356 | [184; 185) 'x': usize | 356 | 184..185 'x': usize |
357 | [191; 192) 'x': usize | 357 | 191..192 'x': usize |
358 | [202; 206) 'E::B': E | 358 | 202..206 'E::B': E |
359 | [210; 213) 'foo': bool | 359 | 210..213 'foo': bool |
360 | [217; 218) '1': usize | 360 | 217..218 '1': usize |
361 | [228; 232) 'E::B': E | 361 | 228..232 'E::B': E |
362 | [236; 238) '10': usize | 362 | 236..238 '10': usize |
363 | [256; 275) 'ref d ...{ .. }': &E | 363 | 256..275 'ref d ...{ .. }': &E |
364 | [264; 275) 'E::A { .. }': E | 364 | 264..275 'E::A { .. }': E |
365 | [278; 279) 'e': E | 365 | 278..279 'e': E |
366 | [285; 286) 'd': &E | 366 | 285..286 'd': &E |
367 | "### | 367 | "### |
368 | ); | 368 | ); |
369 | } | 369 | } |
@@ -391,23 +391,23 @@ fn test(a1: A<u32>, o: Option<u64>) { | |||
391 | } | 391 | } |
392 | "#), | 392 | "#), |
393 | @r###" | 393 | @r###" |
394 | [79; 81) 'a1': A<u32> | 394 | 79..81 'a1': A<u32> |
395 | [91; 92) 'o': Option<u64> | 395 | 91..92 'o': Option<u64> |
396 | [107; 244) '{ ... }; }': () | 396 | 107..244 '{ ... }; }': () |
397 | [117; 128) 'A { x: x2 }': A<u32> | 397 | 117..128 'A { x: x2 }': A<u32> |
398 | [124; 126) 'x2': u32 | 398 | 124..126 'x2': u32 |
399 | [131; 133) 'a1': A<u32> | 399 | 131..133 'a1': A<u32> |
400 | [143; 161) 'A::<i6...: x3 }': A<i64> | 400 | 143..161 'A::<i6...: x3 }': A<i64> |
401 | [157; 159) 'x3': i64 | 401 | 157..159 'x3': i64 |
402 | [164; 174) 'A { x: 1 }': A<i64> | 402 | 164..174 'A { x: 1 }': A<i64> |
403 | [171; 172) '1': i64 | 403 | 171..172 '1': i64 |
404 | [180; 241) 'match ... }': u64 | 404 | 180..241 'match ... }': u64 |
405 | [186; 187) 'o': Option<u64> | 405 | 186..187 'o': Option<u64> |
406 | [198; 213) 'Option::Some(t)': Option<u64> | 406 | 198..213 'Option::Some(t)': Option<u64> |
407 | [211; 212) 't': u64 | 407 | 211..212 't': u64 |
408 | [217; 218) 't': u64 | 408 | 217..218 't': u64 |
409 | [228; 229) '_': Option<u64> | 409 | 228..229 '_': Option<u64> |
410 | [233; 234) '1': u64 | 410 | 233..234 '1': u64 |
411 | "### | 411 | "### |
412 | ); | 412 | ); |
413 | } | 413 | } |
@@ -431,27 +431,27 @@ fn test() { | |||
431 | } | 431 | } |
432 | "#, true), | 432 | "#, true), |
433 | @r###" | 433 | @r###" |
434 | [74; 75) '1': usize | 434 | 74..75 '1': usize |
435 | [88; 310) '{ ...atch }': () | 435 | 88..310 '{ ...atch }': () |
436 | [98; 99) 'a': Option<u32> | 436 | 98..99 'a': Option<u32> |
437 | [115; 119) 'None': Option<u32> | 437 | 115..119 'None': Option<u32> |
438 | [129; 130) 'b': Option<i64> | 438 | 129..130 'b': Option<i64> |
439 | [146; 183) 'match ... }': Option<i64> | 439 | 146..183 'match ... }': Option<i64> |
440 | [152; 153) 'a': Option<u32> | 440 | 152..153 'a': Option<u32> |
441 | [164; 168) 'None': Option<u32> | 441 | 164..168 'None': Option<u32> |
442 | [172; 176) 'None': Option<i64> | 442 | 172..176 'None': Option<i64> |
443 | [193; 194) '_': () | 443 | 193..194 '_': () |
444 | [201; 224) 'match ... Foo }': Foo | 444 | 201..224 'match ... Foo }': Foo |
445 | [207; 209) '()': () | 445 | 207..209 '()': () |
446 | [212; 215) 'Foo': Foo | 446 | 212..215 'Foo': Foo |
447 | [219; 222) 'Foo': Foo | 447 | 219..222 'Foo': Foo |
448 | [255; 256) '_': () | 448 | 255..256 '_': () |
449 | [263; 286) 'match ... Bar }': usize | 449 | 263..286 'match ... Bar }': usize |
450 | [269; 271) '()': () | 450 | 269..271 '()': () |
451 | [274; 277) 'Bar': usize | 451 | 274..277 'Bar': usize |
452 | [281; 284) 'Bar': usize | 452 | 281..284 'Bar': usize |
453 | [201; 224): expected (), got Foo | 453 | 201..224: expected (), got Foo |
454 | [263; 286): expected (), got usize | 454 | 263..286: expected (), got usize |
455 | "### | 455 | "### |
456 | ); | 456 | ); |
457 | } | 457 | } |
@@ -469,15 +469,15 @@ fn main() { | |||
469 | } | 469 | } |
470 | } | 470 | } |
471 | "#), @" | 471 | "#), @" |
472 | [28; 32) 'self': &S | 472 | 28..32 'self': &S |
473 | [42; 51) '{ false }': bool | 473 | 42..51 '{ false }': bool |
474 | [44; 49) 'false': bool | 474 | 44..49 'false': bool |
475 | [65; 116) '{ ... } }': () | 475 | 65..116 '{ ... } }': () |
476 | [71; 114) 'match ... }': () | 476 | 71..114 'match ... }': () |
477 | [77; 78) 'S': S | 477 | 77..78 'S': S |
478 | [89; 90) 's': S | 478 | 89..90 's': S |
479 | [94; 95) 's': S | 479 | 94..95 's': S |
480 | [94; 101) 's.foo()': bool | 480 | 94..101 's.foo()': bool |
481 | [105; 107) '()': () | 481 | 105..107 '()': () |
482 | ") | 482 | ") |
483 | } | 483 | } |
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 61a6801fc..8a1292c7a 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs | |||
@@ -14,11 +14,11 @@ fn test() { | |||
14 | } | 14 | } |
15 | "#), | 15 | "#), |
16 | @r###" | 16 | @r###" |
17 | [11; 37) '{ l... {}; }': () | 17 | 11..37 '{ l... {}; }': () |
18 | [20; 21) 'x': () | 18 | 20..21 'x': () |
19 | [24; 34) 'if true {}': () | 19 | 24..34 'if true {}': () |
20 | [27; 31) 'true': bool | 20 | 27..31 'true': bool |
21 | [32; 34) '{}': () | 21 | 32..34 '{}': () |
22 | "### | 22 | "### |
23 | ); | 23 | ); |
24 | } | 24 | } |
@@ -34,10 +34,10 @@ fn test(x: X) { | |||
34 | } | 34 | } |
35 | "#), | 35 | "#), |
36 | @r###" | 36 | @r###" |
37 | [20; 21) 'x': X | 37 | 20..21 'x': X |
38 | [26; 47) '{ ...eld; }': () | 38 | 26..47 '{ ...eld; }': () |
39 | [32; 33) 'x': X | 39 | 32..33 'x': X |
40 | [32; 44) 'x.some_field': {unknown} | 40 | 32..44 'x.some_field': {unknown} |
41 | "### | 41 | "### |
42 | ); | 42 | ); |
43 | } | 43 | } |
@@ -55,14 +55,14 @@ fn test() { | |||
55 | } | 55 | } |
56 | "#), | 56 | "#), |
57 | @r###" | 57 | @r###" |
58 | [11; 89) '{ ... } }': () | 58 | 11..89 '{ ... } }': () |
59 | [17; 21) 'X {}': {unknown} | 59 | 17..21 'X {}': {unknown} |
60 | [27; 87) 'match ... }': () | 60 | 27..87 'match ... }': () |
61 | [33; 34) 'x': {unknown} | 61 | 33..34 'x': {unknown} |
62 | [45; 52) 'A::B {}': {unknown} | 62 | 45..52 'A::B {}': {unknown} |
63 | [56; 58) '()': () | 63 | 56..58 '()': () |
64 | [68; 74) 'A::Y()': {unknown} | 64 | 68..74 'A::Y()': {unknown} |
65 | [78; 80) '()': () | 65 | 78..80 '()': () |
66 | "### | 66 | "### |
67 | ); | 67 | ); |
68 | } | 68 | } |
@@ -77,12 +77,12 @@ fn quux() { | |||
77 | } | 77 | } |
78 | "#), | 78 | "#), |
79 | @r###" | 79 | @r###" |
80 | [11; 41) '{ ...+ y; }': () | 80 | 11..41 '{ ...+ y; }': () |
81 | [21; 22) 'y': i32 | 81 | 21..22 'y': i32 |
82 | [25; 27) '92': i32 | 82 | 25..27 '92': i32 |
83 | [33; 34) '1': i32 | 83 | 33..34 '1': i32 |
84 | [33; 38) '1 + y': i32 | 84 | 33..38 '1 + y': i32 |
85 | [37; 38) 'y': i32 | 85 | 37..38 'y': i32 |
86 | "### | 86 | "### |
87 | ); | 87 | ); |
88 | } | 88 | } |
@@ -99,13 +99,13 @@ fn test() { | |||
99 | } | 99 | } |
100 | "#), | 100 | "#), |
101 | @r###" | 101 | @r###" |
102 | [11; 48) '{ ...&y]; }': () | 102 | 11..48 '{ ...&y]; }': () |
103 | [21; 22) 'y': &{unknown} | 103 | 21..22 'y': &{unknown} |
104 | [25; 32) 'unknown': &{unknown} | 104 | 25..32 'unknown': &{unknown} |
105 | [38; 45) '[y, &y]': [&&{unknown}; _] | 105 | 38..45 '[y, &y]': [&&{unknown}; _] |
106 | [39; 40) 'y': &{unknown} | 106 | 39..40 'y': &{unknown} |
107 | [42; 44) '&y': &&{unknown} | 107 | 42..44 '&y': &&{unknown} |
108 | [43; 44) 'y': &{unknown} | 108 | 43..44 'y': &{unknown} |
109 | "### | 109 | "### |
110 | ); | 110 | ); |
111 | } | 111 | } |
@@ -123,20 +123,20 @@ fn test() { | |||
123 | } | 123 | } |
124 | "#), | 124 | "#), |
125 | @r###" | 125 | @r###" |
126 | [11; 80) '{ ...x)]; }': () | 126 | 11..80 '{ ...x)]; }': () |
127 | [21; 22) 'x': &&{unknown} | 127 | 21..22 'x': &&{unknown} |
128 | [25; 32) 'unknown': &&{unknown} | 128 | 25..32 'unknown': &&{unknown} |
129 | [42; 43) 'y': &&{unknown} | 129 | 42..43 'y': &&{unknown} |
130 | [46; 53) 'unknown': &&{unknown} | 130 | 46..53 'unknown': &&{unknown} |
131 | [59; 77) '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _] | 131 | 59..77 '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _] |
132 | [60; 66) '(x, y)': (&&&{unknown}, &&&{unknown}) | 132 | 60..66 '(x, y)': (&&&{unknown}, &&&{unknown}) |
133 | [61; 62) 'x': &&{unknown} | 133 | 61..62 'x': &&{unknown} |
134 | [64; 65) 'y': &&{unknown} | 134 | 64..65 'y': &&{unknown} |
135 | [68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown}) | 135 | 68..76 '(&y, &x)': (&&&{unknown}, &&&{unknown}) |
136 | [69; 71) '&y': &&&{unknown} | 136 | 69..71 '&y': &&&{unknown} |
137 | [70; 71) 'y': &&{unknown} | 137 | 70..71 'y': &&{unknown} |
138 | [73; 75) '&x': &&&{unknown} | 138 | 73..75 '&x': &&&{unknown} |
139 | [74; 75) 'x': &&{unknown} | 139 | 74..75 'x': &&{unknown} |
140 | "### | 140 | "### |
141 | ); | 141 | ); |
142 | } | 142 | } |
@@ -158,12 +158,12 @@ fn write() { | |||
158 | } | 158 | } |
159 | "#), | 159 | "#), |
160 | @r###" | 160 | @r###" |
161 | [54; 139) '{ ... } }': () | 161 | 54..139 '{ ... } }': () |
162 | [60; 137) 'match ... }': () | 162 | 60..137 'match ... }': () |
163 | [66; 83) 'someth...nknown': Maybe<{unknown}> | 163 | 66..83 'someth...nknown': Maybe<{unknown}> |
164 | [94; 124) 'Maybe:...thing)': Maybe<{unknown}> | 164 | 94..124 'Maybe:...thing)': Maybe<{unknown}> |
165 | [106; 123) 'ref mu...ething': &mut {unknown} | 165 | 106..123 'ref mu...ething': &mut {unknown} |
166 | [128; 130) '()': () | 166 | 128..130 '()': () |
167 | "### | 167 | "### |
168 | ); | 168 | ); |
169 | } | 169 | } |
@@ -179,13 +179,13 @@ fn test_line_buffer() { | |||
179 | } | 179 | } |
180 | "#), | 180 | "#), |
181 | @r###" | 181 | @r###" |
182 | [23; 53) '{ ...n']; }': () | 182 | 23..53 '{ ...n']; }': () |
183 | [29; 50) '&[0, b...b'\n']': &[u8; _] | 183 | 29..50 '&[0, b...b'\n']': &[u8; _] |
184 | [30; 50) '[0, b'...b'\n']': [u8; _] | 184 | 30..50 '[0, b'...b'\n']': [u8; _] |
185 | [31; 32) '0': u8 | 185 | 31..32 '0': u8 |
186 | [34; 39) 'b'\n'': u8 | 186 | 34..39 'b'\n'': u8 |
187 | [41; 42) '1': u8 | 187 | 41..42 '1': u8 |
188 | [44; 49) 'b'\n'': u8 | 188 | 44..49 'b'\n'': u8 |
189 | "### | 189 | "### |
190 | ); | 190 | ); |
191 | } | 191 | } |
@@ -202,14 +202,14 @@ pub fn compute() { | |||
202 | } | 202 | } |
203 | "#), | 203 | "#), |
204 | @r###" | 204 | @r###" |
205 | [18; 108) '{ ... } }': () | 205 | 18..108 '{ ... } }': () |
206 | [24; 106) 'match ... }': () | 206 | 24..106 'match ... }': () |
207 | [30; 37) 'nope!()': {unknown} | 207 | 30..37 'nope!()': {unknown} |
208 | [48; 94) 'SizeSk...tail }': {unknown} | 208 | 48..94 'SizeSk...tail }': {unknown} |
209 | [82; 86) 'true': bool | 209 | 82..86 'true': bool |
210 | [82; 86) 'true': bool | 210 | 82..86 'true': bool |
211 | [88; 92) 'tail': {unknown} | 211 | 88..92 'tail': {unknown} |
212 | [98; 100) '{}': () | 212 | 98..100 '{}': () |
213 | "### | 213 | "### |
214 | ); | 214 | ); |
215 | } | 215 | } |
@@ -226,14 +226,14 @@ pub fn primitive_type() { | |||
226 | } | 226 | } |
227 | "#), | 227 | "#), |
228 | @r###" | 228 | @r###" |
229 | [25; 106) '{ ... } }': () | 229 | 25..106 '{ ... } }': () |
230 | [31; 104) 'match ... }': () | 230 | 31..104 'match ... }': () |
231 | [37; 42) '*self': {unknown} | 231 | 37..42 '*self': {unknown} |
232 | [38; 42) 'self': {unknown} | 232 | 38..42 'self': {unknown} |
233 | [53; 91) 'Borrow...), ..}': {unknown} | 233 | 53..91 'Borrow...), ..}': {unknown} |
234 | [74; 86) 'Primitive(p)': {unknown} | 234 | 74..86 'Primitive(p)': {unknown} |
235 | [84; 85) 'p': {unknown} | 235 | 84..85 'p': {unknown} |
236 | [95; 97) '{}': () | 236 | 95..97 '{}': () |
237 | "### | 237 | "### |
238 | ); | 238 | ); |
239 | } | 239 | } |
@@ -260,29 +260,29 @@ fn extra_compiler_flags() { | |||
260 | } | 260 | } |
261 | "#), | 261 | "#), |
262 | @r###" | 262 | @r###" |
263 | [27; 323) '{ ... } }': () | 263 | 27..323 '{ ... } }': () |
264 | [33; 321) 'for co... }': () | 264 | 33..321 'for co... }': () |
265 | [37; 44) 'content': &{unknown} | 265 | 37..44 'content': &{unknown} |
266 | [48; 61) 'doesnt_matter': {unknown} | 266 | 48..61 'doesnt_matter': {unknown} |
267 | [62; 321) '{ ... }': () | 267 | 62..321 '{ ... }': () |
268 | [76; 80) 'name': &&{unknown} | 268 | 76..80 'name': &&{unknown} |
269 | [83; 167) 'if doe... }': &&{unknown} | 269 | 83..167 'if doe... }': &&{unknown} |
270 | [86; 99) 'doesnt_matter': bool | 270 | 86..99 'doesnt_matter': bool |
271 | [100; 129) '{ ... }': &&{unknown} | 271 | 100..129 '{ ... }': &&{unknown} |
272 | [114; 119) 'first': &&{unknown} | 272 | 114..119 'first': &&{unknown} |
273 | [135; 167) '{ ... }': &&{unknown} | 273 | 135..167 '{ ... }': &&{unknown} |
274 | [149; 157) '&content': &&{unknown} | 274 | 149..157 '&content': &&{unknown} |
275 | [150; 157) 'content': &{unknown} | 275 | 150..157 'content': &{unknown} |
276 | [182; 189) 'content': &{unknown} | 276 | 182..189 'content': &{unknown} |
277 | [192; 314) 'if ICE... }': &{unknown} | 277 | 192..314 'if ICE... }': &{unknown} |
278 | [195; 232) 'ICE_RE..._VALUE': {unknown} | 278 | 195..232 'ICE_RE..._VALUE': {unknown} |
279 | [195; 248) 'ICE_RE...&name)': bool | 279 | 195..248 'ICE_RE...&name)': bool |
280 | [242; 247) '&name': &&&{unknown} | 280 | 242..247 '&name': &&&{unknown} |
281 | [243; 247) 'name': &&{unknown} | 281 | 243..247 'name': &&{unknown} |
282 | [249; 277) '{ ... }': &&{unknown} | 282 | 249..277 '{ ... }': &&{unknown} |
283 | [263; 267) 'name': &&{unknown} | 283 | 263..267 'name': &&{unknown} |
284 | [283; 314) '{ ... }': &{unknown} | 284 | 283..314 '{ ... }': &{unknown} |
285 | [297; 304) 'content': &{unknown} | 285 | 297..304 'content': &{unknown} |
286 | "### | 286 | "### |
287 | ); | 287 | ); |
288 | } | 288 | } |
@@ -303,11 +303,11 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) { | |||
303 | } | 303 | } |
304 | "#), | 304 | "#), |
305 | @r###" | 305 | @r###" |
306 | [92; 106) 'query_response': Canonical<QueryResponse<R>> | 306 | 92..106 'query_response': Canonical<QueryResponse<R>> |
307 | [137; 167) '{ ...lue; }': () | 307 | 137..167 '{ ...lue; }': () |
308 | [143; 164) '&query....value': &QueryResponse<R> | 308 | 143..164 '&query....value': &QueryResponse<R> |
309 | [144; 158) 'query_response': Canonical<QueryResponse<R>> | 309 | 144..158 'query_response': Canonical<QueryResponse<R>> |
310 | [144; 164) 'query_....value': QueryResponse<R> | 310 | 144..164 'query_....value': QueryResponse<R> |
311 | "### | 311 | "### |
312 | ); | 312 | ); |
313 | } | 313 | } |
@@ -322,9 +322,9 @@ fn test() { | |||
322 | } | 322 | } |
323 | "#), | 323 | "#), |
324 | @r###" | 324 | @r###" |
325 | ![0; 4) '0u32': u32 | 325 | !0..4 '0u32': u32 |
326 | [45; 70) '{ ...()); }': () | 326 | 45..70 '{ ...()); }': () |
327 | [55; 56) 'a': u32 | 327 | 55..56 'a': u32 |
328 | "### |