rust/tests/ui/unsized-locals/unsized-index.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
442 B
Rust
Raw Normal View History

2020-10-20 15:40:02 +00:00
// run-pass
2019-04-16 21:11:19 +00:00
#![feature(unsized_fn_params)]
2019-04-16 21:11:19 +00:00
use std::ops;
2020-10-20 15:40:02 +00:00
use std::ops::Index;
2019-04-16 21:11:19 +00:00
pub struct A;
impl ops::Index<str> for A {
type Output = ();
2020-10-16 20:46:59 +00:00
fn index(&self, _: str) -> &Self::Output {
2020-10-20 15:40:02 +00:00
&()
2020-10-16 20:46:59 +00:00
}
2019-04-16 21:11:19 +00:00
}
impl ops::IndexMut<str> for A {
2020-10-16 20:46:59 +00:00
fn index_mut(&mut self, _: str) -> &mut Self::Output {
panic!()
}
2019-04-16 21:11:19 +00:00
}
2020-10-20 15:40:02 +00:00
fn main() {
let a = A {};
let s = String::new().into_boxed_str();
assert_eq!(&(), a.index(*s));
}