Skip to content

Commit 5f0c593

Browse files
authored
Rollup merge of #69179 - JohnTitor:rename-to-fnretty, r=Centril
Rename `FunctionRetTy` to `FnRetTy` As per FIXME comment r? @Centril
2 parents 50ddda6 + eb12ed8 commit 5f0c593

File tree

42 files changed

+111
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+111
-118
lines changed

src/librustc_ast_lowering/expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
480480
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
481481
) -> hir::ExprKind<'hir> {
482482
let output = match ret_ty {
483-
Some(ty) => FunctionRetTy::Ty(ty),
484-
None => FunctionRetTy::Default(span),
483+
Some(ty) => FnRetTy::Ty(ty),
484+
None => FnRetTy::Default(span),
485485
};
486486
let ast_decl = FnDecl { inputs: vec![], output };
487487
let decl = self.lower_fn_decl(&ast_decl, None, /* impl trait allowed */ false, None);
@@ -721,7 +721,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
721721
fn_decl_span: Span,
722722
) -> hir::ExprKind<'hir> {
723723
let outer_decl =
724-
FnDecl { inputs: decl.inputs.clone(), output: FunctionRetTy::Default(fn_decl_span) };
724+
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
725725
// We need to lower the declaration outside the new scope, because we
726726
// have to conserve the state of being inside a loop condition for the
727727
// closure argument types.
@@ -747,7 +747,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
747747
// `|x: u8| future_from_generator(|| -> X { ... })`.
748748
let body_id = this.lower_fn_body(&outer_decl, |this| {
749749
let async_ret_ty =
750-
if let FunctionRetTy::Ty(ty) = &decl.output { Some(ty.clone()) } else { None };
750+
if let FnRetTy::Ty(ty) = &decl.output { Some(ty.clone()) } else { None };
751751
let async_body = this.make_async_expr(
752752
capture_clause,
753753
closure_id,

src/librustc_ast_lowering/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,16 +1725,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17251725
)
17261726
} else {
17271727
match decl.output {
1728-
FunctionRetTy::Ty(ref ty) => {
1728+
FnRetTy::Ty(ref ty) => {
17291729
let context = match in_band_ty_params {
17301730
Some((def_id, _)) if impl_trait_return_allow => {
17311731
ImplTraitContext::OpaqueTy(Some(def_id), hir::OpaqueTyOrigin::FnReturn)
17321732
}
17331733
_ => ImplTraitContext::disallowed(),
17341734
};
1735-
hir::FunctionRetTy::Return(self.lower_ty(ty, context))
1735+
hir::FnRetTy::Return(self.lower_ty(ty, context))
17361736
}
1737-
FunctionRetTy::Default(span) => hir::FunctionRetTy::DefaultReturn(span),
1737+
FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(span),
17381738
}
17391739
};
17401740

@@ -1781,10 +1781,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17811781
// `elided_lt_replacement`: replacement for elided lifetimes in the return type
17821782
fn lower_async_fn_ret_ty(
17831783
&mut self,
1784-
output: &FunctionRetTy,
1784+
output: &FnRetTy,
17851785
fn_def_id: DefId,
17861786
opaque_ty_node_id: NodeId,
1787-
) -> hir::FunctionRetTy<'hir> {
1787+
) -> hir::FnRetTy<'hir> {
17881788
debug!(
17891789
"lower_async_fn_ret_ty(\
17901790
output={:?}, \
@@ -1949,27 +1949,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19491949
// only the lifetime parameters that we must supply.
19501950
let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args);
19511951
let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
1952-
hir::FunctionRetTy::Return(self.arena.alloc(opaque_ty))
1952+
hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
19531953
}
19541954

19551955
/// Transforms `-> T` into `Future<Output = T>`
19561956
fn lower_async_fn_output_type_to_future_bound(
19571957
&mut self,
1958-
output: &FunctionRetTy,
1958+
output: &FnRetTy,
19591959
fn_def_id: DefId,
19601960
span: Span,
19611961
) -> hir::GenericBound<'hir> {
19621962
// Compute the `T` in `Future<Output = T>` from the return type.
19631963
let output_ty = match output {
1964-
FunctionRetTy::Ty(ty) => {
1964+
FnRetTy::Ty(ty) => {
19651965
// Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
19661966
// `impl Future` opaque type that `async fn` implicitly
19671967
// generates.
19681968
let context =
19691969
ImplTraitContext::OpaqueTy(Some(fn_def_id), hir::OpaqueTyOrigin::FnReturn);
19701970
self.lower_ty(ty, context)
19711971
}
1972-
FunctionRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
1972+
FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
19731973
};
19741974

19751975
// "<Output = T>"

src/librustc_ast_lowering/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
397397
inputs.iter().map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed())),
398398
);
399399
let output_ty = match output {
400-
FunctionRetTy::Ty(ty) => this.lower_ty(&ty, ImplTraitContext::disallowed()),
401-
FunctionRetTy::Default(_) => this.arena.alloc(this.ty_tup(span, &[])),
400+
FnRetTy::Ty(ty) => this.lower_ty(&ty, ImplTraitContext::disallowed()),
401+
FnRetTy::Default(_) => this.arena.alloc(this.ty_tup(span, &[])),
402402
};
403403
let args = smallvec![GenericArg::Type(this.ty_tup(span, inputs))];
404404
let binding = this.output_ty_binding(output_ty.span, output_ty);

src/librustc_ast_passes/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
954954
}
955955
GenericArgs::Parenthesized(ref data) => {
956956
walk_list!(self, visit_ty, &data.inputs);
957-
if let FunctionRetTy::Ty(ty) = &data.output {
957+
if let FnRetTy::Ty(ty) = &data.output {
958958
// `-> Foo` syntax is essentially an associated type binding,
959959
// so it is also allowed to contain nested `impl Trait`.
960960
self.with_impl_trait(None, |this| this.visit_ty(ty));

src/librustc_ast_passes/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
419419
visit::walk_ty(self, ty)
420420
}
421421

422-
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
423-
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
422+
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FnRetTy) {
423+
if let ast::FnRetTy::Ty(ref output_ty) = *ret_ty {
424424
if let ast::TyKind::Never = output_ty.kind {
425425
// Do nothing.
426426
} else {

src/librustc_ast_pretty/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,8 @@ impl<'a> State<'a> {
26732673
self.end();
26742674
}
26752675

2676-
crate fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FunctionRetTy) {
2677-
if let ast::FunctionRetTy::Ty(ty) = fn_ret_ty {
2676+
crate fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FnRetTy) {
2677+
if let ast::FnRetTy::Ty(ty) = fn_ret_ty {
26782678
self.space_if_not_bol();
26792679
self.ibox(INDENT_UNIT);
26802680
self.word_space("->");

src/librustc_ast_pretty/pprust/tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ fn test_fun_to_string() {
3434
with_default_globals(|| {
3535
let abba_ident = ast::Ident::from_str("abba");
3636

37-
let decl = ast::FnDecl {
38-
inputs: Vec::new(),
39-
output: ast::FunctionRetTy::Default(rustc_span::DUMMY_SP),
40-
};
37+
let decl =
38+
ast::FnDecl { inputs: Vec::new(), output: ast::FnRetTy::Default(rustc_span::DUMMY_SP) };
4139
let generics = ast::Generics::default();
4240
assert_eq!(
4341
fun_to_string(&decl, ast::FnHeader::default(), abba_ident, &generics),

src/librustc_builtin_macros/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ impl<'a> MethodDef<'a> {
957957
let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident);
958958

959959
let method_ident = cx.ident_of(self.name, trait_.span);
960-
let fn_decl = cx.fn_decl(args, ast::FunctionRetTy::Ty(ret_type));
960+
let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
961961
let body_block = cx.block_expr(body);
962962

963963
let unsafety = if self.is_unsafe { ast::Unsafe::Yes(trait_.span) } else { ast::Unsafe::No };

src/librustc_builtin_macros/global_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl AllocFnFactory<'_, '_> {
6363
let args = method.inputs.iter().map(|ty| self.arg_ty(ty, &mut abi_args, mk)).collect();
6464
let result = self.call_allocator(method.name, args);
6565
let (output_ty, output_expr) = self.ret_ty(&method.output, result);
66-
let decl = self.cx.fn_decl(abi_args, ast::FunctionRetTy::Ty(output_ty));
66+
let decl = self.cx.fn_decl(abi_args, ast::FnRetTy::Ty(output_ty));
6767
let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() };
6868
let sig = FnSig { decl, header };
6969
let kind = ItemKind::Fn(sig, Generics::default(), Some(self.cx.block_expr(output_expr)));

src/librustc_builtin_macros/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
391391
// If the termination trait is active, the compiler will check that the output
392392
// type implements the `Termination` trait as `libtest` enforces that.
393393
let has_output = match sig.decl.output {
394-
ast::FunctionRetTy::Default(..) => false,
395-
ast::FunctionRetTy::Ty(ref t) if t.kind.is_unit() => false,
394+
ast::FnRetTy::Default(..) => false,
395+
ast::FnRetTy::Ty(ref t) if t.kind.is_unit() => false,
396396
_ => true,
397397
};
398398

0 commit comments

Comments
 (0)