Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ debug = 2

[workspace.dependencies]
# local crates
macros = { path = "./crates/macros", version = "0.0.0" }
base-db = { path = "./crates/base-db", version = "0.0.0" }
cfg = { path = "./crates/cfg", version = "0.0.0", features = ["tt"] }
hir = { path = "./crates/hir", version = "0.0.0" }
Expand Down
14 changes: 14 additions & 0 deletions crates/hir-def/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ bitflags::bitflags! {
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
pub struct ImplFlags: u8 {
const NEGATIVE = 1 << 1;
const DEFAULT = 1 << 2;
const UNSAFE = 1 << 3;
}
}
Expand All @@ -374,6 +375,9 @@ impl ImplSignature {
if src.value.excl_token().is_some() {
flags.insert(ImplFlags::NEGATIVE);
}
if src.value.default_token().is_some() {
flags.insert(ImplFlags::DEFAULT);
}

let (store, source_map, self_ty, target_trait, generic_params) =
crate::expr_store::lower::lower_impl(db, loc.container, src, id);
Expand All @@ -389,6 +393,16 @@ impl ImplSignature {
Arc::new(source_map),
)
}

#[inline]
pub fn is_negative(&self) -> bool {
self.flags.contains(ImplFlags::NEGATIVE)
}

#[inline]
pub fn is_default(&self) -> bool {
self.flags.contains(ImplFlags::DEFAULT)
}
}

bitflags::bitflags! {
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tracing-tree.workspace = true

# local deps
stdx.workspace = true
macros.workspace = true
intern.workspace = true
hir-def.workspace = true
hir-expand.workspace = true
Expand Down
15 changes: 12 additions & 3 deletions crates/hir-ty/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ impl<D> TyBuilder<D> {
}

pub fn fill_with_unknown(self) -> Self {
let interner = DbInterner::conjure();
// self.fill is inlined to make borrow checker happy
let mut this = self;
let filler = this.param_kinds[this.vec.len()..].iter().map(|x| match x {
ParamKind::Type => TyKind::Error.intern(Interner).cast(Interner),
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
ParamKind::Const(ty) => {
unknown_const_as_generic(ty.to_nextsolver(interner)).to_chalk(interner)
}
ParamKind::Lifetime => error_lifetime().cast(Interner),
});
this.vec.extend(filler.casted(Interner));
Expand Down Expand Up @@ -219,13 +222,16 @@ impl TyBuilder<()> {
}

pub fn unknown_subst(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution {
let interner = DbInterner::conjure();
let params = generics(db, def.into());
Substitution::from_iter(
Interner,
params.iter_id().map(|id| match id {
GenericParamId::TypeParamId(_) => TyKind::Error.intern(Interner).cast(Interner),
GenericParamId::ConstParamId(id) => {
unknown_const_as_generic(db.const_param_ty(id)).cast(Interner)
unknown_const_as_generic(db.const_param_ty_ns(id))
.to_chalk(interner)
.cast(Interner)
}
GenericParamId::LifetimeParamId(_) => error_lifetime().cast(Interner),
}),
Expand Down Expand Up @@ -267,6 +273,7 @@ impl TyBuilder<hir_def::AdtId> {
db: &dyn HirDatabase,
mut fallback: impl FnMut() -> Ty,
) -> Self {
let interner = DbInterner::conjure();
// Note that we're building ADT, so we never have parent generic parameters.
let defaults = db.generic_defaults(self.data.into());

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