Skip to content

Commit eb12ed8

Browse files
committed
Rename FunctionRetTy to FnRetTy
1 parent a643ee8 commit eb12ed8

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

+4-4
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

+9-9
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

+2-2
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

+1-1
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

+2-2
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

+2-2
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

+2-4
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

+1-1
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

+1-1
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

+2-2
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

src/librustc_builtin_macros/test_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
305305
ecx.block(sp, vec![call_test_main])
306306
};
307307

308-
let decl = ecx.fn_decl(vec![], ast::FunctionRetTy::Ty(main_ret_ty));
308+
let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty));
309309
let sig = ast::FnSig { decl, header: ast::FnHeader::default() };
310310
let main = ast::ItemKind::Fn(sig, ast::Generics::default(), Some(main_body));
311311

src/librustc_expand/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'a> ExtCtxt<'a> {
519519
pub fn lambda(&self, span: Span, ids: Vec<ast::Ident>, body: P<ast::Expr>) -> P<ast::Expr> {
520520
let fn_decl = self.fn_decl(
521521
ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(),
522-
ast::FunctionRetTy::Default(span),
522+
ast::FnRetTy::Default(span),
523523
);
524524

525525
// FIXME -- We are using `span` as the span of the `|...|`
@@ -569,7 +569,7 @@ impl<'a> ExtCtxt<'a> {
569569
}
570570

571571
// FIXME: unused `self`
572-
pub fn fn_decl(&self, inputs: Vec<ast::Param>, output: ast::FunctionRetTy) -> P<ast::FnDecl> {
572+
pub fn fn_decl(&self, inputs: Vec<ast::Param>, output: ast::FnRetTy) -> P<ast::FnDecl> {
573573
P(ast::FnDecl { inputs, output })
574574
}
575575

src/librustc_hir/hir.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::itemlikevisit;
55
use crate::print;
66

77
crate use BlockCheckMode::*;
8-
crate use FunctionRetTy::*;
8+
crate use FnRetTy::*;
99
crate use UnsafeSource::*;
1010

1111
use rustc_data_structures::fx::FxHashSet;
@@ -2082,7 +2082,7 @@ pub struct FnDecl<'hir> {
20822082
///
20832083
/// Additional argument data is stored in the function's [body](Body::parameters).
20842084
pub inputs: &'hir [Ty<'hir>],
2085-
pub output: FunctionRetTy<'hir>,
2085+
pub output: FnRetTy<'hir>,
20862086
pub c_variadic: bool,
20872087
/// Does the function have an implicit self?
20882088
pub implicit_self: ImplicitSelfKind,
@@ -2148,7 +2148,7 @@ impl Defaultness {
21482148
}
21492149

21502150
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
2151-
pub enum FunctionRetTy<'hir> {
2151+
pub enum FnRetTy<'hir> {
21522152
/// Return type is not specified.
21532153
///
21542154
/// Functions default to `()` and
@@ -2159,7 +2159,7 @@ pub enum FunctionRetTy<'hir> {
21592159
Return(&'hir Ty<'hir>),
21602160
}
21612161

2162-
impl fmt::Display for FunctionRetTy<'_> {
2162+
impl fmt::Display for FnRetTy<'_> {
21632163
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21642164
match self {
21652165
Self::Return(ref ty) => print::to_string(print::NO_ANN, |s| s.print_type(ty)).fmt(f),
@@ -2168,7 +2168,7 @@ impl fmt::Display for FunctionRetTy<'_> {
21682168
}
21692169
}
21702170

2171-
impl FunctionRetTy<'_> {
2171+
impl FnRetTy<'_> {
21722172
pub fn span(&self) -> Span {
21732173
match *self {
21742174
Self::DefaultReturn(span) => span,

src/librustc_hir/intravisit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,8 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
865865
}
866866
}
867867

868-
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy<'v>) {
869-
if let FunctionRetTy::Return(ref output_ty) = *ret_ty {
868+
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) {
869+
if let FnRetTy::Return(ref output_ty) = *ret_ty {
870870
visitor.visit_ty(output_ty)
871871
}
872872
}

src/librustc_infer/infer/error_reporting/need_type_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
77
use rustc_hir as hir;
88
use rustc_hir::def::{DefKind, Namespace};
99
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
10-
use rustc_hir::{Body, Expr, ExprKind, FunctionRetTy, HirId, Local, Pat};
10+
use rustc_hir::{Body, Expr, ExprKind, FnRetTy, HirId, Local, Pat};
1111
use rustc_span::source_map::DesugaringKind;
1212
use rustc_span::symbol::kw;
1313
use rustc_span::Span;
@@ -108,7 +108,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
108108
fn closure_return_type_suggestion(
109109
span: Span,
110110
err: &mut DiagnosticBuilder<'_>,
111-
output: &FunctionRetTy<'_>,
111+
output: &FnRetTy<'_>,
112112
body: &Body<'_>,
113113
descr: &str,
114114
name: &str,
@@ -117,7 +117,7 @@ fn closure_return_type_suggestion(
117117
parent_descr: Option<&str>,
118118
) {
119119
let (arrow, post) = match output {
120-
FunctionRetTy::DefaultReturn(_) => ("-> ", " "),
120+
FnRetTy::DefaultReturn(_) => ("-> ", " "),
121121
_ => ("", ""),
122122
};
123123
let suggestion = match body.value.kind {

src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
44
use rustc::ty;
55
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
6-
use rustc_hir::{FunctionRetTy, TyKind};
6+
use rustc_hir::{FnRetTy, TyKind};
77

88
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
99
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
@@ -79,7 +79,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
7979
{
8080
return None;
8181
}
82-
if let FunctionRetTy::Return(ty) = &fndecl.output {
82+
if let FnRetTy::Return(ty) = &fndecl.output {
8383
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.kind, sub) {
8484
// This is an impl Trait return that evaluates de need of 'static.
8585
// We handle this case better in `static_impl_trait`.

src/librustc_infer/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
594594
_ => return false,
595595
};
596596

597-
let ret_ty = if let hir::FunctionRetTy::Return(ret_ty) = sig.decl.output {
597+
let ret_ty = if let hir::FnRetTy::Return(ret_ty) = sig.decl.output {
598598
ret_ty
599599
} else {
600600
return false;

src/librustc_interface/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
620620
ret
621621
}
622622

623-
fn should_ignore_fn(ret_ty: &ast::FunctionRetTy) -> bool {
624-
if let ast::FunctionRetTy::Ty(ref ty) = ret_ty {
623+
fn should_ignore_fn(ret_ty: &ast::FnRetTy) -> bool {
624+
if let ast::FnRetTy::Ty(ref ty) = ret_ty {
625625
fn involves_impl_trait(ty: &ast::Ty) -> bool {
626626
match ty.kind {
627627
ast::TyKind::ImplTrait(..) => true,

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
953953
self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty, false);
954954
}
955955

956-
if let hir::FunctionRetTy::Return(ref ret_hir) = decl.output {
956+
if let hir::FnRetTy::Return(ref ret_hir) = decl.output {
957957
let ret_ty = sig.output();
958958
if !ret_ty.is_unit() {
959959
self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty, false);

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
18851885
// as the HIR doesn't have full types for closure arguments.
18861886
let return_ty = *sig.output().skip_binder();
18871887
let mut return_span = fn_decl.output.span();
1888-
if let hir::FunctionRetTy::Return(ty) = &fn_decl.output {
1888+
if let hir::FnRetTy::Return(ty) = &fn_decl.output {
18891889
if let hir::TyKind::Rptr(lifetime, _) = ty.kind {
18901890
return_span = lifetime.span;
18911891
}

src/librustc_mir/borrow_check/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
645645
..
646646
}) => (
647647
match return_ty.output {
648-
hir::FunctionRetTy::DefaultReturn(_) => tcx.sess.source_map().end_point(*span),
649-
hir::FunctionRetTy::Return(_) => return_ty.output.span(),
648+
hir::FnRetTy::DefaultReturn(_) => tcx.sess.source_map().end_point(*span),
649+
hir::FnRetTy::Return(_) => return_ty.output.span(),
650650
},
651651
if gen_move.is_some() { " of generator" } else { " of closure" },
652652
),

src/librustc_parse/parser/expr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use rustc_span::source_map::{self, Span, Spanned};
1010
use rustc_span::symbol::{kw, sym, Symbol};
1111
use std::mem;
1212
use syntax::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, DUMMY_NODE_ID};
13-
use syntax::ast::{
14-
AnonConst, BinOp, BinOpKind, FnDecl, FunctionRetTy, Mac, Param, Ty, TyKind, UnOp,
15-
};
13+
use syntax::ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, Mac, Param, Ty, TyKind, UnOp};
1614
use syntax::ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
1715
use syntax::ptr::P;
1816
use syntax::token::{self, Token, TokenKind};
@@ -1358,7 +1356,7 @@ impl<'a> Parser<'a> {
13581356
let decl = self.parse_fn_block_decl()?;
13591357
let decl_hi = self.prev_span;
13601358
let body = match decl.output {
1361-
FunctionRetTy::Default(_) => {
1359+
FnRetTy::Default(_) => {
13621360
let restrictions = self.restrictions - Restrictions::STMT_EXPR;
13631361
self.parse_expr_res(restrictions, None)?
13641362
}

0 commit comments

Comments
 (0)