let ty = self.lower_ty(
t,
if self.sess.features_untracked().impl_trait_in_bindings {
- ImplTraitContext::OpaqueTy(None)
+ ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc)
} else {
ImplTraitContext::Disallowed(ImplTraitPosition::Binding)
},
let ty = self.lower_ty(
t,
if self.sess.features_untracked().impl_trait_in_bindings {
- ImplTraitContext::OpaqueTy(None)
+ ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc)
} else {
ImplTraitContext::Disallowed(ImplTraitPosition::Binding)
},
// `impl Future<Output = T>` here because lower_body
// only cares about the input argument patterns in the function
// declaration (decl), not the return types.
- let asyncness = header.asyncness.node;
+ let asyncness = header.asyncness;
let body_id =
this.lower_maybe_async_body(span, &decl, asyncness, body.as_deref());
}
Some(bounds) => {
let ty = hir::OpaqueTy {
- generics: self.lower_generics(generics, ImplTraitContext::OpaqueTy(None)),
- bounds: self.lower_param_bounds(bounds, ImplTraitContext::OpaqueTy(None)),
+ generics: self.lower_generics(
+ generics,
+ ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc),
+ ),
+ bounds: self.lower_param_bounds(
+ bounds,
+ ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc),
+ ),
impl_trait_fn: None,
origin: hir::OpaqueTyOrigin::TypeAlias,
};
let (generics, kind) = match i.kind {
AssocItemKind::Const(ref ty, ref default) => {
- let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
let ty = self.lower_ty(ty, ImplTraitContext::disallowed());
- (
- generics,
- hir::TraitItemKind::Const(
- ty,
- default.as_ref().map(|x| self.lower_const_body(i.span, Some(x))),
- ),
- )
+ let body = default.as_ref().map(|x| self.lower_const_body(i.span, Some(x)));
+ (hir::Generics::empty(), hir::TraitItemKind::Const(ty, body))
}
- AssocItemKind::Fn(ref sig, None) => {
+ AssocItemKind::Fn(ref sig, ref generics, None) => {
let names = self.lower_fn_params_to_names(&sig.decl);
let (generics, sig) =
- self.lower_method_sig(&i.generics, sig, trait_item_def_id, false, None);
+ self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
}
- AssocItemKind::Fn(ref sig, Some(ref body)) => {
+ AssocItemKind::Fn(ref sig, ref generics, Some(ref body)) => {
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
let (generics, sig) =
- self.lower_method_sig(&i.generics, sig, trait_item_def_id, false, None);
+ self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
}
- AssocItemKind::TyAlias(ref bounds, ref default) => {
+ AssocItemKind::TyAlias(ref generics, ref bounds, ref default) => {
let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed()));
- let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
+ let generics = self.lower_generics(generics, ImplTraitContext::disallowed());
let kind = hir::TraitItemKind::Type(
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
ty,
}
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
- let (kind, has_default) = match i.kind {
- AssocItemKind::Const(_, ref default) => (hir::AssocItemKind::Const, default.is_some()),
- AssocItemKind::TyAlias(_, ref default) => (hir::AssocItemKind::Type, default.is_some()),
- AssocItemKind::Fn(ref sig, ref default) => {
+ let (kind, has_default) = match &i.kind {
+ AssocItemKind::Const(_, default) => (hir::AssocItemKind::Const, default.is_some()),
+ AssocItemKind::TyAlias(_, _, default) => (hir::AssocItemKind::Type, default.is_some()),
+ AssocItemKind::Fn(sig, _, default) => {
(hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
}
AssocItemKind::Macro(..) => unimplemented!(),
let (generics, kind) = match i.kind {
AssocItemKind::Const(ref ty, ref expr) => {
- let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
let ty = self.lower_ty(ty, ImplTraitContext::disallowed());
(
- generics,
+ hir::Generics::empty(),
hir::ImplItemKind::Const(ty, self.lower_const_body(i.span, expr.as_deref())),
)
}
- AssocItemKind::Fn(ref sig, ref body) => {
+ AssocItemKind::Fn(ref sig, ref generics, ref body) => {
self.current_item = Some(i.span);
- let body_id = self.lower_maybe_async_body(
- i.span,
- &sig.decl,
- sig.header.asyncness.node,
- body.as_deref(),
- );
+ let asyncness = sig.header.asyncness;
+ let body_id =
+ self.lower_maybe_async_body(i.span, &sig.decl, asyncness, body.as_deref());
let impl_trait_return_allow = !self.is_in_trait_impl;
let (generics, sig) = self.lower_method_sig(
- &i.generics,
+ generics,
sig,
impl_item_def_id,
impl_trait_return_allow,
- sig.header.asyncness.node.opt_return_id(),
+ asyncness.opt_return_id(),
);
(generics, hir::ImplItemKind::Method(sig, body_id))
}
- AssocItemKind::TyAlias(_, ref ty) => {
- let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
+ AssocItemKind::TyAlias(ref generics, _, ref ty) => {
+ let generics = self.lower_generics(generics, ImplTraitContext::disallowed());
let kind = match ty {
None => {
let ty = self.arena.alloc(self.ty(i.span, hir::TyKind::Err));
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
kind: match &i.kind {
AssocItemKind::Const(..) => hir::AssocItemKind::Const,
- AssocItemKind::TyAlias(_, ty) => {
+ AssocItemKind::TyAlias(_, _, ty) => {
match ty.as_deref().and_then(|ty| ty.kind.opaque_top_hack()) {
None => hir::AssocItemKind::Type,
Some(_) => hir::AssocItemKind::OpaqueTy,
}
}
- AssocItemKind::Fn(sig, _) => {
+ AssocItemKind::Fn(sig, _, _) => {
hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
}
AssocItemKind::Macro(..) => unimplemented!(),
&mut self,
span: Span,
decl: &FnDecl,
- asyncness: IsAsync,
+ asyncness: Async,
body: Option<&Block>,
) -> hir::BodyId {
let closure_id = match asyncness {
- IsAsync::Async { closure_id, .. } => closure_id,
- IsAsync::NotAsync => return self.lower_fn_body_block(span, decl, body),
+ Async::Yes { closure_id, .. } => closure_id,
+ Async::No => return self.lower_fn_body_block(span, decl, body),
};
self.lower_body(|this| {
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
hir::FnHeader {
unsafety: self.lower_unsafety(h.unsafety),
- asyncness: self.lower_asyncness(h.asyncness.node),
+ asyncness: self.lower_asyncness(h.asyncness),
constness: self.lower_constness(h.constness),
abi: self.lower_extern(h.ext),
}
.emit();
}
- fn lower_asyncness(&mut self, a: IsAsync) -> hir::IsAsync {
+ fn lower_asyncness(&mut self, a: Async) -> hir::IsAsync {
match a {
- IsAsync::Async { .. } => hir::IsAsync::Async,
- IsAsync::NotAsync => hir::IsAsync::NotAsync,
+ Async::Yes { .. } => hir::IsAsync::Async,
+ Async::No => hir::IsAsync::NotAsync,
}
}