@@ -15,7 +15,7 @@ use session::search_paths::PathKind;
15
15
use util:: nodemap:: { NodeMap , FnvHashMap } ;
16
16
17
17
use syntax:: ast:: { NodeId , NodeIdAssigner , Name } ;
18
- use syntax:: codemap:: Span ;
18
+ use syntax:: codemap:: { Span , MultiSpan } ;
19
19
use syntax:: errors:: { self , DiagnosticBuilder } ;
20
20
use syntax:: errors:: emitter:: { Emitter , BasicEmitter , EmitterWriter } ;
21
21
use syntax:: errors:: json:: JsonEmitter ;
@@ -47,7 +47,7 @@ pub struct Session {
47
47
pub cstore : Rc <for <' a > CrateStore < ' a > >,
48
48
pub parse_sess : ParseSess ,
49
49
// 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 ) > > ,
51
51
pub entry_type : Cell < Option < config:: EntryFnType > > ,
52
52
pub plugin_registrar_fn : Cell < Option < ast:: NodeId > > ,
53
53
pub default_sysroot : Option < PathBuf > ,
@@ -57,7 +57,7 @@ pub struct Session {
57
57
pub local_crate_source_file : Option < PathBuf > ,
58
58
pub working_dir : PathBuf ,
59
59
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 ) > > > ,
61
61
pub plugin_llvm_passes : RefCell < Vec < String > > ,
62
62
pub plugin_attributes : RefCell < Vec < ( String , AttributeType ) > > ,
63
63
pub crate_types : RefCell < Vec < config:: CrateType > > ,
@@ -81,36 +81,36 @@ pub struct Session {
81
81
}
82
82
83
83
impl 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 > {
88
88
self . diagnostic ( ) . struct_span_warn ( sp, msg)
89
89
}
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 > {
95
95
self . diagnostic ( ) . struct_span_warn_with_code ( sp, msg, code)
96
96
}
97
97
pub fn struct_warn < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
98
98
self . diagnostic ( ) . struct_warn ( msg)
99
99
}
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 > {
104
104
match split_msg_into_multilines ( msg) {
105
105
Some ( ref msg) => self . diagnostic ( ) . struct_span_err ( sp, msg) ,
106
106
None => self . diagnostic ( ) . struct_span_err ( sp, msg) ,
107
107
}
108
108
}
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 > {
114
114
match split_msg_into_multilines ( msg) {
115
115
Some ( ref msg) => self . diagnostic ( ) . struct_span_err_with_code ( sp, msg, code) ,
116
116
None => self . diagnostic ( ) . struct_span_err_with_code ( sp, msg, code) ,
@@ -119,46 +119,46 @@ impl Session {
119
119
pub fn struct_err < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
120
120
self . diagnostic ( ) . struct_err ( msg)
121
121
}
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 > {
126
126
self . diagnostic ( ) . struct_span_fatal ( sp, msg)
127
127
}
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 > {
133
133
self . diagnostic ( ) . struct_span_fatal_with_code ( sp, msg, code)
134
134
}
135
135
pub fn struct_fatal < ' a > ( & ' a self , msg : & str ) -> DiagnosticBuilder < ' a > {
136
136
self . diagnostic ( ) . struct_fatal ( msg)
137
137
}
138
138
139
- pub fn span_fatal ( & self , sp : Span , msg : & str ) -> ! {
139
+ pub fn span_fatal < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
140
140
panic ! ( self . diagnostic( ) . span_fatal( sp, msg) )
141
141
}
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 ) -> ! {
143
143
panic ! ( self . diagnostic( ) . span_fatal_with_code( sp, msg, code) )
144
144
}
145
145
pub fn fatal ( & self , msg : & str ) -> ! {
146
146
panic ! ( self . diagnostic( ) . fatal( msg) )
147
147
}
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 ) {
149
149
if is_warning {
150
150
self . span_warn ( sp, msg) ;
151
151
} else {
152
152
self . span_err ( sp, msg) ;
153
153
}
154
154
}
155
- pub fn span_err ( & self , sp : Span , msg : & str ) {
155
+ pub fn span_err < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
156
156
match split_msg_into_multilines ( msg) {
157
157
Some ( msg) => self . diagnostic ( ) . span_err ( sp, & msg) ,
158
158
None => self . diagnostic ( ) . span_err ( sp, msg)
159
159
}
160
160
}
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 ) {
162
162
match split_msg_into_multilines ( msg) {
163
163
Some ( msg) => self . diagnostic ( ) . span_err_with_code ( sp, & msg, code) ,
164
164
None => self . diagnostic ( ) . span_err_with_code ( sp, msg, code)
@@ -199,32 +199,32 @@ impl Session {
199
199
}
200
200
}
201
201
}
202
- pub fn span_warn ( & self , sp : Span , msg : & str ) {
202
+ pub fn span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
203
203
self . diagnostic ( ) . span_warn ( sp, msg)
204
204
}
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 ) {
206
206
self . diagnostic ( ) . span_warn_with_code ( sp, msg, code)
207
207
}
208
208
pub fn warn ( & self , msg : & str ) {
209
209
self . diagnostic ( ) . warn ( msg)
210
210
}
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 ) {
212
212
match opt_sp {
213
213
Some ( sp) => self . span_warn ( sp, msg) ,
214
214
None => self . warn ( msg) ,
215
215
}
216
216
}
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 ) -> ! {
218
218
match opt_sp {
219
219
Some ( sp) => self . span_bug ( sp, msg) ,
220
220
None => self . bug ( msg) ,
221
221
}
222
222
}
223
223
/// 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 ) {
225
225
self . diagnostic ( ) . delay_span_bug ( sp, msg)
226
226
}
227
- pub fn span_bug ( & self , sp : Span , msg : & str ) -> ! {
227
+ pub fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
228
228
self . diagnostic ( ) . span_bug ( sp, msg)
229
229
}
230
230
pub fn bug ( & self , msg : & str ) -> ! {
@@ -233,10 +233,10 @@ impl Session {
233
233
pub fn note_without_error ( & self , msg : & str ) {
234
234
self . diagnostic ( ) . note_without_error ( msg)
235
235
}
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 ) {
237
237
self . diagnostic ( ) . span_note_without_error ( sp, msg)
238
238
}
239
- pub fn span_unimpl ( & self , sp : Span , msg : & str ) -> ! {
239
+ pub fn span_unimpl < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
240
240
self . diagnostic ( ) . span_unimpl ( sp, msg)
241
241
}
242
242
pub fn unimpl ( & self , msg : & str ) -> ! {
@@ -273,7 +273,7 @@ impl Session {
273
273
}
274
274
// This exists to help with refactoring to eliminate impossible
275
275
// 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 ) -> ! {
277
277
self . span_bug ( sp, & format ! ( "impossible case reached: {}" , msg) ) ;
278
278
}
279
279
pub fn verbose ( & self ) -> bool { self . opts . debugging_opts . verbose }
0 commit comments