diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index b87dacb8679..424bdd9f3ea 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -1818,10 +1818,10 @@ trait LowerWellKnownTrait { impl LowerWellKnownTrait for WellKnownTrait { fn lower(&self) -> rust_ir::WellKnownTrait { match self { - Self::SizedTrait => rust_ir::WellKnownTrait::SizedTrait, - Self::CopyTrait => rust_ir::WellKnownTrait::CopyTrait, - Self::CloneTrait => rust_ir::WellKnownTrait::CloneTrait, - Self::DropTrait => rust_ir::WellKnownTrait::DropTrait, + Self::Sized => rust_ir::WellKnownTrait::Sized, + Self::Copy => rust_ir::WellKnownTrait::Copy, + Self::Clone => rust_ir::WellKnownTrait::Clone, + Self::Drop => rust_ir::WellKnownTrait::Drop, } } } diff --git a/chalk-parse/src/ast.rs b/chalk-parse/src/ast.rs index 7925f664a58..c806b7a1f1e 100644 --- a/chalk-parse/src/ast.rs +++ b/chalk-parse/src/ast.rs @@ -64,10 +64,10 @@ pub struct TraitDefn { #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum WellKnownTrait { - SizedTrait, - CopyTrait, - CloneTrait, - DropTrait, + Sized, + Copy, + Clone, + Drop, } #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/chalk-parse/src/parser.lalrpop b/chalk-parse/src/parser.lalrpop index 531a8a3f778..944f4733261 100644 --- a/chalk-parse/src/parser.lalrpop +++ b/chalk-parse/src/parser.lalrpop @@ -47,10 +47,10 @@ CoinductiveKeyword: () = "#" "[" "coinductive" "]"; ObjectSafeKeyword: () = "#" "[" "object_safe" "]"; WellKnownTrait: WellKnownTrait = { - "#" "[" "lang" "(" "sized" ")" "]" => WellKnownTrait::SizedTrait, - "#" "[" "lang" "(" "copy" ")" "]" => WellKnownTrait::CopyTrait, - "#" "[" "lang" "(" "clone" ")" "]" => WellKnownTrait::CloneTrait, - "#" "[" "lang" "(" "drop" ")" "]" => WellKnownTrait::DropTrait, + "#" "[" "lang" "(" "sized" ")" "]" => WellKnownTrait::Sized, + "#" "[" "lang" "(" "copy" ")" "]" => WellKnownTrait::Copy, + "#" "[" "lang" "(" "clone" ")" "]" => WellKnownTrait::Clone, + "#" "[" "lang" "(" "drop" ")" "]" => WellKnownTrait::Drop, }; StructDefn: StructDefn = { diff --git a/chalk-solve/src/clauses/builtin_traits.rs b/chalk-solve/src/clauses/builtin_traits.rs index cb9eac50b11..3a6fa7f7514 100644 --- a/chalk-solve/src/clauses/builtin_traits.rs +++ b/chalk-solve/src/clauses/builtin_traits.rs @@ -29,17 +29,11 @@ pub fn add_builtin_program_clauses( } match well_known { - WellKnownTrait::SizedTrait => { - sized::add_sized_program_clauses(db, builder, &trait_ref, ty) - } - WellKnownTrait::CopyTrait => { - copy::add_copy_program_clauses(db, builder, &trait_ref, ty) - } - WellKnownTrait::CloneTrait => { - clone::add_clone_program_clauses(db, builder, &trait_ref, ty) - } + WellKnownTrait::Sized => sized::add_sized_program_clauses(db, builder, &trait_ref, ty), + WellKnownTrait::Copy => copy::add_copy_program_clauses(db, builder, &trait_ref, ty), + WellKnownTrait::Clone => clone::add_clone_program_clauses(db, builder, &trait_ref, ty), // Drop impls are provided explicitly - WellKnownTrait::DropTrait => (), + WellKnownTrait::Drop => (), } }); } diff --git a/chalk-solve/src/clauses/program_clauses.rs b/chalk-solve/src/clauses/program_clauses.rs index 800f3a8fc94..47f19126820 100644 --- a/chalk-solve/src/clauses/program_clauses.rs +++ b/chalk-solve/src/clauses/program_clauses.rs @@ -602,7 +602,7 @@ impl ToProgramClauses for TraitDatum { // i.e. Drop implementation for `struct S {}` is forced to be // `impl Drop for S { ... }`. That means that orphan rules // prevent Drop from being implemented in downstream crates. - if self.well_known != Some(WellKnownTrait::DropTrait) { + if self.well_known != Some(WellKnownTrait::Drop) { // Add all cases for potential downstream impls that could exist for i in 0..type_parameters.len() { builder.push_clause( diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 4d28d1aad31..d0c57919e52 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -212,10 +212,10 @@ pub struct TraitDatum { /// the chalk-solve crate has special, hard-coded impls for them. #[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)] pub enum WellKnownTrait { - SizedTrait, - CopyTrait, - CloneTrait, - DropTrait, + Sized, + Copy, + Clone, + Drop, } impl TraitDatum { diff --git a/chalk-solve/src/wf.rs b/chalk-solve/src/wf.rs index 2bb64a3f617..a6a97d32a4b 100644 --- a/chalk-solve/src/wf.rs +++ b/chalk-solve/src/wf.rs @@ -470,10 +470,8 @@ impl WfWellKnownGoals { trait_ref: &TraitRef, ) -> Option> { match db.trait_datum(trait_ref.trait_id).well_known? { - WellKnownTrait::CopyTrait => Self::copy_impl_constraint(db, trait_ref), - WellKnownTrait::DropTrait | WellKnownTrait::CloneTrait | WellKnownTrait::SizedTrait => { - None - } + WellKnownTrait::Copy => Self::copy_impl_constraint(db, trait_ref), + WellKnownTrait::Drop | WellKnownTrait::Clone | WellKnownTrait::Sized => None, } } @@ -488,9 +486,9 @@ impl WfWellKnownGoals { match db.trait_datum(impl_datum.trait_id()).well_known? { // You can't add a manual implementation of Sized - WellKnownTrait::SizedTrait => Some(GoalData::CannotProve(()).intern(interner)), - WellKnownTrait::DropTrait => Self::drop_impl_constraint(db, impl_datum), - WellKnownTrait::CopyTrait | WellKnownTrait::CloneTrait => None, + WellKnownTrait::Sized => Some(GoalData::CannotProve(()).intern(interner)), + WellKnownTrait::Drop => Self::drop_impl_constraint(db, impl_datum), + WellKnownTrait::Copy | WellKnownTrait::Clone => None, } } @@ -507,7 +505,7 @@ impl WfWellKnownGoals { let interner = db.interner(); - let sized_trait = db.well_known_trait_id(WellKnownTrait::SizedTrait)?; + let sized_trait = db.well_known_trait_id(WellKnownTrait::Sized)?; Some(Goal::all( interner, @@ -547,16 +545,16 @@ impl WfWellKnownGoals { }; // not { Implemented(ImplSelfTy: Drop) } - let neg_drop_goal = - db.well_known_trait_id(WellKnownTrait::DropTrait) - .map(|drop_trait_id| { - TraitRef { - trait_id: drop_trait_id, - substitution: Substitution::from1(interner, ty.clone()), - } - .cast::>(interner) - .negate(interner) - }); + let neg_drop_goal = db + .well_known_trait_id(WellKnownTrait::Drop) + .map(|drop_trait_id| { + TraitRef { + trait_id: drop_trait_id, + substitution: Substitution::from1(interner, ty.clone()), + } + .cast::>(interner) + .negate(interner) + }); let adt_datum = db.adt_datum(adt_id);