Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCorrect regression in type-inference #27258
Conversation
rust-highfive
assigned
eddyb
Jul 24, 2015
arielb1
reviewed
Jul 24, 2015
src/librustc/middle/traits/select.rs
Outdated
| let upcast_trait_refs: Vec<_> = util::supertraits(self.tcx(), poly_trait_ref).collect(); | ||
|
|
||
| // Find the first one that matches; this is what we are upcasting to. | ||
| let index = |
This comment has been minimized.
This comment has been minimized.
arielb1
Jul 24, 2015
Contributor
nit: I think this iterator salad would actually be clearer as a for-loop
arielb1
reviewed
Jul 24, 2015
| @@ -1367,11 +1367,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | |||
| // correct trait, but also the correct type parameters. | |||
| // For example, we may be trying to upcast `Foo` to `Bar<i32>`, | |||
| // but `Foo` is declared as `trait Foo : Bar<u32>`. | |||
| let upcast_trait_refs = util::supertraits(self.tcx(), poly_trait_ref) | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r+ modulo nit |
eddyb
reviewed
Jul 24, 2015
src/librustc/middle/traits/select.rs
Outdated
| let mut upcast_trait_ref = None; | ||
| let mut vtable_base = 0; | ||
| // Collect the full set of supertraitrefs. | ||
| let upcast_trait_refs: Vec<_> = util::supertraits(self.tcx(), poly_trait_ref).collect(); |
This comment has been minimized.
This comment has been minimized.
eddyb
reviewed
Jul 24, 2015
src/librustc/middle/traits/select.rs
Outdated
| // Now that we found the correct trait ref, we have to match again outside | ||
| // the probe to confirm the effects. | ||
| let upcast_trait_ref = upcast_trait_refs[index].clone(); | ||
| self.match_poly_trait_ref(obligation, upcast_trait_ref.clone()).unwrap(); |
This comment has been minimized.
This comment has been minimized.
eddyb
Jul 24, 2015
Member
I think it would be enough to just add this and keep the non-allocating loop.
nikomatsakis
force-pushed the
nikomatsakis:issue-26952
branch
from
93e7295
to
4726bb4
Jul 24, 2015
This comment has been minimized.
This comment has been minimized.
|
@eddyb updated |
eddyb
reviewed
Jul 24, 2015
| @@ -1898,7 +1898,7 @@ impl<'tcx> PolyTraitRef<'tcx> { | |||
| /// erase, or otherwise "discharge" these bound regions, we change the | |||
| /// type from `Binder<T>` to just `T` (see | |||
| /// e.g. `liberate_late_bound_regions`). | |||
| #[derive(Clone, PartialEq, Eq, Hash, Debug)] | |||
| #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] | |||
| pub struct Binder<T>(pub T); | |||
This comment has been minimized.
This comment has been minimized.
eddyb
Jul 24, 2015
Member
Time to remove a thousand clone calls :P.
@huonw @Manishearth How about a lint against calling .clone() on a Copy type?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Jul 24, 2015
bors
added a commit
that referenced
this pull request
Jul 24, 2015
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jul 25, 2015
This comment has been minimized.
This comment has been minimized.
bors
merged commit 4726bb4
into
rust-lang:master
Jul 25, 2015
nikomatsakis
deleted the
nikomatsakis:issue-26952
branch
Mar 30, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
nikomatsakis commentedJul 24, 2015
Correct regression in type-inference caused by failing to reconfirm that
the object trait matches the required trait during trait selection. The
existing code was checking that the object trait WOULD match (in a
probe), but never executing the match outside of a probe.
This corrects various regressions observed in the wild, including
issue #26952. Fixes #26952.
r? @eddyb
cc @frankmcsherry