Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2fdd1ac

Browse files
committedMay 1, 2023
Auto merge of rust-lang#14664 - HKalbasi:mir, r=HKalbasi
MIR episode 4 In lowering, it now supports overloaded and arith assignment binary operators, statics. and constants in patterns. There is now 252 functions that we fail to emit mir for them, and the majority of them are due type mismatches or other deep and unrelated issues (but it isn't done yet, for example slice patterns and destructing assignment is not implemented yet). In evaluating, it now can evaluate associated constants in traits (so now typenum's `U5::ToConst` should work), allocator functions, atomic intrinsics, and some more things. It also provides a (hacky) basis for making progress in rust-lang#14275. I also added a `Interpret` code lens to `Run` and `Debug` when the experimental `interpret tests` is enabled (previously it showed result in hover, which was unusable even for debugging) Changes in unrelated files are: * Changes substitutions of closures, now it includes parent substs ~~before~~ after `sig_ty`. * ~~A salsa input for retrieving the path of a file id, used in emitting stack trace for interpret result.~~ * Normalizing associated types in layout computing
2 parents 001607f + 6312fbf commit 2fdd1ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2556
-804
lines changed
 

‎crates/base-db/src/change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl fmt::Debug for Change {
3434
}
3535

3636
impl Change {
37-
pub fn new() -> Change {
37+
pub fn new() -> Self {
3838
Change::default()
3939
}
4040

‎crates/hir-def/src/body/lower.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hash::FxHashMap;
1717
use smallvec::SmallVec;
1818
use syntax::{
1919
ast::{
20-
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasLoopBody, HasName,
20+
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasLoopBody, HasName,
2121
SlicePatComponents,
2222
},
2323
AstNode, AstPtr, SyntaxNodePtr,
@@ -302,16 +302,29 @@ impl ExprCollector<'_> {
302302
self.alloc_expr(Expr::For { iterable, pat, body, label }, syntax_ptr)
303303
}
304304
ast::Expr::CallExpr(e) => {
305-
let callee = self.collect_expr_opt(e.expr());
306-
let args = if let Some(arg_list) = e.arg_list() {
307-
arg_list.args().filter_map(|e| self.maybe_collect_expr(e)).collect()
308-
} else {
309-
Box::default()
305+
let is_rustc_box = {
306+
let attrs = e.attrs();
307+
attrs.filter_map(|x| x.as_simple_atom()).any(|x| x == "rustc_box")
310308
};
311-
self.alloc_expr(
312-
Expr::Call { callee, args, is_assignee_expr: self.is_lowering_assignee_expr },
313-
syntax_ptr,
314-
)
309+
if is_rustc_box {
310+
let expr = self.collect_expr_opt(e.arg_list().and_then(|x| x.args().next()));
311+
self.alloc_expr(Expr::Box { expr }, syntax_ptr)
312+
} else {
313+
let callee = self.collect_expr_opt(e.expr());
314+
let args = if let Some(arg_list) = e.arg_list() {
315+
arg_list.args().filter_map(|e| self.maybe_collect_expr(e)).collect()
316+
} else {
317+
Box::default()
318+
};
319+
self.alloc_expr(
320+
Expr::Call {
321+
callee,
322+
args,
323+
is_assignee_expr: self.is_lowering_assignee_expr,
324+
},
325+
syntax_ptr,
326+
)
327+
}
315328
}
316329
ast::Expr::MethodCallExpr(e) => {
317330
let receiver = self.collect_expr_opt(e.receiver());

0 commit comments

Comments
 (0)
This repository has been archived.