Skip to content

Commit 72062fc

Browse files
committed
slight check_trait_impl cleanup
1 parent f562ada commit 72062fc

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

crates/formality-check/src/impls.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ use formality_types::{
1717
};
1818

1919
impl super::Check<'_> {
20-
#[context("check_trait_impl({v:?})")]
21-
pub(super) fn check_trait_impl(&self, v: &TraitImpl) -> Fallible<()> {
22-
let TraitImpl { binder, safety } = v;
23-
20+
#[context("check_trait_impl({trait_impl:?})")]
21+
pub(super) fn check_trait_impl(&self, trait_impl: &TraitImpl) -> Fallible<()> {
2422
let mut env = Env::default();
2523

2624
let TraitImplBoundData {
@@ -29,7 +27,7 @@ impl super::Check<'_> {
2927
trait_parameters,
3028
where_clauses,
3129
impl_items,
32-
} = env.instantiate_universally(binder);
30+
} = env.instantiate_universally(&trait_impl.binder);
3331

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

@@ -45,7 +43,7 @@ impl super::Check<'_> {
4543
trait_items,
4644
} = trait_decl.binder.instantiate_with(&trait_ref.parameters)?;
4745

48-
self.check_safety_matches(&trait_decl, safety)?;
46+
self.check_safety_matches(&trait_decl, &trait_impl)?;
4947

5048
for impl_item in &impl_items {
5149
self.check_trait_impl_item(&env, &where_clauses, &trait_items, impl_item)?;
@@ -74,8 +72,8 @@ impl super::Check<'_> {
7472
}
7573

7674
/// Validate that the declared safety of an impl matches the one from the trait declaration.
77-
fn check_safety_matches(&self, trait_decl: &Trait, trait_impl: &Safety) -> Fallible<()> {
78-
if trait_decl.safety != *trait_impl {
75+
fn check_safety_matches(&self, trait_decl: &Trait, trait_impl: &TraitImpl) -> Fallible<()> {
76+
if trait_decl.safety != trait_impl.safety {
7977
match trait_decl.safety {
8078
Safety::Safe => bail!("implementing the trait `{:?}` is not unsafe", trait_decl.id),
8179
Safety::Unsafe => bail!(

0 commit comments

Comments
 (0)