Skip to content

Commit 1d23d3a

Browse files
authored
Rollup merge of rust-lang#100616 - lnicola:rust-analyzer-2022-08-16, r=lnicola
⬆️ rust-analyzer r? `@ghost`
2 parents 04dd369 + a06da98 commit 1d23d3a

File tree

111 files changed

+5774
-5108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+5774
-5108
lines changed

src/tools/rust-analyzer/.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
- name: Install Nodejs
102102
uses: actions/setup-node@v1
103103
with:
104-
node-version: 14.x
104+
node-version: 16.x
105105

106106
- name: Install xvfb
107107
if: matrix.os == 'ubuntu-latest'

src/tools/rust-analyzer/.github/workflows/release.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Install Node.js
6969
uses: actions/setup-node@v1
7070
with:
71-
node-version: 14.x
71+
node-version: 16.x
7272

7373
- name: Update apt repositories
7474
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf'
@@ -133,7 +133,7 @@ jobs:
133133
container:
134134
image: rust:alpine
135135
volumes:
136-
- /usr/local/cargo/registry
136+
- /usr/local/cargo/registry:/usr/local/cargo/registry
137137

138138
steps:
139139
- name: Install dependencies
@@ -176,7 +176,7 @@ jobs:
176176
- name: Install Nodejs
177177
uses: actions/setup-node@v1
178178
with:
179-
node-version: 14.x
179+
node-version: 16.x
180180

181181
- run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
182182
if: github.ref == 'refs/heads/release'
@@ -253,9 +253,9 @@ jobs:
253253
- name: Publish Extension (Code Marketplace, nightly)
254254
if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
255255
working-directory: ./editors/code
256-
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release
256+
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
257257

258258
- name: Publish Extension (OpenVSX, nightly)
259259
if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
260260
working-directory: ./editors/code
261-
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release
261+
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix

src/tools/rust-analyzer/.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"request": "launch",
7979
"runtimeExecutable": "${execPath}",
8080
"args": [
81-
"--disable-extension", "matklad.rust-analyzer",
81+
"--disable-extension", "rust-lang.rust-analyzer",
8282
"--extensionDevelopmentPath=${workspaceFolder}/editors/code"
8383
],
8484
"outFiles": [

src/tools/rust-analyzer/Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ dependencies = [
710710
"ide-db",
711711
"itertools",
712712
"profile",
713+
"serde_json",
713714
"sourcegen",
714715
"stdx",
715716
"syntax",

src/tools/rust-analyzer/crates/base-db/src/input.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
77
//! actual IO is done and lowered to input.
88
9-
use std::{fmt, iter::FromIterator, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
9+
use std::{fmt, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
1010

1111
use cfg::CfgOptions;
1212
use rustc_hash::{FxHashMap, FxHashSet};

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ fn test_concat_expand() {
295295
#[rustc_builtin_macro]
296296
macro_rules! concat {}
297297
298-
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false); }
298+
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
299299
"##,
300300
expect![[r##"
301301
#[rustc_builtin_macro]
302302
macro_rules! concat {}
303303
304-
fn main() { "foor0bar\nfalse"; }
304+
fn main() { "foor0bar\nfalse\"\u{0}"; }
305305
"##]],
306306
);
307307
}

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ macro_rules! m {
885885
($t:ty) => ( fn bar() -> $ t {} )
886886
}
887887
888-
fn bar() -> & 'a Baz<u8> {}
888+
fn bar() -> &'a Baz<u8> {}
889889
890890
fn bar() -> extern "Rust"fn() -> Ret {}
891891
"#]],
@@ -1578,7 +1578,7 @@ macro_rules !register_methods {
15781578
($$($val: expr), *) = > {
15791579
struct Foo;
15801580
impl Foo {
1581-
$(fn $method()-> & 'static[u32] {
1581+
$(fn $method()-> &'static[u32] {
15821582
&[$$($$val), *]
15831583
}
15841584
)*
@@ -1591,21 +1591,21 @@ macro_rules !implement_methods {
15911591
($($val: expr), *) = > {
15921592
struct Foo;
15931593
impl Foo {
1594-
fn alpha()-> & 'static[u32] {
1594+
fn alpha()-> &'static[u32] {
15951595
&[$($val), *]
15961596
}
1597-
fn beta()-> & 'static[u32] {
1597+
fn beta()-> &'static[u32] {
15981598
&[$($val), *]
15991599
}
16001600
}
16011601
}
16021602
}
16031603
struct Foo;
16041604
impl Foo {
1605-
fn alpha() -> & 'static[u32] {
1605+
fn alpha() -> &'static[u32] {
16061606
&[1, 2, 3]
16071607
}
1608-
fn beta() -> & 'static[u32] {
1608+
fn beta() -> &'static[u32] {
16091609
&[1, 2, 3]
16101610
}
16111611
}

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ macro_rules! int_base {
166166
}
167167
}
168168
#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Binary for isize {
169-
fn fmt(&self , f: &mut fmt::Formatter< '_>) -> fmt::Result {
169+
fn fmt(&self , f: &mut fmt::Formatter<'_>) -> fmt::Result {
170170
Binary.fmt_int(*self as usize, f)
171171
}
172172
}
@@ -724,7 +724,7 @@ macro_rules! delegate_impl {
724724
}
725725
}
726726
}
727-
impl <> Data for & 'amut G where G: Data {}
727+
impl <> Data for &'amut G where G: Data {}
728728
"##]],
729729
);
730730
}

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ m!(static bar: &'static str = "hello";);
7878
macro_rules! m {
7979
($($t:tt)*) => { $($t)*}
8080
}
81-
static bar: & 'static str = "hello";
81+
static bar: &'static str = "hello";
8282
"#]],
8383
);
8484
}

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn foo() { bar.; blub }
8787
fn foo() { bar.; blub }
8888
8989
fn foo() {
90-
bar. ;
90+
bar.;
9191
blub
9292
}"##]],
9393
);

src/tools/rust-analyzer/crates/hir-def/src/nameres/mod_resolution.rs

+2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ impl ModDir {
7373
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
7474
}
7575
None if file_id.is_include_macro(db.upcast()) => {
76+
let name = name.unescaped();
7677
candidate_files.push(format!("{}.rs", name));
7778
candidate_files.push(format!("{}/mod.rs", name));
7879
}
7980
None => {
81+
let name = name.unescaped();
8082
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
8183
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
8284
}

src/tools/rust-analyzer/crates/hir-def/src/nameres/tests/mod_resolution.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ pub struct Bar;
132132
expect![[r#"
133133
crate
134134
Bar: t v
135-
async: t
135+
r#async: t
136136
137-
crate::async
137+
crate::r#async
138138
Bar: t v
139139
"#]],
140140
);

src/tools/rust-analyzer/crates/hir-expand/src/builtin_fn_macro.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,13 @@ fn format_args_expand(
251251
}
252252
for arg in &mut args {
253253
// Remove `key =`.
254-
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' && p.spacing != tt::Spacing::Joint)
254+
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=')
255255
{
256-
arg.token_trees.drain(..2);
256+
// but not with `==`
257+
if !matches!(arg.token_trees.get(2), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' )
258+
{
259+
arg.token_trees.drain(..2);
260+
}
257261
}
258262
}
259263
let _format_string = args.remove(0);
@@ -357,6 +361,12 @@ fn unquote_str(lit: &tt::Literal) -> Option<String> {
357361
token.value().map(|it| it.into_owned())
358362
}
359363

364+
fn unquote_char(lit: &tt::Literal) -> Option<char> {
365+
let lit = ast::make::tokens::literal(&lit.to_string());
366+
let token = ast::Char::cast(lit)?;
367+
token.value()
368+
}
369+
360370
fn unquote_byte_string(lit: &tt::Literal) -> Option<Vec<u8>> {
361371
let lit = ast::make::tokens::literal(&lit.to_string());
362372
let token = ast::ByteString::cast(lit)?;
@@ -408,8 +418,12 @@ fn concat_expand(
408418
// concat works with string and char literals, so remove any quotes.
409419
// It also works with integer, float and boolean literals, so just use the rest
410420
// as-is.
411-
let component = unquote_str(it).unwrap_or_else(|| it.text.to_string());
412-
text.push_str(&component);
421+
if let Some(c) = unquote_char(it) {
422+
text.push(c);
423+
} else {
424+
let component = unquote_str(it).unwrap_or_else(|| it.text.to_string());
425+
text.push_str(&component);
426+
}
413427
}
414428
// handle boolean literals
415429
tt::TokenTree::Leaf(tt::Leaf::Ident(id))

0 commit comments

Comments
 (0)