From f0a71f7f4d583f7c93899ae913d6494cc42ad2ac Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 20 Oct 2020 12:40:02 -0300 Subject: [PATCH] Better test unsized_fn_params --- src/test/ui/unsized-locals/unsized-index.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/ui/unsized-locals/unsized-index.rs b/src/test/ui/unsized-locals/unsized-index.rs index 2c31ade7a387..e8782e894815 100644 --- a/src/test/ui/unsized-locals/unsized-index.rs +++ b/src/test/ui/unsized-locals/unsized-index.rs @@ -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 for A { type Output = (); fn index(&self, _: str) -> &Self::Output { - panic!() + &() } } @@ -24,4 +20,8 @@ fn index_mut(&mut self, _: str) -> &mut Self::Output { } } -fn main() {} +fn main() { + let a = A {}; + let s = String::new().into_boxed_str(); + assert_eq!(&(), a.index(*s)); +}