Skip to content

Commit

Permalink
Remove OpaqueTyOrigin::Misc, use TyAlias instead
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 18, 2021
1 parent d983845 commit 000b945
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Expand Up @@ -280,7 +280,7 @@ enum ImplTraitContext<'b, 'a> {
// FIXME(impl_trait): but `required_region_bounds` will ICE later
// anyway.
capturable_lifetimes: &'b mut FxHashSet<hir::LifetimeName>,
/// Origin: Either OpaqueTyOrigin::TyAlias or OpaqueTyOrigin::Misc,
/// Origin: OpaqueTyOrigin::TyAlias
origin: hir::OpaqueTyOrigin,
},
/// `impl Trait` is not accepted in this position.
Expand Down Expand Up @@ -1152,7 +1152,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
true,
ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut capturable_lifetimes,
origin: hir::OpaqueTyOrigin::Misc,
origin: hir::OpaqueTyOrigin::TyAlias,
},
)
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Expand Up @@ -2272,8 +2272,6 @@ pub enum OpaqueTyOrigin {
AsyncFn,
/// type aliases: `type Foo = impl Trait;`
TyAlias,
/// Impl trait consts, statics, bounds.
Misc,
}

/// The various kinds of types recognized by the compiler.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/opaque_types.rs
Expand Up @@ -402,7 +402,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
}
// These opaque type inherit all lifetime parameters from their
// parent, so we have to check them all.
hir::OpaqueTyOrigin::TyAlias | hir::OpaqueTyOrigin::Misc => 0,
hir::OpaqueTyOrigin::TyAlias => 0,
};

let span = tcx.def_span(def_id);
Expand Down Expand Up @@ -994,7 +994,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
may_define_opaque_type(tcx, self.parent_def_id, opaque_hir_id),
origin,
),
_ => (def_scope_default(), hir::OpaqueTyOrigin::Misc),
_ => (def_scope_default(), hir::OpaqueTyOrigin::TyAlias),
};
if in_definition_scope {
let opaque_type_key =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/check.rs
Expand Up @@ -700,7 +700,7 @@ fn check_opaque_meets_bounds<'tcx>(
// Checked when type checking the function containing them.
hir::OpaqueTyOrigin::FnReturn | hir::OpaqueTyOrigin::AsyncFn => return,
// Can have different predicates to their defining use
hir::OpaqueTyOrigin::Misc | hir::OpaqueTyOrigin::TyAlias => {}
hir::OpaqueTyOrigin::TyAlias => {}
}

let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/writeback.rs
Expand Up @@ -521,8 +521,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
let mut skip_add = false;

if let ty::Opaque(definition_ty_def_id, _substs) = *definition_ty.kind() {
if let hir::OpaqueTyOrigin::Misc | hir::OpaqueTyOrigin::TyAlias = opaque_defn.origin
{
if let hir::OpaqueTyOrigin::TyAlias = opaque_defn.origin {
if opaque_type_key.def_id == definition_ty_def_id {
debug!(
"skipping adding concrete definition for opaque type {:?} {:?}",
Expand Down

0 comments on commit 000b945

Please sign in to comment.