@@ -15,7 +15,7 @@ use session::search_paths::PathKind;
1515use util:: nodemap:: { NodeMap , FnvHashMap } ;
1616
1717use syntax:: ast:: { NodeId , NodeIdAssigner , Name } ;
18- use syntax:: codemap:: Span ;
18+ use syntax:: codemap:: { Span , MultiSpan } ;
1919use syntax:: errors:: { self , DiagnosticBuilder } ;
2020use syntax:: errors:: emitter:: { Emitter , BasicEmitter , EmitterWriter } ;
2121use syntax:: errors:: json:: JsonEmitter ;
@@ -47,7 +47,7 @@ pub struct Session {
4747 pub cstore : Rc <for <' a > CrateStore < ' a > >,
4848 pub parse_sess : ParseSess ,
4949 // For a library crate, this is always none
50- pub entry_fn : RefCell < Option < ( NodeId , codemap :: Span ) > > ,
50+ pub entry_fn : RefCell < Option < ( NodeId , Span ) > > ,
5151 pub entry_type : Cell < Option < config:: EntryFnType > > ,
5252 pub plugin_registrar_fn : Cell < Option < ast:: NodeId > > ,
5353 pub default_sysroot : Option < PathBuf > ,
@@ -57,7 +57,7 @@ pub struct Session {
5757 pub local_crate_source_file : Option < PathBuf > ,
5858 pub working_dir : PathBuf ,
5959 pub lint_store : RefCell < lint:: LintStore > ,
60- pub lints : RefCell < NodeMap < Vec < ( lint:: LintId , codemap :: Span , String ) > > > ,
60+ pub lints : RefCell < NodeMap < Vec < ( lint:: LintId , Span , String ) > > > ,
6161 pub plugin_llvm_passes : RefCell < Vec < String > > ,
6262 pub plugin_attributes : RefCell < Vec < ( String , AttributeType ) > > ,
6363 pub crate_types : RefCell < Vec < config:: CrateType > > ,
@@ -81,36 +81,36 @@ pub struct Session {
8181}
8282
8383impl Session {
84- pub fn struct_span_warn < ' a > ( & ' a self ,
85- sp : Span ,
86- msg : & str )
87- -> DiagnosticBuilder < ' a > {
84+ pub fn struct_span_warn < ' a , S : Into < MultiSpan > > ( & ' a self ,
85+ sp : S ,
86+ msg : & str )
87+ -> DiagnosticBuilder < ' a > {
8888 self . diagnostic ( ) . struct_span_warn ( sp, msg)
8989 }
90- pub fn struct_span_warn_with_code < ' a > ( & ' a self ,
91- sp : Span ,
92- msg : & str ,
93- code : & str )
94- -> DiagnosticBuilder < ' a > {
90+ pub fn struct_span_warn_with_code < ' a , S : Into < MultiSpan > > ( & ' a self ,
91+ sp : S ,
92+ msg : & str ,
93+ code : & str )
94+ -> DiagnosticBuilder < ' a > {
9595 self . diagnostic ( ) . struct_span_warn_with_code ( sp, msg, code)
9696 }
9797 pub fn struct_warn < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
9898 self . diagnostic ( ) . struct_warn ( msg)
9999 }
100- pub fn struct_span_err < ' a > ( & ' a self ,
101- sp : Span ,
102- msg : & str )
103- -> DiagnosticBuilder < ' a > {
100+ pub fn struct_span_err < ' a , S : Into < MultiSpan > > ( & ' a self ,
101+ sp : S ,
102+ msg : & str )
103+ -> DiagnosticBuilder < ' a > {
104104 match split_msg_into_multilines ( msg) {
105105 Some ( ref msg) => self . diagnostic ( ) . struct_span_err ( sp, msg) ,
106106 None => self . diagnostic ( ) . struct_span_err ( sp, msg) ,
107107 }
108108 }
109- pub fn struct_span_err_with_code < ' a > ( & ' a self ,
110- sp : Span ,
111- msg : & str ,
112- code : & str )
113- -> DiagnosticBuilder < ' a > {
109+ pub fn struct_span_err_with_code < ' a , S : Into < MultiSpan > > ( & ' a self ,
110+ sp : S ,
111+ msg : & str ,
112+ code : & str )
113+ -> DiagnosticBuilder < ' a > {
114114 match split_msg_into_multilines ( msg) {
115115 Some ( ref msg) => self . diagnostic ( ) . struct_span_err_with_code ( sp, msg, code) ,
116116 None => self . diagnostic ( ) . struct_span_err_with_code ( sp, msg, code) ,
@@ -119,46 +119,46 @@ impl Session {
119119 pub fn struct_err < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
120120 self . diagnostic ( ) . struct_err ( msg)
121121 }
122- pub fn struct_span_fatal < ' a > ( & ' a self ,
123- sp : Span ,
124- msg : & str )
125- -> DiagnosticBuilder < ' a > {
122+ pub fn struct_span_fatal < ' a , S : Into < MultiSpan > > ( & ' a self ,
123+ sp : S ,
124+ msg : & str )
125+ -> DiagnosticBuilder < ' a > {
126126 self . diagnostic ( ) . struct_span_fatal ( sp, msg)
127127 }
128- pub fn struct_span_fatal_with_code < ' a > ( & ' a self ,
129- sp : Span ,
130- msg : & str ,
131- code : & str )
132- -> DiagnosticBuilder < ' a > {
128+ pub fn struct_span_fatal_with_code < ' a , S : Into < MultiSpan > > ( & ' a self ,
129+ sp : S ,
130+ msg : & str ,
131+ code : & str )
132+ -> DiagnosticBuilder < ' a > {
133133 self . diagnostic ( ) . struct_span_fatal_with_code ( sp, msg, code)
134134 }
135135 pub fn struct_fatal < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
136136 self . diagnostic ( ) . struct_fatal ( msg)
137137 }
138138
139- pub fn span_fatal ( & self , sp : Span , msg : & str ) -> ! {
139+ pub fn span_fatal < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
140140 panic ! ( self . diagnostic( ) . span_fatal( sp, msg) )
141141 }
142- pub fn span_fatal_with_code ( & self , sp : Span , msg : & str , code : & str ) -> ! {
142+ pub fn span_fatal_with_code < S : Into < MultiSpan > > ( & self , sp : S , msg : & str , code : & str ) -> ! {
143143 panic ! ( self . diagnostic( ) . span_fatal_with_code( sp, msg, code) )
144144 }
145145 pub fn fatal ( & self , msg : & str ) -> ! {
146146 panic ! ( self . diagnostic( ) . fatal( msg) )
147147 }
148- pub fn span_err_or_warn ( & self , is_warning : bool , sp : Span , msg : & str ) {
148+ pub fn span_err_or_warn < S : Into < MultiSpan > > ( & self , is_warning : bool , sp : S , msg : & str ) {
149149 if is_warning {
150150 self . span_warn ( sp, msg) ;
151151 } else {
152152 self . span_err ( sp, msg) ;
153153 }
154154 }
155- pub fn span_err ( & self , sp : Span , msg : & str ) {
155+ pub fn span_err < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
156156 match split_msg_into_multilines ( msg) {
157157 Some ( msg) => self . diagnostic ( ) . span_err ( sp, & msg) ,
158158 None => self . diagnostic ( ) . span_err ( sp, msg)
159159 }
160160 }
161- pub fn span_err_with_code ( & self , sp : Span , msg : & str , code : & str ) {
161+ pub fn span_err_with_code < S : Into < MultiSpan > > ( & self , sp : S , msg : & str , code : & str ) {
162162 match split_msg_into_multilines ( msg) {
163163 Some ( msg) => self . diagnostic ( ) . span_err_with_code ( sp, & msg, code) ,
164164 None => self . diagnostic ( ) . span_err_with_code ( sp, msg, code)
@@ -199,32 +199,32 @@ impl Session {
199199 }
200200 }
201201 }
202- pub fn span_warn ( & self , sp : Span , msg : & str ) {
202+ pub fn span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
203203 self . diagnostic ( ) . span_warn ( sp, msg)
204204 }
205- pub fn span_warn_with_code ( & self , sp : Span , msg : & str , code : & str ) {
205+ pub fn span_warn_with_code < S : Into < MultiSpan > > ( & self , sp : S , msg : & str , code : & str ) {
206206 self . diagnostic ( ) . span_warn_with_code ( sp, msg, code)
207207 }
208208 pub fn warn ( & self , msg : & str ) {
209209 self . diagnostic ( ) . warn ( msg)
210210 }
211- pub fn opt_span_warn ( & self , opt_sp : Option < Span > , msg : & str ) {
211+ pub fn opt_span_warn < S : Into < MultiSpan > > ( & self , opt_sp : Option < S > , msg : & str ) {
212212 match opt_sp {
213213 Some ( sp) => self . span_warn ( sp, msg) ,
214214 None => self . warn ( msg) ,
215215 }
216216 }
217- pub fn opt_span_bug ( & self , opt_sp : Option < Span > , msg : & str ) -> ! {
217+ pub fn opt_span_bug < S : Into < MultiSpan > > ( & self , opt_sp : Option < S > , msg : & str ) -> ! {
218218 match opt_sp {
219219 Some ( sp) => self . span_bug ( sp, msg) ,
220220 None => self . bug ( msg) ,
221221 }
222222 }
223223 /// Delay a span_bug() call until abort_if_errors()
224- pub fn delay_span_bug ( & self , sp : Span , msg : & str ) {
224+ pub fn delay_span_bug < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
225225 self . diagnostic ( ) . delay_span_bug ( sp, msg)
226226 }
227- pub fn span_bug ( & self , sp : Span , msg : & str ) -> ! {
227+ pub fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
228228 self . diagnostic ( ) . span_bug ( sp, msg)
229229 }
230230 pub fn bug ( & self , msg : & str ) -> ! {
@@ -233,10 +233,10 @@ impl Session {
233233 pub fn note_without_error ( & self , msg : & str ) {
234234 self . diagnostic ( ) . note_without_error ( msg)
235235 }
236- pub fn span_note_without_error ( & self , sp : Span , msg : & str ) {
236+ pub fn span_note_without_error < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
237237 self . diagnostic ( ) . span_note_without_error ( sp, msg)
238238 }
239- pub fn span_unimpl ( & self , sp : Span , msg : & str ) -> ! {
239+ pub fn span_unimpl < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
240240 self . diagnostic ( ) . span_unimpl ( sp, msg)
241241 }
242242 pub fn unimpl ( & self , msg : & str ) -> ! {
@@ -273,7 +273,7 @@ impl Session {
273273 }
274274 // This exists to help with refactoring to eliminate impossible
275275 // cases later on
276- pub fn impossible_case ( & self , sp : Span , msg : & str ) -> ! {
276+ pub fn impossible_case < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
277277 self . span_bug ( sp, & format ! ( "impossible case reached: {}" , msg) ) ;
278278 }
279279 pub fn verbose ( & self ) -> bool { self . opts . debugging_opts . verbose }
0 commit comments