Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtree update of rust-analyzer #134681

Merged
merged 67 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
4704a96
feat: improve name generation in destructure_tuple_binding
roife Dec 13, 2024
5e196f0
feat: Use string literal contents as a name when extracting into vari…
Giga-Bowser Dec 14, 2024
de55520
refactor: simplify `edit_tuple_usages` in destructure_tuple_binding
roife Dec 13, 2024
ffe908d
Report unresolved idents for implicit captures in `format_args!()`
ChayimFriedman2 Dec 16, 2024
1cace0a
internal: Simplify ratoml testdir usage
Veykril Dec 16, 2024
4c52ed4
Merge pull request #18697 from Veykril/push-qtmmtvpyrntr
Veykril Dec 16, 2024
dd09410
Merge pull request #18696 from ChayimFriedman2/syn-syn
Veykril Dec 16, 2024
99a4592
Merge pull request #18695 from roife/improve-tuple-destruction
Veykril Dec 16, 2024
5c67821
internal: Don't serialize empty fields in completions and resolve pay…
Veykril Dec 16, 2024
4717662
Merge pull request #18690 from Giga-Bowser/extract-variable-string
Veykril Dec 16, 2024
7980b81
Merge pull request #18698 from Veykril/push-vpqwrwxptsql
Veykril Dec 16, 2024
9fc5cef
fix: Fix path qualified auto-importing completions not working with r…
Veykril Dec 16, 2024
0e81d18
Merge pull request #18699 from Veykril/push-ltqwwusvtlot
Veykril Dec 16, 2024
536318c
Fix a panic with a diagnostics fix when a keyword is used as a field
ChayimFriedman2 Dec 16, 2024
cf32a6f
Use a record struct instead of a tuple for each namespace in `PerNs`
ChayimFriedman2 Dec 16, 2024
7f45fed
Merge pull request #18700 from ChayimFriedman2/dyn-send
Veykril Dec 16, 2024
716673c
Fix pretty-printing of `@` patterns
ChayimFriedman2 Dec 17, 2024
45f3da5
Merge pull request #18708 from ChayimFriedman2/fix-tiny
Veykril Dec 18, 2024
f01874c
Remove salsa from proc-macro server dep tree
Veykril Dec 18, 2024
ff97582
Merge pull request #18710 from Veykril/push-oywuruktpozm
Veykril Dec 18, 2024
b2b95f0
Taking a raw ref of a deref is always safe
Veykril Dec 18, 2024
88be63a
Merge pull request #18711 from Veykril/push-kwurwxttmqwo
Veykril Dec 18, 2024
5105513
internal: Cleanup label structure of `CompletionItem`
Veykril Dec 18, 2024
20bc753
Merge pull request #18713 from Veykril/push-zmmkzspnwxsn
Veykril Dec 18, 2024
11536cc
fix: Do not ask the client ro resolve for non existing label details
Veykril Dec 18, 2024
4db0f68
Merge pull request #18714 from Veykril/push-krxvsqwrokwp
Veykril Dec 18, 2024
950a750
Fix AsmOption rule in rust.ungram
aibaars Dec 18, 2024
29fc82d
fix: Consider both completion detail fields in to_proto
Veykril Dec 18, 2024
84dd3cb
Merge pull request #18716 from Veykril/push-lyxuzrnkmklp
Veykril Dec 18, 2024
4aa34ab
Merge pull request #18715 from aibaars/ungram-asm-option
Veykril Dec 18, 2024
1930075
internal: Set `result_id` for pull diagnostics
Veykril Dec 18, 2024
4f03dd9
Merge pull request #18717 from Veykril/push-pomxnvxotwlr
Veykril Dec 19, 2024
a1924e8
fix: Reduce applicability of unnecessary_async assist
Veykril Dec 20, 2024
4200da4
Merge pull request #18726 from Veykril/push-vyzotyqqtpqs
Veykril Dec 20, 2024
23e2f8a
internal: Split serde derive feature into `serde_derive` usage
Veykril Dec 20, 2024
3309dfa
Merge pull request #18702 from ChayimFriedman2/prep
Veykril Dec 20, 2024
90c345b
Merge pull request #18728 from Veykril/push-ozqlrzmqklwt
Veykril Dec 20, 2024
0e266ae
Fix a case where completion was unable to expand a macro
ChayimFriedman2 Dec 20, 2024
df8b8ec
Merge pull request #18723 from ChayimFriedman2/tracing-complete
Veykril Dec 20, 2024
98fcc05
Clear flycheck diagnostics more granularly
Veykril Dec 20, 2024
3f786bb
Arc the workspace root flycheck
Veykril Dec 20, 2024
bc5a260
Arc the package ids coming from flycheck
Veykril Dec 20, 2024
cb3eba1
Clear all check diagnostics when the workspace changes
Veykril Dec 20, 2024
b694ff3
Merge pull request #18729 from Veykril/push-kyxtnozqzwkn
Veykril Dec 20, 2024
b7bde82
Revert "internal: Drop proc-macro server support for ~1.66.0 and olde…
Veykril Dec 20, 2024
2d895a7
Merge pull request #18731 from rust-lang/revert-18670-push-ylomnylswnxm
Veykril Dec 20, 2024
4f754f4
fix: remove always! check for file_id in runnables
roife Dec 20, 2024
56ced3b
fix: only show debug lens with a valid root
roife Dec 20, 2024
0c409e5
Merge pull request #18727 from roife/fix-issue-18704
Veykril Dec 21, 2024
c2e2360
fix: Set `result_id` for `RelatedFullDocumentDiagnosticReport` everyw…
Veykril Dec 22, 2024
9812c4d
Merge pull request #18735 from Veykril/push-rpuxqrzrzvsw
Veykril Dec 22, 2024
5c302cc
minor: Tell the server to stop prior to restarting it
Veykril Dec 22, 2024
36455e9
Merge pull request #18737 from Veykril/push-rslstwynmzpx
Veykril Dec 22, 2024
15206e4
fix: Don't trigger paren wrapping typing handler after idents
Veykril Dec 22, 2024
b08d1f9
fix: Properly check if workspace flychecking is allowed
Veykril Dec 22, 2024
3613526
Merge pull request #18739 from Veykril/push-ntpvvqnnovtn
Veykril Dec 22, 2024
2a977e0
fix: Fix empty check diagnostics not marking files as changed
Veykril Dec 22, 2024
84b7c8b
Merge pull request #18740 from Veykril/push-tntsvtmtlotw
Veykril Dec 22, 2024
c38d297
Merge pull request #18738 from Veykril/push-vqxqutskzvvu
Veykril Dec 22, 2024
eea63c2
fix: Delay initial flycheck until after build scripts
Veykril Dec 22, 2024
6604f22
fix: Fix flycheck workspace when requested but package was found
Veykril Dec 22, 2024
7bd85e9
Merge pull request #18741 from Veykril/push-nuqmzsrrltux
Veykril Dec 22, 2024
63a3c39
Merge pull request #18742 from Veykril/push-yswvkzmsvqql
Veykril Dec 22, 2024
2141349
Preparing for merge from rust-lang/rust
lnicola Dec 23, 2024
9420a0b
Merge from rust-lang/rust
lnicola Dec 23, 2024
0180d2d
Bump rustc crates
lnicola Dec 23, 2024
8dbdcc0
Merge pull request #18746 from lnicola/sync-from-rust
lnicola Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1011,24 +1011,25 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "lsp-server"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "550446e84739dcaf6d48a4a093973850669e13e8a34d8f8d64851041be267cd9"
dependencies = [
"crossbeam-channel",
"ctrlc",
"log",
"lsp-types",
"serde",
"serde_json",
]

[[package]]
name = "lsp-server"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "550446e84739dcaf6d48a4a093973850669e13e8a34d8f8d64851041be267cd9"
version = "0.7.8"
dependencies = [
"crossbeam-channel",
"ctrlc",
"log",
"lsp-types",
"serde",
"serde_derive",
"serde_json",
]

Expand Down Expand Up @@ -1289,7 +1290,6 @@ name = "paths"
version = "0.0.0"
dependencies = [
"camino",
"serde",
]

[[package]]
Expand Down Expand Up @@ -1352,12 +1352,12 @@ dependencies = [
name = "proc-macro-api"
version = "0.0.0"
dependencies = [
"base-db",
"indexmap",
"intern",
"paths",
"rustc-hash 2.0.0",
"serde",
"serde_derive",
"serde_json",
"span",
"stdx",
Expand All @@ -1369,7 +1369,6 @@ dependencies = [
name = "proc-macro-srv"
version = "0.0.0"
dependencies = [
"base-db",
"expect-test",
"intern",
"libloading",
Expand Down Expand Up @@ -1448,6 +1447,7 @@ dependencies = [
"rustc-hash 2.0.0",
"semver",
"serde",
"serde_derive",
"serde_json",
"span",
"stdx",
Expand Down Expand Up @@ -1507,9 +1507,9 @@ dependencies = [

[[package]]
name = "ra-ap-rustc_abi"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af462c3a2d524b84a51b6848b439787f01b35c6c1086d3e3086a5f5eea92ed9a"
checksum = "28b782af0a7a8df16ddf43cd70da9f17bc3b1ce712c9e4992b6edb16f5f53632"
dependencies = [
"bitflags 2.6.0",
"ra-ap-rustc_index",
Expand All @@ -1518,19 +1518,19 @@ dependencies = [

[[package]]
name = "ra-ap-rustc_index"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be6bb8cb0ab78d94a222f1ffd3e87254cdfb57413382b8d6ebe26a85482f99d1"
checksum = "ce5742f134960482f543b35ecebec3cacc6d79a9a685713518b4d8d70c5f9aa8"
dependencies = [
"ra-ap-rustc_index_macros",
"smallvec",
]

[[package]]
name = "ra-ap-rustc_index_macros"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c24b1641455b46e87435b7321219672077066e678963d239a4a2904732979b16"
checksum = "d7ea011fcf68309a8835ad01d91c032cb18444617b00e2cab21d45b208164441"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -1539,29 +1539,29 @@ dependencies = [

[[package]]
name = "ra-ap-rustc_lexer"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94daa86974417981fed2f12bd8fb00158dfa6fee561152bed689278c846d0272"
checksum = "eb76f0a4d4c20859e41f0a23bff0f37ab9ca9171c214a6c7dd72ea69434865dc"
dependencies = [
"unicode-properties",
"unicode-xid",
]

[[package]]
name = "ra-ap-rustc_parse_format"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc07f6bd581746f358e39c4b6bfe8d455b3d6ad1a857821016d0d42eeb5e1e3e"
checksum = "06080bd35078305421a62da77f3c128482d8d44441b6da8ce9d146d1cd9cdb5b"
dependencies = [
"ra-ap-rustc_index",
"ra-ap-rustc_lexer",
]

[[package]]
name = "ra-ap-rustc_pattern_analysis"
version = "0.85.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f49b86e1276c1c3c72898410def29b699415f4e7d1dfb3531daf79794694372"
checksum = "68a3154fe4c20c177d7b3c678a2d3a97aba0cca156ddef88959915041889daf0"
dependencies = [
"ra-ap-rustc_index",
"rustc-hash 2.0.0",
Expand Down Expand Up @@ -1676,7 +1676,7 @@ dependencies = [
"intern",
"itertools",
"load-cargo",
"lsp-server 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lsp-server 0.7.7",
"lsp-types",
"memchr",
"mimalloc",
Expand All @@ -1695,6 +1695,7 @@ dependencies = [
"scip",
"semver",
"serde",
"serde_derive",
"serde_json",
"stdx",
"syntax",
Expand Down Expand Up @@ -1822,18 +1823,18 @@ dependencies = [

[[package]]
name = "serde"
version = "1.0.206"
version = "1.0.216"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284"
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e"
dependencies = [
"serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.206"
version = "1.0.216"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97"
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
dependencies = [
"proc-macro2",
"quote",
Expand Down Expand Up @@ -1924,12 +1925,6 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"

[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"

[[package]]
name = "stdx"
version = "0.0.0"
Expand All @@ -1946,9 +1941,9 @@ dependencies = [

[[package]]
name = "syn"
version = "2.0.74"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
Expand Down Expand Up @@ -2264,13 +2259,9 @@ dependencies = [

[[package]]
name = "triomphe"
version = "0.1.13"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369"
dependencies = [
"serde",
"stable_deref_trait",
]
checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85"

[[package]]
name = "tt"
Expand Down
15 changes: 8 additions & 7 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" }
edition = { path = "./crates/edition", version = "0.0.0" }

ra-ap-rustc_lexer = { version = "0.85", default-features = false }
ra-ap-rustc_parse_format = { version = "0.85", default-features = false }
ra-ap-rustc_index = { version = "0.85", default-features = false }
ra-ap-rustc_abi = { version = "0.85", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.85", default-features = false }
ra-ap-rustc_lexer = { version = "0.87", default-features = false }
ra-ap-rustc_parse_format = { version = "0.87", default-features = false }
ra-ap-rustc_index = { version = "0.87", default-features = false }
ra-ap-rustc_abi = { version = "0.87", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.87", default-features = false }

# local crates that aren't published to crates.io. These should not have versions.
test-fixture = { path = "./crates/test-fixture" }
Expand Down Expand Up @@ -138,7 +138,8 @@ pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
rustc-hash = "2.0.0"
semver = "1.0.14"
serde = { version = "1.0.192", features = ["derive"] }
serde = { version = "1.0.192" }
serde_derive = { version = "1.0.192" }
serde_json = "1.0.108"
smallvec = { version = "1.10.0", features = [
"const_new",
Expand All @@ -157,7 +158,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
"time",
"tracing-log",
] }
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
triomphe = { version = "0.1.14", default-features = false, features = ["std"] }
url = "2.3.1"
xshell = "0.2.5"

Expand Down
52 changes: 38 additions & 14 deletions src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use smallvec::SmallVec;
use span::{Edition, MacroFileId};
use syntax::{ast, AstPtr, SyntaxNodePtr};
use triomphe::Arc;
use tt::TextRange;

use crate::{
db::DefDatabase,
Expand Down Expand Up @@ -143,15 +144,7 @@ pub struct BodySourceMap {

pub types: TypesSourceMap,

// FIXME: Make this a sane struct.
template_map: Option<
Box<(
// format_args!
FxHashMap<ExprId, (HygieneId, Vec<(syntax::TextRange, Name)>)>,
// asm!
FxHashMap<ExprId, Vec<Vec<(syntax::TextRange, usize)>>>,
)>,
>,
template_map: Option<Box<FormatTemplate>>,

expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, MacroFileId>,

Expand All @@ -160,6 +153,20 @@ pub struct BodySourceMap {
diagnostics: Vec<BodyDiagnostic>,
}

#[derive(Default, Debug, Eq, PartialEq)]
struct FormatTemplate {
/// A map from `format_args!()` expressions to their captures.
format_args_to_captures: FxHashMap<ExprId, (HygieneId, Vec<(syntax::TextRange, Name)>)>,
/// A map from `asm!()` expressions to their captures.
asm_to_captures: FxHashMap<ExprId, Vec<Vec<(syntax::TextRange, usize)>>>,
/// A map from desugared expressions of implicit captures to their source.
///
/// The value stored for each capture is its template literal and offset inside it. The template literal
/// is from the `format_args[_nl]!()` macro and so needs to be mapped up once to go to the user-written
/// template.
implicit_capture_to_source: FxHashMap<ExprId, InFile<(AstPtr<ast::Expr>, TextRange)>>,
}

#[derive(Debug, Eq, PartialEq)]
pub enum BodyDiagnostic {
InactiveCode { node: InFile<SyntaxNodePtr>, cfg: CfgExpr, opts: CfgOptions },
Expand Down Expand Up @@ -798,18 +805,29 @@ impl BodySourceMap {
node: InFile<&ast::FormatArgsExpr>,
) -> Option<(HygieneId, &[(syntax::TextRange, Name)])> {
let src = node.map(AstPtr::new).map(AstPtr::upcast::<ast::Expr>);
let (hygiene, names) =
self.template_map.as_ref()?.0.get(&self.expr_map.get(&src)?.as_expr()?)?;
let (hygiene, names) = self
.template_map
.as_ref()?
.format_args_to_captures
.get(&self.expr_map.get(&src)?.as_expr()?)?;
Some((*hygiene, &**names))
}

pub fn format_args_implicit_capture(
&self,
capture_expr: ExprId,
) -> Option<InFile<(AstPtr<ast::Expr>, TextRange)>> {
self.template_map.as_ref()?.implicit_capture_to_source.get(&capture_expr).copied()
}

pub fn asm_template_args(
&self,
node: InFile<&ast::AsmExpr>,
) -> Option<(ExprId, &[Vec<(syntax::TextRange, usize)>])> {
let src = node.map(AstPtr::new).map(AstPtr::upcast::<ast::Expr>);
let expr = self.expr_map.get(&src)?.as_expr()?;
Some(expr).zip(self.template_map.as_ref()?.1.get(&expr).map(std::ops::Deref::deref))
Some(expr)
.zip(self.template_map.as_ref()?.asm_to_captures.get(&expr).map(std::ops::Deref::deref))
}

/// Get a reference to the body source map's diagnostics.
Expand All @@ -835,8 +853,14 @@ impl BodySourceMap {
types,
} = self;
if let Some(template_map) = template_map {
template_map.0.shrink_to_fit();
template_map.1.shrink_to_fit();
let FormatTemplate {
format_args_to_captures,
asm_to_captures,
implicit_capture_to_source,
} = &mut **template_map;
format_args_to_captures.shrink_to_fit();
asm_to_captures.shrink_to_fit();
implicit_capture_to_source.shrink_to_fit();
}
expr_map.shrink_to_fit();
expr_map_back.shrink_to_fit();
Expand Down
20 changes: 16 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1957,17 +1957,29 @@ impl ExprCollector<'_> {
_ => None,
});
let mut mappings = vec![];
let (fmt, hygiene) = match template.and_then(|it| self.expand_macros_to_string(it)) {
Some((s, is_direct_literal)) => {
let (fmt, hygiene) = match template.and_then(|template| {
self.expand_macros_to_string(template.clone()).map(|it| (it, template))
}) {
Some(((s, is_direct_literal), template)) => {
let call_ctx = self.expander.syntax_context();
let hygiene = self.hygiene_id_for(s.syntax().text_range().start());
let fmt = format_args::parse(
&s,
fmt_snippet,
args,
is_direct_literal,
|name| {
|name, range| {
let expr_id = self.alloc_expr_desugared(Expr::Path(Path::from(name)));
if let Some(range) = range {
self.source_map
.template_map
.get_or_insert_with(Default::default)
.implicit_capture_to_source
.insert(
expr_id,
self.expander.in_file((AstPtr::new(&template), range)),
);
}
if !hygiene.is_root() {
self.body.expr_hygiene.insert(expr_id, hygiene);
}
Expand Down Expand Up @@ -2139,7 +2151,7 @@ impl ExprCollector<'_> {
self.source_map
.template_map
.get_or_insert_with(Default::default)
.0
.format_args_to_captures
.insert(idx, (hygiene, mappings));
idx
}
Expand Down
Loading
Loading