@@ -189,14 +189,14 @@ enum ImplTraitContext<'a> {
189189 /// Newly generated parameters should be inserted into the given `Vec`.
190190 Universal ( & ' a mut Vec < hir:: GenericParam > ) ,
191191
192- /// Treat `impl Trait` as shorthand for a new existential parameter .
192+ /// Treat `impl Trait` as shorthand for a new opaque type .
193193 /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
194- /// equivalent to a fresh existential parameter like `existential type T; fn foo() -> T`.
194+ /// equivalent to a new opaque type like `type T = impl Debug ; fn foo() -> T`.
195195 ///
196196 /// We optionally store a `DefId` for the parent item here so we can look up necessary
197197 /// information later. It is `None` when no information about the context should be stored
198198 /// (e.g., for consts and statics).
199- Existential ( Option < DefId > /* fn def-ID */ ) ,
199+ OpaqueTy ( Option < DefId > /* fn def-ID */ ) ,
200200
201201 /// `impl Trait` is not accepted in this position.
202202 Disallowed ( ImplTraitPosition ) ,
@@ -222,7 +222,7 @@ impl<'a> ImplTraitContext<'a> {
222222 use self :: ImplTraitContext :: * ;
223223 match self {
224224 Universal ( params) => Universal ( params) ,
225- Existential ( fn_def_id) => Existential ( * fn_def_id) ,
225+ OpaqueTy ( fn_def_id) => OpaqueTy ( * fn_def_id) ,
226226 Disallowed ( pos) => Disallowed ( * pos) ,
227227 }
228228 }
@@ -487,7 +487,7 @@ impl<'a> LoweringContext<'a> {
487487 | ItemKind :: Union ( _, ref generics)
488488 | ItemKind :: Enum ( _, ref generics)
489489 | ItemKind :: Ty ( _, ref generics)
490- | ItemKind :: Existential ( _, ref generics)
490+ | ItemKind :: OpaqueTy ( _, ref generics)
491491 | ItemKind :: Trait ( _, _, ref generics, ..) => {
492492 let def_id = self . lctx . resolver . definitions ( ) . local_def_id ( item. id ) ;
493493 let count = generics
@@ -1422,7 +1422,7 @@ impl<'a> LoweringContext<'a> {
14221422 // so desugar to
14231423 //
14241424 // fn foo() -> impl Iterator<Item = impl Debug>
1425- ImplTraitContext :: Existential ( _) => ( true , itctx) ,
1425+ ImplTraitContext :: OpaqueTy ( _) => ( true , itctx) ,
14261426
14271427 // We are in the argument position, but within a dyn type:
14281428 //
@@ -1436,11 +1436,11 @@ impl<'a> LoweringContext<'a> {
14361436 // In `type Foo = dyn Iterator<Item: Debug>` we desugar to
14371437 // `type Foo = dyn Iterator<Item = impl Debug>` but we have to override the
14381438 // "impl trait context" to permit `impl Debug` in this position (it desugars
1439- // then to an existential type).
1439+ // then to an opaque type).
14401440 //
14411441 // FIXME: this is only needed until `impl Trait` is allowed in type aliases.
14421442 ImplTraitContext :: Disallowed ( _) if self . is_in_dyn_type =>
1443- ( true , ImplTraitContext :: Existential ( None ) ) ,
1443+ ( true , ImplTraitContext :: OpaqueTy ( None ) ) ,
14441444
14451445 // We are in the argument position, but not within a dyn type:
14461446 //
@@ -1634,8 +1634,8 @@ impl<'a> LoweringContext<'a> {
16341634 TyKind :: ImplTrait ( def_node_id, ref bounds) => {
16351635 let span = t. span ;
16361636 match itctx {
1637- ImplTraitContext :: Existential ( fn_def_id) => {
1638- self . lower_existential_impl_trait (
1637+ ImplTraitContext :: OpaqueTy ( fn_def_id) => {
1638+ self . lower_opaque_impl_trait (
16391639 span, fn_def_id, def_node_id,
16401640 |this| this. lower_param_bounds ( bounds, itctx) ,
16411641 )
@@ -1717,7 +1717,7 @@ impl<'a> LoweringContext<'a> {
17171717 }
17181718 }
17191719
1720- fn lower_existential_impl_trait (
1720+ fn lower_opaque_impl_trait (
17211721 & mut self ,
17221722 span : Span ,
17231723 fn_def_id : Option < DefId > ,
@@ -1730,7 +1730,7 @@ impl<'a> LoweringContext<'a> {
17301730 // Not tracking it makes lints in rustc and clippy very fragile, as
17311731 // frequently opened issues show.
17321732 let exist_ty_span = self . mark_span_with_reason (
1733- DesugaringKind :: ExistentialType ,
1733+ DesugaringKind :: OpaqueTy ,
17341734 span,
17351735 None ,
17361736 ) ;
@@ -1763,11 +1763,11 @@ impl<'a> LoweringContext<'a> {
17631763 } ,
17641764 bounds : hir_bounds,
17651765 impl_trait_fn : fn_def_id,
1766- origin : hir:: ExistTyOrigin :: ReturnImplTrait ,
1766+ origin : hir:: OpaqueTyOrigin :: ReturnImplTrait ,
17671767 } ;
17681768
17691769 trace ! ( "exist ty from impl trait def-index: {:#?}" , exist_ty_def_index) ;
1770- let exist_ty_id = lctx. generate_existential_type (
1770+ let exist_ty_id = lctx. generate_opaque_type (
17711771 exist_ty_node_id,
17721772 exist_ty_item,
17731773 span,
@@ -1779,19 +1779,19 @@ impl<'a> LoweringContext<'a> {
17791779 } )
17801780 }
17811781
1782- /// Registers a new existential type with the proper `NodeId`s and
1783- /// returns the lowered node-ID for the existential type.
1784- fn generate_existential_type (
1782+ /// Registers a new opaque type with the proper `NodeId`s and
1783+ /// returns the lowered node-ID for the opaque type.
1784+ fn generate_opaque_type (
17851785 & mut self ,
17861786 exist_ty_node_id : NodeId ,
17871787 exist_ty_item : hir:: ExistTy ,
17881788 span : Span ,
17891789 exist_ty_span : Span ,
17901790 ) -> hir:: HirId {
1791- let exist_ty_item_kind = hir:: ItemKind :: Existential ( exist_ty_item) ;
1791+ let exist_ty_item_kind = hir:: ItemKind :: OpaqueTy ( exist_ty_item) ;
17921792 let exist_ty_id = self . lower_node_id ( exist_ty_node_id) ;
1793- // Generate an `existential type Foo: Trait;` declaration.
1794- trace ! ( "registering existential type with id {:#?}" , exist_ty_id) ;
1793+ // Generate an `type Foo = impl Trait;` declaration.
1794+ trace ! ( "registering opaque type with id {:#?}" , exist_ty_id) ;
17951795 let exist_ty_item = hir:: Item {
17961796 hir_id : exist_ty_id,
17971797 ident : Ident :: invalid ( ) ,
@@ -1802,7 +1802,7 @@ impl<'a> LoweringContext<'a> {
18021802 } ;
18031803
18041804 // Insert the item into the global item list. This usually happens
1805- // automatically for all AST items. But this existential type item
1805+ // automatically for all AST items. But this opaque type item
18061806 // does not actually exist in the AST.
18071807 self . insert_item ( exist_ty_item) ;
18081808 exist_ty_id
@@ -2439,7 +2439,7 @@ impl<'a> LoweringContext<'a> {
24392439 . as_ref ( )
24402440 . map ( |t| self . lower_ty ( t,
24412441 if self . sess . features_untracked ( ) . impl_trait_in_bindings {
2442- ImplTraitContext :: Existential ( Some ( parent_def_id) )
2442+ ImplTraitContext :: OpaqueTy ( Some ( parent_def_id) )
24432443 } else {
24442444 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
24452445 }
@@ -2500,7 +2500,7 @@ impl<'a> LoweringContext<'a> {
25002500 let lt_mode = if make_ret_async. is_some ( ) {
25012501 // In `async fn`, argument-position elided lifetimes
25022502 // must be transformed into fresh generic parameters so that
2503- // they can be applied to the existential return type.
2503+ // they can be applied to the opaque `impl Trait` return type.
25042504 AnonymousLifetimeMode :: CreateParameter
25052505 } else {
25062506 self . anonymous_lifetime_mode
@@ -2539,7 +2539,7 @@ impl<'a> LoweringContext<'a> {
25392539 FunctionRetTy :: Ty ( ref ty) => match in_band_ty_params {
25402540 Some ( ( def_id, _) ) if impl_trait_return_allow => {
25412541 hir:: Return ( self . lower_ty ( ty,
2542- ImplTraitContext :: Existential ( Some ( def_id) )
2542+ ImplTraitContext :: OpaqueTy ( Some ( def_id) )
25432543 ) )
25442544 }
25452545 _ => {
@@ -2585,12 +2585,12 @@ impl<'a> LoweringContext<'a> {
25852585 // Transforms `-> T` for `async fn` into `-> ExistTy { .. }`
25862586 // combined with the following definition of `ExistTy`:
25872587 //
2588- // existential type ExistTy<generics_from_parent_fn>: Future<Output = T>;
2588+ // type ExistTy<generics_from_parent_fn> = impl Future<Output = T>;
25892589 //
25902590 // `inputs`: lowered types of arguments to the function (used to collect lifetimes)
25912591 // `output`: unlowered output type (`T` in `-> T`)
25922592 // `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition)
2593- // `exist_ty_node_id`: `NodeId` of the existential type that should be created
2593+ // `exist_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
25942594 // `elided_lt_replacement`: replacement for elided lifetimes in the return type
25952595 fn lower_async_fn_ret_ty (
25962596 & mut self ,
@@ -2626,7 +2626,7 @@ impl<'a> LoweringContext<'a> {
26262626 ) ;
26272627
26282628 // Calculate all the lifetimes that should be captured
2629- // by the existential type. This should include all in-scope
2629+ // by the opaque type. This should include all in-scope
26302630 // lifetime parameters, including those defined in-band.
26312631 //
26322632 // Note: this must be done after lowering the output type,
@@ -2657,11 +2657,11 @@ impl<'a> LoweringContext<'a> {
26572657 } ,
26582658 bounds : hir_vec ! [ future_bound] ,
26592659 impl_trait_fn : Some ( fn_def_id) ,
2660- origin : hir:: ExistTyOrigin :: AsyncFn ,
2660+ origin : hir:: OpaqueTyOrigin :: AsyncFn ,
26612661 } ;
26622662
26632663 trace ! ( "exist ty from async fn def index: {:#?}" , exist_ty_def_index) ;
2664- let exist_ty_id = this. generate_existential_type (
2664+ let exist_ty_id = this. generate_opaque_type (
26652665 exist_ty_node_id,
26662666 exist_ty_item,
26672667 span,
@@ -2702,7 +2702,7 @@ impl<'a> LoweringContext<'a> {
27022702 // Compute the `T` in `Future<Output = T>` from the return type.
27032703 let output_ty = match output {
27042704 FunctionRetTy :: Ty ( ty) => {
2705- self . lower_ty ( ty, ImplTraitContext :: Existential ( Some ( fn_def_id) ) )
2705+ self . lower_ty ( ty, ImplTraitContext :: OpaqueTy ( Some ( fn_def_id) ) )
27062706 }
27072707 FunctionRetTy :: Default ( ret_ty_span) => {
27082708 P ( hir:: Ty {
@@ -2905,7 +2905,7 @@ impl<'a> LoweringContext<'a> {
29052905
29062906 let kind = hir:: GenericParamKind :: Type {
29072907 default : default. as_ref ( ) . map ( |x| {
2908- self . lower_ty ( x, ImplTraitContext :: Existential ( None ) )
2908+ self . lower_ty ( x, ImplTraitContext :: OpaqueTy ( None ) )
29092909 } ) ,
29102910 synthetic : param. attrs . iter ( )
29112911 . filter ( |attr| attr. check_name ( sym:: rustc_synthetic) )
@@ -3384,7 +3384,7 @@ impl<'a> LoweringContext<'a> {
33843384 self . lower_ty (
33853385 t,
33863386 if self . sess . features_untracked ( ) . impl_trait_in_bindings {
3387- ImplTraitContext :: Existential ( None )
3387+ ImplTraitContext :: OpaqueTy ( None )
33883388 } else {
33893389 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
33903390 }
@@ -3398,7 +3398,7 @@ impl<'a> LoweringContext<'a> {
33983398 self . lower_ty (
33993399 t,
34003400 if self . sess . features_untracked ( ) . impl_trait_in_bindings {
3401- ImplTraitContext :: Existential ( None )
3401+ ImplTraitContext :: OpaqueTy ( None )
34023402 } else {
34033403 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
34043404 }
@@ -3444,14 +3444,14 @@ impl<'a> LoweringContext<'a> {
34443444 self . lower_ty ( t, ImplTraitContext :: disallowed ( ) ) ,
34453445 self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
34463446 ) ,
3447- ItemKind :: Existential ( ref b, ref generics) => hir:: ItemKind :: Existential (
3447+ ItemKind :: OpaqueTy ( ref b, ref generics) => hir:: ItemKind :: OpaqueTy (
34483448 hir:: ExistTy {
34493449 generics : self . lower_generics ( generics,
3450- ImplTraitContext :: Existential ( None ) ) ,
3450+ ImplTraitContext :: OpaqueTy ( None ) ) ,
34513451 bounds : self . lower_param_bounds ( b,
3452- ImplTraitContext :: Existential ( None ) ) ,
3452+ ImplTraitContext :: OpaqueTy ( None ) ) ,
34533453 impl_trait_fn : None ,
3454- origin : hir:: ExistTyOrigin :: ExistentialType ,
3454+ origin : hir:: OpaqueTyOrigin :: TraitAliasImplTrait ,
34553455 } ,
34563456 ) ,
34573457 ItemKind :: Enum ( ref enum_definition, ref generics) => {
@@ -3918,9 +3918,9 @@ impl<'a> LoweringContext<'a> {
39183918 self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ,
39193919 hir:: ImplItemKind :: Type ( self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ) ,
39203920 ) ,
3921- ImplItemKind :: Existential ( ref bounds) => (
3921+ ImplItemKind :: OpaqueTy ( ref bounds) => (
39223922 self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ,
3923- hir:: ImplItemKind :: Existential (
3923+ hir:: ImplItemKind :: OpaqueTy (
39243924 self . lower_param_bounds ( bounds, ImplTraitContext :: disallowed ( ) ) ,
39253925 ) ,
39263926 ) ,
@@ -3951,7 +3951,7 @@ impl<'a> LoweringContext<'a> {
39513951 kind : match i. node {
39523952 ImplItemKind :: Const ( ..) => hir:: AssocItemKind :: Const ,
39533953 ImplItemKind :: Type ( ..) => hir:: AssocItemKind :: Type ,
3954- ImplItemKind :: Existential ( ..) => hir:: AssocItemKind :: Existential ,
3954+ ImplItemKind :: OpaqueTy ( ..) => hir:: AssocItemKind :: OpaqueTy ,
39553955 ImplItemKind :: Method ( ref sig, _) => hir:: AssocItemKind :: Method {
39563956 has_self : sig. decl . has_self ( ) ,
39573957 } ,
0 commit comments