Skip to content

⬆️ rust-analyzer #101197

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

Merged
merged 62 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1883d1f
activate assoc item test
kartva Aug 7, 2022
196f389
try adding diagnostrics for AssocItems
kartva Aug 8, 2022
c1eae3d
make diagnostic function public
kartva Aug 8, 2022
ad7a1ed
fix: Fix panics on GATs involving const generics
N3xed Aug 16, 2022
87b7797
make impl and trait inactive diagnostics work
kartva Aug 20, 2022
8f87fcb
remove push_diagnostic methods
kartva Aug 20, 2022
23c00ed
fix: formatting
kartva Aug 20, 2022
ac8cb8c
Expect the test to panic by catching the unwind
N3xed Aug 21, 2022
2c0d2e7
internal: remove unnecessary stream writer try_clone in lsp-server
pymongo Aug 22, 2022
f27f4a9
Auto merge of #13078 - pymongo:master, r=Veykril
bors Aug 22, 2022
dea1639
Auto merge of #12965 - DesmondWillowbrook:assoc-method-dimming, r=Vey…
bors Aug 22, 2022
f9d1b26
Replace crossbeam with std's scoped threads
Veykril Aug 11, 2022
c2310a0
Auto merge of #13001 - Veykril:scoped, r=Veykril
bors Aug 22, 2022
fdc28b4
Auto merge of #13021 - N3xed:fix-gat-panics, r=flodiebold
bors Aug 22, 2022
b19f78b
Remove auto-config patching from the VSCode client
Veykril Aug 22, 2022
2abb78d
Pop an error notification when flycheck can't be restarted
Veykril Aug 22, 2022
6711ded
Auto merge of #13088 - Veykril:flycheck-failure, r=Veykril
bors Aug 22, 2022
50ecb09
feat: emit SCIP via rust-analyzer
tjdevries Jun 11, 2022
148bdf8
Do not substitute `Self` when in same impl block
ice1000 Aug 23, 2022
b2bf37c
Auto merge of #12976 - tjdevries:scip, r=Veykril
bors Aug 23, 2022
6627b47
Auto merge of #13090 - ice1k:master, r=Veykril
bors Aug 23, 2022
16315ed
Make punctuation highlighting configurable, disable it by default
Veykril Aug 22, 2022
afc8cfb
Make operator highlighting configurable, disable it by default
Veykril Aug 22, 2022
9a20187
Move highlight configuration from protocol into the feature
Veykril Aug 22, 2022
9700c95
Make doc comment highlight injection configurable
Veykril Aug 22, 2022
b26733f
Change attribute semantic token type to decorator
Veykril Aug 22, 2022
f6f0516
Add config for macro bang token highlighting, disable by default
Veykril Aug 22, 2022
eadc267
Regen docs
Veykril Aug 22, 2022
31fb917
Remove unused default semantic modifiers
Veykril Aug 22, 2022
2a26b05
Use lsp-types DECORATOR token type
Veykril Aug 23, 2022
6c5d158
fix: Fix reference autocompletions using incorrect offsets in macro i…
Veykril Aug 23, 2022
631ed2a
Auto merge of #13092 - Veykril:ref-match-completion, r=Veykril
bors Aug 23, 2022
f045f14
Auto merge of #13084 - Veykril:highlight-config, r=Veykril
bors Aug 23, 2022
16a0eb1
Avoid error popup when using in Live Share
Aug 23, 2022
dcbbb7f
ForGoT tO RuN prEttIeR¿
Aug 23, 2022
8969655
Allow leading `|` in more pattern positions
Aug 23, 2022
e73b7a9
Auto merge of #13096 - jonas-schievink:parse-more-or-pats, r=jonas-sc…
bors Aug 23, 2022
0cc1a89
Add a short blurb about VS Code Live Share to the manual
Aug 23, 2022
27e17ff
Auto merge of #13097 - jonas-schievink:liveshare-docs, r=jonas-schievink
bors Aug 23, 2022
5804412
Register decorator token type to avoid panic
Aug 23, 2022
8dcf4c7
Auto merge of #13099 - jonas-schievink:add-decorator-token, r=jonas-s…
bors Aug 23, 2022
322e706
Resolve doc links on impl blocks
Aug 23, 2022
1456b80
Auto merge of #13100 - jonas-schievink:doc-links-on-impl, r=jonas-sch…
bors Aug 23, 2022
715e3fc
Re-export standard semantic token types and mods
Veykril Aug 23, 2022
e3dc5a5
Auto merge of #13101 - Veykril:sem-tokens, r=jonas-schievink
bors Aug 23, 2022
71c15f2
add test
kartva Aug 25, 2022
9480b38
extract const generic in ArrayType
kartva Aug 25, 2022
0d7ba13
style: run tidy tests
kartva Aug 25, 2022
1061793
Remove unused UpdatesChannel type
lnicola Aug 25, 2022
d025c5d
Make use of NoHash hashing for FileId and CrateId
Veykril Aug 25, 2022
0c9375b
Remove u/i128 hashing overloads from NoHashHasher::Hasher impl
Veykril Aug 25, 2022
6eb7689
Auto merge of #13118 - lnicola:cleanup, r=lnicola
bors Aug 25, 2022
5b6aefe
Update test fixtures
Veykril Aug 25, 2022
ca8093e
Auto merge of #13116 - Veykril:nohash, r=Veykril
bors Aug 25, 2022
5c52e05
Auto merge of #13110 - DesmondWillowbrook:issue-11197, r=jonas-schievink
bors Aug 26, 2022
55bf51d
Auto merge of #13087 - Veykril:config-update, r=Veykril
bors Aug 26, 2022
78a7a81
minor: Simplify
Veykril Aug 26, 2022
ca4e10b
Auto merge of #13123 - Veykril:simplify, r=Veykril
bors Aug 26, 2022
6bea872
Auto merge of #13095 - jonas-schievink:avoid-liveshare-error, r=jonas…
bors Aug 26, 2022
9ad0a8c
Move empty diagnostics workaround back into the server
Veykril Aug 28, 2022
e8e598f
Auto merge of #13133 - Veykril:diag-hack, r=Veykril
bors Aug 28, 2022
367f2ad
:arrow_up: rust-analyzer
lnicola Aug 30, 2022
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
81 changes: 54 additions & 27 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,6 @@ dependencies = [
"cfg-if",
]

[[package]]
name = "crossbeam"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
dependencies = [
"cfg-if",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]

[[package]]
name = "crossbeam-channel"
version = "0.5.6"
Expand Down Expand Up @@ -296,16 +282,6 @@ dependencies = [
"scopeguard",
]

[[package]]
name = "crossbeam-queue"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7"
dependencies = [
"cfg-if",
"crossbeam-utils",
]

[[package]]
name = "crossbeam-utils"
version = "0.8.11"
Expand Down Expand Up @@ -728,6 +704,7 @@ dependencies = [
"ide-db",
"itertools",
"parser",
"stdx",
"syntax",
"test-utils",
"text-edit",
Expand Down Expand Up @@ -895,9 +872,9 @@ dependencies = [

[[package]]
name = "lsp-types"
version = "0.93.0"
version = "0.93.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70c74e2173b2b31f8655d33724b4b45ac13f439386f66290f539c22b144c2212"
checksum = "a3bcfee315dde785ba887edb540b08765fd7df75a7d948844be6bf5712246734"
dependencies = [
"bitflags",
"serde",
Expand Down Expand Up @@ -1178,7 +1155,6 @@ dependencies = [
name = "proc-macro-srv"
version = "0.0.0"
dependencies = [
"crossbeam",
"expect-test",
"libloading",
"mbe",
Expand Down Expand Up @@ -1254,6 +1230,26 @@ dependencies = [
"tracing",
]

[[package]]
name = "protobuf"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ee4a7d8b91800c8f167a6268d1a1026607368e1adc84e98fe044aeb905302f7"
dependencies = [
"once_cell",
"protobuf-support",
"thiserror",
]

[[package]]
name = "protobuf-support"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ca157fe12fc7ee2e315f2f735e27df41b3d97cdd70ea112824dac1ffb08ee1c"
dependencies = [
"thiserror",
]

[[package]]
name = "pulldown-cmark"
version = "0.9.2"
Expand Down Expand Up @@ -1385,6 +1381,7 @@ dependencies = [
"project-model",
"rayon",
"rustc-hash",
"scip",
"serde",
"serde_json",
"sourcegen",
Expand Down Expand Up @@ -1471,6 +1468,15 @@ dependencies = [
"winapi-util",
]

[[package]]
name = "scip"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2bfbb10286f69fad7c78db71004b7839bf957788359fe0c479f029f9849136b"
dependencies = [
"protobuf",
]

[[package]]
name = "scoped-tls"
version = "1.0.0"
Expand Down Expand Up @@ -1656,6 +1662,26 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a"

[[package]]
name = "thiserror"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [
"thiserror-impl",
]

[[package]]
name = "thiserror-impl"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

[[package]]
name = "thread_local"
version = "1.1.4"
Expand Down Expand Up @@ -1896,6 +1922,7 @@ dependencies = [
"indexmap",
"paths",
"rustc-hash",
"stdx",
]

[[package]]
Expand Down
40 changes: 28 additions & 12 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
use std::{fmt, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};

use cfg::CfgOptions;
use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::FxHashMap;
use stdx::hash::{NoHashHashMap, NoHashHashSet};
use syntax::SmolStr;
use tt::Subtree;
use vfs::{file_set::FileSet, FileId, VfsPath};
use vfs::{file_set::FileSet, AnchoredPath, FileId, VfsPath};

/// Files are grouped into source roots. A source root is a directory on the
/// file systems which is watched for changes. Typically it corresponds to a
Expand All @@ -31,22 +32,30 @@ pub struct SourceRoot {
/// Libraries are considered mostly immutable, this assumption is used to
/// optimize salsa's query structure
pub is_library: bool,
pub(crate) file_set: FileSet,
file_set: FileSet,
}

impl SourceRoot {
pub fn new_local(file_set: FileSet) -> SourceRoot {
SourceRoot { is_library: false, file_set }
}

pub fn new_library(file_set: FileSet) -> SourceRoot {
SourceRoot { is_library: true, file_set }
}

pub fn path_for_file(&self, file: &FileId) -> Option<&VfsPath> {
self.file_set.path_for_file(file)
}

pub fn file_for_path(&self, path: &VfsPath) -> Option<&FileId> {
self.file_set.file_for_path(path)
}

pub fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
self.file_set.resolve_path(path)
}

pub fn iter(&self) -> impl Iterator<Item = FileId> + '_ {
self.file_set.iter()
}
Expand All @@ -72,12 +81,19 @@ impl SourceRoot {
/// <https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/architecture.md#serialization>
#[derive(Debug, Clone, Default /* Serialize, Deserialize */)]
pub struct CrateGraph {
arena: FxHashMap<CrateId, CrateData>,
arena: NoHashHashMap<CrateId, CrateData>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct CrateId(pub u32);

impl stdx::hash::NoHashHashable for CrateId {}
impl std::hash::Hash for CrateId {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CrateName(SmolStr);

Expand Down Expand Up @@ -342,7 +358,7 @@ impl CrateGraph {
// Check if adding a dep from `from` to `to` creates a cycle. To figure
// that out, look for a path in the *opposite* direction, from `to` to
// `from`.
if let Some(path) = self.find_path(&mut FxHashSet::default(), dep.crate_id, from) {
if let Some(path) = self.find_path(&mut NoHashHashSet::default(), dep.crate_id, from) {
let path = path.into_iter().map(|it| (it, self[it].display_name.clone())).collect();
let err = CyclicDependenciesError { path };
assert!(err.from().0 == from && err.to().0 == dep.crate_id);
Expand All @@ -365,7 +381,7 @@ impl CrateGraph {
/// including the crate itself.
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
let mut worklist = vec![of];
let mut deps = FxHashSet::default();
let mut deps = NoHashHashSet::default();

while let Some(krate) = worklist.pop() {
if !deps.insert(krate) {
Expand All @@ -382,10 +398,10 @@ impl CrateGraph {
/// including the crate itself.
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
let mut worklist = vec![of];
let mut rev_deps = FxHashSet::default();
let mut rev_deps = NoHashHashSet::default();
rev_deps.insert(of);

let mut inverted_graph = FxHashMap::<_, Vec<_>>::default();
let mut inverted_graph = NoHashHashMap::<_, Vec<_>>::default();
self.arena.iter().for_each(|(&krate, data)| {
data.dependencies
.iter()
Expand All @@ -409,7 +425,7 @@ impl CrateGraph {
/// come before the crate itself).
pub fn crates_in_topological_order(&self) -> Vec<CrateId> {
let mut res = Vec::new();
let mut visited = FxHashSet::default();
let mut visited = NoHashHashSet::default();

for krate in self.arena.keys().copied() {
go(self, &mut visited, &mut res, krate);
Expand All @@ -419,7 +435,7 @@ impl CrateGraph {

fn go(
graph: &CrateGraph,
visited: &mut FxHashSet<CrateId>,
visited: &mut NoHashHashSet<CrateId>,
res: &mut Vec<CrateId>,
source: CrateId,
) {
Expand Down Expand Up @@ -459,7 +475,7 @@ impl CrateGraph {

fn find_path(
&self,
visited: &mut FxHashSet<CrateId>,
visited: &mut NoHashHashSet<CrateId>,
from: CrateId,
to: CrateId,
) -> Option<Vec<CrateId>> {
Expand Down
12 changes: 6 additions & 6 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod fixture;

use std::{panic, sync::Arc};

use rustc_hash::FxHashSet;
use stdx::hash::NoHashHashSet;
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};

pub use crate::{
Expand Down Expand Up @@ -58,7 +58,7 @@ pub trait FileLoader {
/// Text of the file.
fn file_text(&self, file_id: FileId) -> Arc<String>;
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
fn relevant_crates(&self, file_id: FileId) -> Arc<NoHashHashSet<CrateId>>;
}

/// Database which stores all significant input facts: source code and project
Expand Down Expand Up @@ -94,10 +94,10 @@ pub trait SourceDatabaseExt: SourceDatabase {
#[salsa::input]
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;

fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>;
fn source_root_crates(&self, id: SourceRootId) -> Arc<NoHashHashSet<CrateId>>;
}

fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> {
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<NoHashHashSet<CrateId>> {
let graph = db.crate_graph();
let res = graph
.iter()
Expand All @@ -120,10 +120,10 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
// FIXME: this *somehow* should be platform agnostic...
let source_root = self.0.file_source_root(path.anchor);
let source_root = self.0.source_root(source_root);
source_root.file_set.resolve_path(path)
source_root.resolve_path(path)
}

fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
fn relevant_crates(&self, file_id: FileId) -> Arc<NoHashHashSet<CrateId>> {
let _p = profile::span("relevant_crates");
let source_root = self.0.file_source_root(file_id);
self.0.source_root_crates(source_root)
Expand Down
10 changes: 6 additions & 4 deletions src/tools/rust-analyzer/crates/flycheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub enum Progress {
DidCheckCrate(String),
DidFinish(io::Result<()>),
DidCancel,
DidFailToRestart(String),
}

enum Restart {
Expand Down Expand Up @@ -193,10 +194,11 @@ impl FlycheckActor {
self.progress(Progress::DidStart);
}
Err(error) => {
tracing::error!(
command = ?self.check_command(),
%error, "failed to restart flycheck"
);
self.progress(Progress::DidFailToRestart(format!(
"Failed to run the following command: {:?} error={}",
self.check_command(),
error
)));
}
}
}
Expand Down
Loading