88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- //! Give useful errors and suggestions to users when a method can't be
11+ //! Give useful errors and suggestions to users when an item can't be
1212//! found or is otherwise invalid.
1313
1414use CrateCtxt ;
@@ -27,12 +27,12 @@ use syntax::print::pprust;
2727use std:: cell;
2828use std:: cmp:: Ordering ;
2929
30- use super :: { MethodError , CandidateSource , impl_method , trait_method } ;
30+ use super :: { MethodError , CandidateSource , impl_item , trait_item } ;
3131
3232pub fn report_error < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
3333 span : Span ,
3434 rcvr_ty : Ty < ' tcx > ,
35- method_name : ast:: Name ,
35+ item_name : ast:: Name ,
3636 rcvr_expr : Option < & ast:: Expr > ,
3737 error : MethodError )
3838{
@@ -44,26 +44,26 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
4444 match error {
4545 MethodError :: NoMatch ( static_sources, out_of_scope_traits) => {
4646 let cx = fcx. tcx ( ) ;
47- let method_ustring = method_name . user_string ( cx) ;
47+ let item_ustring = item_name . user_string ( cx) ;
4848
4949 fcx. type_error_message (
5050 span,
5151 |actual| {
5252 format ! ( "type `{}` does not implement any \
53- method in scope named `{}`",
53+ item in scope named `{}`",
5454 actual,
55- method_ustring )
55+ item_ustring )
5656 } ,
5757 rcvr_ty,
5858 None ) ;
5959
60- // If the method has the name of a field, give a help note
60+ // If the item has the name of a field, give a help note
6161 if let ( & ty:: ty_struct( did, _) , Some ( _) ) = ( & rcvr_ty. sty , rcvr_expr) {
6262 let fields = ty:: lookup_struct_fields ( cx, did) ;
63- if fields. iter ( ) . any ( |f| f. name == method_name ) {
63+ if fields. iter ( ) . any ( |f| f. name == item_name ) {
6464 cx. sess . span_note ( span,
6565 & format ! ( "use `(s.{0})(...)` if you meant to call the \
66- function stored in the `{0}` field", method_ustring ) ) ;
66+ function stored in the `{0}` field", item_ustring ) ) ;
6767 }
6868 }
6969
@@ -72,25 +72,25 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
7272 span,
7373 "found defined static methods, maybe a `self` is missing?" ) ;
7474
75- report_candidates ( fcx, span, method_name , static_sources) ;
75+ report_candidates ( fcx, span, item_name , static_sources) ;
7676 }
7777
78- suggest_traits_to_import ( fcx, span, rcvr_ty, method_name ,
78+ suggest_traits_to_import ( fcx, span, rcvr_ty, item_name ,
7979 rcvr_expr, out_of_scope_traits)
8080 }
8181
8282 MethodError :: Ambiguity ( sources) => {
8383 span_err ! ( fcx. sess( ) , span, E0034 ,
84- "multiple applicable methods in scope" ) ;
84+ "multiple applicable items in scope" ) ;
8585
86- report_candidates ( fcx, span, method_name , sources) ;
86+ report_candidates ( fcx, span, item_name , sources) ;
8787 }
8888
8989 MethodError :: ClosureAmbiguity ( trait_def_id) => {
9090 let msg = format ! ( "the `{}` method from the `{}` trait cannot be explicitly \
9191 invoked on this closure as we have not yet inferred what \
9292 kind of closure it is",
93- method_name . user_string( fcx. tcx( ) ) ,
93+ item_name . user_string( fcx. tcx( ) ) ,
9494 ty:: item_path_str( fcx. tcx( ) , trait_def_id) ) ;
9595 let msg = if let Some ( callee) = rcvr_expr {
9696 format ! ( "{}; use overloaded call notation instead (e.g., `{}()`)" ,
@@ -104,19 +104,19 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
104104
105105 fn report_candidates ( fcx : & FnCtxt ,
106106 span : Span ,
107- method_name : ast:: Name ,
107+ item_name : ast:: Name ,
108108 mut sources : Vec < CandidateSource > ) {
109109 sources. sort ( ) ;
110110 sources. dedup ( ) ;
111111
112112 for ( idx, source) in sources. iter ( ) . enumerate ( ) {
113113 match * source {
114114 CandidateSource :: ImplSource ( impl_did) => {
115- // Provide the best span we can. Use the method , if local to crate, else
116- // the impl, if local to crate (method may be defaulted), else the call site.
117- let method = impl_method ( fcx. tcx ( ) , impl_did, method_name ) . unwrap ( ) ;
115+ // Provide the best span we can. Use the item , if local to crate, else
116+ // the impl, if local to crate (item may be defaulted), else the call site.
117+ let item = impl_item ( fcx. tcx ( ) , impl_did, item_name ) . unwrap ( ) ;
118118 let impl_span = fcx. tcx ( ) . map . def_id_span ( impl_did, span) ;
119- let method_span = fcx. tcx ( ) . map . def_id_span ( method . def_id , impl_span) ;
119+ let item_span = fcx. tcx ( ) . map . def_id_span ( item . def_id ( ) , impl_span) ;
120120
121121 let impl_ty = check:: impl_self_ty ( fcx, span, impl_did) . ty ;
122122
@@ -127,16 +127,16 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
127127 trait_ref. def_id) ) ,
128128 } ;
129129
130- span_note ! ( fcx. sess( ) , method_span ,
130+ span_note ! ( fcx. sess( ) , item_span ,
131131 "candidate #{} is defined in an impl{} for the type `{}`" ,
132132 idx + 1 ,
133133 insertion,
134134 impl_ty. user_string( fcx. tcx( ) ) ) ;
135135 }
136136 CandidateSource :: TraitSource ( trait_did) => {
137- let ( _, method ) = trait_method ( fcx. tcx ( ) , trait_did, method_name ) . unwrap ( ) ;
138- let method_span = fcx. tcx ( ) . map . def_id_span ( method . def_id , span) ;
139- span_note ! ( fcx. sess( ) , method_span ,
137+ let ( _, item ) = trait_item ( fcx. tcx ( ) , trait_did, item_name ) . unwrap ( ) ;
138+ let item_span = fcx. tcx ( ) . map . def_id_span ( item . def_id ( ) , span) ;
139+ span_note ! ( fcx. sess( ) , item_span ,
140140 "candidate #{} is defined in the trait `{}`" ,
141141 idx + 1 ,
142142 ty:: item_path_str( fcx. tcx( ) , trait_did) ) ;
@@ -152,19 +152,19 @@ pub type AllTraitsVec = Vec<TraitInfo>;
152152fn suggest_traits_to_import < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
153153 span : Span ,
154154 rcvr_ty : Ty < ' tcx > ,
155- method_name : ast:: Name ,
155+ item_name : ast:: Name ,
156156 rcvr_expr : Option < & ast:: Expr > ,
157157 valid_out_of_scope_traits : Vec < ast:: DefId > )
158158{
159159 let tcx = fcx. tcx ( ) ;
160- let method_ustring = method_name . user_string ( tcx) ;
160+ let item_ustring = item_name . user_string ( tcx) ;
161161
162162 if !valid_out_of_scope_traits. is_empty ( ) {
163163 let mut candidates = valid_out_of_scope_traits;
164164 candidates. sort ( ) ;
165165 candidates. dedup ( ) ;
166166 let msg = format ! (
167- "methods from traits can only be called if the trait is in scope; \
167+ "items from traits can only be used if the trait is in scope; \
168168 the following {traits_are} implemented but not in scope, \
169169 perhaps add a `use` for {one_of_them}:",
170170 traits_are = if candidates. len( ) == 1 { "trait is" } else { "traits are" } ,
@@ -185,7 +185,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
185185 let type_is_local = type_derefs_to_local ( fcx, span, rcvr_ty, rcvr_expr) ;
186186
187187 // there's no implemented traits, so lets suggest some traits to
188- // implement, by finding ones that have the method name, and are
188+ // implement, by finding ones that have the item name, and are
189189 // legal to implement.
190190 let mut candidates = all_traits ( fcx. ccx )
191191 . filter ( |info| {
@@ -196,7 +196,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
196196 // implementing a trait would be legal but is rejected
197197 // here).
198198 ( type_is_local || ast_util:: is_local ( info. def_id ) )
199- && trait_method ( tcx, info. def_id , method_name ) . is_some ( )
199+ && trait_item ( tcx, info. def_id , item_name ) . is_some ( )
200200 } )
201201 . collect :: < Vec < _ > > ( ) ;
202202
@@ -209,12 +209,12 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
209209 // of a type parameter: suggest adding a trait bound rather
210210 // than implementing.
211211 let msg = format ! (
212- "methods from traits can only be called if the trait is implemented and in scope; \
213- the following {traits_define} a method `{name}`, \
212+ "items from traits can only be used if the trait is implemented and in scope; \
213+ the following {traits_define} an item `{name}`, \
214214 perhaps you need to implement {one_of_them}:",
215215 traits_define = if candidates. len( ) == 1 { "trait defines" } else { "traits define" } ,
216216 one_of_them = if candidates. len( ) == 1 { "it" } else { "one of them" } ,
217- name = method_ustring ) ;
217+ name = item_ustring ) ;
218218
219219 fcx. sess ( ) . fileline_help ( span, & msg[ ..] ) ;
220220
0 commit comments