summaryrefslogtreecommitdiff
path: root/Notes
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-09-21 09:37:32 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-09-21 09:37:32 +0800
commit0c9a998feb2d7308c03e45aa71475d2a9315f6be (patch)
treefc17ed1528040bea6f9156cb0d911f8c3e45453c /Notes
parent231bd48ccb5a9a94e6289690a7af2d218523a3e7 (diff)
downloadmrust-0c9a998feb2d7308c03e45aa71475d2a9315f6be.tar.gz
Notes - Some outstanding issues
Diffstat (limited to 'Notes')
-rw-r--r--Notes/ISSUE-MovesInMatchGuards.txt30
-rw-r--r--Notes/ISSUE-TraitMethodsVsInherentMethods.txt12
2 files changed, 42 insertions, 0 deletions
diff --git a/Notes/ISSUE-MovesInMatchGuards.txt b/Notes/ISSUE-MovesInMatchGuards.txt
new file mode 100644
index 00000000..51f9453c
--- /dev/null
+++ b/Notes/ISSUE-MovesInMatchGuards.txt
@@ -0,0 +1,30 @@
+Encountered while processing https://github.com/rust-lang/rust/blob/8c93a79e387f5197e8b8fe73b3d87d2b101b7c4a/src/test/run-pass/move-guard-const.rs
+- Value is moved in a match guard, which fails and falls to an arm where the value is still belived to be valid.
+
+Ideal 1: Model match common codegen as a else-if chain.
+ > For each arm: Make a split scope, expand patterns, codegen guard, then switch to the other scope and immediately complete it.
+- Problem: A move can be bypassed.
+- Solution: Treat a bypass path as a second arm to the `if`
+- Problem 2: Arms can be mutually exclusive, and hence can move in both with no lower-time error.
+- Post-validation can solve that.
+
+
+Idea 2: Refactor state tracking to instead store a COW state stack what can have the state removed for later use.
+- Push/pop state around each pattern
+- Unify apply after patterns in an arm
+- Pop state after processing the condition
+- Unify before processing each arm
+- Problem: Doens't concretely determine if something is moved? (Will use drop
+ flags when not needed)
+
+
+Idea 3: When processing a match guard, enter a mode where all moves of above values are conditional.
+ > Flag on the Scope::Split used for the match pattern
+ > Flag is set/cleared around processing the arm guard
+ > Mutating the state within this scope creates a drop flag
+- Problem: Structurally, allocating the drop flag is a challeng
+ > Solution: Use a new scope type (with no split, just applies backwards)
+
+
+Overall problem: Use-after-free still possible (but has to be invalid code with the above fixes)
+- Solution: Dump the entire concept and just add a "NoMutate" scope type that errors if state changes across it
diff --git a/Notes/ISSUE-TraitMethodsVsInherentMethods.txt b/Notes/ISSUE-TraitMethodsVsInherentMethods.txt
new file mode 100644
index 00000000..1e70f767
--- /dev/null
+++ b/Notes/ISSUE-TraitMethodsVsInherentMethods.txt
@@ -0,0 +1,12 @@
+ISSUE: Trait method .powi not being considered because <f32>::powi is found
+
+Needs to search for trait methods first.
+- But that falls into problems when the trait method isn't the correct method!
+ - E.g. `impl Iterator for Parser` ... `impl Parser { fn position(&mut self) }`
+
+
+References:
+- `rustc-nightly/src/libfmt_macros/lib.rs` line 272
+ - Requires that `<Parser>::position` be called not `Iterator::position`
+- `rustc-nightly/src/vendor/num-traits/src/lib.rs` line 308
+ - Requires that `Float::powi` be chosen for inferrence to succeed