-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #130344 - Jaic1:fix-116306, r=BoxyUwU
Handle unsized consts with type `str` in v0 symbol mangling This PR fixes #116303 by handling consts with type `str` in v0 symbol mangling as partial support for unsized consts. This PR is related to `#![feature(adt_const_params)]` (#95174) and `#![feature(unsized_const_params)]` (#128028). r? ``@BoxyUwU``
- Loading branch information
Showing
2 changed files
with
51 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/ui/const-generics/unsized_const_params/symbol_mangling_v0_str.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ check-pass | ||
//@ compile-flags: -Csymbol-mangling-version=v0 | ||
#![allow(incomplete_features)] | ||
#![feature(unsized_const_params)] | ||
|
||
// Regression test for #116303 | ||
|
||
#[derive(PartialEq, Eq)] | ||
struct MyStr(str); | ||
impl std::marker::UnsizedConstParamTy for MyStr {} | ||
|
||
fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr { | ||
S | ||
} | ||
|
||
impl MyStr { | ||
const fn new(s: &'static str) -> &'static MyStr { | ||
unsafe { std::mem::transmute(s) } | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let f = function_with_my_str::<{ MyStr::new("hello") }>(); | ||
} |