Skip to content

Commit f6b8e2b

Browse files
m-ou-seehuss
authored andcommitted
Rollup merge of #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 #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) #80207.
1 parent 567eb04 commit f6b8e2b

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
@@ -188,7 +188,6 @@ pub(super) fn check_fn<'a, 'tcx>(
188188
// possible cases.
189189
fcx.check_expr(&body.value);
190190
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
191-
tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type");
192191
} else {
193192
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
194193
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)