Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set rustfmt style_edition to 2024 #820

Closed
wants to merge 1 commit into from
Closed
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
64 changes: 29 additions & 35 deletions chalk-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<Z: ::chalk_ir::zip::Zipper<#interner>>(
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<Z: ::chalk_ir::zip::Zipper<#interner>>(
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:
Expand Down Expand Up @@ -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<E>(
self,
folder: &mut dyn ::chalk_ir::fold::FallibleTypeFolder < #interner, Error = E >,
outer_binder: ::chalk_ir::DebruijnIndex,
) -> ::std::result::Result<Self, E> {
Ok(match self { #body })
}
},
)
s.bound_impl(quote!(::chalk_ir::fold::TypeFoldable<#interner>), quote! {
fn try_fold_with<E>(
self,
folder: &mut dyn ::chalk_ir::fold::FallibleTypeFolder < #interner, Error = E >,
outer_binder: ::chalk_ir::DebruijnIndex,
) -> ::std::result::Result<Self, E> {
Ok(match self { #body })
}
})
}

fn derive_fallible_type_folder(mut s: synstructure::Structure) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I: Interner> {
Expand Down
23 changes: 15 additions & 8 deletions chalk-engine/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 5 additions & 8 deletions chalk-engine/src/slg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,13 +59,10 @@ impl<I: Interner> 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
}

Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/slg/aggregate.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/slg/resolvent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/solve.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion chalk-engine/src/tables.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::table::Table;
use crate::TableIndex;
use crate::table::Table;
use rustc_hash::FxHashMap;
use std::ops::{Index, IndexMut};

Expand Down
3 changes: 2 additions & 1 deletion chalk-integration/src/db.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
20 changes: 8 additions & 12 deletions chalk-integration/src/interner.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand All @@ -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\"",
},)
}
}

Expand Down
2 changes: 1 addition & 1 deletion chalk-integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion chalk-integration/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion chalk-integration/src/lowering/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions chalk-integration/src/lowering/program_lowerer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions chalk-integration/src/program.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions chalk-integration/src/query.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
8 changes: 4 additions & 4 deletions chalk-integration/src/tls.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading
Loading