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
4 changes: 4 additions & 0 deletions crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,7 @@ fn resolve_type_param_assoc_type_shorthand(
let mut supertraits_resolution = None;
for maybe_parent_generics in generics.iter_owners().rev() {
ctx.store = maybe_parent_generics.store();
ctx.def = ExpressionStoreOwnerId::Signature(maybe_parent_generics.def());
for pred in maybe_parent_generics.where_predicates() {
let (WherePredicate::TypeBound { target, bound }
| WherePredicate::ForLifetime { lifetimes: _, target, bound }) = pred
Expand Down Expand Up @@ -2366,6 +2367,7 @@ fn generic_predicates(
ctx.diagnostics.clear();

ctx.store = maybe_parent_generics.store();
ctx.def = ExpressionStoreOwnerId::Signature(maybe_parent_generics.def());
for pred in maybe_parent_generics.where_predicates() {
tracing::debug!(?pred);
for (pred, source) in ctx.lower_where_predicate(pred, false) {
Expand Down Expand Up @@ -2568,13 +2570,15 @@ pub(crate) fn generic_defaults_with_diagnostics(
let mut defaults = ThinVec::new();
if let Some(parent) = generics.parent() {
ctx.store = parent.store();
ctx.def = ExpressionStoreOwnerId::Signature(parent.def());
defaults.extend(
parent.iter_with_idx().map(|(idx, _id, p)| handle_generic_param(&mut ctx, idx, p)),
);
}
ctx.diagnostics.clear(); // Don't include diagnostics from the parent.
ctx.defined_anon_consts.clear();
ctx.store = store_for_self;
ctx.def = ExpressionStoreOwnerId::Signature(def);
defaults.extend(
generics.iter_self_with_idx().map(|(idx, _id, p)| handle_generic_param(&mut ctx, idx, p)),
);
Expand Down
20 changes: 20 additions & 0 deletions crates/hir-ty/src/tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ fn no_panic_on_field_of_enum() {
);
}

#[test]
fn anon_const_projection_in_impl_predicate() {
check_no_mismatches(
r#"
trait Trait {
type Assoc;
}

struct S<const N: usize>;

impl<const N: usize> S<N>
where
S<{ N }>: Trait,
{
fn new(_: <S<N> as Trait>::Assoc) {}
}
"#,
);
}

#[test]
fn bug_585() {
check_infer(
Expand Down
Loading