Skip to content

Commit

Permalink
Improve autocompletion by looking on the type and name
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
  • Loading branch information
bnjjj committed Apr 11, 2020
2 parents d42346f + fd06fe7 commit f62fe8d
Show file tree
Hide file tree
Showing 287 changed files with 3,917 additions and 5,414 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/ci.yaml
Expand Up @@ -20,25 +20,14 @@ jobs:
name: Audit Rust vulnerabilities
runs-on: ubuntu-latest
steps:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Checkout repository
uses: actions/checkout@v2

- run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/

- name: Cache cargo
uses: actions/cache@v1
- uses: actions-rs/install@v0.1
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
crate: cargo-audit
use-tool-cache: true

- run: cargo install cargo-audit
- run: cargo audit

rust:
Expand Down
76 changes: 66 additions & 10 deletions Cargo.lock

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

17 changes: 16 additions & 1 deletion crates/ra_assists/src/doc_tests/generated.rs
Expand Up @@ -180,7 +180,7 @@ trait Trait<T> {
}
impl Trait<u32> for () {
fn foo(&self) -> u32 { unimplemented!() }
fn foo(&self) -> u32 { todo!() }
}
"#####,
Expand Down Expand Up @@ -606,6 +606,21 @@ impl Walrus {
)
}

#[test]
fn doctest_reorder_fields() {
check(
"reorder_fields",
r#####"
struct Foo {foo: i32, bar: i32};
const test: Foo = <|>Foo {bar: 0, foo: 1}
"#####,
r#####"
struct Foo {foo: i32, bar: i32};
const test: Foo = Foo {foo: 1, bar: 0}
"#####,
)
}

#[test]
fn doctest_replace_if_let_with_match() {
check(
Expand Down
4 changes: 2 additions & 2 deletions crates/ra_assists/src/handlers/add_impl.rs
@@ -1,5 +1,5 @@
use ra_syntax::{
ast::{self, AstNode, AstToken, NameOwner, TypeParamsOwner},
ast::{self, AstNode, NameOwner, TypeParamsOwner},
TextUnit,
};
use stdx::{format_to, SepBy};
Expand Down Expand Up @@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> {
if let Some(type_params) = type_params {
let lifetime_params = type_params
.lifetime_params()
.filter_map(|it| it.lifetime())
.filter_map(|it| it.lifetime_token())
.map(|it| it.text().clone());
let type_params =
type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
Expand Down
34 changes: 17 additions & 17 deletions crates/ra_assists/src/handlers/add_missing_impl_members.rs
Expand Up @@ -40,7 +40,7 @@ enum AddMissingImplMembersMode {
// }
//
// impl Trait<u32> for () {
// fn foo(&self) -> u32 { unimplemented!() }
// fn foo(&self) -> u32 { todo!() }
//
// }
// ```
Expand Down Expand Up @@ -165,7 +165,7 @@ fn add_missing_impl_members_inner(

fn add_body(fn_def: ast::FnDef) -> ast::FnDef {
if fn_def.body().is_none() {
fn_def.with_body(make::block_from_expr(make::expr_unimplemented()))
fn_def.with_body(make::block_from_expr(make::expr_todo()))
} else {
fn_def
}
Expand Down Expand Up @@ -215,8 +215,8 @@ impl Foo for S {
fn bar(&self) {}
<|>type Output;
const CONST: usize = 42;
fn foo(&self) { unimplemented!() }
fn baz(&self) { unimplemented!() }
fn foo(&self) { todo!() }
fn baz(&self) { todo!() }
}",
);
Expand Down Expand Up @@ -250,7 +250,7 @@ struct S;
impl Foo for S {
fn bar(&self) {}
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }
}",
);
Expand All @@ -268,7 +268,7 @@ impl Foo for S { <|> }",
trait Foo { fn foo(&self); }
struct S;
impl Foo for S {
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }
}",
);
}
Expand All @@ -285,7 +285,7 @@ impl Foo<u32> for S { <|> }",
trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S;
impl Foo<u32> for S {
<|>fn foo(&self, t: u32) -> &u32 { unimplemented!() }
<|>fn foo(&self, t: u32) -> &u32 { todo!() }
}",
);
}
Expand All @@ -302,7 +302,7 @@ impl<U> Foo<U> for S { <|> }",
trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S;
impl<U> Foo<U> for S {
<|>fn foo(&self, t: U) -> &U { unimplemented!() }
<|>fn foo(&self, t: U) -> &U { todo!() }
}",
);
}
Expand All @@ -319,7 +319,7 @@ impl Foo for S {}<|>",
trait Foo { fn foo(&self); }
struct S;
impl Foo for S {
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }
}",
)
}
Expand All @@ -342,7 +342,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar) { todo!() }
}",
);
}
Expand All @@ -365,7 +365,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<u32>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>) { todo!() }
}",
);
}
Expand All @@ -388,7 +388,7 @@ mod foo {
}
struct S;
impl foo::Foo<u32> for S {
<|>fn foo(&self, bar: foo::Bar<u32>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>) { todo!() }
}",
);
}
Expand All @@ -414,7 +414,7 @@ mod foo {
struct Param;
struct S;
impl foo::Foo<Param> for S {
<|>fn foo(&self, bar: Param) { unimplemented!() }
<|>fn foo(&self, bar: Param) { todo!() }
}",
);
}
Expand All @@ -439,7 +439,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<u32>::Assoc) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>::Assoc) { todo!() }
}",
);
}
Expand All @@ -464,7 +464,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<foo::Baz>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<foo::Baz>) { todo!() }
}",
);
}
Expand All @@ -487,7 +487,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: dyn Fn(u32) -> i32) { unimplemented!() }
<|>fn foo(&self, bar: dyn Fn(u32) -> i32) { todo!() }
}",
);
}
Expand Down Expand Up @@ -544,7 +544,7 @@ trait Foo {
struct S;
impl Foo for S {
<|>type Output;
fn foo(&self) { unimplemented!() }
fn foo(&self) { todo!() }
}"#,
)
}
Expand Down

0 comments on commit f62fe8d

Please sign in to comment.