diff options
-rw-r--r-- | .github/workflows/ci.yaml | 36 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 25 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 15 |
3 files changed, 54 insertions, 22 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a5a4b3ccd..c915b9d14 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml | |||
@@ -34,7 +34,7 @@ jobs: | |||
34 | name: Rust | 34 | name: Rust |
35 | runs-on: ${{ matrix.os }} | 35 | runs-on: ${{ matrix.os }} |
36 | env: | 36 | env: |
37 | CC: deny_c | 37 | CC: deny_c |
38 | 38 | ||
39 | strategy: | 39 | strategy: |
40 | fail-fast: false | 40 | fail-fast: false |
@@ -64,20 +64,16 @@ jobs: | |||
64 | - if: matrix.os == 'ubuntu-latest' | 64 | - if: matrix.os == 'ubuntu-latest' |
65 | run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ | 65 | run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ |
66 | 66 | ||
67 | - name: Cache cargo registry | 67 | - name: Cache cargo directories |
68 | uses: actions/cache@v1 | 68 | uses: actions/cache@v2 |
69 | with: | 69 | with: |
70 | path: ~/.cargo/registry | 70 | path: | |
71 | key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | 71 | ~/.cargo/registry |
72 | 72 | ~/.cargo/git | |
73 | - name: Cache cargo index | 73 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
74 | uses: actions/cache@v1 | ||
75 | with: | ||
76 | path: ~/.cargo/git | ||
77 | key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
78 | 74 | ||
79 | - name: Cache cargo target dir | 75 | - name: Cache cargo target dir |
80 | uses: actions/cache@v1 | 76 | uses: actions/cache@v2 |
81 | with: | 77 | with: |
82 | path: target | 78 | path: target |
83 | key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | 79 | key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
@@ -114,17 +110,13 @@ jobs: | |||
114 | 110 | ||
115 | - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ | 111 | - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ |
116 | 112 | ||
117 | - name: Cache cargo registry | 113 | - name: Cache cargo directories |
118 | uses: actions/cache@v1 | 114 | uses: actions/cache@v2 |
119 | with: | ||
120 | path: ~/.cargo/registry | ||
121 | key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
122 | |||
123 | - name: Cache cargo index | ||
124 | uses: actions/cache@v1 | ||
125 | with: | 115 | with: |
126 | path: ~/.cargo/git | 116 | path: | |
127 | key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | 117 | ~/.cargo/registry |
118 | ~/.cargo/git | ||
119 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
128 | 120 | ||
129 | - name: Check | 121 | - name: Check |
130 | run: cargo check --target=powerpc-unknown-linux-gnu --all-targets | 122 | run: cargo check --target=powerpc-unknown-linux-gnu --all-targets |
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index d6aaf53f1..f185e61e5 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -158,6 +158,9 @@ fn add_missing_impl_members_inner( | |||
158 | .map(|it| ast_transform::apply(&*ast_transform, it)) | 158 | .map(|it| ast_transform::apply(&*ast_transform, it)) |
159 | .map(|it| match it { | 159 | .map(|it| match it { |
160 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), | 160 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), |
161 | ast::AssocItem::TypeAliasDef(def) => { | ||
162 | ast::AssocItem::TypeAliasDef(def.remove_bounds()) | ||
163 | } | ||
161 | _ => it, | 164 | _ => it, |
162 | }) | 165 | }) |
163 | .map(|it| edit::remove_attrs_and_docs(&it)); | 166 | .map(|it| edit::remove_attrs_and_docs(&it)); |
@@ -684,4 +687,26 @@ impl Foo<T> for S<T> { | |||
684 | }"#, | 687 | }"#, |
685 | ) | 688 | ) |
686 | } | 689 | } |
690 | |||
691 | #[test] | ||
692 | fn test_assoc_type_bounds_are_removed() { | ||
693 | check_assist( | ||
694 | add_missing_impl_members, | ||
695 | r#" | ||
696 | trait Tr { | ||
697 | type Ty: Copy + 'static; | ||
698 | } | ||
699 | |||
700 | impl Tr for ()<|> { | ||
701 | }"#, | ||
702 | r#" | ||
703 | trait Tr { | ||
704 | type Ty: Copy + 'static; | ||
705 | } | ||
706 | |||
707 | impl Tr for () { | ||
708 | $0type Ty; | ||
709 | }"#, | ||
710 | ) | ||
711 | } | ||
687 | } | 712 | } |
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 940c30c7f..abc7a646c 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -189,6 +189,21 @@ impl ast::RecordFieldList { | |||
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | impl ast::TypeAliasDef { | ||
193 | #[must_use] | ||
194 | pub fn remove_bounds(&self) -> ast::TypeAliasDef { | ||
195 | let colon = match self.colon_token() { | ||
196 | Some(it) => it, | ||
197 | None => return self.clone(), | ||
198 | }; | ||
199 | let end = match self.type_bound_list() { | ||
200 | Some(it) => it.syntax().clone().into(), | ||
201 | None => colon.clone().into(), | ||
202 | }; | ||
203 | self.replace_children(colon.into()..=end, iter::empty()) | ||
204 | } | ||
205 | } | ||
206 | |||
192 | impl ast::TypeParam { | 207 | impl ast::TypeParam { |
193 | #[must_use] | 208 | #[must_use] |
194 | pub fn remove_bounds(&self) -> ast::TypeParam { | 209 | pub fn remove_bounds(&self) -> ast::TypeParam { |