Skip to content

Commit

Permalink
introduce struct pattern in check_neg_trait_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lqd committed Nov 12, 2023
1 parent 765661e commit 9a61bf6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/formality-check/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ impl super::Check<'_> {

#[context("check_neg_trait_impl({trait_impl:?})")]
pub(super) fn check_neg_trait_impl(&self, trait_impl: &NegTraitImpl) -> Fallible<()> {
let NegTraitImpl { binder, safety } = trait_impl;

let mut env = Env::default();

let NegTraitImplBoundData {
trait_id,
self_ty,
trait_parameters,
where_clauses,
} = env.instantiate_universally(&trait_impl.binder);
} = env.instantiate_universally(binder);

let trait_ref = trait_id.with(self_ty, trait_parameters);

// Negative impls are always safe (rustc E0198) regardless of the trait's safety.
if trait_impl.safety == Safety::Unsafe {
if *safety == Safety::Unsafe {
bail!("negative impls cannot be unsafe");
}

Expand Down

0 comments on commit 9a61bf6

Please sign in to comment.