This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1349,9 +1349,8 @@ declare_lint! {
13491349 /// ### Example
13501350 ///
13511351 /// ```rust
1352- /// #![feature(box_syntax)]
13531352 /// fn main() {
1354- /// let a = (box [1, 2, 3]).len();
1353+ /// let a = Box::new( [1, 2, 3]).len();
13551354 /// }
13561355 /// ```
13571356 ///
@@ -1373,6 +1372,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
13731372 fn check_expr ( & mut self , cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) {
13741373 match e. kind {
13751374 hir:: ExprKind :: Box ( _) => { }
1375+ hir:: ExprKind :: Call ( path_expr, [ _] )
1376+ if let hir:: ExprKind :: Path ( qpath) = & path_expr. kind
1377+ && let Some ( did) = cx. qpath_res ( qpath, path_expr. hir_id ) . opt_def_id ( )
1378+ && cx. tcx . is_diagnostic_item ( sym:: box_new, did)
1379+ => { }
13761380 _ => return ,
13771381 }
13781382
Original file line number Diff line number Diff line change @@ -429,6 +429,7 @@ symbols! {
429429 borrowck_graphviz_format,
430430 borrowck_graphviz_postflow,
431431 box_free,
432+ box_new,
432433 box_patterns,
433434 box_syntax,
434435 bpf_target_feature,
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ impl<T> Box<T> {
214214 #[ inline( always) ]
215215 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
216216 #[ must_use]
217+ #[ rustc_diagnostic_item = "box_new" ]
217218 pub fn new ( x : T ) -> Self {
218219 #[ rustc_box]
219220 Box :: new ( x)
You can’t perform that action at this time.
0 commit comments