aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide/src/references/rename.rs11
-rw-r--r--crates/parser/src/grammar/items.rs10
-rw-r--r--crates/syntax/test_data/parser/ok/0068_item_modifiers.rast16
-rw-r--r--crates/syntax/test_data/parser/ok/0068_item_modifiers.rs2
-rw-r--r--editors/code/rust.tmGrammar.json2
5 files changed, 31 insertions, 10 deletions
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs
index b8725693a..91c64bd4a 100644
--- a/crates/ide/src/references/rename.rs
+++ b/crates/ide/src/references/rename.rs
@@ -1,4 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use std::{
3 convert::TryInto,
4 error::Error,
5 fmt::{self, Display},
6};
2 7
3use hir::{Module, ModuleDef, ModuleSource, Semantics}; 8use hir::{Module, ModuleDef, ModuleSource, Semantics};
4use ide_db::base_db::{FileRange, SourceDatabaseExt}; 9use ide_db::base_db::{FileRange, SourceDatabaseExt};
@@ -6,12 +11,6 @@ use ide_db::{
6 defs::{Definition, NameClass, NameRefClass}, 11 defs::{Definition, NameClass, NameRefClass},
7 RootDatabase, 12 RootDatabase,
8}; 13};
9
10use std::{
11 convert::TryInto,
12 error::Error,
13 fmt::{self, Display},
14};
15use syntax::{ 14use syntax::{
16 algo::find_node_at_offset, 15 algo::find_node_at_offset,
17 ast::{self, NameOwner}, 16 ast::{self, NameOwner},
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 780bc470a..ad29b82f7 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -112,7 +112,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
112 has_mods = true; 112 has_mods = true;
113 } 113 }
114 114
115 if p.at(T![extern]) { 115 if p.at(T![extern]) && p.nth(1) != T!['{'] && (p.nth(1) != STRING || p.nth(2) != T!['{']) {
116 has_mods = true; 116 has_mods = true;
117 abi(p); 117 abi(p);
118 } 118 }
@@ -181,6 +181,14 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
181 T![type] => { 181 T![type] => {
182 type_alias(p, m); 182 type_alias(p, m);
183 } 183 }
184
185 // unsafe extern "C" {}
186 T![extern] => {
187 abi(p);
188 extern_item_list(p);
189 m.complete(p, EXTERN_BLOCK);
190 }
191
184 _ => { 192 _ => {
185 if !has_visibility && !has_mods { 193 if !has_visibility && !has_mods {
186 return Err(m); 194 return Err(m);
diff --git a/crates/syntax/test_data/parser/ok/0068_item_modifiers.rast b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rast
index 50a6d8ee9..87eebf185 100644
--- a/crates/syntax/test_data/parser/ok/0068_item_modifiers.rast
+++ b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rast
@@ -1,4 +1,4 @@
1[email protected]04 1[email protected]28
2 [email protected] 2 [email protected]
3 [email protected] "async" 3 [email protected] "async"
4 [email protected] " " 4 [email protected] " "
@@ -215,4 +215,16 @@ [email protected]
215 [email protected] 215 [email protected]
216 [email protected] "{" 216 [email protected] "{"
217 [email protected] "}" 217 [email protected] "}"
218 [email protected] "\n" 218 [email protected] "\n\n"
219 [email protected]
220 [email protected] "unsafe"
221 [email protected] " "
222 [email protected]
223 [email protected] "extern"
224 [email protected] " "
225 [email protected] "\"C++\""
226 [email protected] " "
227 [email protected]
228 [email protected] "{"
229 [email protected] "}"
230 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/ok/0068_item_modifiers.rs b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rs
index 8d697c04b..6d27a082c 100644
--- a/crates/syntax/test_data/parser/ok/0068_item_modifiers.rs
+++ b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rs
@@ -14,3 +14,5 @@ unsafe auto trait T {}
14unsafe impl Foo {} 14unsafe impl Foo {}
15default impl Foo {} 15default impl Foo {}
16unsafe default impl Foo {} 16unsafe default impl Foo {}
17
18unsafe extern "C++" {}
diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json
index cd4775d27..4759bb116 100644
--- a/editors/code/rust.tmGrammar.json
+++ b/editors/code/rust.tmGrammar.json
@@ -409,7 +409,7 @@
409 { 409 {
410 "comment": "booleans", 410 "comment": "booleans",
411 "name": "constant.language.bool.rust", 411 "name": "constant.language.bool.rust",
412 "match": "\\btrue|false\\b" 412 "match": "\\b(true|false)\\b"
413 } 413 }
414 ] 414 ]
415 }, 415 },