Skip to content

Commit 8a407a8

Browse files
committed
Auto merge of #142250 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents c6768de + f5bfde2 commit 8a407a8

File tree

79 files changed

+2373
-1085
lines changed

Some content is hidden

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

79 files changed

+2373
-1085
lines changed

src/tools/rust-analyzer/.github/workflows/autopublish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: rustup update --no-self-update stable
2929

3030
- name: Install cargo-workspaces
31-
run: cargo install cargo-workspaces
31+
run: cargo install cargo-workspaces --version "0.3.6"
3232

3333
- name: Publish Crates
3434
env:
@@ -54,8 +54,8 @@ jobs:
5454
cargo workspaces rename --from project-model project_model
5555
cargo workspaces rename --from test-fixture test_fixture
5656
cargo workspaces rename --from test-utils test_utils
57-
# Remove library crates from the workspaces so we don't auto-publish them as well
58-
sed -i 's/ "lib\/\*",//' ./Cargo.toml
57+
# Remove library crates and xtask from the workspaces so we don't auto-publish them as well
58+
sed -i 's|^members = .*$|members = ["crates/*"]|' Cargo.toml
5959
cargo workspaces rename ra_ap_%n
6060
find crates/rust-analyzer -type f -name '*.rs' -exec sed -i 's/rust_analyzer/ra_ap_rust_analyzer/g' {} +
6161
cargo workspaces publish --yes --force '*' --exact --no-git-commit --allow-dirty --skip-published custom 0.0.$(($RUN_NUMBER + 133))

src/tools/rust-analyzer/.github/workflows/publish-libs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: rustup update --no-self-update stable
2323

2424
- name: Install cargo-workspaces
25-
run: cargo install cargo-workspaces
25+
run: cargo install cargo-workspaces --version "0.3.6"
2626

2727
- name: Publish Crates
2828
env:

src/tools/rust-analyzer/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ smol_str.opt-level = 3
2121
text-size.opt-level = 3
2222
serde.opt-level = 3
2323
salsa.opt-level = 3
24+
dissimilar.opt-level = 3
25+
2426
# This speeds up `cargo xtask dist`.
2527
miniz_oxide.opt-level = 3
2628

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ pub mod keys {
6767
pub const PROC_MACRO: Key<ast::Fn, ProcMacroId> = Key::new();
6868
pub const MACRO_CALL: Key<ast::MacroCall, MacroCallId> = Key::new();
6969
pub const ATTR_MACRO_CALL: Key<ast::Item, MacroCallId> = Key::new();
70-
pub const DERIVE_MACRO_CALL: Key<ast::Attr, (AttrId, MacroCallId, Box<[Option<MacroCallId>]>)> =
71-
Key::new();
70+
pub const DERIVE_MACRO_CALL: Key<
71+
ast::Attr,
72+
(
73+
AttrId,
74+
/* derive() */ MacroCallId,
75+
/* actual derive macros */ Box<[Option<MacroCallId>]>,
76+
),
77+
> = Key::new();
7278

7379
/// XXX: AST Nodes and SyntaxNodes have identity equality semantics: nodes are
7480
/// equal if they point to exactly the same object.

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,12 @@ pub fn new() {
931931
// PATH_TYPE@23..26
932932
// PATH@23..26
933933
// PATH_SEGMENT@23..26
934-
// L_ANGLE@23..24 "<"
935-
// PAREN_TYPE@24..26
936-
// L_PAREN@24..25 "("
937-
// ERROR@25..26
938-
// INT_NUMBER@25..26 "8"
934+
// TYPE_ANCHOR@23..26
935+
// L_ANGLE@23..24 "<"
936+
// PAREN_TYPE@24..26
937+
// L_PAREN@24..25 "("
938+
// ERROR@25..26
939+
// INT_NUMBER@25..26 "8"
939940
// PLUS@26..27 "+"
940941
// CONST_ARG@27..28
941942
// LITERAL@27..28

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{
3131
#[query_group::query_group]
3232
pub trait HirDatabase: DefDatabase + std::fmt::Debug {
3333
#[salsa::invoke(crate::infer::infer_query)]
34+
#[salsa::cycle(cycle_result = crate::infer::infer_cycle_result)]
3435
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
3536

3637
// region:mir
@@ -132,6 +133,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
132133

133134
// FIXME: Make this a non-interned query.
134135
#[salsa::invoke_interned(crate::lower::const_param_ty_with_diagnostics_query)]
136+
#[salsa::cycle(cycle_result = crate::lower::const_param_ty_with_diagnostics_cycle_result)]
135137
fn const_param_ty_with_diagnostics(&self, def: ConstParamId) -> (Ty, Diagnostics);
136138

137139
#[salsa::invoke(crate::lower::const_param_ty_query)]

src/tools/rust-analyzer/crates/hir-ty/src/infer.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ use chalk_ir::{
3535
use either::Either;
3636
use hir_def::{
3737
AdtId, AssocItemId, ConstId, DefWithBodyId, FieldId, FunctionId, GenericDefId, GenericParamId,
38-
ImplId, ItemContainerId, Lookup, TraitId, TupleFieldId, TupleId, TypeAliasId, VariantId,
38+
ImplId, ItemContainerId, LocalFieldId, Lookup, TraitId, TupleFieldId, TupleId, TypeAliasId,
39+
VariantId,
3940
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
4041
expr_store::{Body, ExpressionStore, HygieneId, path::Path},
4142
hir::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, LabelId, PatId},
@@ -135,6 +136,10 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer
135136
Arc::new(ctx.resolve_all())
136137
}
137138

139+
pub(crate) fn infer_cycle_result(_: &dyn HirDatabase, _: DefWithBodyId) -> Arc<InferenceResult> {
140+
Arc::new(InferenceResult { has_errors: true, ..Default::default() })
141+
}
142+
138143
/// Fully normalize all the types found within `ty` in context of `owner` body definition.
139144
///
140145
/// This is appropriate to use only after type-check: it assumes
@@ -203,7 +208,7 @@ pub(crate) type InferResult<T> = Result<InferOk<T>, TypeError>;
203208
pub enum InferenceDiagnostic {
204209
NoSuchField {
205210
field: ExprOrPatId,
206-
private: bool,
211+
private: Option<LocalFieldId>,
207212
variant: VariantId,
208213
},
209214
PrivateField {
@@ -558,6 +563,9 @@ impl InferenceResult {
558563
ExprOrPatId::PatId(id) => self.type_of_pat.get(id),
559564
}
560565
}
566+
pub fn is_erroneous(&self) -> bool {
567+
self.has_errors && self.type_of_expr.iter().count() == 0
568+
}
561569
}
562570

563571
impl Index<ExprId> for InferenceResult {

src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl InferenceContext<'_> {
554554
self.push_diagnostic(
555555
InferenceDiagnostic::NoSuchField {
556556
field: field.expr.into(),
557-
private: true,
557+
private: Some(local_id),
558558
variant: def,
559559
},
560560
);
@@ -564,7 +564,7 @@ impl InferenceContext<'_> {
564564
None => {
565565
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
566566
field: field.expr.into(),
567-
private: false,
567+
private: None,
568568
variant: def,
569569
});
570570
None

src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl InferenceContext<'_> {
143143
{
144144
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
145145
field: inner.into(),
146-
private: true,
146+
private: Some(local_id),
147147
variant: def,
148148
});
149149
}
@@ -157,7 +157,7 @@ impl InferenceContext<'_> {
157157
None => {
158158
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
159159
field: inner.into(),
160-
private: false,
160+
private: None,
161161
variant: def,
162162
});
163163
self.err_ty()

src/tools/rust-analyzer/crates/hir-ty/src/lower.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,14 @@ pub(crate) fn impl_self_ty_with_diagnostics_query(
16041604
)
16051605
}
16061606

1607+
pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
1608+
db: &dyn HirDatabase,
1609+
impl_id: ImplId,
1610+
) -> (Binders<Ty>, Diagnostics) {
1611+
let generics = generics(db, impl_id.into());
1612+
(make_binders(db, &generics, TyKind::Error.intern(Interner)), None)
1613+
}
1614+
16071615
pub(crate) fn const_param_ty_query(db: &dyn HirDatabase, def: ConstParamId) -> Ty {
16081616
db.const_param_ty_with_diagnostics(def).0
16091617
}
@@ -1633,12 +1641,12 @@ pub(crate) fn const_param_ty_with_diagnostics_query(
16331641
(ty, create_diagnostics(ctx.diagnostics))
16341642
}
16351643

1636-
pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
1637-
db: &dyn HirDatabase,
1638-
impl_id: ImplId,
1639-
) -> (Binders<Ty>, Diagnostics) {
1640-
let generics = generics(db, impl_id.into());
1641-
(make_binders(db, &generics, TyKind::Error.intern(Interner)), None)
1644+
pub(crate) fn const_param_ty_with_diagnostics_cycle_result(
1645+
_: &dyn HirDatabase,
1646+
_: crate::db::HirDatabaseData,
1647+
_: ConstParamId,
1648+
) -> (Ty, Diagnostics) {
1649+
(TyKind::Error.intern(Interner), None)
16421650
}
16431651

16441652
pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<Binders<TraitRef>> {

src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ pub fn lower_to_mir(
21822182
// need to take this input explicitly.
21832183
root_expr: ExprId,
21842184
) -> Result<MirBody> {
2185-
if infer.type_mismatches().next().is_some() {
2185+
if infer.type_mismatches().next().is_some() || infer.is_erroneous() {
21862186
return Err(MirLowerError::HasErrors);
21872187
}
21882188
let mut ctx = MirLowerCtx::new(db, owner, body, infer);

0 commit comments

Comments
 (0)