1
Fork 0

Reformat using the new identifier sorting from rustfmt

This commit is contained in:
Michael Goulet 2024-09-22 19:05:04 -04:00
parent 1173204b36
commit c682aa162b
1455 changed files with 7152 additions and 8384 deletions

View file

@ -15,10 +15,10 @@ use rustc_middle::ty::{
use smallvec::SmallVec;
use tracing::debug;
use crate::infer::InferCtxt;
use crate::infer::canonical::{
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues,
};
use crate::infer::InferCtxt;
impl<'tcx> InferCtxt<'tcx> {
/// Canonicalizes a query value `V`. When we canonicalize a query,

View file

@ -19,7 +19,7 @@ use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use tracing::{debug, instrument};
use crate::infer::canonical::instantiate::{instantiate_value, CanonicalExt};
use crate::infer::canonical::instantiate::{CanonicalExt, instantiate_value};
use crate::infer::canonical::{
Canonical, CanonicalQueryResponse, CanonicalVarValues, Certainty, OriginalQueryValues,
QueryOutlivesConstraint, QueryRegionConstraints, QueryResponse,

View file

@ -1,12 +1,12 @@
///! Definition of `InferCtxtLike` from the librarified type layer.
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::traits::solve::{Goal, NoSolution, SolverMode};
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::solve::{Goal, NoSolution, SolverMode};
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::DUMMY_SP;
use rustc_type_ir::relate::Relate;
use rustc_type_ir::InferCtxtLike;
use rustc_type_ir::relate::Relate;
use super::{BoundRegionConversionTime, InferCtxt, SubregionOrigin};

View file

@ -4,7 +4,7 @@ use std::fmt;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::implementation::{
Direction, Graph, NodeIndex, INCOMING, OUTGOING,
Direction, Graph, INCOMING, NodeIndex, OUTGOING,
};
use rustc_data_structures::intern::Interned;
use rustc_data_structures::unord::UnordSet;

View file

@ -1,6 +1,9 @@
use std::cell::{Cell, RefCell};
use std::fmt;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
pub use SubregionOrigin::*;
pub use at::DefineOpaqueTypes;
use free_regions::RegionRelations;
pub use freshen::TypeFreshener;
@ -10,8 +13,8 @@ use opaque_types::OpaqueTypeStorage;
use region_constraints::{
GenericKind, RegionConstraintCollector, RegionConstraintStorage, VarInfos, VerifyBound,
};
pub use relate::combine::{CombineFields, PredicateEmittingRelation};
pub use relate::StructurallyRelateAliases;
pub use relate::combine::{CombineFields, PredicateEmittingRelation};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
@ -26,29 +29,26 @@ use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::{
ConstVariableOrigin, ConstVariableValue, ConstVidKey, EffectVarValue, EffectVidKey,
};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
use rustc_middle::traits::select;
use rustc_middle::traits::solve::{Goal, NoSolution};
pub use rustc_middle::ty::IntVarValue;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::fold::{
BoundVarReplacerDelegate, TypeFoldable, TypeFolder, TypeSuperFoldable,
};
use rustc_middle::ty::visit::TypeVisitableExt;
pub use rustc_middle::ty::IntVarValue;
use rustc_middle::ty::{
self, ConstVid, EffectVid, FloatVid, GenericArg, GenericArgKind, GenericArgs, GenericArgsRef,
GenericParamDefKind, InferConst, IntVid, Ty, TyCtxt, TyVid,
};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use snapshot::undo_log::InferCtxtUndoLogs;
use tracing::{debug, instrument};
use type_variable::TypeVariableOrigin;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
pub use SubregionOrigin::*;
use crate::infer::relate::RelateResult;
use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine};
@ -1776,16 +1776,13 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
self.idx += 1;
idx
};
Ty::new_placeholder(
self.tcx,
ty::PlaceholderType {
universe: ty::UniverseIndex::ROOT,
bound: ty::BoundTy {
var: ty::BoundVar::from_u32(idx),
kind: ty::BoundTyKind::Anon,
},
Ty::new_placeholder(self.tcx, ty::PlaceholderType {
universe: ty::UniverseIndex::ROOT,
bound: ty::BoundTy {
var: ty::BoundVar::from_u32(idx),
kind: ty::BoundTyKind::Anon,
},
)
})
} else {
t.super_fold_with(self)
}
@ -1793,17 +1790,14 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
if let ty::ConstKind::Infer(_) = c.kind() {
ty::Const::new_placeholder(
self.tcx,
ty::PlaceholderConst {
universe: ty::UniverseIndex::ROOT,
bound: ty::BoundVar::from_u32({
let idx = self.idx;
self.idx += 1;
idx
}),
},
)
ty::Const::new_placeholder(self.tcx, ty::PlaceholderConst {
universe: ty::UniverseIndex::ROOT,
bound: ty::BoundVar::from_u32({
let idx = self.idx;
self.idx += 1;
idx
}),
})
} else {
c.super_fold_with(self)
}

View file

@ -2,8 +2,8 @@ use hir::def_id::{DefId, LocalDefId};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::Lrc;
use rustc_hir as hir;
use rustc_middle::traits::solve::Goal;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::fold::BottomUpFolder;
use rustc_middle::ty::{

View file

@ -5,8 +5,8 @@ use rustc_middle::ty::{self, Region};
use tracing::{debug, instrument};
use super::explicit_outlives_bounds;
use crate::infer::free_regions::FreeRegionMap;
use crate::infer::GenericKind;
use crate::infer::free_regions::FreeRegionMap;
use crate::traits::query::OutlivesBound;
/// The `OutlivesEnvironment` collects information about what outlives

View file

@ -68,7 +68,7 @@ use rustc_middle::ty::{
TypeFoldable as _, TypeVisitableExt,
};
use rustc_span::DUMMY_SP;
use rustc_type_ir::outlives::{push_outlives_components, Component};
use rustc_type_ir::outlives::{Component, push_outlives_components};
use smallvec::smallvec;
use tracing::{debug, instrument};
@ -101,19 +101,15 @@ impl<'tcx> InferCtxt<'tcx> {
) {
debug!(?sup_type, ?sub_region, ?cause);
let origin = SubregionOrigin::from_obligation_cause(cause, || {
infer::RelateParamBound(
cause.span,
sup_type,
match cause.code().peel_derives() {
ObligationCauseCode::WhereClause(_, span)
| ObligationCauseCode::WhereClauseInExpr(_, span, ..)
if !span.is_dummy() =>
{
Some(*span)
}
_ => None,
},
)
infer::RelateParamBound(cause.span, sup_type, match cause.code().peel_derives() {
ObligationCauseCode::WhereClause(_, span)
| ObligationCauseCode::WhereClauseInExpr(_, span, ..)
if !span.is_dummy() =>
{
Some(*span)
}
_ => None,
})
});
self.register_region_obligation(RegionObligation { sup_type, sub_region, origin });

View file

@ -1,7 +1,7 @@
use std::assert_matches::assert_matches;
use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
use rustc_type_ir::outlives::{compute_alias_components_recursive, Component};
use rustc_type_ir::outlives::{Component, compute_alias_components_recursive};
use smallvec::smallvec;
use tracing::{debug, instrument, trace};

View file

@ -30,7 +30,7 @@ use super::glb::Glb;
use super::lub::Lub;
use super::type_relating::TypeRelating;
use super::{RelateResult, StructurallyRelateAliases};
use crate::infer::{relate, DefineOpaqueTypes, InferCtxt, TypeTrace};
use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace, relate};
use crate::traits::{Obligation, PredicateObligation};
#[derive(Clone)]

View file

@ -17,7 +17,7 @@ use super::{
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
};
use crate::infer::type_variable::TypeVariableValue;
use crate::infer::{relate, InferCtxt, RegionVariableOrigin};
use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
impl<'tcx> InferCtxt<'tcx> {
/// The idea is that we should ensure that the type variable `target_vid`

View file

@ -6,9 +6,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
use tracing::{debug, instrument};
use super::StructurallyRelateAliases;
use super::combine::{CombineFields, PredicateEmittingRelation};
use super::lattice::{self, LatticeDir};
use super::StructurallyRelateAliases;
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
use crate::traits::ObligationCause;

View file

@ -6,8 +6,8 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
use tracing::{debug, instrument};
use super::RelateResult;
use crate::infer::snapshot::CombinedSnapshot;
use crate::infer::InferCtxt;
use crate::infer::snapshot::CombinedSnapshot;
impl<'tcx> InferCtxt<'tcx> {
/// Replaces all bound variables (lifetimes, types, and constants) bound by
@ -34,22 +34,22 @@ impl<'tcx> InferCtxt<'tcx> {
let delegate = FnMutDelegate {
regions: &mut |br: ty::BoundRegion| {
ty::Region::new_placeholder(
self.tcx,
ty::PlaceholderRegion { universe: next_universe, bound: br },
)
ty::Region::new_placeholder(self.tcx, ty::PlaceholderRegion {
universe: next_universe,
bound: br,
})
},
types: &mut |bound_ty: ty::BoundTy| {
Ty::new_placeholder(
self.tcx,
ty::PlaceholderType { universe: next_universe, bound: bound_ty },
)
Ty::new_placeholder(self.tcx, ty::PlaceholderType {
universe: next_universe,
bound: bound_ty,
})
},
consts: &mut |bound_var: ty::BoundVar| {
ty::Const::new_placeholder(
self.tcx,
ty::PlaceholderConst { universe: next_universe, bound: bound_var },
)
ty::Const::new_placeholder(self.tcx, ty::PlaceholderConst {
universe: next_universe,
bound: bound_var,
})
},
};

View file

@ -6,9 +6,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
use tracing::{debug, instrument};
use super::StructurallyRelateAliases;
use super::combine::{CombineFields, PredicateEmittingRelation};
use super::lattice::{self, LatticeDir};
use super::StructurallyRelateAliases;
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
use crate::traits::ObligationCause;

View file

@ -1,14 +1,14 @@
use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::{
relate_args_invariantly, relate_args_with_variances, Relate, RelateResult, TypeRelation,
Relate, RelateResult, TypeRelation, relate_args_invariantly, relate_args_with_variances,
};
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar};
use rustc_span::Span;
use tracing::{debug, instrument};
use super::combine::CombineFields;
use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
use crate::infer::BoundRegionConversionTime::HigherRankedType;
use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
/// Enforce that `a` is equal to or a subtype of `b`.

View file

@ -2,8 +2,8 @@ use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::ty;
use tracing::{debug, instrument};
use super::region_constraints::RegionSnapshot;
use super::InferCtxt;
use super::region_constraints::RegionSnapshot;
mod fudge;
pub(crate) mod undo_log;

View file

@ -6,7 +6,7 @@ use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey, RegionVidKey};
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey};
use tracing::debug;
use crate::infer::{region_constraints, type_variable, InferCtxtInner};
use crate::infer::{InferCtxtInner, region_constraints, type_variable};
use crate::traits;
pub struct Snapshot<'tcx> {

View file

@ -45,15 +45,12 @@ pub trait TraitEngine<'tcx, E: 'tcx>: 'tcx {
cause: ObligationCause<'tcx>,
) {
let trait_ref = ty::TraitRef::new(infcx.tcx, def_id, [ty]);
self.register_predicate_obligation(
infcx,
Obligation {
cause,
recursion_depth: 0,
param_env,
predicate: trait_ref.upcast(infcx.tcx),
},
);
self.register_predicate_obligation(infcx, Obligation {
cause,
recursion_depth: 0,
param_env,
predicate: trait_ref.upcast(infcx.tcx),
});
}
fn register_predicate_obligation(

View file

@ -18,14 +18,14 @@ pub use rustc_middle::traits::*;
use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
use rustc_span::Span;
pub use self::ImplSource::*;
pub use self::SelectionError::*;
pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine};
pub(crate) use self::project::UndoLog;
pub use self::project::{
MismatchedProjectionTypes, Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry,
ProjectionCacheKey, ProjectionCacheStorage,
};
pub use self::ImplSource::*;
pub use self::SelectionError::*;
use crate::infer::InferCtxt;
/// An `Obligation` represents some trait reference (e.g., `i32: Eq`) for

View file

@ -200,10 +200,10 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
if result.must_apply_considering_regions() {
ty.obligations = vec![];
}
map.insert(
key,
ProjectionCacheEntry::NormalizedTerm { ty, complete: Some(result) },
);
map.insert(key, ProjectionCacheEntry::NormalizedTerm {
ty,
complete: Some(result),
});
}
ref value => {
// Type inference could "strand behind" old cache entries. Leave

View file

@ -1,7 +1,7 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::ty::{self, ToPolyTraitRef, TyCtxt};
use rustc_span::symbol::Ident;
use rustc_span::Span;
use rustc_span::symbol::Ident;
pub use rustc_type_ir::elaborate::*;
use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};