Run rustfmt --file-lines ... for changes from previous commits.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-12 00:11:55 +03:00
parent 21ac960334
commit fff08cb043
176 changed files with 2212 additions and 2132 deletions

View file

@ -30,8 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break`
}
pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
body: &hir::Body) -> CFG {
pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG {
let mut graph = graph::Graph::new();
let entry = graph.add_node(CFGNodeData::Entry);

View file

@ -49,8 +49,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
pub type CFGEdge = graph::Edge<CFGEdgeData>;
impl CFG {
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
body: &hir::Body) -> CFG {
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG {
construct::construct(tcx, body)
}

View file

@ -480,7 +480,8 @@ trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug {
}
impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
where T: HashStable<StableHashingContext<'tcx>> + fmt::Debug
where
T: HashStable<StableHashingContext<'tcx>> + fmt::Debug,
{
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;

View file

@ -90,7 +90,6 @@ where
}
impl DepGraph {
pub fn new(prev_graph: PreviousDepGraph,
prev_work_products: FxHashMap<WorkProductId, WorkProduct>) -> DepGraph {
let prev_graph_node_count = prev_graph.node_count();
@ -559,7 +558,7 @@ impl DepGraph {
pub fn try_mark_green_and_read(
&self,
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode
dep_node: &DepNode,
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| {
debug_assert!(self.is_green(&dep_node));
@ -571,7 +570,7 @@ impl DepGraph {
pub fn try_mark_green(
&self,
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode
dep_node: &DepNode,
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
debug_assert!(!dep_node.kind.is_eval_always());
@ -607,7 +606,7 @@ impl DepGraph {
tcx: TyCtxt<'tcx, 'tcx>,
data: &DepGraphData,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode
dep_node: &DepNode,
) -> Option<DepNodeIndex> {
debug!("try_mark_previous_green({:?}) - BEGIN", dep_node);

View file

@ -33,8 +33,7 @@ impl DepGraphSafe for DefId {
/// The type context itself can be used to access all kinds of tracked
/// state, but those accesses should always generate read events.
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {
}
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {}
/// Tuples make it easy to build up state.
impl<A, B> DepGraphSafe for (A, B)

View file

@ -14,11 +14,7 @@ use crate::ty::{self, TyCtxt};
impl<'tcx, V> Canonical<'tcx, V> {
/// Instantiate the wrapped value, replacing each canonical value
/// with the value given in `var_values`.
pub fn substitute(
&self,
tcx: TyCtxt<'_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>,
) -> V
pub fn substitute(&self, tcx: TyCtxt<'_, 'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V
where
V: TypeFoldable<'tcx>,
{

View file

@ -58,12 +58,14 @@ pub enum RelationDir {
}
impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
pub fn super_combine_tys<R>(&self,
relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
where R: TypeRelation<'gcx, 'tcx>
pub fn super_combine_tys<R>(
&self,
relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
{
let a_is_expected = relation.a_is_expected();

View file

@ -338,7 +338,10 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
}
impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T>
where T: for<'a, 'b, 'c> Print<'gcx, 'tcx,
where
T: for<'a, 'b, 'c> Print<
'gcx,
'tcx,
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>,
Error = fmt::Error,
>,

View file

@ -27,7 +27,7 @@ use crate::ty::TyVar;
use crate::ty::{self, Ty};
use crate::ty::relate::{RelateResult, TypeRelation};
pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'gcx, 'tcx> {
pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> {
fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>;
fn cause(&self) -> &ObligationCause<'tcx>;

View file

@ -28,11 +28,12 @@ impl<'tcx> FreeRegionMap<'tcx> {
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_free_regions<'gcx>(&self,
tcx: TyCtxt<'gcx, 'tcx>,
r_a: Region<'tcx>,
r_b: Region<'tcx>)
-> Region<'tcx> {
pub fn lub_free_regions<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
r_a: Region<'tcx>,
r_b: Region<'tcx>,
) -> Region<'tcx> {
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
assert!(is_free(r_a));
assert!(is_free(r_b));

View file

@ -1423,10 +1423,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
}
}
fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'tcx, 'tcx>,
pass: T
) {
fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx, 'tcx>, pass: T) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir().krate();
@ -1461,7 +1458,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'tcx, 'tcx>,
builtin_lints: T
builtin_lints: T,
) {
let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap();

View file

@ -766,9 +766,7 @@ pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_>, id: hir::HirId) -> bool {
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
}
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum)
-> &'tcx LintLevelMap
{
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap {
assert_eq!(cnum, LOCAL_CRATE);
let mut builder = LintLevelMapBuilder {
levels: LintLevelSets::builder(tcx.sess),

View file

@ -211,9 +211,7 @@ pub trait CrateStore {
fn crates_untracked(&self) -> Vec<CrateNum>;
// utility functions
fn encode_metadata<'tcx>(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> EncodedMetadata;
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata;
fn metadata_encoding_version(&self) -> &[u8];
}
@ -228,9 +226,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
// In order to get this left-to-right dependency ordering, we perform a
// topological sort of all crates putting the leaves at the right-most
// positions.
pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference)
-> Vec<(CrateNum, LibSource)>
{
pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> {
let mut libs = tcx.crates()
.iter()
.cloned()

View file

@ -26,8 +26,7 @@ use syntax_pos;
// explored. For example, if it's a live Node::Item that is a
// function, then we should explore its block to check for codes that
// may need to be marked as live.
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
hir_id: hir::HirId) -> bool {
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool {
match tcx.hir().find_by_hir_id(hir_id) {
Some(Node::Item(..)) |
Some(Node::ImplItem(..)) |
@ -302,9 +301,11 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}
}
fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_>,
id: hir::HirId,
attrs: &[ast::Attribute]) -> bool {
fn has_allow_dead_code_or_lang_attr(
tcx: TyCtxt<'_, '_>,
id: hir::HirId,
attrs: &[ast::Attribute],
) -> bool {
if attr::contains_name(attrs, sym::lang) {
return true;
}
@ -451,10 +452,11 @@ fn create_and_seed_worklist<'tcx>(
(life_seeder.worklist, life_seeder.struct_constructors)
}
fn find_live<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
access_levels: &privacy::AccessLevels,
krate: &hir::Crate)
-> FxHashSet<hir::HirId> {
fn find_live<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
access_levels: &privacy::AccessLevels,
krate: &hir::Crate,
) -> FxHashSet<hir::HirId> {
let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
let mut symbol_visitor = MarkSymbolVisitor {
worklist,

View file

@ -92,9 +92,7 @@ pub fn calculate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
sess.dependency_formats.set(fmts);
}
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ty: config::CrateType) -> DependencyList {
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: config::CrateType) -> DependencyList {
let sess = &tcx.sess;
if !sess.opts.output_types.should_codegen() {
@ -242,10 +240,12 @@ fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ret
}
fn add_library(tcx: TyCtxt<'_, '_>,
cnum: CrateNum,
link: LinkagePreference,
m: &mut FxHashMap<CrateNum, LinkagePreference>) {
fn add_library(
tcx: TyCtxt<'_, '_>,
cnum: CrateNum,
link: LinkagePreference,
m: &mut FxHashMap<CrateNum, LinkagePreference>,
) {
match m.get(&cnum) {
Some(&link2) => {
// If the linkages differ, then we'd have two copies of the library

View file

@ -38,9 +38,7 @@ pub enum ExportedSymbol<'tcx> {
}
impl<'tcx> ExportedSymbol<'tcx> {
pub fn symbol_name(&self,
tcx: TyCtxt<'tcx, '_>)
-> ty::SymbolName {
pub fn symbol_name(&self, tcx: TyCtxt<'tcx, '_>) -> ty::SymbolName {
match *self {
ExportedSymbol::NonGeneric(def_id) => {
tcx.symbol_name(ty::Instance::mono(tcx, def_id))
@ -54,10 +52,11 @@ impl<'tcx> ExportedSymbol<'tcx> {
}
}
pub fn compare_stable(&self,
tcx: TyCtxt<'tcx, '_>,
other: &ExportedSymbol<'tcx>)
-> cmp::Ordering {
pub fn compare_stable(
&self,
tcx: TyCtxt<'tcx, '_>,
other: &ExportedSymbol<'tcx>,
) -> cmp::Ordering {
match *self {
ExportedSymbol::NonGeneric(self_def_id) => match *other {
ExportedSymbol::NonGeneric(other_def_id) => {

View file

@ -266,15 +266,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
/// `None` means that rvalues will be given more conservative lifetimes.
///
/// See also `with_infer`, which is used *during* typeck.
pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a),
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> Self
{
pub fn new(
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
) -> Self {
ExprUseVisitor {
mc: mc::MemCategorizationContext::new(tcx,
body_owner,

View file

@ -25,7 +25,7 @@ pub fn provide(providers: &mut Providers<'_>) {
}
struct ItemVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>
tcx: TyCtxt<'tcx, 'tcx>,
}
struct ExprVisitor<'tcx> {
@ -36,9 +36,7 @@ struct ExprVisitor<'tcx> {
/// If the type is `Option<T>`, it will return `T`, otherwise
/// the type itself. Works on most `Option`-like types.
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>)
-> Ty<'tcx> {
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let (def, substs) = match ty.sty {
ty::Adt(def, substs) => (def, substs),
_ => return ty

View file

@ -352,12 +352,14 @@ impl IrMaps<'tcx> {
}
}
fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'tcx>,
fk: FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
body_id: hir::BodyId,
sp: Span,
id: hir::HirId) {
fn visit_fn<'a, 'tcx: 'a>(
ir: &mut IrMaps<'tcx>,
fk: FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
body_id: hir::BodyId,
sp: Span,
id: hir::HirId,
) {
debug!("visit_fn");
// swap in a new set of IR maps for this function body:

View file

@ -287,7 +287,7 @@ impl HirNode for hir::Pat {
}
#[derive(Clone)]
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
pub struct MemCategorizationContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'gcx, 'tcx>,
pub body_owner: DefId,
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
@ -339,8 +339,11 @@ impl MutabilityCategory {
ret
}
fn from_local(tcx: TyCtxt<'_, '_>, tables: &ty::TypeckTables<'_>,
id: ast::NodeId) -> MutabilityCategory {
fn from_local(
tcx: TyCtxt<'_, '_>,
tables: &ty::TypeckTables<'_>,
id: ast::NodeId,
) -> MutabilityCategory {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
PatKind::Binding(..) => {
@ -400,12 +403,13 @@ impl MutabilityCategory {
}
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
) -> MemCategorizationContext<'a, 'tcx, 'tcx> {
MemCategorizationContext {
tcx,
body_owner,

View file

@ -27,9 +27,7 @@ use crate::hir::intravisit;
// Returns true if the given item must be inlined because it may be
// monomorphized or it was marked with `#[inline]`. This will only return
// true for functions.
fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>,
item: &hir::Item,
attrs: CodegenFnAttrs) -> bool {
fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item, attrs: CodegenFnAttrs) -> bool {
if attrs.requests_inline() {
return true
}
@ -44,9 +42,11 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>,
}
}
fn method_might_be_inlined<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
impl_item: &hir::ImplItem,
impl_src: DefId) -> bool {
fn method_might_be_inlined<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
impl_item: &hir::ImplItem,
impl_src: DefId,
) -> bool {
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {

View file

@ -646,9 +646,11 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives.
pub fn early_free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
br: &ty::EarlyBoundRegion)
-> Scope {
pub fn early_free_scope<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
br: &ty::EarlyBoundRegion,
) -> Scope {
let param_owner = tcx.parent(br.def_id).unwrap();
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
@ -677,8 +679,7 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives.
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion)
-> Scope {
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion) -> Scope {
let param_owner = match fr.bound_region {
ty::BoundRegion::BrNamed(def_id, _) => {
tcx.parent(def_id).unwrap()
@ -734,9 +735,11 @@ impl<'tcx> ScopeTree {
}
/// Records the lifetime of a local variable as `cx.var_parent`
fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_>,
var_id: hir::ItemLocalId,
_sp: Span) {
fn record_var_lifetime(
visitor: &mut RegionResolutionVisitor<'_>,
var_id: hir::ItemLocalId,
_sp: Span,
) {
match visitor.cx.var_parent {
None => {
// this can happen in extern fn declarations like
@ -977,9 +980,11 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
visitor.cx = prev_cx;
}
fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
pat: Option<&'tcx hir::Pat>,
init: Option<&'tcx hir::Expr>) {
fn resolve_local<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
pat: Option<&'tcx hir::Pat>,
init: Option<&'tcx hir::Expr>,
) {
debug!("resolve_local(pat={:?}, init={:?})", pat, init);
let blk_scope = visitor.cx.var_parent.map(|(p, _)| p);
@ -1130,8 +1135,8 @@ fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
fn record_rvalue_scope_if_borrow_expr<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr,
blk_id: Option<Scope>)
{
blk_id: Option<Scope>,
) {
match expr.node {
hir::ExprKind::AddrOf(_, ref subexpr) => {
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
@ -1178,9 +1183,11 @@ fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
/// | <rvalue>
///
/// Note: ET is intended to match "rvalues or places based on rvalues".
fn record_rvalue_scope<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr,
blk_scope: Option<Scope>) {
fn record_rvalue_scope<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr,
blk_scope: Option<Scope>,
) {
let mut expr = expr;
loop {
// Note: give all the expressions matching `ET` with the
@ -1327,9 +1334,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
}
}
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId)
-> &'tcx ScopeTree
{
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ScopeTree {
let closure_base_def_id = tcx.closure_base_def_id(def_id);
if closure_base_def_id != def_id {
return tcx.region_scope_tree(closure_base_def_id);

View file

@ -368,10 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// entire crate. You should not read the result of this query
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
/// etc.
fn resolve_lifetimes<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
for_krate: CrateNum,
) -> &'tcx ResolveLifetimes {
fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes {
assert_eq!(for_krate, LOCAL_CRATE);
let named_region_map = krate(tcx);
@ -1256,9 +1253,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
}
}
fn compute_object_lifetime_defaults(
tcx: TyCtxt<'_, '_>,
) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
let mut map = HirIdMap::default();
for item in tcx.hir().krate().items.values() {
match item.node {

View file

@ -452,7 +452,7 @@ impl<'tcx> Index<'tcx> {
AnnotationKind::Required,
|v| intravisit::walk_crate(v, krate));
}
return index
return index;
}
pub fn local_stability(&self, id: HirId) -> Option<&'tcx Stability> {
@ -924,7 +924,7 @@ fn unnecessary_stable_feature_lint<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
span: Span,
feature: Symbol,
since: Symbol
since: Symbol,
) {
tcx.lint_hir(lint::builtin::STABLE_FEATURES,
hir::CRATE_HIR_ID,

View file

@ -75,18 +75,15 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
}
impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
pub fn struct_error(&self,
pub fn struct_error(
&self,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str)
-> Result<DiagnosticBuilder<'tcx>, ErrorHandled>
{
message: &str,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
self.struct_generic(tcx, message, None)
}
pub fn report_as_error(&self,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str
) -> ErrorHandled {
pub fn report_as_error(&self, tcx: TyCtxtAt<'gcx, 'tcx>, message: &str) -> ErrorHandled {
let err = self.struct_error(tcx, message);
match err {
Ok(mut err) => {
@ -97,7 +94,8 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
}
}
pub fn report_as_lint(&self,
pub fn report_as_lint(
&self,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str,
lint_root: hir::HirId,
@ -172,10 +170,7 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
}
}
pub fn struct_error<'gcx, 'tcx>(
tcx: TyCtxtAt<'gcx, 'tcx>,
msg: &str,
) -> DiagnosticBuilder<'tcx> {
pub fn struct_error<'gcx, 'tcx>(tcx: TyCtxtAt<'gcx, 'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
}

View file

@ -142,12 +142,10 @@ pub struct AllocDecodingSession<'s> {
}
impl<'s> AllocDecodingSession<'s> {
// Decodes an AllocId in a thread-safe way.
pub fn decode_alloc_id<D>(&self,
decoder: &mut D)
-> Result<AllocId, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_alloc_id<D>(&self, decoder: &mut D) -> Result<AllocId, D::Error>
where
D: TyDecoder<'tcx>,
{
// Read the index of the allocation
let idx = decoder.read_u32()? as usize;

View file

@ -3158,7 +3158,7 @@ pub enum ClosureOutlivesSubject<'tcx> {
/*
* TypeFoldable implementations for MIR types
*/
*/
CloneTypeFoldableAndLiftImpls! {
BlockTailInfo,

View file

@ -87,9 +87,7 @@ impl<'tcx> MonoItem<'tcx> {
}
}
pub fn instantiation_mode(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> InstantiationMode {
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx, 'tcx>) -> InstantiationMode {
let inline_in_all_cgus =
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
tcx.sess.opts.optimize != OptLevel::No
@ -195,11 +193,12 @@ impl<'tcx> MonoItem<'tcx> {
}
};
fn to_string_internal<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
prefix: &str,
instance: Instance<'tcx>,
debug: bool)
-> String {
fn to_string_internal<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
prefix: &str,
instance: Instance<'tcx>,
debug: bool,
) -> String {
let mut result = String::with_capacity(32);
result.push_str(prefix);
let printer = DefPathBasedNames::new(tcx, false, false);
@ -369,17 +368,16 @@ impl<'tcx> CodegenUnit<'tcx> {
})
}
pub fn items_in_deterministic_order(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> Vec<(MonoItem<'tcx>,
(Linkage, Visibility))> {
pub fn items_in_deterministic_order(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
) -> Vec<(MonoItem<'tcx>, (Linkage, Visibility))> {
// The codegen tests rely on items being process in the same order as
// they appear in the file, so for local items, we sort by node_id first
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct ItemSortKey(Option<HirId>, SymbolName);
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
item: MonoItem<'tcx>) -> ItemSortKey {
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: MonoItem<'tcx>) -> ItemSortKey {
ItemSortKey(match item {
MonoItem::Fn(ref instance) => {
match instance.def {

View file

@ -33,8 +33,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
/// not carry a `Ty` for `T`.)
///
/// Note that the resulting type has not been normalized.
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx>
{
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx> {
let answer = match self.ty.sty {
ty::Adt(adt_def, substs) => {
let variant_def = match self.variant_index {
@ -57,10 +56,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
/// Convenience wrapper around `projection_ty_core` for
/// `PlaceElem`, where we can just use the `Ty` that is already
/// stored inline on field projection elems.
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>,
elem: &PlaceElem<'tcx>)
-> PlaceTy<'tcx>
{
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> {
self.projection_ty_core(tcx, elem, |_, _, ty| ty)
}
@ -73,10 +69,11 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
self,
tcx: TyCtxt<'gcx, 'tcx>,
elem: &ProjectionElem<V, T>,
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>)
-> PlaceTy<'tcx>
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>,
) -> PlaceTy<'tcx>
where
V: ::std::fmt::Debug, T: ::std::fmt::Debug
V: ::std::fmt::Debug,
T: ::std::fmt::Debug,
{
let answer = match *elem {
ProjectionElem::Deref => {
@ -122,7 +119,8 @@ BraceStructTypeFoldableImpl! {
impl<'tcx> Place<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx>
where D: HasLocalDecls<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match *self {
Place::Base(PlaceBase::Local(index)) =>
@ -142,7 +140,8 @@ pub enum RvalueInitializationState {
impl<'tcx> Rvalue<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match *self {
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
@ -223,7 +222,8 @@ impl<'tcx> Rvalue<'tcx> {
impl<'tcx> Operand<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match self {
&Operand::Copy(ref l) |
@ -234,10 +234,12 @@ impl<'tcx> Operand<'tcx> {
}
impl<'tcx> BinOp {
pub fn ty<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>)
-> Ty<'tcx> {
pub fn ty<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
) -> Ty<'tcx> {
// FIXME: handle SIMD correctly
match self {
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |

View file

@ -18,11 +18,10 @@ use crate::ty::fold::TypeFoldable;
/// that type check should guarantee to us that all nested
/// obligations *could be* resolved if we wanted to.
/// Assumes that this is run after the entire crate has been successfully type-checked.
pub fn codegen_fulfill_obligation<'tcx>(ty: TyCtxt<'tcx, 'tcx>,
(param_env, trait_ref):
(ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>))
-> Vtable<'tcx, ()>
{
pub fn codegen_fulfill_obligation<'tcx>(
ty: TyCtxt<'tcx, 'tcx>,
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
) -> Vtable<'tcx, ()> {
// Remove any references to regions; this helps improve caching.
let trait_ref = ty.erase_regions(&trait_ref);

View file

@ -183,10 +183,10 @@ fn overlap_within_probe(
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
}
pub fn trait_ref_is_knowable<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>)
-> Option<Conflict>
{
pub fn trait_ref_is_knowable<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> Option<Conflict> {
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Remote).is_ok() {
// A downstream or cousin crate is allowed to implement some
@ -229,9 +229,10 @@ pub fn trait_ref_is_knowable<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
}
}
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>)
-> bool {
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> bool {
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
}
@ -246,10 +247,10 @@ pub enum OrphanCheckErr<'tcx> {
///
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
/// 2. Some local type must appear in `Self`.
pub fn orphan_check<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId)
-> Result<(), OrphanCheckErr<'tcx>>
{
pub fn orphan_check<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
) -> Result<(), OrphanCheckErr<'tcx>> {
debug!("orphan_check({:?})", impl_def_id);
// We only except this routine to be invoked on implementations
@ -353,11 +354,11 @@ pub fn orphan_check<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
///
/// Note that this function is never called for types that have both type
/// parameters and inference variables.
fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_>,
trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate)
-> Result<(), OrphanCheckErr<'tcx>>
{
fn orphan_check_trait_ref<'tcx>(
tcx: TyCtxt<'_, '_>,
trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate,
) -> Result<(), OrphanCheckErr<'tcx>> {
debug!("orphan_check_trait_ref(trait_ref={:?}, in_crate={:?})",
trait_ref, in_crate);
@ -430,8 +431,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_>,
}
}
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate)
-> Vec<Ty<'tcx>> {
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<Ty<'tcx>> {
if ty_is_local_constructor(ty, in_crate) {
vec![]
} else if fundamental_ty(ty) {

View file

@ -1242,15 +1242,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err
}
fn report_closure_arg_mismatch(&self,
span: Span,
found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>)
-> DiagnosticBuilder<'tcx>
{
fn build_fn_sig_string<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: &ty::TraitRef<'tcx>) -> String {
fn report_closure_arg_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx> {
fn build_fn_sig_string<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: &ty::TraitRef<'tcx>,
) -> String {
let inputs = trait_ref.substs.type_at(1);
let sig = if let ty::Tuple(inputs) = inputs.sty {
tcx.mk_fn_sig(
@ -1447,10 +1449,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// Returns `true` if the trait predicate may apply for *some* assignment
/// to the type parameters.
fn predicate_can_apply(&self,
param_env: ty::ParamEnv<'tcx>,
pred: ty::PolyTraitRef<'tcx>)
-> bool {
fn predicate_can_apply(
&self,
param_env: ty::ParamEnv<'tcx>,
pred: ty::PolyTraitRef<'tcx>,
) -> bool {
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>

View file

@ -710,13 +710,13 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>(
}
}
fn do_normalize_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>)
-> Result<Vec<ty::Predicate<'tcx>>, ErrorReported>
{
fn do_normalize_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>,
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorReported> {
debug!(
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
predicates,
@ -795,12 +795,12 @@ fn do_normalize_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
// FIXME: this is gonna need to be removed ...
/// Normalizes the parameter environment, reporting errors if they occur.
pub fn normalize_param_env_or_error<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>)
-> ty::ParamEnv<'tcx>
{
pub fn normalize_param_env_or_error<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
) -> ty::ParamEnv<'tcx> {
// I'm not wild about reporting errors here; I'd prefer to
// have the errors get reported at a defined place (e.g.,
// during typeck). Instead I have all parameter
@ -936,10 +936,10 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
/// environment. If this returns false, then either normalize
/// encountered an error or one of the predicates did not hold. Used
/// when creating vtables to check for unsatisfiable methods.
fn normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
predicates: Vec<ty::Predicate<'tcx>>)
-> bool
{
fn normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
predicates: Vec<ty::Predicate<'tcx>>,
) -> bool {
debug!("normalize_and_test_predicates(predicates={:?})",
predicates);
@ -965,10 +965,10 @@ fn normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
result
}
fn substitute_normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
key: (DefId, SubstsRef<'tcx>))
-> bool
{
fn substitute_normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
key: (DefId, SubstsRef<'tcx>),
) -> bool {
debug!("substitute_normalize_and_test_predicates(key={:?})",
key);
@ -985,9 +985,8 @@ fn substitute_normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
fn vtable_methods<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> &'tcx [Option<(DefId, SubstsRef<'tcx>)>]
{
trait_ref: ty::PolyTraitRef<'tcx>,
) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
debug!("vtable_methods({:?})", trait_ref);
tcx.arena.alloc_from_iter(

View file

@ -84,7 +84,6 @@ pub enum MethodViolationCode {
}
impl<'tcx> TyCtxt<'tcx, 'tcx> {
/// Returns the object safety violations that affect
/// astconv -- currently, `Self` in supertraits. This is needed
/// because `object_safety_violations` can't be used during
@ -703,7 +702,6 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> {
}
}
pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
trait_def_id: DefId) -> bool {
pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId) -> bool {
tcx.object_safety_violations(trait_def_id).is_empty()
}

View file

@ -35,12 +35,13 @@ impl OnUnimplementedNote {
}
}
fn parse_error(tcx: TyCtxt<'_, '_>, span: Span,
message: &str,
label: &str,
note: Option<&str>)
-> ErrorReported
{
fn parse_error(
tcx: TyCtxt<'_, '_>,
span: Span,
message: &str,
label: &str,
note: Option<&str>,
) -> ErrorReported {
let mut diag = struct_span_err!(
tcx.sess, span, E0232, "{}", message);
diag.span_label(span, label);
@ -52,13 +53,13 @@ fn parse_error(tcx: TyCtxt<'_, '_>, span: Span,
}
impl<'gcx, 'tcx> OnUnimplementedDirective {
fn parse(tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
items: &[NestedMetaItem],
span: Span,
is_root: bool)
-> Result<Self, ErrorReported>
{
fn parse(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
items: &[NestedMetaItem],
span: Span,
is_root: bool,
) -> Result<Self, ErrorReported> {
let mut errored = false;
let mut item_iter = items.iter();
@ -132,12 +133,11 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
}
}
pub fn of_item(tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
impl_def_id: DefId)
-> Result<Option<Self>, ErrorReported>
{
pub fn of_item(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
impl_def_id: DefId,
) -> Result<Option<Self>, ErrorReported> {
let attrs = tcx.get_attrs(impl_def_id);
let attr = if let Some(item) = attr::find_by_name(&attrs, sym::rustc_on_unimplemented) {
@ -164,12 +164,12 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
result
}
pub fn evaluate(&self,
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
options: &[(Symbol, Option<String>)])
-> OnUnimplementedNote
{
pub fn evaluate(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
options: &[(Symbol, Option<String>)],
) -> OnUnimplementedNote {
let mut message = None;
let mut label = None;
let mut note = None;
@ -215,12 +215,12 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
}
impl<'gcx, 'tcx> OnUnimplementedFormatString {
fn try_parse(tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
from: LocalInternedString,
err_sp: Span)
-> Result<Self, ErrorReported>
{
fn try_parse(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
from: LocalInternedString,
err_sp: Span,
) -> Result<Self, ErrorReported> {
let result = OnUnimplementedFormatString(from);
result.verify(tcx, trait_def_id, err_sp)?;
Ok(result)

View file

@ -85,12 +85,7 @@ pub struct DropckOutlivesResult<'tcx> {
}
impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn report_overflows(
&self,
tcx: TyCtxt<'_, 'tcx>,
span: Span,
ty: Ty<'tcx>,
) {
pub fn report_overflows(&self, tcx: TyCtxt<'_, 'tcx>, span: Span, ty: Ty<'tcx>) {
if let Some(overflow_ty) = self.overflows.iter().next() {
let mut err = struct_span_err!(
tcx.sess,

View file

@ -149,10 +149,10 @@ pub fn find_associated_item<'tcx>(
/// Specialization is determined by the sets of types to which the impls apply;
/// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies
/// to.
pub(super) fn specializes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
(impl1_def_id, impl2_def_id): (DefId, DefId))
-> bool
{
pub(super) fn specializes<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
(impl1_def_id, impl2_def_id): (DefId, DefId),
) -> bool {
debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id);
// The feature gate should prevent introducing new specializations, but not

View file

@ -83,9 +83,7 @@ enum Inserted {
impl<'gcx, 'tcx> Children {
/// Insert an impl into this set of children without comparing to any existing impls.
fn insert_blindly(&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId) {
fn insert_blindly(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty);
@ -99,9 +97,7 @@ impl<'gcx, 'tcx> Children {
/// Removes an impl from this set of children. Used when replacing
/// an impl with a parent. The impl must be present in the list of
/// children already.
fn remove_existing(&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId) {
fn remove_existing(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
let vec: &mut Vec<DefId>;
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
@ -118,12 +114,12 @@ impl<'gcx, 'tcx> Children {
/// Attempt to insert an impl into this set of children, while comparing for
/// specialization relationships.
fn insert(&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
simplified_self: Option<SimplifiedType>)
-> Result<Inserted, OverlapError>
{
fn insert(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
simplified_self: Option<SimplifiedType>,
) -> Result<Inserted, OverlapError> {
let mut last_lint = None;
let mut replace_children = Vec::new();
@ -293,10 +289,11 @@ impl<'gcx, 'tcx> Graph {
/// Insert a local impl into the specialization graph. If an existing impl
/// conflicts with it (has overlap, but neither specializes the other),
/// information about the area of overlap is returned in the `Err`.
pub fn insert(&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId)
-> Result<Option<FutureCompatOverlapError>, OverlapError> {
pub fn insert(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
) -> Result<Option<FutureCompatOverlapError>, OverlapError> {
assert!(impl_def_id.is_local());
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
@ -386,10 +383,12 @@ impl<'gcx, 'tcx> Graph {
}
/// Insert cached metadata mapping from a child impl back to its parent.
pub fn record_impl_from_cstore(&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
parent: DefId,
child: DefId) {
pub fn record_impl_from_cstore(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
parent: DefId,
child: DefId,
) {
if self.parent.insert(child, parent).is_some() {
bug!("When recording an impl from the crate store, information about its parent \
was already present.");
@ -423,10 +422,7 @@ impl<'gcx, 'tcx> Node {
}
/// Iterate over the items defined directly by the given (impl or trait) node.
pub fn items(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
) -> ty::AssocItemsIterator<'gcx, 'tcx> {
pub fn items(&self, tcx: TyCtxt<'gcx, 'tcx>) -> ty::AssocItemsIterator<'gcx, 'tcx> {
tcx.associated_items(self.def_id())
}
@ -508,10 +504,11 @@ impl<'gcx, 'tcx> Ancestors<'gcx> {
/// Walk up the specialization ancestors of a given impl, starting with that
/// impl itself.
pub fn ancestors(tcx: TyCtxt<'tcx, '_>,
trait_def_id: DefId,
start_from_impl: DefId)
-> Ancestors<'tcx> {
pub fn ancestors(
tcx: TyCtxt<'tcx, '_>,
trait_def_id: DefId,
start_from_impl: DefId,
) -> Ancestors<'tcx> {
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
Ancestors {
trait_def_id,

View file

@ -12,9 +12,10 @@ use crate::util::nodemap::FxHashSet;
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
fn anonymize_predicate<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
pred: &ty::Predicate<'tcx>)
-> ty::Predicate<'tcx> {
fn anonymize_predicate<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
pred: &ty::Predicate<'tcx>,
) -> ty::Predicate<'tcx> {
match *pred {
ty::Predicate::Trait(ref data) =>
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
@ -95,26 +96,23 @@ pub struct Elaborator<'gcx, 'tcx> {
pub fn elaborate_trait_ref<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> Elaborator<'gcx, 'tcx>
{
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Elaborator<'gcx, 'tcx> {
elaborate_predicates(tcx, vec![trait_ref.to_predicate()])
}
pub fn elaborate_trait_refs<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Elaborator<'gcx, 'tcx>
{
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Elaborator<'gcx, 'tcx> {
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect();
elaborate_predicates(tcx, predicates)
}
pub fn elaborate_predicates<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
mut predicates: Vec<ty::Predicate<'tcx>>)
-> Elaborator<'gcx, 'tcx>
{
mut predicates: Vec<ty::Predicate<'tcx>>,
) -> Elaborator<'gcx, 'tcx> {
let mut visited = PredicateSet::new(tcx);
predicates.retain(|pred| visited.insert(pred));
Elaborator { stack: predicates, visited }
@ -256,15 +254,17 @@ impl Iterator for Elaborator<'gcx, 'tcx> {
pub type Supertraits<'gcx, 'tcx> = FilterToTraits<Elaborator<'gcx, 'tcx>>;
pub fn supertraits<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> Supertraits<'gcx, 'tcx> {
pub fn supertraits<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Supertraits<'gcx, 'tcx> {
elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
}
pub fn transitive_bounds<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Supertraits<'gcx, 'tcx> {
pub fn transitive_bounds<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Supertraits<'gcx, 'tcx> {
elaborate_trait_refs(tcx, bounds).filter_to_traits()
}
@ -339,7 +339,7 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
pub fn expand_trait_aliases<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>,
) -> TraitAliasExpander<'gcx, 'tcx> {
let items: Vec<_> = trait_refs
.into_iter()
@ -420,10 +420,10 @@ pub struct SupertraitDefIds<'gcx, 'tcx> {
visited: FxHashSet<DefId>,
}
pub fn supertrait_def_ids<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId)
-> SupertraitDefIds<'gcx, 'tcx>
{
pub fn supertrait_def_ids<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
) -> SupertraitDefIds<'gcx, 'tcx> {
SupertraitDefIds {
tcx,
stack: vec![trait_def_id],

View file

@ -20,7 +20,7 @@ use crate::mir::interpret::ConstValue;
/// important thing about the result is Ok/Err. Also, matching never
/// affects any type variables or unification state.
pub struct Match<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>
tcx: TyCtxt<'gcx, 'tcx>,
}
impl Match<'gcx, 'tcx> {

View file

@ -104,8 +104,11 @@ pub struct OverloadedDeref<'tcx> {
}
impl<'gcx, 'tcx> OverloadedDeref<'tcx> {
pub fn method_call(&self, tcx: TyCtxt<'gcx, 'tcx>, source: Ty<'tcx>)
-> (DefId, SubstsRef<'tcx>) {
pub fn method_call(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
source: Ty<'tcx>,
) -> (DefId, SubstsRef<'tcx>) {
let trait_def_id = match self.mutbl {
hir::MutImmutable => tcx.lang_items().deref_trait(),
hir::MutMutable => tcx.lang_items().deref_mut_trait()

View file

@ -132,25 +132,28 @@ pub trait TyDecoder<'tcx>: Decoder {
#[inline]
pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D
decoder: &mut D,
) -> Result<&'tcx T, D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_arena_allocable_slice<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D
decoder: &mut D,
) -> Result<&'tcx [T], D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
}
#[inline]
pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
let cnum = CrateNum::from_u32(u32::decode(decoder)?);
Ok(decoder.map_encoded_cnum_to_current(cnum))
@ -158,7 +161,8 @@ pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
#[inline]
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
// Handle shorthands first, if we have an usize > 0x80.
if decoder.positioned_at_shorthand() {
@ -176,9 +180,9 @@ pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
}
#[inline]
pub fn decode_predicates<D>(decoder: &mut D)
-> Result<ty::GenericPredicates<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_predicates<D>(decoder: &mut D) -> Result<ty::GenericPredicates<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(ty::GenericPredicates {
parent: Decodable::decode(decoder)?,
@ -201,7 +205,8 @@ pub fn decode_predicates<D>(decoder: &mut D)
#[inline]
pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
let tcx = decoder.tcx();
@ -210,33 +215,36 @@ pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
#[inline]
pub fn decode_region<D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_ty_slice<D>(decoder: &mut D)
-> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_ty_slice<D>(decoder: &mut D) -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
}
#[inline]
pub fn decode_adt_def<D>(decoder: &mut D)
-> Result<&'tcx ty::AdtDef, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_adt_def<D>(decoder: &mut D) -> Result<&'tcx ty::AdtDef, D::Error>
where
D: TyDecoder<'tcx>,
{
let def_id = DefId::decode(decoder)?;
Ok(decoder.tcx().adt_def(def_id))
}
#[inline]
pub fn decode_existential_predicate_slice<D>(decoder: &mut D)
-> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_existential_predicate_slice<D>(
decoder: &mut D,
) -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx()
@ -244,9 +252,9 @@ pub fn decode_existential_predicate_slice<D>(decoder: &mut D)
}
#[inline]
pub fn decode_canonical_var_infos<D>(decoder: &mut D)
-> Result<CanonicalVarInfos<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_canonical_var_infos<D>(decoder: &mut D) -> Result<CanonicalVarInfos<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
@ -256,17 +264,17 @@ pub fn decode_canonical_var_infos<D>(decoder: &mut D)
}
#[inline]
pub fn decode_const<D>(decoder: &mut D)
-> Result<&'tcx ty::Const<'tcx>, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_const<D>(decoder: &mut D) -> Result<&'tcx ty::Const<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_allocation<D>(decoder: &mut D)
-> Result<&'tcx Allocation, D::Error>
where D: TyDecoder<'tcx>,
pub fn decode_allocation<D>(decoder: &mut D) -> Result<&'tcx Allocation, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))
}

View file

@ -1678,10 +1678,7 @@ impl<'gcx> GlobalCtxt<'gcx> {
/// Call the closure with a local `TyCtxt` using the given arena.
/// `interners` is a slot passed so we can create a CtxtInterners
/// with the same lifetime as `arena`.
pub fn enter_local<'tcx, F, R>(
&'gcx self,
f: F
) -> R
pub fn enter_local<'tcx, F, R>(&'gcx self, f: F) -> R
where
F: FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
'gcx: 'tcx,
@ -1732,41 +1729,41 @@ pub trait Lift<'tcx>: fmt::Debug {
macro_rules! nop_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $lifted;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
type Lifted = $lifted;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
};
}
macro_rules! nop_list_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(List::empty());
type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(List::empty());
}
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
};
}
@ -1941,7 +1938,8 @@ pub mod tls {
/// This happens once per rustc session and TyCtxts only exists
/// inside the `f` function.
pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R
where F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R
where
F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R,
{
// Update GCX_PTR to indicate there's a GlobalCtxt available
GCX_PTR.with(|lock| {
@ -1978,7 +1976,8 @@ pub mod tls {
/// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local.
/// This is used in the deadlock handler.
pub unsafe fn with_global<F, R>(f: F) -> R
where F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R
where
F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
{
let gcx = GCX_PTR.with(|lock| *lock.lock());
assert!(gcx != 0);
@ -2031,7 +2030,8 @@ pub mod tls {
/// the current ImplicitCtxt's tcx field.
#[inline]
pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'gcx, 'tcx1>, f: F) -> R
where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R
where
F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R,
{
with_context(|context| {
unsafe {
@ -2049,7 +2049,8 @@ pub mod tls {
/// a different local interner from the current ImplicitCtxt's tcx field.
#[inline]
pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'gcx, 'tcx>, f: F) -> R
where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R
where
F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R,
{
with_context(|context| {
unsafe {
@ -2065,7 +2066,8 @@ pub mod tls {
/// Panics if there is no ImplicitCtxt available
#[inline]
pub fn with<F, R>(f: F) -> R
where F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R
where
F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
{
with_context(|context| f(context.tcx))
}
@ -2074,7 +2076,8 @@ pub mod tls {
/// The closure is passed None if there is no ImplicitCtxt available
#[inline]
pub fn with_opt<F, R>(f: F) -> R
where F: for<'gcx, 'tcx> FnOnce(Option<TyCtxt<'gcx, 'tcx>>) -> R
where
F: for<'gcx, 'tcx> FnOnce(Option<TyCtxt<'gcx, 'tcx>>) -> R,
{
with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx)))
}

View file

@ -55,11 +55,11 @@ pub enum SimplifiedTypeGen<D>
/// then we can't say much about whether two types would unify. Put another way,
/// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they
/// are to be considered bound.
pub fn simplify_type<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
ty: Ty<'_>,
can_simplify_params: bool)
-> Option<SimplifiedType>
{
pub fn simplify_type<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
ty: Ty<'_>,
can_simplify_params: bool,
) -> Option<SimplifiedType> {
match ty.sty {
ty::Bool => Some(BoolSimplifiedType),
ty::Char => Some(CharSimplifiedType),

View file

@ -155,7 +155,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
/// default implementation that does an "identity" fold. Within each
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
/// sub-item.
pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized {
pub trait TypeFolder<'gcx: 'tcx, 'tcx>: Sized {
fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>;
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
@ -199,9 +199,10 @@ pub trait TypeVisitor<'tcx> : Sized {
// Some sample folders
pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
where
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{
pub tcx: TyCtxt<'gcx, 'tcx>,
pub ty_op: F,
@ -210,11 +211,14 @@ pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
}
impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
where
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
let t = ty.super_fold_with(self);
@ -361,7 +365,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// visited by this folder; only regions that occur free will be
/// visited by `fld_r`.
pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
pub struct RegionFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'gcx, 'tcx>,
skipped_regions: &'a mut bool,
@ -373,10 +377,8 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
/// Callback invokes for each free region. The `DebruijnIndex`
/// points to the binder *just outside* the ones we have passed
/// through.
fold_region_fn: &'a mut (dyn FnMut(
ty::Region<'tcx>,
ty::DebruijnIndex,
) -> ty::Region<'tcx> + 'a),
fold_region_fn:
&'a mut (dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx> + 'a),
}
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
@ -396,7 +398,9 @@ impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
}
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -445,9 +449,10 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
fld_t: &'a mut G,
fld_c: &'a mut H,
) -> Self
where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
where
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
{
BoundVarReplacer {
tcx,
@ -460,7 +465,9 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
}
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -741,7 +748,9 @@ impl Shifter<'gcx, 'tcx> {
}
impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -820,7 +829,7 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
pub fn shift_region<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
region: ty::Region<'tcx>,
amount: u32
amount: u32,
) -> ty::Region<'tcx> {
match region {
ty::ReLateBound(debruijn, br) if amount > 0 => {
@ -832,22 +841,20 @@ pub fn shift_region<'gcx, 'tcx>(
}
}
pub fn shift_vars<'gcx, 'tcx, T>(
tcx: TyCtxt<'gcx, 'tcx>,
value: &T,
amount: u32
) -> T where T: TypeFoldable<'tcx> {
pub fn shift_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("shift_vars(value={:?}, amount={})",
value, amount);
value.fold_with(&mut Shifter::new(tcx, amount, Direction::In))
}
pub fn shift_out_vars<'gcx, 'tcx, T>(
tcx: TyCtxt<'gcx, 'tcx>,
value: &T,
amount: u32
) -> T where T: TypeFoldable<'tcx> {
pub fn shift_out_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("shift_out_vars(value={:?}, amount={})",
value, amount);

View file

@ -52,17 +52,14 @@ impl<'gcx, 'tcx> DefIdForest {
}
/// Tests whether the forest contains a given DefId.
pub fn contains(&self,
tcx: TyCtxt<'gcx, 'tcx>,
id: DefId) -> bool
{
pub fn contains(&self, tcx: TyCtxt<'gcx, 'tcx>, id: DefId) -> bool {
self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id))
}
/// Calculate the intersection of a collection of forests.
pub fn intersection<I>(tcx: TyCtxt<'gcx, 'tcx>,
iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest>
pub fn intersection<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
where
I: IntoIterator<Item = DefIdForest>,
{
let mut iter = iter.into_iter();
let mut ret = if let Some(first) = iter.next() {
@ -97,9 +94,9 @@ impl<'gcx, 'tcx> DefIdForest {
}
/// Calculate the union of a collection of forests.
pub fn union<I>(tcx: TyCtxt<'gcx, 'tcx>,
iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest>
pub fn union<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
where
I: IntoIterator<Item = DefIdForest>,
{
let mut ret = DefIdForest::empty();
let mut next_ret = SmallVec::new();

View file

@ -108,11 +108,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
impl<'gcx, 'tcx> AdtDef {
/// Calculate the forest of DefIds from which this adt is visibly uninhabited.
fn uninhabited_from(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>) -> DefIdForest
{
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest {
// Non-exhaustive ADTs from other crates are always considered inhabited.
if self.is_variant_list_non_exhaustive() && !self.did.is_local() {
DefIdForest::empty()
@ -130,8 +126,8 @@ impl<'gcx, 'tcx> VariantDef {
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind) -> DefIdForest
{
adt_kind: AdtKind,
) -> DefIdForest {
let is_enum = match adt_kind {
// For now, `union`s are never considered uninhabited.
// The precise semantics of inhabitedness with respect to unions is currently undecided.
@ -182,8 +178,7 @@ impl<'gcx, 'tcx> FieldDef {
impl<'gcx, 'tcx> TyS<'tcx> {
/// Calculate the forest of DefIds from which this type is visibly uninhabited.
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest
{
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest {
match self.sty {
Adt(def, substs) => def.uninhabited_from(tcx, substs),

View file

@ -43,10 +43,7 @@ pub enum InstanceDef<'tcx> {
}
impl<'tcx> Instance<'tcx> {
pub fn ty(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> Ty<'tcx>
{
pub fn ty(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> {
let ty = tcx.type_of(self.def.def_id());
tcx.subst_and_normalize_erasing_regions(
self.substs,
@ -140,10 +137,7 @@ impl<'tcx> InstanceDef<'tcx> {
tcx.get_attrs(self.def_id())
}
pub fn is_inline(
&self,
tcx: TyCtxt<'tcx, 'tcx>
) -> bool {
pub fn is_inline(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
use crate::hir::map::DefPathData;
let def_id = match *self {
ty::InstanceDef::Item(def_id) => def_id,
@ -156,10 +150,7 @@ impl<'tcx> InstanceDef<'tcx> {
}
}
pub fn requires_local(
&self,
tcx: TyCtxt<'tcx, 'tcx>
) -> bool {
pub fn requires_local(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
if self.is_inline(tcx) {
return true
}
@ -245,10 +236,12 @@ impl<'b, 'tcx> Instance<'tcx> {
/// Presuming that coherence and type-check have succeeded, if this method is invoked
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return
/// `Some`.
pub fn resolve(tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
pub fn resolve(
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>,
) -> Option<Instance<'tcx>> {
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
@ -297,10 +290,12 @@ impl<'b, 'tcx> Instance<'tcx> {
result
}
pub fn resolve_for_vtable(tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
pub fn resolve_for_vtable(
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>,
) -> Option<Instance<'tcx>> {
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
let fn_sig = tcx.fn_sig(def_id);
let is_vtable_shim =
@ -320,9 +315,8 @@ impl<'b, 'tcx> Instance<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId,
substs: ty::ClosureSubsts<'tcx>,
requested_kind: ty::ClosureKind)
-> Instance<'tcx>
{
requested_kind: ty::ClosureKind,
) -> Instance<'tcx> {
let actual_kind = substs.closure_kind(def_id, tcx);
match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
@ -331,11 +325,7 @@ impl<'b, 'tcx> Instance<'tcx> {
}
}
pub fn resolve_drop_in_place(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>)
-> ty::Instance<'tcx>
{
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
let substs = tcx.intern_substs(&[ty.into()]);
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
@ -344,9 +334,8 @@ impl<'b, 'tcx> Instance<'tcx> {
pub fn fn_once_adapter_instance(
tcx: TyCtxt<'tcx, 'tcx>,
closure_did: DefId,
substs: ty::ClosureSubsts<'tcx>)
-> Instance<'tcx>
{
substs: ty::ClosureSubsts<'tcx>,
) -> Instance<'tcx> {
debug!("fn_once_adapter_shim({:?}, {:?})",
closure_did,
substs);

View file

@ -28,17 +28,16 @@ use rustc_target::abi::call::{
ArgAttribute, ArgAttributes, ArgType, Conv, FnType, IgnoreMode, PassMode, Reg, RegKind
};
pub trait IntegerExt {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer;
fn repr_discr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128)
-> (Integer, bool);
fn repr_discr<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128,
) -> (Integer, bool);
}
impl IntegerExt for Integer {
@ -77,12 +76,13 @@ impl IntegerExt for Integer {
/// signed discriminant range and #[repr] attribute.
/// N.B.: u128 values above i128::MAX will be treated as signed, but
/// that shouldn't affect anything, other than maybe debuginfo.
fn repr_discr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128)
-> (Integer, bool) {
fn repr_discr<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128,
) -> (Integer, bool) {
// Theoretically, negative values could be larger in unsigned representation
// than the unsigned representation of the signed minimum. However, if there
// are any negative values, the only valid unsigned representation is u128
@ -171,10 +171,10 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
}
}
fn layout_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> Result<&'tcx LayoutDetails, LayoutError<'tcx>>
{
fn layout_raw<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
ty::tls::with_related_context(tcx, move |icx| {
let rec_limit = *tcx.sess.recursion_limit.get();
let (param_env, ty) = query.into_parts();
@ -1604,10 +1604,11 @@ pub enum SizeSkeleton<'tcx> {
}
impl<'tcx> SizeSkeleton<'tcx> {
pub fn compute(ty: Ty<'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>)
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
pub fn compute(
ty: Ty<'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
debug_assert!(!ty.has_infer_types());
// First try computing a static layout.

View file

@ -957,11 +957,11 @@ impl<'gcx, 'tcx> Generics {
false
}
pub fn region_param(&'tcx self,
param: &EarlyBoundRegion,
tcx: TyCtxt<'gcx, 'tcx>)
-> &'tcx GenericParamDef
{
pub fn region_param(
&'tcx self,
param: &EarlyBoundRegion,
tcx: TyCtxt<'gcx, 'tcx>,
) -> &'tcx GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize];
match param.kind {
@ -975,10 +975,11 @@ impl<'gcx, 'tcx> Generics {
}
/// Returns the `GenericParamDef` associated with this `ParamTy`.
pub fn type_param(&'tcx self,
param: &ParamTy,
tcx: TyCtxt<'gcx, 'tcx>)
-> &'tcx GenericParamDef {
pub fn type_param(
&'tcx self,
param: &ParamTy,
tcx: TyCtxt<'gcx, 'tcx>,
) -> &'tcx GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize];
match param.kind {
@ -992,10 +993,11 @@ impl<'gcx, 'tcx> Generics {
}
/// Returns the `ConstParameterDef` associated with this `ParamConst`.
pub fn const_param(&'tcx self,
param: &ParamConst,
tcx: TyCtxt<'gcx, 'tcx>)
-> &GenericParamDef {
pub fn const_param(
&'tcx self,
param: &ParamConst,
tcx: TyCtxt<'gcx, 'tcx>,
) -> &GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize];
match param.kind {
@ -1020,23 +1022,32 @@ impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
impl<'gcx, 'tcx> GenericPredicates<'tcx> {
pub fn instantiate(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>)
-> InstantiatedPredicates<'tcx> {
pub fn instantiate(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>,
) -> InstantiatedPredicates<'tcx> {
let mut instantiated = InstantiatedPredicates::empty();
self.instantiate_into(tcx, &mut instantiated, substs);
instantiated
}
pub fn instantiate_own(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>)
-> InstantiatedPredicates<'tcx> {
pub fn instantiate_own(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>,
) -> InstantiatedPredicates<'tcx> {
InstantiatedPredicates {
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
}
}
fn instantiate_into(&self, tcx: TyCtxt<'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>,
substs: SubstsRef<'tcx>) {
fn instantiate_into(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>,
substs: SubstsRef<'tcx>,
) {
if let Some(def_id) = self.parent {
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
}
@ -1045,25 +1056,28 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> {
);
}
pub fn instantiate_identity(&self, tcx: TyCtxt<'gcx, 'tcx>)
-> InstantiatedPredicates<'tcx> {
pub fn instantiate_identity(&self, tcx: TyCtxt<'gcx, 'tcx>) -> InstantiatedPredicates<'tcx> {
let mut instantiated = InstantiatedPredicates::empty();
self.instantiate_identity_into(tcx, &mut instantiated);
instantiated
}
fn instantiate_identity_into(&self, tcx: TyCtxt<'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>) {
fn instantiate_identity_into(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>,
) {
if let Some(def_id) = self.parent {
tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated);
}
instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p))
}
pub fn instantiate_supertrait(&self, tcx: TyCtxt<'gcx, 'tcx>,
poly_trait_ref: &ty::PolyTraitRef<'tcx>)
-> InstantiatedPredicates<'tcx>
{
pub fn instantiate_supertrait(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
poly_trait_ref: &ty::PolyTraitRef<'tcx>,
) -> InstantiatedPredicates<'tcx> {
assert_eq!(self.parent, None);
InstantiatedPredicates {
predicates: self.predicates.iter().map(|(pred, _)| {
@ -1134,10 +1148,11 @@ impl<'gcx, 'tcx> Predicate<'tcx> {
/// poly-trait-ref holds. This is slightly different from a normal
/// substitution in terms of what happens with bound regions. See
/// lengthy comment below for details.
pub fn subst_supertrait(&self, tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: &ty::PolyTraitRef<'tcx>)
-> ty::Predicate<'tcx>
{
pub fn subst_supertrait(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: &ty::PolyTraitRef<'tcx>,
) -> ty::Predicate<'tcx> {
// The interaction between HRTB and supertraits is not entirely
// obvious. Let me walk you (and myself) through an example.
//
@ -2140,7 +2155,6 @@ impl ReprOptions {
pub fn inhibit_union_abi_opt(&self) -> bool {
self.c()
}
}
impl<'gcx, 'tcx> AdtDef {
@ -2150,7 +2164,7 @@ impl<'gcx, 'tcx> AdtDef {
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, VariantDef>,
repr: ReprOptions
repr: ReprOptions,
) -> Self {
debug!("AdtDef::new({:?}, {:?}, {:?}, {:?})", did, kind, variants, repr);
let mut flags = AdtFlags::NO_ADT_FLAGS;
@ -2427,10 +2441,11 @@ impl<'gcx, 'tcx> AdtDef {
/// discriminant (the last one before the requested variant),
/// assuming there are no constant-evaluation errors there.
#[inline]
pub fn discriminant_for_variant(&self,
tcx: TyCtxt<'gcx, 'tcx>,
variant_index: VariantIdx)
-> Discr<'tcx> {
pub fn discriminant_for_variant(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
variant_index: VariantIdx,
) -> Discr<'tcx> {
let (val, offset) = self.discriminant_def_for_variant(variant_index);
let explicit_value = val
.and_then(|expr_did| self.eval_explicit_discr(tcx, expr_did))
@ -2483,10 +2498,7 @@ impl<'gcx, 'tcx> AdtDef {
tcx.adt_sized_constraint(self.did).0
}
fn sized_constraint_for_ty(&self,
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>)
-> Vec<Ty<'tcx>> {
fn sized_constraint_for_ty(&self, tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
let result = match ty.sty {
Bool | Char | Int(..) | Uint(..) | Float(..) |
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
@ -2763,9 +2775,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Returns an iterator of the `DefId`s for all body-owners in this
/// crate. If you would prefer to iterate over the bodies
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
pub fn body_owners(
self,
) -> impl Iterator<Item = DefId> + Captures<'gcx> + 'tcx {
pub fn body_owners(self) -> impl Iterator<Item = DefId> + Captures<'gcx> + 'tcx {
self.hir().krate()
.body_ids
.iter()
@ -2889,10 +2899,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
})
}
pub fn associated_items(
self,
def_id: DefId,
) -> AssocItemsIterator<'gcx, 'tcx> {
pub fn associated_items(self, def_id: DefId) -> AssocItemsIterator<'gcx, 'tcx> {
// Ideally, we would use `-> impl Iterator` here, but it falls
// afoul of the conservative "capture [restrictions]" we put
// in place, so we use a hand-written iterator.
@ -3176,9 +3183,7 @@ pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]);
/// such.
/// - a Error, if a type contained itself. The representability
/// check should catch this case.
fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> AdtSizedConstraint<'tcx> {
fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> AdtSizedConstraint<'tcx> {
let def = tcx.adt_def(def_id);
let result = tcx.mk_type_list(def.variants.iter().flat_map(|v| {
@ -3192,9 +3197,7 @@ fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
AdtSizedConstraint(result)
}
fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> &'tcx [DefId] {
fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx [DefId] {
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let item = tcx.hir().expect_item_by_hir_id(id);
match item.node {
@ -3247,10 +3250,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Option<DefId> {
}
/// See `ParamEnv` struct definition for details.
fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> ParamEnv<'tcx>
{
fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> {
// The param_env of an impl Trait type is its defining function's param_env
if let Some(parent) = is_impl_trait_defn(tcx, def_id) {
return param_env(tcx, parent);
@ -3285,28 +3285,25 @@ fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
}
fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
crate_num: CrateNum) -> CrateDisambiguator {
fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> CrateDisambiguator {
assert_eq!(crate_num, LOCAL_CRATE);
tcx.sess.local_crate_disambiguator()
}
fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
crate_num: CrateNum) -> Symbol {
fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Symbol {
assert_eq!(crate_num, LOCAL_CRATE);
tcx.crate_name.clone()
}
fn crate_hash<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
crate_num: CrateNum)
-> Svh {
fn crate_hash<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Svh {
assert_eq!(crate_num, LOCAL_CRATE);
tcx.hir().crate_hash
}
fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
instance_def: InstanceDef<'tcx>)
-> usize {
fn instance_def_size_estimate<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
instance_def: InstanceDef<'tcx>,
) -> usize {
match instance_def {
InstanceDef::Item(..) |
InstanceDef::DropGlue(..) => {
@ -3321,10 +3318,7 @@ fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
///
/// See [`ImplOverlapKind::Issue33140`] for more details.
fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> Option<Ty<'tcx>>
{
fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option<Ty<'tcx>> {
debug!("issue33140_self_ty({:?})", def_id);
let trait_ref = tcx.impl_trait_ref(def_id).unwrap_or_else(|| {

View file

@ -54,14 +54,12 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
false
}
fn try_load_from_disk(_: TyCtxt<'tcx, 'tcx>,
_: SerializedDepNodeIndex)
-> Option<Self::Value> {
fn try_load_from_disk(_: TyCtxt<'tcx, 'tcx>, _: SerializedDepNodeIndex) -> Option<Self::Value> {
bug!("QueryDescription::load_from_disk() called for an unsupported query.")
}
}
impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M {
impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M {
default fn describe(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Cow<'static, str> {
if !tcx.sess.verbose() {
format!("processing `{}`", tcx.def_path_str(def_id)).into()

View file

@ -340,7 +340,7 @@ fn connected_to_root<'tcx>(
fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc<QueryJob<'tcx>>)>(
tcx: TyCtxt<'tcx, '_>,
queries: &'a [T],
f: F
f: F,
) -> &'a T {
// Deterministically pick an entry point
// FIXME: Sort this instead
@ -366,7 +366,7 @@ fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc<QueryJob<'tcx>>)>(
fn remove_cycle<'tcx>(
jobs: &mut Vec<Lrc<QueryJob<'tcx>>>,
wakelist: &mut Vec<Lrc<QueryWaiter<'tcx>>>,
tcx: TyCtxt<'tcx, '_>
tcx: TyCtxt<'tcx, '_>,
) -> bool {
let mut visited = FxHashSet::default();
let mut stack = Vec::new();

View file

@ -136,7 +136,7 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
}
}
impl<'tcx> Key for ty::PolyTraitRef<'tcx>{
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
fn query_crate(&self) -> CrateNum {
self.def_id().krate
}

View file

@ -156,12 +156,14 @@ impl<'sess> OnDiskCache<'sess> {
}
}
pub fn serialize<'tcx, E>(&self,
tcx: TyCtxt<'tcx, 'tcx>,
encoder: &mut E)
-> Result<(), E::Error>
where E: ty_codec::TyEncoder
{
pub fn serialize<'tcx, E>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
encoder: &mut E,
) -> Result<(), E::Error>
where
E: ty_codec::TyEncoder,
{
// Serializing the DepGraph should not modify it:
tcx.dep_graph.with_ignore(|| {
// Allocate SourceFileIndices
@ -326,10 +328,11 @@ impl<'sess> OnDiskCache<'sess> {
}
/// Loads a diagnostic emitted during the previous compilation session.
pub fn load_diagnostics<'tcx>(&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex)
-> Vec<Diagnostic> {
pub fn load_diagnostics<'tcx>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex,
) -> Vec<Diagnostic> {
let diagnostics: Option<EncodedDiagnostics> = self.load_indexed(
tcx,
dep_node_index,
@ -354,11 +357,13 @@ impl<'sess> OnDiskCache<'sess> {
/// Returns the cached query result if there is something in the cache for
/// the given `SerializedDepNodeIndex`; otherwise returns `None`.
pub fn try_load_query_result<'tcx, T>(&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex)
-> Option<T>
where T: Decodable
pub fn try_load_query_result<'tcx, T>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex,
) -> Option<T>
where
T: Decodable,
{
self.load_indexed(tcx,
dep_node_index,
@ -382,14 +387,15 @@ impl<'sess> OnDiskCache<'sess> {
x.extend(Into::<Vec<_>>::into(diagnostics));
}
fn load_indexed<'tcx, T>(&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex,
index: &FxHashMap<SerializedDepNodeIndex,
AbsoluteBytePos>,
debug_tag: &'static str)
-> Option<T>
where T: Decodable
fn load_indexed<'tcx, T>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex,
index: &FxHashMap<SerializedDepNodeIndex, AbsoluteBytePos>,
debug_tag: &'static str,
) -> Option<T>
where
T: Decodable,
{
let pos = index.get(&dep_node_index).cloned()?;
@ -423,10 +429,10 @@ impl<'sess> OnDiskCache<'sess> {
// current-session-CrateNum. There might be CrateNums from the previous
// Session that don't occur in the current one. For these, the mapping
// maps to None.
fn compute_cnum_map(tcx: TyCtxt<'_, '_>,
prev_cnums: &[(u32, String, CrateDisambiguator)])
-> IndexVec<CrateNum, Option<CrateNum>>
{
fn compute_cnum_map(
tcx: TyCtxt<'_, '_>,
prev_cnums: &[(u32, String, CrateDisambiguator)],
) -> IndexVec<CrateNum, Option<CrateNum>> {
tcx.dep_graph.with_ignore(|| {
let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| {
let crate_name = tcx.original_crate_name(cnum)
@ -524,7 +530,6 @@ fn decode_tagged<'a, 'tcx, D, T, V>(decoder: &mut D,
Ok(value)
}
impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
#[inline]
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
@ -583,7 +588,7 @@ impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
}
}
implement_ty_decoder!( CacheDecoder<'a, 'tcx> );
implement_ty_decoder!(CacheDecoder<'a, 'tcx>);
impl<'a, 'tcx> SpecializedDecoder<interpret::AllocId> for CacheDecoder<'a, 'tcx> {
fn specialized_decode(&mut self) -> Result<interpret::AllocId, Self::Error> {
@ -724,7 +729,8 @@ impl<'a, 'tcx> SpecializedDecoder<Fingerprint> for CacheDecoder<'a, 'tcx> {
}
impl<'a, 'tcx, T: Decodable> SpecializedDecoder<mir::ClearCrossCrate<T>>
for CacheDecoder<'a, 'tcx> {
for CacheDecoder<'a, 'tcx>
{
#[inline]
fn specialized_decode(&mut self) -> Result<mir::ClearCrossCrate<T>, Self::Error> {
let discr = u8::decode(self)?;
@ -757,7 +763,8 @@ struct CacheEncoder<'a, 'tcx, E: ty_codec::TyEncoder> {
}
impl<'a, 'tcx, E> CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
self.file_to_file_index[&(&*source_file as *const SourceFile)]
@ -784,7 +791,8 @@ impl<'a, 'tcx, E> CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> SpecializedEncoder<interpret::AllocId> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
fn specialized_encode(&mut self, alloc_id: &interpret::AllocId) -> Result<(), Self::Error> {
use std::collections::hash_map::Entry;
@ -803,7 +811,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<interpret::AllocId> for CacheEncoder<'a, 't
}
impl<'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
fn specialized_encode(&mut self, span: &Span) -> Result<(), Self::Error> {
@ -859,7 +868,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn position(&self) -> usize {
@ -868,7 +878,8 @@ impl<'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, cnum: &CrateNum) -> Result<(), Self::Error> {
@ -877,7 +888,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> SpecializedEncoder<Ty<'tcx>> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, ty: &Ty<'tcx>) -> Result<(), Self::Error> {
@ -886,9 +898,9 @@ impl<'a, 'tcx, E> SpecializedEncoder<Ty<'tcx>> for CacheEncoder<'a, 'tcx, E>
}
}
impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>> for CacheEncoder<'a, 'tcx, E>
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self,
@ -900,7 +912,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
}
impl<'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, id: &hir::HirId) -> Result<(), Self::Error> {
@ -916,9 +929,9 @@ impl<'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'a, 'tcx, E>
}
}
impl<'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, id: &DefId) -> Result<(), Self::Error> {
@ -928,7 +941,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, id: &LocalDefId) -> Result<(), Self::Error> {
@ -937,7 +951,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'a, 'tcx, E>
}
impl<'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
fn specialized_encode(&mut self, _: &DefIndex) -> Result<(), Self::Error> {
bug!("Encoding DefIndex without context.")
@ -947,7 +962,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'a, 'tcx, E>
// NodeIds are not stable across compilation sessions, so we store them in their
// HirId representation. This allows use to map them to the current NodeId.
impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
#[inline]
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
@ -956,18 +972,16 @@ impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
}
}
impl<'a, 'tcx> SpecializedEncoder<Fingerprint>
for CacheEncoder<'a, 'tcx, opaque::Encoder>
{
impl<'a, 'tcx> SpecializedEncoder<Fingerprint> for CacheEncoder<'a, 'tcx, opaque::Encoder> {
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
f.encode_opaque(&mut self.encoder)
}
}
impl<'a, 'tcx, E, T> SpecializedEncoder<mir::ClearCrossCrate<T>>
for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder,
T: Encodable,
impl<'a, 'tcx, E, T> SpecializedEncoder<mir::ClearCrossCrate<T>> for CacheEncoder<'a, 'tcx, E>
where
E: 'a + ty_codec::TyEncoder,
T: Encodable,
{
#[inline]
fn specialized_encode(&mut self,
@ -994,7 +1008,8 @@ macro_rules! encoder_methods {
}
impl<'a, 'tcx, E> Encoder for CacheEncoder<'a, 'tcx, E>
where E: 'a + ty_codec::TyEncoder
where
E: 'a + ty_codec::TyEncoder,
{
type Error = E::Error;
@ -1064,13 +1079,15 @@ impl<'a> SpecializedDecoder<IntEncodedWithFixedSize> for opaque::Decoder<'a> {
}
}
fn encode_query_results<'a, 'tcx, Q, E>(tcx: TyCtxt<'tcx, 'tcx>,
encoder: &mut CacheEncoder<'a, 'tcx, E>,
query_result_index: &mut EncodedQueryResultIndex)
-> Result<(), E::Error>
where Q: super::config::QueryDescription<'tcx>,
E: 'a + TyEncoder,
Q::Value: Encodable,
fn encode_query_results<'a, 'tcx, Q, E>(
tcx: TyCtxt<'tcx, 'tcx>,
encoder: &mut CacheEncoder<'a, 'tcx, E>,
query_result_index: &mut EncodedQueryResultIndex,
) -> Result<(), E::Error>
where
Q: super::config::QueryDescription<'tcx>,
E: 'a + TyEncoder,
Q::Value: Encodable,
{
let desc = &format!("encode_query_results for {}",
unsafe { ::std::intrinsics::type_name::<Q>() });

View file

@ -256,10 +256,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
self,
job: Lrc<QueryJob<'gcx>>,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: F)
-> R
compute: F,
) -> R
where
F: for<'lcx> FnOnce(TyCtxt<'gcx, 'lcx>) -> R
F: for<'lcx> FnOnce(TyCtxt<'gcx, 'lcx>) -> R,
{
// The TyCtxt stored in TLS has the same global interner lifetime
// as `self`, so we use `with_related_context` to relate the 'gcx lifetimes
@ -285,9 +285,8 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
#[cold]
pub(super) fn report_cycle(
self,
CycleError { usage, cycle: stack }: CycleError<'gcx>
) -> DiagnosticBuilder<'tcx>
{
CycleError { usage, cycle: stack }: CycleError<'gcx>,
) -> DiagnosticBuilder<'tcx> {
assert!(!stack.is_empty());
let fix_span = |span: Span, query: &Query<'gcx>| {
@ -1148,10 +1147,7 @@ macro_rules! define_provider_struct {
/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
/// add it to the "We don't have enough information to reconstruct..." group in
/// the match below.
pub fn force_from_dep_node<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
dep_node: &DepNode
) -> bool {
pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> bool {
use crate::dep_graph::RecoverKey;
// We must avoid ever having to call force_from_dep_node() for a

View file

@ -22,7 +22,7 @@ pub enum Cause {
ExistentialRegionBound, // relating an existential region bound
}
pub trait TypeRelation<'gcx: 'tcx, 'tcx> : Sized {
pub trait TypeRelation<'gcx: 'tcx, 'tcx>: Sized {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx>;
/// Returns a static string we can use for printouts.
@ -94,20 +94,26 @@ pub trait TypeRelation<'gcx: 'tcx, 'tcx> : Sized {
}
pub trait Relate<'tcx>: TypeFoldable<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self)
-> RelateResult<'tcx, Self>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a;
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a;
}
///////////////////////////////////////////////////////////////////////////
// Relate impls
impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::TypeAndMut<'tcx>,
b: &ty::TypeAndMut<'tcx>)
-> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::TypeAndMut<'tcx>,
b: &ty::TypeAndMut<'tcx>,
) -> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
debug!("{}.mts({:?}, {:?})",
relation.tag(),
@ -127,12 +133,16 @@ impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> {
}
}
pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
variances: Option<&[ty::Variance]>,
a_subst: SubstsRef<'tcx>,
b_subst: SubstsRef<'tcx>)
-> RelateResult<'tcx, SubstsRef<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
pub fn relate_substs<'a, 'gcx, 'tcx, R>(
relation: &mut R,
variances: Option<&[ty::Variance]>,
a_subst: SubstsRef<'tcx>,
b_subst: SubstsRef<'tcx>,
) -> RelateResult<'tcx, SubstsRef<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let tcx = relation.tcx();
@ -145,11 +155,15 @@ pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
}
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::FnSig<'tcx>,
b: &ty::FnSig<'tcx>)
-> RelateResult<'tcx, ty::FnSig<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::FnSig<'tcx>,
b: &ty::FnSig<'tcx>,
) -> RelateResult<'tcx, ty::FnSig<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let tcx = relation.tcx();
@ -185,11 +199,15 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
}
impl<'tcx> Relate<'tcx> for ast::Unsafety {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ast::Unsafety,
b: &ast::Unsafety)
-> RelateResult<'tcx, ast::Unsafety>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ast::Unsafety,
b: &ast::Unsafety,
) -> RelateResult<'tcx, ast::Unsafety>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
if a != b {
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
@ -200,11 +218,15 @@ impl<'tcx> Relate<'tcx> for ast::Unsafety {
}
impl<'tcx> Relate<'tcx> for abi::Abi {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &abi::Abi,
b: &abi::Abi)
-> RelateResult<'tcx, abi::Abi>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &abi::Abi,
b: &abi::Abi,
) -> RelateResult<'tcx, abi::Abi>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
if a == b {
Ok(*a)
@ -215,11 +237,15 @@ impl<'tcx> Relate<'tcx> for abi::Abi {
}
impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::ProjectionTy<'tcx>,
b: &ty::ProjectionTy<'tcx>)
-> RelateResult<'tcx, ty::ProjectionTy<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::ProjectionTy<'tcx>,
b: &ty::ProjectionTy<'tcx>,
) -> RelateResult<'tcx, ty::ProjectionTy<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
if a.item_def_id != b.item_def_id {
Err(TypeError::ProjectionMismatched(
@ -235,11 +261,15 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
}
impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::ExistentialProjection<'tcx>,
b: &ty::ExistentialProjection<'tcx>)
-> RelateResult<'tcx, ty::ExistentialProjection<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::ExistentialProjection<'tcx>,
b: &ty::ExistentialProjection<'tcx>,
) -> RelateResult<'tcx, ty::ExistentialProjection<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
if a.item_def_id != b.item_def_id {
Err(TypeError::ProjectionMismatched(
@ -257,11 +287,15 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
}
impl<'tcx> Relate<'tcx> for Vec<ty::PolyExistentialProjection<'tcx>> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Vec<ty::PolyExistentialProjection<'tcx>>,
b: &Vec<ty::PolyExistentialProjection<'tcx>>)
-> RelateResult<'tcx, Vec<ty::PolyExistentialProjection<'tcx>>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &Vec<ty::PolyExistentialProjection<'tcx>>,
b: &Vec<ty::PolyExistentialProjection<'tcx>>,
) -> RelateResult<'tcx, Vec<ty::PolyExistentialProjection<'tcx>>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
// To be compatible, `a` and `b` must be for precisely the
// same set of traits and item names. We always require that
@ -280,11 +314,15 @@ impl<'tcx> Relate<'tcx> for Vec<ty::PolyExistentialProjection<'tcx>> {
}
impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::TraitRef<'tcx>,
b: &ty::TraitRef<'tcx>)
-> RelateResult<'tcx, ty::TraitRef<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::TraitRef<'tcx>,
b: &ty::TraitRef<'tcx>,
) -> RelateResult<'tcx, ty::TraitRef<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
// Different traits cannot be related
if a.def_id != b.def_id {
@ -297,11 +335,15 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
}
impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::ExistentialTraitRef<'tcx>,
b: &ty::ExistentialTraitRef<'tcx>)
-> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::ExistentialTraitRef<'tcx>,
b: &ty::ExistentialTraitRef<'tcx>,
) -> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
// Different traits cannot be related
if a.def_id != b.def_id {
@ -323,11 +365,15 @@ TupleStructTypeFoldableImpl! {
}
impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &GeneratorWitness<'tcx>,
b: &GeneratorWitness<'tcx>)
-> RelateResult<'tcx, GeneratorWitness<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &GeneratorWitness<'tcx>,
b: &GeneratorWitness<'tcx>,
) -> RelateResult<'tcx, GeneratorWitness<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
assert_eq!(a.0.len(), b.0.len());
let tcx = relation.tcx();
@ -337,11 +383,15 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
}
impl<'tcx> Relate<'tcx> for Ty<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Ty<'tcx>,
b: &Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &Ty<'tcx>,
b: &Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
relation.tys(a, b)
}
@ -350,11 +400,15 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> {
/// The main "type relation" routine. Note that this does not handle
/// inference artifacts, so you should filter those out before calling
/// it.
pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(
relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let tcx = relation.tcx();
debug!("super_relate_tys: a={:?} b={:?}", a, b);
@ -553,10 +607,12 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(
relation: &mut R,
a: &'tcx ty::Const<'tcx>,
b: &'tcx ty::Const<'tcx>
b: &'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let tcx = relation.tcx();
@ -632,12 +688,12 @@ where
}
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Self,
b: &Self)
-> RelateResult<'tcx, Self>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a {
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
if a.len() != b.len() {
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
}
@ -657,11 +713,15 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
}
impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::ClosureSubsts<'tcx>,
b: &ty::ClosureSubsts<'tcx>)
-> RelateResult<'tcx, ty::ClosureSubsts<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::ClosureSubsts<'tcx>,
b: &ty::ClosureSubsts<'tcx>,
) -> RelateResult<'tcx, ty::ClosureSubsts<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let substs = relate_substs(relation, None, a.substs, b.substs)?;
Ok(ty::ClosureSubsts { substs })
@ -669,11 +729,15 @@ impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> {
}
impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::GeneratorSubsts<'tcx>,
b: &ty::GeneratorSubsts<'tcx>)
-> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::GeneratorSubsts<'tcx>,
b: &ty::GeneratorSubsts<'tcx>,
) -> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let substs = relate_substs(relation, None, a.substs, b.substs)?;
Ok(ty::GeneratorSubsts { substs })
@ -681,55 +745,71 @@ impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> {
}
impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &SubstsRef<'tcx>,
b: &SubstsRef<'tcx>)
-> RelateResult<'tcx, SubstsRef<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &SubstsRef<'tcx>,
b: &SubstsRef<'tcx>,
) -> RelateResult<'tcx, SubstsRef<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
relate_substs(relation, None, a, b)
}
}
impl<'tcx> Relate<'tcx> for ty::Region<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::Region<'tcx>,
b: &ty::Region<'tcx>)
-> RelateResult<'tcx, ty::Region<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::Region<'tcx>,
b: &ty::Region<'tcx>,
) -> RelateResult<'tcx, ty::Region<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
relation.regions(*a, *b)
}
}
impl<'tcx> Relate<'tcx> for &'tcx ty::Const<'tcx> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &&'tcx ty::Const<'tcx>,
b: &&'tcx ty::Const<'tcx>)
-> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &&'tcx ty::Const<'tcx>,
b: &&'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
relation.consts(*a, *b)
}
}
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<T> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &ty::Binder<T>,
b: &ty::Binder<T>)
-> RelateResult<'tcx, ty::Binder<T>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::Binder<T>,
b: &ty::Binder<T>,
) -> RelateResult<'tcx, ty::Binder<T>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
relation.binders(a, b)
}
}
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc<T> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Rc<T>,
b: &Rc<T>)
-> RelateResult<'tcx, Rc<T>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Rc<T>, b: &Rc<T>) -> RelateResult<'tcx, Rc<T>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let a: &T = a;
let b: &T = b;
@ -738,11 +818,11 @@ impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc<T> {
}
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box<T> {
fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Box<T>,
b: &Box<T>)
-> RelateResult<'tcx, Box<T>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Box<T>, b: &Box<T>) -> RelateResult<'tcx, Box<T>>
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
let a: &T = a;
let b: &T = b;
@ -754,10 +834,12 @@ impl<'tcx> Relate<'tcx> for Kind<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &Kind<'tcx>,
b: &Kind<'tcx>
b: &Kind<'tcx>,
) -> RelateResult<'tcx, Kind<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a,
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
match (a.unpack(), b.unpack()) {
(UnpackedKind::Lifetime(a_lt), UnpackedKind::Lifetime(b_lt)) => {
@ -786,9 +868,12 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &ty::TraitPredicate<'tcx>,
b: &ty::TraitPredicate<'tcx>
b: &ty::TraitPredicate<'tcx>,
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
Ok(ty::TraitPredicate {
trait_ref: relation.relate(&a.trait_ref, &b.trait_ref)?,
@ -802,7 +887,10 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> {
a: &ty::ProjectionPredicate<'tcx>,
b: &ty::ProjectionPredicate<'tcx>,
) -> RelateResult<'tcx, ty::ProjectionPredicate<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
Ok(ty::ProjectionPredicate {
projection_ty: relation.relate(&a.projection_ty, &b.projection_ty)?,
@ -815,9 +903,12 @@ impl<'tcx> Relate<'tcx> for traits::WhereClause<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::WhereClause<'tcx>,
b: &traits::WhereClause<'tcx>
b: &traits::WhereClause<'tcx>,
) -> RelateResult<'tcx, traits::WhereClause<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::WhereClause::*;
match (a, b) {
@ -852,9 +943,12 @@ impl<'tcx> Relate<'tcx> for traits::WellFormed<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::WellFormed<'tcx>,
b: &traits::WellFormed<'tcx>
b: &traits::WellFormed<'tcx>,
) -> RelateResult<'tcx, traits::WellFormed<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::WellFormed::*;
match (a, b) {
@ -869,9 +963,12 @@ impl<'tcx> Relate<'tcx> for traits::FromEnv<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::FromEnv<'tcx>,
b: &traits::FromEnv<'tcx>
b: &traits::FromEnv<'tcx>,
) -> RelateResult<'tcx, traits::FromEnv<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::FromEnv::*;
match (a, b) {
@ -886,9 +983,12 @@ impl<'tcx> Relate<'tcx> for traits::DomainGoal<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::DomainGoal<'tcx>,
b: &traits::DomainGoal<'tcx>
b: &traits::DomainGoal<'tcx>,
) -> RelateResult<'tcx, traits::DomainGoal<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::DomainGoal::*;
match (a, b) {
@ -909,9 +1009,12 @@ impl<'tcx> Relate<'tcx> for traits::Goal<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::Goal<'tcx>,
b: &traits::Goal<'tcx>
b: &traits::Goal<'tcx>,
) -> RelateResult<'tcx, traits::Goal<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::GoalKind::*;
match (a, b) {
@ -955,9 +1058,12 @@ impl<'tcx> Relate<'tcx> for traits::Goals<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::Goals<'tcx>,
b: &traits::Goals<'tcx>
b: &traits::Goals<'tcx>,
) -> RelateResult<'tcx, traits::Goals<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
if a.len() != b.len() {
return Err(TypeError::Mismatch);
@ -973,9 +1079,12 @@ impl<'tcx> Relate<'tcx> for traits::Clause<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::Clause<'tcx>,
b: &traits::Clause<'tcx>
b: &traits::Clause<'tcx>,
) -> RelateResult<'tcx, traits::Clause<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
use crate::traits::Clause::*;
match (a, b) {
@ -998,9 +1107,12 @@ impl<'tcx> Relate<'tcx> for traits::Clauses<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::Clauses<'tcx>,
b: &traits::Clauses<'tcx>
b: &traits::Clauses<'tcx>,
) -> RelateResult<'tcx, traits::Clauses<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
if a.len() != b.len() {
return Err(TypeError::Mismatch);
@ -1016,9 +1128,12 @@ impl<'tcx> Relate<'tcx> for traits::ProgramClause<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::ProgramClause<'tcx>,
b: &traits::ProgramClause<'tcx>
b: &traits::ProgramClause<'tcx>,
) -> RelateResult<'tcx, traits::ProgramClause<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
Ok(traits::ProgramClause {
goal: relation.relate(&a.goal, &b.goal)?,
@ -1032,9 +1147,12 @@ impl<'tcx> Relate<'tcx> for traits::Environment<'tcx> {
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::Environment<'tcx>,
b: &traits::Environment<'tcx>
b: &traits::Environment<'tcx>,
) -> RelateResult<'tcx, traits::Environment<'tcx>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
Ok(traits::Environment {
clauses: relation.relate(&a.clauses, &b.clauses)?,
@ -1043,14 +1161,18 @@ impl<'tcx> Relate<'tcx> for traits::Environment<'tcx> {
}
impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G>
where G: Relate<'tcx>
where
G: Relate<'tcx>,
{
fn relate<'a, 'gcx, R>(
relation: &mut R,
a: &traits::InEnvironment<'tcx, G>,
b: &traits::InEnvironment<'tcx, G>
b: &traits::InEnvironment<'tcx, G>,
) -> RelateResult<'tcx, traits::InEnvironment<'tcx, G>>
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
where
R: TypeRelation<'gcx, 'tcx>,
'gcx: 'tcx,
'tcx: 'a,
{
Ok(traits::InEnvironment {
environment: relation.relate(&a.environment, &b.environment)?,
@ -1062,11 +1184,12 @@ impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G>
///////////////////////////////////////////////////////////////////////////
// Error handling
pub fn expected_found<'a, 'gcx, 'tcx, R, T>(relation: &mut R,
a: &T,
b: &T)
-> ExpectedFound<T>
where R: TypeRelation<'gcx, 'tcx>, T: Clone, 'gcx: 'a+'tcx, 'tcx: 'a
pub fn expected_found<'a, 'gcx, 'tcx, R, T>(relation: &mut R, a: &T, b: &T) -> ExpectedFound<T>
where
R: TypeRelation<'gcx, 'tcx>,
T: Clone,
'gcx: 'a + 'tcx,
'tcx: 'a,
{
expected_found_bool(relation.a_is_expected(), a, b)
}

View file

@ -450,8 +450,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> {
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
type Lifted = ty::TraitPredicate<'tcx>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
-> Option<ty::TraitPredicate<'tcx>> {
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate {
trait_ref,
})
@ -460,8 +459,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
type Lifted = ty::SubtypePredicate<'tcx>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
-> Option<ty::SubtypePredicate<'tcx>> {
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::SubtypePredicate<'tcx>> {
tcx.lift(&(self.a, self.b)).map(|(a, b)| ty::SubtypePredicate {
a_is_expected: self.a_is_expected,
a,
@ -470,7 +468,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
}
}
impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
impl<'tcx, A: Copy + Lift<'tcx>, B: Copy + Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
@ -479,8 +477,7 @@ impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPr
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
type Lifted = ty::ProjectionTy<'tcx>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
-> Option<ty::ProjectionTy<'tcx>> {
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::ProjectionTy<'tcx>> {
tcx.lift(&self.substs).map(|substs| {
ty::ProjectionTy {
item_def_id: self.item_def_id,
@ -492,8 +489,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
type Lifted = ty::ProjectionPredicate<'tcx>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
-> Option<ty::ProjectionPredicate<'tcx>> {
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> {
tcx.lift(&(self.projection_ty, self.ty)).map(|(projection_ty, ty)| {
ty::ProjectionPredicate {
projection_ty,

View file

@ -335,9 +335,11 @@ impl<'tcx> ClosureSubsts<'tcx> {
}
#[inline]
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
impl Iterator<Item=Ty<'tcx>> + 'tcx
{
pub fn upvar_tys(
self,
def_id: DefId,
tcx: TyCtxt<'_, '_>,
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
upvar_kinds.iter().map(|t| {
if let UnpackedKind::Type(ty) = t.unpack() {
@ -422,9 +424,11 @@ impl<'tcx> GeneratorSubsts<'tcx> {
}
#[inline]
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
impl Iterator<Item=Ty<'tcx>> + 'tcx
{
pub fn upvar_tys(
self,
def_id: DefId,
tcx: TyCtxt<'_, '_>,
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
upvar_kinds.iter().map(|t| {
if let UnpackedKind::Type(ty) = t.unpack() {
@ -489,7 +493,10 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
/// out of range.
#[inline]
pub fn discriminant_for_variant(
&self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>, variant_index: VariantIdx
&self,
def_id: DefId,
tcx: TyCtxt<'gcx, 'tcx>,
variant_index: VariantIdx,
) -> Discr<'tcx> {
// Generators don't support explicit discriminant values, so they are
// the same as the variant index.
@ -501,8 +508,10 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
/// variant indices.
#[inline]
pub fn discriminants(
&'tcx self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>
) -> impl Iterator<Item=(VariantIdx, Discr<'tcx>)> + Captures<'gcx> {
&'tcx self,
def_id: DefId,
tcx: TyCtxt<'gcx, 'tcx>,
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'gcx> {
self.variant_range(def_id, tcx).map(move |index| {
(index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) })
})
@ -533,9 +542,11 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
/// The locals are grouped by their variant number. Note that some locals may
/// be repeated in multiple variants.
#[inline]
pub fn state_tys(self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>) ->
impl Iterator<Item=impl Iterator<Item=Ty<'tcx>> + Captures<'gcx>>
{
pub fn state_tys(
self,
def_id: DefId,
tcx: TyCtxt<'gcx, 'tcx>,
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + Captures<'gcx>> {
let layout = tcx.generator_layout(def_id);
layout.variant_fields.iter().map(move |variant| {
variant.iter().map(move |field| {
@ -547,9 +558,11 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
/// This is the types of the fields of a generator which are not stored in a
/// variant.
#[inline]
pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>) ->
impl Iterator<Item=Ty<'tcx>>
{
pub fn prefix_tys(
self,
def_id: DefId,
tcx: TyCtxt<'gcx, 'tcx>,
) -> impl Iterator<Item = Ty<'tcx>> {
self.upvar_tys(def_id, tcx)
}
}
@ -562,9 +575,11 @@ pub enum UpvarSubsts<'tcx> {
impl<'tcx> UpvarSubsts<'tcx> {
#[inline]
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
impl Iterator<Item=Ty<'tcx>> + 'tcx
{
pub fn upvar_tys(
self,
def_id: DefId,
tcx: TyCtxt<'_, '_>,
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
let upvar_kinds = match self {
UpvarSubsts::Closure(substs) => substs.split(def_id, tcx).upvar_kinds,
UpvarSubsts::Generator(substs) => substs.split(def_id, tcx).upvar_kinds,
@ -607,12 +622,10 @@ impl<'gcx, 'tcx> ExistentialPredicate<'tcx> {
(AutoTrait(_), _) => Ordering::Greater,
}
}
}
impl<'gcx, 'tcx> Binder<ExistentialPredicate<'tcx>> {
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
-> ty::Predicate<'tcx> {
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> {
use crate::ty::ToPredicate;
match *self.skip_binder() {
ExistentialPredicate::Trait(tr) => Binder(tr).with_self_ty(tcx, self_ty).to_predicate(),
@ -764,10 +777,11 @@ impl<'tcx> TraitRef<'tcx> {
self.substs.types()
}
pub fn from_method(tcx: TyCtxt<'_, 'tcx>,
trait_id: DefId,
substs: SubstsRef<'tcx>)
-> ty::TraitRef<'tcx> {
pub fn from_method(
tcx: TyCtxt<'_, 'tcx>,
trait_id: DefId,
substs: SubstsRef<'tcx>,
) -> ty::TraitRef<'tcx> {
let defs = tcx.generics_of(trait_id);
ty::TraitRef {
@ -817,9 +831,10 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> {
self.substs.types()
}
pub fn erase_self_ty(tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>)
-> ty::ExistentialTraitRef<'tcx> {
pub fn erase_self_ty(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> ty::ExistentialTraitRef<'tcx> {
// Assert there is a Self.
trait_ref.substs.type_at(0);
@ -833,8 +848,7 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> {
/// we convert the principal trait-ref into a normal trait-ref,
/// you must give *some* self type. A common choice is `mk_err()`
/// or some placeholder type.
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
-> ty::TraitRef<'tcx> {
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> {
// otherwise the escaping vars would be captured by the binder
// debug_assert!(!self_ty.has_escaping_bound_vars());
@ -856,9 +870,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
/// we convert the principal trait-ref into a normal trait-ref,
/// you must give *some* self type. A common choice is `mk_err()`
/// or some placeholder type.
pub fn with_self_ty(&self, tcx: TyCtxt<'_, 'tcx>,
self_ty: Ty<'tcx>)
-> ty::PolyTraitRef<'tcx> {
pub fn with_self_ty(&self, tcx: TyCtxt<'_, 'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> {
self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty))
}
}
@ -992,7 +1004,9 @@ impl<'tcx> ProjectionTy<'tcx> {
/// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the
/// associated item named `item_name`.
pub fn from_ref_and_name(
tcx: TyCtxt<'_, '_>, trait_ref: ty::TraitRef<'tcx>, item_name: Ident
tcx: TyCtxt<'_, '_>,
trait_ref: ty::TraitRef<'tcx>,
item_name: Ident,
) -> ProjectionTy<'tcx> {
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
item.kind == ty::AssocKind::Type &&
@ -1421,10 +1435,11 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> {
}
}
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>,
self_ty: Ty<'tcx>)
-> ty::ProjectionPredicate<'tcx>
{
pub fn with_self_ty(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
self_ty: Ty<'tcx>,
) -> ty::ProjectionPredicate<'tcx> {
// otherwise the escaping regions would be captured by the binders
debug_assert!(!self_ty.has_escaping_bound_vars());
@ -1439,8 +1454,11 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> {
}
impl<'tcx, 'gcx> PolyExistentialProjection<'tcx> {
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
-> ty::PolyProjectionPredicate<'tcx> {
pub fn with_self_ty(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
self_ty: Ty<'tcx>,
) -> ty::PolyProjectionPredicate<'tcx> {
self.map_bound(|p| p.with_self_ty(tcx, self_ty))
}
@ -2099,7 +2117,7 @@ impl<'gcx, 'tcx> TyS<'tcx> {
pub fn discriminant_for_variant(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
variant_index: VariantIdx
variant_index: VariantIdx,
) -> Option<Discr<'tcx>> {
match self.sty {
TyKind::Adt(adt, _) => Some(adt.discriminant_for_variant(tcx, variant_index)),
@ -2239,11 +2257,7 @@ static_assert_size!(Const<'_>, 40);
impl<'tcx> Const<'tcx> {
#[inline]
pub fn from_scalar(
tcx: TyCtxt<'_, 'tcx>,
val: Scalar,
ty: Ty<'tcx>,
) -> &'tcx Self {
pub fn from_scalar(tcx: TyCtxt<'_, 'tcx>, val: Scalar, ty: Ty<'tcx>) -> &'tcx Self {
tcx.mk_const(Self {
val: ConstValue::Scalar(val),
ty,
@ -2279,11 +2293,7 @@ impl<'tcx> Const<'tcx> {
}
#[inline]
pub fn to_bits(
&self,
tcx: TyCtxt<'_, 'tcx>,
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Option<u128> {
pub fn to_bits(&self, tcx: TyCtxt<'_, 'tcx>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option<u128> {
if self.ty != ty.value {
return None;
}
@ -2324,11 +2334,7 @@ impl<'tcx> Const<'tcx> {
}
#[inline]
pub fn unwrap_bits(
&self,
tcx: TyCtxt<'_, '_>,
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> u128 {
pub fn unwrap_bits(&self, tcx: TyCtxt<'_, '_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> u128 {
self.assert_bits(tcx, ty).unwrap_or_else(||
bug!("expected bits of {}, got {:#?}", ty.value, self))
}

View file

@ -194,10 +194,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
/// var bound at index `0`. For types, we use a `BoundVar` index equal to
/// the type parameter index. For regions, we use the `BoundRegion::BrNamed`
/// variant (which has a `DefId`).
pub fn bound_vars_for_item(
tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId
) -> SubstsRef<'tcx> {
pub fn bound_vars_for_item(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> {
Self::for_item(tcx, def_id, |param, _| {
match param.kind {
ty::GenericParamDefKind::Type { .. } => {
@ -233,11 +230,9 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
/// The closures get to observe the `InternalSubsts` as they're
/// being built, which can be used to correctly
/// substitute defaults of generic parameters.
pub fn for_item<F>(tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId,
mut mk_kind: F)
-> SubstsRef<'tcx>
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
pub fn for_item<F>(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx>
where
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
{
let defs = tcx.generics_of(def_id);
let count = defs.count();
@ -246,12 +241,14 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
tcx.intern_substs(&substs)
}
pub fn extend_to<F>(&self,
tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId,
mut mk_kind: F)
-> SubstsRef<'tcx>
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
pub fn extend_to<F>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId,
mut mk_kind: F,
) -> SubstsRef<'tcx>
where
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
{
Self::for_item(tcx, def_id, |param, substs| {
self.get(param.index as usize)
@ -260,11 +257,13 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
})
}
fn fill_item<F>(substs: &mut SmallVec<[Kind<'tcx>; 8]>,
tcx: TyCtxt<'gcx, 'tcx>,
defs: &ty::Generics,
mk_kind: &mut F)
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
fn fill_item<F>(
substs: &mut SmallVec<[Kind<'tcx>; 8]>,
tcx: TyCtxt<'gcx, 'tcx>,
defs: &ty::Generics,
mk_kind: &mut F,
) where
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
{
if let Some(def_id) = defs.parent {
let parent_defs = tcx.generics_of(def_id);
@ -372,16 +371,17 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
/// in a different item, with `target_substs` as the base for
/// the target impl/trait, with the source child-specific
/// parameters (e.g., method parameters) on top of that base.
pub fn rebase_onto(&self, tcx: TyCtxt<'gcx, 'tcx>,
source_ancestor: DefId,
target_substs: SubstsRef<'tcx>)
-> SubstsRef<'tcx> {
pub fn rebase_onto(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
source_ancestor: DefId,
target_substs: SubstsRef<'tcx>,
) -> SubstsRef<'tcx> {
let defs = tcx.generics_of(source_ancestor);
tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned())
}
pub fn truncate_to(&self, tcx: TyCtxt<'gcx, 'tcx>, generics: &ty::Generics)
-> SubstsRef<'tcx> {
pub fn truncate_to(&self, tcx: TyCtxt<'gcx, 'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> {
tcx.mk_substs(self.iter().take(generics.count()).cloned())
}
}
@ -414,23 +414,25 @@ impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {}
// there is more information available (for better errors).
pub trait Subst<'tcx>: Sized {
fn subst<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
substs: &[Kind<'tcx>]) -> Self {
fn subst<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: &[Kind<'tcx>]) -> Self {
self.subst_spanned(tcx, substs, None)
}
fn subst_spanned<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>)
-> Self;
fn subst_spanned<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>,
) -> Self;
}
impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
fn subst_spanned<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>)
-> T
{
impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T {
fn subst_spanned<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>,
) -> T {
let mut folder = SubstFolder { tcx,
substs,
span,
@ -444,7 +446,7 @@ impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
///////////////////////////////////////////////////////////////////////////
// The actual substitution engine itself is a type folder.
struct SubstFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
struct SubstFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'gcx, 'tcx>,
substs: &'a [Kind<'tcx>],

View file

@ -64,9 +64,11 @@ impl<'gcx, 'tcx> TraitDef {
}
}
pub fn ancestors(&self, tcx: TyCtxt<'gcx, 'tcx>,
of_impl: DefId)
-> specialization_graph::Ancestors<'gcx> {
pub fn ancestors(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
of_impl: DefId,
) -> specialization_graph::Ancestors<'gcx> {
specialization_graph::ancestors(tcx, self.def_id, of_impl)
}
}
@ -148,9 +150,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
}
// Query provider for `trait_impls_of`.
pub(super) fn trait_impls_of_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
trait_id: DefId)
-> &'tcx TraitImpls {
pub(super) fn trait_impls_of_provider<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
trait_id: DefId,
) -> &'tcx TraitImpls {
let mut impls = TraitImpls::default();
{

View file

@ -105,8 +105,11 @@ impl<'tcx> Discr<'tcx> {
pub trait IntTypeExt {
fn to_ty<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>;
fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, val: Option<Discr<'tcx>>)
-> Option<Discr<'tcx>>;
fn disr_incr<'tcx>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
val: Option<Discr<'tcx>>,
) -> Option<Discr<'tcx>>;
fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Discr<'tcx>;
}
@ -178,10 +181,11 @@ pub enum Representability {
}
impl<'tcx> ty::ParamEnv<'tcx> {
pub fn can_type_implement_copy(self,
tcx: TyCtxt<'tcx, 'tcx>,
self_type: Ty<'tcx>)
-> Result<(), CopyImplementationError<'tcx>> {
pub fn can_type_implement_copy(
self,
tcx: TyCtxt<'tcx, 'tcx>,
self_type: Ty<'tcx>,
) -> Result<(), CopyImplementationError<'tcx>> {
// FIXME: (@jroesch) float this code up
tcx.infer_ctxt().enter(|infcx| {
let (adt, substs) = match self_type.sty {
@ -695,11 +699,12 @@ impl<'tcx> ty::TyS<'tcx> {
/// does copies even when the type actually doesn't satisfy the
/// full requirements for the `Copy` trait (cc #29149) -- this
/// winds up being reported as an error during NLL borrow check.
pub fn is_copy_modulo_regions(&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
span: Span)
-> bool {
pub fn is_copy_modulo_regions(
&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
span: Span,
) -> bool {
tcx.at(span).is_copy_raw(param_env.and(self))
}
@ -709,10 +714,11 @@ impl<'tcx> ty::TyS<'tcx> {
/// over-approximation in generic contexts, where one can have
/// strange rules like `<T as Foo<'static>>::Bar: Sized` that
/// actually carry lifetime requirements.
pub fn is_sized(&'tcx self,
tcx_at: TyCtxtAt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>)-> bool
{
pub fn is_sized(
&'tcx self,
tcx_at: TyCtxtAt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> bool {
tcx_at.is_sized_raw(param_env.and(self))
}
@ -723,11 +729,12 @@ impl<'tcx> ty::TyS<'tcx> {
/// optimization as well as the rules around static values. Note
/// that the `Freeze` trait is not exposed to end users and is
/// effectively an implementation detail.
pub fn is_freeze(&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
span: Span)-> bool
{
pub fn is_freeze(
&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
span: Span,
) -> bool {
tcx.at(span).is_freeze_raw(param_env.and(self))
}
@ -738,10 +745,7 @@ impl<'tcx> ty::TyS<'tcx> {
/// (Note that this implies that if `ty` has a destructor attached,
/// then `needs_drop` will definitely return `true` for `ty`.)
#[inline]
pub fn needs_drop(&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>)
-> bool {
pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
tcx.needs_drop_raw(param_env.and(self)).0
}
@ -760,11 +764,7 @@ impl<'tcx> ty::TyS<'tcx> {
/// Check whether a type is representable. This means it cannot contain unboxed
/// structural recursion. This check is needed for structs and enums.
pub fn is_representable(&'tcx self,
tcx: TyCtxt<'tcx, 'tcx>,
sp: Span)
-> Representability
{
pub fn is_representable(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, sp: Span) -> Representability {
// Iterate until something non-representable is found
fn fold_repr<It: Iterator<Item=Representability>>(iter: It) -> Representability {
iter.fold(Representability::Representable, |r1, r2| {
@ -779,12 +779,12 @@ impl<'tcx> ty::TyS<'tcx> {
}
fn are_inner_types_recursive<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, sp: Span,
tcx: TyCtxt<'tcx, 'tcx>,
sp: Span,
seen: &mut Vec<Ty<'tcx>>,
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
ty: Ty<'tcx>)
-> Representability
{
ty: Ty<'tcx>,
) -> Representability {
match ty.sty {
Tuple(ref ts) => {
// Find non representable
@ -843,8 +843,8 @@ impl<'tcx> ty::TyS<'tcx> {
sp: Span,
seen: &mut Vec<Ty<'tcx>>,
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
ty: Ty<'tcx>) -> Representability
{
ty: Ty<'tcx>,
) -> Representability {
debug!("is_type_structurally_recursive: {:?} {:?}", ty, sp);
if let Some(representability) = representable_cache.get(ty) {
debug!("is_type_structurally_recursive: {:?} {:?} - (cached) {:?}",
@ -864,8 +864,8 @@ impl<'tcx> ty::TyS<'tcx> {
sp: Span,
seen: &mut Vec<Ty<'tcx>>,
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
ty: Ty<'tcx>) -> Representability
{
ty: Ty<'tcx>,
) -> Representability {
match ty.sty {
Adt(def, _) => {
{
@ -937,10 +937,7 @@ impl<'tcx> ty::TyS<'tcx> {
}
}
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> bool
{
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem);
tcx.infer_ctxt()
@ -953,10 +950,7 @@ fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
))
}
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> bool
{
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem);
tcx.infer_ctxt()
@ -969,10 +963,7 @@ fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
))
}
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> bool
{
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem);
tcx.infer_ctxt()
@ -988,10 +979,10 @@ fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
#[derive(Clone, HashStable)]
pub struct NeedsDrop(pub bool);
fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> NeedsDrop
{
fn needs_drop_raw<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> NeedsDrop {
let (param_env, ty) = query.into_parts();
let needs_drop = |ty: Ty<'tcx>| -> bool {

View file

@ -510,9 +510,8 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
/// `ty::required_region_bounds`, see that for more information.
pub fn object_region_bounds<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>)
-> Vec<ty::Region<'tcx>>
{
existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>,
) -> Vec<ty::Region<'tcx>> {
// Since we don't actually *know* the self type for an object,
// this "open(err)" serves as a kind of dummy standin -- basically
// a placeholder type.

View file

@ -179,11 +179,13 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) { }
}
pub fn check_loans<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
dfcx_loans: &LoanDataFlow<'tcx>,
move_data: &move_data::FlowedMoveData<'tcx>,
all_loans: &[Loan<'tcx>],
body: &hir::Body) {
pub fn check_loans<'a, 'tcx>(
bccx: &BorrowckCtxt<'a, 'tcx>,
dfcx_loans: &LoanDataFlow<'tcx>,
move_data: &move_data::FlowedMoveData<'tcx>,
all_loans: &[Loan<'tcx>],
body: &hir::Body,
) {
debug!("check_loans(body id={})", body.value.hir_id);
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());

View file

@ -73,9 +73,7 @@ pub struct AnalysisData<'tcx> {
pub move_data: move_data::FlowedMoveData<'tcx>,
}
fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId)
-> &'tcx BorrowCheckResult
{
fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckResult {
assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
debug!("borrowck(body_owner_def_id={:?})", owner_def_id);
@ -141,12 +139,14 @@ fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId)
})
}
fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tcx>,
force_analysis: bool,
body_id: hir::BodyId,
get_cfg: F)
-> Option<AnalysisData<'tcx>>
where F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG
fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(
this: &mut BorrowckCtxt<'a, 'tcx>,
force_analysis: bool,
body_id: hir::BodyId,
get_cfg: F,
) -> Option<AnalysisData<'tcx>>
where
F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG,
{
// Check the body of fn items.
let (all_loans, move_data) =
@ -195,9 +195,8 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
body_id: hir::BodyId,
cfg: &cfg::CFG)
-> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>)
{
cfg: &cfg::CFG,
) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>) {
let owner_id = tcx.hir().body_owner(body_id);
let owner_def_id = tcx.hir().local_def_id(owner_id);
let tables = tcx.typeck_tables_of(owner_def_id);
@ -238,7 +237,6 @@ pub struct BorrowckCtxt<'a, 'tcx> {
signalled_any_error: Cell<SignalledError>,
}
impl BorrowckCtxt<'_, 'tcx> {
fn signal_error(&self) {
self.signalled_any_error.set(SignalledError::SawSomeError);
@ -390,8 +388,7 @@ pub enum LoanPathElem<'tcx> {
LpInterior(Option<DefId>, InteriorKind),
}
fn closure_to_block(closure_id: LocalDefId,
tcx: TyCtxt<'_, '_>) -> HirId {
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_, '_>) -> HirId {
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
match tcx.hir().get(closure_id) {
Node::Expr(expr) => match expr.node {

View file

@ -47,7 +47,7 @@ pub struct FlowedMoveData<'tcx> {
// We could (and maybe should, for efficiency) combine both move
// and assign data flow into one, but this way it's easier to
// distinguish the bits that correspond to moves and assignments.
pub dfcx_assign: AssignDataFlow<'tcx>
pub dfcx_assign: AssignDataFlow<'tcx>,
}
/// Index into `MoveData.paths`, used like a pointer
@ -223,8 +223,7 @@ impl MoveData<'tcx> {
/// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for
/// `lp` and any of its base paths that do not yet have an index.
pub fn move_path(&self, tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>) -> MovePathIndex {
pub fn move_path(&self, tcx: TyCtxt<'tcx, 'tcx>, lp: Rc<LoanPath<'tcx>>) -> MovePathIndex {
if let Some(&index) = self.path_map.borrow().get(&lp) {
return index;
}
@ -311,10 +310,13 @@ impl MoveData<'tcx> {
}
/// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`.
pub fn add_move(&self, tcx: TyCtxt<'tcx, 'tcx>,
orig_lp: Rc<LoanPath<'tcx>>,
id: hir::ItemLocalId,
kind: MoveKind) {
pub fn add_move(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
orig_lp: Rc<LoanPath<'tcx>>,
id: hir::ItemLocalId,
kind: MoveKind,
) {
// Moving one union field automatically moves all its fields. Also move siblings of
// all parent union fields, moves do not propagate upwards automatically.
let mut lp = orig_lp.clone();
@ -340,10 +342,13 @@ impl MoveData<'tcx> {
self.add_move_helper(tcx, orig_lp, id, kind);
}
fn add_move_helper(&self, tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
id: hir::ItemLocalId,
kind: MoveKind) {
fn add_move_helper(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
id: hir::ItemLocalId,
kind: MoveKind,
) {
debug!("add_move(lp={:?}, id={:?}, kind={:?})",
lp,
id,
@ -365,10 +370,13 @@ impl MoveData<'tcx> {
/// Adds a new record for an assignment to `lp` that occurs at location `id` with the given
/// `span`.
pub fn add_assignment(&self, tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
assign_id: hir::ItemLocalId,
span: Span) {
pub fn add_assignment(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
assign_id: hir::ItemLocalId,
span: Span,
) {
// Assigning to one union field automatically assigns to all its fields.
if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind {
if let ty::Adt(adt_def, _) = base_lp.ty.sty {
@ -395,10 +403,13 @@ impl MoveData<'tcx> {
self.add_assignment_helper(tcx, lp, assign_id, span);
}
fn add_assignment_helper(&self, tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
assign_id: hir::ItemLocalId,
span: Span) {
fn add_assignment_helper(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
assign_id: hir::ItemLocalId,
span: Span,
) {
debug!("add_assignment(lp={:?}, assign_id={:?}", lp, assign_id);
let path_index = self.move_path(tcx, lp.clone());
@ -427,10 +438,12 @@ impl MoveData<'tcx> {
/// Moves are generated by moves and killed by assignments and
/// scoping. Assignments are generated by assignment to variables and
/// killed by scoping. See `README.md` for more details.
fn add_gen_kills(&self,
bccx: &BorrowckCtxt<'_, 'tcx>,
dfcx_moves: &mut MoveDataFlow<'_>,
dfcx_assign: &mut AssignDataFlow<'_>) {
fn add_gen_kills(
&self,
bccx: &BorrowckCtxt<'_, 'tcx>,
dfcx_moves: &mut MoveDataFlow<'_>,
dfcx_assign: &mut AssignDataFlow<'_>,
) {
for (i, the_move) in self.moves.borrow().iter().enumerate() {
dfcx_moves.add_gen(the_move.id, i);
}
@ -534,11 +547,13 @@ impl MoveData<'tcx> {
ret
}
fn kill_moves(&self,
path: MovePathIndex,
kill_id: hir::ItemLocalId,
kill_kind: KillFrom,
dfcx_moves: &mut MoveDataFlow<'_>) {
fn kill_moves(
&self,
path: MovePathIndex,
kill_id: hir::ItemLocalId,
kill_kind: KillFrom,
dfcx_moves: &mut MoveDataFlow<'_>,
) {
// We can only perform kills for paths that refer to a unique location,
// since otherwise we may kill a move from one location with an
// assignment referring to another location.
@ -556,11 +571,12 @@ impl MoveData<'tcx> {
}
impl<'tcx> FlowedMoveData<'tcx> {
pub fn new(move_data: MoveData<'tcx>,
bccx: &BorrowckCtxt<'_, 'tcx>,
cfg: &cfg::CFG,
body: &hir::Body)
-> FlowedMoveData<'tcx> {
pub fn new(
move_data: MoveData<'tcx>,
bccx: &BorrowckCtxt<'_, 'tcx>,
cfg: &cfg::CFG,
body: &hir::Body,
) -> FlowedMoveData<'tcx> {
let tcx = bccx.tcx;
let mut dfcx_moves =

View file

@ -51,7 +51,6 @@ pub struct DataFlowContext<'tcx, O> {
// `id_range`, there is a range of words equal to `words_per_id`.
// So, to access the bits for any given id, you take a slice of
// the full vector (see the method `compute_id_range()`).
/// bits generated as we exit the cfg node. Updated by `add_gen()`.
gens: Vec<usize>,
@ -82,7 +81,7 @@ pub trait DataFlowOperator : BitwiseOperator {
struct PropagationContext<'a, 'tcx, O> {
dfcx: &'a mut DataFlowContext<'tcx, O>,
changed: bool
changed: bool,
}
fn get_cfg_indices<'a>(id: hir::ItemLocalId,
@ -98,7 +97,7 @@ impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> {
}
}
impl<'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'tcx, O> {
impl<'tcx, O: DataFlowOperator> pprust::PpAnn for DataFlowContext<'tcx, O> {
fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> {
pprust::PpAnn::nested(self.tcx.hir(), state, nested)
}
@ -225,12 +224,14 @@ pub enum KillFrom {
}
impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>,
analysis_name: &'static str,
body: Option<&hir::Body>,
cfg: &cfg::CFG,
oper: O,
bits_per_id: usize) -> DataFlowContext<'tcx, O> {
pub fn new(
tcx: TyCtxt<'tcx, 'tcx>,
analysis_name: &'static str,
body: Option<&hir::Body>,
cfg: &cfg::CFG,
oper: O,
bits_per_id: usize,
) -> DataFlowContext<'tcx, O> {
let usize_bits = mem::size_of::<usize>() * 8;
let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
let num_nodes = cfg.graph.all_nodes().len();

View file

@ -61,11 +61,14 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
}
}
fn build_set<O:DataFlowOperator, F>(&self,
e: EntryOrExit,
cfgidx: CFGIndex,
dfcx: &DataFlowContext<'tcx, O>,
mut to_lp: F) -> String where
fn build_set<O: DataFlowOperator, F>(
&self,
e: EntryOrExit,
cfgidx: CFGIndex,
dfcx: &DataFlowContext<'tcx, O>,
mut to_lp: F,
) -> String
where
F: FnMut(usize) -> Rc<LoanPath<'tcx>>,
{
let mut saw_some = false;

View file

@ -44,7 +44,7 @@ use crate::value::Value;
pub fn write_compressed_metadata<'a, 'gcx>(
tcx: TyCtxt<'gcx, 'gcx>,
metadata: &EncodedMetadata,
llvm_module: &mut ModuleLlvm
llvm_module: &mut ModuleLlvm,
) {
use std::io::Write;
use flate2::Compression;

View file

@ -47,8 +47,8 @@ pub struct CodegenCx<'ll, 'tcx: 'll> {
/// Cache instances of monomorphic and polymorphic items
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
/// Cache generated vtables
pub vtables: RefCell<FxHashMap<
(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
pub vtables:
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
/// Cache of constant strings,
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
@ -207,10 +207,11 @@ pub unsafe fn create_module(
}
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
crate fn new(tcx: TyCtxt<'tcx, 'tcx>,
codegen_unit: Arc<CodegenUnit<'tcx>>,
llvm_module: &'ll crate::ModuleLlvm)
-> Self {
crate fn new(
tcx: TyCtxt<'tcx, 'tcx>,
codegen_unit: Arc<CodegenUnit<'tcx>>,
llvm_module: &'ll crate::ModuleLlvm,
) -> Self {
// An interesting part of Windows which MSVC forces our hand on (and
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
// attributes in LLVM IR as well as native dependencies (in C these

View file

@ -894,10 +894,11 @@ fn pointer_type_metadata(
}
}
pub fn compile_unit_metadata(tcx: TyCtxt<'_, '_>,
codegen_unit_name: &str,
debug_context: &CrateDebugContext<'ll, '_>)
-> &'ll DIDescriptor {
pub fn compile_unit_metadata(
tcx: TyCtxt<'_, '_>,
codegen_unit_name: &str,
debug_context: &CrateDebugContext<'ll, '_>,
) -> &'ll DIDescriptor {
let mut name_in_debuginfo = match tcx.sess.local_crate_source_file {
Some(ref path) => path.clone(),
None => PathBuf::from(&*tcx.crate_name(LOCAL_CRATE).as_str()),

View file

@ -111,7 +111,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
&self,
tcx: TyCtxt<'gcx, 'gcx>,
metadata: &EncodedMetadata,
llvm_module: &mut ModuleLlvm
llvm_module: &mut ModuleLlvm,
) {
base::write_compressed_metadata(tcx, metadata, llvm_module)
}
@ -119,7 +119,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
&self,
tcx: TyCtxt<'gcx, 'gcx>,
mods: &mut ModuleLlvm,
kind: AllocatorKind
kind: AllocatorKind,
) {
unsafe { allocator::codegen(tcx, mods, kind) }
}
@ -289,7 +289,7 @@ impl CodegenBackend for LlvmCodegenBackend {
tcx: TyCtxt<'tcx, 'tcx>,
metadata: EncodedMetadata,
need_metadata_module: bool,
rx: mpsc::Receiver<Box<dyn Any + Send>>
rx: mpsc::Receiver<Box<dyn Any + Send>>,
) -> Box<dyn Any> {
box rustc_codegen_ssa::base::codegen_crate(
LlvmCodegenBackend(()), tcx, metadata, need_metadata_module, rx)

View file

@ -46,10 +46,10 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor
}
}
fn reachable_non_generics_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum)
-> &'tcx DefIdMap<SymbolExportLevel>
{
fn reachable_non_generics_provider<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum,
) -> &'tcx DefIdMap<SymbolExportLevel> {
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
@ -157,9 +157,7 @@ fn reachable_non_generics_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
tcx.arena.alloc(reachable_non_generics)
}
fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> bool {
fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
let export_threshold = threshold(tcx);
if let Some(&level) = tcx.reachable_non_generics(def_id.krate).get(&def_id) {
@ -169,17 +167,14 @@ fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
}
}
fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> bool {
fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
tcx.reachable_non_generics(def_id.krate).contains_key(&def_id)
}
fn exported_symbols_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum)
-> Arc<Vec<(ExportedSymbol<'tcx>,
SymbolExportLevel)>>
{
fn exported_symbols_provider_local<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum,
) -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
@ -280,9 +275,8 @@ fn exported_symbols_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
fn upstream_monomorphizations_provider<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum)
-> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>>
{
cnum: CrateNum,
) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
debug_assert!(cnum == LOCAL_CRATE);
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
@ -330,9 +324,8 @@ fn upstream_monomorphizations_provider<'tcx>(
fn upstream_monomorphizations_for_provider<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId)
-> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
{
def_id: DefId,
) -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
debug_assert!(!def_id.is_local());
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
}

View file

@ -378,7 +378,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
tcx: TyCtxt<'_, '_>,
metadata: EncodedMetadata,
coordinator_receive: Receiver<Box<dyn Any + Send>>,
total_cgus: usize
total_cgus: usize,
) -> OngoingCodegen<B> {
let sess = tcx.sess;
let crate_name = tcx.crate_name(LOCAL_CRATE);
@ -1005,7 +1005,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
jobserver: Client,
modules_config: Arc<ModuleConfig>,
metadata_config: Arc<ModuleConfig>,
allocator_config: Arc<ModuleConfig>
allocator_config: Arc<ModuleConfig>,
) -> thread::JoinHandle<Result<CompiledModules, ()>> {
let coordinator_send = tcx.tx_to_llvm_workers.lock().clone();
let sess = tcx.sess;
@ -1861,9 +1861,11 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
}, work_products)
}
pub fn submit_pre_codegened_module_to_llvm(&self,
tcx: TyCtxt<'_, '_>,
module: ModuleCodegen<B::Module>) {
pub fn submit_pre_codegened_module_to_llvm(
&self,
tcx: TyCtxt<'_, '_>,
module: ModuleCodegen<B::Module>,
) {
self.wait_for_signal_to_codegen_item();
self.check_for_errors(tcx.sess);
@ -1913,7 +1915,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tcx: TyCtxt<'_, '_>,
module: ModuleCodegen<B::Module>,
cost: u64
cost: u64,
) {
let llvm_work_item = WorkItem::Optimize(module);
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
@ -1925,7 +1927,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tcx: TyCtxt<'_, '_>,
module: CachedModuleCodegen
module: CachedModuleCodegen,
) {
let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module);
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
@ -1937,7 +1939,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tcx: TyCtxt<'_, '_>,
module: CachedModuleCodegen
module: CachedModuleCodegen,
) {
let filename = pre_lto_bitcode_filename(&module.name);
let bc_path = in_incr_comp_dir_sess(tcx.sess, &filename);

View file

@ -483,9 +483,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
tcx: TyCtxt<'tcx, 'tcx>,
metadata: EncodedMetadata,
need_metadata_module: bool,
rx: mpsc::Receiver<Box<dyn Any + Send>>
rx: mpsc::Receiver<Box<dyn Any + Send>>,
) -> OngoingCodegen<B> {
check_for_rustc_errors_attr(tcx);
// Skip crate items and just output metadata in -Z no-codegen mode.
@ -776,7 +775,7 @@ impl CrateInfo {
info.missing_lang_items.insert(cnum, missing);
}
return info
return info;
}
}
@ -850,9 +849,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
};
}
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
cgu: &CodegenUnit<'tcx>)
-> CguReuse {
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
if !tcx.dep_graph.is_fully_enabled() {
return CguReuse::No
}

View file

@ -122,11 +122,7 @@ mod temp_stable_hash_impls {
}
}
pub fn langcall(tcx: TyCtxt<'_, '_>,
span: Option<Span>,
msg: &str,
li: LangItem)
-> DefId {
pub fn langcall(tcx: TyCtxt<'_, '_>, span: Option<Span>, msg: &str, li: LangItem) -> DefId {
tcx.lang_items().require(li).unwrap_or_else(|s| {
let msg = format!("{} {}", msg, s);
match span {

View file

@ -8,10 +8,11 @@ use rustc_data_structures::fx::FxHashSet;
// any caching, i.e., calling the function twice with the same type will also do
// the work twice. The `qualified` parameter only affects the first level of the
// type name, further levels (i.e., type parameters) are always fully qualified.
pub fn compute_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool)
-> String {
pub fn compute_debuginfo_type_name<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool,
) -> String {
let mut result = String::with_capacity(64);
let mut visited = FxHashSet::default();
push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited);
@ -20,12 +21,13 @@ pub fn compute_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
// Pushes the name of the type as it should be stored in debuginfo on the
// `output` String. See also compute_debuginfo_type_name().
pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool,
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>) {
pub fn push_debuginfo_type_name<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool,
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>,
) {
// When targeting MSVC, emit C++ style type names for compatibility with
// .natvis visualizers (and perhaps other existing native debuggers?)
let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
@ -208,10 +210,12 @@ pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
}
}
fn push_item_name(tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId,
qualified: bool,
output: &mut String) {
fn push_item_name(
tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId,
qualified: bool,
output: &mut String,
) {
if qualified {
output.push_str(&tcx.crate_name(def_id.krate).as_str());
for path_element in tcx.def_path(def_id).data {
@ -228,10 +232,12 @@ pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
// reconstructed for items from non-local crates. For local crates, this
// would be possible but with inlining and LTO we have to use the least
// common denominator - otherwise we would run into conflicts.
fn push_type_params<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
substs: SubstsRef<'tcx>,
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>) {
fn push_type_params<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
substs: SubstsRef<'tcx>,
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>,
) {
if substs.types().next().is_none() {
return;
}

View file

@ -42,13 +42,9 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
&self,
tcx: TyCtxt<'gcx, 'gcx>,
mods: &mut Self::Module,
kind: AllocatorKind
);
fn compile_codegen_unit<'a, 'tcx: 'a>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
cgu_name: InternedString,
kind: AllocatorKind,
);
fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx, 'tcx>, cgu_name: InternedString);
// If find_features is true this won't access `sess.crate_types` by assuming
// that `is_pie_binary` is false. When we discover LLVM target features
// `sess.crate_types` is uninitialized so we cannot access it.

View file

@ -6,7 +6,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
#![feature(box_syntax)]
use std::any::Any;
@ -39,7 +38,7 @@ pub trait CodegenBackend {
tcx: TyCtxt<'tcx, 'tcx>,
metadata: EncodedMetadata,
need_metadata_module: bool,
rx: mpsc::Receiver<Box<dyn Any + Send>>
rx: mpsc::Receiver<Box<dyn Any + Send>>,
) -> Box<dyn Any>;
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`

View file

@ -154,12 +154,14 @@ pub fn parse_pretty(sess: &Session,
impl PpSourceMode {
/// Constructs a `PrinterSupport` object and passes it to `f`.
fn call_with_pp_support<'tcx, A, F>(&self,
sess: &'tcx Session,
tcx: Option<TyCtxt<'tcx, 'tcx>>,
f: F)
-> A
where F: FnOnce(&dyn PrinterSupport) -> A
fn call_with_pp_support<'tcx, A, F>(
&self,
sess: &'tcx Session,
tcx: Option<TyCtxt<'tcx, 'tcx>>,
f: F,
) -> A
where
F: FnOnce(&dyn PrinterSupport) -> A,
{
match *self {
PpmNormal | PpmEveryBodyLoops | PpmExpanded => {
@ -186,12 +188,9 @@ impl PpSourceMode {
_ => panic!("Should use call_with_pp_support_hir"),
}
}
fn call_with_pp_support_hir<'tcx, A, F>(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
f: F
) -> A
where F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A
fn call_with_pp_support_hir<'tcx, A, F>(&self, tcx: TyCtxt<'tcx, 'tcx>, f: F) -> A
where
F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A,
{
match *self {
PpmNormal => {
@ -454,7 +453,6 @@ impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
}
}
struct TypedAnnotation<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx>,
tables: Cell<&'a ty::TypeckTables<'tcx>>,
@ -617,12 +615,13 @@ impl UserIdentifiedItem {
}
}
fn print_flowgraph<'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
tcx: TyCtxt<'tcx, 'tcx>,
code: blocks::Code<'tcx>,
mode: PpFlowGraphMode,
mut out: W)
-> io::Result<()> {
fn print_flowgraph<'tcx, W: Write>(
variants: Vec<borrowck_dot::Variant>,
tcx: TyCtxt<'tcx, 'tcx>,
code: blocks::Code<'tcx>,
mode: PpFlowGraphMode,
mut out: W,
) -> io::Result<()> {
let body_id = match code {
blocks::Code::Expr(expr) => {
// Find the function this expression is from.
@ -760,7 +759,8 @@ pub fn print_after_hir_lowering<'tcx>(
krate: &ast::Crate,
ppm: PpMode,
opt_uii: Option<UserIdentifiedItem>,
ofile: Option<&Path>) {
ofile: Option<&Path>,
) {
if ppm.needs_analysis() {
abort_on_err(print_with_analysis(
tcx,
@ -869,7 +869,7 @@ fn print_with_analysis<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ppm: PpMode,
uii: Option<UserIdentifiedItem>,
ofile: Option<&Path>
ofile: Option<&Path>,
) -> Result<(), ErrorReported> {
let nodeid = if let Some(uii) = uii {
debug!("pretty printing for {:?}", uii);

View file

@ -184,10 +184,11 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> {
}
}
fn check_paths<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
if_this_changed: &Sources,
then_this_would_need: &Targets)
{
fn check_paths<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
if_this_changed: &Sources,
then_this_would_need: &Targets,
) {
// Return early here so as not to construct the query, which is not cheap.
if if_this_changed.is_empty() {
for &(target_span, _, _, _) in then_this_would_need {

View file

@ -129,8 +129,7 @@ fn save_in<F>(sess: &Session, path_buf: PathBuf, encode: F)
}
}
fn encode_dep_graph(tcx: TyCtxt<'_, '_>,
encoder: &mut Encoder) {
fn encode_dep_graph(tcx: TyCtxt<'_, '_>, encoder: &mut Encoder) {
// First encode the commandline arguments hash
tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap();
@ -234,8 +233,7 @@ fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduc
serialized_products.encode(encoder).unwrap();
}
fn encode_query_cache(tcx: TyCtxt<'_, '_>,
encoder: &mut Encoder) {
fn encode_query_cache(tcx: TyCtxt<'_, '_>, encoder: &mut Encoder) {
time(tcx.sess, "serialize query result cache", || {
tcx.serialize_query_result_cache(encoder).unwrap();
})

View file

@ -798,7 +798,7 @@ declare_box_region_type!(
impl BoxedGlobalCtxt {
pub fn enter<F, R>(&mut self, f: F) -> R
where
F: for<'tcx> FnOnce(TyCtxt<'tcx, 'tcx>) -> R
F: for<'tcx> FnOnce(TyCtxt<'tcx, 'tcx>) -> R,
{
self.access(|gcx| ty::tls::enter_global(gcx, |tcx| f(tcx)))
}
@ -878,10 +878,7 @@ pub fn create_global_ctxt(
/// Runs the resolution, type-checking, region checking and other
/// miscellaneous analysis passes on the crate.
fn analysis<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum,
) -> Result<()> {
fn analysis<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Result<()> {
assert_eq!(cnum, LOCAL_CRATE);
let sess = tcx.sess;

View file

@ -10,10 +10,7 @@ pub fn find<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option<DefId> {
tcx.proc_macro_decls_static(LOCAL_CRATE)
}
fn proc_macro_decls_static<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
cnum: CrateNum,
) -> Option<DefId> {
fn proc_macro_decls_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);
let mut finder = Finder { decls: None };

View file

@ -555,11 +555,12 @@ fn ty_is_known_nonnull<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
/// to function pointers, references, core::num::NonZero*,
/// core::ptr::NonNull, and #[repr(transparent)] newtypes.
/// FIXME: This duplicates code in codegen.
fn is_repr_nullable_ptr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
ty_def: &'tcx ty::AdtDef,
substs: SubstsRef<'tcx>)
-> bool {
fn is_repr_nullable_ptr<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
ty_def: &'tcx ty::AdtDef,
substs: SubstsRef<'tcx>,
) -> bool {
if ty_def.variants.len() != 2 {
return false;
}

View file

@ -314,7 +314,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
fn add_query_description_impl(
query: &Query,
modifiers: QueryModifiers,
impls: &mut proc_macro2::TokenStream
impls: &mut proc_macro2::TokenStream,
) {
let name = &query.name;
let arg = &query.arg;

View file

@ -550,10 +550,7 @@ impl CrateStore for cstore::CStore {
self.do_postorder_cnums_untracked()
}
fn encode_metadata<'tcx>(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> EncodedMetadata
{
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata {
encoder::encode_metadata(tcx)
}

View file

@ -55,7 +55,9 @@ pub trait Metadata<'a, 'tcx>: Copy {
fn raw_bytes(self) -> &'a [u8];
fn cdata(self) -> Option<&'a CrateMetadata> { None }
fn sess(self) -> Option<&'a Session> { None }
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> { None }
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> {
None
}
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
let tcx = self.tcx();
@ -170,7 +172,6 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
}
impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
#[inline]
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx.expect("missing TyCtxt in DecodeContext")
@ -551,7 +552,7 @@ impl<'a, 'tcx> CrateMetadata {
item: &Entry<'_>,
index: DefIndex,
parent_did: DefId,
adt_kind: ty::AdtKind
adt_kind: ty::AdtKind,
) -> ty::VariantDef {
let data = match item.kind {
EntryKind::Variant(data) |
@ -588,10 +589,7 @@ impl<'a, 'tcx> CrateMetadata {
)
}
pub fn get_adt_def(&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> &'tcx ty::AdtDef {
pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> &'tcx ty::AdtDef {
let item = self.entry(item_id);
let did = self.local_def_id(item_id);
@ -616,24 +614,27 @@ impl<'a, 'tcx> CrateMetadata {
tcx.alloc_adt_def(did, kind, variants, repr)
}
pub fn get_predicates(&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> ty::GenericPredicates<'tcx> {
pub fn get_predicates(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.entry(item_id).predicates.unwrap().decode((self, tcx))
}
pub fn get_predicates_defined_on(&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> ty::GenericPredicates<'tcx> {
pub fn get_predicates_defined_on(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
}
pub fn get_super_predicates(&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> ty::GenericPredicates<'tcx> {
pub fn get_super_predicates(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
) -> ty::GenericPredicates<'tcx> {
let super_predicates = match self.entry(item_id).kind {
EntryKind::Trait(data) => data.decode(self).super_predicates,
EntryKind::TraitAlias(data) => data.decode(self).super_predicates,
@ -700,10 +701,11 @@ impl<'a, 'tcx> CrateMetadata {
self.get_impl_data(id).coerce_unsized_info
}
pub fn get_impl_trait(&self,
id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> Option<ty::TraitRef<'tcx>> {
pub fn get_impl_trait(
&self,
id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
) -> Option<ty::TraitRef<'tcx>> {
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
}
@ -720,10 +722,7 @@ impl<'a, 'tcx> CrateMetadata {
}
/// Iterates over the language items in the given crate.
pub fn get_lang_items(
&self,
tcx: TyCtxt<'tcx, '_>,
) -> &'tcx [(DefId, usize)] {
pub fn get_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [(DefId, usize)] {
if self.proc_macros.is_some() {
// Proc macro crates do not export any lang-items to the target.
&[]
@ -884,10 +883,11 @@ impl<'a, 'tcx> CrateMetadata {
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
}
pub fn maybe_get_optimized_mir(&self,
tcx: TyCtxt<'tcx, 'tcx>,
id: DefIndex)
-> Option<Body<'tcx>> {
pub fn maybe_get_optimized_mir(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
id: DefIndex,
) -> Option<Body<'tcx>> {
match self.is_proc_macro(id) {
true => None,
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),
@ -1020,7 +1020,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_inherent_implementations_for_type(
&self,
tcx: TyCtxt<'tcx, '_>,
id: DefIndex
id: DefIndex,
) -> &'tcx [DefId] {
tcx.arena.alloc_from_iter(self.entry(id)
.inherent_impls
@ -1085,10 +1085,7 @@ impl<'a, 'tcx> CrateMetadata {
}
}
pub fn get_foreign_modules(
&self,
tcx: TyCtxt<'tcx, '_>,
) -> &'tcx [ForeignModule] {
pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [ForeignModule] {
if self.proc_macros.is_some() {
// Proc macro crates do not have any *target* foreign modules.
&[]
@ -1111,10 +1108,7 @@ impl<'a, 'tcx> CrateMetadata {
}))
}
pub fn get_missing_lang_items(
&self,
tcx: TyCtxt<'tcx, '_>,
) -> &'tcx [lang_items::LangItem] {
pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [lang_items::LangItem] {
if self.proc_macros.is_some() {
// Proc macro crates do not depend on any target weak lang-items.
&[]
@ -1135,9 +1129,10 @@ impl<'a, 'tcx> CrateMetadata {
arg_names.decode(self).collect()
}
pub fn exported_symbols(&self,
tcx: TyCtxt<'tcx, 'tcx>)
-> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
pub fn exported_symbols(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
if self.proc_macros.is_some() {
// If this crate is a custom derive crate, then we're not even going to
// link those in so we skip those crates.
@ -1192,10 +1187,7 @@ impl<'a, 'tcx> CrateMetadata {
}
}
pub fn fn_sig(&self,
id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>)
-> ty::PolyFnSig<'tcx> {
pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
let sig = match self.entry(id).kind {
EntryKind::Fn(data) |
EntryKind::ForeignFn(data) => data.decode(self).sig,

View file

@ -217,8 +217,7 @@ impl<'tcx> SpecializedEncoder<Fingerprint> for EncodeContext<'tcx> {
}
}
impl<'tcx, T: Encodable> SpecializedEncoder<mir::ClearCrossCrate<T>>
for EncodeContext<'tcx> {
impl<'tcx, T: Encodable> SpecializedEncoder<mir::ClearCrossCrate<T>> for EncodeContext<'tcx> {
fn specialized_encode(&mut self,
_: &mir::ClearCrossCrate<T>)
-> Result<(), Self::Error> {
@ -233,7 +232,6 @@ impl<'tcx> TyEncoder for EncodeContext<'tcx> {
}
impl<'tcx> EncodeContext<'tcx> {
fn emit_node<F: FnOnce(&mut Self, usize) -> R, R>(&mut self, f: F) -> R {
assert_eq!(self.lazy_state, LazyState::NoNode);
let pos = self.position();
@ -1865,9 +1863,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
// will allow us to slice the metadata to the precise length that we just
// generated regardless of trailing bytes that end up in it.
pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>)
-> EncodedMetadata
{
pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata {
let mut encoder = opaque::Encoder::new(vec![]);
encoder.emit_raw_bytes(METADATA_HEADER);

View file

@ -9,7 +9,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<ForeignModule> {
modules: Vec::new(),
};
tcx.hir().krate().visit_all_item_likes(&mut collector);
return collector.modules
return collector.modules;
}
struct Collector<'tcx> {

View file

@ -18,7 +18,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<String> {
}
}
return collector.args
return collector.args;
}
struct Collector {

View file

@ -18,7 +18,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<NativeLibrary> {
};
tcx.hir().krate().visit_all_item_likes(&mut collector);
collector.process_command_line();
return collector.libs
return collector.libs;
}
pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {

View file

@ -125,9 +125,8 @@ impl<'tcx> BorrowSet<'tcx> {
tcx: TyCtxt<'_, 'tcx>,
body: &Body<'tcx>,
locals_are_invalidated_at_exit: bool,
move_data: &MoveData<'tcx>
move_data: &MoveData<'tcx>,
) -> Self {
let mut visitor = GatherBorrows {
tcx,
body,

View file

@ -22,7 +22,7 @@ pub(super) enum Control {
}
/// Encapsulates the idea of iterating over every borrow that involves a particular path
pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S> (
pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S>(
s: &mut S,
tcx: TyCtxt<'gcx, 'tcx>,
body: &Body<'tcx>,
@ -33,7 +33,7 @@ pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S> (
mut op: F,
) where
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control,
I: Iterator<Item=BorrowIndex>
I: Iterator<Item = BorrowIndex>,
{
let (access, place) = access_place;

View file

@ -15,7 +15,7 @@ crate trait PlaceExt<'tcx> {
tcx: TyCtxt<'_, 'tcx>,
body: &Body<'tcx>,
locals_state_at_exit: &LocalsStateAtExit,
) -> bool;
) -> bool;
}
impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {

View file

@ -186,7 +186,7 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> {
/// can change `'tcx` so we have to transmute afterwards.
struct GlobalizeMir<'gcx> {
tcx: TyCtxt<'gcx, 'gcx>,
span: Span
span: Span,
}
impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> {
@ -234,10 +234,11 @@ impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> {
///////////////////////////////////////////////////////////////////////////
// BuildMir -- walks a crate, looking for fn items and methods to build MIR from
fn liberated_closure_env_ty<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
closure_expr_id: hir::HirId,
body_id: hir::BodyId)
-> Ty<'tcx> {
fn liberated_closure_env_ty<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
closure_expr_id: hir::HirId,
body_id: hir::BodyId,
) -> Ty<'tcx> {
let closure_ty = tcx.body_tables(body_id).node_type(closure_expr_id);
let (closure_def_id, closure_substs) = match closure_ty.sty {
@ -551,10 +552,7 @@ macro_rules! unpack {
};
}
fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
fn_def_id: DefId,
abi: Abi)
-> bool {
fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool {
// Not callable from C, so we can safely unwind through these
if abi == Abi::Rust || abi == Abi::RustCall { return false; }

View file

@ -308,9 +308,7 @@ impl interpret::MayLeak for ! {
}
}
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx>
for CompileTimeInterpreter<'mir, 'tcx>
{
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 'tcx> {
type MemoryKinds = !;
type PointerTag = ();
@ -454,18 +452,13 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx>
}
#[inline(always)]
fn stack_push(
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
) -> InterpResult<'tcx> {
fn stack_push(_ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
Ok(())
}
/// Called immediately before a stack frame gets popped.
#[inline(always)]
fn stack_pop(
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
_extra: (),
) -> InterpResult<'tcx> {
fn stack_pop(_ecx: &mut InterpretCx<'mir, 'tcx, Self>, _extra: ()) -> InterpResult<'tcx> {
Ok(())
}
}
@ -511,7 +504,7 @@ pub fn const_variant_index<'tcx>(
pub fn error_to_const_error<'mir, 'tcx>(
ecx: &InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
mut error: InterpErrorInfo<'tcx>
mut error: InterpErrorInfo<'tcx>,
) -> ConstEvalErr<'tcx> {
error.print_backtrace();
let stacktrace = ecx.generate_stacktrace(None);

View file

@ -46,9 +46,11 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
/// is no need to maintain separate drop flags to track such state.
//
// FIXME: we have to do something for moving slice patterns.
fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
body: &Body<'tcx>,
place: &mir::Place<'tcx>) -> bool {
fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
body: &Body<'tcx>,
place: &mir::Place<'tcx>,
) -> bool {
let ty = place.ty(body, tcx).ty;
match ty.sty {
ty::Array(..) => {
@ -77,8 +79,9 @@ pub(crate) fn on_lookup_result_bits<'gcx, 'tcx, F>(
body: &Body<'tcx>,
move_data: &MoveData<'tcx>,
lookup_result: LookupResult,
each_child: F)
where F: FnMut(MovePathIndex)
each_child: F,
) where
F: FnMut(MovePathIndex),
{
match lookup_result {
LookupResult::Parent(..) => {
@ -95,15 +98,16 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>(
body: &Body<'tcx>,
move_data: &MoveData<'tcx>,
move_path_index: MovePathIndex,
mut each_child: F)
where F: FnMut(MovePathIndex)
mut each_child: F,
) where
F: FnMut(MovePathIndex),
{
fn is_terminal_path<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
body: &Body<'tcx>,
move_data: &MoveData<'tcx>,
path: MovePathIndex) -> bool
{
path: MovePathIndex,
) -> bool {
place_contents_drop_state_cannot_differ(
tcx, body, &move_data.move_paths[path].place)
}
@ -113,8 +117,9 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>(
body: &Body<'tcx>,
move_data: &MoveData<'tcx>,
move_path_index: MovePathIndex,
each_child: &mut F)
where F: FnMut(MovePathIndex)
each_child: &mut F,
) where
F: FnMut(MovePathIndex),
{
each_child(move_path_index);
@ -136,8 +141,9 @@ pub(crate) fn on_all_drop_children_bits<'gcx, 'tcx, F>(
body: &Body<'tcx>,
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
path: MovePathIndex,
mut each_child: F)
where F: FnMut(MovePathIndex)
mut each_child: F,
) where
F: FnMut(MovePathIndex),
{
on_all_children_bits(tcx, body, &ctxt.move_data, path, |child| {
let place = &ctxt.move_data.move_paths[path].place;
@ -158,8 +164,9 @@ pub(crate) fn drop_flag_effects_for_function_entry<'gcx, 'tcx, F>(
tcx: TyCtxt<'gcx, 'tcx>,
body: &Body<'tcx>,
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
mut callback: F)
where F: FnMut(MovePathIndex, DropFlagState)
mut callback: F,
) where
F: FnMut(MovePathIndex, DropFlagState),
{
let move_data = &ctxt.move_data;
for arg in body.args_iter() {
@ -176,8 +183,9 @@ pub(crate) fn drop_flag_effects_for_location<'gcx, 'tcx, F>(
body: &Body<'tcx>,
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
loc: Location,
mut callback: F)
where F: FnMut(MovePathIndex, DropFlagState)
mut callback: F,
) where
F: FnMut(MovePathIndex, DropFlagState),
{
let move_data = &ctxt.move_data;
debug!("drop_flag_effects_for_location({:?})", loc);
@ -208,8 +216,9 @@ pub(crate) fn for_location_inits<'gcx, 'tcx, F>(
body: &Body<'tcx>,
move_data: &MoveData<'tcx>,
loc: Location,
mut callback: F)
where F: FnMut(MovePathIndex)
mut callback: F,
) where
F: FnMut(MovePathIndex),
{
for ii in &move_data.init_loc_map[loc] {
let init = move_data.inits[*ii];

View file

@ -70,11 +70,11 @@ pub struct MaybeInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
}
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
-> Self
{
pub fn new(
tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
) -> Self {
MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -125,11 +125,11 @@ pub struct MaybeUninitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
}
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
-> Self
{
pub fn new(
tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
) -> Self {
MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -179,11 +179,11 @@ pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
}
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
-> Self
{
pub fn new(
tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
) -> Self {
DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -228,11 +228,11 @@ pub struct EverInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
}
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
-> Self
{
pub fn new(
tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
) -> Self {
EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}

View file

@ -121,29 +121,36 @@ pub struct MoveDataParamEnv<'gcx, 'tcx> {
pub(crate) param_env: ty::ParamEnv<'gcx>,
}
pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
def_id: DefId,
attributes: &[ast::Attribute],
dead_unwinds: &BitSet<BasicBlock>,
bd: BD,
p: P)
-> DataflowResults<'tcx, BD>
where BD: BitDenotation<'tcx> + InitialFlow,
P: Fn(&BD, BD::Idx) -> DebugFormatted
pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(
tcx: TyCtxt<'gcx, 'tcx>,
body: &'a Body<'tcx>,
def_id: DefId,
attributes: &[ast::Attribute],
dead_unwinds: &BitSet<BasicBlock>,
bd: BD,
p: P,
) -> DataflowResults<'tcx, BD>
where
BD: BitDenotation<'tcx> + InitialFlow,
P: Fn(&BD, BD::Idx) -> DebugFormatted,
{
let flow_state = DataflowAnalysis::new(body, dead_unwinds, bd);
flow_state.run(tcx, def_id, attributes, p)
}
impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>,
{
pub(crate) fn run<P>(self,
tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId,
attributes: &[ast::Attribute],
p: P) -> DataflowResults<'tcx, BD>
where P: Fn(&BD, BD::Idx) -> DebugFormatted
pub(crate) fn run<P>(
self,
tcx: TyCtxt<'gcx, 'tcx>,
def_id: DefId,
attributes: &[ast::Attribute],
p: P,
) -> DataflowResults<'tcx, BD>
where
P: Fn(&BD, BD::Idx) -> DebugFormatted,
{
let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option<String> {
if let Some(item) = has_rustc_mir_with(attrs, name) {

View file

@ -204,7 +204,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
pub(super) fn gather_moves<'gcx, 'tcx>(
body: &Body<'tcx>,
tcx: TyCtxt<'gcx, 'tcx>
tcx: TyCtxt<'gcx, 'tcx>,
) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
let mut builder = MoveDataBuilder::new(body, tcx);

Some files were not shown because too many files have changed in this diff Show more