mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #155386 - cijiugechu:fix-box-new-diagnostic-item, r=Kivooeo
Use `box_new` diagnostic item for Box::new suggestions When look this part of code, I noticed this FIXME and fixed it :)
This commit is contained in:
@@ -3107,14 +3107,11 @@ pub(crate) fn suggest_deref_or_ref(
|
||||
{
|
||||
let deref_kind = if checked_ty.is_box() {
|
||||
// detect Box::new(..)
|
||||
// FIXME: use `box_new` diagnostic item instead?
|
||||
if let ExprKind::Call(box_new, [_]) = expr.kind
|
||||
&& let ExprKind::Path(qpath) = &box_new.kind
|
||||
&& let Res::Def(DefKind::AssocFn, fn_id) =
|
||||
self.typeck_results.borrow().qpath_res(qpath, box_new.hir_id)
|
||||
&& let Some(impl_id) = self.tcx.inherent_impl_of_assoc(fn_id)
|
||||
&& self.tcx.type_of(impl_id).skip_binder().is_box()
|
||||
&& self.tcx.item_name(fn_id) == sym::new
|
||||
&& self.tcx.is_diagnostic_item(sym::box_new, fn_id)
|
||||
{
|
||||
let l_paren = self.tcx.sess.source_map().next_point(box_new.span);
|
||||
let r_paren = self.tcx.sess.source_map().end_point(expr.span);
|
||||
|
||||
Reference in New Issue
Block a user