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! {
1349
1349
/// ### Example
1350
1350
///
1351
1351
/// ```rust
1352
- /// #![feature(box_syntax)]
1353
1352
/// fn main() {
1354
- /// let a = (box [1, 2, 3]).len();
1353
+ /// let a = Box::new( [1, 2, 3]).len();
1355
1354
/// }
1356
1355
/// ```
1357
1356
///
@@ -1373,6 +1372,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
1373
1372
fn check_expr ( & mut self , cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) {
1374
1373
match e. kind {
1375
1374
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
+ => { }
1376
1380
_ => return ,
1377
1381
}
1378
1382
Original file line number Diff line number Diff line change @@ -429,6 +429,7 @@ symbols! {
429
429
borrowck_graphviz_format,
430
430
borrowck_graphviz_postflow,
431
431
box_free,
432
+ box_new,
432
433
box_patterns,
433
434
box_syntax,
434
435
bpf_target_feature,
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ impl<T> Box<T> {
214
214
#[ inline( always) ]
215
215
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
216
216
#[ must_use]
217
+ #[ rustc_diagnostic_item = "box_new" ]
217
218
pub fn new ( x : T ) -> Self {
218
219
#[ rustc_box]
219
220
Box :: new ( x)
You can’t perform that action at this time.
0 commit comments