X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_ast_lowering%2Fsrc%2Fpath.rs;h=592fc5aa6456f064e0d399f5a0c1487067f147ce;hb=d429e463c19fc45d70343779eef5b0b8f7231c70;hp=dc85b5e95ea86d75a73a63cd9e0eaa1d9fb5bd1b;hpb=e4d1fe7b15117a1624f3d9b051c477cb117176b3;p=rust.git diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index dc85b5e95ea..592fc5aa645 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -9,10 +9,10 @@ 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))] @@ -144,13 +144,13 @@ pub(crate) fn lower_qpath( ); } - 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( @@ -165,17 +165,6 @@ pub(crate) fn lower_path_extra( }) } - 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, @@ -363,11 +352,18 @@ fn lower_parenthesized_parameter_data( // 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))