diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-14 05:05:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-14 05:05:51 +0200 |
| commit | 85180cd365f2a518183b24468fb5754f6c842e0f (patch) | |
| tree | 8dc6a0d572ac4c08c2cd0b63220a895393c66276 /tests/codegen | |
| parent | 2cb59087dbbbacbe173414e43c12bf046d84224c (diff) | |
| parent | c6fb0f344e0c6edb34966b1d73c3c1d8c5afbe34 (diff) | |
| download | rust-85180cd365f2a518183b24468fb5754f6c842e0f.tar.gz rust-85180cd365f2a518183b24468fb5754f6c842e0f.zip | |
Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors
alloc: add ToString specialization for `&&str` Fixes #128690
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/issues/str-to-string-128690.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/codegen/issues/str-to-string-128690.rs b/tests/codegen/issues/str-to-string-128690.rs new file mode 100644 index 00000000000..8b416306ba6 --- /dev/null +++ b/tests/codegen/issues/str-to-string-128690.rs @@ -0,0 +1,36 @@ +//@ compile-flags: -C opt-level=3 -Z merge-functions=disabled +#![crate_type = "lib"] + +//! Make sure str::to_string is specialized not to use fmt machinery. + +// CHECK-LABEL: define {{(dso_local )?}}void @one_ref +#[no_mangle] +pub fn one_ref(input: &str) -> String { + // CHECK-NOT: {{(call|invoke).*}}fmt + input.to_string() +} + +// CHECK-LABEL: define {{(dso_local )?}}void @two_ref +#[no_mangle] +pub fn two_ref(input: &&str) -> String { + // CHECK-NOT: {{(call|invoke).*}}fmt + input.to_string() +} + +// CHECK-LABEL: define {{(dso_local )?}}void @thirteen_ref +#[no_mangle] +pub fn thirteen_ref(input: &&&&&&&&&&&&&str) -> String { + // CHECK-NOT: {{(call|invoke).*}}fmt + input.to_string() +} + +// This is a known performance cliff because of the macro-generated +// specialized impl. If this test suddenly starts failing, +// consider removing the `to_string_str!` macro in `alloc/str/string.rs`. +// +// CHECK-LABEL: define {{(dso_local )?}}void @fourteen_ref +#[no_mangle] +pub fn fourteen_ref(input: &&&&&&&&&&&&&&str) -> String { + // CHECK: {{(call|invoke).*}}fmt + input.to_string() +} |
