Skip to content

Commit

Permalink
⬆️ rust-analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Aug 16, 2022
1 parent 22c8c9c commit 8231fee
Show file tree
Hide file tree
Showing 111 changed files with 5,774 additions and 5,108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: Install Nodejs
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x

- name: Install xvfb
if: matrix.os == 'ubuntu-latest'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x

- name: Update apt repositories
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf'
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
container:
image: rust:alpine
volumes:
- /usr/local/cargo/registry
- /usr/local/cargo/registry:/usr/local/cargo/registry

steps:
- name: Install dependencies
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
- name: Install Nodejs
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x

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

- name: Publish Extension (OpenVSX, nightly)
if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
working-directory: ./editors/code
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extension", "matklad.rust-analyzer",
"--disable-extension", "rust-lang.rust-analyzer",
"--extensionDevelopmentPath=${workspaceFolder}/editors/code"
],
"outFiles": [
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
//! actual IO is done and lowered to input.

use std::{fmt, iter::FromIterator, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
use std::{fmt, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};

use cfg::CfgOptions;
use rustc_hash::{FxHashMap, FxHashSet};
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ fn test_concat_expand() {
#[rustc_builtin_macro]
macro_rules! concat {}
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false); }
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
"##,
expect![[r##"
#[rustc_builtin_macro]
macro_rules! concat {}
fn main() { "foor0bar\nfalse"; }
fn main() { "foor0bar\nfalse\"\u{0}"; }
"##]],
);
}
Expand Down
12 changes: 6 additions & 6 deletions crates/hir-def/src/macro_expansion_tests/mbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ macro_rules! m {
($t:ty) => ( fn bar() -> $ t {} )
}
fn bar() -> & 'a Baz<u8> {}
fn bar() -> &'a Baz<u8> {}
fn bar() -> extern "Rust"fn() -> Ret {}
"#]],
Expand Down Expand Up @@ -1578,7 +1578,7 @@ macro_rules !register_methods {
($$($val: expr), *) = > {
struct Foo;
impl Foo {
$(fn $method()-> & 'static[u32] {
$(fn $method()-> &'static[u32] {
&[$$($$val), *]
}
)*
Expand All @@ -1591,21 +1591,21 @@ macro_rules !implement_methods {
($($val: expr), *) = > {
struct Foo;
impl Foo {
fn alpha()-> & 'static[u32] {
fn alpha()-> &'static[u32] {
&[$($val), *]
}
fn beta()-> & 'static[u32] {
fn beta()-> &'static[u32] {
&[$($val), *]
}
}
}
}
struct Foo;
impl Foo {
fn alpha() -> & 'static[u32] {
fn alpha() -> &'static[u32] {
&[1, 2, 3]
}
fn beta() -> & 'static[u32] {
fn beta() -> &'static[u32] {
&[1, 2, 3]
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ macro_rules! int_base {
}
}
#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Binary for isize {
fn fmt(&self , f: &mut fmt::Formatter< '_>) -> fmt::Result {
fn fmt(&self , f: &mut fmt::Formatter<'_>) -> fmt::Result {
Binary.fmt_int(*self as usize, f)
}
}
Expand Down Expand Up @@ -724,7 +724,7 @@ macro_rules! delegate_impl {
}
}
}
impl <> Data for & 'amut G where G: Data {}
impl <> Data for &'amut G where G: Data {}
"##]],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ m!(static bar: &'static str = "hello";);
macro_rules! m {
($($t:tt)*) => { $($t)*}
}
static bar: & 'static str = "hello";
static bar: &'static str = "hello";
"#]],
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/macro_expansion_tests/proc_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn foo() { bar.; blub }
fn foo() { bar.; blub }
fn foo() {
bar. ;
bar.;
blub
}"##]],
);
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-def/src/nameres/mod_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ impl ModDir {
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
}
None if file_id.is_include_macro(db.upcast()) => {
let name = name.unescaped();
candidate_files.push(format!("{}.rs", name));
candidate_files.push(format!("{}/mod.rs", name));
}
None => {
let name = name.unescaped();
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/nameres/tests/mod_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ pub struct Bar;
expect![[r#"
crate
Bar: t v
async: t
r#async: t
crate::async
crate::r#async
Bar: t v
"#]],
);
Expand Down
22 changes: 18 additions & 4 deletions crates/hir-expand/src/builtin_fn_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ fn format_args_expand(
}
for arg in &mut args {
// Remove `key =`.
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' && p.spacing != tt::Spacing::Joint)
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=')
{
arg.token_trees.drain(..2);
// but not with `==`
if !matches!(arg.token_trees.get(2), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' )
{
arg.token_trees.drain(..2);
}
}
}
let _format_string = args.remove(0);
Expand Down Expand Up @@ -357,6 +361,12 @@ fn unquote_str(lit: &tt::Literal) -> Option<String> {
token.value().map(|it| it.into_owned())
}

fn unquote_char(lit: &tt::Literal) -> Option<char> {
let lit = ast::make::tokens::literal(&lit.to_string());
let token = ast::Char::cast(lit)?;
token.value()
}

fn unquote_byte_string(lit: &tt::Literal) -> Option<Vec<u8>> {
let lit = ast::make::tokens::literal(&lit.to_string());
let token = ast::ByteString::cast(lit)?;
Expand Down Expand Up @@ -408,8 +418,12 @@ fn concat_expand(
// concat works with string and char literals, so remove any quotes.
// It also works with integer, float and boolean literals, so just use the rest
// as-is.
let component = unquote_str(it).unwrap_or_else(|| it.text.to_string());
text.push_str(&component);
if let Some(c) = unquote_char(it) {
text.push(c);
} else {
let component = unquote_str(it).unwrap_or_else(|| it.text.to_string());
text.push_str(&component);
}
}
// handle boolean literals
tt::TokenTree::Leaf(tt::Leaf::Ident(id))
Expand Down
Loading

0 comments on commit 8231fee

Please sign in to comment.