diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-04-29 18:48:58 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-05-03 11:26:58 +0200 |
| commit | d33140d2dc95c33bc8281b476048c923476c8b73 (patch) | |
| tree | 0c34de2c8a888f4babf83db1d022c1666c0c1684 /compiler/rustc_parse_format/src/tests.rs | |
| parent | 683c582c1e88c573c454b7fa6f00bc6647421864 (diff) | |
| download | rust-d33140d2dc95c33bc8281b476048c923476c8b73.tar.gz rust-d33140d2dc95c33bc8281b476048c923476c8b73.zip | |
Make rustc_parse_format compile on stable
This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
Diffstat (limited to 'compiler/rustc_parse_format/src/tests.rs')
| -rw-r--r-- | compiler/rustc_parse_format/src/tests.rs | 172 |
1 files changed, 85 insertions, 87 deletions
diff --git a/compiler/rustc_parse_format/src/tests.rs b/compiler/rustc_parse_format/src/tests.rs index 6c960fdc72b..c9667922ee7 100644 --- a/compiler/rustc_parse_format/src/tests.rs +++ b/compiler/rustc_parse_format/src/tests.rs @@ -144,93 +144,91 @@ fn format_align_fill() { } #[test] fn format_counts() { - rustc_span::create_default_session_globals_then(|| { - same( - "{:10x}", - &[NextArgument(Argument { - position: ArgumentImplicitlyIs(0), - format: FormatSpec { - fill: None, - align: AlignUnknown, - flags: 0, - precision: CountImplied, - width: CountIs(10), - precision_span: None, - width_span: None, - ty: "x", - ty_span: None, - }, - })], - ); - same( - "{:10$.10x}", - &[NextArgument(Argument { - position: ArgumentImplicitlyIs(0), - format: FormatSpec { - fill: None, - align: AlignUnknown, - flags: 0, - precision: CountIs(10), - width: CountIsParam(10), - precision_span: None, - width_span: Some(InnerSpan::new(3, 6)), - ty: "x", - ty_span: None, - }, - })], - ); - same( - "{:.*x}", - &[NextArgument(Argument { - position: ArgumentImplicitlyIs(1), - format: FormatSpec { - fill: None, - align: AlignUnknown, - flags: 0, - precision: CountIsParam(0), - width: CountImplied, - precision_span: Some(InnerSpan::new(3, 5)), - width_span: None, - ty: "x", - ty_span: None, - }, - })], - ); - same( - "{:.10$x}", - &[NextArgument(Argument { - position: ArgumentImplicitlyIs(0), - format: FormatSpec { - fill: None, - align: AlignUnknown, - flags: 0, - precision: CountIsParam(10), - width: CountImplied, - precision_span: Some(InnerSpan::new(3, 7)), - width_span: None, - ty: "x", - ty_span: None, - }, - })], - ); - same( - "{:a$.b$?}", - &[NextArgument(Argument { - position: ArgumentImplicitlyIs(0), - format: FormatSpec { - fill: None, - align: AlignUnknown, - flags: 0, - precision: CountIsName(Symbol::intern("b"), InnerSpan::new(6, 7)), - width: CountIsName(Symbol::intern("a"), InnerSpan::new(4, 4)), - precision_span: None, - width_span: None, - ty: "?", - ty_span: None, - }, - })], - ); - }); + same( + "{:10x}", + &[NextArgument(Argument { + position: ArgumentImplicitlyIs(0), + format: FormatSpec { + fill: None, + align: AlignUnknown, + flags: 0, + precision: CountImplied, + width: CountIs(10), + precision_span: None, + width_span: None, + ty: "x", + ty_span: None, + }, + })], + ); + same( + "{:10$.10x}", + &[NextArgument(Argument { + position: ArgumentImplicitlyIs(0), + format: FormatSpec { + fill: None, + align: AlignUnknown, + flags: 0, + precision: CountIs(10), + width: CountIsParam(10), + precision_span: None, + width_span: Some(InnerSpan::new(3, 6)), + ty: "x", + ty_span: None, + }, + })], + ); + same( + "{:.*x}", + &[NextArgument(Argument { + position: ArgumentImplicitlyIs(1), + format: FormatSpec { + fill: None, + align: AlignUnknown, + flags: 0, + precision: CountIsParam(0), + width: CountImplied, + precision_span: Some(InnerSpan::new(3, 5)), + width_span: None, + ty: "x", + ty_span: None, + }, + })], + ); + same( + "{:.10$x}", + &[NextArgument(Argument { + position: ArgumentImplicitlyIs(0), + format: FormatSpec { + fill: None, + align: AlignUnknown, + flags: 0, + precision: CountIsParam(10), + width: CountImplied, + precision_span: Some(InnerSpan::new(3, 7)), + width_span: None, + ty: "x", + ty_span: None, + }, + })], + ); + same( + "{:a$.b$?}", + &[NextArgument(Argument { + position: ArgumentImplicitlyIs(0), + format: FormatSpec { + fill: None, + align: AlignUnknown, + flags: 0, + precision: CountIsName("b", InnerSpan::new(6, 7)), + width: CountIsName("a", InnerSpan::new(4, 4)), + precision_span: None, + width_span: None, + ty: "?", + ty_span: None, + }, + })], + ); } #[test] fn format_flags() { |
