Skip to content

Commit ce10fa8

Browse files
committed
syntax: rename TypeMethod to MethodSig and use it in MethDecl.
1 parent f98b176 commit ce10fa8

File tree

28 files changed

+291
-513
lines changed

28 files changed

+291
-513
lines changed

src/librustc/metadata/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
838838
if !any_types {
839839
encode_symbol(ecx, rbml_w, m.def_id.node);
840840
}
841-
encode_method_argument_names(rbml_w, ast_method.pe_fn_decl());
841+
encode_method_argument_names(rbml_w, &ast_method.pe_sig().decl);
842842
}
843843
}
844844

@@ -1383,7 +1383,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
13831383
encode_trait_item(rbml_w);
13841384
encode_item_sort(rbml_w, 'p');
13851385
encode_inlined_item(ecx, rbml_w, IITraitItemRef(def_id, trait_item));
1386-
encode_method_argument_names(rbml_w, &*m.pe_fn_decl());
1386+
encode_method_argument_names(rbml_w, &*m.pe_sig().decl);
13871387
}
13881388

13891389
ast::TypeTraitItem(..) => {

src/librustc/middle/effect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
9191
visit::FkItemFn(_, _, fn_style, _) =>
9292
(true, fn_style == ast::Unsafety::Unsafe),
9393
visit::FkMethod(_, method) =>
94-
(true, method.pe_unsafety() == ast::Unsafety::Unsafe),
94+
(true, method.pe_sig().unsafety == ast::Unsafety::Unsafe),
9595
_ => (false, false),
9696
};
9797

src/librustc/middle/infer/error_reporting.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -841,19 +841,19 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
841841
ast_map::NodeItem(ref item) => {
842842
match item.node {
843843
ast::ItemFn(ref fn_decl, pur, _, ref gen, _) => {
844-
Some((&**fn_decl, gen, pur, item.ident, None, item.span))
844+
Some((fn_decl, gen, pur, item.ident, None, item.span))
845845
},
846846
_ => None
847847
}
848848
}
849849
ast_map::NodeImplItem(item) => {
850850
match item.node {
851851
ast::MethodImplItem(ref m) => {
852-
Some((m.pe_fn_decl(),
853-
m.pe_generics(),
854-
m.pe_unsafety(),
852+
Some((&m.pe_sig().decl,
853+
&m.pe_sig().generics,
854+
m.pe_sig().unsafety,
855855
item.ident,
856-
Some(&m.pe_explicit_self().node),
856+
Some(&m.pe_sig().explicit_self.node),
857857
item.span))
858858
}
859859
ast::TypeImplItem(_) => None,
@@ -862,11 +862,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
862862
ast_map::NodeTraitItem(item) => {
863863
match item.node {
864864
ast::ProvidedMethod(ref m) => {
865-
Some((m.pe_fn_decl(),
866-
m.pe_generics(),
867-
m.pe_unsafety(),
865+
Some((&m.pe_sig().decl,
866+
&m.pe_sig().generics,
867+
m.pe_sig().unsafety,
868868
item.ident,
869-
Some(&m.pe_explicit_self().node),
869+
Some(&m.pe_sig().explicit_self.node),
870870
item.span))
871871
}
872872
_ => None
@@ -1732,7 +1732,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
17321732
ast_map::NodeImplItem(ii) => {
17331733
match ii.node {
17341734
ast::MethodImplItem(ref m) => {
1735-
taken.push_all(&m.pe_generics().lifetimes);
1735+
taken.push_all(&m.pe_sig().generics.lifetimes);
17361736
Some(ii.id)
17371737
}
17381738
ast::TypeImplItem(_) => None,

src/librustc/middle/reachable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn method_might_be_inlined(tcx: &ty::ctxt, method: &ast::Method,
5757
impl_item: &ast::ImplItem,
5858
impl_src: ast::DefId) -> bool {
5959
if attr::requests_inline(&impl_item.attrs) ||
60-
generics_require_inlining(method.pe_generics()) {
60+
generics_require_inlining(&method.pe_sig().generics) {
6161
return true
6262
}
6363
if is_local(impl_src) {
@@ -191,7 +191,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
191191
Some(ast_map::NodeImplItem(impl_item)) => {
192192
match impl_item.node {
193193
ast::MethodImplItem(ref method) => {
194-
if generics_require_inlining(method.pe_generics()) ||
194+
if generics_require_inlining(&method.pe_sig().generics) ||
195195
attr::requests_inline(&impl_item.attrs) {
196196
true
197197
} else {

src/librustc/middle/resolve_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
149149
})
150150
}
151151
visit::FkMethod(_, m) => {
152-
self.visit_early_late(subst::FnSpace, m.pe_generics(), |this| {
152+
self.visit_early_late(subst::FnSpace, &m.pe_sig().generics, |this| {
153153
visit::walk_fn(this, fk, fd, b, s)
154154
})
155155
}

src/librustc_lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use std::{cmp, slice};
4646
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4747

4848
use syntax::{abi, ast, ast_map};
49-
use syntax::ast_util::{self, is_shift_binop, local_def};
49+
use syntax::ast_util::{self, is_shift_binop, local_def, PostExpansionMethod};
5050
use syntax::attr::{self, AttrMetaMethods};
5151
use syntax::codemap::{self, Span};
5252
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
@@ -1319,7 +1319,7 @@ impl LintPass for UnsafeCode {
13191319
cx.span_lint(UNSAFE_CODE, span, "declaration of an `unsafe` function"),
13201320

13211321
visit::FkMethod(_, m) => {
1322-
if let ast::MethDecl(_, _, _, ast::Unsafety::Unsafe, _, _) = *m {
1322+
if m.pe_sig().unsafety == ast::Unsafety::Unsafe {
13231323
cx.span_lint(UNSAFE_CODE, span, "implementation of an `unsafe` method")
13241324
}
13251325
},

src/librustc_privacy/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
275275
match impl_item.node {
276276
ast::MethodImplItem(ref method) => {
277277
let meth_public =
278-
match method.pe_explicit_self().node {
278+
match method.pe_sig().explicit_self.node {
279279
ast::SelfStatic => public_ty,
280280
_ => true,
281281
} && impl_item.vis == ast::Public;
@@ -1355,7 +1355,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
13551355
for impl_item in impl_items {
13561356
match impl_item.node {
13571357
ast::MethodImplItem(ref method) => {
1358-
if method.pe_explicit_self().node ==
1358+
if method.pe_sig().explicit_self.node ==
13591359
ast::SelfStatic &&
13601360
self.exported_items
13611361
.contains(&impl_item.id) {

src/librustc_resolve/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
243243
ItemRibKind
244244
}
245245
visit::FkMethod(_, method) => {
246-
self.visit_generics(method.pe_generics());
247-
self.visit_explicit_self(method.pe_explicit_self());
246+
self.visit_generics(&method.pe_sig().generics);
247+
self.visit_explicit_self(&method.pe_sig().explicit_self);
248248
MethodRibKind
249249
}
250250
visit::FkFnBlock(..) => ClosureRibKind(node_id)
@@ -2814,13 +2814,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
28142814
// FIXME #4951: Do we need a node ID here?
28152815

28162816
let type_parameters = match trait_item.node {
2817-
ast::RequiredMethod(ref ty_m) => {
2818-
HasTypeParameters(&ty_m.generics,
2817+
ast::RequiredMethod(ref sig) => {
2818+
HasTypeParameters(&sig.generics,
28192819
FnSpace,
28202820
MethodRibKind)
28212821
}
28222822
ast::ProvidedMethod(ref m) => {
2823-
HasTypeParameters(m.pe_generics(),
2823+
HasTypeParameters(&m.pe_sig().generics,
28242824
FnSpace,
28252825
MethodRibKind)
28262826
}
@@ -3075,7 +3075,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30753075
// We also need a new scope for the method-
30763076
// specific type parameters.
30773077
let type_parameters =
3078-
HasTypeParameters(method.pe_generics(),
3078+
HasTypeParameters(&method.pe_sig().generics,
30793079
FnSpace,
30803080
MethodRibKind);
30813081
this.with_type_parameter_rib(type_parameters, |this| {
@@ -3956,11 +3956,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
39563956
let explicit_self = match this.ast_map.get(did.node) {
39573957
ast_map::NodeTraitItem(trait_item) => match trait_item.node {
39583958
ast::RequiredMethod(ref m) => &m.explicit_self,
3959-
ast::ProvidedMethod(ref m) => m.pe_explicit_self(),
3959+
ast::ProvidedMethod(ref m) => &m.pe_sig().explicit_self,
39603960
_ => return false
39613961
},
39623962
ast_map::NodeImplItem(impl_item) => match impl_item.node {
3963-
ast::MethodImplItem(ref m) => m.pe_explicit_self(),
3963+
ast::MethodImplItem(ref m) => &m.pe_sig().explicit_self,
39643964
_ => return false
39653965
},
39663966
_ => return false

src/librustc_trans/save/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,21 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
382382
decl_id,
383383
scope_id);
384384

385-
self.process_formals(&method.pe_fn_decl().inputs, qualname);
385+
self.process_formals(&method.pe_sig().decl.inputs, qualname);
386386

387387
// walk arg and return types
388-
for arg in &method.pe_fn_decl().inputs {
388+
for arg in &method.pe_sig().decl.inputs {
389389
self.visit_ty(&*arg.ty);
390390
}
391391

392-
if let ast::Return(ref ret_ty) = method.pe_fn_decl().output {
392+
if let ast::Return(ref ret_ty) = method.pe_sig().decl.output {
393393
self.visit_ty(&**ret_ty);
394394
}
395395

396396
// walk the fn body
397397
self.nest(id, |v| v.visit_block(&*method.pe_body()));
398398

399-
self.process_generic_params(method.pe_generics(),
399+
self.process_generic_params(&method.pe_sig().generics,
400400
span,
401401
qualname,
402402
id);

src/librustc_trans/trans/debuginfo.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
12921292

12931293
match item.node {
12941294
ast::ItemFn(ref fn_decl, _, _, ref generics, ref top_level_block) => {
1295-
(item.ident, &**fn_decl, generics, &**top_level_block, item.span, true)
1295+
(item.ident, fn_decl, generics, &**top_level_block, item.span, true)
12961296
}
12971297
_ => {
12981298
cx.sess().span_bug(item.span,
@@ -1308,8 +1308,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13081308
}
13091309

13101310
(impl_item.ident,
1311-
method.pe_fn_decl(),
1312-
method.pe_generics(),
1311+
&method.pe_sig().decl,
1312+
&method.pe_sig().generics,
13131313
method.pe_body(),
13141314
impl_item.span,
13151315
true)
@@ -1326,7 +1326,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13261326
ast::ExprClosure(_, ref fn_decl, ref top_level_block) => {
13271327
let name = format!("fn{}", token::gensym("fn"));
13281328
let name = token::str_to_ident(&name[..]);
1329-
(name, &**fn_decl,
1329+
(name, fn_decl,
13301330
// This is not quite right. It should actually inherit
13311331
// the generics of the enclosing function.
13321332
&empty_generics,
@@ -1347,8 +1347,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13471347
}
13481348

13491349
(trait_item.ident,
1350-
method.pe_fn_decl(),
1351-
method.pe_generics(),
1350+
&method.pe_sig().decl,
1351+
&method.pe_sig().generics,
13521352
method.pe_body(),
13531353
trait_item.span,
13541354
true)

src/librustc_trans/trans/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
149149
if let ast::MethodImplItem(ref mth) = impl_item.node {
150150
let impl_tpt = ty::lookup_item_type(ccx.tcx(), impl_did);
151151
if impl_tpt.generics.types.is_empty() &&
152-
mth.pe_generics().ty_params.is_empty() {
152+
mth.pe_sig().generics.ty_params.is_empty() {
153153
let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
154154
let llfn = get_item_val(ccx, impl_item.id);
155155
trans_fn(ccx,
156-
&*mth.pe_fn_decl(),
156+
&*mth.pe_sig().decl,
157157
&*mth.pe_body(),
158158
llfn,
159159
empty_substs,

src/librustc_trans/trans/meth.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ pub fn trans_impl(ccx: &CrateContext,
8080
for impl_item in impl_items {
8181
match impl_item.node {
8282
ast::MethodImplItem(ref method) => {
83-
if method.pe_generics().ty_params.len() == 0 {
83+
if method.pe_sig().generics.ty_params.len() == 0 {
8484
let trans_everywhere = attr::requests_inline(&impl_item.attrs);
8585
for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
8686
let llfn = get_item_val(ccx, impl_item.id);
8787
let empty_substs = tcx.mk_substs(Substs::trans_empty());
8888
trans_fn(ccx,
89-
method.pe_fn_decl(),
89+
&method.pe_sig().decl,
9090
method.pe_body(),
9191
llfn,
9292
empty_substs,

src/librustc_trans/trans/monomorphize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
223223
let needs_body = setup_lldecl(d, &impl_item.attrs);
224224
if needs_body {
225225
trans_fn(ccx,
226-
mth.pe_fn_decl(),
226+
&mth.pe_sig().decl,
227227
mth.pe_body(),
228228
d,
229229
psubsts,
@@ -243,7 +243,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
243243
let d = mk_lldecl(abi::Rust);
244244
let needs_body = setup_lldecl(d, &trait_item.attrs);
245245
if needs_body {
246-
trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d,
246+
trans_fn(ccx, &mth.pe_sig().decl, mth.pe_body(), d,
247247
psubsts, trait_item.id, &[]);
248248
}
249249
d

src/librustc_typeck/astconv.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1442,22 +1442,19 @@ struct SelfInfo<'a, 'tcx> {
14421442
}
14431443

14441444
pub fn ty_of_method<'tcx>(this: &AstConv<'tcx>,
1445-
unsafety: ast::Unsafety,
1446-
untransformed_self_ty: Ty<'tcx>,
1447-
explicit_self: &ast::ExplicitSelf,
1448-
decl: &ast::FnDecl,
1449-
abi: abi::Abi)
1445+
sig: &ast::MethodSig,
1446+
untransformed_self_ty: Ty<'tcx>)
14501447
-> (ty::BareFnTy<'tcx>, ty::ExplicitSelfCategory) {
14511448
let self_info = Some(SelfInfo {
14521449
untransformed_self_ty: untransformed_self_ty,
1453-
explicit_self: explicit_self,
1450+
explicit_self: &sig.explicit_self,
14541451
});
14551452
let (bare_fn_ty, optional_explicit_self_category) =
14561453
ty_of_method_or_bare_fn(this,
1457-
unsafety,
1458-
abi,
1454+
sig.unsafety,
1455+
sig.abi,
14591456
self_info,
1460-
decl);
1457+
&sig.decl);
14611458
(bare_fn_ty, optional_explicit_self_category.unwrap())
14621459
}
14631460

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
867867
debug!("check_method_body: fty={}", fty.repr(ccx.tcx));
868868

869869
check_bare_fn(ccx,
870-
&*method.pe_fn_decl(),
870+
&*method.pe_sig().decl,
871871
&*method.pe_body(),
872872
id,
873873
span,

0 commit comments

Comments
 (0)