Skip to content

Commit ede0a71

Browse files
committed
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 rust-lang#80207.
1 parent b81f581 commit ede0a71

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
@@ -192,7 +192,6 @@ pub(super) fn check_fn<'a, 'tcx>(
192192
// possible cases.
193193
fcx.check_expr(&body.value);
194194
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
195-
tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type");
196195
} else {
197196
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
198197
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)