Better test unsized_fn_params
This commit is contained in:
parent
70b8c79a96
commit
f0a71f7f4d
|
@ -1,20 +1,16 @@
|
|||
// build-pass (FIXME(62277): could be check-pass?)
|
||||
// run-pass
|
||||
|
||||
// `std::ops::Index` has an `: ?Sized` bound on the `Idx` type param. This is
|
||||
// an accidental left-over from the times when it `Index` was by-reference.
|
||||
// Tightening the bound now could be a breaking change. Although no crater
|
||||
// regression were observed (https://github.com/rust-lang/rust/pull/59527),
|
||||
// let's be conservative and just add a test for this.
|
||||
#![feature(unsized_fn_params)]
|
||||
|
||||
use std::ops;
|
||||
use std::ops::Index;
|
||||
|
||||
pub struct A;
|
||||
|
||||
impl ops::Index<str> for A {
|
||||
type Output = ();
|
||||
fn index(&self, _: str) -> &Self::Output {
|
||||
panic!()
|
||||
&()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,4 +20,8 @@ impl ops::IndexMut<str> for A {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let a = A {};
|
||||
let s = String::new().into_boxed_str();
|
||||
assert_eq!(&(), a.index(*s));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue