Skip to content

Rollup of 8 pull requests #138310

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 90 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
66368aa
Allow unsetting default cfgs
Veykril Feb 27, 2025
f19b205
Warn when the used toolchain looks too old for rust-analyzer
Veykril Feb 27, 2025
43c5e95
Normalize some assist names
Veykril Mar 2, 2025
2f9e558
add diagnostic for dangling dyn
Shourya742 Mar 2, 2025
1840f57
add diagnostic for dangling impl
Shourya742 Mar 2, 2025
c2a630e
Add dangling impl
Shourya742 Mar 3, 2025
c315ad9
Support tuple struct patterns for expand_rest_pattern assist
Veykril Mar 2, 2025
6610e60
Merge pull request #19244 from Veykril/push-nmnrnlysvyvk
Veykril Mar 3, 2025
73e0fe1
Merge pull request #19243 from Veykril/push-qrrqsywkwyzp
Veykril Mar 3, 2025
16644ba
Merge pull request #19261 from Veykril/push-rnqlyrvqpols
Veykril Mar 3, 2025
de07b17
Bump minimum supported toolchain to 1.82
lnicola Mar 3, 2025
d137fee
Merge pull request #19275 from lnicola/min-1-82
Veykril Mar 3, 2025
0d6dfc8
Improve keyword completion for 'let' and 'let mut'
Natural-selection1 Mar 4, 2025
120d549
change 'let mut' keyword completion into 'ietm' snippet
Natural-selection1 Mar 4, 2025
b9d157c
Twiddle with the rustup invocation on CI
lnicola Mar 5, 2025
9a8968f
Merge pull request #19265 from Shourya742/2025-03-01-add-dangling-dyn…
lnicola Mar 5, 2025
e260467
Merge pull request #19286 from lnicola/twiddle-ci
lnicola Mar 5, 2025
0ffef9b
minicore: Add size_of to prelude and add rust_2024 prelude
thaliaarchi Mar 5, 2025
653801b
Use size_of from the prelude instead of imported
thaliaarchi Mar 5, 2025
5ad05fb
Merge pull request #19288 from thaliaarchi/use-prelude-size-of
Veykril Mar 5, 2025
5421fba
add test cases for 'letm' keyword completion
Natural-selection1 Mar 5, 2025
049f4db
Add warning and debug information when `cargo metadata` fails
aibaars Mar 5, 2025
52525bc
Improve tracing log format in cargo_workspace.rs
aibaars Mar 5, 2025
87815f7
Use HIR unsafety information for unsafe syntax highlightng
Veykril Mar 3, 2025
b9f5453
Merge pull request #19274 from Veykril/push-pouwrwwrlrlt
Veykril Mar 5, 2025
8641805
Fix syntax highlightingg punct filtering ignoring mods
Veykril Mar 5, 2025
363297d
Merge pull request #19279 from Natural-selection1/master
Veykril Mar 5, 2025
2cff701
Merge pull request #19292 from Veykril/push-zonnrrlosqmv
Veykril Mar 5, 2025
bee6cdd
fix: Make RustAnalyzer:Run available in manifest file
alibektas Mar 5, 2025
d95d278
Adjust relevance scoring threshold to consistent with existing implem…
Natural-selection1 Mar 6, 2025
86741ea
Merge pull request #19297 from Natural-selection1/master
Veykril Mar 6, 2025
2e6292c
Merge pull request #19295 from alibektas/rust_analyzer_run_on_cargo_toml
Veykril Mar 6, 2025
66a1164
Change `%e` to `?e` to include detailed error message
aibaars Mar 6, 2025
6a3ede1
Merge pull request #19290 from aibaars/patch-1
Veykril Mar 6, 2025
860637a
Normalize projections in evaluated const display and layout calculation
ChayimFriedman2 Feb 27, 2025
fcb34b1
Pass the target crate in `HirFormatter`
ChayimFriedman2 Feb 27, 2025
92de0ff
Use correct crate for trait env in `render_const_scalar()`
ChayimFriedman2 Feb 27, 2025
0bd3229
Warn the user when a rename will change the meaning of the program
ChayimFriedman2 Feb 1, 2025
b58fc9c
Mark `rust-analyzer.showSyntaxTree` config option as requiring server…
ChayimFriedman2 Mar 6, 2025
c4f727b
Merge pull request #19304 from ChayimFriedman2/restart-syntax-tree
ChayimFriedman2 Mar 6, 2025
f68fd66
Fix logical error in relevance scoring implementation
Natural-selection1 Mar 7, 2025
16878eb
Refactor relevance scoring to use a named constant BASE_SCORE
Natural-selection1 Mar 7, 2025
c8d9d5a
Move project MSRV back to 1.78
Veykril Mar 7, 2025
5c6a124
Pop up a notification for the MSRV project loading warning
Veykril Mar 7, 2025
02c9b7c
Merge pull request #19307 from Natural-selection1/master
Veykril Mar 7, 2025
d11c5b8
Merge pull request #19308 from Veykril/push-rnrxutwlvmly
Veykril Mar 7, 2025
bdf602a
Log build script error output in `load_cargo::load_workspace_at`
aibaars Mar 7, 2025
e98837f
fix(hir): `VariantDef` is `impl HasSource`
snprajwal Mar 7, 2025
b6f1ce8
fix: do not apply editorconfig to git commit msg
snprajwal Mar 7, 2025
871be8f
Add missing `GH_TOKEN` environment variable
Kobzol Mar 8, 2025
ff67423
Fix checkout in post-merge workflow
Kobzol Mar 8, 2025
e88f892
Fix syntax fixup producing invalid punctuation
Feb 28, 2025
fee83ba
Generated doc update
Feb 28, 2025
bb82831
Bump chalk for built-in supports of async closures
ShoyuVanilla Feb 26, 2025
0e4f189
internal: Migrate `inline_local_variable` to `SyntaxEditor`
ShoyuVanilla Mar 9, 2025
965a0c0
fix: Prevent wrong invocations of `needs_parens_in` with non-ancestra…
ShoyuVanilla Mar 9, 2025
60da021
Merge pull request #19324 from ShoyuVanilla/migrate-inline-var
Veykril Mar 9, 2025
e1912f8
Rank ADT constructors as constructors for completion scoring
Veykril Mar 9, 2025
295c70e
Fix O(tests) stack usage in edition 2024 mergeable doctests
saethlin Mar 9, 2025
129545f
Merge pull request #19325 from Veykril/push-sxyvwwsmtxrr
Veykril Mar 10, 2025
f36e2ea
Merge pull request #19232 from ShoyuVanilla/issue-19196
Veykril Mar 10, 2025
b2501ef
Merge pull request #19252 from flodiebold/fix-fixup-delimiters
Veykril Mar 10, 2025
b2a4f3d
Merge pull request #19316 from snprajwal/git-commit-ec
Veykril Mar 10, 2025
71b9103
Merge pull request #19314 from snprajwal/variantdef-impl
Veykril Mar 10, 2025
c961ee6
Merge pull request #19311 from aibaars/log-build-script-error
Veykril Mar 10, 2025
7ee9ce8
Fix `path` macro hygiene
Veykril Mar 10, 2025
fdee1c1
Preparing for merge from rust-lang/rust
lnicola Mar 10, 2025
e1da1b0
Merge from rust-lang/rust
lnicola Mar 10, 2025
f53d1eb
Merge pull request #19327 from Veykril/push-qyyvkulltzpz
Veykril Mar 10, 2025
44fad0b
Merge pull request #19079 from ChayimFriedman2/rename-conflict
Veykril Mar 10, 2025
1483cb6
Handle empty test suites in job summary report
Kobzol Mar 10, 2025
1c8acd4
Merge pull request #19330 from ChayimFriedman2/normalize-projection
Veykril Mar 10, 2025
ee79f3e
Run proc-macro server tests are separate CI job
Veykril Mar 10, 2025
87d5bf2
Bump rustc crates
lnicola Mar 10, 2025
c372c55
Fix simd layout test
lnicola Mar 10, 2025
af32b22
Merge pull request #19328 from Veykril/push-umwykvoskvyp
Veykril Mar 10, 2025
1d983bf
Format code
lnicola Mar 10, 2025
52f39ff
Merge pull request #19331 from lnicola/sync-from-rust
lnicola Mar 10, 2025
063ef18
Revert "Use workspace lints for crates in `compiler/` #138084"
jieyouxu Mar 10, 2025
dc576cb
Add remark for missing llvm-tools component re. rustc_private linker …
xizheyin Mar 10, 2025
61122d1
Delegation: fix ICE with invalid MethodCall generation
Bryanskiy Mar 10, 2025
bc4f0bb
Pass InferCtxt to InlineAsmCtxt to properly taint on error
compiler-errors Mar 6, 2025
150e88c
Rollup merge of #137931 - xizheyin:issue-137421, r=jieyouxu
matthiaskrgr Mar 10, 2025
69c7e36
Rollup merge of #138138 - compiler-errors:inline-asm-tainting, r=oli-obk
matthiaskrgr Mar 10, 2025
739672c
Rollup merge of #138223 - Kobzol:fix-post-merge, r=marcoieni
matthiaskrgr Mar 10, 2025
5717cc9
Rollup merge of #138268 - Kobzol:fix-summary-nan, r=jieyouxu
matthiaskrgr Mar 10, 2025
0d63119
Rollup merge of #138278 - Bryanskiy:delegation-ice-1, r=petrochenkov
matthiaskrgr Mar 10, 2025
d1a875c
Rollup merge of #138281 - saethlin:mergeable-doctests-stacksize, r=Gu…
matthiaskrgr Mar 10, 2025
2abecee
Rollup merge of #138305 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Mar 10, 2025
44ec67f
Rollup merge of #138306 - jieyouxu:revert-workspace-lints, r=Noratrieb
matthiaskrgr Mar 10, 2025
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
Prev Previous commit
Next Next commit
Warn when the used toolchain looks too old for rust-analyzer
  • Loading branch information
Veykril committed Feb 27, 2025
commit f19b205df4cf90067c9590a752b3de46df4baf22
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ use triomphe::Arc;
use vfs::{AbsPath, AbsPathBuf, FileId, VfsPath};

use crate::{
completion_item_hash,
config::{Config, RustfmtConfig, WorkspaceSymbolConfig},
diagnostics::convert_diagnostic,
global_state::{FetchWorkspaceRequest, GlobalState, GlobalStateSnapshot},
hack_recover_crate_name,
line_index::LineEndings,
lsp::{
completion_item_hash,
ext::{
InternalTestingFetchConfigOption, InternalTestingFetchConfigParams,
InternalTestingFetchConfigResponse,
Expand Down
121 changes: 9 additions & 112 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
//! The `cli` submodule implements some batch-processing analysis, primarily as
//! a debugging aid.

/// Any toolchain less than this version will likely not work with rust-analyzer built from this revision.
pub const MINIMUM_SUPPORTED_TOOLCHAIN_VERSION: semver::Version = semver::Version {
major: 1,
minor: 78,
patch: 0,
pre: semver::Prerelease::EMPTY,
build: semver::BuildMetadata::EMPTY,
};

pub mod cli;

mod command;
Expand Down Expand Up @@ -47,10 +56,7 @@ use self::lsp::ext as lsp_ext;
#[cfg(test)]
mod integrated_benchmarks;

use hir::Mutability;
use ide::{CompletionItem, CompletionItemRefMode, CompletionRelevance};
use serde::de::DeserializeOwned;
use tenthash::TentHash;

pub use crate::{
lsp::capabilities::server_capabilities, main_loop::main_loop, reload::ws_to_crate_graph,
Expand All @@ -65,115 +71,6 @@ pub fn from_json<T: DeserializeOwned>(
.map_err(|e| anyhow::format_err!("Failed to deserialize {what}: {e}; {json}"))
}

fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8; 20] {
fn hash_completion_relevance(hasher: &mut TentHash, relevance: &CompletionRelevance) {
use ide_completion::{
CompletionRelevancePostfixMatch, CompletionRelevanceReturnType,
CompletionRelevanceTypeMatch,
};

hasher.update([
u8::from(relevance.exact_name_match),
u8::from(relevance.is_local),
u8::from(relevance.is_name_already_imported),
u8::from(relevance.requires_import),
u8::from(relevance.is_private_editable),
]);

match relevance.type_match {
None => hasher.update([0u8]),
Some(CompletionRelevanceTypeMatch::CouldUnify) => hasher.update([1u8]),
Some(CompletionRelevanceTypeMatch::Exact) => hasher.update([2u8]),
}

hasher.update([u8::from(relevance.trait_.is_some())]);
if let Some(trait_) = &relevance.trait_ {
hasher.update([u8::from(trait_.is_op_method), u8::from(trait_.notable_trait)]);
}

match relevance.postfix_match {
None => hasher.update([0u8]),
Some(CompletionRelevancePostfixMatch::NonExact) => hasher.update([1u8]),
Some(CompletionRelevancePostfixMatch::Exact) => hasher.update([2u8]),
}

hasher.update([u8::from(relevance.function.is_some())]);
if let Some(function) = &relevance.function {
hasher.update([u8::from(function.has_params), u8::from(function.has_self_param)]);
let discriminant: u8 = match function.return_type {
CompletionRelevanceReturnType::Other => 0,
CompletionRelevanceReturnType::DirectConstructor => 1,
CompletionRelevanceReturnType::Constructor => 2,
CompletionRelevanceReturnType::Builder => 3,
};
hasher.update([discriminant]);
}
}

let mut hasher = TentHash::new();
hasher.update([
u8::from(is_ref_completion),
u8::from(item.is_snippet),
u8::from(item.deprecated),
u8::from(item.trigger_call_info),
]);

hasher.update(item.label.primary.len().to_ne_bytes());
hasher.update(&item.label.primary);

hasher.update([u8::from(item.label.detail_left.is_some())]);
if let Some(label_detail) = &item.label.detail_left {
hasher.update(label_detail.len().to_ne_bytes());
hasher.update(label_detail);
}

hasher.update([u8::from(item.label.detail_right.is_some())]);
if let Some(label_detail) = &item.label.detail_right {
hasher.update(label_detail.len().to_ne_bytes());
hasher.update(label_detail);
}

// NB: do not hash edits or source range, as those may change between the time the client sends the resolve request
// and the time it receives it: some editors do allow changing the buffer between that, leading to ranges being different.
//
// Documentation hashing is skipped too, as it's a large blob to process,
// while not really making completion properties more unique as they are already.

let kind_tag = item.kind.tag();
hasher.update(kind_tag.len().to_ne_bytes());
hasher.update(kind_tag);

hasher.update(item.lookup.len().to_ne_bytes());
hasher.update(&item.lookup);

hasher.update([u8::from(item.detail.is_some())]);
if let Some(detail) = &item.detail {
hasher.update(detail.len().to_ne_bytes());
hasher.update(detail);
}

hash_completion_relevance(&mut hasher, &item.relevance);

hasher.update([u8::from(item.ref_match.is_some())]);
if let Some((ref_mode, text_size)) = &item.ref_match {
let discriminant = match ref_mode {
CompletionItemRefMode::Reference(Mutability::Shared) => 0u8,
CompletionItemRefMode::Reference(Mutability::Mut) => 1u8,
CompletionItemRefMode::Dereference => 2u8,
};
hasher.update([discriminant]);
hasher.update(u32::from(*text_size).to_ne_bytes());
}

hasher.update(item.import_to_add.len().to_ne_bytes());
for import_path in &item.import_to_add {
hasher.update(import_path.len().to_ne_bytes());
hasher.update(import_path);
}

hasher.finalize()
}

#[doc(hidden)]
macro_rules! try_default_ {
($it:expr $(,)?) => {
Expand Down
113 changes: 113 additions & 0 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

use core::fmt;

use hir::Mutability;
use ide::{CompletionItem, CompletionItemRefMode, CompletionRelevance};
use tenthash::TentHash;

pub mod ext;

pub(crate) mod capabilities;
Expand Down Expand Up @@ -29,3 +33,112 @@ impl fmt::Display for LspError {
}

impl std::error::Error for LspError {}

pub(crate) fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8; 20] {
fn hash_completion_relevance(hasher: &mut TentHash, relevance: &CompletionRelevance) {
use ide_completion::{
CompletionRelevancePostfixMatch, CompletionRelevanceReturnType,
CompletionRelevanceTypeMatch,
};

hasher.update([
u8::from(relevance.exact_name_match),
u8::from(relevance.is_local),
u8::from(relevance.is_name_already_imported),
u8::from(relevance.requires_import),
u8::from(relevance.is_private_editable),
]);

match relevance.type_match {
None => hasher.update([0u8]),
Some(CompletionRelevanceTypeMatch::CouldUnify) => hasher.update([1u8]),
Some(CompletionRelevanceTypeMatch::Exact) => hasher.update([2u8]),
}

hasher.update([u8::from(relevance.trait_.is_some())]);
if let Some(trait_) = &relevance.trait_ {
hasher.update([u8::from(trait_.is_op_method), u8::from(trait_.notable_trait)]);
}

match relevance.postfix_match {
None => hasher.update([0u8]),
Some(CompletionRelevancePostfixMatch::NonExact) => hasher.update([1u8]),
Some(CompletionRelevancePostfixMatch::Exact) => hasher.update([2u8]),
}

hasher.update([u8::from(relevance.function.is_some())]);
if let Some(function) = &relevance.function {
hasher.update([u8::from(function.has_params), u8::from(function.has_self_param)]);
let discriminant: u8 = match function.return_type {
CompletionRelevanceReturnType::Other => 0,
CompletionRelevanceReturnType::DirectConstructor => 1,
CompletionRelevanceReturnType::Constructor => 2,
CompletionRelevanceReturnType::Builder => 3,
};
hasher.update([discriminant]);
}
}

let mut hasher = TentHash::new();
hasher.update([
u8::from(is_ref_completion),
u8::from(item.is_snippet),
u8::from(item.deprecated),
u8::from(item.trigger_call_info),
]);

hasher.update(item.label.primary.len().to_ne_bytes());
hasher.update(&item.label.primary);

hasher.update([u8::from(item.label.detail_left.is_some())]);
if let Some(label_detail) = &item.label.detail_left {
hasher.update(label_detail.len().to_ne_bytes());
hasher.update(label_detail);
}

hasher.update([u8::from(item.label.detail_right.is_some())]);
if let Some(label_detail) = &item.label.detail_right {
hasher.update(label_detail.len().to_ne_bytes());
hasher.update(label_detail);
}

// NB: do not hash edits or source range, as those may change between the time the client sends the resolve request
// and the time it receives it: some editors do allow changing the buffer between that, leading to ranges being different.
//
// Documentation hashing is skipped too, as it's a large blob to process,
// while not really making completion properties more unique as they are already.

let kind_tag = item.kind.tag();
hasher.update(kind_tag.len().to_ne_bytes());
hasher.update(kind_tag);

hasher.update(item.lookup.len().to_ne_bytes());
hasher.update(&item.lookup);

hasher.update([u8::from(item.detail.is_some())]);
if let Some(detail) = &item.detail {
hasher.update(detail.len().to_ne_bytes());
hasher.update(detail);
}

hash_completion_relevance(&mut hasher, &item.relevance);

hasher.update([u8::from(item.ref_match.is_some())]);
if let Some((ref_mode, text_size)) = &item.ref_match {
let discriminant = match ref_mode {
CompletionItemRefMode::Reference(Mutability::Shared) => 0u8,
CompletionItemRefMode::Reference(Mutability::Mut) => 1u8,
CompletionItemRefMode::Dereference => 2u8,
};
hasher.update([discriminant]);
hasher.update(u32::from(*text_size).to_ne_bytes());
}

hasher.update(item.import_to_add.len().to_ne_bytes());
for import_path in &item.import_to_add {
hasher.update(import_path.len().to_ne_bytes());
hasher.update(import_path);
}

hasher.finalize()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ use serde_json::to_value;
use vfs::AbsPath;

use crate::{
completion_item_hash,
config::{CallInfoConfig, Config},
global_state::GlobalStateSnapshot,
line_index::{LineEndings, LineIndex, PositionEncoding},
lsp::{
completion_item_hash,
ext::ShellRunnableArgs,
semantic_tokens::{self, standard_fallback_type},
utils::invalid_params_error,
Expand Down
16 changes: 16 additions & 0 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ impl GlobalState {
self.proc_macro_clients.iter().map(Some).chain(iter::repeat_with(|| None));

for (ws, proc_macro_client) in self.workspaces.iter().zip(proc_macro_clients) {
if let Some(toolchain) = &ws.toolchain {
if *toolchain < crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION {
status.health |= lsp_ext::Health::Warning;
format_to!(
message,
"Workspace `{}` is using an outdated toolchain version `{}` but \
rust-analyzer only supports `{}` and higher.\n\
Consider using the rust-analyzer rustup component for your toolchain or
upgrade your toolchain to a supported version.\n\n",
ws.manifest_or_root(),
toolchain,
crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION,
);
}
}

if let ProjectWorkspaceKind::Cargo { error: Some(error), .. }
| ProjectWorkspaceKind::DetachedFile {
cargo: Some((_, _, Some(error))), ..
Expand Down