Skip to content

Commit 6695944

Browse files
authored
Rollup merge of rust-lang#81532 - estebank:ice-ice-baby, r=pnkfelix
Remove incorrect `delay_span_bug` The following code is supposed to compile ```rust use std::ops::BitOr; pub trait IntWrapper { type InternalStorage; } impl<T> BitOr for dyn IntWrapper<InternalStorage = T> where Self: Sized, T: BitOr + BitOr<Output = T>, { type Output = Self; fn bitor(self, _other: Self) -> Self { todo!() } } ``` Before this change it would ICE. In rust-lang#70998 the removed logic was added to provide better suggestions, and the `delay_span_bug` guard was added to protect against a potential logic error when returning traits. As it happens, there are cases, like the one above, where traits can indeed be returned, so valid code was being rejected. Fix (but not close) rust-lang#80207.
2 parents 00dabfb + ede0a71 commit 6695944

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

compiler/rustc_typeck/src/check/check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ pub(super) fn check_fn<'a, 'tcx>(
203203
// possible cases.
204204
fcx.check_expr(&body.value);
205205
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
206-
tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type");
207206
} else {
208207
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
209208
fcx.check_return_expr(&body.value);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check-pass
2+
3+
trait Foo {
4+
fn do_stuff() -> Self;
5+
}
6+
7+
trait Bar {
8+
type Output;
9+
}
10+
11+
impl<T> Foo for dyn Bar<Output = T>
12+
where
13+
Self: Sized,
14+
{
15+
fn do_stuff() -> Self {
16+
todo!()
17+
}
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)