Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d5087d
Display valid values in --crate-type
malezjaa Dec 24, 2024
5a2e2a9
add relnotes
BoxyUwU Dec 20, 2024
575cdf7
Stabilized APIs
BoxyUwU Jan 3, 2025
db17be8
[generic_assert] Constify methods used by the formatting system
c410-f3r Jan 5, 2025
49c7423
Add support for wasm exception handling to Emscripten target
hoodmane Oct 17, 2024
37f2631
add deprecated and do nothing flag to options table
klensy Jan 5, 2025
87ce94d
last feedback items
pietroalbini Jan 6, 2025
2be9ffc
Add derived causes for host effect predicates
compiler-errors Dec 10, 2024
96285bd
Don't ice on bad transmute in typeck in new solver
compiler-errors Dec 25, 2024
ebdf19a
Recurse on GAT where clauses in fulfillment error proof tree visitor
compiler-errors Dec 23, 2024
ec6d5bc
Implement const Destruct in old solver
compiler-errors Dec 29, 2024
304ccf4
Suggest to replace tuple constructor through projection
compiler-errors Jan 4, 2025
5172364
Update triagebot.toml: celinval vacation is over
celinval Jan 6, 2025
b0aaa38
rustdoc: Fix mismatched capitalization in sidebar
camelid Jan 5, 2025
971a01a
Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubilee
jhpratt Jan 7, 2025
4fc205f
Rollup merge of #132345 - compiler-errors:fx-diag, r=lcnr
jhpratt Jan 7, 2025
1c6862f
Rollup merge of #134568 - BoxyUwU:relnotes_1_84, r=pietroalbini
jhpratt Jan 7, 2025
fa48f63
Rollup merge of #134720 - malezjaa:feat/crate-type-valid-values, r=ji…
jhpratt Jan 7, 2025
9f2ac38
Rollup merge of #134744 - compiler-errors:transmute-non-wf, r=lcnr
jhpratt Jan 7, 2025
6ae7a88
Rollup merge of #134875 - compiler-errors:const-destruct-old-solver, …
jhpratt Jan 7, 2025
e1e9fcd
Rollup merge of #135090 - compiler-errors:invalid-tuple-ctor-projecti…
jhpratt Jan 7, 2025
49ac654
Rollup merge of #135116 - camelid:sidebar-case, r=fmease
jhpratt Jan 7, 2025
b5cf02f
Rollup merge of #135126 - klensy:deprecated-and-do-nothing, r=jieyouxu
jhpratt Jan 7, 2025
3836aa7
Rollup merge of #135139 - c410-f3r:8-years-rfc, r=jhpratt
jhpratt Jan 7, 2025
8c1f55a
Rollup merge of #135170 - celinval:chores-vacation-end, r=jieyouxu
jhpratt Jan 7, 2025
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
Prev Previous commit
Next Next commit
[generic_assert] Constify methods used by the formatting system
  • Loading branch information
c410-f3r committed Jan 5, 2025
commit db17be84fe7902e663ad78d3bc419b3f32717c52
4 changes: 2 additions & 2 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ impl<'a> Arguments<'a> {
/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.
#[inline]
pub fn new_v1<const P: usize, const A: usize>(
pub const fn new_v1<const P: usize, const A: usize>(
pieces: &'a [&'static str; P],
args: &'a [rt::Argument<'a>; A],
) -> Arguments<'a> {
Expand All @@ -612,7 +612,7 @@ impl<'a> Arguments<'a> {
/// 2. Every `rt::Placeholder::position` value within `fmt` must be a valid index of `args`.
/// 3. Every `rt::Count::Param` within `fmt` must contain a valid index of `args`.
#[inline]
pub fn new_v1_formatted(
pub const fn new_v1_formatted(
pieces: &'a [&'static str],
args: &'a [rt::Argument<'a>],
fmt: &'a [rt::Placeholder],
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/fmt/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ pub struct Argument<'a> {
#[rustc_diagnostic_item = "ArgumentMethods"]
impl Argument<'_> {
#[inline]
fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'a> {
const fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'a> {
Argument {
// INVARIANT: this creates an `ArgumentType<'a>` from a `&'a T` and
// a `fn(&T, ...)`, so the invariant is maintained.
ty: ArgumentType::Placeholder {
value: NonNull::from(x).cast(),
value: NonNull::from_ref(x).cast(),
// SAFETY: function pointers always have the same layout.
formatter: unsafe { mem::transmute(f) },
_lifetime: PhantomData,
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Argument<'_> {
Self::new(x, UpperExp::fmt)
}
#[inline]
pub fn from_usize(x: &usize) -> Argument<'_> {
pub const fn from_usize(x: &usize) -> Argument<'_> {
Argument { ty: ArgumentType::Count(*x) }
}

Expand Down Expand Up @@ -181,7 +181,7 @@ impl Argument<'_> {
}

#[inline]
pub(super) fn as_usize(&self) -> Option<usize> {
pub(super) const fn as_usize(&self) -> Option<usize> {
match self.ty {
ArgumentType::Count(count) => Some(count),
ArgumentType::Placeholder { .. } => None,
Expand All @@ -199,7 +199,7 @@ impl Argument<'_> {
/// println!("{f}");
/// ```
#[inline]
pub fn none() -> [Self; 0] {
pub const fn none() -> [Self; 0] {
[]
}
}
Expand All @@ -216,7 +216,7 @@ impl UnsafeArg {
/// See documentation where `UnsafeArg` is required to know when it is safe to
/// create and use `UnsafeArg`.
#[inline]
pub unsafe fn new() -> Self {
pub const unsafe fn new() -> Self {
Self { _private: () }
}
}
2 changes: 0 additions & 2 deletions tests/ui/consts/const-eval/format.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const fn failure() {
panic!("{:?}", 0);
//~^ ERROR cannot call non-const formatting macro in constant functions
//~| ERROR cannot call non-const associated function `Arguments::<'_>::new_v1::<1, 1>` in constant functions
}

const fn print() {
println!("{:?}", 0);
//~^ ERROR cannot call non-const formatting macro in constant functions
//~| ERROR cannot call non-const associated function `Arguments::<'_>::new_v1::<2, 1>` in constant functions
//~| ERROR cannot call non-const function `_print` in constant functions
}

Expand Down
24 changes: 3 additions & 21 deletions tests/ui/consts/const-eval/format.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,24 @@ LL | panic!("{:?}", 0);
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0015]: cannot call non-const associated function `Arguments::<'_>::new_v1::<1, 1>` in constant functions
--> $DIR/format.rs:2:5
|
LL | panic!("{:?}", 0);
| ^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0015]: cannot call non-const formatting macro in constant functions
--> $DIR/format.rs:8:15
--> $DIR/format.rs:7:15
|
LL | println!("{:?}", 0);
| ^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0015]: cannot call non-const associated function `Arguments::<'_>::new_v1::<2, 1>` in constant functions
--> $DIR/format.rs:8:5
|
LL | println!("{:?}", 0);
| ^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0015]: cannot call non-const function `_print` in constant functions
--> $DIR/format.rs:8:5
--> $DIR/format.rs:7:5
|
LL | println!("{:?}", 0);
| ^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

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

For more information about this error, try `rustc --explain E0015`.
Loading