use rustc_hir as hir;
use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::GenericArg;
-use rustc_span::symbol::{kw, Ident};
+use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{BytePos, Span, DUMMY_SP};
-use smallvec::smallvec;
+use smallvec::{smallvec, SmallVec};
impl<'a, 'hir> LoweringContext<'a, 'hir> {
#[instrument(level = "trace", skip(self))]
);
}
- pub(crate) fn lower_path_extra(
+ pub(crate) fn lower_use_path(
&mut self,
- res: Res,
+ res: SmallVec<[Res; 3]>,
p: &Path,
param_mode: ParamMode,
- ) -> &'hir hir::Path<'hir> {
- self.arena.alloc(hir::Path {
+ ) -> &'hir hir::UsePath<'hir> {
+ self.arena.alloc(hir::UsePath {
res,
segments: self.arena.alloc_from_iter(p.segments.iter().map(|segment| {
self.lower_path_segment(
})
}
- pub(crate) fn lower_path(
- &mut self,
- id: NodeId,
- p: &Path,
- param_mode: ParamMode,
- ) -> &'hir hir::Path<'hir> {
- let res = self.expect_full_res(id);
- let res = self.lower_res(res);
- self.lower_path_extra(res, p, param_mode)
- }
-
pub(crate) fn lower_path_segment(
&mut self,
path_span: Span,
// fn f(_: impl Fn() -> impl Debug) -> impl Fn() -> impl Debug
// // disallowed --^^^^^^^^^^ allowed --^^^^^^^^^^
// ```
- FnRetTy::Ty(ty)
- if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. })
- && self.tcx.features().impl_trait_in_fn_trait_return =>
- {
- self.lower_ty(&ty, itctx)
+ FnRetTy::Ty(ty) if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. }) => {
+ if self.tcx.features().impl_trait_in_fn_trait_return {
+ self.lower_ty(&ty, itctx)
+ } else {
+ self.lower_ty(
+ &ty,
+ &ImplTraitContext::FeatureGated(
+ ImplTraitPosition::FnTraitReturn,
+ sym::impl_trait_in_fn_trait_return,
+ ),
+ )
+ }
}
FnRetTy::Ty(ty) => {
self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::FnTraitReturn))