From e503135eb7aa91bd28256b7f91b62ee265b47fdf Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 16 Sep 2016 22:30:33 +0800 Subject: Notes - `box` operator quirks --- Notes/BoxOperator.md | 36 ++++++++++++++++++++++++++++++++++++ Notes/todo.txt | 7 +++---- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Notes/BoxOperator.md (limited to 'Notes') diff --git a/Notes/BoxOperator.md b/Notes/BoxOperator.md new file mode 100644 index 00000000..33e30268 --- /dev/null +++ b/Notes/BoxOperator.md @@ -0,0 +1,36 @@ +% `box` and `in` operators + +See: https://github.com/rust-lang/rfcs/pull/1426#r48383364 + +Structures +========= + +AST +--- + +UniOp for `box` and BinOp for `in` and `<-` + + +HIR +--- + +```c++ +struct ExprNode_Emplace +{ + enum class Type { + Placer, + Boxer, + }; + + Type m_type; + ExprNodeP m_place; + ExprNodeP m_value; +} +``` + + +Type Inferrence +=============== + +The `_Emplace` node type has a revisit to obtain the expected result type. + diff --git a/Notes/todo.txt b/Notes/todo.txt index b1518ef4..161c34eb 100644 --- a/Notes/todo.txt +++ b/Notes/todo.txt @@ -1,8 +1,7 @@ TODO: -- Fix method selection such that calling `let _: Foo = bar.into();` works - - A `From` impl for `Foo` isn't found, becuase the code that searches for the `Into` impl doesn't know that the param is `Foo` - - Could have an edge case where a trait is selected if it's the only possibility (there's no other source of that method name) - - Correct solution would be to hand parameters to the `find_method` function. +- Replace `box` desugaring with passthrough to HIR which will replace with operator call after typeck + - See https://github.com/rust-lang/rfcs/pull/1426#r48383364 + - May require a design/notes doc covering the inferrence behavior. - Audit TODOs in codebase - Method and type monomorphisation - Test compile against a no_std program -- cgit v1.2.3