From aa693552abbae01cc874ae29348fcba229deb596 Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Thu, 2 Jan 2025 14:17:56 +0100 Subject: [PATCH] Set rustfmt `style_edition` to 2024 This fixes the annoying `.0 .0` thing. --- chalk-derive/src/lib.rs | 64 +++++++++---------- chalk-engine/src/context.rs | 2 +- chalk-engine/src/logic.rs | 23 ++++--- chalk-engine/src/slg.rs | 13 ++-- chalk-engine/src/slg/aggregate.rs | 2 +- chalk-engine/src/slg/resolvent.rs | 2 +- chalk-engine/src/solve.rs | 2 +- chalk-engine/src/table.rs | 2 +- chalk-engine/src/tables.rs | 2 +- chalk-integration/src/db.rs | 3 +- chalk-integration/src/interner.rs | 20 +++--- chalk-integration/src/lib.rs | 2 +- chalk-integration/src/lowering.rs | 2 +- chalk-integration/src/lowering/env.rs | 2 +- .../src/lowering/program_lowerer.rs | 6 +- chalk-integration/src/program.rs | 16 ++--- chalk-integration/src/query.rs | 6 +- chalk-integration/src/tls.rs | 8 +-- chalk-ir/src/could_match.rs | 6 +- chalk-ir/src/interner.rs | 2 +- chalk-ir/src/lib.rs | 8 +-- chalk-ir/src/visit/boring_impls.rs | 8 +-- chalk-recursive/src/fulfill.rs | 9 +-- chalk-recursive/src/recursive.rs | 6 +- chalk-recursive/src/solve.rs | 2 +- chalk-solve/src/clauses.rs | 31 ++++----- chalk-solve/src/clauses/builder.rs | 2 +- chalk-solve/src/clauses/builtin_traits.rs | 2 +- .../src/clauses/builtin_traits/copy.rs | 2 +- .../src/clauses/builtin_traits/coroutine.rs | 11 ++-- .../src/clauses/builtin_traits/sized.rs | 2 +- .../src/clauses/builtin_traits/unsize.rs | 4 +- chalk-solve/src/clauses/dyn_ty.rs | 2 +- chalk-solve/src/clauses/env_elaborator.rs | 6 +- chalk-solve/src/clauses/generalize.rs | 4 +- chalk-solve/src/clauses/super_traits.rs | 23 +++---- chalk-solve/src/coherence.rs | 2 +- chalk-solve/src/coherence/orphan.rs | 2 +- chalk-solve/src/coherence/solve.rs | 2 +- chalk-solve/src/display.rs | 2 +- chalk-solve/src/display/items.rs | 36 ++++------- chalk-solve/src/display/stub.rs | 59 +++++++---------- chalk-solve/src/display/ty.rs | 56 ++++++++-------- chalk-solve/src/goal_builder.rs | 2 +- chalk-solve/src/infer/test.rs | 37 ++++------- chalk-solve/src/infer/unify.rs | 2 +- chalk-solve/src/logging.rs | 2 +- chalk-solve/src/logging_db.rs | 2 +- chalk-solve/src/logging_db/id_collector.rs | 2 +- chalk-solve/src/rust_ir.rs | 6 +- chalk-solve/src/split.rs | 2 +- chalk-solve/src/wf.rs | 2 +- rustfmt.toml | 1 + src/main.rs | 4 +- tests/display/unique_names.rs | 6 +- tests/display/util.rs | 2 +- tests/integration/panic.rs | 39 +++++------ tests/logging_db/util.rs | 6 +- tests/lowering/mod.rs | 2 +- tests/test/bench.rs | 2 +- tests/test/mod.rs | 8 +-- tests/test/type_flags.rs | 30 ++++----- 62 files changed, 274 insertions(+), 349 deletions(-) create mode 100644 rustfmt.toml diff --git a/chalk-derive/src/lib.rs b/chalk-derive/src/lib.rs index 598e12ffb58..e13c0dffeb0 100644 --- a/chalk-derive/src/lib.rs +++ b/chalk-derive/src/lib.rs @@ -1,9 +1,9 @@ extern crate proc_macro; use proc_macro2::{Span, TokenStream}; -use quote::quote; use quote::ToTokens; -use syn::{parse_quote, DeriveInput, Ident, TypeParam, TypeParamBound}; +use quote::quote; +use syn::{DeriveInput, Ident, TypeParam, TypeParamBound, parse_quote}; use synstructure::decl_derive; @@ -54,7 +54,10 @@ fn get_intern_param(input: &DeriveInput) -> Option<(DeriveKind, &Ident)> { }); let param = params.next(); - assert!(params.next().is_none(), "deriving this trait only works with at most one type parameter that implements HasInterner or Interner"); + assert!( + params.next().is_none(), + "deriving this trait only works with at most one type parameter that implements HasInterner or Interner" + ); param } @@ -130,12 +133,9 @@ fn derive_has_interner(mut s: synstructure::Structure) -> TokenStream { let (interner, _) = find_interner(&mut s); s.add_bounds(synstructure::AddBounds::None); - s.bound_impl( - quote!(::chalk_ir::interner::HasInterner), - quote! { - type Interner = #interner; - }, - ) + s.bound_impl(quote!(::chalk_ir::interner::HasInterner), quote! { + type Interner = #interner; + }) } /// Derives TypeVisitable for structs and enums for which one of the following is true: @@ -240,20 +240,17 @@ fn derive_zip(mut s: synstructure::Structure) -> TokenStream { quote!((_, _) => Err(::chalk_ir::NoSolution)).to_tokens(&mut body); s.add_bounds(synstructure::AddBounds::None); - s.bound_impl( - quote!(::chalk_ir::zip::Zip<#interner>), - quote! { - - fn zip_with>( - zipper: &mut Z, - variance: ::chalk_ir::Variance, - a: &Self, - b: &Self, - ) -> ::chalk_ir::Fallible<()> { - match (a, b) { #body } - } - }, - ) + s.bound_impl(quote!(::chalk_ir::zip::Zip<#interner>), quote! { + + fn zip_with>( + zipper: &mut Z, + variance: ::chalk_ir::Variance, + a: &Self, + b: &Self, + ) -> ::chalk_ir::Fallible<()> { + match (a, b) { #body } + } + }) } /// Derives TypeFoldable for structs and enums for which one of the following is true: @@ -284,18 +281,15 @@ fn derive_type_foldable(mut s: synstructure::Structure) -> TokenStream { }; s.add_bounds(synstructure::AddBounds::None); - s.bound_impl( - quote!(::chalk_ir::fold::TypeFoldable<#interner>), - quote! { - fn try_fold_with( - self, - folder: &mut dyn ::chalk_ir::fold::FallibleTypeFolder < #interner, Error = E >, - outer_binder: ::chalk_ir::DebruijnIndex, - ) -> ::std::result::Result { - Ok(match self { #body }) - } - }, - ) + s.bound_impl(quote!(::chalk_ir::fold::TypeFoldable<#interner>), quote! { + fn try_fold_with( + self, + folder: &mut dyn ::chalk_ir::fold::FallibleTypeFolder < #interner, Error = E >, + outer_binder: ::chalk_ir::DebruijnIndex, + ) -> ::std::result::Result { + Ok(match self { #body }) + } + }) } fn derive_fallible_type_folder(mut s: synstructure::Structure) -> TokenStream { diff --git a/chalk-engine/src/context.rs b/chalk-engine/src/context.rs index fa418dfd49c..42081376771 100644 --- a/chalk-engine/src/context.rs +++ b/chalk-engine/src/context.rs @@ -6,8 +6,8 @@ //! [`Context`] trait for a list of types. use crate::CompleteAnswer; -use chalk_ir::interner::Interner; use chalk_ir::Substitution; +use chalk_ir::interner::Interner; use std::fmt::Debug; pub enum AnswerResult { diff --git a/chalk-engine/src/logic.rs b/chalk-engine/src/logic.rs index e38ed9187ac..05661168c17 100644 --- a/chalk-engine/src/logic.rs +++ b/chalk-engine/src/logic.rs @@ -17,8 +17,8 @@ use chalk_ir::{ }; use chalk_solve::clauses::program_clauses_that_could_match; use chalk_solve::coinductive_goal::IsCoinductive; -use chalk_solve::infer::ucanonicalize::UCanonicalized; use chalk_solve::infer::InferenceTable; +use chalk_solve::infer::ucanonicalize::UCanonicalized; use chalk_solve::solve::truncate; use tracing::{debug, debug_span, info, instrument}; @@ -678,7 +678,9 @@ impl<'forest, I: Interner> SolveState<'forest, I> { // the SLG FACTOR operation, though NFTD just makes it // part of computing the SLG resolvent. if self.forest.answer(subgoal_table, answer_index).ambiguous { - debug!("Marking Strand as ambiguous because answer to (positive) subgoal was ambiguous"); + debug!( + "Marking Strand as ambiguous because answer to (positive) subgoal was ambiguous" + ); ex_clause.ambiguous = true; } @@ -745,7 +747,10 @@ impl<'forest, I: Interner> SolveState<'forest, I> { // We want to disproval the subgoal, but we // have an unconditional answer for the subgoal, // therefore we have failed to disprove it. - debug!(?strand, "Marking Strand as ambiguous because answer to (negative) subgoal was ambiguous"); + debug!( + ?strand, + "Marking Strand as ambiguous because answer to (negative) subgoal was ambiguous" + ); strand.ex_clause.ambiguous = true; // Strand is ambigious. @@ -1329,11 +1334,13 @@ impl<'forest, I: Interner> SolveState<'forest, I> { // All the subgoals of this strand floundered. We may be able // to get helpful information from this strand still, but it // will *always* be ambiguous, so mark it as so. - assert!(!canonical_strand - .value - .ex_clause - .floundered_subgoals - .is_empty()); + assert!( + !canonical_strand + .value + .ex_clause + .floundered_subgoals + .is_empty() + ); canonical_strand.value.ex_clause.ambiguous = true; return SubGoalSelection::NotSelected; } diff --git a/chalk-engine/src/slg.rs b/chalk-engine/src/slg.rs index cffb9994ed5..59510221bc7 100644 --- a/chalk-engine/src/slg.rs +++ b/chalk-engine/src/slg.rs @@ -3,8 +3,8 @@ use crate::ExClause; use chalk_derive::HasInterner; use chalk_ir::interner::Interner; use chalk_ir::*; -use chalk_solve::infer::InferenceTable; use chalk_solve::RustIrDatabase; +use chalk_solve::infer::InferenceTable; use std::fmt::Debug; use std::marker::PhantomData; @@ -59,13 +59,10 @@ impl SlgContextOps<'_, I> { goal.canonical.clone(), ); infer - .canonicalize( - self.program.interner(), - ConstrainedSubst { - subst, - constraints: Constraints::empty(self.program.interner()), - }, - ) + .canonicalize(self.program.interner(), ConstrainedSubst { + subst, + constraints: Constraints::empty(self.program.interner()), + }) .quantified } diff --git a/chalk-engine/src/slg/aggregate.rs b/chalk-engine/src/slg/aggregate.rs index f8a1f84de81..b12ba1d0466 100644 --- a/chalk-engine/src/slg/aggregate.rs +++ b/chalk-engine/src/slg/aggregate.rs @@ -1,7 +1,7 @@ +use crate::CompleteAnswer; use crate::context::{self, AnswerResult}; use crate::slg::SlgContextOps; use crate::slg::SubstitutionExt; -use crate::CompleteAnswer; use chalk_ir::cast::Cast; use chalk_ir::interner::Interner; use chalk_ir::*; diff --git a/chalk-engine/src/slg/resolvent.rs b/chalk-engine/src/slg/resolvent.rs index 8606026006a..87315a7ce46 100644 --- a/chalk-engine/src/slg/resolvent.rs +++ b/chalk-engine/src/slg/resolvent.rs @@ -2,8 +2,8 @@ use crate::normalize_deep::DeepNormalizer; use crate::slg::ResolventOps; use crate::{ExClause, Literal, TimeStamp}; use chalk_ir::cast::Caster; -use chalk_ir::fold::shift::Shift; use chalk_ir::fold::TypeFoldable; +use chalk_ir::fold::shift::Shift; use chalk_ir::interner::{HasInterner, Interner}; use chalk_ir::zip::{Zip, Zipper}; use chalk_ir::*; diff --git a/chalk-engine/src/solve.rs b/chalk-engine/src/solve.rs index fc35adb6638..6a7f6e2fff5 100644 --- a/chalk-engine/src/solve.rs +++ b/chalk-engine/src/solve.rs @@ -1,7 +1,7 @@ use crate::context::{AnswerResult, AnswerStream}; use crate::forest::Forest; -use crate::slg::aggregate::AggregateOps; use crate::slg::SlgContextOps; +use crate::slg::aggregate::AggregateOps; use chalk_ir::interner::Interner; use chalk_ir::{Canonical, ConstrainedSubst, Goal, InEnvironment, UCanonical}; use chalk_solve::{RustIrDatabase, Solution, Solver, SubstitutionResult}; diff --git a/chalk-engine/src/table.rs b/chalk-engine/src/table.rs index e883cad322e..51e965968b2 100644 --- a/chalk-engine/src/table.rs +++ b/chalk-engine/src/table.rs @@ -2,8 +2,8 @@ use crate::index_struct; use crate::strand::CanonicalStrand; use crate::{Answer, AnswerMode}; use rustc_hash::FxHashMap; -use std::collections::hash_map::Entry; use std::collections::VecDeque; +use std::collections::hash_map::Entry; use std::mem; use chalk_ir::interner::Interner; diff --git a/chalk-engine/src/tables.rs b/chalk-engine/src/tables.rs index 76508eaa8dd..483d87094ba 100644 --- a/chalk-engine/src/tables.rs +++ b/chalk-engine/src/tables.rs @@ -1,5 +1,5 @@ -use crate::table::Table; use crate::TableIndex; +use crate::table::Table; use rustc_hash::FxHashMap; use std::ops::{Index, IndexMut}; diff --git a/chalk-integration/src/db.rs b/chalk-integration/src/db.rs index b705343b8d8..7eb67c57902 100644 --- a/chalk-integration/src/db.rs +++ b/chalk-integration/src/db.rs @@ -1,10 +1,11 @@ use crate::{ + SolverChoice, error::ChalkError, interner::ChalkIr, lowering::lower_goal, program::Program, query::{Lowering, LoweringDatabase}, - tls, SolverChoice, + tls, }; use chalk_ir::{ AdtId, AssocTypeId, Binders, Canonical, CanonicalVarKinds, ClosureId, ConstrainedSubst, diff --git a/chalk-integration/src/interner.rs b/chalk-integration/src/interner.rs index cef01c2cd42..a97ea554ac6 100644 --- a/chalk-integration/src/interner.rs +++ b/chalk-integration/src/interner.rs @@ -1,8 +1,4 @@ use crate::tls; -use chalk_ir::{ - interner::{HasInterner, Interner}, - TyKind, -}; use chalk_ir::{ AdtId, AliasTy, AssocTypeId, CanonicalVarKind, CanonicalVarKinds, ConstData, Constraint, Constraints, FnDefId, Goals, InEnvironment, Lifetime, OpaqueTy, OpaqueTyId, @@ -13,6 +9,10 @@ use chalk_ir::{ GenericArg, GenericArgData, Goal, GoalData, LifetimeData, ProgramClause, ProgramClauseData, QuantifiedWhereClause, Variance, }; +use chalk_ir::{ + TyKind, + interner::{HasInterner, Interner}, +}; use std::fmt; use std::fmt::Debug; use std::sync::Arc; @@ -39,14 +39,10 @@ pub enum ChalkFnAbi { impl Debug for ChalkFnAbi { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - fmt, - "{}", - match self { - ChalkFnAbi::Rust => "\"rust\"", - ChalkFnAbi::C => "\"c\"", - }, - ) + write!(fmt, "{}", match self { + ChalkFnAbi::Rust => "\"rust\"", + ChalkFnAbi::C => "\"c\"", + },) } } diff --git a/chalk-integration/src/lib.rs b/chalk-integration/src/lib.rs index f77030b9407..854e6071b02 100644 --- a/chalk-integration/src/lib.rs +++ b/chalk-integration/src/lib.rs @@ -12,8 +12,8 @@ pub mod test_macros; pub mod tls; use chalk_engine::solve::SLGSolver; -use chalk_ir::interner::HasInterner; use chalk_ir::Binders; +use chalk_ir::interner::HasInterner; use chalk_recursive::{Cache, RecursiveSolver}; use chalk_solve::Solver; use interner::ChalkIr; diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index ce6101b3a96..85527a0075c 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -746,7 +746,7 @@ impl LowerWithEnv for Ty { } match env.lookup_type(name)? { TypeLookup::Parameter(_) => { - return Err(RustIrError::CannotApplyTypeParameter(name.clone())) + return Err(RustIrError::CannotApplyTypeParameter(name.clone())); } TypeLookup::Adt(id) => tykind!(env.adt_kind(id), Adt, id), TypeLookup::FnDef(id) => tykind!(env.fn_def_kind(id), FnDef, id), diff --git a/chalk-integration/src/lowering/env.rs b/chalk-integration/src/lowering/env.rs index f399830bbc4..0a3d315e182 100644 --- a/chalk-integration/src/lowering/env.rs +++ b/chalk-integration/src/lowering/env.rs @@ -3,7 +3,7 @@ use chalk_ir::{ self, AdtId, BoundVar, ClosureId, CoroutineId, DebruijnIndex, FnDefId, OpaqueTyId, TraitId, VariableKinds, }; -use chalk_ir::{cast::Cast, ForeignDefId, WithKind}; +use chalk_ir::{ForeignDefId, WithKind, cast::Cast}; use chalk_parse::ast::*; use chalk_solve::rust_ir::AssociatedTyValueId; use std::collections::BTreeMap; diff --git a/chalk-integration/src/lowering/program_lowerer.rs b/chalk-integration/src/lowering/program_lowerer.rs index d6cbfd4b6f6..75a7d5476d6 100644 --- a/chalk-integration/src/lowering/program_lowerer.rs +++ b/chalk-integration/src/lowering/program_lowerer.rs @@ -13,11 +13,11 @@ use std::collections::{BTreeMap, HashSet}; use std::sync::Arc; use string_cache::DefaultAtom as Atom; -use super::{env::*, lower_adt_size_align, Lower, LowerParameterMap, LowerWithEnv, FIXME_SELF}; +use super::{FIXME_SELF, Lower, LowerParameterMap, LowerWithEnv, env::*, lower_adt_size_align}; +use crate::RawId; use crate::error::RustIrError; use crate::program::Program as LoweredProgram; -use crate::RawId; -use crate::{interner::ChalkIr, TypeKind, TypeSort}; +use crate::{TypeKind, TypeSort, interner::ChalkIr}; #[derive(Default)] pub(super) struct ProgramLowerer { diff --git a/chalk-integration/src/program.rs b/chalk-integration/src/program.rs index 9e55350d6b6..b0cfde2bc86 100644 --- a/chalk-integration/src/program.rs +++ b/chalk-integration/src/program.rs @@ -1,20 +1,20 @@ use crate::interner::ChalkIr; -use crate::{tls, Identifier, TypeKind}; -use chalk_ir::{could_match::CouldMatch, UnificationDatabase}; -use chalk_ir::{debug::Angle, Variance}; +use crate::{Identifier, TypeKind, tls}; use chalk_ir::{ - debug::SeparatorTraitRef, AdtId, AliasTy, AssocTypeId, Binders, CanonicalVarKinds, ClosureId, - CoroutineId, FnDefId, ForeignDefId, GenericArg, Goal, Goals, ImplId, IntTy, Lifetime, OpaqueTy, - OpaqueTyId, ProgramClause, ProgramClauseImplication, ProgramClauses, ProjectionTy, Scalar, - Substitution, TraitId, Ty, TyKind, UintTy, Variances, + AdtId, AliasTy, AssocTypeId, Binders, CanonicalVarKinds, ClosureId, CoroutineId, FnDefId, + ForeignDefId, GenericArg, Goal, Goals, ImplId, IntTy, Lifetime, OpaqueTy, OpaqueTyId, + ProgramClause, ProgramClauseImplication, ProgramClauses, ProjectionTy, Scalar, Substitution, + TraitId, Ty, TyKind, UintTy, Variances, debug::SeparatorTraitRef, }; +use chalk_ir::{UnificationDatabase, could_match::CouldMatch}; +use chalk_ir::{Variance, debug::Angle}; +use chalk_solve::RustIrDatabase; use chalk_solve::rust_ir::{ AdtDatum, AdtRepr, AdtSizeAlign, AssociatedTyDatum, AssociatedTyValue, AssociatedTyValueId, ClosureKind, CoroutineDatum, CoroutineWitnessDatum, FnDefDatum, FnDefInputsAndOutputDatum, ImplDatum, ImplType, OpaqueTyDatum, TraitDatum, WellKnownTrait, }; use chalk_solve::split::Split; -use chalk_solve::RustIrDatabase; use std::collections::{BTreeMap, HashSet}; use std::fmt; use std::sync::Arc; diff --git a/chalk-integration/src/query.rs b/chalk-integration/src/query.rs index ad493be94a6..6d3a6952bf5 100644 --- a/chalk-integration/src/query.rs +++ b/chalk-integration/src/query.rs @@ -1,21 +1,21 @@ // https://crates.io/crates/salsa // hello world https://github.com/salsa-rs/salsa/blob/master/examples/hello_world/main.rs +use crate::SolverChoice; use crate::error::ChalkError; use crate::interner::ChalkIr; use crate::lowering::Lower; use crate::program::Program; use crate::program_environment::ProgramEnvironment; use crate::tls; -use crate::SolverChoice; use chalk_ir::TraitId; +use chalk_solve::RustIrDatabase; +use chalk_solve::Solver; use chalk_solve::clauses::builder::ClauseBuilder; use chalk_solve::clauses::program_clauses::ToProgramClauses; use chalk_solve::coherence::orphan; use chalk_solve::coherence::{CoherenceSolver, SpecializationPriorities}; use chalk_solve::wf; -use chalk_solve::RustIrDatabase; -use chalk_solve::Solver; use salsa::Database; use std::clone::Clone; use std::cmp::{Eq, PartialEq}; diff --git a/chalk-integration/src/tls.rs b/chalk-integration/src/tls.rs index 58b1da3dfa8..69e3f6ffd33 100644 --- a/chalk-integration/src/tls.rs +++ b/chalk-integration/src/tls.rs @@ -1,9 +1,9 @@ use crate::interner::ChalkIr; use chalk_ir::{ - debug::SeparatorTraitRef, AdtId, AliasTy, AssocTypeId, CanonicalVarKinds, Constraints, FnDefId, - GenericArg, Goal, Goals, Lifetime, OpaqueTy, OpaqueTyId, ProgramClause, - ProgramClauseImplication, ProgramClauses, ProjectionTy, QuantifiedWhereClauses, Substitution, - TraitId, Ty, VariableKinds, Variances, + AdtId, AliasTy, AssocTypeId, CanonicalVarKinds, Constraints, FnDefId, GenericArg, Goal, Goals, + Lifetime, OpaqueTy, OpaqueTyId, ProgramClause, ProgramClauseImplication, ProgramClauses, + ProjectionTy, QuantifiedWhereClauses, Substitution, TraitId, Ty, VariableKinds, Variances, + debug::SeparatorTraitRef, }; use std::cell::RefCell; use std::fmt; diff --git a/chalk-ir/src/could_match.rs b/chalk-ir/src/could_match.rs index da69d6f22cd..8d94bafe49e 100644 --- a/chalk-ir/src/could_match.rs +++ b/chalk-ir/src/could_match.rs @@ -142,11 +142,7 @@ where _ => true, }; - if could_match { - Ok(()) - } else { - Err(NoSolution) - } + if could_match { Ok(()) } else { Err(NoSolution) } } fn zip_lifetimes( diff --git a/chalk-ir/src/interner.rs b/chalk-ir/src/interner.rs index e0bd4e7b602..3a4c4f783f6 100644 --- a/chalk-ir/src/interner.rs +++ b/chalk-ir/src/interner.rs @@ -563,7 +563,7 @@ pub trait Interner: Debug + Copy + Eq + Hash + Sized { /// Lookup the `ProgramClauseData` that was interned to create a `ProgramClause`. fn program_clauses_data(self, clauses: &Self::InternedProgramClauses) - -> &[ProgramClause]; + -> &[ProgramClause]; /// Create an "interned" quantified where clauses from `data`. This is not /// normally invoked directly; instead, you invoke diff --git a/chalk-ir/src/lib.rs b/chalk-ir/src/lib.rs index 7763738264a..c43e40fe7ad 100644 --- a/chalk-ir/src/lib.rs +++ b/chalk-ir/src/lib.rs @@ -2504,10 +2504,10 @@ impl Goal { QuantifierKind::ForAll, Binders::with_fresh_type_var(interner, |ty| { GoalData::Implies( - ProgramClauses::from_iter( - interner, - vec![DomainGoal::Compatible, DomainGoal::DownstreamType(ty)], - ), + ProgramClauses::from_iter(interner, vec![ + DomainGoal::Compatible, + DomainGoal::DownstreamType(ty), + ]), self.shifted_in(interner), ) .intern(interner) diff --git a/chalk-ir/src/visit/boring_impls.rs b/chalk-ir/src/visit/boring_impls.rs index 462bacc64d6..bb9b7085b94 100644 --- a/chalk-ir/src/visit/boring_impls.rs +++ b/chalk-ir/src/visit/boring_impls.rs @@ -5,11 +5,11 @@ //! The more interesting impls of `TypeVisitable` remain in the `visit` module. use crate::{ - try_break, AdtId, AssocTypeId, ClausePriority, ClosureId, Constraints, ControlFlow, - CoroutineId, DebruijnIndex, FloatTy, FnDefId, ForeignDefId, GenericArg, Goals, ImplId, IntTy, - Interner, Mutability, OpaqueTyId, PlaceholderIndex, ProgramClause, ProgramClauses, + AdtId, AssocTypeId, ClausePriority, ClosureId, Constraints, ControlFlow, CoroutineId, + DebruijnIndex, FloatTy, FnDefId, ForeignDefId, GenericArg, Goals, ImplId, IntTy, Interner, + Mutability, OpaqueTyId, PlaceholderIndex, ProgramClause, ProgramClauses, QuantifiedWhereClauses, QuantifierKind, Safety, Scalar, Substitution, TraitId, - TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy, UniverseIndex, + TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy, UniverseIndex, try_break, }; use std::{marker::PhantomData, sync::Arc}; diff --git a/chalk-recursive/src/fulfill.rs b/chalk-recursive/src/fulfill.rs index 2524ff795b8..2d1b9623ce2 100644 --- a/chalk-recursive/src/fulfill.rs +++ b/chalk-recursive/src/fulfill.rs @@ -548,14 +548,11 @@ impl<'s, I: Interner, Solver: SolveDatabase> Fulfill<'s, I, Solver> { // and the current inference state is the unique way to solve them. let constraints = Constraints::from_iter(self.interner(), self.constraints.clone()); - let constrained = canonicalize( - &mut self.infer, - self.solver.interner(), - ConstrainedSubst { + let constrained = + canonicalize(&mut self.infer, self.solver.interner(), ConstrainedSubst { subst: self.subst, constraints, - }, - ); + }); return Ok(Solution::Unique(constrained.0)); } diff --git a/chalk-recursive/src/recursive.rs b/chalk-recursive/src/recursive.rs index 61680c75269..e315999dc20 100644 --- a/chalk-recursive/src/recursive.rs +++ b/chalk-recursive/src/recursive.rs @@ -1,10 +1,10 @@ +use crate::UCanonicalGoal; use crate::fixed_point::{Cache, Minimums, RecursiveContext, SolverStuff}; use crate::solve::{SolveDatabase, SolveIteration}; -use crate::UCanonicalGoal; -use chalk_ir::{interner::Interner, NoSolution}; use chalk_ir::{Canonical, ConstrainedSubst, Goal, InEnvironment, UCanonical}; use chalk_ir::{Constraints, Fallible}; -use chalk_solve::{coinductive_goal::IsCoinductive, RustIrDatabase, Solution}; +use chalk_ir::{NoSolution, interner::Interner}; +use chalk_solve::{RustIrDatabase, Solution, coinductive_goal::IsCoinductive}; use std::fmt; /// A Solver is the basic context in which you can propose goals for a given diff --git a/chalk-recursive/src/solve.rs b/chalk-recursive/src/solve.rs index ba2525467b9..0b885ff716f 100644 --- a/chalk-recursive/src/solve.rs +++ b/chalk-recursive/src/solve.rs @@ -1,7 +1,7 @@ use super::combine; use super::fulfill::Fulfill; -use crate::fixed_point::Minimums; use crate::UCanonicalGoal; +use crate::fixed_point::Minimums; use chalk_ir::could_match::CouldMatch; use chalk_ir::fold::TypeFoldable; use chalk_ir::interner::{HasInterner, Interner}; diff --git a/chalk-solve/src/clauses.rs b/chalk-solve/src/clauses.rs index fae04ff55f2..f0491a5b9d7 100644 --- a/chalk-solve/src/clauses.rs +++ b/chalk-solve/src/clauses.rs @@ -1,10 +1,10 @@ use self::builder::ClauseBuilder; use self::env_elaborator::elaborate_env_clauses; use self::program_clauses::ToProgramClauses; +use crate::RustIrDatabase; use crate::goal_builder::GoalBuilder; use crate::rust_ir::{Movability, WellKnownTrait}; use crate::split::Split; -use crate::RustIrDatabase; use chalk_ir::cast::{Cast, Caster}; use chalk_ir::could_match::CouldMatch; use chalk_ir::interner::Interner; @@ -956,16 +956,10 @@ fn match_ty( builder.push_bound_lifetime(|builder, lifetime| { let ref_ty = TyKind::Ref(*mutbl, lifetime.clone(), ty.clone()) .intern(builder.interner()); - builder.push_clause( - WellFormed::Ty(ref_ty), - [ - DomainGoal::WellFormed(WellFormed::Ty(ty.clone())), - DomainGoal::Holds(WhereClause::TypeOutlives(TypeOutlives { - ty, - lifetime, - })), - ], - ); + builder.push_clause(WellFormed::Ty(ref_ty), [ + DomainGoal::WellFormed(WellFormed::Ty(ty.clone())), + DomainGoal::Holds(WhereClause::TypeOutlives(TypeOutlives { ty, lifetime })), + ]); }) }); } @@ -991,15 +985,12 @@ fn match_ty( // forall WF([T, N]) :- T: Sized let interner = builder.interner(); let binders = Binders::new( - VariableKinds::from_iter( - interner, - [ - VariableKind::Ty(TyVariableKind::General), - VariableKind::Const( - TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(interner), - ), - ], - ), + VariableKinds::from_iter(interner, [ + VariableKind::Ty(TyVariableKind::General), + VariableKind::Const( + TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(interner), + ), + ]), PhantomData::, ); builder.push_binders(binders, |builder, PhantomData| { diff --git a/chalk-solve/src/clauses/builder.rs b/chalk-solve/src/clauses/builder.rs index bbe7c2fd217..53dc8f269f8 100644 --- a/chalk-solve/src/clauses/builder.rs +++ b/chalk-solve/src/clauses/builder.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; -use crate::cast::{Cast, CastTo}; use crate::RustIrDatabase; +use crate::cast::{Cast, CastTo}; use chalk_ir::fold::{Shift, TypeFoldable}; use chalk_ir::interner::{HasInterner, Interner}; use chalk_ir::*; diff --git a/chalk-solve/src/clauses/builtin_traits.rs b/chalk-solve/src/clauses/builtin_traits.rs index f054e0db415..15b09d72e40 100644 --- a/chalk-solve/src/clauses/builtin_traits.rs +++ b/chalk-solve/src/clauses/builtin_traits.rs @@ -1,6 +1,6 @@ use super::{builder::ClauseBuilder, generalize}; use crate::{ - rust_ir::AdtKind, CanonicalVarKinds, Interner, RustIrDatabase, TraitRef, WellKnownTrait, + CanonicalVarKinds, Interner, RustIrDatabase, TraitRef, WellKnownTrait, rust_ir::AdtKind, }; use chalk_ir::{Floundered, Substitution, Ty, TyKind}; diff --git a/chalk-solve/src/clauses/builtin_traits/copy.rs b/chalk-solve/src/clauses/builtin_traits/copy.rs index 6477d5add13..110ef32e70e 100644 --- a/chalk-solve/src/clauses/builtin_traits/copy.rs +++ b/chalk-solve/src/clauses/builtin_traits/copy.rs @@ -1,5 +1,5 @@ -use crate::clauses::builtin_traits::needs_impl_for_tys; use crate::clauses::ClauseBuilder; +use crate::clauses::builtin_traits::needs_impl_for_tys; use crate::{Interner, RustIrDatabase, TraitRef}; use chalk_ir::{CanonicalVarKinds, Floundered, Substitution, TyKind, TyVariableKind, VariableKind}; use std::iter; diff --git a/chalk-solve/src/clauses/builtin_traits/coroutine.rs b/chalk-solve/src/clauses/builtin_traits/coroutine.rs index 615a9d3d051..96f9c3b1d67 100644 --- a/chalk-solve/src/clauses/builtin_traits/coroutine.rs +++ b/chalk-solve/src/clauses/builtin_traits/coroutine.rs @@ -30,13 +30,10 @@ pub fn add_coroutine_program_clauses( trait_datum.associated_ty_ids ); - let substitution = Substitution::from_iter( - interner, - &[ - self_ty.cast(interner), - coroutine_io_datum.resume_type.cast(interner), - ], - ); + let substitution = Substitution::from_iter(interner, &[ + self_ty.cast(interner), + coroutine_io_datum.resume_type.cast(interner), + ]); // coroutine: Coroutine builder.push_fact(TraitRef { diff --git a/chalk-solve/src/clauses/builtin_traits/sized.rs b/chalk-solve/src/clauses/builtin_traits/sized.rs index 6a92c32b529..5a69b0f4750 100644 --- a/chalk-solve/src/clauses/builtin_traits/sized.rs +++ b/chalk-solve/src/clauses/builtin_traits/sized.rs @@ -1,7 +1,7 @@ use std::iter; -use crate::clauses::builtin_traits::needs_impl_for_tys; use crate::clauses::ClauseBuilder; +use crate::clauses::builtin_traits::needs_impl_for_tys; use crate::{Interner, RustIrDatabase, TraitRef}; use chalk_ir::{ AdtId, CanonicalVarKinds, Floundered, Substitution, TyKind, TyVariableKind, VariableKind, diff --git a/chalk-solve/src/clauses/builtin_traits/unsize.rs b/chalk-solve/src/clauses/builtin_traits/unsize.rs index 6682735b692..8cf2d304771 100644 --- a/chalk-solve/src/clauses/builtin_traits/unsize.rs +++ b/chalk-solve/src/clauses/builtin_traits/unsize.rs @@ -6,11 +6,11 @@ use crate::clauses::ClauseBuilder; use crate::rust_ir::AdtKind; use crate::{Interner, RustIrDatabase, TraitRef, WellKnownTrait}; use chalk_ir::{ + Binders, Const, ConstValue, DebruijnIndex, DomainGoal, DynTy, EqGoal, Goal, LifetimeOutlives, + QuantifiedWhereClauses, Substitution, TraitId, Ty, TyKind, TypeOutlives, WhereClause, cast::Cast, interner::HasInterner, visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}, - Binders, Const, ConstValue, DebruijnIndex, DomainGoal, DynTy, EqGoal, Goal, LifetimeOutlives, - QuantifiedWhereClauses, Substitution, TraitId, Ty, TyKind, TypeOutlives, WhereClause, }; struct UnsizeParameterCollector { diff --git a/chalk-solve/src/clauses/dyn_ty.rs b/chalk-solve/src/clauses/dyn_ty.rs index 505da43f972..9a7dde05a2b 100644 --- a/chalk-solve/src/clauses/dyn_ty.rs +++ b/chalk-solve/src/clauses/dyn_ty.rs @@ -1,6 +1,6 @@ use super::{builder::ClauseBuilder, generalize}; use crate::RustIrDatabase; -use chalk_ir::{cast::Cast, interner::Interner, Ty, TyKind, WhereClause}; +use chalk_ir::{Ty, TyKind, WhereClause, cast::Cast, interner::Interner}; /// If the self type `S` of an `Implemented` goal is a `dyn trait` type, we wish /// to generate program-clauses that indicates that it implements its own diff --git a/chalk-solve/src/clauses/env_elaborator.rs b/chalk-solve/src/clauses/env_elaborator.rs index 6279d36a78a..240e6505385 100644 --- a/chalk-solve/src/clauses/env_elaborator.rs +++ b/chalk-solve/src/clauses/env_elaborator.rs @@ -1,12 +1,12 @@ use super::program_clauses::ToProgramClauses; -use crate::clauses::builder::ClauseBuilder; -use crate::clauses::{match_alias_ty, match_ty}; use crate::DomainGoal; use crate::FromEnv; use crate::ProgramClause; use crate::RustIrDatabase; use crate::Ty; -use crate::{debug_span, TyKind}; +use crate::clauses::builder::ClauseBuilder; +use crate::clauses::{match_alias_ty, match_ty}; +use crate::{TyKind, debug_span}; use chalk_ir::interner::Interner; use chalk_ir::visit::{TypeVisitable, TypeVisitor}; use chalk_ir::{DebruijnIndex, Environment}; diff --git a/chalk-solve/src/clauses/generalize.rs b/chalk-solve/src/clauses/generalize.rs index bff05b36995..a4da8519d07 100644 --- a/chalk-solve/src/clauses/generalize.rs +++ b/chalk-solve/src/clauses/generalize.rs @@ -8,10 +8,10 @@ use chalk_derive::FallibleTypeFolder; use chalk_ir::{ - fold::{TypeFoldable, TypeFolder}, - interner::{HasInterner, Interner}, Binders, BoundVar, Const, ConstData, ConstValue, DebruijnIndex, Lifetime, LifetimeData, Ty, TyKind, TyVariableKind, VariableKind, VariableKinds, + fold::{TypeFoldable, TypeFolder}, + interner::{HasInterner, Interner}, }; use rustc_hash::FxHashMap; diff --git a/chalk-solve/src/clauses/super_traits.rs b/chalk-solve/src/clauses/super_traits.rs index c6040b6dc28..39f8526a1a2 100644 --- a/chalk-solve/src/clauses/super_traits.rs +++ b/chalk-solve/src/clauses/super_traits.rs @@ -2,10 +2,10 @@ use itertools::{Either, Itertools}; use rustc_hash::FxHashSet; use super::builder::ClauseBuilder; -use crate::{split::Split, RustIrDatabase}; +use crate::{RustIrDatabase, split::Split}; use chalk_ir::{ - fold::shift::Shift, interner::Interner, AliasEq, AliasTy, Binders, BoundVar, DebruijnIndex, - Normalize, ProjectionTy, TraitId, TraitRef, Ty, WhereClause, + AliasEq, AliasTy, Binders, BoundVar, DebruijnIndex, Normalize, ProjectionTy, TraitId, TraitRef, + Ty, WhereClause, fold::shift::Shift, interner::Interner, }; /// Generate `Implemented` and `Normalize` clauses for `dyn Trait` and opaque types. @@ -83,16 +83,13 @@ fn super_traits( let interner = db.interner(); let mut seen_traits = FxHashSet::default(); let trait_datum = db.trait_datum(trait_id); - let trait_ref = Binders::empty( - db.interner(), - TraitRef { - trait_id, - substitution: trait_datum - .binders - .identity_substitution(interner) - .shifted_in(interner), - }, - ); + let trait_ref = Binders::empty(db.interner(), TraitRef { + trait_id, + substitution: trait_datum + .binders + .identity_substitution(interner) + .shifted_in(interner), + }); let mut trait_refs = Vec::new(); let mut aliases = Vec::new(); go( diff --git a/chalk-solve/src/coherence.rs b/chalk-solve/src/coherence.rs index 5528b9a21fd..f07561ad56e 100644 --- a/chalk-solve/src/coherence.rs +++ b/chalk-solve/src/coherence.rs @@ -2,8 +2,8 @@ use indexmap::IndexMap; use petgraph::prelude::*; use rustc_hash::FxHashMap; -use crate::solve::Solver; use crate::RustIrDatabase; +use crate::solve::Solver; use chalk_ir::interner::Interner; use chalk_ir::{self, ImplId, TraitId}; use std::fmt; diff --git a/chalk-solve/src/coherence/orphan.rs b/chalk-solve/src/coherence/orphan.rs index f8e06b901ec..b5e87020327 100644 --- a/chalk-solve/src/coherence/orphan.rs +++ b/chalk-solve/src/coherence/orphan.rs @@ -1,7 +1,7 @@ +use crate::RustIrDatabase; use crate::coherence::CoherenceError; use crate::ext::GoalExt; use crate::solve::Solver; -use crate::RustIrDatabase; use chalk_ir::cast::*; use chalk_ir::interner::Interner; use chalk_ir::*; diff --git a/chalk-solve/src/coherence/solve.rs b/chalk-solve/src/coherence/solve.rs index 57dd81061dc..3df95b71fd8 100644 --- a/chalk-solve/src/coherence/solve.rs +++ b/chalk-solve/src/coherence/solve.rs @@ -2,7 +2,7 @@ use crate::coherence::{CoherenceError, CoherenceSolver}; use crate::debug_span; use crate::ext::*; use crate::rust_ir::*; -use crate::{goal_builder::GoalBuilder, Solution}; +use crate::{Solution, goal_builder::GoalBuilder}; use chalk_ir::cast::*; use chalk_ir::fold::shift::Shift; use chalk_ir::interner::Interner; diff --git a/chalk-solve/src/display.rs b/chalk-solve/src/display.rs index b608232d432..9f1993d0d5b 100644 --- a/chalk-solve/src/display.rs +++ b/chalk-solve/src/display.rs @@ -8,7 +8,7 @@ use crate::rust_ir::*; use chalk_ir::{interner::Interner, *}; use itertools::Itertools; -use crate::{logging_db::RecordedItemId, split::Split, RustIrDatabase}; +use crate::{RustIrDatabase, logging_db::RecordedItemId, split::Split}; #[macro_use] mod utils; diff --git a/chalk-solve/src/display/items.rs b/chalk-solve/src/display/items.rs index 49454eb642f..b57dc2ddea8 100644 --- a/chalk-solve/src/display/items.rs +++ b/chalk-solve/src/display/items.rs @@ -77,16 +77,12 @@ impl RenderAsRust for AdtDatum { let value = self.binders.skip_binders(); // flags - write_flags!( - f, - self.flags, - AdtFlags { - // Ordering matters - upstream, - fundamental, - phantom_data - } - ); + write_flags!(f, self.flags, AdtFlags { + // Ordering matters + upstream, + fundamental, + phantom_data + }); // repr let repr = s.db().adt_repr(self.id); @@ -171,18 +167,14 @@ impl RenderAsRust for TraitDatum { let value = self.binders.skip_binders(); // flags - write_flags!( - f, - self.flags, - TraitFlags { - auto, - marker, - upstream, - fundamental, - non_enumerable, - coinductive - } - ); + write_flags!(f, self.flags, TraitFlags { + auto, + marker, + upstream, + fundamental, + non_enumerable, + coinductive + }); // object safe if s.db().is_object_safe(self.id) { diff --git a/chalk-solve/src/display/stub.rs b/chalk-solve/src/display/stub.rs index 0631e9c291f..118a6b2ca8e 100644 --- a/chalk-solve/src/display/stub.rs +++ b/chalk-solve/src/display/stub.rs @@ -4,15 +4,15 @@ use std::sync::Arc; use crate::rust_ir::{CoroutineDatum, CoroutineWitnessDatum}; use crate::{ + RustIrDatabase, rust_ir::{ AdtDatumBound, AdtKind, AdtVariantDatum, AssociatedTyDatumBound, FnDefDatumBound, OpaqueTyDatumBound, TraitDatumBound, }, - RustIrDatabase, }; use chalk_ir::{ - interner::Interner, Binders, CanonicalVarKinds, CoroutineId, Substitution, Ty, - UnificationDatabase, VariableKinds, Variances, + Binders, CanonicalVarKinds, CoroutineId, Substitution, Ty, UnificationDatabase, VariableKinds, + Variances, interner::Interner, }; #[derive(Debug)] @@ -46,13 +46,10 @@ impl> RustIrDatabase for StubWrapper<'_, D ty: chalk_ir::AssocTypeId, ) -> std::sync::Arc> { let mut v = (*self.db.associated_ty_data(ty)).clone(); - v.binders = Binders::new( - v.binders.binders.clone(), - AssociatedTyDatumBound { - where_clauses: Vec::new(), - bounds: Vec::new(), - }, - ); + v.binders = Binders::new(v.binders.binders.clone(), AssociatedTyDatumBound { + where_clauses: Vec::new(), + bounds: Vec::new(), + }); Arc::new(v) } @@ -61,12 +58,9 @@ impl> RustIrDatabase for StubWrapper<'_, D trait_id: chalk_ir::TraitId, ) -> std::sync::Arc> { let mut v = (*self.db.trait_datum(trait_id)).clone(); - v.binders = Binders::new( - v.binders.binders.clone(), - TraitDatumBound { - where_clauses: Vec::new(), - }, - ); + v.binders = Binders::new(v.binders.binders.clone(), TraitDatumBound { + where_clauses: Vec::new(), + }); Arc::new(v) } @@ -76,13 +70,10 @@ impl> RustIrDatabase for StubWrapper<'_, D AdtKind::Struct | AdtKind::Union => vec![AdtVariantDatum { fields: vec![] }], AdtKind::Enum => vec![], }; - v.binders = Binders::new( - v.binders.binders.clone(), - AdtDatumBound { - variants, - where_clauses: Vec::new(), - }, - ); + v.binders = Binders::new(v.binders.binders.clone(), AdtDatumBound { + variants, + where_clauses: Vec::new(), + }); Arc::new(v) } @@ -99,13 +90,10 @@ impl> RustIrDatabase for StubWrapper<'_, D fn_def_id: chalk_ir::FnDefId, ) -> std::sync::Arc> { let mut v = (*self.db.fn_def_datum(fn_def_id)).clone(); - v.binders = Binders::new( - v.binders.binders.clone(), - FnDefDatumBound { - inputs_and_output: v.binders.skip_binders().inputs_and_output.clone(), - where_clauses: Vec::new(), - }, - ); + v.binders = Binders::new(v.binders.binders.clone(), FnDefDatumBound { + inputs_and_output: v.binders.skip_binders().inputs_and_output.clone(), + where_clauses: Vec::new(), + }); Arc::new(v) } @@ -128,13 +116,10 @@ impl> RustIrDatabase for StubWrapper<'_, D id: chalk_ir::OpaqueTyId, ) -> std::sync::Arc> { let mut v = (*self.db.opaque_ty_data(id)).clone(); - v.bound = Binders::new( - v.bound.binders, - OpaqueTyDatumBound { - bounds: Binders::new(VariableKinds::empty(self.db.interner()), Vec::new()), - where_clauses: Binders::new(VariableKinds::empty(self.db.interner()), Vec::new()), - }, - ); + v.bound = Binders::new(v.bound.binders, OpaqueTyDatumBound { + bounds: Binders::new(VariableKinds::empty(self.db.interner()), Vec::new()), + where_clauses: Binders::new(VariableKinds::empty(self.db.interner()), Vec::new()), + }); Arc::new(v) } diff --git a/chalk-solve/src/display/ty.rs b/chalk-solve/src/display/ty.rs index daa47ccc999..fd30e34ca98 100644 --- a/chalk-solve/src/display/ty.rs +++ b/chalk-solve/src/display/ty.rs @@ -200,36 +200,32 @@ impl RenderAsRust for FnPointer { impl RenderAsRust for Scalar { fn fmt(&self, _s: &InternalWriterState<'_, I>, f: &mut Formatter<'_>) -> Result { use chalk_ir::{FloatTy::*, IntTy::*, UintTy::*}; - write!( - f, - "{}", - match self { - Scalar::Bool => "bool", - Scalar::Char => "char", - Scalar::Int(int) => match int { - Isize => "isize", - I8 => "i8", - I16 => "i16", - I32 => "i32", - I64 => "i64", - I128 => "i128", - }, - Scalar::Uint(uint) => match uint { - Usize => "usize", - U8 => "u8", - U16 => "u16", - U32 => "u32", - U64 => "u64", - U128 => "u128", - }, - Scalar::Float(float) => match float { - F16 => "f16", - F32 => "f32", - F64 => "f64", - F128 => "f128", - }, - } - ) + write!(f, "{}", match self { + Scalar::Bool => "bool", + Scalar::Char => "char", + Scalar::Int(int) => match int { + Isize => "isize", + I8 => "i8", + I16 => "i16", + I32 => "i32", + I64 => "i64", + I128 => "i128", + }, + Scalar::Uint(uint) => match uint { + Usize => "usize", + U8 => "u8", + U16 => "u16", + U32 => "u32", + U64 => "u64", + U128 => "u128", + }, + Scalar::Float(float) => match float { + F16 => "f16", + F32 => "f32", + F64 => "f64", + F128 => "f128", + }, + }) } } diff --git a/chalk-solve/src/goal_builder.rs b/chalk-solve/src/goal_builder.rs index aa5c9c9eb49..653dbd0399d 100644 --- a/chalk-solve/src/goal_builder.rs +++ b/chalk-solve/src/goal_builder.rs @@ -3,8 +3,8 @@ use cast::CastTo; use chalk_ir::cast::Cast; use chalk_ir::cast::Caster; use chalk_ir::*; -use fold::shift::Shift; use fold::TypeFoldable; +use fold::shift::Shift; use interner::{HasInterner, Interner}; pub struct GoalBuilder<'i, I: Interner> { diff --git a/chalk-solve/src/infer/test.rs b/chalk-solve/src/infer/test.rs index 2ac35f0275d..a90cc365df9 100644 --- a/chalk-solve/src/infer/test.rs +++ b/chalk-solve/src/infer/test.rs @@ -267,14 +267,11 @@ fn quantify_simple() { .quantified, Canonical { value: ty!(apply (item 0) (bound 0) (bound 1) (bound 2)), - binders: CanonicalVarKinds::from_iter( - interner, - vec![ - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U2), - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U1), - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), - ] - ), + binders: CanonicalVarKinds::from_iter(interner, vec![ + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U2), + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U1), + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), + ]), } ); } @@ -310,14 +307,11 @@ fn quantify_bound() { .quantified, Canonical { value: ty!(apply (item 0) (apply (item 1) (bound 0) (bound 1)) (bound 2) (bound 0) (bound 1)), - binders: CanonicalVarKinds::from_iter( - interner, - vec![ - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U1), - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U2), - ] - ), + binders: CanonicalVarKinds::from_iter(interner, vec![ + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U1), + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U2), + ]), } ); } @@ -356,13 +350,10 @@ fn quantify_ty_under_binder() { .quantified, Canonical { value: ty!(function 3 (apply (item 0) (bound 1) (bound 1 0) (bound 1 0) (lifetime (bound 1 1)))), - binders: CanonicalVarKinds::from_iter( - interner, - vec![ - CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), - CanonicalVarKind::new(VariableKind::Lifetime, U0) - ] - ), + binders: CanonicalVarKinds::from_iter(interner, vec![ + CanonicalVarKind::new(VariableKind::Ty(TyVariableKind::General), U0), + CanonicalVarKind::new(VariableKind::Lifetime, U0) + ]), } ); } diff --git a/chalk-solve/src/infer/unify.rs b/chalk-solve/src/infer/unify.rs index 1ce4796da98..9acb91599f4 100644 --- a/chalk-solve/src/infer/unify.rs +++ b/chalk-solve/src/infer/unify.rs @@ -1,11 +1,11 @@ use super::var::*; use super::*; use crate::debug_span; +use chalk_ir::UnificationDatabase; use chalk_ir::cast::Cast; use chalk_ir::fold::{FallibleTypeFolder, TypeFoldable}; use chalk_ir::interner::{HasInterner, Interner}; use chalk_ir::zip::{Zip, Zipper}; -use chalk_ir::UnificationDatabase; use std::fmt::Debug; use tracing::{debug, instrument}; diff --git a/chalk-solve/src/logging.rs b/chalk-solve/src/logging.rs index a5be4d4d468..9031d3b69cb 100644 --- a/chalk-solve/src/logging.rs +++ b/chalk-solve/src/logging.rs @@ -2,7 +2,7 @@ /// from `CHALK_DEBUG`. #[cfg(feature = "tracing-full")] pub fn with_tracing_logs(action: impl FnOnce() -> T) -> T { - use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; + use tracing_subscriber::{EnvFilter, Registry, layer::SubscriberExt}; use tracing_tree::HierarchicalLayer; let filter = EnvFilter::from_env("CHALK_DEBUG"); let subscriber = Registry::default() diff --git a/chalk-solve/src/logging_db.rs b/chalk-solve/src/logging_db.rs index 14d4c21c188..e2352c72135 100644 --- a/chalk-solve/src/logging_db.rs +++ b/chalk-solve/src/logging_db.rs @@ -11,8 +11,8 @@ use std::{ use crate::rust_ir::*; use crate::{ - display::{self, WriterState}, RustIrDatabase, + display::{self, WriterState}, }; use chalk_ir::{interner::Interner, *}; diff --git a/chalk-solve/src/logging_db/id_collector.rs b/chalk-solve/src/logging_db/id_collector.rs index 4b97bac26b8..9690bc9be90 100644 --- a/chalk-solve/src/logging_db/id_collector.rs +++ b/chalk-solve/src/logging_db/id_collector.rs @@ -1,10 +1,10 @@ use super::RecordedItemId; use crate::RustIrDatabase; use chalk_ir::{ + AliasTy, DebruijnIndex, TyKind, WhereClause, interner::Interner, visit::TypeVisitor, visit::{TypeSuperVisitable, TypeVisitable}, - AliasTy, DebruijnIndex, TyKind, WhereClause, }; use std::ops::ControlFlow; diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 9c29814ff7b..89e3518ae74 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -7,9 +7,9 @@ use chalk_ir::cast::Cast; use chalk_ir::fold::shift::Shift; use chalk_ir::interner::Interner; use chalk_ir::{ - try_break, visit::TypeVisitable, AdtId, AliasEq, AliasTy, AssocTypeId, Binders, DebruijnIndex, - FnDefId, GenericArg, ImplId, OpaqueTyId, ProjectionTy, QuantifiedWhereClause, Substitution, - ToGenericArg, TraitId, TraitRef, Ty, TyKind, VariableKind, WhereClause, WithKind, + AdtId, AliasEq, AliasTy, AssocTypeId, Binders, DebruijnIndex, FnDefId, GenericArg, ImplId, + OpaqueTyId, ProjectionTy, QuantifiedWhereClause, Substitution, ToGenericArg, TraitId, TraitRef, + Ty, TyKind, VariableKind, WhereClause, WithKind, try_break, visit::TypeVisitable, }; use std::iter; use std::ops::ControlFlow; diff --git a/chalk-solve/src/split.rs b/chalk-solve/src/split.rs index bea24044db8..c3710047e02 100644 --- a/chalk-solve/src/split.rs +++ b/chalk-solve/src/split.rs @@ -1,5 +1,5 @@ -use crate::rust_ir::*; use crate::RustIrDatabase; +use crate::rust_ir::*; use chalk_ir::interner::Interner; use chalk_ir::*; use std::sync::Arc; diff --git a/chalk-solve/src/wf.rs b/chalk-solve/src/wf.rs index e3be0558697..8db0111a615 100644 --- a/chalk-solve/src/wf.rs +++ b/chalk-solve/src/wf.rs @@ -2,7 +2,7 @@ use std::ops::ControlFlow; use std::{fmt, iter}; use crate::{ - ext::*, goal_builder::GoalBuilder, rust_ir::*, solve::Solver, split::Split, RustIrDatabase, + RustIrDatabase, ext::*, goal_builder::GoalBuilder, rust_ir::*, solve::Solver, split::Split, }; use chalk_ir::{ cast::*, diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000000..3501136812c --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +style_edition = "2024" diff --git a/src/main.rs b/src/main.rs index 0b900bbbd96..6e815a4e453 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,14 +5,14 @@ use std::fs::File; use std::io::Read; use std::process::exit; +use chalk_integration::SolverChoice; use chalk_integration::db::ChalkDatabase; use chalk_integration::interner::ChalkIr; use chalk_integration::lowering::*; use chalk_integration::query::LoweringDatabase; -use chalk_integration::SolverChoice; +use chalk_solve::RustIrDatabase; use chalk_solve::ext::*; use chalk_solve::logging; -use chalk_solve::RustIrDatabase; use docopt::Docopt; use rustyline::error::ReadlineError; diff --git a/tests/display/unique_names.rs b/tests/display/unique_names.rs index d8545a98d42..c1d8a1404fd 100644 --- a/tests/display/unique_names.rs +++ b/tests/display/unique_names.rs @@ -1,13 +1,13 @@ use chalk_integration::{program::Program, query::LoweringDatabase, tls}; -use chalk_ir::{interner::Interner, UnificationDatabase}; +use chalk_ir::{UnificationDatabase, interner::Interner}; use chalk_solve::{ - display::{write_items, WriterState}, RustIrDatabase, + display::{WriterState, write_items}, }; use std::marker::PhantomData; use std::sync::Arc; -use super::util::{program_item_ids, ReparseTestResult}; +use super::util::{ReparseTestResult, program_item_ids}; /// `DuplicateNamesDb` implements `RustIrDatabase`, and returns `Foo` for all /// requested item names. This allows us to test that names are correctly diff --git a/tests/display/util.rs b/tests/display/util.rs index 1f40313b4a0..cd80f6587a3 100644 --- a/tests/display/util.rs +++ b/tests/display/util.rs @@ -5,7 +5,7 @@ //! compiled as a standalone test (rather than from `lib.rs`). use chalk_integration::{interner::ChalkIr, program::Program, query::LoweringDatabase, tls}; use chalk_solve::{ - display::{write_items, WriterState}, + display::{WriterState, write_items}, logging_db::RecordedItemId, }; use regex::Regex; diff --git a/tests/integration/panic.rs b/tests/integration/panic.rs index af9617a0d0e..29feafafb74 100644 --- a/tests/integration/panic.rs +++ b/tests/integration/panic.rs @@ -1,8 +1,8 @@ -use chalk_integration::interner::{ChalkIr, RawId}; use chalk_integration::SolverChoice; +use chalk_integration::interner::{ChalkIr, RawId}; use chalk_ir::*; -use chalk_solve::rust_ir::*; use chalk_solve::RustIrDatabase; +use chalk_solve::rust_ir::*; use std::sync::Arc; // FIXME: some of these are probably redundant, so we should figure out which panic in the same place in `chalk-engine` @@ -67,12 +67,9 @@ impl RustIrDatabase for MockDatabase { assert_eq!(id.0.index, 0); Arc::new(TraitDatum { id, - binders: Binders::new( - VariableKinds::empty(ChalkIr), - TraitDatumBound { - where_clauses: vec![], - }, - ), + binders: Binders::new(VariableKinds::empty(ChalkIr), TraitDatumBound { + where_clauses: vec![], + }), flags: TraitFlags { auto: false, marker: false, @@ -99,16 +96,13 @@ impl RustIrDatabase for MockDatabase { TyKind::Adt(AdtId(RawId { index: 1 }), Substitution::empty(ChalkIr)), ); - let binders = Binders::new( - VariableKinds::empty(ChalkIr), - ImplDatumBound { - trait_ref: TraitRef { - trait_id: TraitId(RawId { index: 0 }), - substitution: Substitution::from1(ChalkIr, substitution), - }, - where_clauses: vec![], + let binders = Binders::new(VariableKinds::empty(ChalkIr), ImplDatumBound { + trait_ref: TraitRef { + trait_id: TraitId(RawId { index: 0 }), + substitution: Substitution::from1(ChalkIr, substitution), }, - ); + where_clauses: vec![], + }); Arc::new(ImplDatum { polarity: Polarity::Positive, @@ -136,13 +130,10 @@ impl RustIrDatabase for MockDatabase { fn adt_datum(&self, id: AdtId) -> Arc> { // Only needed because we always access the adt datum for logging Arc::new(AdtDatum { - binders: Binders::empty( - ChalkIr, - AdtDatumBound { - variants: vec![], - where_clauses: vec![], - }, - ), + binders: Binders::empty(ChalkIr, AdtDatumBound { + variants: vec![], + where_clauses: vec![], + }), flags: AdtFlags { fundamental: false, phantom_data: false, diff --git a/tests/logging_db/util.rs b/tests/logging_db/util.rs index ca00e9a24ff..df1db618b61 100644 --- a/tests/logging_db/util.rs +++ b/tests/logging_db/util.rs @@ -5,12 +5,12 @@ //! to `test/`. We can't compile without access to `test/`, so we can't be under //! of `test_util.rs`. use chalk_integration::{ - db::ChalkDatabase, lowering::lower_goal, program::Program, query::LoweringDatabase, - SolverChoice, + SolverChoice, db::ChalkDatabase, lowering::lower_goal, program::Program, + query::LoweringDatabase, }; +use chalk_solve::RustIrDatabase; use chalk_solve::ext::*; use chalk_solve::logging_db::LoggingRustIrDatabase; -use chalk_solve::RustIrDatabase; use crate::test::assert_result_str; diff --git a/tests/lowering/mod.rs b/tests/lowering/mod.rs index 628f7b2104e..0a85d6b0e8a 100644 --- a/tests/lowering/mod.rs +++ b/tests/lowering/mod.rs @@ -1,6 +1,6 @@ +use chalk_integration::SolverChoice; use chalk_integration::db::ChalkDatabase; use chalk_integration::query::LoweringDatabase; -use chalk_integration::SolverChoice; #[test] fn lower_success() { diff --git a/tests/test/bench.rs b/tests/test/bench.rs index 93e34f4ea41..fcb48d1e5b2 100644 --- a/tests/test/bench.rs +++ b/tests/test/bench.rs @@ -3,8 +3,8 @@ use self::test::Bencher; use chalk_ir; -use chalk_solve::ext::*; use chalk_solve::SolverChoice; +use chalk_solve::ext::*; use super::{assert_result, parse_and_lower_goal, parse_and_lower_program_with_env}; diff --git a/tests/test/mod.rs b/tests/test/mod.rs index a23ad1b69d9..7e919931fdf 100644 --- a/tests/test/mod.rs +++ b/tests/test/mod.rs @@ -3,19 +3,19 @@ use std::sync::Arc; use chalk_integration::program::Program; -use expect_test::{expect, Expect}; +use expect_test::{Expect, expect}; use crate::test_util::assert_same; +use chalk_integration::SolverChoice; use chalk_integration::db::ChalkDatabase; use chalk_integration::interner::ChalkIr; use chalk_integration::lowering::lower_goal; use chalk_integration::query::LoweringDatabase; -use chalk_integration::SolverChoice; use chalk_ir::Constraints; -use chalk_solve::ext::*; -use chalk_solve::logging::with_tracing_logs; use chalk_solve::RustIrDatabase; use chalk_solve::Solution; +use chalk_solve::ext::*; +use chalk_solve::logging::with_tracing_logs; #[cfg(feature = "bench")] mod bench; diff --git a/tests/test/type_flags.rs b/tests/test/type_flags.rs index 5678781eab6..cab60169d0f 100644 --- a/tests/test/type_flags.rs +++ b/tests/test/type_flags.rs @@ -51,16 +51,15 @@ fn dyn_ty_flags_correct() { }; let bounds = chalk_ir::Binders::>::empty( ChalkIr, - chalk_ir::QuantifiedWhereClauses::from_iter( + chalk_ir::QuantifiedWhereClauses::from_iter(ChalkIr, vec![chalk_ir::Binders::< + chalk_ir::WhereClause, + >::empty( ChalkIr, - vec![chalk_ir::Binders::>::empty( - ChalkIr, - chalk_ir::WhereClause::AliasEq(chalk_ir::AliasEq { - ty: internal_ty, - alias: chalk_ir::AliasTy::Projection(projection_ty), - }), - )], - ), + chalk_ir::WhereClause::AliasEq(chalk_ir::AliasEq { + ty: internal_ty, + alias: chalk_ir::AliasTy::Projection(projection_ty), + }), + )]), ); let dyn_ty = chalk_ir::DynTy { lifetime: lifetime!(placeholder 5), @@ -96,14 +95,11 @@ fn flagless_ty_has_no_flags() { #[test] fn static_and_bound_lifetimes() { - let substitutions = chalk_ir::Substitution::from_iter( - ChalkIr, - vec![ - chalk_ir::GenericArgData::Lifetime(chalk_ir::LifetimeData::Static.intern(ChalkIr)) - .intern(ChalkIr), - chalk_ir::GenericArgData::Lifetime(lifetime!(bound 5)).intern(ChalkIr), - ], - ); + let substitutions = chalk_ir::Substitution::from_iter(ChalkIr, vec![ + chalk_ir::GenericArgData::Lifetime(chalk_ir::LifetimeData::Static.intern(ChalkIr)) + .intern(ChalkIr), + chalk_ir::GenericArgData::Lifetime(lifetime!(bound 5)).intern(ChalkIr), + ]); let ty = TyKind::Adt( chalk_ir::AdtId(chalk_integration::interner::RawId { index: 0 }),