Skip to content

Commit 4f09335

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sync-from-rust
2 parents 8ba31cc + 850ba2f commit 4f09335

File tree

185 files changed

+2613
-1779
lines changed

Some content is hidden

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

185 files changed

+2613
-1779
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Switch to stable toolchain
9191
run: |
9292
rustup update --no-self-update stable
93-
rustup component add --toolchain stable rust-src
93+
rustup component add --toolchain stable rust-src clippy
9494
rustup default stable
9595
9696
- name: Run analysis-stats on rust-analyzer
@@ -103,6 +103,10 @@ jobs:
103103
RUSTC_BOOTSTRAP: 1
104104
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
105105

106+
- name: clippy
107+
if: matrix.os == 'ubuntu-latest'
108+
run: cargo clippy --all-targets
109+
106110
# Weird targets to catch non-portable code
107111
rust-cross:
108112
if: github.repository == 'rust-lang/rust-analyzer'

Cargo.lock

Lines changed: 19 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ itertools = "0.12.0"
113113
libc = "0.2.150"
114114
nohash-hasher = "0.2.0"
115115
rayon = "1.8.0"
116-
rust-analyzer-salsa = "0.17.0-pre.5"
116+
rust-analyzer-salsa = "0.17.0-pre.6"
117117
rustc-hash = "1.1.0"
118118
semver = "1.0.14"
119119
serde = { version = "1.0.192", features = ["derive"] }
@@ -128,9 +128,9 @@ text-size = "1.1.1"
128128
tracing = "0.1.40"
129129
tracing-tree = "0.3.0"
130130
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
131-
"registry",
132-
"fmt",
133-
"tracing-log",
131+
"registry",
132+
"fmt",
133+
"tracing-log",
134134
] }
135135
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
136136
xshell = "0.2.5"
@@ -167,29 +167,14 @@ new_ret_no_self = "allow"
167167

168168
## Following lints should be tackled at some point
169169
borrowed_box = "allow"
170-
borrow_deref_ref = "allow"
171-
derivable_impls = "allow"
172170
derived_hash_with_manual_eq = "allow"
173-
field_reassign_with_default = "allow"
174171
forget_non_drop = "allow"
175-
format_collect = "allow"
176-
large_enum_variant = "allow"
177172
needless_doctest_main = "allow"
178-
new_without_default = "allow"
179173
non_canonical_clone_impl = "allow"
180174
non_canonical_partial_ord_impl = "allow"
181175
self_named_constructors = "allow"
182-
skip_while_next = "allow"
183176
too_many_arguments = "allow"
184-
toplevel_ref_arg = "allow"
185177
type_complexity = "allow"
186-
unnecessary_cast = "allow"
187-
unnecessary_filter_map = "allow"
188-
unnecessary_lazy_evaluations = "allow"
189-
unnecessary_mut_passed = "allow"
190-
useless_conversion = "allow"
191-
useless_format = "allow"
192-
wildcard_in_or_patterns = "allow"
193178
wrong_self_convention = "allow"
194179

195180
## warn at following lints

crates/base-db/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rust-analyzer-salsa.workspace = true
1717
rustc-hash.workspace = true
1818
triomphe.workspace = true
1919
semver.workspace = true
20+
tracing.workspace = true
2021

2122
# local deps
2223
cfg.workspace = true
@@ -27,4 +28,4 @@ vfs.workspace = true
2728
span.workspace = true
2829

2930
[lints]
30-
workspace = true
31+
workspace = true

crates/base-db/src/change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl FileChange {
5151
}
5252

5353
pub fn apply(self, db: &mut dyn SourceDatabaseExt) {
54-
let _p = profile::span("RootDatabase::apply_change");
54+
let _p = tracing::span!(tracing::Level::INFO, "RootDatabase::apply_change").entered();
5555
if let Some(roots) = self.roots {
5656
for (idx, root) in roots.into_iter().enumerate() {
5757
let root_id = SourceRootId(idx as u32);

crates/base-db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl CrateGraph {
494494
from: CrateId,
495495
dep: Dependency,
496496
) -> Result<(), CyclicDependenciesError> {
497-
let _p = profile::span("add_dep");
497+
let _p = tracing::span!(tracing::Level::INFO, "add_dep").entered();
498498

499499
self.check_cycle_after_dependency(from, dep.crate_id)?;
500500

crates/base-db/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
6565
}
6666

6767
fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
68-
let _p = profile::span("parse_query").detail(|| format!("{file_id:?}"));
68+
let _p = tracing::span!(tracing::Level::INFO, "parse_query", ?file_id).entered();
6969
let text = db.file_text(file_id);
7070
SourceFile::parse(&text)
7171
}
@@ -116,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
116116
}
117117

118118
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
119-
let _p = profile::span("relevant_crates");
119+
let _p = tracing::span!(tracing::Level::INFO, "relevant_crates").entered();
120120
let source_root = self.0.file_source_root(file_id);
121121
self.0.source_root_crates(source_root)
122122
}

crates/flycheck/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ impl CargoActor {
493493
// Skip certain kinds of messages to only spend time on what's useful
494494
JsonMessage::Cargo(message) => match message {
495495
cargo_metadata::Message::CompilerArtifact(artifact) if !artifact.fresh => {
496-
self.sender.send(CargoMessage::CompilerArtifact(artifact)).unwrap();
496+
self.sender
497+
.send(CargoMessage::CompilerArtifact(Box::new(artifact)))
498+
.unwrap();
497499
}
498500
cargo_metadata::Message::CompilerMessage(msg) => {
499501
self.sender.send(CargoMessage::Diagnostic(msg.message)).unwrap();
@@ -538,7 +540,7 @@ impl CargoActor {
538540
}
539541

540542
enum CargoMessage {
541-
CompilerArtifact(cargo_metadata::Artifact),
543+
CompilerArtifact(Box<cargo_metadata::Artifact>),
542544
Diagnostic(Diagnostic),
543545
}
544546

crates/hir-def/src/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Attrs {
7575
db: &dyn DefDatabase,
7676
v: VariantId,
7777
) -> Arc<ArenaMap<LocalFieldId, Attrs>> {
78-
let _p = profile::span("fields_attrs_query");
78+
let _p = tracing::span!(tracing::Level::INFO, "fields_attrs_query").entered();
7979
// FIXME: There should be some proper form of mapping between item tree field ids and hir field ids
8080
let mut res = ArenaMap::default();
8181

@@ -322,7 +322,7 @@ impl AttrsWithOwner {
322322
}
323323

324324
pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs {
325-
let _p = profile::span("attrs_query");
325+
let _p = tracing::span!(tracing::Level::INFO, "attrs_query").entered();
326326
// FIXME: this should use `Trace` to avoid duplication in `source_map` below
327327
let raw_attrs = match def {
328328
AttrDefId::ModuleId(module) => {

crates/hir-def/src/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Body {
122122
db: &dyn DefDatabase,
123123
def: DefWithBodyId,
124124
) -> (Arc<Body>, Arc<BodySourceMap>) {
125-
let _p = profile::span("body_with_source_map_query");
125+
let _p = tracing::span!(tracing::Level::INFO, "body_with_source_map_query").entered();
126126
let mut params = None;
127127

128128
let mut is_async_fn = false;

crates/hir-def/src/body/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
3333
}
3434
)
3535
}),
36-
DefWithBodyId::InTypeConstId(_) => format!("In type const = "),
36+
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_string(),
3737
DefWithBodyId::VariantId(it) => {
3838
let loc = it.lookup(db);
3939
let enum_loc = loc.parent.lookup(db);

crates/hir-def/src/body/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl SsrError {
256256
"##,
257257
);
258258

259-
assert_eq!(db.body_with_source_map(def.into()).1.diagnostics(), &[]);
259+
assert_eq!(db.body_with_source_map(def).1.diagnostics(), &[]);
260260
expect![[r#"
261261
fn main() {
262262
_ = $crate::error::SsrError::new(
@@ -309,7 +309,7 @@ fn f() {
309309
"#,
310310
);
311311

312-
let (_, source_map) = db.body_with_source_map(def.into());
312+
let (_, source_map) = db.body_with_source_map(def);
313313
assert_eq!(source_map.diagnostics(), &[]);
314314

315315
for (_, def_map) in body.blocks(&db) {

crates/hir-def/src/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl ImplData {
340340
db: &dyn DefDatabase,
341341
id: ImplId,
342342
) -> (Arc<ImplData>, DefDiagnostics) {
343-
let _p = profile::span("impl_data_with_diagnostics_query");
343+
let _p = tracing::span!(tracing::Level::INFO, "impl_data_with_diagnostics_query").entered();
344344
let ItemLoc { container: module_id, id: tree_id } = id.lookup(db);
345345

346346
let item_tree = tree_id.item_tree(db);
@@ -782,7 +782,7 @@ impl<'a> AssocItemCollector<'a> {
782782
self.diagnostics.push(DefDiagnostic::macro_expansion_parse_error(
783783
self.module_id.local_id,
784784
error_call_kind(),
785-
errors.into(),
785+
errors,
786786
));
787787
}
788788

crates/hir-def/src/db.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Defines database & queries for name resolution.
2-
use base_db::{salsa, CrateId, SourceDatabase, Upcast};
2+
use base_db::{salsa, CrateId, FileId, SourceDatabase, Upcast};
33
use either::Either;
44
use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId};
55
use intern::Interned;
66
use la_arena::ArenaMap;
7+
use span::MacroCallId;
78
use syntax::{ast, AstPtr};
89
use triomphe::Arc;
910

@@ -234,10 +235,26 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
234235
fn crate_notable_traits(&self, krate: CrateId) -> Option<Arc<[TraitId]>>;
235236

236237
fn crate_supports_no_std(&self, crate_id: CrateId) -> bool;
238+
239+
fn include_macro_invoc(&self, crate_id: CrateId) -> Vec<(MacroCallId, FileId)>;
240+
}
241+
242+
// return: macro call id and include file id
243+
fn include_macro_invoc(db: &dyn DefDatabase, krate: CrateId) -> Vec<(MacroCallId, FileId)> {
244+
db.crate_def_map(krate)
245+
.modules
246+
.values()
247+
.flat_map(|m| m.scope.iter_macro_invoc())
248+
.filter_map(|invoc| {
249+
db.lookup_intern_macro_call(*invoc.1)
250+
.include_file_id(db.upcast(), *invoc.1)
251+
.map(|x| (*invoc.1, x))
252+
})
253+
.collect()
237254
}
238255

239256
fn crate_def_map_wait(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> {
240-
let _p = profile::span("crate_def_map:wait");
257+
let _p = tracing::span!(tracing::Level::INFO, "crate_def_map:wait").entered();
241258
db.crate_def_map_query(krate)
242259
}
243260

0 commit comments

Comments
 (0)