Skip to content

Commit 0a9ab5e

Browse files
authored
Unrolled build for #159600
Rollup merge of #159600 - lnicola:sync-from-ra, r=lnicola `rust-analyzer` subtree update Subtree update of `rust-analyzer` to rust-lang/rust-analyzer@cac0779. Created using https://github.com/rust-lang/josh-sync. r? @ghost
2 parents d527bc9 + c19056d commit 0a9ab5e

127 files changed

Lines changed: 3437 additions & 1321 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/tools/rust-analyzer/AI_POLICY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
We allow using AI (i.e., LLMs) as tools for contributing to rust-analyzer.
22
However, you remain responsible for any code you publish and we are responsible for any code we merge and release.
33
We hold a high bar for all contributions to our projects.
4+
Also, we kindly ask you to disclose usage of AI tools in your contributions.
45

56
**AI should not be used to generate comments when communicating with maintainers**.
67
We expect comments on our projects to be written by humans.

src/tools/rust-analyzer/Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ dependencies = [
14551455

14561456
[[package]]
14571457
name = "lsp-server"
1458-
version = "0.9.0"
1458+
version = "0.10.0"
14591459
dependencies = [
14601460
"anyhow",
14611461
"crossbeam-channel",

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ impl Default for Nonce {
315315
}
316316

317317
impl Nonce {
318+
#[inline]
319+
pub const fn invalid() -> Nonce {
320+
Nonce(usize::MAX)
321+
}
322+
318323
#[inline]
319324
pub fn new() -> Nonce {
320325
Nonce(NEXT_NONCE.fetch_add(1, std::sync::atomic::Ordering::SeqCst))

src/tools/rust-analyzer/crates/hir-def/src/attrs.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,29 @@ pub fn parse_extra_crate_attrs(db: &dyn SourceDatabase, krate: Crate) -> Option<
380380
Some(p.tree())
381381
}
382382

383+
/// Whether the crate root declares `#![no_std]`, looking through `cfg_attr` gating.
384+
#[salsa::tracked(returns(copy))]
385+
pub(crate) fn crate_supports_no_std(db: &dyn SourceDatabase, krate: Crate) -> bool {
386+
fn contains_no_std(meta: ast::Meta) -> bool {
387+
match meta {
388+
ast::Meta::PathMeta(meta) => meta.path().is1("no_std"),
389+
ast::Meta::CfgAttrMeta(meta) => meta.metas().any(contains_no_std),
390+
ast::Meta::UnsafeMeta(meta) => meta.meta().is_some_and(contains_no_std),
391+
ast::Meta::CfgMeta(_) | ast::Meta::KeyValueMeta(_) | ast::Meta::TokenTreeMeta(_) => {
392+
false
393+
}
394+
}
395+
}
396+
397+
let root_file = krate.root_file_id(db).parse(db).tree();
398+
parse_extra_crate_attrs(db, krate)
399+
.into_iter()
400+
.flat_map(|extra| extra.attrs())
401+
.chain(root_file.attrs())
402+
.filter_map(|attr| attr.meta())
403+
.any(contains_no_std)
404+
}
405+
383406
fn attrs_source(
384407
db: &dyn SourceDatabase,
385408
owner: AttrDefId,

src/tools/rust-analyzer/crates/hir-def/src/expr_store.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ impl ExpressionStore {
947947
}
948948
}
949949

950-
pub trait StoreVisitor {
950+
pub trait StoreVisitor: Sized {
951951
fn on_expr(&mut self, expr: ExprId) {
952952
let _ = expr;
953953
}
@@ -963,6 +963,26 @@ pub trait StoreVisitor {
963963
fn on_lifetime(&mut self, lifetime: LifetimeRefId) {
964964
let _ = lifetime;
965965
}
966+
967+
fn on_generic_args(&mut self, args: &GenericArgs) {
968+
visit_generic_args(self, args);
969+
}
970+
}
971+
972+
pub(crate) fn visit_generic_args<V: StoreVisitor>(visitor: &mut V, args: &GenericArgs) {
973+
let GenericArgs { args, bindings, parenthesized: _, has_self_type: _ } = args;
974+
for arg in args {
975+
match arg {
976+
GenericArg::Type(arg) => visitor.on_type(*arg),
977+
GenericArg::Const(ConstRef { expr }) => visitor.on_anon_const_expr(*expr),
978+
GenericArg::Lifetime(arg) => visitor.on_lifetime(*arg),
979+
}
980+
}
981+
for AssociatedTypeBinding { name: _, args, type_ref, bounds } in bindings {
982+
visitor.on_generic_args_opt(args);
983+
visitor.on_type_opt(*type_ref);
984+
visitor.on_type_bounds(bounds);
985+
}
966986
}
967987

968988
impl<V: StoreVisitor> StoreVisitor for &mut V {
@@ -981,25 +1001,13 @@ impl<V: StoreVisitor> StoreVisitor for &mut V {
9811001
fn on_lifetime(&mut self, lifetime: LifetimeRefId) {
9821002
V::on_lifetime(self, lifetime);
9831003
}
984-
}
9851004

986-
trait StoreVisitorExt: StoreVisitor {
9871005
fn on_generic_args(&mut self, args: &GenericArgs) {
988-
let GenericArgs { args, bindings, parenthesized: _, has_self_type: _ } = args;
989-
for arg in args {
990-
match arg {
991-
GenericArg::Type(arg) => self.on_type(*arg),
992-
GenericArg::Const(ConstRef { expr }) => self.on_anon_const_expr(*expr),
993-
GenericArg::Lifetime(arg) => self.on_lifetime(*arg),
994-
}
995-
}
996-
for AssociatedTypeBinding { name: _, args, type_ref, bounds } in bindings {
997-
self.on_generic_args_opt(args);
998-
self.on_type_opt(*type_ref);
999-
self.on_type_bounds(bounds);
1000-
}
1006+
V::on_generic_args(self, args);
10011007
}
1008+
}
10021009

1010+
trait StoreVisitorExt: StoreVisitor {
10031011
fn on_type_bound(&mut self, bound: &TypeBound) {
10041012
match bound {
10051013
TypeBound::Path(path_id, _) => self.on_type(path_id.type_ref()),

0 commit comments

Comments
 (0)