@@ -153,21 +153,13 @@ fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<
153
153
Ok ( MacroInput { fmtstr, args, is_direct_literal } )
154
154
}
155
155
156
- fn make_format_args (
157
- ecx : & mut ExtCtxt < ' _ > ,
158
- input : MacroInput ,
159
- append_newline : bool ,
160
- ) -> Result < FormatArgs , ( ) > {
156
+ fn make_format_args ( ecx : & mut ExtCtxt < ' _ > , input : MacroInput ) -> Result < FormatArgs , ( ) > {
161
157
let msg = "format argument must be a string literal" ;
162
158
let unexpanded_fmt_span = input. fmtstr . span ;
163
159
164
160
let MacroInput { fmtstr : efmt, mut args, is_direct_literal } = input;
165
161
166
162
let ( fmt_str, fmt_style, fmt_span) = match expr_to_spanned_string ( ecx, efmt, msg) {
167
- Ok ( mut fmt) if append_newline => {
168
- fmt. 0 = Symbol :: intern ( & format ! ( "{}\n " , fmt. 0 ) ) ;
169
- fmt
170
- }
171
163
Ok ( fmt) => fmt,
172
164
Err ( err) => {
173
165
if let Some ( ( mut err, suggested) ) = err {
@@ -196,13 +188,7 @@ fn make_format_args(
196
188
197
189
let fmt_str = fmt_str. as_str ( ) ; // for the suggestions below
198
190
let fmt_snippet = ecx. source_map ( ) . span_to_snippet ( unexpanded_fmt_span) . ok ( ) ;
199
- let mut parser = parse:: Parser :: new (
200
- fmt_str,
201
- str_style,
202
- fmt_snippet,
203
- append_newline,
204
- parse:: ParseMode :: Format ,
205
- ) ;
191
+ let mut parser = parse:: Parser :: new ( fmt_str, str_style, fmt_snippet, parse:: ParseMode :: Format ) ;
206
192
207
193
let mut pieces = Vec :: new ( ) ;
208
194
while let Some ( piece) = parser. next ( ) {
@@ -831,16 +817,15 @@ fn report_invalid_references(
831
817
e. emit ( ) ;
832
818
}
833
819
834
- fn expand_format_args_impl < ' cx > (
820
+ pub fn expand_format_args < ' cx > (
835
821
ecx : & ' cx mut ExtCtxt < ' _ > ,
836
822
mut sp : Span ,
837
823
tts : TokenStream ,
838
- nl : bool ,
839
824
) -> Box < dyn base:: MacResult + ' cx > {
840
825
sp = ecx. with_def_site_ctxt ( sp) ;
841
826
match parse_args ( ecx, sp, tts) {
842
827
Ok ( input) => {
843
- if let Ok ( format_args) = make_format_args ( ecx, input, nl ) {
828
+ if let Ok ( format_args) = make_format_args ( ecx, input) {
844
829
MacEager :: expr ( ecx. expr ( sp, ExprKind :: FormatArgs ( P ( format_args) ) ) )
845
830
} else {
846
831
MacEager :: expr ( DummyResult :: raw_expr ( sp, true ) )
@@ -852,19 +837,3 @@ fn expand_format_args_impl<'cx>(
852
837
}
853
838
}
854
839
}
855
-
856
- pub fn expand_format_args < ' cx > (
857
- ecx : & ' cx mut ExtCtxt < ' _ > ,
858
- sp : Span ,
859
- tts : TokenStream ,
860
- ) -> Box < dyn base:: MacResult + ' cx > {
861
- expand_format_args_impl ( ecx, sp, tts, false )
862
- }
863
-
864
- pub fn expand_format_args_nl < ' cx > (
865
- ecx : & ' cx mut ExtCtxt < ' _ > ,
866
- sp : Span ,
867
- tts : TokenStream ,
868
- ) -> Box < dyn base:: MacResult + ' cx > {
869
- expand_format_args_impl ( ecx, sp, tts, true )
870
- }
0 commit comments