diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 653116e1fe00d..ed35da87e0abb 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -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 { 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: - // ::new_const(lit_pieces) + // const { ::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, diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 4cbcfb07795bd..4f2228aaae789 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -333,7 +333,7 @@ pub struct Arguments<'a> { #[unstable(feature = "fmt_internals", issue = "none")] impl<'a> Arguments<'a> { #[inline] - #[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")] + #[rustc_const_stable(feature = "const_fmt_arguments_new", since = "CURRENT_RUSTC_VERSION")] pub const fn new_const(pieces: &'a [&'static str; N]) -> Self { const { assert!(N <= 1) }; Arguments { pieces, fmt: None, args: &[] } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index b21618e28a48e..86909d37d6890 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -120,7 +120,6 @@ #![feature(const_char_encode_utf16)] #![feature(const_eval_select)] #![feature(const_exact_div)] -#![feature(const_fmt_arguments_new)] #![feature(const_hash)] #![feature(const_heap)] #![feature(const_index_range_slice_index)] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index aa0646846e43e..a517414f704d2 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1038,7 +1038,7 @@ pub(crate) mod builtin { /// /// This macro will be removed once `format_args` is allowed in const contexts. #[unstable(feature = "const_format_args", issue = "none")] - #[allow_internal_unstable(fmt_internals, const_fmt_arguments_new)] + #[allow_internal_unstable(fmt_internals)] #[rustc_builtin_macro] #[macro_export] macro_rules! const_format_args { diff --git a/tests/codegen/issues/issue-128709-format-without-args.rs b/tests/codegen/issues/issue-128709-format-without-args.rs index ceb9ce034d435..c9a63822eff24 100644 --- a/tests/codegen/issues/issue-128709-format-without-args.rs +++ b/tests/codegen/issues/issue-128709-format-without-args.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] // String formating macros without any arguments should compile -// to a `memcpy` followed by a call to `std::io::stdio::_print`. +// to a `memcpy` followed by a call to a library function. #[no_mangle] pub fn code() { diff --git a/tests/coverage/assert.cov-map b/tests/coverage/assert.cov-map index 018fcc2c3dbb3..a171726f45a0c 100644 --- a/tests/coverage/assert.cov-map +++ b/tests/coverage/assert.cov-map @@ -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 diff --git a/tests/coverage/bad_counter_ids.cov-map b/tests/coverage/bad_counter_ids.cov-map index 2b5399f33bbd3..b62215d745e04 100644 --- a/tests/coverage/bad_counter_ids.cov-map +++ b/tests/coverage/bad_counter_ids.cov-map @@ -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 diff --git a/tests/coverage/closure_macro.cov-map b/tests/coverage/closure_macro.cov-map index 7c9d3292f988a..9ddd8042e8799 100644 --- a/tests/coverage/closure_macro.cov-map +++ b/tests/coverage/closure_macro.cov-map @@ -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 diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index e2a52e57015c4..92b1d5ccc1799 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -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 diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index a8ad17574ba3d..1ab995c180ac4 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -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 diff --git a/tests/crashes/105249.rs b/tests/crashes/105249.rs index 592ed5b6dbc8f..ba1612b188156 100644 --- a/tests/crashes/105249.rs +++ b/tests/crashes/105249.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Zpolymorphize=on trait Foo { - 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 () { } diff --git a/tests/incremental/hashes/inherent_impls.rs b/tests/incremental/hashes/inherent_impls.rs index caea394977a73..5c5ebb85338f8 100644 --- a/tests/incremental/hashes/inherent_impls.rs +++ b/tests/incremental/hashes/inherent_impls.rs @@ -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"); } } diff --git a/tests/incremental/hygiene/auxiliary/cached_hygiene.rs b/tests/incremental/hygiene/auxiliary/cached_hygiene.rs index a49715761582c..9ea0dc02eb3bb 100644 --- a/tests/incremental/hygiene/auxiliary/cached_hygiene.rs +++ b/tests/incremental/hygiene/auxiliary/cached_hygiene.rs @@ -9,7 +9,7 @@ #[allow(unused)] macro_rules! first_macro { () => { - println!("New call!"); + println!("{}", "hola"); } } diff --git a/tests/ui/borrowck/issue-64453.rs b/tests/ui/borrowck/issue-64453.rs index 33d55be5812e7..5f1f35d6ca9bb 100644 --- a/tests/ui/borrowck/issue-64453.rs +++ b/tests/ui/borrowck/issue-64453.rs @@ -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 diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index e671817633be4..98b05ead64918 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -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`. diff --git a/tests/ui/consts/const-format-arguments.rs b/tests/ui/consts/const-format-arguments.rs index 46f9c0b76ed55..7e6e5371d6df5 100644 --- a/tests/ui/consts/const-format-arguments.rs +++ b/tests/ui/consts/const-format-arguments.rs @@ -1,5 +1,5 @@ - pub fn main() { const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]); //~^ use of unstable library feature + //~| temporary value dropped while borrowed } diff --git a/tests/ui/consts/const-format-arguments.stderr b/tests/ui/consts/const-format-arguments.stderr index 46f5c642f8e0d..4f45c838a03ac 100644 --- a/tests/ui/consts/const-format-arguments.stderr +++ b/tests/ui/consts/const-format-arguments.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'fmt_internals' - --> $DIR/const-format-arguments.rs:3:36 + --> $DIR/const-format-arguments.rs:2:36 | LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,14 +7,17 @@ LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola" = help: add `#![feature(fmt_internals)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: `Arguments::<'a>::new_const` is not yet stable as a const fn - --> $DIR/const-format-arguments.rs:3:36 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-format-arguments.rs:2:68 | LL | const A: std::fmt::Arguments = std::fmt::Arguments::new_const(&[&"hola"]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable + | --------------------------------^^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary value which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0658, E0716. +For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs index b8b9e07b3bd60..cdefebc87d675 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Znext-solver #![allow(incomplete_features)] -#![feature(const_fmt_arguments_new)] #![feature(const_trait_impl, effects)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr index 9e6348d37ed5e..49f380c1a2b57 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr @@ -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"); | ^^^^^^^^^^^^^^^