Skip to content

Commit 5c962c7

Browse files
committed
Rename FunctionRetTy to FnRetTy
1 parent 19288dd commit 5c962c7

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/infer/error_reporting/need_type_info.rs

Lines changed: 3 additions & 3 deletions
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/error_reporting/nice_region_error/named_anon_conflict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
44
use crate::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/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
593593
_ => return false,
594594
};
595595

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

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
@@ -1723,16 +1723,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17231723
)
17241724
} else {
17251725
match decl.output {
1726-
FunctionRetTy::Ty(ref ty) => {
1726+
FnRetTy::Ty(ref ty) => {
17271727
let context = match in_band_ty_params {
17281728
Some((def_id, _)) if impl_trait_return_allow => {
17291729
ImplTraitContext::OpaqueTy(Some(def_id), hir::OpaqueTyOrigin::FnReturn)
17301730
}
17311731
_ => ImplTraitContext::disallowed(),
17321732
};
1733-
hir::FunctionRetTy::Return(self.lower_ty(ty, context))
1733+
hir::FnRetTy::Return(self.lower_ty(ty, context))
17341734
}
1735-
FunctionRetTy::Default(span) => hir::FunctionRetTy::DefaultReturn(span),
1735+
FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(span),
17361736
}
17371737
};
17381738

@@ -1779,10 +1779,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17791779
// `elided_lt_replacement`: replacement for elided lifetimes in the return type
17801780
fn lower_async_fn_ret_ty(
17811781
&mut self,
1782-
output: &FunctionRetTy,
1782+
output: &FnRetTy,
17831783
fn_def_id: DefId,
17841784
opaque_ty_node_id: NodeId,
1785-
) -> hir::FunctionRetTy<'hir> {
1785+
) -> hir::FnRetTy<'hir> {
17861786
debug!(
17871787
"lower_async_fn_ret_ty(\
17881788
output={:?}, \
@@ -1947,27 +1947,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19471947
// only the lifetime parameters that we must supply.
19481948
let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args);
19491949
let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
1950-
hir::FunctionRetTy::Return(self.arena.alloc(opaque_ty))
1950+
hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
19511951
}
19521952

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

19731973
// "<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),

0 commit comments

Comments
 (0)