Skip to content

Commit 1267ecd

Browse files
Rollup merge of rust-lang#157251 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update Subtree update of `rust-analyzer` to rust-lang/rust-analyzer@123c166. Created using https://github.com/rust-lang/josh-sync. r? @ghost
2 parents 968d50a + 08b5b88 commit 1267ecd

241 files changed

Lines changed: 7184 additions & 2966 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/.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Install Rust toolchain
5757
run: |
5858
RUSTC_VERSION=$(cat rust-version)
59-
rustup-toolchain-install-master ${RUSTC_VERSION} -c cargo -c rust-src -c rustfmt
59+
rustup-toolchain-install-master ${RUSTC_VERSION} -c cargo -c rust-src -c rustfmt -c rustc-dev -c llvm-tools
6060
rustup default ${RUSTC_VERSION}
6161
6262
# Emulate a nightly toolchain, because the toolchain installed above does not have "nightly"
@@ -72,7 +72,7 @@ jobs:
7272
run: cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
7373

7474
- name: Check salsa dependency
75-
run: "! (cargo tree -p proc-macro-srv-cli | grep -q salsa)"
75+
run: "! (cargo tree -p proc-macro-srv-cli -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -i salsa)"
7676

7777
rust:
7878
if: github.repository == 'rust-lang/rust-analyzer'

src/tools/rust-analyzer/Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,6 @@ dependencies = [
18871887
"object",
18881888
"paths",
18891889
"proc-macro-test",
1890-
"ra-ap-rustc_lexer",
18911890
"span",
18921891
"temp-dir",
18931892
]
@@ -1939,7 +1938,6 @@ dependencies = [
19391938
name = "profile"
19401939
version = "0.0.0"
19411940
dependencies = [
1942-
"cfg-if",
19431941
"libc",
19441942
"perf-event",
19451943
"tikv-jemalloc-ctl",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern crate rustc_driver as _;
77

88
pub use salsa;
99
pub use salsa_macros;
10+
use span::TextSize;
1011

1112
// FIXME: Rename this crate, base db is non descriptive
1213
mod change;
@@ -49,6 +50,7 @@ macro_rules! impl_intern_key {
4950
#[salsa_macros::interned(no_lifetime, revisions = usize::MAX)]
5051
#[derive(PartialOrd, Ord)]
5152
pub struct $id {
53+
#[returns(ref)]
5254
pub loc: $loc,
5355
}
5456

@@ -280,6 +282,8 @@ pub trait SourceDatabase: salsa::Database {
280282
fn crates_map(&self) -> Arc<CratesMap>;
281283

282284
fn nonce_and_revision(&self) -> (Nonce, salsa::Revision);
285+
286+
fn line_column(&self, file: FileId, offset: TextSize) -> Result<(u32, u32), ()>;
283287
}
284288

285289
static NEXT_NONCE: AtomicUsize = AtomicUsize::new(0);

src/tools/rust-analyzer/crates/cfg/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl fmt::Display for CfgDiff {
222222
for (i, atom) in self.disable.iter().enumerate() {
223223
let sep = match i {
224224
0 => "",
225-
_ if i == self.enable.len() - 1 => " and ",
225+
_ if i == self.disable.len() - 1 => " and ",
226226
_ => ", ",
227227
};
228228
f.write_str(sep)?;

src/tools/rust-analyzer/crates/cfg/src/tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ fn hints() {
194194

195195
check_enable_hints("#![cfg(test)]", &opts, &[]);
196196
check_enable_hints("#![cfg(not(test))]", &opts, &["disable test"]);
197+
198+
opts.insert_atom(Symbol::intern("a"));
199+
opts.insert_atom(Symbol::intern("b"));
200+
check_enable_hints("#![cfg(all(not(a), not(b)))]", &opts, &["disable a and b"]);
197201
}
198202

199203
/// Tests that we don't suggest hints for cfgs that express an inconsistent formula.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use hir_expand::{
77
use triomphe::Arc;
88

99
use crate::{
10-
AssocItemId, AttrDefId, Macro2Loc, MacroExpander, MacroId, MacroRulesLoc, MacroRulesLocFlags,
11-
TraitId,
10+
AssocItemId, AttrDefId, MacroExpander, MacroId, MacroRulesLocFlags, TraitId,
1211
attrs::AttrFlags,
1312
item_tree::{ItemTree, file_item_tree},
1413
nameres::crate_def_map,
@@ -76,12 +75,13 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
7675
MacroExpander::BuiltInAttr(it) => MacroDefKind::BuiltInAttr(in_file, it),
7776
MacroExpander::BuiltInDerive(it) => MacroDefKind::BuiltInDerive(in_file, it),
7877
MacroExpander::BuiltInEager(it) => MacroDefKind::BuiltInEager(in_file, it),
78+
MacroExpander::UnimplementedBuiltIn => MacroDefKind::UnimplementedBuiltIn(in_file),
7979
}
8080
};
8181

8282
match id {
8383
MacroId::Macro2Id(it) => {
84-
let loc: Macro2Loc = it.lookup(db);
84+
let loc = it.lookup(db);
8585

8686
MacroDefId {
8787
krate: loc.container.krate(db),
@@ -92,7 +92,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
9292
}
9393
}
9494
MacroId::MacroRulesId(it) => {
95-
let loc: MacroRulesLoc = it.lookup(db);
95+
let loc = it.lookup(db);
9696

9797
MacroDefId {
9898
krate: loc.container.krate(db),

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ pub enum ExpressionStoreDiagnostics {
332332
AwaitOutsideOfAsync { node: InFile<AstPtr<ast::AwaitExpr>>, location: String },
333333
UndeclaredLabel { node: InFile<AstPtr<ast::Lifetime>>, name: Name },
334334
PatternArgInExternFn { node: InFile<AstPtr<ast::Pat>> },
335+
FruInDestructuringAssignment { node: InFile<AstPtr<ast::Expr>> },
335336
}
336337

337338
impl ExpressionStoreBuilder {
@@ -616,7 +617,7 @@ impl ExpressionStore {
616617
visitor.on_expr_opt(*end);
617618
}
618619
Pat::Lit(expr) | Pat::ConstBlock(expr) | Pat::Expr(expr) => visitor.on_expr(*expr),
619-
Pat::Path(_) | Pat::Wild | Pat::Missing | Pat::Rest => {}
620+
Pat::Path(_) | Pat::Wild | Pat::Missing | Pat::Rest | Pat::NotNull => {}
620621
&Pat::Bind { subpat, id: _ } => visitor.on_pat_opt(subpat),
621622
Pat::Or(args) | Pat::Tuple { args, ellipsis: _ } => visitor.on_pats(args),
622623
Pat::TupleStruct { args, ellipsis: _, path } => {
@@ -719,7 +720,7 @@ impl ExpressionStore {
719720
}
720721
visitor.on_expr_opt(*tail);
721722
}
722-
Expr::Loop { body, label: _ } => visitor.on_expr(*body),
723+
Expr::Loop { body, label: _, source: _ } => visitor.on_expr(*body),
723724
Expr::Call { callee, args } => {
724725
visitor.on_expr(*callee);
725726
visitor.on_exprs(args);
@@ -855,6 +856,10 @@ impl ExpressionStore {
855856
pub fn visit_type_ref_children(&self, type_ref: TypeRefId, mut visitor: impl StoreVisitor) {
856857
match &self[type_ref] {
857858
TypeRef::Never | TypeRef::Placeholder | TypeRef::TypeParam(_) | TypeRef::Error => {}
859+
&TypeRef::PatternType(ty, pat) => {
860+
visitor.on_type(ty);
861+
visitor.on_pat(pat)
862+
}
858863
TypeRef::Tuple(types) => visitor.on_types(types),
859864
TypeRef::Path(path) => visitor.on_path(path),
860865
TypeRef::RawPtr(inner, _) | TypeRef::Slice(inner) => visitor.on_type(*inner),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use syntax::ast;
99
use triomphe::Arc;
1010

1111
use crate::{
12-
DefWithBodyId, HasModule,
12+
DefWithBodyId, ExpressionStoreOwnerId, HasModule,
1313
db::DefDatabase,
1414
expr_store::{
1515
ExpressionStore, ExpressionStoreSourceMap, SelfParamPtr, lower::lower_body, pretty,
@@ -160,12 +160,12 @@ impl Body {
160160
pub fn pretty_print_pat(
161161
&self,
162162
db: &dyn DefDatabase,
163-
owner: DefWithBodyId,
163+
owner: ExpressionStoreOwnerId,
164164
pat: PatId,
165165
oneline: bool,
166166
edition: Edition,
167167
) -> String {
168-
pretty::print_pat_hir(db, self, owner.into(), pat, oneline, edition)
168+
pretty::print_pat_hir(db, self, owner, pat, oneline, edition)
169169
}
170170
}
171171

0 commit comments

Comments
 (0)