Skip to content

Commit a3120d8

Browse files
Merge remote-tracking branch 'origin/master' into extension-configuration
2 parents bbffb1f + c5181db commit a3120d8

File tree

115 files changed

+4231
-4516
lines changed

Some content is hidden

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

115 files changed

+4231
-4516
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ jobs:
293293
timeout-minutes: 10
294294
env:
295295
FORCE_COLOR: 1
296-
TYPOS_VERSION: v1.28.3
296+
TYPOS_VERSION: v1.38.1
297297
steps:
298298
- name: download typos
299299
run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ makro = "makro"
3232
trivias = "trivias"
3333
thir = "thir"
3434
jod = "jod"
35+
tructure = "tructure"
3536

3637
[default.extend-identifiers]
3738
anc = "anc"

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ debug = 2
5252

5353
[workspace.dependencies]
5454
# local crates
55+
macros = { path = "./crates/macros", version = "0.0.0" }
5556
base-db = { path = "./crates/base-db", version = "0.0.0" }
5657
cfg = { path = "./crates/cfg", version = "0.0.0", features = ["tt"] }
5758
hir = { path = "./crates/hir", version = "0.0.0" }

crates/hir-def/src/signatures.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ bitflags::bitflags! {
349349
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
350350
pub struct ImplFlags: u8 {
351351
const NEGATIVE = 1 << 1;
352+
const DEFAULT = 1 << 2;
352353
const UNSAFE = 1 << 3;
353354
}
354355
}
@@ -374,6 +375,9 @@ impl ImplSignature {
374375
if src.value.excl_token().is_some() {
375376
flags.insert(ImplFlags::NEGATIVE);
376377
}
378+
if src.value.default_token().is_some() {
379+
flags.insert(ImplFlags::DEFAULT);
380+
}
377381

378382
let (store, source_map, self_ty, target_trait, generic_params) =
379383
crate::expr_store::lower::lower_impl(db, loc.container, src, id);
@@ -389,6 +393,16 @@ impl ImplSignature {
389393
Arc::new(source_map),
390394
)
391395
}
396+
397+
#[inline]
398+
pub fn is_negative(&self) -> bool {
399+
self.flags.contains(ImplFlags::NEGATIVE)
400+
}
401+
402+
#[inline]
403+
pub fn is_default(&self) -> bool {
404+
self.flags.contains(ImplFlags::DEFAULT)
405+
}
392406
}
393407

394408
bitflags::bitflags! {

crates/hir-ty/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ tracing-tree.workspace = true
5050

5151
# local deps
5252
stdx.workspace = true
53+
macros.workspace = true
5354
intern.workspace = true
5455
hir-def.workspace = true
5556
hir-expand.workspace = true

crates/hir-ty/src/autoderef.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
66
use std::fmt;
77

8-
use hir_def::TraitId;
9-
use hir_def::{TypeAliasId, lang_item::LangItem};
8+
use hir_def::{TraitId, TypeAliasId, lang_item::LangItem};
109
use rustc_type_ir::inherent::{IntoKind, Ty as _};
1110
use tracing::debug;
1211
use triomphe::Arc;
1312

14-
use crate::next_solver::TraitRef;
15-
use crate::next_solver::infer::InferOk;
16-
use crate::next_solver::infer::traits::Obligation;
1713
use crate::{
1814
TraitEnvironment,
1915
db::HirDatabase,
2016
infer::unify::InferenceTable,
2117
next_solver::{
22-
Ty, TyKind,
23-
infer::traits::{ObligationCause, PredicateObligations},
24-
mapping::{ChalkToNextSolver, NextSolverToChalk},
18+
Canonical, TraitRef, Ty, TyKind,
19+
infer::{
20+
InferOk,
21+
traits::{Obligation, ObligationCause, PredicateObligations},
22+
},
2523
obligation_ctxt::ObligationCtxt,
2624
},
2725
};
@@ -38,17 +36,16 @@ const AUTODEREF_RECURSION_LIMIT: usize = 20;
3836
pub fn autoderef<'db>(
3937
db: &'db dyn HirDatabase,
4038
env: Arc<TraitEnvironment<'db>>,
41-
ty: crate::Canonical<crate::Ty>,
42-
) -> impl Iterator<Item = crate::Ty> + use<> {
39+
ty: Canonical<'db, Ty<'db>>,
40+
) -> impl Iterator<Item = Ty<'db>> + use<'db> {
4341
let mut table = InferenceTable::new(db, env);
44-
let interner = table.interner();
45-
let ty = table.instantiate_canonical(ty.to_nextsolver(interner));
42+
let ty = table.instantiate_canonical(ty);
4643
let mut autoderef = Autoderef::new_no_tracking(&mut table, ty);
4744
let mut v = Vec::new();
4845
while let Some((ty, _steps)) = autoderef.next() {
4946
// `ty` may contain unresolved inference variables. Since there's no chance they would be
5047
// resolved, just replace with fallback type.
51-
let resolved = autoderef.table.resolve_completely(ty).to_chalk(interner);
48+
let resolved = autoderef.table.resolve_completely(ty);
5249

5350
// If the deref chain contains a cycle (e.g. `A` derefs to `B` and `B` derefs to `A`), we
5451
// would revisit some already visited types. Stop here to avoid duplication.

crates/hir-ty/src/builder.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ impl<D> TyBuilder<D> {
130130
}
131131

132132
pub fn fill_with_unknown(self) -> Self {
133+
let interner = DbInterner::conjure();
133134
// self.fill is inlined to make borrow checker happy
134135
let mut this = self;
135136
let filler = this.param_kinds[this.vec.len()..].iter().map(|x| match x {
136137
ParamKind::Type => TyKind::Error.intern(Interner).cast(Interner),
137-
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
138+
ParamKind::Const(ty) => {
139+
unknown_const_as_generic(ty.to_nextsolver(interner)).to_chalk(interner)
140+
}
138141
ParamKind::Lifetime => error_lifetime().cast(Interner),
139142
});
140143
this.vec.extend(filler.casted(Interner));
@@ -219,13 +222,16 @@ impl TyBuilder<()> {
219222
}
220223

221224
pub fn unknown_subst(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution {
225+
let interner = DbInterner::conjure();
222226
let params = generics(db, def.into());
223227
Substitution::from_iter(
224228
Interner,
225229
params.iter_id().map(|id| match id {
226230
GenericParamId::TypeParamId(_) => TyKind::Error.intern(Interner).cast(Interner),
227231
GenericParamId::ConstParamId(id) => {
228-
unknown_const_as_generic(db.const_param_ty(id)).cast(Interner)
232+
unknown_const_as_generic(db.const_param_ty_ns(id))
233+
.to_chalk(interner)
234+
.cast(Interner)
229235
}
230236
GenericParamId::LifetimeParamId(_) => error_lifetime().cast(Interner),
231237
}),
@@ -267,6 +273,7 @@ impl TyBuilder<hir_def::AdtId> {
267273
db: &dyn HirDatabase,
268274
mut fallback: impl FnMut() -> Ty,
269275
) -> Self {
276+
let interner = DbInterner::conjure();
270277
// Note that we're building ADT, so we never have parent generic parameters.
271278
let defaults = db.generic_defaults(self.data.into());
272279

@@ -287,7 +294,9 @@ impl TyBuilder<hir_def::AdtId> {
287294
// The defaults may be missing if no param has default, so fill that.
288295
let filler = self.param_kinds[self.vec.len()..].iter().map(|x| match x {
289296
ParamKind::Type => fallback().cast(Interner),
290-
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
297+
ParamKind::Const(ty) => {
298+
unknown_const_as_generic(ty.to_nextsolver(interner)).to_chalk(interner)
299+
}
291300
ParamKind::Lifetime => error_lifetime().cast(Interner),
292301
});
293302
self.vec.extend(filler.casted(Interner));

0 commit comments

Comments
 (0)