]> git.proxmox.com Git - rustc.git/blob - tests/ui/specialization/issue-40582.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / tests / ui / specialization / issue-40582.rs
1 // check-pass
2 // known-bug: #40582
3
4 // Should fail. Should not be possible to implement `make_static`.
5
6 #![feature(specialization)]
7 #![allow(incomplete_features)]
8
9 trait FromRef<'a, T: ?Sized> {
10 fn from_ref(r: &'a T) -> Self;
11 }
12
13 impl<'a, T: ?Sized> FromRef<'a, T> for &'a T {
14 fn from_ref(r: &'a T) -> Self {
15 r
16 }
17 }
18
19 impl<'a, T: ?Sized, R> FromRef<'a, T> for R {
20 default fn from_ref(_: &'a T) -> Self {
21 unimplemented!()
22 }
23 }
24
25 fn make_static<T: ?Sized>(data: &T) -> &'static T {
26 fn helper<T: ?Sized, R>(data: &T) -> R {
27 R::from_ref(data)
28 }
29 helper(data)
30 }
31
32 fn main() {
33 let s = "specialization".to_owned();
34 println!("{:?}", make_static(s.as_str()));
35 }