Skip to content

Commit f0a71f7

Browse files
committed
Better test unsized_fn_params
1 parent 70b8c79 commit f0a71f7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
// build-pass (FIXME(62277): could be check-pass?)
1+
// run-pass
22

3-
// `std::ops::Index` has an `: ?Sized` bound on the `Idx` type param. This is
4-
// an accidental left-over from the times when it `Index` was by-reference.
5-
// Tightening the bound now could be a breaking change. Although no crater
6-
// regression were observed (https://github.com/rust-lang/rust/pull/59527),
7-
// let's be conservative and just add a test for this.
83
#![feature(unsized_fn_params)]
94

105
use std::ops;
6+
use std::ops::Index;
117

128
pub struct A;
139

1410
impl ops::Index<str> for A {
1511
type Output = ();
1612
fn index(&self, _: str) -> &Self::Output {
17-
panic!()
13+
&()
1814
}
1915
}
2016

@@ -24,4 +20,8 @@ impl ops::IndexMut<str> for A {
2420
}
2521
}
2622

27-
fn main() {}
23+
fn main() {
24+
let a = A {};
25+
let s = String::new().into_boxed_str();
26+
assert_eq!(&(), a.index(*s));
27+
}

0 commit comments

Comments
 (0)