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 #122628

Merged
merged 89 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5db0494
By tracking import use types to check whether it is scope uses or the…
surechen Nov 10, 2023
1c10aa4
Auto merge of #117772 - surechen:for_117448, r=petrochenkov
bors Feb 18, 2024
e057365
Remove suspicious auto trait lint
spastorino Feb 19, 2024
9e4ecc6
Merge commit '4a8d0f7f565b6df45da5522dd7366a4df3460cd7' into sync-fro…
lnicola Feb 25, 2024
2edd74b
Add missing imports
lnicola Feb 25, 2024
f206d8b
Avoid using cfg(FALSE)
lnicola Feb 25, 2024
80470d5
Merge commit '4ef6a49b44e8aa380da7522442234bfd7a52c55e' into sync-fro…
lnicola Mar 3, 2024
49c0b33
Change message type in bug functions.
nnethercote Feb 21, 2024
593156a
Re-use `InferenceTable` by snapshotting in method resolution
Veykril Mar 4, 2024
d21f888
Remove some unnecessary cloning in method_resolution
Veykril Mar 4, 2024
b45cfe1
Added quickfix for unresolved field.
wyatt-herkamp Mar 5, 2024
6027eae
Fix Tests + Fix Warnings
wyatt-herkamp Mar 5, 2024
255ba69
Added tests, added Union Support, and code cleanup
wyatt-herkamp Mar 6, 2024
4f0bc1a
Typo
wyatt-herkamp Mar 6, 2024
f45b080
Starting Fix for cfg stripping
wyatt-herkamp Mar 8, 2024
02b6c18
Compress file text using lz4 in salsa
lnicola Jan 10, 2024
0f43b55
Stop using an Arc when setting the file text
lnicola Jan 10, 2024
a12ccd5
Fix test
lnicola Mar 8, 2024
79f2651
Add cfg_attr and cleanup code
wyatt-herkamp Mar 9, 2024
948a2de
Clippy Fix
wyatt-herkamp Mar 9, 2024
717ba1d
Clippy fixes
lnicola Feb 14, 2024
aa74d57
Merge commit '574e23ec508064613783cba3d1833a95fd9a5080' into sync-fro…
lnicola Mar 10, 2024
ce64207
Bring back in-rust-tree feature to ide
lnicola Mar 10, 2024
fb9744e
Merge branch 'master' into sync-from-rust3
lnicola Mar 11, 2024
f65fe4e
Fix import
lnicola Mar 11, 2024
0931361
Auto merge of #16807 - lnicola:sync-from-rust3, r=lnicola
bors Mar 11, 2024
558feea
internal: Remove synstructure const hack support
Veykril Mar 8, 2024
458f4a2
internal: Treat the self param as different from patterns when lowering
Veykril Mar 6, 2024
c679482
Add method resolution deref inference var test
Veykril Mar 5, 2024
1069f57
Auto merge of #16784 - Veykril:body-invalid, r=Veykril
bors Mar 11, 2024
a5035f4
Auto merge of #16749 - Veykril:on-demand-validation-err, r=Veykril
bors Mar 11, 2024
57a0ad4
Stop eagerly resolving inlay hint text edits for VSCode
SomeoneToIgnore Jan 10, 2024
0dbaccd
Track vscode version for conditional bug server sided bugfixes
Veykril Mar 11, 2024
a58f574
Auto merge of #16762 - wyatt-herkamp:master, r=Veykril
bors Mar 11, 2024
a0dd822
Auto merge of #16473 - SomeoneToIgnore:kb/remove-resolve-stub, r=Veykril
bors Mar 11, 2024
0fb5d0d
Check for cfg_attr on the actual item and Debug instead of info in cf…
wyatt-herkamp Mar 11, 2024
7713657
feat: add fix for unused_variables
Young-Flash Mar 11, 2024
562f4a2
test: update test for unused_variables
Young-Flash Mar 11, 2024
2320e12
Auto merge of #16771 - Veykril:self-param-split, r=Veykril
bors Mar 11, 2024
40ee359
Auto merge of #16810 - Young-Flash:unused_var_fix, r=Veykril
bors Mar 11, 2024
fc11216
feat: Add proc macro semantic token type
ShoyuVanilla Mar 11, 2024
2f87215
Auto merge of #16808 - ShoyuVanilla:proc-macro-sem-token, r=Veykril
bors Mar 11, 2024
8f8bcfc
Auto merge of #16335 - lnicola:salsa-lz4-file-text, r=Veykril
bors Mar 11, 2024
fdc527f
fix: Fix method resolution snapshotting receiver_ty too early
Veykril Mar 11, 2024
03d2d90
Auto merge of #16811 - Veykril:snapshot, r=Veykril
bors Mar 11, 2024
447de3d
Review Updates and added tests.
wyatt-herkamp Mar 11, 2024
d3e6fea
Auto merge of #16789 - wyatt-herkamp:cfg_attr, r=Veykril
bors Mar 12, 2024
cb6c26b
Don't auto-close block comments in strings
lnicola Mar 12, 2024
9bc1eb4
Auto merge of #16820 - lnicola:no-string-comment-autoclose, r=lnicola
bors Mar 12, 2024
9ba4493
internal: Improve rooted upmapping
Veykril Mar 12, 2024
a2e2741
Auto merge of #16819 - Veykril:span-upmapping, r=Veykril
bors Mar 12, 2024
30d3d68
Fix unwanted leading whitespace in hover text
Wilfred Mar 12, 2024
e8182a5
Auto merge of #16824 - Wilfred:size_whitespace, r=lnicola
bors Mar 13, 2024
87e0bbc
Stronger typing for macro_arg query
Veykril Mar 13, 2024
abe3177
Shrink MacroCallLoc
Veykril Mar 13, 2024
9767156
Simplify
Veykril Mar 13, 2024
9c8a57e
fix: simplify extract_module
roife Mar 13, 2024
4180565
fix: donot generate redundant use stmt for items in selection in extr…
roife Mar 14, 2024
6fc3a3e
Auto merge of #16832 - Veykril:macarons, r=Veykril
bors Mar 14, 2024
02214a6
fix: remove redundant use node insertion
roife Mar 14, 2024
6248b45
fix: do not add use stmt when use stmt is selected in extract_module
roife Mar 14, 2024
d2f8eae
feat: Support macro calls in eager macros for IDE features
Veykril Mar 14, 2024
d085ade
Remove dead test code
Veykril Mar 14, 2024
14558af
Auto merge of #16834 - Veykril:macarons, r=Veykril
bors Mar 14, 2024
5b2809f
fix: simplification on extract_module
roife Mar 14, 2024
c50c4f8
internal: Use assoc items as anchors for spans
Veykril Mar 15, 2024
a9a26c1
Auto merge of #16841 - Veykril:macarons, r=Veykril
bors Mar 15, 2024
3b1ad23
internal: Make def site span for proc-macro more invalidation resistant
Veykril Mar 15, 2024
9029c51
Auto merge of #16842 - Veykril:macarons, r=Veykril
bors Mar 15, 2024
08327e0
Drop eager macro parse errors, they can't crop up
Veykril Mar 15, 2024
b59c8c7
Repalce Span with SyntaxContextId in MacroCallLoc
Veykril Mar 15, 2024
de71605
fix: remove useless loop
roife Mar 15, 2024
0dd89d7
Remove usages of SpanData where Span suffices
Veykril Mar 15, 2024
d763e05
Auto merge of #16844 - Veykril:macarons, r=Veykril
bors Mar 15, 2024
eeff20d
Show compilation progress in test explorer
HKalbasi Mar 15, 2024
513c6d3
fix: re-insert use stmts that is extracted
roife Mar 15, 2024
d40c0fe
test: add test for extract_module
roife Mar 15, 2024
10aa999
fix: typo
roife Mar 15, 2024
f9a4d05
Auto merge of #16845 - HKalbasi:test-explorer, r=HKalbasi
bors Mar 15, 2024
dcfc9cc
Distinguish integration tests from crates in test explorer
HKalbasi Mar 15, 2024
d7ec7a5
Auto merge of #16847 - HKalbasi:test-explorer, r=HKalbasi
bors Mar 15, 2024
bf89762
Build releases on Ubuntu 20.04
lnicola Mar 15, 2024
ee03bd0
Auto merge of #16851 - lnicola:ubuntu-20.04, r=lnicola
bors Mar 16, 2024
64c12e6
Bump follow-redirects from 1.15.4 to 1.15.6 in /editors/code
dependabot[bot] Mar 16, 2024
c8badeb
Auto merge of #16854 - rust-lang:dependabot/npm_and_yarn/editors/code…
bors Mar 16, 2024
d69a81f
fix: Fix wrong where clause rendering on hover
Veykril Mar 16, 2024
b94c285
Auto merge of #16856 - Veykril:macarons, r=Veykril
bors Mar 16, 2024
5ecace4
Auto merge of #16846 - roife:fix-issue16826, r=Veykril
bors Mar 16, 2024
20ecf07
Merge commit '5ecace48f693afaa6adf8cb23086b651db3aec96' into sync-fro…
lnicola Mar 17, 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
9 changes: 0 additions & 9 deletions src/tools/rust-analyzer/.github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
code-target: linux-x64
container: ubuntu:18.04
- os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
code-target: linux-arm64
Expand All @@ -63,14 +62,6 @@ jobs:
with:
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Install toolchain dependencies
if: matrix.container == 'ubuntu:18.04'
shell: bash
run: |
apt-get update && apt-get install -y build-essential curl
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH

- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
Expand Down
16 changes: 12 additions & 4 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ version = "0.0.0"
dependencies = [
"cfg",
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lz4_flex",
"rustc-hash",
"salsa",
"semver",
Expand Down Expand Up @@ -134,9 +135,9 @@ dependencies = [

[[package]]
name = "cc"
version = "1.0.89"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723"
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"

[[package]]
name = "cfg"
Expand Down Expand Up @@ -874,9 +875,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"

[[package]]
name = "libloading"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2caa5afb8bf9f3a2652760ce7d4f62d21c4d5a423e68466fca30df82f2330164"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [
"cfg-if",
"windows-targets 0.52.4",
Expand Down Expand Up @@ -992,6 +993,12 @@ dependencies = [
"url",
]

[[package]]
name = "lz4_flex"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "912b45c753ff5f7f5208307e8ace7d2a2e30d024e26d3509f3dce546c044ce15"

[[package]]
name = "mbe"
version = "0.0.0"
Expand Down Expand Up @@ -1597,6 +1604,7 @@ dependencies = [
"rayon",
"rustc-hash",
"scip",
"semver",
"serde",
"serde_json",
"sourcegen",
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ anyhow = "1.0.75"
arrayvec = "0.7.4"
bitflags = "2.4.1"
cargo_metadata = "0.18.1"
chalk-solve = { version = "0.96.0", default-features = false }
chalk-ir = "0.96.0"
chalk-recursive = { version = "0.96.0", default-features = false }
chalk-derive = "0.96.0"
command-group = "2.0.1"
crossbeam-channel = "0.5.8"
dissimilar = "1.0.7"
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rust-version.workspace = true
doctest = false

[dependencies]
lz4_flex = { version = "0.11", default-features = false }

la-arena.workspace = true
salsa.workspace = true
rustc-hash.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions src/tools/rust-analyzer/crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use salsa::Durability;
use triomphe::Arc;
use vfs::FileId;

use crate::{CrateGraph, SourceDatabaseExt, SourceRoot, SourceRootId};
use crate::{CrateGraph, SourceDatabaseExt, SourceDatabaseExt2, SourceRoot, SourceRootId};

/// Encapsulate a bunch of raw `.set` calls on the database.
#[derive(Default)]
pub struct FileChange {
pub roots: Option<Vec<SourceRoot>>,
pub files_changed: Vec<(FileId, Option<Arc<str>>)>,
pub files_changed: Vec<(FileId, Option<String>)>,
pub crate_graph: Option<CrateGraph>,
}

Expand Down Expand Up @@ -42,7 +42,7 @@ impl FileChange {
self.roots = Some(roots);
}

pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
pub fn change_file(&mut self, file_id: FileId, new_text: Option<String>) {
self.files_changed.push((file_id, new_text))
}

Expand All @@ -68,8 +68,8 @@ impl FileChange {
let source_root = db.source_root(source_root_id);
let durability = durability(&source_root);
// XXX: can't actually remove the file, just reset the text
let text = text.unwrap_or_else(|| Arc::from(""));
db.set_file_text_with_durability(file_id, text, durability)
let text = text.unwrap_or_default();
db.set_file_text_with_durability(file_id, &text, durability)
}
if let Some(crate_graph) = self.crate_graph {
db.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH);
Expand Down
43 changes: 43 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod input;

use std::panic;

use salsa::Durability;
use syntax::{ast, Parse, SourceFile};
use triomphe::Arc;

Expand Down Expand Up @@ -42,6 +43,7 @@ pub trait Upcast<T: ?Sized> {
fn upcast(&self) -> &T;
}

pub const DEFAULT_FILE_TEXT_LRU_CAP: usize = 16;
pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
pub const DEFAULT_BORROWCK_LRU_CAP: usize = 1024;

Expand Down Expand Up @@ -89,7 +91,10 @@ fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
#[salsa::query_group(SourceDatabaseExtStorage)]
pub trait SourceDatabaseExt: SourceDatabase {
#[salsa::input]
fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>;

fn file_text(&self, file_id: FileId) -> Arc<str>;

/// Path to a file, relative to the root of its source root.
/// Source root of the file.
#[salsa::input]
Expand All @@ -101,6 +106,44 @@ pub trait SourceDatabaseExt: SourceDatabase {
fn source_root_crates(&self, id: SourceRootId) -> Arc<[CrateId]>;
}

fn file_text(db: &dyn SourceDatabaseExt, file_id: FileId) -> Arc<str> {
let bytes = db.compressed_file_text(file_id);
let bytes =
lz4_flex::decompress_size_prepended(&bytes).expect("lz4 decompression should not fail");
let text = std::str::from_utf8(&bytes).expect("file contents should be valid UTF-8");
Arc::from(text)
}

pub trait SourceDatabaseExt2 {
fn set_file_text(&mut self, file_id: FileId, text: &str) {
self.set_file_text_with_durability(file_id, text, Durability::LOW);
}

fn set_file_text_with_durability(
&mut self,
file_id: FileId,
text: &str,
durability: Durability,
);
}

impl<Db: ?Sized + SourceDatabaseExt> SourceDatabaseExt2 for Db {
fn set_file_text_with_durability(
&mut self,
file_id: FileId,
text: &str,
durability: Durability,
) {
let bytes = text.as_bytes();
let compressed = lz4_flex::compress_prepend_size(bytes);
self.set_compressed_file_text_with_durability(
file_id,
Arc::from(compressed.as_slice()),
durability,
)
}
}

fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[CrateId]> {
let graph = db.crate_graph();
let mut crates = graph
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ mbe.workspace = true
syntax.workspace = true

[lints]
workspace = true
workspace = true
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl CfgExpr {
pub fn parse<S>(tt: &tt::Subtree<S>) -> CfgExpr {
next_cfg_expr(&mut tt.token_trees.iter()).unwrap_or(CfgExpr::Invalid)
}

/// Fold the cfg by querying all basic `Atom` and `KeyValue` predicates.
pub fn fold(&self, query: &dyn Fn(&CfgAtom) -> bool) -> Option<bool> {
match self {
Expand All @@ -62,7 +63,6 @@ impl CfgExpr {
}
}
}

fn next_cfg_expr<S>(it: &mut SliceIter<'_, tt::TokenTree<S>>) -> Option<CfgExpr> {
let name = match it.next() {
None => return None,
Expand Down
9 changes: 5 additions & 4 deletions src/tools/rust-analyzer/crates/flycheck/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ pub enum CargoTestMessage {
},
Suite,
Finished,
Custom {
text: String,
},
}

impl ParseFromLine for CargoTestMessage {
fn from_line(line: &str, error: &mut String) -> Option<Self> {
fn from_line(line: &str, _: &mut String) -> Option<Self> {
let mut deserializer = serde_json::Deserializer::from_str(line);
deserializer.disable_recursion_limit();
if let Ok(message) = CargoTestMessage::deserialize(&mut deserializer) {
return Some(message);
}

error.push_str(line);
error.push('\n');
None
Some(CargoTestMessage::Custom { text: line.to_owned() })
}

fn from_eof() -> Option<Self> {
Expand Down
25 changes: 14 additions & 11 deletions src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::ops::Index;

use base_db::CrateId;
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{name::Name, HirFileId, InFile};
use la_arena::{Arena, ArenaMap};
use rustc_hash::FxHashMap;
Expand Down Expand Up @@ -45,7 +44,8 @@ pub struct Body {
///
/// If this `Body` is for the body of a constant, this will just be
/// empty.
pub params: Vec<PatId>,
pub params: Box<[PatId]>,
pub self_param: Option<BindingId>,
/// The `ExprId` of the actual body expression.
pub body_expr: ExprId,
/// Block expressions in this body that may contain inner items.
Expand All @@ -55,14 +55,15 @@ pub struct Body {
pub type ExprPtr = AstPtr<ast::Expr>;
pub type ExprSource = InFile<ExprPtr>;

pub type PatPtr = AstPtr<Either<ast::Pat, ast::SelfParam>>;
pub type PatPtr = AstPtr<ast::Pat>;
pub type PatSource = InFile<PatPtr>;

pub type LabelPtr = AstPtr<ast::Label>;
pub type LabelSource = InFile<LabelPtr>;

pub type FieldPtr = AstPtr<ast::RecordExprField>;
pub type FieldSource = InFile<FieldPtr>;

pub type PatFieldPtr = AstPtr<ast::RecordPatField>;
pub type PatFieldSource = InFile<PatFieldPtr>;

Expand All @@ -88,6 +89,8 @@ pub struct BodySourceMap {
label_map: FxHashMap<LabelSource, LabelId>,
label_map_back: ArenaMap<LabelId, LabelSource>,

self_param: Option<InFile<AstPtr<ast::SelfParam>>>,

/// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
/// Instead, we use id of expression (`92`) to identify the field.
field_map_back: FxHashMap<ExprId, FieldSource>,
Expand Down Expand Up @@ -215,18 +218,18 @@ impl Body {
fn shrink_to_fit(&mut self) {
let Self {
body_expr: _,
params: _,
self_param: _,
block_scopes,
exprs,
labels,
params,
pats,
bindings,
binding_owners,
} = self;
block_scopes.shrink_to_fit();
exprs.shrink_to_fit();
labels.shrink_to_fit();
params.shrink_to_fit();
pats.shrink_to_fit();
bindings.shrink_to_fit();
binding_owners.shrink_to_fit();
Expand Down Expand Up @@ -297,6 +300,7 @@ impl Default for Body {
params: Default::default(),
block_scopes: Default::default(),
binding_owners: Default::default(),
self_param: Default::default(),
}
}
}
Expand Down Expand Up @@ -354,14 +358,12 @@ impl BodySourceMap {
self.pat_map_back.get(pat).cloned().ok_or(SyntheticSyntax)
}

pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> {
let src = node.map(|it| AstPtr::new(it).wrap_left());
self.pat_map.get(&src).cloned()
pub fn self_param_syntax(&self) -> Option<InFile<AstPtr<ast::SelfParam>>> {
self.self_param
}

pub fn node_self_param(&self, node: InFile<&ast::SelfParam>) -> Option<PatId> {
let src = node.map(|it| AstPtr::new(it).wrap_right());
self.pat_map.get(&src).cloned()
pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> {
self.pat_map.get(&node.map(AstPtr::new)).cloned()
}

pub fn label_syntax(&self, label: LabelId) -> LabelSource {
Expand Down Expand Up @@ -401,6 +403,7 @@ impl BodySourceMap {

fn shrink_to_fit(&mut self) {
let Self {
self_param: _,
expr_map,
expr_map_back,
pat_map,
Expand Down
Loading
Loading