Skip to content

Commit 5bd3b56

Browse files
committed
Auto merge of #9531 - Jarcho:ice_9459, r=llogiq
Fix ICE in `needless_pass_by_value` with unsized `dyn Fn` fixes #9459 Not really sure why a query for a type implementing `FnOnce` even works since the trait if `FnOnce<T>`, but it seems to. I would have expected it to crash like it does when passing `dyn FnOnce()` as the type. changelog: [`needless_pass_by_value`](https://rust-lang.github.io/rust-clippy/master/#needless_pass_by_value) Fix ICE in with unsized `dyn Fn` argument
2 parents 8b1ad17 + 1141c55 commit 5bd3b56

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clippy_lints/src/needless_pass_by_value.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::mir::FakeReadCause;
1818
use rustc_middle::ty::{self, TypeVisitable};
1919
use rustc_session::{declare_lint_pass, declare_tool_lint};
2020
use rustc_span::symbol::kw;
21-
use rustc_span::{sym, Span};
21+
use rustc_span::{sym, Span, DUMMY_SP};
2222
use rustc_target::spec::abi::Abi;
2323
use rustc_trait_selection::traits;
2424
use rustc_trait_selection::traits::misc::can_type_implement_copy;
@@ -186,6 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
186186
if !is_self(arg);
187187
if !ty.is_mutable_ptr();
188188
if !is_copy(cx, ty);
189+
if ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env);
189190
if !allowed_traits.iter().any(|&t| implements_trait(cx, ty, t, &[]));
190191
if !implements_borrow_trait;
191192
if !all_borrowable_trait;

tests/ui/crashes/ice-9459.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![feature(unsized_fn_params)]
2+
3+
pub fn f0(_f: dyn FnOnce()) {}
4+
5+
fn main() {}

0 commit comments

Comments
 (0)