Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4acf3ba
libtest: expose --fail-fast
sourcefrog Jun 20, 2025
547c729
Make fail-fast unstable
sourcefrog Jun 20, 2025
b5a4e5d
remove gates
Kivooeo Aug 3, 2025
9fd57df
add tests, some with incorrect lifetime extension behavior
dianne Aug 13, 2025
0976d6c
don't extend non-extended `super let` initializers' block tail temps
dianne Aug 25, 2025
d5b5a4a
additional tests
dianne Aug 25, 2025
1ebf69d
initial implementation of the darwin_objc unstable feature
jbatez Jun 5, 2025
9405e76
Detect attempt to use var-args in closure
estebank Sep 15, 2025
0e290e4
Silence inference error on `PatKind::Err`
estebank Sep 15, 2025
a84c8de
Fix existing test
estebank Sep 15, 2025
53b58b3
tests/run-make: Update list of statically linked musl targets
Gelbpunkt Sep 15, 2025
fa7e474
remove FIXME from `has_significant_drop`, replaced with checking non_…
tnuha Sep 15, 2025
d66fb49
Suggest removing Box::new
camsteffen Sep 6, 2025
c89b6a9
Iterator repeat: no infinite loop for `last` and `count`
hkBst Sep 10, 2025
c916e88
fmt
estebank Sep 16, 2025
ed85f98
remove redundant test
estebank Sep 16, 2025
8306a2f
Reword note
estebank Sep 16, 2025
e9270e3
Detect top-level `...` in argument type
estebank Sep 16, 2025
580b489
Update the minimum external LLVM to 20
cuviper Aug 7, 2025
e54602c
Merge similar output checks in assembly-llvm/x86_64-cmp
cuviper Aug 8, 2025
88bef49
Update the FIXME comments in the generic three_way_compare
cuviper Aug 8, 2025
d81872a
add Readme.md to tidy
simp4t7 Sep 12, 2025
53b91ea
Remove Rvalue::Len.
cjgillot Sep 14, 2025
f018b46
Update docs.
cjgillot Sep 16, 2025
de73af9
Add test.
cjgillot Sep 16, 2025
40d879a
Add test.
cjgillot Sep 14, 2025
fe3a784
Do not renumber resume local.
cjgillot Sep 14, 2025
eddd755
Bless ui.
cjgillot Sep 16, 2025
5419896
Use `LLVMDIBuilderCreateSubroutineType`
Zalathar Sep 16, 2025
2552deb
Use `LLVMDIBuilderCreateUnionType`
Zalathar Sep 16, 2025
bef8f64
Use `LLVMDIBuilderCreateArrayType`
Zalathar Sep 16, 2025
3e9048d
Use `LLVMDIBuilderCreateBasicType`
Zalathar Sep 16, 2025
bae6fde
Use `LLVMDIBuilderCreatePointerType`
Zalathar Sep 16, 2025
af88d14
Use `LLVMDIBuilderCreateStructType`
Zalathar Sep 16, 2025
9d93fab
Rollup merge of #142807 - sourcefrog:failfast, r=dtolnay
Zalathar Sep 17, 2025
feeb68e
Rollup merge of #144871 - Kivooeo:btree_entry_insert-stabilize, r=jhp…
Zalathar Sep 17, 2025
f104ecf
Rollup merge of #145071 - cuviper:min-llvm-20, r=nikic
Zalathar Sep 17, 2025
f21a9c9
Rollup merge of #145181 - Borgerr:remove-fixme-from-has-sigdrop, r=lcnr
Zalathar Sep 17, 2025
6ad9875
Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,…
Zalathar Sep 17, 2025
c2e8264
Rollup merge of #145838 - dianne:non-extending-super-let, r=jackh726,…
Zalathar Sep 17, 2025
79f8acb
Rollup merge of #146259 - camsteffen:remove-the-box, r=jackh726
Zalathar Sep 17, 2025
cefd932
Rollup merge of #146410 - hkBst:repeat-1, r=jhpratt
Zalathar Sep 17, 2025
c7af12e
Rollup merge of #146460 - simp4t7:add-tidy-readme, r=clubby789
Zalathar Sep 17, 2025
577f18f
Rollup merge of #146552 - cjgillot:resume-noremap, r=jackh726
Zalathar Sep 17, 2025
6473a0f
Rollup merge of #146564 - cjgillot:mir-nolen, r=scottmcm
Zalathar Sep 17, 2025
61f5358
Rollup merge of #146581 - estebank:issue-146489, r=lcnr
Zalathar Sep 17, 2025
76f1159
Rollup merge of #146588 - Gelbpunkt:musl-default-linking-test, r=jiey…
Zalathar Sep 17, 2025
4e6640b
Rollup merge of #146631 - Zalathar:di-builder, r=nnethercote
Zalathar Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Suggest removing Box::new
  • Loading branch information
camsteffen authored and jackh726 committed Sep 16, 2025
commit d66fb4910fb7e87b7e17477ae147854adf76b0dd
22 changes: 22 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
)
{
let deref_kind = if checked_ty.is_box() {
// detect Box::new(..)
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
{
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);
return Some((
vec![
(box_new.span.to(l_paren), String::new()),
(r_paren, String::new()),
],
"consider removing the Box".to_string(),
Applicability::MachineApplicable,
false,
false,
));
}
"unboxing the value"
} else if checked_ty.is_ref() {
"dereferencing the borrow"
Expand Down
7 changes: 4 additions & 3 deletions tests/ui/coercion/coerce-block-tail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ LL | let _: &i32 = & { Box::new(1i32) };
|
= note: expected type `i32`
found struct `Box<i32>`
help: consider unboxing the value
help: consider removing the Box
|
LL - let _: &i32 = & { Box::new(1i32) };
LL + let _: &i32 = & { 1i32 };
|
LL | let _: &i32 = & { *Box::new(1i32) };
| +

error: aborting due to 1 previous error

Expand Down
4 changes: 4 additions & 0 deletions tests/ui/coercion/coerce-box-new-to-unboxed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
let _: String = Box::new(String::new());
//~^ ERROR mismatched types
}
19 changes: 19 additions & 0 deletions tests/ui/coercion/coerce-box-new-to-unboxed.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/coerce-box-new-to-unboxed.rs:2:21
|
LL | let _: String = Box::new(String::new());
| ------ ^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Box<String>`
| |
| expected due to this
|
= note: expected struct `String`
found struct `Box<String>`
help: consider removing the Box
|
LL - let _: String = Box::new(String::new());
LL + let _: String = String::new();
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Loading