Skip to content

Evaluate std::fmt::Arguments::new_const() during Compile Time #131663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions compiler/rustc_ast_lowering/src/format.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ use rustc_ast::visit::Visitor;
use rustc_ast::*;
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_session::config::FmtDebug;
use rustc_span::symbol::{Ident, kw};
use rustc_span::{Span, Symbol, sym};
@@ -24,6 +25,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
expand_format_args(self, sp, &fmt, allow_const)
}

/// Wraps given `ExprKind` in an inline const block.
///
/// Caller must ensure it's safe and sound to do so.
fn wrap_in_const_context(
&mut self,
sp: Span,
kind: hir::ExprKind<'hir>,
) -> hir::ExprKind<'hir> {
let expr = hir::Expr { hir_id: self.next_id(), kind, span: self.lower_span(sp) };
let const_node_id = self.next_node_id();
let parent_def_id = self.current_def_id_parent;
let def_id =
self.create_def(parent_def_id, const_node_id, kw::Empty, DefKind::InlineConst, sp);
let hir_id = self.lower_node_id(const_node_id);
let const_block = self.with_new_scopes(sp, |this| hir::ConstBlock {
def_id,
hir_id,
body: this.with_def_id_parent(def_id, |this| this.lower_body(|_| (&[], expr))),
});
hir::ExprKind::ConstBlock(const_block)
}

/// Try to convert a literal into an interned string
fn try_inline_lit(&self, lit: token::Lit) -> Option<Symbol> {
match LitKind::from_token_lit(lit) {
@@ -464,14 +487,14 @@ fn expand_format_args<'hir>(

if allow_const && arguments.is_empty() && argmap.is_empty() {
// Generate:
// <core::fmt::Arguments>::new_const(lit_pieces)
// const { <core::fmt::Arguments>::new_const(lit_pieces) }
let new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
macsp,
hir::LangItem::FormatArguments,
sym::new_const,
));
let new_args = ctx.arena.alloc_from_iter([lit_pieces]);
return hir::ExprKind::Call(new, new_args);
return ctx.wrap_in_const_context(macsp, hir::ExprKind::Call(new, new_args));
}

// If the args array contains exactly all the original arguments once,
4 changes: 2 additions & 2 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
@@ -1024,7 +1024,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "format_args_macro")]
#[allow_internal_unsafe]
#[allow_internal_unstable(fmt_internals)]
#[allow_internal_unstable(fmt_internals, const_fmt_arguments_new)]
#[rustc_builtin_macro]
#[macro_export]
macro_rules! format_args {
@@ -1053,7 +1053,7 @@ pub(crate) mod builtin {
reason = "`format_args_nl` is only for internal \
language use and is subject to change"
)]
#[allow_internal_unstable(fmt_internals)]
#[allow_internal_unstable(fmt_internals, const_fmt_arguments_new)]
#[rustc_builtin_macro]
#[macro_export]
macro_rules! format_args_nl {
17 changes: 17 additions & 0 deletions tests/codegen/issues/issue-128709-format-without-args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ compile-flags: -C no-prepopulate-passes -C opt-level=0

#![crate_type = "lib"]

// String formating macros without any arguments should compile
// to a `memcpy` followed by a call to a library function.

#[no_mangle]
pub fn code() {
// CHECK-LABEL: @code
// CHECK-NOT: getelementptr
// CHECK-NOT: store
// CHECK-NOT: ; call core::fmt::Arguments::new_const
// CHECK: call void @llvm.memcpy
// CHECK-NEXT: ; call std::io::stdio::_print
println!("hello world");
}
13 changes: 5 additions & 8 deletions tests/coverage/assert.cov-map
Original file line number Diff line number Diff line change
@@ -28,15 +28,12 @@ Number of file 0 mappings: 9
Highest counter ID seen: c4

Function name: assert::might_fail_assert
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]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 01, 02, 3e, 05, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 3
- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 15)
- Code(Expression(0, Sub)) at (prev + 2, 37) to (start + 0, 61)
= (c0 - c1)
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 62)
- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2)
Highest counter ID seen: c1

42 changes: 18 additions & 24 deletions tests/coverage/bad_counter_ids.cov-map
Original file line number Diff line number Diff line change
@@ -9,16 +9,13 @@ Number of file 0 mappings: 2
Highest counter ID seen: c0

Function name: bad_counter_ids::eq_bad_message
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]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 29, 01, 02, 2c, 00, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Zero
Number of file 0 mappings: 3
- Code(Counter(0)) at (prev + 41, 1) to (start + 2, 15)
- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43)
= (c0 - Zero)
- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 41, 1) to (start + 2, 44)
- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
Highest counter ID seen: c0

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

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

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

Function name: bad_counter_ids::ne_bad_message
Raw bytes (19): 0x[01, 01, 00, 03, 01, 33, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
Raw bytes (14): 0x[01, 01, 00, 02, 01, 33, 01, 02, 2c, 00, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 3
- Code(Counter(0)) at (prev + 51, 1) to (start + 2, 15)
- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43)
- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
Highest counter ID seen: c1
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 51, 1) to (start + 2, 44)
- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
Highest counter ID seen: c0

Function name: bad_counter_ids::ne_good
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
Highest counter ID seen: c0

Function name: bad_counter_ids::ne_good_message
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]
Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 1f, 01, 02, 2c, 02, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(0), rhs = Zero
Number of file 0 mappings: 3
- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 15)
- Code(Zero) at (prev + 2, 32) to (start + 0, 43)
- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2)
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 44)
- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2)
= (c0 - Zero)
Highest counter ID seen: c0

9 changes: 4 additions & 5 deletions tests/coverage/closure_macro.cov-map
Original file line number Diff line number Diff line change
@@ -25,20 +25,19 @@ Number of file 0 mappings: 6
Highest counter ID seen: c1

Function name: closure_macro::main::{closure#0}
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]
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]
Number of files: 1
- file 0 => global file 1
Number of expressions: 3
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add)
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
Number of file 0 mappings: 5
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 16, 28) to (start + 3, 33)
- Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39)
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 22)
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 31)
= (c0 - c1)
- Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30)
- Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10)
= (c1 + (c2 + c3))
Highest counter ID seen: c3
Highest counter ID seen: c1

9 changes: 4 additions & 5 deletions tests/coverage/closure_macro_async.cov-map
Original file line number Diff line number Diff line change
@@ -34,20 +34,19 @@ Number of file 0 mappings: 6
Highest counter ID seen: c1

Function name: closure_macro_async::test::{closure#0}::{closure#0}
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]
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]
Number of files: 1
- file 0 => global file 1
Number of expressions: 3
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add)
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
Number of file 0 mappings: 5
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 21, 28) to (start + 3, 33)
- Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39)
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 22)
- Code(Expression(0, Sub)) at (prev + 3, 17) to (start + 0, 31)
= (c0 - c1)
- Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30)
- Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10)
= (c1 + (c2 + c3))
Highest counter ID seen: c3
Highest counter ID seen: c1

87 changes: 35 additions & 52 deletions tests/coverage/issue-84561.cov-map
Original file line number Diff line number Diff line change
@@ -22,32 +22,27 @@ Number of file 0 mappings: 1
Highest counter ID seen: c0

Function name: issue_84561::test1
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]
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]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 9
- Code(Counter(0)) at (prev + 154, 1) to (start + 1, 11)
- Code(Counter(1)) at (prev + 1, 12) to (start + 0, 30)
- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11)
- Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30)
- Code(Counter(0)) at (prev + 1, 13) to (start + 1, 11)
- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 30)
- Code(Counter(0)) at (prev + 1, 5) to (start + 3, 11)
- Code(Counter(4)) at (prev + 3, 12) to (start + 0, 30)
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
Highest counter ID seen: c4
Number of file 0 mappings: 5
- Code(Counter(0)) at (prev + 154, 1) to (start + 1, 31)
- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 31)
- Code(Counter(0)) at (prev + 1, 13) to (start + 1, 31)
- Code(Counter(0)) at (prev + 2, 5) to (start + 3, 31)
- Code(Counter(0)) at (prev + 4, 1) to (start + 0, 2)
Highest counter ID seen: c0

Function name: issue_84561::test2
Raw bytes (20): 0x[01, 01, 00, 03, 01, b0, 01, 01, 01, 10, 05, 01, 11, 00, 23, 01, 01, 01, 00, 02]
Raw bytes (15): 0x[01, 01, 00, 02, 01, b0, 01, 01, 01, 24, 01, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 3
- Code(Counter(0)) at (prev + 176, 1) to (start + 1, 16)
- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 35)
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
Highest counter ID seen: c1
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 176, 1) to (start + 1, 36)
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)
Highest counter ID seen: c0

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

Function name: issue_84561::test3
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]
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]
Number of files: 1
- file 0 => global file 1
Number of expressions: 49
Number of expressions: 44
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
- expression 1 operands: lhs = Counter(3), rhs = Zero
- expression 2 operands: lhs = Counter(5), rhs = Counter(6)
@@ -94,25 +89,20 @@ Number of expressions: 49
- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(24)
- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(21)
- expression 30 operands: lhs = Counter(20), rhs = Zero
- expression 31 operands: lhs = Counter(29), rhs = Expression(47, Sub)
- expression 32 operands: lhs = Expression(48, Sub), rhs = Counter(30)
- expression 31 operands: lhs = Counter(29), rhs = Expression(42, Sub)
- expression 32 operands: lhs = Expression(43, Sub), rhs = Counter(30)
- expression 33 operands: lhs = Counter(26), rhs = Counter(27)
- expression 34 operands: lhs = Counter(26), rhs = Counter(27)
- expression 35 operands: lhs = Counter(26), rhs = Counter(27)
- expression 36 operands: lhs = Expression(48, Sub), rhs = Zero
- expression 36 operands: lhs = Expression(43, Sub), rhs = Zero
- expression 37 operands: lhs = Counter(26), rhs = Counter(27)
- expression 38 operands: lhs = Expression(48, Sub), rhs = Counter(30)
- expression 38 operands: lhs = Expression(43, Sub), rhs = Counter(30)
- expression 39 operands: lhs = Counter(26), rhs = Counter(27)
- expression 40 operands: lhs = Expression(46, Add), rhs = Counter(31)
- expression 41 operands: lhs = Counter(29), rhs = Expression(47, Sub)
- expression 42 operands: lhs = Expression(48, Sub), rhs = Counter(30)
- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(31)
- expression 41 operands: lhs = Counter(29), rhs = Expression(42, Sub)
- expression 42 operands: lhs = Expression(43, Sub), rhs = Counter(30)
- expression 43 operands: lhs = Counter(26), rhs = Counter(27)
- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero
- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(31)
- expression 46 operands: lhs = Counter(29), rhs = Expression(47, Sub)
- expression 47 operands: lhs = Expression(48, Sub), rhs = Counter(30)
- expression 48 operands: lhs = Counter(26), rhs = Counter(27)
Number of file 0 mappings: 51
Number of file 0 mappings: 45
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28)
- Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28)
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 4, 31)
@@ -123,9 +113,8 @@ Number of file 0 mappings: 51
- Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28)
- Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31)
= (c5 - c6)
- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15)
- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 49)
= ((c5 - c6) - Zero)
- Code(Zero) at (prev + 0, 32) to (start + 0, 48)
- Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15)
- Code(Zero) at (prev + 3, 32) to (start + 0, 48)
- Code(Zero) at (prev + 0, 51) to (start + 0, 65)
@@ -148,12 +137,10 @@ Number of file 0 mappings: 51
= ((c15 - Zero) - c17)
- Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15)
= ((c17 - Zero) + c18)
- Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19)
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
- Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19)
- Code(Counter(20)) at (prev + 1, 9) to (start + 4, 10)
- Code(Expression(14, Sub)) at (prev + 6, 9) to (start + 4, 10)
= (((c17 - Zero) + c18) - c20)
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
- Code(Expression(29, Add)) at (prev + 3, 5) to (start + 0, 15)
- Code(Expression(29, Add)) at (prev + 6, 5) to (start + 0, 15)
= ((c20 - Zero) + c21)
- Code(Expression(29, Add)) at (prev + 1, 12) to (start + 0, 19)
= ((c20 - Zero) + c21)
@@ -165,27 +152,23 @@ Number of file 0 mappings: 51
- Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19)
- Code(Expression(27, Sub)) at (prev + 2, 13) to (start + 0, 19)
= ((((c20 - Zero) + c21) - c24) - c25)
- Code(Expression(46, Add)) at (prev + 3, 5) to (start + 0, 15)
- Code(Expression(41, Add)) at (prev + 3, 5) to (start + 0, 15)
= (c29 + ((c26 - c27) - c30))
- Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
- Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14)
- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(48, Sub)) at (prev + 2, 13) to (start + 0, 23)
- Code(Expression(43, Sub)) at (prev + 2, 13) to (start + 0, 23)
= (c26 - c27)
- Code(Expression(48, Sub)) at (prev + 1, 20) to (start + 0, 27)
- Code(Expression(43, Sub)) at (prev + 1, 20) to (start + 0, 27)
= (c26 - c27)
- Code(Zero) at (prev + 1, 21) to (start + 0, 27)
- Code(Expression(36, Sub)) at (prev + 2, 21) to (start + 0, 27)
= ((c26 - c27) - Zero)
- Code(Expression(47, Sub)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(42, Sub)) at (prev + 4, 13) to (start + 0, 19)
= ((c26 - c27) - c30)
- Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25)
- Code(Expression(45, Sub)) at (prev + 2, 5) to (start + 0, 15)
- Code(Expression(40, Sub)) at (prev + 5, 5) to (start + 4, 6)
= ((c29 + ((c26 - c27) - c30)) - c31)
- Code(Expression(44, Sub)) at (prev + 3, 9) to (start + 0, 34)
= (((c29 + ((c26 - c27) - c30)) - c31) - Zero)
- Code(Zero) at (prev + 2, 5) to (start + 0, 15)
- Code(Zero) at (prev + 3, 9) to (start + 0, 44)
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
Highest counter ID seen: c31
- Code(Zero) at (prev + 5, 5) to (start + 4, 6)
- Code(Zero) at (prev + 5, 1) to (start + 0, 2)
Highest counter ID seen: c29

2 changes: 1 addition & 1 deletion tests/crashes/105249.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//@ compile-flags: -Zpolymorphize=on

trait Foo<T> {
fn print<'a>(&'a self) where T: 'a { println!("foo"); }
fn print<'a>(&'a self) where T: 'a { println!("{}", "foo"); }
}

impl<'a> Foo<&'a ()> for () { }
4 changes: 2 additions & 2 deletions tests/incremental/hashes/inherent_impls.rs
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ impl Foo {
//--------------------------
#[inline]
pub fn method_body_inlined() {
// -----------------------
// ---------------------
}
}

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

2 changes: 1 addition & 1 deletion tests/incremental/hygiene/auxiliary/cached_hygiene.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
#[allow(unused)]
macro_rules! first_macro {
() => {
println!("New call!");
println!("{}", "hola");
}
}

10 changes: 5 additions & 5 deletions tests/pretty/issue-4264.pp
Original file line number Diff line number Diff line change
@@ -33,11 +33,11 @@
fn(String) -> String {must_use::<String>})(({
let res =
((::alloc::fmt::format as
for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
as
fn(&[&'static str; 1]) -> Arguments<'_> {Arguments::<'_>::new_const::<1>})((&([("test"
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
as String);
for<'a> fn(Arguments<'a>) -> String {format})((const
((format_arguments::new_const as
fn(&[&'static str; 1]) -> Arguments<'_> {Arguments::<'_>::new_const::<1>})((&([("test"
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>) as
Arguments<'_>)) as String);
(res as String)
} as String)) as String);
} as ())
2 changes: 1 addition & 1 deletion tests/run-make/symbol-mangling-hashed/a_dylib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![crate_type = "dylib"]
pub fn hello() {
println!("hello dylib");
println!("{}", "hello dylib");
}
2 changes: 1 addition & 1 deletion tests/run-make/symbol-mangling-hashed/a_rlib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_type = "rlib"]

pub fn hello() {
println!("hello rlib");
println!("{}", "hello rlib");
}
1 change: 0 additions & 1 deletion tests/ui/borrowck/issue-64453.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ struct Value;

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

fn from_string(_: String) -> Value {
Value
13 changes: 2 additions & 11 deletions tests/ui/borrowck/issue-64453.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
error: `Arguments::<'a>::new_const` is not yet stable as a const fn
--> $DIR/issue-64453.rs:4:31
|
LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^
|
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
= 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)

error[E0015]: cannot call non-const fn `format` in statics
--> $DIR/issue-64453.rs:4:31
|
@@ -18,7 +9,7 @@ LL | static settings_dir: String = format!("");
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0507]: cannot move out of static item `settings_dir`
--> $DIR/issue-64453.rs:14:37
--> $DIR/issue-64453.rs:13:37
|
LL | let settings_data = from_string(settings_dir);
| ^^^^^^^^^^^^ 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
LL | let settings_data = from_string(settings_dir.clone());
| ++++++++

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0015, E0507.
For more information about an error, try `rustc --explain E0015`.
1 change: 0 additions & 1 deletion tests/ui/traits/const-traits/issue-79450.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ compile-flags: -Znext-solver
#![allow(incomplete_features)]
#![feature(const_fmt_arguments_new)]
#![feature(const_trait_impl, effects)]

#[const_trait]
2 changes: 1 addition & 1 deletion tests/ui/traits/const-traits/issue-79450.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0015]: cannot call non-const fn `_print` in constant functions
--> $DIR/issue-79450.rs:11:9
--> $DIR/issue-79450.rs:10:9
|
LL | println!("lul");
| ^^^^^^^^^^^^^^^