Fix ICE in needless_pass_by_value with unsized dyn Fn

This commit is contained in:
Jason Newcomb 2022-09-24 17:07:35 -04:00
parent 8b1ad17e5c
commit 1141c553d8
2 changed files with 7 additions and 1 deletions

View file

@ -18,7 +18,7 @@ use rustc_middle::mir::FakeReadCause;
use rustc_middle::ty::{self, TypeVisitable};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::symbol::kw;
use rustc_span::{sym, Span};
use rustc_span::{sym, Span, DUMMY_SP};
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits;
use rustc_trait_selection::traits::misc::can_type_implement_copy;
@ -186,6 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
if !is_self(arg);
if !ty.is_mutable_ptr();
if !is_copy(cx, ty);
if ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env);
if !allowed_traits.iter().any(|&t| implements_trait(cx, ty, t, &[]));
if !implements_borrow_trait;
if !all_borrowable_trait;

View file

@ -0,0 +1,5 @@
#![feature(unsized_fn_params)]
pub fn f0(_f: dyn FnOnce()) {}
fn main() {}