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

⬆️ rust-analyzer #116136

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
940d87b
extend check.overrideCommand and buildScripts.overrideCommand docs re…
RalfJung Aug 21, 2023
2de62be
projects/workspaces
RalfJung Aug 21, 2023
23ffda1
full function signatures option
vxpm Sep 4, 2023
6afa5b0
better handling of spaces & newlines
vxpm Sep 4, 2023
6b487ed
fix & run tests
vxpm Sep 4, 2023
d7a8e80
feat: initial version of bool_to_enum assist
rmehri01 Aug 19, 2023
59738d5
fix: add generated doctest
rmehri01 Aug 19, 2023
83196fd
fix: remove trailing whitespace
rmehri01 Aug 19, 2023
91ac1d6
fix: initializing struct multiple times
Sep 8, 2023
455dacf
fix: only trigger assist on Name
Sep 8, 2023
136a9db
style: rename some locals
Sep 8, 2023
2e13aed
feat: support cross module imports
rmehri01 Sep 9, 2023
7ba2e13
fix: add checks for overwriting incorrect ancestor
rmehri01 Sep 10, 2023
5683df2
Deunwrap inline call
alibektas Aug 9, 2023
68d24b6
Deunwrap inline call v2
alibektas Sep 9, 2023
38491fc
v3
alibektas Sep 10, 2023
9c62571
Deunwrap convert_comment_block
alibektas Aug 9, 2023
b316bcc
replace for loops with sth more idiomatic
alibektas Aug 9, 2023
a66dbd1
v2
alibektas Aug 15, 2023
2fdf7e4
v3
alibektas Sep 10, 2023
25b1b3e
feat: add support for other ADT types and destructuring patterns
rmehri01 Sep 11, 2023
0863024
Make assist lazy again
alibektas Sep 11, 2023
893e191
Make assist lazy again
alibektas Sep 11, 2023
145a101
Deunwrap add_missing_match_arms
alibektas Sep 11, 2023
d794865
remove `as _` on auto importing on trait that is aliased with `_`
dfireBird Jul 22, 2023
df1239b
add tests for insert use with renamed imports
dfireBird Sep 11, 2023
ebbbaaa
refactor: fix clippy lints
shogo-nakano-desu Sep 15, 2023
0bb2298
refactor: remove TODO with no explanation
shogo-nakano-desu Sep 15, 2023
96c3332
refactor: fix clippy lint
shogo-nakano-desu Sep 15, 2023
f4704bc
Switch to in-tree rustc dependencies with a cfg flag
HKalbasi Sep 15, 2023
24b6922
triagebot exclude_labels -> exclude_titles
pitaj Sep 16, 2023
cac796a
Give `unmerge_use` a label explaining what it will affect.
kpreid Sep 16, 2023
c372431
scip: Use load_workspace_at.
emilio Sep 19, 2023
cdaadb6
Auto merge of #15632 - emilio:scip-build-rs, r=lnicola
bors Sep 19, 2023
22b18b9
Auto merge of #15616 - HKalbasi:rustc-deps, r=HKalbasi
bors Sep 19, 2023
1841192
Do not resolve inlayHint.textEdit for VSCode client
SomeoneToIgnore Sep 19, 2023
f9fac02
Use proper editor name
SomeoneToIgnore Sep 19, 2023
0427a23
Auto merge of #15635 - SomeoneToIgnore:fix-vscode-edits, r=Veykril
bors Sep 19, 2023
3a63255
Update chalk version
Wilfred Sep 19, 2023
4778255
Auto merge of #15637 - Wilfred:update_chalk, r=lnicola
bors Sep 20, 2023
dd84306
refactor: remove boxing
shogo-nakano-desu Sep 20, 2023
d6fef2c
Auto merge of #15621 - kpreid:import, r=Veykril
bors Sep 20, 2023
91b012f
Documentation: Add parenthesis to the list of on-typing assists.
tomalexander Sep 21, 2023
60f7473
fix parens when inlining closure local variables
rmehri01 Sep 22, 2023
ea11846
fix parens when inlining closure in body of function
rmehri01 Sep 22, 2023
c22bb03
Auto merge of #15651 - rmehri01:15639_fix_inline_local_closure, r=lni…
bors Sep 22, 2023
fccae08
Auto merge of #15649 - tomalexander:master, r=Veykril
bors Sep 22, 2023
11ffcc0
Auto merge of #15615 - shogo-nakano-desu:refactor/fix-clippy-lints, r…
bors Sep 22, 2023
93562dd
Use parent + and_then instead of ancestors
Veykril Sep 22, 2023
2ededa2
Auto merge of #15432 - alibektas:deunwrap/inline_call, r=Veykril
bors Sep 22, 2023
df75809
Auto merge of #15484 - rmehri01:14779_bool_to_enum_assist, r=Veykril
bors Sep 22, 2023
5855bd8
Auto merge of #15587 - dfireBird:fix-15128, r=Veykril
bors Sep 22, 2023
609bdbc
Auto merge of #15620 - pitaj:no-merges_exclude-titles, r=Veykril
bors Sep 22, 2023
556f0c6
Various small fixes
Veykril Sep 22, 2023
4a8622c
Auto merge of #15652 - Veykril:format_to, r=lnicola
bors Sep 22, 2023
0a91a54
v4
alibektas Sep 22, 2023
622e1a8
Add a test case to `add_missing_match_arms`
alibektas Sep 22, 2023
59bcbaf
Auto merge of #15594 - alibektas:deunwrap/add_missing_match_arms, r=V…
bors Sep 22, 2023
ba7f2bf
Update config docs
Veykril Sep 22, 2023
8139e8e
Auto merge of #15425 - alibektas:deunwrap/convert_comment_block, r=Ve…
bors Sep 22, 2023
2b580a1
Auto merge of #15492 - RalfJung:invocation, r=Veykril
bors Sep 22, 2023
9f3d627
add tests for full signatures
vxpm Sep 23, 2023
10fae62
split detail function
vxpm Sep 23, 2023
e5e937a
Auto merge of #15582 - vxpm:master, r=HKalbasi
bors Sep 24, 2023
588c7d9
minor: hover_simple refactor
DaniPopes Sep 24, 2023
862a300
Auto merge of #15660 - DaniPopes:hover-simple-refactor, r=HKalbasi
bors Sep 24, 2023
4bc746b
Merge commit '862a3004e958082d0e9cbdf1172c5fe2bab6cf2d' into sync-fro…
lnicola Sep 25, 2023
2678cd3
Allow rustc_private for RustAnalyzer
lnicola Sep 25, 2023
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
3 changes: 1 addition & 2 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,7 @@ pub struct RustAnalyzer {
}

impl RustAnalyzer {
pub const ALLOW_FEATURES: &'static str =
"proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink";
pub const ALLOW_FEATURES: &'static str = "rustc_private,proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink";
}

impl Step for RustAnalyzer {
Expand Down
38 changes: 24 additions & 14 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chalk-derive"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff5053a8a42dbff5279a82423946fc56dc1253b76cf211b2b3c14b3aad4e1281"
checksum = "264726159011fc7f22c23eb51f49021ece6e71bc358b96e7f2e842db0b14162b"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -189,9 +189,9 @@ dependencies = [

[[package]]
name = "chalk-ir"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a56de2146a8ed0fcd54f4bd50db852f1de4eac9e1efe568494f106c21b77d2a"
checksum = "d65c17407d4c756b8f7f84344acb0fb96364d0298822743219bb25769b6d00df"
dependencies = [
"bitflags 1.3.2",
"chalk-derive",
Expand All @@ -200,9 +200,9 @@ dependencies = [

[[package]]
name = "chalk-recursive"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc09e6e9531f3544989ef89b189e80fbc7ad9e2f73f1c5e03ddc9ffb0527463"
checksum = "80e2cf7b70bedaaf3a8cf3c93b6120c2bb65be89389124028e724d19e209686e"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -213,9 +213,9 @@ dependencies = [

[[package]]
name = "chalk-solve"
version = "0.92.0"
version = "0.93.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b392e02b4c81ec76d3748da839fc70a5539b83d27c9030668463d34d5110b860"
checksum = "afc67c548d3854f64e97e67dc5b7c88513425c5bfa347cff96b7992ae6379288"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down Expand Up @@ -531,8 +531,6 @@ dependencies = [
"fst",
"hashbrown 0.12.3",
"hir-expand",
"hkalbasi-rustc-ap-rustc_abi",
"hkalbasi-rustc-ap-rustc_index",
"indexmap 2.0.0",
"intern",
"itertools",
Expand All @@ -541,7 +539,7 @@ dependencies = [
"mbe",
"once_cell",
"profile",
"ra-ap-rustc_parse_format",
"rustc-dependencies",
"rustc-hash",
"smallvec",
"stdx",
Expand Down Expand Up @@ -594,7 +592,6 @@ dependencies = [
"expect-test",
"hir-def",
"hir-expand",
"hkalbasi-rustc-ap-rustc_index",
"intern",
"itertools",
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -604,6 +601,7 @@ dependencies = [
"oorandom",
"profile",
"project-model",
"rustc-dependencies",
"rustc-hash",
"scoped-tls",
"smallvec",
Expand Down Expand Up @@ -1277,7 +1275,7 @@ dependencies = [
"drop_bomb",
"expect-test",
"limit",
"ra-ap-rustc_lexer",
"rustc-dependencies",
"sourcegen",
"stdx",
]
Expand Down Expand Up @@ -1594,10 +1592,12 @@ dependencies = [
"oorandom",
"parking_lot 0.12.1",
"parking_lot_core 0.9.6",
"parser",
"proc-macro-api",
"profile",
"project-model",
"rayon",
"rustc-dependencies",
"rustc-hash",
"scip",
"serde",
Expand Down Expand Up @@ -1626,6 +1626,16 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"

[[package]]
name = "rustc-dependencies"
version = "0.0.0"
dependencies = [
"hkalbasi-rustc-ap-rustc_abi",
"hkalbasi-rustc-ap-rustc_index",
"ra-ap-rustc_lexer",
"ra-ap-rustc_parse_format",
]

[[package]]
name = "rustc-hash"
version = "1.1.0"
Expand Down Expand Up @@ -1853,9 +1863,9 @@ dependencies = [
"proc-macro2",
"profile",
"quote",
"ra-ap-rustc_lexer",
"rayon",
"rowan",
"rustc-dependencies",
"rustc-hash",
"smol_str",
"sourcegen",
Expand Down
18 changes: 7 additions & 11 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
tt = { path = "./crates/tt", version = "0.0.0" }
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" }
rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }

# local crates that aren't published to crates.io. These should not have versions.
proc-macro-test = { path = "./crates/proc-macro-test" }
Expand All @@ -90,9 +91,9 @@ lsp-server = { version = "0.7.4" }

# non-local crates
smallvec = { version = "1.10.0", features = [
"const_new",
"union",
"const_generics",
"const_new",
"union",
"const_generics",
] }
smol_str = "0.2.0"
nohash-hasher = "0.2.0"
Expand All @@ -101,11 +102,6 @@ serde = { version = "1.0.156", features = ["derive"] }
serde_json = "1.0.96"
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
# can't upgrade due to dashmap depending on 0.12.3 currently
hashbrown = { version = "0.12.3", features = ["inline-more"], default-features = false }

rustc_lexer = { version = "0.10.0", package = "ra-ap-rustc_lexer" }
rustc_parse_format = { version = "0.10.0", package = "ra-ap-rustc_parse_format", default-features = false }

# Upstream broke this for us so we can't update it
rustc_abi = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
hashbrown = { version = "0.12.3", features = [
"inline-more",
], default-features = false }
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
) -> Result<Subtree, ProcMacroExpansionError>;
}

#[derive(Debug)]
pub enum ProcMacroExpansionError {
Panic(String),
/// Things like "proc macro server was killed by OOM".
Expand Down
8 changes: 4 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ smallvec.workspace = true
hashbrown.workspace = true
triomphe.workspace = true

rustc_abi.workspace = true
rustc_index.workspace = true
rustc_parse_format.workspace = true

rustc-dependencies.workspace = true

# local deps
stdx.workspace = true
Expand All @@ -53,3 +50,6 @@ expect-test = "1.4.0"

# local deps
test-utils.workspace = true

[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
11 changes: 5 additions & 6 deletions src/tools/rust-analyzer/crates/hir-def/src/body/scope.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Name resolution for expressions.
use hir_expand::name::Name;
use la_arena::{Arena, Idx, IdxRange, RawIdx};
use rustc_hash::FxHashMap;
use la_arena::{Arena, ArenaMap, Idx, IdxRange, RawIdx};
use triomphe::Arc;

use crate::{
Expand All @@ -17,7 +16,7 @@ pub type ScopeId = Idx<ScopeData>;
pub struct ExprScopes {
scopes: Arena<ScopeData>,
scope_entries: Arena<ScopeEntry>,
scope_by_expr: FxHashMap<ExprId, ScopeId>,
scope_by_expr: ArenaMap<ExprId, ScopeId>,
}

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -77,10 +76,10 @@ impl ExprScopes {
}

pub fn scope_for(&self, expr: ExprId) -> Option<ScopeId> {
self.scope_by_expr.get(&expr).copied()
self.scope_by_expr.get(expr).copied()
}

pub fn scope_by_expr(&self) -> &FxHashMap<ExprId, ScopeId> {
pub fn scope_by_expr(&self) -> &ArenaMap<ExprId, ScopeId> {
&self.scope_by_expr
}
}
Expand All @@ -94,7 +93,7 @@ impl ExprScopes {
let mut scopes = ExprScopes {
scopes: Arena::default(),
scope_entries: Arena::default(),
scope_by_expr: FxHashMap::default(),
scope_by_expr: ArenaMap::with_capacity(body.exprs.len()),
};
let mut root = scopes.root_scope();
scopes.add_params_bindings(body, root, &body.params);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hir_expand::{
};
use intern::Interned;
use la_arena::{Arena, ArenaMap};
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
use rustc_dependencies::abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
use syntax::ast::{self, HasName, HasVisibility};
use triomphe::Arc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::mem;

use hir_expand::name::Name;
use rustc_parse_format as parse;
use rustc_dependencies::parse_format as parse;
use syntax::{
ast::{self, IsString},
AstToken, SmolStr, TextRange,
Expand Down
13 changes: 7 additions & 6 deletions src/tools/rust-analyzer/crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! A map of all publicly exported items in a crate.

use std::collections::hash_map::Entry;
use std::{fmt, hash::BuildHasherDefault};
use std::{collections::hash_map::Entry, fmt, hash::BuildHasherDefault};

use base_db::CrateId;
use fst::{self, Streamer};
Expand All @@ -11,10 +10,12 @@ use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
use triomphe::Arc;

use crate::item_scope::ImportOrExternCrate;
use crate::{
db::DefDatabase, item_scope::ItemInNs, nameres::DefMap, visibility::Visibility, AssocItemId,
ModuleDefId, ModuleId, TraitId,
db::DefDatabase,
item_scope::{ImportOrExternCrate, ItemInNs},
nameres::DefMap,
visibility::Visibility,
AssocItemId, ModuleDefId, ModuleId, TraitId,
};

type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<FxHasher>>;
Expand Down Expand Up @@ -94,7 +95,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn

// We look only into modules that are public(ly reexported), starting with the crate root.
let root = def_map.module_id(DefMap::ROOT);
let mut worklist = vec![(root, 0)];
let mut worklist = vec![(root, 0u32)];
// Records items' minimum module depth.
let mut depth_map = FxHashMap::default();

Expand Down
8 changes: 3 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//! actually true.

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[allow(unused)]
macro_rules! eprintln {
Expand Down Expand Up @@ -48,7 +49,7 @@ pub mod visibility;
pub mod find_path;
pub mod import_map;

pub use rustc_abi as layout;
pub use rustc_dependencies::abi as layout;
use triomphe::Arc;

#[cfg(test)]
Expand Down Expand Up @@ -498,10 +499,7 @@ impl_from!(Macro2Id, MacroRulesId, ProcMacroId for MacroId);

impl MacroId {
pub fn is_attribute(self, db: &dyn db::DefDatabase) -> bool {
match self {
MacroId::ProcMacroId(it) => it.lookup(db).kind == ProcMacroKind::Attr,
_ => false,
}
matches!(self, MacroId::ProcMacroId(it) if it.lookup(db).kind == ProcMacroKind::Attr)
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/tools/rust-analyzer/crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ oorandom = "11.1.3"
tracing = "0.1.35"
rustc-hash = "1.1.0"
scoped-tls = "1.0.0"
chalk-solve = { version = "0.92.0", default-features = false }
chalk-ir = "0.92.0"
chalk-recursive = { version = "0.92.0", default-features = false }
chalk-derive = "0.92.0"
chalk-solve = { version = "0.93.0", default-features = false }
chalk-ir = "0.93.0"
chalk-recursive = { version = "0.93.0", default-features = false }
chalk-derive = "0.93.0"
la-arena.workspace = true
once_cell = "1.17.0"
triomphe.workspace = true
nohash-hasher.workspace = true
typed-arena = "2.0.1"

rustc_index.workspace = true
rustc-dependencies.workspace = true

# local deps
stdx.workspace = true
Expand All @@ -56,3 +56,6 @@ project-model = { path = "../project-model" }

# local deps
test-utils.workspace = true

[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-ty/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod target;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct RustcEnumVariantIdx(pub LocalEnumVariantId);

impl rustc_index::vec::Idx for RustcEnumVariantIdx {
impl rustc_dependencies::index::vec::Idx for RustcEnumVariantIdx {
fn new(idx: usize) -> Self {
RustcEnumVariantIdx(Idx::from_raw(RawIdx::from(idx as u32)))
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ fn scope_for_offset(
.scope_by_expr()
.iter()
.filter_map(|(id, scope)| {
let InFile { file_id, value } = source_map.expr_syntax(*id).ok()?;
let InFile { file_id, value } = source_map.expr_syntax(id).ok()?;
if from_file == file_id {
return Some((value.text_range(), scope));
}
Expand Down Expand Up @@ -923,7 +923,7 @@ fn adjust(
.scope_by_expr()
.iter()
.filter_map(|(id, scope)| {
let source = source_map.expr_syntax(*id).ok()?;
let source = source_map.expr_syntax(id).ok()?;
// FIXME: correctly handle macro expansion
if source.file_id != from_file {
return None;
Expand Down
Loading
Loading