Skip to content

Commit 33422e7

Browse files
committed
Auto merge of rust-lang#126865 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents aabbf84 + 70e9582 commit 33422e7

File tree

284 files changed

+8852
-4803
lines changed

Some content is hidden

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

284 files changed

+8852
-4803
lines changed

src/tools/rust-analyzer/.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ tq = "test -- -q"
44
qt = "tq"
55
lint = "clippy --all-targets -- --cap-lints warn"
66
codegen = "run --package xtask --bin xtask -- codegen"
7+
dist = "run --package xtask --bin xtask -- dist"
78

89
[target.x86_64-pc-windows-msvc]
910
linker = "rust-lld"

src/tools/rust-analyzer/Cargo.lock

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ dependencies = [
328328
"dirs-sys",
329329
]
330330

331+
[[package]]
332+
name = "dirs"
333+
version = "5.0.1"
334+
source = "registry+https://github.com/rust-lang/crates.io-index"
335+
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
336+
dependencies = [
337+
"dirs-sys",
338+
]
339+
331340
[[package]]
332341
name = "dirs-sys"
333342
version = "0.4.1"
@@ -503,6 +512,7 @@ dependencies = [
503512
"hir-def",
504513
"hir-expand",
505514
"hir-ty",
515+
"intern",
506516
"itertools",
507517
"once_cell",
508518
"rustc-hash",
@@ -891,9 +901,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
891901

892902
[[package]]
893903
name = "libc"
894-
version = "0.2.154"
904+
version = "0.2.155"
895905
source = "registry+https://github.com/rust-lang/crates.io-index"
896-
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
906+
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
897907

898908
[[package]]
899909
name = "libloading"
@@ -1665,6 +1675,7 @@ dependencies = [
16651675
"anyhow",
16661676
"cfg",
16671677
"crossbeam-channel",
1678+
"dirs",
16681679
"dissimilar",
16691680
"expect-test",
16701681
"flycheck",

src/tools/rust-analyzer/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ xshell = "0.2.5"
162162
dashmap = { version = "=5.5.3", features = ["raw-api"] }
163163

164164
[workspace.lints.rust]
165-
rust_2018_idioms = "warn"
165+
bare_trait_objects = "warn"
166+
elided_lifetimes_in_paths = "warn"
167+
ellipsis_inclusive_range_patterns = "warn"
168+
explicit_outlives_requirements = "warn"
169+
unused_extern_crates = "warn"
166170
unused_lifetimes = "warn"
167171
unreachable_pub = "warn"
168172
semicolon_in_expressions_from_macros = "warn"

src/tools/rust-analyzer/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 = tracing::span!(tracing::Level::INFO, "FileChange::apply").entered();
54+
let _p = tracing::info_span!("FileChange::apply").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);

src/tools/rust-analyzer/crates/base-db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl CrateGraph {
412412
from: CrateId,
413413
dep: Dependency,
414414
) -> Result<(), CyclicDependenciesError> {
415-
let _p = tracing::span!(tracing::Level::INFO, "add_dep").entered();
415+
let _p = tracing::info_span!("add_dep").entered();
416416

417417
self.check_cycle_after_dependency(from, dep.crate_id)?;
418418

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn toolchain_channel(db: &dyn SourceDatabase, krate: CrateId) -> Option<ReleaseC
8585
}
8686

8787
fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
88-
let _p = tracing::span!(tracing::Level::INFO, "parse", ?file_id).entered();
88+
let _p = tracing::info_span!("parse", ?file_id).entered();
8989
let text = db.file_text(file_id);
9090
// FIXME: Edition based parsing
9191
SourceFile::parse(&text, span::Edition::CURRENT)
@@ -187,7 +187,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
187187
}
188188

189189
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
190-
let _p = tracing::span!(tracing::Level::INFO, "relevant_crates").entered();
190+
let _p = tracing::info_span!("relevant_crates").entered();
191191
let source_root = self.0.file_source_root(file_id);
192192
self.0.source_root_crates(source_root)
193193
}

src/tools/rust-analyzer/crates/flycheck/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl FlycheckActor {
304304
Some(c) => c,
305305
None => continue,
306306
};
307-
let formatted_command = format!("{:?}", command);
307+
let formatted_command = format!("{command:?}");
308308

309309
tracing::debug!(?command, "will restart flycheck");
310310
let (sender, receiver) = unbounded();
@@ -318,8 +318,7 @@ impl FlycheckActor {
318318
}
319319
Err(error) => {
320320
self.report_progress(Progress::DidFailToRestart(format!(
321-
"Failed to run the following command: {} error={}",
322-
formatted_command, error
321+
"Failed to run the following command: {formatted_command} error={error}"
323322
)));
324323
self.status = FlycheckStatus::Finished;
325324
}
@@ -331,7 +330,7 @@ impl FlycheckActor {
331330
// Watcher finished
332331
let command_handle = self.command_handle.take().unwrap();
333332
self.command_receiver.take();
334-
let formatted_handle = format!("{:?}", command_handle);
333+
let formatted_handle = format!("{command_handle:?}");
335334

336335
let res = command_handle.join();
337336
if let Err(error) = &res {
@@ -387,6 +386,7 @@ impl FlycheckActor {
387386
"did cancel flycheck"
388387
);
389388
command_handle.cancel();
389+
self.command_receiver.take();
390390
self.report_progress(Progress::DidCancel);
391391
self.status = FlycheckStatus::Finished;
392392
}

src/tools/rust-analyzer/crates/hir-def/src/attr.rs

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
//! A higher level attributes based on TokenTree, with also some shortcuts.
22
3-
pub mod builtin;
4-
5-
#[cfg(test)]
6-
mod tests;
7-
83
use std::{borrow::Cow, hash::Hash, ops, slice::Iter as SliceIter};
94

105
use base_db::CrateId;
@@ -75,7 +70,7 @@ impl Attrs {
7570
db: &dyn DefDatabase,
7671
v: VariantId,
7772
) -> Arc<ArenaMap<LocalFieldId, Attrs>> {
78-
let _p = tracing::span!(tracing::Level::INFO, "fields_attrs_query").entered();
73+
let _p = tracing::info_span!("fields_attrs_query").entered();
7974
// FIXME: There should be some proper form of mapping between item tree field ids and hir field ids
8075
let mut res = ArenaMap::default();
8176

@@ -326,7 +321,7 @@ impl AttrsWithOwner {
326321
}
327322

328323
pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs {
329-
let _p = tracing::span!(tracing::Level::INFO, "attrs_query").entered();
324+
let _p = tracing::info_span!("attrs_query").entered();
330325
// FIXME: this should use `Trace` to avoid duplication in `source_map` below
331326
let raw_attrs = match def {
332327
AttrDefId::ModuleId(module) => {
@@ -646,3 +641,55 @@ pub(crate) fn fields_attrs_source_map(
646641

647642
Arc::new(res)
648643
}
644+
645+
#[cfg(test)]
646+
mod tests {
647+
//! This module contains tests for doc-expression parsing.
648+
//! Currently, it tests `#[doc(hidden)]` and `#[doc(alias)]`.
649+
650+
use triomphe::Arc;
651+
652+
use base_db::FileId;
653+
use hir_expand::span_map::{RealSpanMap, SpanMap};
654+
use mbe::{syntax_node_to_token_tree, DocCommentDesugarMode};
655+
use syntax::{ast, AstNode, TextRange};
656+
657+
use crate::attr::{DocAtom, DocExpr};
658+
659+
fn assert_parse_result(input: &str, expected: DocExpr) {
660+
let source_file = ast::SourceFile::parse(input, span::Edition::CURRENT).ok().unwrap();
661+
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
662+
let map = SpanMap::RealSpanMap(Arc::new(RealSpanMap::absolute(FileId::from_raw(0))));
663+
let tt = syntax_node_to_token_tree(
664+
tt.syntax(),
665+
map.as_ref(),
666+
map.span_for_range(TextRange::empty(0.into())),
667+
DocCommentDesugarMode::ProcMacro,
668+
);
669+
let cfg = DocExpr::parse(&tt);
670+
assert_eq!(cfg, expected);
671+
}
672+
673+
#[test]
674+
fn test_doc_expr_parser() {
675+
assert_parse_result("#![doc(hidden)]", DocAtom::Flag("hidden".into()).into());
676+
677+
assert_parse_result(
678+
r#"#![doc(alias = "foo")]"#,
679+
DocAtom::KeyValue { key: "alias".into(), value: "foo".into() }.into(),
680+
);
681+
682+
assert_parse_result(r#"#![doc(alias("foo"))]"#, DocExpr::Alias(["foo".into()].into()));
683+
assert_parse_result(
684+
r#"#![doc(alias("foo", "bar", "baz"))]"#,
685+
DocExpr::Alias(["foo".into(), "bar".into(), "baz".into()].into()),
686+
);
687+
688+
assert_parse_result(
689+
r#"
690+
#[doc(alias("Bar", "Qux"))]
691+
struct Foo;"#,
692+
DocExpr::Alias(["Bar".into(), "Qux".into()].into()),
693+
);
694+
}
695+
}

src/tools/rust-analyzer/crates/hir-def/src/attr/tests.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/tools/rust-analyzer/crates/hir-def/src/body.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Body {
124124
db: &dyn DefDatabase,
125125
def: DefWithBodyId,
126126
) -> (Arc<Body>, Arc<BodySourceMap>) {
127-
let _p = tracing::span!(tracing::Level::INFO, "body_with_source_map_query").entered();
127+
let _p = tracing::info_span!("body_with_source_map_query").entered();
128128
let mut params = None;
129129

130130
let mut is_async_fn = false;
@@ -395,6 +395,12 @@ impl BodySourceMap {
395395
self.expr_map.get(&src).copied()
396396
}
397397

398+
pub fn expansions(
399+
&self,
400+
) -> impl Iterator<Item = (&InFile<AstPtr<ast::MacroCall>>, &MacroFileId)> {
401+
self.expansions.iter()
402+
}
403+
398404
pub fn implicit_format_args(
399405
&self,
400406
node: InFile<&ast::FormatArgsExpr>,

0 commit comments

Comments
 (0)