Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 558d241

Browse files
committedOct 14, 2024·
Evaluate std::fmt::Arguments::new_const() During Compile Time
1 parent deb0d0f commit 558d241

File tree

19 files changed

+112
-126
lines changed

19 files changed

+112
-126
lines changed
 

‎compiler/rustc_ast_lowering/src/format.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_ast::visit::Visitor;
55
use rustc_ast::*;
66
use rustc_data_structures::fx::FxIndexMap;
77
use rustc_hir as hir;
8+
use rustc_hir::def::DefKind;
89
use rustc_session::config::FmtDebug;
910
use rustc_span::symbol::{Ident, kw};
1011
use rustc_span::{Span, Symbol, sym};
@@ -24,6 +25,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
2425
expand_format_args(self, sp, &fmt, allow_const)
2526
}
2627

28+
/// Wraps given `ExprKind` in an inline const block.
29+
///
30+
/// Caller must ensure it's safe and sound to do so.
31+
fn wrap_in_const_context(
32+
&mut self,
33+
sp: Span,
34+
kind: hir::ExprKind<'hir>,
35+
) -> hir::ExprKind<'hir> {
36+
let expr = hir::Expr { hir_id: self.next_id(), kind, span: self.lower_span(sp) };
37+
let const_node_id = self.next_node_id();
38+
let parent_def_id = self.current_def_id_parent;
39+
let def_id =
40+
self.create_def(parent_def_id, const_node_id, kw::Empty, DefKind::InlineConst, sp);
41+
let hir_id = self.lower_node_id(const_node_id);
42+
let const_block = self.with_new_scopes(sp, |this| hir::ConstBlock {
43+
def_id,
44+
hir_id,
45+
body: this.with_def_id_parent(def_id, |this| this.lower_body(|_| (&[], expr))),
46+
});
47+
hir::ExprKind::ConstBlock(const_block)
48+
}
49+
2750
/// Try to convert a literal into an interned string
2851
fn try_inline_lit(&self, lit: token::Lit) -> Option<Symbol> {
2952
match LitKind::from_token_lit(lit) {
@@ -464,14 +487,14 @@ fn expand_format_args<'hir>(
464487

465488
if allow_const && arguments.is_empty() && argmap.is_empty() {
466489
// Generate:
467-
// <core::fmt::Arguments>::new_const(lit_pieces)
490+
// const { <core::fmt::Arguments>::new_const(lit_pieces) }
468491
let new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
469492
macsp,
470493
hir::LangItem::FormatArguments,
471494
sym::new_const,
472495
));
473496
let new_args = ctx.arena.alloc_from_iter([lit_pieces]);
474-
return hir::ExprKind::Call(new, new_args);
497+
return ctx.wrap_in_const_context(macsp, hir::ExprKind::Call(new, new_args));
475498
}
476499

477500
// If the args array contains exactly all the original arguments once,

‎library/core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub struct Arguments<'a> {
333333
#[unstable(feature = "fmt_internals", issue = "none")]
334334
impl<'a> Arguments<'a> {
335335
#[inline]
336-
#[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")]
336+
#[rustc_const_stable(feature = "const_fmt_arguments_new", since = "CURRENT_RUSTC_VERSION")]
337337
pub const fn new_const<const N: usize>(pieces: &'a [&'static str; N]) -> Self {
338338
const { assert!(N <= 1) };
339339
Arguments { pieces, fmt: None, args: &[] }

‎library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
#![feature(const_char_encode_utf16)]
121121
#![feature(const_eval_select)]
122122
#![feature(const_exact_div)]
123-
#![feature(const_fmt_arguments_new)]
124123
#![feature(const_hash)]
125124
#![feature(const_heap)]
126125
#![feature(const_index_range_slice_index)]

‎library/core/src/macros/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ pub(crate) mod builtin {
10381038
///
10391039
/// This macro will be removed once `format_args` is allowed in const contexts.
10401040
#[unstable(feature = "const_format_args", issue = "none")]
1041-
#[allow_internal_unstable(fmt_internals, const_fmt_arguments_new)]
1041+
#[allow_internal_unstable(fmt_internals)]
10421042
#[rustc_builtin_macro]
10431043
#[macro_export]
10441044
macro_rules! const_format_args {

‎tests/codegen/issues/issue-128709-format-without-args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![crate_type = "lib"]
44

55
// String formating macros without any arguments should compile
6-
// to a `memcpy` followed by a call to `std::io::stdio::_print`.
6+
// to a `memcpy` followed by a call to a library function.
77

88
#[no_mangle]
99
pub fn code() {

‎tests/coverage/assert.cov-map

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ Number of file 0 mappings: 9
2828
Highest counter ID seen: c4
2929

3030
Function name: assert::might_fail_assert
31-
Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 02, 0f, 02, 02, 25, 00, 3d, 05, 01, 01, 00, 02]
31+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 01, 02, 3e, 05, 03, 01, 00, 02]
3232
Number of files: 1
3333
- file 0 => global file 1
34-
Number of expressions: 1
35-
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
36-
Number of file 0 mappings: 3
37-
- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 15)
38-
- Code(Expression(0, Sub)) at (prev + 2, 37) to (start + 0, 61)
39-
= (c0 - c1)
40-
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
34+
Number of expressions: 0
35+
Number of file 0 mappings: 2
36+
- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 62)
37+
- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2)
4138
Highest counter ID seen: c1
4239

‎tests/coverage/bad_counter_ids.cov-map

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ Number of file 0 mappings: 2
99
Highest counter ID seen: c0
1010

1111
Function name: bad_counter_ids::eq_bad_message
12-
Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 29, 01, 02, 0f, 02, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
12+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 29, 01, 02, 2c, 00, 03, 01, 00, 02]
1313
Number of files: 1
1414
- file 0 => global file 1
15-
Number of expressions: 1
16-
- expression 0 operands: lhs = Counter(0), rhs = Zero
17-
Number of file 0 mappings: 3
18-
- Code(Counter(0)) at (prev + 41, 1) to (start + 2, 15)
19-
- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43)
20-
= (c0 - Zero)
21-
- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
15+
Number of expressions: 0
16+
Number of file 0 mappings: 2
17+
- Code(Counter(0)) at (prev + 41, 1) to (start + 2, 44)
18+
- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
2219
Highest counter ID seen: c0
2320

2421
Function name: bad_counter_ids::eq_good
@@ -32,14 +29,13 @@ Number of file 0 mappings: 2
3229
Highest counter ID seen: c1
3330

3431
Function name: bad_counter_ids::eq_good_message
35-
Raw bytes (19): 0x[01, 01, 00, 03, 01, 15, 01, 02, 0f, 00, 02, 20, 00, 2b, 05, 01, 01, 00, 02]
32+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 15, 01, 02, 2c, 05, 03, 01, 00, 02]
3633
Number of files: 1
3734
- file 0 => global file 1
3835
Number of expressions: 0
39-
Number of file 0 mappings: 3
40-
- Code(Counter(0)) at (prev + 21, 1) to (start + 2, 15)
41-
- Code(Zero) at (prev + 2, 32) to (start + 0, 43)
42-
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
36+
Number of file 0 mappings: 2
37+
- Code(Counter(0)) at (prev + 21, 1) to (start + 2, 44)
38+
- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2)
4339
Highest counter ID seen: c1
4440

4541
Function name: bad_counter_ids::ne_bad
@@ -53,15 +49,14 @@ Number of file 0 mappings: 2
5349
Highest counter ID seen: c0
5450

5551
Function name: bad_counter_ids::ne_bad_message
56-
Raw bytes (19): 0x[01, 01, 00, 03, 01, 33, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
52+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 33, 01, 02, 2c, 00, 03, 01, 00, 02]
5753
Number of files: 1
5854
- file 0 => global file 1
5955
Number of expressions: 0
60-
Number of file 0 mappings: 3
61-
- Code(Counter(0)) at (prev + 51, 1) to (start + 2, 15)
62-
- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43)
63-
- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
64-
Highest counter ID seen: c1
56+
Number of file 0 mappings: 2
57+
- Code(Counter(0)) at (prev + 51, 1) to (start + 2, 44)
58+
- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
59+
Highest counter ID seen: c0
6560

6661
Function name: bad_counter_ids::ne_good
6762
Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 1a, 01, 02, 1f, 02, 03, 01, 00, 02]
@@ -76,15 +71,14 @@ Number of file 0 mappings: 2
7671
Highest counter ID seen: c0
7772

7873
Function name: bad_counter_ids::ne_good_message
79-
Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 1f, 01, 02, 0f, 00, 02, 20, 00, 2b, 02, 01, 01, 00, 02]
74+
Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 1f, 01, 02, 2c, 02, 03, 01, 00, 02]
8075
Number of files: 1
8176
- file 0 => global file 1
8277
Number of expressions: 1
8378
- expression 0 operands: lhs = Counter(0), rhs = Zero
84-
Number of file 0 mappings: 3
85-
- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 15)
86-
- Code(Zero) at (prev + 2, 32) to (start + 0, 43)
87-
- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2)
79+
Number of file 0 mappings: 2
80+
- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 44)
81+
- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2)
8882
= (c0 - Zero)
8983
Highest counter ID seen: c0
9084

‎tests/coverage/closure_macro.cov-map

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@ Number of file 0 mappings: 6
2525
Highest counter ID seen: c1
2626

2727
Function name: closure_macro::main::{closure#0}
28-
Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 05, 01, 10, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a]
28+
Raw bytes (30): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 04, 01, 10, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 1f, 07, 02, 09, 00, 0a]
2929
Number of files: 1
3030
- file 0 => global file 1
3131
Number of expressions: 3
3232
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
3333
- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add)
3434
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
35-
Number of file 0 mappings: 5
35+
Number of file 0 mappings: 4
3636
- Code(Counter(0)) at (prev + 16, 28) to (start + 3, 33)
3737
- Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39)
38-
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 22)
38+
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 31)
3939
= (c0 - c1)
40-
- Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30)
4140
- Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10)
4241
= (c1 + (c2 + c3))
43-
Highest counter ID seen: c3
42+
Highest counter ID seen: c1
4443

‎tests/coverage/closure_macro_async.cov-map

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,19 @@ Number of file 0 mappings: 6
3434
Highest counter ID seen: c1
3535

3636
Function name: closure_macro_async::test::{closure#0}::{closure#0}
37-
Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 05, 01, 15, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a]
37+
Raw bytes (30): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 04, 01, 15, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 1f, 07, 02, 09, 00, 0a]
3838
Number of files: 1
3939
- file 0 => global file 1
4040
Number of expressions: 3
4141
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
4242
- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add)
4343
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
44-
Number of file 0 mappings: 5
44+
Number of file 0 mappings: 4
4545
- Code(Counter(0)) at (prev + 21, 28) to (start + 3, 33)
4646
- Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39)
47-
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 22)
47+
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 31)
4848
= (c0 - c1)
49-
- Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30)
5049
- Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10)
5150
= (c1 + (c2 + c3))
52-
Highest counter ID seen: c3
51+
Highest counter ID seen: c1
5352

‎tests/coverage/issue-84561.cov-map

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,27 @@ Number of file 0 mappings: 1
2222
Highest counter ID seen: c0
2323

2424
Function name: issue_84561::test1
25-
Raw bytes (50): 0x[01, 01, 00, 09, 01, 9a, 01, 01, 01, 0b, 05, 01, 0c, 00, 1e, 01, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 01, 01, 0d, 01, 0b, 0d, 01, 0c, 00, 1e, 01, 01, 05, 03, 0b, 11, 03, 0c, 00, 1e, 01, 01, 01, 00, 02]
25+
Raw bytes (30): 0x[01, 01, 00, 05, 01, 9a, 01, 01, 01, 1f, 01, 02, 05, 00, 1f, 01, 01, 0d, 01, 1f, 01, 02, 05, 03, 1f, 01, 04, 01, 00, 02]
2626
Number of files: 1
2727
- file 0 => global file 1
2828
Number of expressions: 0
29-
Number of file 0 mappings: 9
30-
- Code(Counter(0)) at (prev + 154, 1) to (start + 1, 11)
31-
- Code(Counter(1)) at (prev + 1, 12) to (start + 0, 30)
32-
- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11)
33-
- Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30)
34-
- Code(Counter(0)) at (prev + 1, 13) to (start + 1, 11)
35-
- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 30)
36-
- Code(Counter(0)) at (prev + 1, 5) to (start + 3, 11)
37-
- Code(Counter(4)) at (prev + 3, 12) to (start + 0, 30)
38-
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
39-
Highest counter ID seen: c4
29+
Number of file 0 mappings: 5
30+
- Code(Counter(0)) at (prev + 154, 1) to (start + 1, 31)
31+
- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 31)
32+
- Code(Counter(0)) at (prev + 1, 13) to (start + 1, 31)
33+
- Code(Counter(0)) at (prev + 2, 5) to (start + 3, 31)
34+
- Code(Counter(0)) at (prev + 4, 1) to (start + 0, 2)
35+
Highest counter ID seen: c0
4036

4137
Function name: issue_84561::test2
42-
Raw bytes (20): 0x[01, 01, 00, 03, 01, b0, 01, 01, 01, 10, 05, 01, 11, 00, 23, 01, 01, 01, 00, 02]
38+
Raw bytes (15): 0x[01, 01, 00, 02, 01, b0, 01, 01, 01, 24, 01, 02, 01, 00, 02]
4339
Number of files: 1
4440
- file 0 => global file 1
4541
Number of expressions: 0
46-
Number of file 0 mappings: 3
47-
- Code(Counter(0)) at (prev + 176, 1) to (start + 1, 16)
48-
- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 35)
49-
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
50-
Highest counter ID seen: c1
42+
Number of file 0 mappings: 2
43+
- Code(Counter(0)) at (prev + 176, 1) to (start + 1, 36)
44+
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)
45+
Highest counter ID seen: c0
5146

5247
Function name: issue_84561::test2::call_print
5348
Raw bytes (10): 0x[01, 01, 00, 01, 01, a7, 01, 09, 02, 0a]
@@ -59,10 +54,10 @@ Number of file 0 mappings: 1
5954
Highest counter ID seen: c0
6055

6156
Function name: issue_84561::test3
62-
Raw bytes (375): 0x[01, 01, 31, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, be, 01, c2, 01, 79, 69, 6d, 69, 6d, 69, 6d, c2, 01, 00, 69, 6d, c2, 01, 79, 69, 6d, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, b6, 01, 00, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 77, 03, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, bb, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, c2, 01, 02, 0d, 00, 17, c2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, b6, 01, 02, 05, 00, 0f, b2, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
57+
Raw bytes (330): 0x[01, 01, 2c, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, aa, 01, ae, 01, 79, 69, 6d, 69, 6d, 69, 6d, ae, 01, 00, 69, 6d, ae, 01, 79, 69, 6d, a7, 01, 7d, 75, aa, 01, ae, 01, 79, 69, 6d, 2d, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 31, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 04, 0a, 3a, 06, 09, 04, 0a, 77, 06, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, a7, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, ae, 01, 02, 0d, 00, 17, ae, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, aa, 01, 04, 0d, 00, 13, a2, 01, 05, 05, 04, 06, 00, 05, 05, 04, 06, 00, 05, 01, 00, 02]
6358
Number of files: 1
6459
- file 0 => global file 1
65-
Number of expressions: 49
60+
Number of expressions: 44
6661
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
6762
- expression 1 operands: lhs = Counter(3), rhs = Zero
6863
- expression 2 operands: lhs = Counter(5), rhs = Counter(6)
@@ -94,25 +89,20 @@ Number of expressions: 49
9489
- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(24)
9590
- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(21)
9691
- expression 30 operands: lhs = Counter(20), rhs = Zero
97-
- expression 31 operands: lhs = Counter(29), rhs = Expression(47, Sub)
98-
- expression 32 operands: lhs = Expression(48, Sub), rhs = Counter(30)
92+
- expression 31 operands: lhs = Counter(29), rhs = Expression(42, Sub)
93+
- expression 32 operands: lhs = Expression(43, Sub), rhs = Counter(30)
9994
- expression 33 operands: lhs = Counter(26), rhs = Counter(27)
10095
- expression 34 operands: lhs = Counter(26), rhs = Counter(27)
10196
- expression 35 operands: lhs = Counter(26), rhs = Counter(27)
102-
- expression 36 operands: lhs = Expression(48, Sub), rhs = Zero
97+
- expression 36 operands: lhs = Expression(43, Sub), rhs = Zero
10398
- expression 37 operands: lhs = Counter(26), rhs = Counter(27)
104-
- expression 38 operands: lhs = Expression(48, Sub), rhs = Counter(30)
99+
- expression 38 operands: lhs = Expression(43, Sub), rhs = Counter(30)
105100
- expression 39 operands: lhs = Counter(26), rhs = Counter(27)
106-
- expression 40 operands: lhs = Expression(46, Add), rhs = Counter(31)
107-
- expression 41 operands: lhs = Counter(29), rhs = Expression(47, Sub)
108-
- expression 42 operands: lhs = Expression(48, Sub), rhs = Counter(30)
101+
- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(31)
102+
- expression 41 operands: lhs = Counter(29), rhs = Expression(42, Sub)
103+
- expression 42 operands: lhs = Expression(43, Sub), rhs = Counter(30)
109104
- expression 43 operands: lhs = Counter(26), rhs = Counter(27)
110-
- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero
111-
- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(31)
112-
- expression 46 operands: lhs = Counter(29), rhs = Expression(47, Sub)
113-
- expression 47 operands: lhs = Expression(48, Sub), rhs = Counter(30)
114-
- expression 48 operands: lhs = Counter(26), rhs = Counter(27)
115-
Number of file 0 mappings: 51
105+
Number of file 0 mappings: 45
116106
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28)
117107
- Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28)
118108
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 4, 31)
@@ -123,9 +113,8 @@ Number of file 0 mappings: 51
123113
- Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28)
124114
- Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31)
125115
= (c5 - c6)
126-
- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15)
116+
- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 49)
127117
= ((c5 - c6) - Zero)
128-
- Code(Zero) at (prev + 0, 32) to (start + 0, 48)
129118
- Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15)
130119
- Code(Zero) at (prev + 3, 32) to (start + 0, 48)
131120
- Code(Zero) at (prev + 0, 51) to (start + 0, 65)
@@ -148,12 +137,10 @@ Number of file 0 mappings: 51
148137
= ((c15 - Zero) - c17)
149138
- Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15)
150139
= ((c17 - Zero) + c18)
151-
- Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19)
152-
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
153-
- Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19)
140+
- Code(Counter(20)) at (prev + 1, 9) to (start + 4, 10)
141+
- Code(Expression(14, Sub)) at (prev + 6, 9) to (start + 4, 10)
154142
= (((c17 - Zero) + c18) - c20)
155-
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
156-
- Code(Expression(29, Add)) at (prev + 3, 5) to (start + 0, 15)
143+
- Code(Expression(29, Add)) at (prev + 6, 5) to (start + 0, 15)
157144
= ((c20 - Zero) + c21)
158145
- Code(Expression(29, Add)) at (prev + 1, 12) to (start + 0, 19)
159146
= ((c20 - Zero) + c21)
@@ -165,27 +152,23 @@ Number of file 0 mappings: 51
165152
- Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19)
166153
- Code(Expression(27, Sub)) at (prev + 2, 13) to (start + 0, 19)
167154
= ((((c20 - Zero) + c21) - c24) - c25)
168-
- Code(Expression(46, Add)) at (prev + 3, 5) to (start + 0, 15)
155+
- Code(Expression(41, Add)) at (prev + 3, 5) to (start + 0, 15)
169156
= (c29 + ((c26 - c27) - c30))
170157
- Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
171158
- Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14)
172159
- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19)
173-
- Code(Expression(48, Sub)) at (prev + 2, 13) to (start + 0, 23)
160+
- Code(Expression(43, Sub)) at (prev + 2, 13) to (start + 0, 23)
174161
= (c26 - c27)
175-
- Code(Expression(48, Sub)) at (prev + 1, 20) to (start + 0, 27)
162+
- Code(Expression(43, Sub)) at (prev + 1, 20) to (start + 0, 27)
176163
= (c26 - c27)
177164
- Code(Zero) at (prev + 1, 21) to (start + 0, 27)
178165
- Code(Expression(36, Sub)) at (prev + 2, 21) to (start + 0, 27)
179166
= ((c26 - c27) - Zero)
180-
- Code(Expression(47, Sub)) at (prev + 4, 13) to (start + 0, 19)
167+
- Code(Expression(42, Sub)) at (prev + 4, 13) to (start + 0, 19)
181168
= ((c26 - c27) - c30)
182-
- Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25)
183-
- Code(Expression(45, Sub)) at (prev + 2, 5) to (start + 0, 15)
169+
- Code(Expression(40, Sub)) at (prev + 5, 5) to (start + 4, 6)
184170
= ((c29 + ((c26 - c27) - c30)) - c31)
185-
- Code(Expression(44, Sub)) at (prev + 3, 9) to (start + 0, 34)
186-
= (((c29 + ((c26 - c27) - c30)) - c31) - Zero)
187-
- Code(Zero) at (prev + 2, 5) to (start + 0, 15)
188-
- Code(Zero) at (prev + 3, 9) to (start + 0, 44)
189-
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
190-
Highest counter ID seen: c31
171+
- Code(Zero) at (prev + 5, 5) to (start + 4, 6)
172+
- Code(Zero) at (prev + 5, 1) to (start + 0, 2)
173+
Highest counter ID seen: c29
191174

‎tests/crashes/105249.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ compile-flags: -Zpolymorphize=on
33

44
trait Foo<T> {
5-
fn print<'a>(&'a self) where T: 'a { println!("foo"); }
5+
fn print<'a>(&'a self) where T: 'a { println!("{}", "foo"); }
66
}
77

88
impl<'a> Foo<&'a ()> for () { }

‎tests/incremental/hashes/inherent_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Foo {
8383
//--------------------------
8484
#[inline]
8585
pub fn method_body_inlined() {
86-
// -----------------------
86+
// ---------------------
8787
}
8888
}
8989

@@ -105,7 +105,7 @@ impl Foo {
105105
#[rustc_clean(cfg="cfail6")]
106106
#[inline]
107107
pub fn method_body_inlined() {
108-
println!("Hello, world!");
108+
println!("{}", "Hello");
109109
}
110110
}
111111

‎tests/incremental/hygiene/auxiliary/cached_hygiene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#[allow(unused)]
1010
macro_rules! first_macro {
1111
() => {
12-
println!("New call!");
12+
println!("{}", "hola");
1313
}
1414
}
1515

‎tests/ui/borrowck/issue-64453.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ struct Value;
33

44
static settings_dir: String = format!("");
55
//~^ ERROR cannot call non-const fn
6-
//~| ERROR is not yet stable as a const
76

87
fn from_string(_: String) -> Value {
98
Value

‎tests/ui/borrowck/issue-64453.stderr

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error: `Arguments::<'a>::new_const` is not yet stable as a const fn
2-
--> $DIR/issue-64453.rs:4:31
3-
|
4-
LL | static settings_dir: String = format!("");
5-
| ^^^^^^^^^^^
6-
|
7-
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
8-
= note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
9-
101
error[E0015]: cannot call non-const fn `format` in statics
112
--> $DIR/issue-64453.rs:4:31
123
|
@@ -18,7 +9,7 @@ LL | static settings_dir: String = format!("");
189
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
1910

2011
error[E0507]: cannot move out of static item `settings_dir`
21-
--> $DIR/issue-64453.rs:14:37
12+
--> $DIR/issue-64453.rs:13:37
2213
|
2314
LL | let settings_data = from_string(settings_dir);
2415
| ^^^^^^^^^^^^ move occurs because `settings_dir` has type `String`, which does not implement the `Copy` trait
@@ -28,7 +19,7 @@ help: consider cloning the value if the performance cost is acceptable
2819
LL | let settings_data = from_string(settings_dir.clone());
2920
| ++++++++
3021

31-
error: aborting due to 3 previous errors
22+
error: aborting due to 2 previous errors
3223

3324
Some errors have detailed explanations: E0015, E0507.
3425
For more information about an error, try `rustc --explain E0015`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
pub fn main() {
32
const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
43
//~^ use of unstable library feature
4+
//~| temporary value dropped while borrowed
55
}
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
error[E0658]: use of unstable library feature 'fmt_internals'
2-
--> $DIR/const-format-arguments.rs:3:36
2+
--> $DIR/const-format-arguments.rs:2:36
33
|
44
LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(fmt_internals)]` to the crate attributes to enable
88
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99

10-
error: `Arguments::<'a>::new_const` is not yet stable as a const fn
11-
--> $DIR/const-format-arguments.rs:3:36
10+
error[E0716]: temporary value dropped while borrowed
11+
--> $DIR/const-format-arguments.rs:2:68
1212
|
1313
LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
|
16-
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
14+
| --------------------------------^^^^^^^^^-
15+
| | | |
16+
| | | temporary value is freed at the end of this statement
17+
| | creates a temporary value which is freed while still in use
18+
| using this value as a constant requires that borrow lasts for `'static`
1719

1820
error: aborting due to 2 previous errors
1921

20-
For more information about this error, try `rustc --explain E0658`.
22+
Some errors have detailed explanations: E0658, E0716.
23+
For more information about an error, try `rustc --explain E0658`.

‎tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ compile-flags: -Znext-solver
22
#![allow(incomplete_features)]
3-
#![feature(const_fmt_arguments_new)]
43
#![feature(const_trait_impl, effects)]
54

65
#[const_trait]

‎tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0015]: cannot call non-const fn `_print` in constant functions
2-
--> $DIR/issue-79450.rs:11:9
2+
--> $DIR/issue-79450.rs:10:9
33
|
44
LL | println!("lul");
55
| ^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)
Please sign in to comment.