Unnamed repository; edit this file 'description' to name the repository.
Remove support for `#[rustc_box]`
It was replaced with an intrinsic in https://github.com/rust-lang/rust/pull/135046, released in 1.86.0. And add MIR eval support for the intrinsic.
Chayim Refael Friedman 2 weeks ago
parent 05fcbfe · commit e2c2526
-rw-r--r--crates/hir-def/src/expr_store.rs1
-rw-r--r--crates/hir-def/src/expr_store/lower.rs26
-rw-r--r--crates/hir-def/src/expr_store/pretty.rs4
-rw-r--r--crates/hir-def/src/hir.rs7
-rw-r--r--crates/hir-ty/src/consteval/tests.rs7
-rw-r--r--crates/hir-ty/src/infer.rs5
-rw-r--r--crates/hir-ty/src/infer/closure/analysis/expr_use_visitor.rs2
-rw-r--r--crates/hir-ty/src/infer/expr.rs25
-rw-r--r--crates/hir-ty/src/infer/mutability.rs1
-rw-r--r--crates/hir-ty/src/mir.rs14
-rw-r--r--crates/hir-ty/src/mir/borrowck.rs9
-rw-r--r--crates/hir-ty/src/mir/eval.rs8
-rw-r--r--crates/hir-ty/src/mir/eval/shim.rs9
-rw-r--r--crates/hir-ty/src/mir/lower.rs16
-rw-r--r--crates/hir-ty/src/mir/monomorphization.rs3
-rw-r--r--crates/hir-ty/src/mir/pretty.rs6
-rw-r--r--crates/hir-ty/src/tests/simple.rs44
-rw-r--r--crates/ide-diagnostics/src/handlers/mutability_errors.rs7
18 files changed, 59 insertions, 135 deletions
diff --git a/crates/hir-def/src/expr_store.rs b/crates/hir-def/src/expr_store.rs
index ca3ca39754..32d16957ae 100644
--- a/crates/hir-def/src/expr_store.rs
+++ b/crates/hir-def/src/expr_store.rs
@@ -776,7 +776,6 @@ impl ExpressionStore {
| Expr::Await { expr }
| Expr::Ref { expr, mutability: _, rawness: _ }
| Expr::UnaryOp { expr, op: _ }
- | Expr::Box { expr }
| Expr::Const(expr) => {
visitor.on_expr(*expr);
}
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index f5cf1180eb..df4fc6e531 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -26,8 +26,8 @@ use stdx::never;
use syntax::{
AstNode, AstPtr, SyntaxNodePtr,
ast::{
- self, ArrayExprKind, AstChildren, BlockExpr, ForBinder, HasArgList, HasAttrs,
- HasGenericArgs, HasGenericParams, HasLoopBody, HasName, HasTypeBounds, IsString, RangeItem,
+ self, ArrayExprKind, AstChildren, BlockExpr, ForBinder, HasArgList, HasGenericArgs,
+ HasGenericParams, HasLoopBody, HasName, HasTypeBounds, IsString, RangeItem,
SlicePatComponents,
},
};
@@ -1460,23 +1460,13 @@ impl<'db> ExprCollector<'db> {
ast::Expr::WhileExpr(e) => self.collect_while_loop(syntax_ptr, e),
ast::Expr::ForExpr(e) => self.collect_for_loop(syntax_ptr, e),
ast::Expr::CallExpr(e) => {
- // FIXME(MINIMUM_SUPPORTED_TOOLCHAIN_VERSION): Remove this once we drop support for <1.86, https://github.com/rust-lang/rust/commit/ac9cb908ac4301dfc25e7a2edee574320022ae2c
- let is_rustc_box = {
- let attrs = e.attrs();
- attrs.filter_map(|it| it.as_simple_atom()).any(|it| it == "rustc_box")
- };
- if is_rustc_box {
- let expr = self.collect_expr_opt(e.arg_list().and_then(|it| it.args().next()));
- self.alloc_expr(Expr::Box { expr }, syntax_ptr)
+ let callee = self.collect_expr_opt(e.expr());
+ let args = if let Some(arg_list) = e.arg_list() {
+ arg_list.args().filter_map(|e| self.maybe_collect_expr(e)).collect()
} else {
- let callee = self.collect_expr_opt(e.expr());
- let args = if let Some(arg_list) = e.arg_list() {
- arg_list.args().filter_map(|e| self.maybe_collect_expr(e)).collect()
- } else {
- Box::default()
- };
- self.alloc_expr(Expr::Call { callee, args }, syntax_ptr)
- }
+ Box::default()
+ };
+ self.alloc_expr(Expr::Call { callee, args }, syntax_ptr)
}
ast::Expr::MethodCallExpr(e) => {
let receiver = self.collect_expr_opt(e.receiver());
diff --git a/crates/hir-def/src/expr_store/pretty.rs b/crates/hir-def/src/expr_store/pretty.rs
index 67eb0814c7..1c70922467 100644
--- a/crates/hir-def/src/expr_store/pretty.rs
+++ b/crates/hir-def/src/expr_store/pretty.rs
@@ -727,10 +727,6 @@ impl Printer<'_> {
}
self.print_expr_in(prec, *expr);
}
- Expr::Box { expr } => {
- w!(self, "box ");
- self.print_expr_in(prec, *expr);
- }
Expr::UnaryOp { expr, op } => {
let op = match op {
ast::UnaryOp::Deref => "*",
diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs
index 75da190dc7..7e56282feb 100644
--- a/crates/hir-def/src/hir.rs
+++ b/crates/hir-def/src/hir.rs
@@ -355,9 +355,6 @@ pub enum Expr {
rawness: Rawness,
mutability: Mutability,
},
- Box {
- expr: ExprId,
- },
UnaryOp {
expr: ExprId,
op: UnaryOp,
@@ -432,9 +429,7 @@ impl Expr {
| Expr::Index { .. }
| Expr::MethodCall { .. } => ExprPrecedence::Postfix,
- Expr::Box { .. } | Expr::Let { .. } | Expr::UnaryOp { .. } | Expr::Ref { .. } => {
- ExprPrecedence::Prefix
- }
+ Expr::Let { .. } | Expr::UnaryOp { .. } | Expr::Ref { .. } => ExprPrecedence::Prefix,
Expr::Cast { .. } => ExprPrecedence::Cast,
diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs
index 95ebdbd409..4eb8c11fac 100644
--- a/crates/hir-ty/src/consteval/tests.rs
+++ b/crates/hir-ty/src/consteval/tests.rs
@@ -2217,14 +2217,17 @@ fn boxes() {
use core::ops::{Deref, DerefMut};
use core::{marker::Unsize, ops::CoerceUnsized};
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub fn box_new<T>(_x: T) -> Box<T>;
+
#[lang = "owned_box"]
pub struct Box<T: ?Sized> {
inner: *mut T,
}
impl<T> Box<T> {
fn new(t: T) -> Self {
- #[rustc_box]
- Box::new(t)
+ box_new(t)
}
}
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index 5db5be0fd1..d5ebe1ac42 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -2629,11 +2629,6 @@ impl<'db> InferenceContext<'db> {
}
}
- fn resolve_boxed_box(&self) -> Option<AdtId> {
- let struct_ = self.lang_items.OwnedBox?;
- Some(struct_.into())
- }
-
fn resolve_range_full(&self) -> Option<AdtId> {
let struct_ = self.lang_items.RangeFull?;
Some(struct_.into())
diff --git a/crates/hir-ty/src/infer/closure/analysis/expr_use_visitor.rs b/crates/hir-ty/src/infer/closure/analysis/expr_use_visitor.rs
index 2b771c5216..4d300f5048 100644
--- a/crates/hir-ty/src/infer/closure/analysis/expr_use_visitor.rs
+++ b/crates/hir-ty/src/infer/closure/analysis/expr_use_visitor.rs
@@ -648,7 +648,7 @@ impl<'a, 'db, D: Delegate<'db>> ExprUseVisitor<'a, 'db, D> {
}
}
- Expr::Become { expr } | Expr::Await { expr } | Expr::Box { expr } => {
+ Expr::Become { expr } | Expr::Await { expr } => {
self.consume_expr(expr)?;
}
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs
index b92a83ab7f..20cfc9008a 100644
--- a/crates/hir-ty/src/infer/expr.rs
+++ b/crates/hir-ty/src/infer/expr.rs
@@ -20,7 +20,7 @@ use rustc_ast_ir::Mutability;
use rustc_hash::FxHashMap;
use rustc_type_ir::{
InferTy, Interner,
- inherent::{GenericArgs as _, IntoKind, Ty as _},
+ inherent::{IntoKind, Ty as _},
};
use stdx::never;
use syntax::ast::RangeOp;
@@ -259,7 +259,6 @@ impl<'db> InferenceContext<'db> {
| Expr::Await { .. }
| Expr::Ref { .. }
| Expr::Range { .. }
- | Expr::Box { .. }
| Expr::RecordLit { .. }
| Expr::Yeet { .. }
| Expr::Missing
@@ -621,7 +620,6 @@ impl<'db> InferenceContext<'db> {
expected,
tgt_expr,
),
- &Expr::Box { expr } => self.infer_expr_box(expr, expected),
Expr::UnaryOp { expr, op } => self.infer_unop_expr(*op, *expr, expected, tgt_expr),
Expr::BinaryOp { lhs, rhs, op } => match op {
Some(BinaryOp::Assignment { op: Some(op) }) => {
@@ -1485,27 +1483,6 @@ impl<'db> InferenceContext<'db> {
self.types.types.never
}
- fn infer_expr_box(&mut self, inner_expr: ExprId, expected: &Expectation<'db>) -> Ty<'db> {
- if let Some(box_id) = self.resolve_boxed_box() {
- let table = &mut self.table;
- let inner_exp = expected
- .to_option(table)
- .as_ref()
- .and_then(|e| e.as_adt())
- .filter(|(e_adt, _)| e_adt == &box_id)
- .map(|(_, subts)| {
- let g = subts.type_at(0);
- Expectation::rvalue_hint(self, g)
- })
- .unwrap_or_else(Expectation::none);
-
- let inner_ty = self.infer_expr_inner(inner_expr, &inner_exp, ExprIsRead::Yes);
- Ty::new_box(self.interner(), inner_ty)
- } else {
- self.err_ty()
- }
- }
-
fn infer_block(
&mut self,
expr: ExprId,
diff --git a/crates/hir-ty/src/infer/mutability.rs b/crates/hir-ty/src/infer/mutability.rs
index 9ec297f5f5..7d285a3a21 100644
--- a/crates/hir-ty/src/infer/mutability.rs
+++ b/crates/hir-ty/src/infer/mutability.rs
@@ -159,7 +159,6 @@ impl<'db> InferenceContext<'db> {
| Expr::Range { lhs: Some(expr), rhs: None, range_type: _ }
| Expr::Range { rhs: Some(expr), lhs: None, range_type: _ }
| Expr::Await { expr }
- | Expr::Box { expr }
| Expr::Loop { body: expr, label: _, source: _ }
| Expr::Cast { expr, type_ref: _ } => {
self.infer_mut_expr(*expr, Mutability::Not);
diff --git a/crates/hir-ty/src/mir.rs b/crates/hir-ty/src/mir.rs
index 976f88601e..fe4b383fbe 100644
--- a/crates/hir-ty/src/mir.rs
+++ b/crates/hir-ty/src/mir.rs
@@ -994,16 +994,6 @@ pub enum Rvalue {
/// coroutine lowering, `Coroutine` aggregate kinds are disallowed too.
Aggregate(AggregateKind, Box<[Operand]>),
- /// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
- ///
- /// This is different from a normal transmute because dataflow analysis will treat the box as
- /// initialized but its content as uninitialized. Like other pointer casts, this in general
- /// affects alias analysis.
- ShallowInitBox(Operand, StoredTy),
-
- /// NON STANDARD: allocates memory with the type's layout, and shallow init the box with the resulting pointer.
- ShallowInitBoxWithAlloc(StoredTy),
-
/// A CopyForDeref is equivalent to a read from a place at the
/// codegen level, but is treated specially by drop elaboration. When such a read happens, it
/// is guaranteed (via nature of the mir_opt `Derefer` in rustc_mir_transform/src/deref_separator)
@@ -1101,9 +1091,7 @@ impl MirBody<'_> {
StatementKind::Assign(p, r) => {
f(p);
match r {
- Rvalue::ShallowInitBoxWithAlloc(_) => (),
- Rvalue::ShallowInitBox(o, _)
- | Rvalue::UnaryOp(_, o)
+ Rvalue::UnaryOp(_, o)
| Rvalue::Cast(_, o, _)
| Rvalue::Repeat(o, _)
| Rvalue::Use(o) => for_operand(o, &mut f),
diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs
index c568209541..e860ae8d3e 100644
--- a/crates/hir-ty/src/mir/borrowck.rs
+++ b/crates/hir-ty/src/mir/borrowck.rs
@@ -239,9 +239,7 @@ fn moved_out_of_ref<'db>(
for statement in &block.statements {
match &statement.kind {
StatementKind::Assign(_, r) => match r {
- Rvalue::ShallowInitBoxWithAlloc(_) => (),
- Rvalue::ShallowInitBox(o, _)
- | Rvalue::UnaryOp(_, o)
+ Rvalue::UnaryOp(_, o)
| Rvalue::Cast(_, o, _)
| Rvalue::Repeat(o, _)
| Rvalue::Use(o) => for_operand(o, statement.span),
@@ -324,9 +322,7 @@ fn partially_moved<'db>(
for statement in &block.statements {
match &statement.kind {
StatementKind::Assign(_, r) => match r {
- Rvalue::ShallowInitBoxWithAlloc(_) => (),
- Rvalue::ShallowInitBox(o, _)
- | Rvalue::UnaryOp(_, o)
+ Rvalue::UnaryOp(_, o)
| Rvalue::Cast(_, o, _)
| Rvalue::Repeat(o, _)
| Rvalue::Use(o) => for_operand(o, statement.span),
@@ -636,7 +632,6 @@ fn mutability_of_locals<'db>(
record_usage_for_operand(arg, &mut result);
}
}
- Rvalue::ShallowInitBox(_, _) | Rvalue::ShallowInitBoxWithAlloc(_) => (),
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index ab60e81646..e968da5111 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -1479,14 +1479,6 @@ impl<'a, 'db> Evaluator<'a, 'db> {
let size = len * val.len();
Owned(val.iter().copied().cycle().take(size).collect())
}
- Rvalue::ShallowInitBox(_, _) => not_supported!("shallow init box"),
- Rvalue::ShallowInitBoxWithAlloc(ty) => {
- let Some((size, align)) = self.size_align_of(ty.as_ref(), locals)? else {
- not_supported!("unsized box initialization");
- };
- let addr = self.heap_allocate(size, align)?;
- Owned(addr.to_bytes().to_vec())
- }
Rvalue::CopyForDeref(_) => not_supported!("copy for deref"),
Rvalue::Aggregate(kind, values) => {
let values = values
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs
index 9db6b36588..a6fb6d764f 100644
--- a/crates/hir-ty/src/mir/eval/shim.rs
+++ b/crates/hir-ty/src/mir/eval/shim.rs
@@ -1415,6 +1415,15 @@ impl<'a, 'db> Evaluator<'a, 'db> {
self.write_memory(location_addr, &location)?;
destination.write_from_bytes(self, &location_addr.to_bytes()[..ptr_size])
}
+ "box_new" => {
+ let ty = generic_args.type_at(0);
+ let Some((size, align)) = self.size_align_of(ty, locals)? else {
+ not_supported!("unsized box initialization");
+ };
+ let addr = self.heap_allocate(size, align)?;
+ self.copy_from_interval(addr, args[0].interval)?;
+ destination.write_from_bytes(self, &addr.to_bytes()[..self.ptr_size()])
+ }
_ if needs_override => not_supported!("intrinsic {name} is not implemented"),
_ => return Ok(false),
}
diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs
index 3a0fe6e249..21c8e83bce 100644
--- a/crates/hir-ty/src/mir/lower.rs
+++ b/crates/hir-ty/src/mir/lower.rs
@@ -999,22 +999,6 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> {
self.push_assignment(current, place, Rvalue::Ref(bk, p.store()), expr_id.into());
Ok(Some(current))
}
- Expr::Box { expr } => {
- let ty = self.expr_ty_after_adjustments(*expr);
- self.push_assignment(
- current,
- place,
- Rvalue::ShallowInitBoxWithAlloc(ty.store()),
- expr_id.into(),
- );
- let Some((operand, current)) = self.lower_expr_to_some_operand(*expr, current)?
- else {
- return Ok(None);
- };
- let p = place.project(ProjectionElem::Deref);
- self.push_assignment(current, p, operand.into(), expr_id.into());
- Ok(Some(current))
- }
Expr::Field { .. }
| Expr::Index { .. }
| Expr::UnaryOp { op: hir_def::hir::UnaryOp::Deref, .. } => {
diff --git a/crates/hir-ty/src/mir/monomorphization.rs b/crates/hir-ty/src/mir/monomorphization.rs
index 042dd076be..bb192a3856 100644
--- a/crates/hir-ty/src/mir/monomorphization.rs
+++ b/crates/hir-ty/src/mir/monomorphization.rs
@@ -179,9 +179,6 @@ impl<'db> Filler<'db> {
super::AggregateKind::Union(_, _) => (),
}
}
- Rvalue::ShallowInitBox(_, ty) | Rvalue::ShallowInitBoxWithAlloc(ty) => {
- self.fill_ty(ty)?;
- }
Rvalue::Use(op) => {
self.fill_operand(op)?;
}
diff --git a/crates/hir-ty/src/mir/pretty.rs b/crates/hir-ty/src/mir/pretty.rs
index 8893069f0c..4a51b5113a 100644
--- a/crates/hir-ty/src/mir/pretty.rs
+++ b/crates/hir-ty/src/mir/pretty.rs
@@ -490,12 +490,6 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> {
self.place(p);
w!(self, ")");
}
- Rvalue::ShallowInitBoxWithAlloc(_) => w!(self, "ShallowInitBoxWithAlloc"),
- Rvalue::ShallowInitBox(op, _) => {
- w!(self, "ShallowInitBox(");
- self.operand(op);
- w!(self, ")");
- }
Rvalue::CopyForDeref(p) => {
w!(self, "CopyForDeref(");
self.place(p);
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index 0c57d050f3..e8f378db32 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -2879,6 +2879,10 @@ unsafe impl Allocator for Global {}
#[fundamental]
pub struct Box<T: ?Sized, A: Allocator = Global>(T, A);
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub fn box_new<T>(_x: T) -> Box<T>;
+
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
pub struct Vec<T, A: Allocator = Global>(T, A);
@@ -2895,8 +2899,8 @@ impl<T> [T] {
}
fn test() {
- let vec = <[_]>::into_vec(#[rustc_box] Box::new([1i32]));
- let v: Vec<Box<dyn B>> = <[_]> :: into_vec(#[rustc_box] Box::new([#[rustc_box] Box::new(Astruct)]));
+ let vec = <[_]>::into_vec(box_new([1i32]));
+ let v: Vec<Box<dyn B>> = <[_]> :: into_vec(box_new([box_new(Astruct)]));
}
trait B{}
@@ -2904,22 +2908,26 @@ struct Astruct;
impl B for Astruct {}
"#,
expect![[r#"
- 639..643 'self': Box<[T], A>
- 672..704 '{ ... }': Vec<T, A>
- 718..888 '{ ...])); }': ()
- 728..731 'vec': Vec<i32, Global>
- 734..749 '<[_]>::into_vec': fn into_vec<i32, Global>(Box<[i32], Global>) -> Vec<i32, Global>
- 734..780 '<[_]>:...i32]))': Vec<i32, Global>
- 750..779 '#[rust...1i32])': Box<[i32; 1], Global>
- 772..778 '[1i32]': [i32; 1]
- 773..777 '1i32': i32
- 790..791 'v': Vec<Box<dyn B + 'static, Global>, Global>
- 811..828 '<[_]> ...to_vec': fn into_vec<Box<dyn B + '?, Global>, Global>(Box<[Box<dyn B + '?, Global>], Global>) -> Vec<Box<dyn B + '?, Global>, Global>
- 811..885 '<[_]> ...ct)]))': Vec<Box<dyn B + '?, Global>, Global>
- 829..884 '#[rust...uct)])': Box<[Box<dyn B + '?, Global>; 1], Global>
- 851..883 '[#[rus...ruct)]': [Box<dyn B + '?, Global>; 1]
- 852..882 '#[rust...truct)': Box<Astruct, Global>
- 874..881 'Astruct': Astruct
+ 428..430 '_x': T
+ 733..737 'self': Box<[T], A>
+ 766..798 '{ ... }': Vec<T, A>
+ 812..940 '{ ...])); }': ()
+ 822..825 'vec': Vec<i32, Global>
+ 828..843 '<[_]>::into_vec': fn into_vec<i32, Global>(Box<[i32], Global>) -> Vec<i32, Global>
+ 828..860 '<[_]>:...i32]))': Vec<i32, Global>
+ 844..851 'box_new': fn box_new<[i32; 1]>([i32; 1]) -> Box<[i32; 1], Global>
+ 844..859 'box_new([1i32])': Box<[i32; 1], Global>
+ 852..858 '[1i32]': [i32; 1]
+ 853..857 '1i32': i32
+ 870..871 'v': Vec<Box<dyn B + 'static, Global>, Global>
+ 891..908 '<[_]> ...to_vec': fn into_vec<Box<dyn B + '?, Global>, Global>(Box<[Box<dyn B + '?, Global>], Global>) -> Vec<Box<dyn B + '?, Global>, Global>
+ 891..937 '<[_]> ...ct)]))': Vec<Box<dyn B + '?, Global>, Global>
+ 909..916 'box_new': fn box_new<[Box<dyn B + '?, Global>; 1]>([Box<dyn B + '?, Global>; 1]) -> Box<[Box<dyn B + '?, Global>; 1], Global>
+ 909..936 'box_ne...uct)])': Box<[Box<dyn B + '?, Global>; 1], Global>
+ 917..935 '[box_n...ruct)]': [Box<dyn B + '?, Global>; 1]
+ 918..925 'box_new': fn box_new<Astruct>(Astruct) -> Box<Astruct, Global>
+ 918..934 'box_ne...truct)': Box<Astruct, Global>
+ 926..933 'Astruct': Astruct
"#]],
)
}
diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
index 5c6c979416..fa9a69c996 100644
--- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs
+++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
@@ -1096,14 +1096,17 @@ fn x(t: &[u8]) {
use core::ops::{Deref, DerefMut};
use core::{marker::Unsize, ops::CoerceUnsized};
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub fn box_new<T>(_x: T) -> Box<T>;
+
#[lang = "owned_box"]
pub struct Box<T: ?Sized> {
inner: *mut T,
}
impl<T> Box<T> {
fn new(t: T) -> Self {
- #[rustc_box]
- Box::new(t)
+ box_new(t)
}
}