Skip to content

Commit 79c7685

Browse files
committed
Auto merge of rust-lang#136117 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents 2f348cb + a7cbe4b commit 79c7685

File tree

126 files changed

+2163
-1325
lines changed

Some content is hidden

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

126 files changed

+2163
-1325
lines changed

src/tools/rust-analyzer/Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ dependencies = [
846846
"dashmap",
847847
"hashbrown",
848848
"rustc-hash 2.0.0",
849-
"sptr",
850849
"triomphe",
851850
]
852851

@@ -1927,12 +1926,6 @@ dependencies = [
19271926
"vfs",
19281927
]
19291928

1930-
[[package]]
1931-
name = "sptr"
1932-
version = "0.3.2"
1933-
source = "registry+https://github.com/rust-lang/crates.io-index"
1934-
checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"
1935-
19361929
[[package]]
19371930
name = "stdx"
19381931
version = "0.0.0"

src/tools/rust-analyzer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exclude = ["crates/proc-macro-srv/proc-macro-test/imp"]
44
resolver = "2"
55

66
[workspace.package]
7-
rust-version = "1.83"
7+
rust-version = "1.84"
88
edition = "2021"
99
license = "MIT OR Apache-2.0"
1010
authors = ["rust-analyzer team"]

src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,9 @@ impl ExprCollector<'_> {
13811381
}
13821382
}
13831383
ast::Stmt::Item(ast::Item::MacroDef(macro_)) => {
1384+
if self.check_cfg(&macro_).is_none() {
1385+
return;
1386+
}
13841387
let Some(name) = macro_.name() else {
13851388
statements.push(Statement::Item(Item::Other));
13861389
return;
@@ -1390,6 +1393,9 @@ impl ExprCollector<'_> {
13901393
self.collect_macro_def(statements, macro_id);
13911394
}
13921395
ast::Stmt::Item(ast::Item::MacroRules(macro_)) => {
1396+
if self.check_cfg(&macro_).is_none() {
1397+
return;
1398+
}
13931399
let Some(name) = macro_.name() else {
13941400
statements.push(Statement::Item(Item::Other));
13951401
return;

src/tools/rust-analyzer/crates/hir-def/src/body/tests/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn outer() {
475475
476476
block scope::tests
477477
name: _
478-
outer: v
478+
outer: vg
479479
480480
crate
481481
outer: v

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

+19-6
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ fn find_in_dep(
445445
};
446446
cov_mark::hit!(partially_imported);
447447
if info.is_unstable {
448+
if !ctx.cfg.allow_unstable {
449+
// the item is unstable and we are not allowed to use unstable items
450+
continue;
451+
}
448452
choice.stability = Unstable;
449453
}
450454

@@ -670,6 +674,7 @@ mod tests {
670674
prefer_prelude: bool,
671675
prefer_absolute: bool,
672676
prefer_no_std: bool,
677+
allow_unstable: bool,
673678
expect: Expect,
674679
) {
675680
let (db, pos) = TestDB::with_position(ra_fixture);
@@ -711,7 +716,7 @@ mod tests {
711716
module,
712717
prefix,
713718
ignore_local_imports,
714-
ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute },
719+
ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute, allow_unstable },
715720
);
716721
format_to!(
717722
res,
@@ -732,31 +737,39 @@ mod tests {
732737
path: &str,
733738
expect: Expect,
734739
) {
735-
check_found_path_(ra_fixture, path, false, false, false, expect);
740+
check_found_path_(ra_fixture, path, false, false, false, false, expect);
736741
}
737742

738743
fn check_found_path_prelude(
739744
#[rust_analyzer::rust_fixture] ra_fixture: &str,
740745
path: &str,
741746
expect: Expect,
742747
) {
743-
check_found_path_(ra_fixture, path, true, false, false, expect);
748+
check_found_path_(ra_fixture, path, true, false, false, false, expect);
744749
}
745750

746751
fn check_found_path_absolute(
747752
#[rust_analyzer::rust_fixture] ra_fixture: &str,
748753
path: &str,
749754
expect: Expect,
750755
) {
751-
check_found_path_(ra_fixture, path, false, true, false, expect);
756+
check_found_path_(ra_fixture, path, false, true, false, false, expect);
752757
}
753758

754759
fn check_found_path_prefer_no_std(
755760
#[rust_analyzer::rust_fixture] ra_fixture: &str,
756761
path: &str,
757762
expect: Expect,
758763
) {
759-
check_found_path_(ra_fixture, path, false, false, true, expect);
764+
check_found_path_(ra_fixture, path, false, false, true, false, expect);
765+
}
766+
767+
fn check_found_path_prefer_no_std_allow_unstable(
768+
#[rust_analyzer::rust_fixture] ra_fixture: &str,
769+
path: &str,
770+
expect: Expect,
771+
) {
772+
check_found_path_(ra_fixture, path, false, false, true, true, expect);
760773
}
761774

762775
#[test]
@@ -1951,7 +1964,7 @@ pub mod ops {
19511964

19521965
#[test]
19531966
fn respect_unstable_modules() {
1954-
check_found_path_prefer_no_std(
1967+
check_found_path_prefer_no_std_allow_unstable(
19551968
r#"
19561969
//- /main.rs crate:main deps:std,core
19571970
extern crate std;

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

+7-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_hash::FxHashSet;
1010
use smallvec::SmallVec;
1111
use span::Edition;
1212
use stdx::{format_to, TupleExt};
13-
use syntax::ToSmolStr;
1413
use triomphe::Arc;
1514

1615
use crate::{
@@ -88,9 +87,9 @@ impl ImportMap {
8887
.iter()
8988
// We've only collected items, whose name cannot be tuple field so unwrapping is fine.
9089
.flat_map(|(&item, (info, _))| {
91-
info.iter().enumerate().map(move |(idx, info)| {
92-
(item, info.name.unescaped().display(db.upcast()).to_smolstr(), idx as u32)
93-
})
90+
info.iter()
91+
.enumerate()
92+
.map(move |(idx, info)| (item, info.name.as_str(), idx as u32))
9493
})
9594
.collect();
9695
importables.sort_by(|(_, l_info, _), (_, r_info, _)| {
@@ -168,7 +167,8 @@ impl ImportMap {
168167
let attr_id = if let Some(import) = import {
169168
match import {
170169
ImportOrExternCrate::ExternCrate(id) => Some(id.into()),
171-
ImportOrExternCrate::Import(id) => Some(id.import.into()),
170+
ImportOrExternCrate::Import(id) => Some(id.use_.into()),
171+
ImportOrExternCrate::Glob(id) => Some(id.use_.into()),
172172
}
173173
} else {
174174
match item {
@@ -441,7 +441,7 @@ pub fn search_dependencies(
441441
}
442442

443443
fn search_maps(
444-
db: &dyn DefDatabase,
444+
_db: &dyn DefDatabase,
445445
import_maps: &[Arc<ImportMap>],
446446
mut stream: fst::map::Union<'_>,
447447
query: &Query,
@@ -464,11 +464,7 @@ fn search_maps(
464464
.then(|| (item, &import_infos[info_idx as usize]))
465465
})
466466
.filter(|&(_, info)| {
467-
query.search_mode.check(
468-
&query.query,
469-
query.case_sensitive,
470-
&info.name.unescaped().display(db.upcast()).to_smolstr(),
471-
)
467+
query.search_mode.check(&query.query, query.case_sensitive, info.name.as_str())
472468
});
473469
res.extend(iter.map(TupleExt::head));
474470
}

0 commit comments

Comments
 (0)