Uh oh!
There was an error while loading. Please reload this page.
Propagate container across object cast - #22012
Conversation
rust-highfive
commented
Feb 6, 2015
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
pnkfelix
commented
Feb 6, 2015
There was a problem hiding this comment.
Could you add a second impl that returns something which is not Box<_>? (same for Refed below)
I recall being bit before by having just one impl and getting it selected even without enough type hints.
There was a problem hiding this comment.
Will do. (Its interesting, @alexcrichton brought up the same issue on the RFC itself. I wonder if this is an artifact of the old trait matching code, or the new, or both...)
eddyb
commented
Feb 9, 2015
r=me with the test additions. |
ca73b6f to
ee87aa1Compare(with multiple impls to further exercise correct trait-matching.)
ee87aa1 to
a1b3189Comparepnkfelix
commented
Feb 9, 2015
@bors: r=eddyb a1b3189 rollup |
…-object-cast, r=eddyb Given `<expr> as Box<Trait>`, infer that `Box<_>` is expected type for `<expr>`.
…object-cast Given `<expr> as Box<Trait>`, infer that `Box<_>` is expected type for `<expr>`. This is useful for addressing fallout from newly proposed box protocol; see rust-lang#22006 for examples of such fallout, much of which will be unnecessary with this fix.
…using `fresh_ty` (hat tip to nikomatsakis who was the one who pointed out this simplification to the logic.)
PR #22012 followup: clean up vtable::check_object_cast by reusing `fresh_ty` (hat tip to nikomatsakis, who was the one who pointed out this simplification to the logic.)
nrc
commented
Mar 22, 2015
Are we going to miss this? I have a branch which removes this facility. The root problem is that we do object conversions differently depending on if we are using coercion or casting. My branch removes the cast code path completely so |
nrc
commented
Mar 22, 2015
ping @pnkfelix about that last comment |
pnkfelix
commented
Mar 23, 2015
@nrc when you say "so x as Box is essentially compiled as If so, then I think that should be fine; the important thing was getting the type-hint that If you look at appendix b from the most recent box/placement RFC, it shows the particular place where I needed this PR, namely the bit that says: #[cfg(coerce_works3)]// (This one assumes PR 22012 has landed)pubfncoerce<'a,F>(f:F) -> BoxFn<'a>whereF:Fn(),F:'a{box_!( f )asBoxFn}so you should be able to take that code, put it into a file, and try your branch on it, to make sure you don't regress the behavior here. (I guess I should have maybe put in some tests to ensure this did not get regressed.) In other words, make sure that this playpen does not stop working, and I'll be happy. |
pnkfelix
commented
Mar 23, 2015
@nrc and I discussed further; I was over-optimistic when I said:
because what I would have really liked would be to compile but in any case, after further discussion I decided that its not the end of the world if @nrc makes the change he desires here. |
…chor-qualifier fix: no imports on type anchor qualified path
Given
<expr> as Box<Trait>, infer thatBox<_>is expected type for<expr>.This is useful for addressing fallout from newly proposed box protocol; see #22006 for examples of such fallout, much of which will be unnecessary with this fix.