aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock28
-rw-r--r--crates/assists/src/handlers/add_missing_impl_members.rs2
-rw-r--r--crates/assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/hir/src/code_model.rs2
-rw-r--r--crates/ide/src/link_rewrite.rs4
-rw-r--r--crates/ssr/src/resolving.rs2
-rw-r--r--crates/syntax/Cargo.toml2
-rw-r--r--crates/syntax/src/ast/edit.rs2
-rw-r--r--crates/syntax/src/parsing/lexer.rs8
-rw-r--r--docs/dev/style.md19
10 files changed, 40 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5b69e3cab..49022502d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -214,9 +214,9 @@ dependencies = [
214 214
215[[package]] 215[[package]]
216name = "chrono" 216name = "chrono"
217version = "0.4.18" 217version = "0.4.19"
218source = "registry+https://github.com/rust-lang/crates.io-index" 218source = "registry+https://github.com/rust-lang/crates.io-index"
219checksum = "d021fddb7bd3e734370acfa4a83f34095571d8570c039f1420d77540f68d5772" 219checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
220dependencies = [ 220dependencies = [
221 "libc", 221 "libc",
222 "num-integer", 222 "num-integer",
@@ -365,9 +365,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
365 365
366[[package]] 366[[package]]
367name = "flate2" 367name = "flate2"
368version = "1.0.17" 368version = "1.0.18"
369source = "registry+https://github.com/rust-lang/crates.io-index" 369source = "registry+https://github.com/rust-lang/crates.io-index"
370checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" 370checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee"
371dependencies = [ 371dependencies = [
372 "cfg-if", 372 "cfg-if",
373 "crc32fast", 373 "crc32fast",
@@ -725,9 +725,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
725 725
726[[package]] 726[[package]]
727name = "libc" 727name = "libc"
728version = "0.2.77" 728version = "0.2.78"
729source = "registry+https://github.com/rust-lang/crates.io-index" 729source = "registry+https://github.com/rust-lang/crates.io-index"
730checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" 730checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98"
731 731
732[[package]] 732[[package]]
733name = "libloading" 733name = "libloading"
@@ -1071,9 +1071,9 @@ checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1"
1071 1071
1072[[package]] 1072[[package]]
1073name = "pin-project-lite" 1073name = "pin-project-lite"
1074version = "0.1.9" 1074version = "0.1.10"
1075source = "registry+https://github.com/rust-lang/crates.io-index" 1075source = "registry+https://github.com/rust-lang/crates.io-index"
1076checksum = "4fe74897791e156a0cd8cce0db31b9b2198e67877316bf3086c3acd187f719f0" 1076checksum = "e555d9e657502182ac97b539fb3dae8b79cda19e3e4f8ffb5e8de4f18df93c95"
1077 1077
1078[[package]] 1078[[package]]
1079name = "plain" 1079name = "plain"
@@ -1083,9 +1083,9 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
1083 1083
1084[[package]] 1084[[package]]
1085name = "proc-macro2" 1085name = "proc-macro2"
1086version = "1.0.23" 1086version = "1.0.24"
1087source = "registry+https://github.com/rust-lang/crates.io-index" 1087source = "registry+https://github.com/rust-lang/crates.io-index"
1088checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9" 1088checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
1089dependencies = [ 1089dependencies = [
1090 "unicode-xid", 1090 "unicode-xid",
1091] 1091]
@@ -1300,9 +1300,9 @@ dependencies = [
1300 1300
1301[[package]] 1301[[package]]
1302name = "rustc-ap-rustc_lexer" 1302name = "rustc-ap-rustc_lexer"
1303version = "673.0.0" 1303version = "681.0.0"
1304source = "registry+https://github.com/rust-lang/crates.io-index" 1304source = "registry+https://github.com/rust-lang/crates.io-index"
1305checksum = "f6b71fa1285bdefe5fb61e59b63d6cc246abf337f4acafdd620d721bc488e671" 1305checksum = "01e579a90506e9d9c9a098f380cad55b9ecf9e7be9fa96cb67b31f52045f41a8"
1306dependencies = [ 1306dependencies = [
1307 "unicode-xid", 1307 "unicode-xid",
1308] 1308]
@@ -1433,9 +1433,9 @@ dependencies = [
1433 1433
1434[[package]] 1434[[package]]
1435name = "serde_json" 1435name = "serde_json"
1436version = "1.0.57" 1436version = "1.0.58"
1437source = "registry+https://github.com/rust-lang/crates.io-index" 1437source = "registry+https://github.com/rust-lang/crates.io-index"
1438checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" 1438checksum = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4"
1439dependencies = [ 1439dependencies = [
1440 "itoa", 1440 "itoa",
1441 "ryu", 1441 "ryu",
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs
index 1ac5fefd6..51b5a2eb0 100644
--- a/crates/assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/assists/src/handlers/add_missing_impl_members.rs
@@ -146,7 +146,7 @@ fn add_missing_impl_members_inner(
146 146
147 let target = impl_def.syntax().text_range(); 147 let target = impl_def.syntax().text_range();
148 acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| { 148 acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| {
149 let impl_item_list = impl_def.assoc_item_list().unwrap_or(make::assoc_item_list()); 149 let impl_item_list = impl_def.assoc_item_list().unwrap_or_else(make::assoc_item_list);
150 150
151 let n_existing_items = impl_item_list.assoc_items().count(); 151 let n_existing_items = impl_item_list.assoc_items().count();
152 let source_scope = ctx.sema.scope_for_def(trait_); 152 let source_scope = ctx.sema.scope_for_def(trait_);
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
index d1eadaa99..f5f03ef36 100644
--- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -91,7 +91,7 @@ fn existing_struct_def(db: &RootDatabase, variant_name: &str, variant: &EnumVari
91 .module(db) 91 .module(db)
92 .scope(db, None) 92 .scope(db, None)
93 .into_iter() 93 .into_iter()
94 .any(|(name, _)| name.to_string() == variant_name.to_string()) 94 .any(|(name, _)| name.to_string() == variant_name)
95} 95}
96 96
97#[allow(dead_code)] 97#[allow(dead_code)]
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 567fd91af..5721a66c4 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -145,7 +145,7 @@ impl Crate {
145 } 145 }
146 }).flat_map(|t| t).next(); 146 }).flat_map(|t| t).next();
147 147
148 doc_url.map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/") 148 doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
149 } 149 }
150} 150}
151 151
diff --git a/crates/ide/src/link_rewrite.rs b/crates/ide/src/link_rewrite.rs
index 107787bb9..a16f90e17 100644
--- a/crates/ide/src/link_rewrite.rs
+++ b/crates/ide/src/link_rewrite.rs
@@ -120,7 +120,7 @@ fn rewrite_intra_doc_link(
120 120
121/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`). 121/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).
122fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> { 122fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
123 if !(target.contains("#") || target.contains(".html")) { 123 if !(target.contains('#') || target.contains(".html")) {
124 return None; 124 return None;
125 } 125 }
126 126
@@ -190,7 +190,7 @@ fn strip_prefixes_suffixes(mut s: &str) -> &str {
190 prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix)); 190 prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix));
191 suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix)); 191 suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix));
192 }); 192 });
193 s.trim_start_matches("@").trim() 193 s.trim_start_matches('@').trim()
194} 194}
195 195
196static TYPES: ([&str; 7], [&str; 0]) = 196static TYPES: ([&str; 7], [&str; 0]) =
diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs
index 5d2cbec47..347cc4aad 100644
--- a/crates/ssr/src/resolving.rs
+++ b/crates/ssr/src/resolving.rs
@@ -205,7 +205,7 @@ impl<'db> ResolutionScope<'db> {
205 205
206 /// Returns the function in which SSR was invoked, if any. 206 /// Returns the function in which SSR was invoked, if any.
207 pub(crate) fn current_function(&self) -> Option<SyntaxNode> { 207 pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
208 self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone()) 208 self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN)
209 } 209 }
210 210
211 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> { 211 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml
index af61bb658..0b15f10e9 100644
--- a/crates/syntax/Cargo.toml
+++ b/crates/syntax/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
13[dependencies] 13[dependencies]
14itertools = "0.9.0" 14itertools = "0.9.0"
15rowan = "0.10.0" 15rowan = "0.10.0"
16rustc_lexer = { version = "673.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "681.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs
index dda0a0319..77233ab31 100644
--- a/crates/syntax/src/ast/edit.rs
+++ b/crates/syntax/src/ast/edit.rs
@@ -159,7 +159,7 @@ impl ast::AssocItemList {
159 let whitespace = 159 let whitespace =
160 last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?; 160 last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?;
161 let text = whitespace.syntax().text(); 161 let text = whitespace.syntax().text();
162 let newline = text.rfind("\n")?; 162 let newline = text.rfind('\n')?;
163 let keep = tokens::WsBuilder::new(&text[newline..]); 163 let keep = tokens::WsBuilder::new(&text[newline..]);
164 Some(self.replace_children( 164 Some(self.replace_children(
165 first_token_after_items..=last_token_before_curly, 165 first_token_after_items..=last_token_before_curly,
diff --git a/crates/syntax/src/parsing/lexer.rs b/crates/syntax/src/parsing/lexer.rs
index fa3be1016..f1202113b 100644
--- a/crates/syntax/src/parsing/lexer.rs
+++ b/crates/syntax/src/parsing/lexer.rs
@@ -120,10 +120,10 @@ fn rustc_token_kind_to_syntax_kind(
120 120
121 let syntax_kind = { 121 let syntax_kind = {
122 match rustc_token_kind { 122 match rustc_token_kind {
123 rustc_lexer::TokenKind::LineComment => COMMENT, 123 rustc_lexer::TokenKind::LineComment { doc_style: _ } => COMMENT,
124 124
125 rustc_lexer::TokenKind::BlockComment { terminated: true } => COMMENT, 125 rustc_lexer::TokenKind::BlockComment { doc_style: _, terminated: true } => COMMENT,
126 rustc_lexer::TokenKind::BlockComment { terminated: false } => { 126 rustc_lexer::TokenKind::BlockComment { doc_style: _, terminated: false } => {
127 return ( 127 return (
128 COMMENT, 128 COMMENT,
129 Some("Missing trailing `*/` symbols to terminate the block comment"), 129 Some("Missing trailing `*/` symbols to terminate the block comment"),
@@ -164,7 +164,7 @@ fn rustc_token_kind_to_syntax_kind(
164 rustc_lexer::TokenKind::Colon => T![:], 164 rustc_lexer::TokenKind::Colon => T![:],
165 rustc_lexer::TokenKind::Dollar => T![$], 165 rustc_lexer::TokenKind::Dollar => T![$],
166 rustc_lexer::TokenKind::Eq => T![=], 166 rustc_lexer::TokenKind::Eq => T![=],
167 rustc_lexer::TokenKind::Not => T![!], 167 rustc_lexer::TokenKind::Bang => T![!],
168 rustc_lexer::TokenKind::Lt => T![<], 168 rustc_lexer::TokenKind::Lt => T![<],
169 rustc_lexer::TokenKind::Gt => T![>], 169 rustc_lexer::TokenKind::Gt => T![>],
170 rustc_lexer::TokenKind::Minus => T![-], 170 rustc_lexer::TokenKind::Minus => T![-],
diff --git a/docs/dev/style.md b/docs/dev/style.md
index bcd86fd3f..fb407afcd 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -197,7 +197,7 @@ fn frobnicate(walrus: Option<Walrus>) {
197} 197}
198``` 198```
199 199
200Avoid preconditions that spawn function boundaries: 200Avoid preconditions that span across function boundaries:
201 201
202 202
203```rust 203```rust
@@ -218,9 +218,8 @@ fn foo() {
218} 218}
219 219
220// Not as good 220// Not as good
221fn is_string_literal(s: &str) -> Option<&str> { 221fn is_string_literal(s: &str) -> bool {
222 s.starts_with('"') && s.ends_with('"') 222 s.starts_with('"') && s.ends_with('"')
223 Some()
224} 223}
225 224
226fn foo() { 225fn foo() {
@@ -231,8 +230,8 @@ fn foo() {
231} 230}
232``` 231```
233 232
234In the "Not as good" version, the precondition that `1` is a valid char boundary is checked in `is_string_literal` and utilized in `foo`. 233In the "Not as good" version, the precondition that `1` is a valid char boundary is checked in `is_string_literal` and used in `foo`.
235In the "Good" version, precondition check and usage are checked in the same block, and then encoded in the types. 234In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
236 235
237# Early Returns 236# Early Returns
238 237
@@ -372,3 +371,13 @@ After you are happy with the state of the code, please use [interactive rebase](
372 371
373Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors). 372Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors).
374Such messages create a lot of duplicate notification traffic during rebases. 373Such messages create a lot of duplicate notification traffic during rebases.
374
375# Clippy
376
377We don't enforce Clippy.
378A number of default lints have high false positive rate.
379Selectively patching false-positives with `allow(clippy)` is considered worse than not using Clippy at all.
380There's `cargo xtask lint` command which runs a subset of low-FPR lints.
381Careful tweaking of `xtask lint` is welcome.
382See also [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537).
383Of course, applying Clippy suggestions is welcome as long as they indeed improve the code.