Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ak 44493 infer predicate #45298

Merged
merged 1 commit into from
Apr 13, 2018
Merged

Conversation

toidiu
Copy link
Contributor

@toidiu toidiu commented Oct 15, 2017

WIP Implements #44493

Things to do:

  • add feature gate and appropriate tests (see forge for some details)
  • add a unit testing system similar to #[rustc_variance]
    • to see how, maybe rg rustc_variance and take some notes
  • add more tests:
  • we need to decide how to handle struct Foo<'a, T> { x: &'a T::Item }
  • handle explicit predicates on types
  • handle explicit predicates on dyn Trait (this could be put off to a follow-up PR)
  • handle explicit predicates on projections (this could be put off to a follow-up PR)

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@kennytm kennytm added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 15, 2017
@bors
Copy link
Contributor

bors commented Oct 16, 2017

☔ The latest upstream changes (presumably #45297) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

I'm confused -- what is the difference between this PR and #44857 ?

@toidiu
Copy link
Contributor Author

toidiu commented Oct 16, 2017

@nikomatsakis sry for the confusion, this is supposed to be the 3rd PR where I actually implement the inferred outlives. I think #44857 is ready to merge and this PR is rebased from that one.

@nikomatsakis
Copy link
Contributor

@toidiu ah, nice, ok!

@nikomatsakis
Copy link
Contributor

@toidiu now that the other PR has merged, can you rebase this one?

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good start :) left a few minor comments

// /// This relation tracks the dependencies between the variance of
// /// various items. In particular, if `a < b`, then the variance of
// /// `a` depends on the sources of `b`.
// pub dependencies: TransitiveRelation<DefId>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not need this; in fact, we can remove it from variance too, but that's a separate issue I suppose

_ => Vec::new()
}
-> Rc<CratePredicatesMap> {
Rc::new(Vec::new())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we be doing something like Rc::new(CratesPredicateMap::new())

@nikomatsakis
Copy link
Contributor

(BTW, if it's useful to you, we can likely iterate within this PR for a while, before we land the next PR. Bors is awfully busy right now.)

@toidiu
Copy link
Contributor Author

toidiu commented Oct 24, 2017

@nikomatsakis yep totally fine with iterating here.

I could use some guidance at this step. It seems like the function type_of is now encountering a ItemTrait and so we need to add an implementation for that in collect.rs

I tried to find an appropriate method for Trait and came up with mk_substs_trait but not sure if its correct. https://github.com/rust-lang/rust/blob/master/src/librustc/ty/context.rs#L2101

I was also unable to implement mk_substs_trait properly since I dont understand where we get &[Ty<'tcx>]

@nikomatsakis
Copy link
Contributor

@toidiu yeah, type_of should never be encountering an ItemTrait; let me look more closely, your patch must be invoking it somehow when it ought not to.

-> Vec<ty::Predicate<'tcx>> {
Vec::new()

if let ty::TyAdt(_def, _) = tcx.type_of(def_id).sty {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoking type_of indiscriminanetly is not really ok. What we want to do is to first convert the def_id into a local node-id, which will then allow us to query the HIR map to find out what kind of node we are looking at.

Something like this:

use hir::map as hir_map;

// Assert that this is a local node-id:
let node_id = self.tcx.as_local_node_id(def_id).unwrap();

match tcx.hir.get(node_id) {
    hir_map::NodeItem(item) => match item.node {
        hir::ItemTrait(..) => ..,
        hir::ItemStruct(..) => ..,
        hir::ItemEnum(..) => ..,
        _ => ...,
    }
    _ => ...
}

Here, the get() method returns a hir::map::Node. You can see that it has many variants. I think we are just interested in struct/enum here, so that would be NodeItem, and then we must further match on the item.node to find out what kind of item we have. (As shown above.) For everything that is not a struct or enum, I think we can just return an empty vector.

@toidiu
Copy link
Contributor Author

toidiu commented Oct 31, 2017

@nikomatsakis thanks for the help. now that this compiles i am going to work on the crate-wide computation. Will iterate here.

@nikomatsakis
Copy link
Contributor

@toidiu excellent, will watch =) let me know if you run into questions

@nikomatsakis
Copy link
Contributor

@toidiu how goes? had any time to hack on this?

}

#[allow(dead_code)]
fn inferred_outlives_crate <'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the def_id parameter here supposed to refer to? My thought was that this function would infer the outlives relationships for all structs/enums in the crate, therefore it probably doesn't need to take a def_id (rather, in the body it will loop over the set of items to find those structs/enums).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. yes I had a little mis-understanding about the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw planning to use tcx.hir.krate().visit_all_item_likes(&mut terms_cx) along with impl ItemLikeVisitor as we do in variance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg, this function should presumably take a CrateNum then -- at least, that's what we've done elsewhere. (I might be inclined to change the convention for singleton queries like this, but let's not do it in this PR.)

_ => false,
}
)
.collect::<Vec<_>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems ok -- the idea is then that, in here, we will look over the structs/enums. We'll have (say) a DefIdMap (a kind of hashtable keyed byDefId) and, for each struct/enum with def-id S, we'll initialize map[S] to be filtered.

Though actually maybe it's better to do it slightly differently. Maybe the map[S] should be initialized to an empty vector. Then we walk over the fields of S -- if we find that the struct S has a field F that references some other struct S2:

struct Foo<'a, T> { // Foo is S
    bar: Bar<'a, T> // Bar is S2
}

struct Bar<'b, U: 'b> { ... }

then we will (a) compute the filtered, explicit predicates for Bar -- this would include U: 'b -- and add in any "extra" predicates for map[Bar] (in this case, an empty vector). This is the set of requirements that Bar imposes to be well-formed; if we translate those back to Foo by applying the substitution [U => T, 'b => 'a], then we get the requirements T: 'a, which would get added to Map[Foo] as one of the implicits we inferred.

In other words, it makes sense to separate out the filtered explicits since we don't really want to add them to the list of implicits, or else we're just duplicating stuff.

Anyway, this is kind of high-level -- would it be helpful if I spelled it out in more low-level detail? Does what I wrote here make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high-level is actually good and one of the things that I am still a bit fuzzy on. I am going to layout the code-plan as my next step; which should help. After that the implementation details should become easier and plug-and-play.

@toidiu
Copy link
Contributor Author

toidiu commented Nov 9, 2017

@nikomatsakis just pushed some changes for how i envision the structure. it definitely doesnt compile and is a mix of rust+pseudo code.

The point of this is that I wanted to get some confirmation that i am thinking about this correctly before expanding and and fixing syntax.

//now infer outlive prediacates from the filtered predicates
for p in filtered {
the_great_inferring(p)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look quite right. This is taking a single item (def_id) -- e.g., a single struct or enum type -- and computing its explicit predicates, and then iterating over those predicates. What we want to do be doing is something more like this.

@bors
Copy link
Contributor

bors commented Nov 16, 2017

☔ The latest upstream changes (presumably #45825) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

@toidiu I was wondering -- it seems like you're having a hard time getting started here, which is totally understandable. Maybe we could schedule some time and do a kind of "pair programming" session just to get things off the ground?

@toidiu
Copy link
Contributor Author

toidiu commented Nov 18, 2017

@nikomatsakis that would be most helpful. Will message you over irc to discuss details.

// for the type.
//for def_id in all_types() {
// let explicit_predicates = tcx.explicit_predicates(def_id);
let def_id = DefId.local(item.hir_id.owner);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikomatsakis I dont know how to retrieve a DefId here from Item. Can you suggest a method from this struct. https://github.com/rust-lang/rust/blob/master/src/librustc/hir/mod.rs#L1816

let local_explicit_predicate = self.tcx.explicit_predicates_of(def_id);

let filtered_predicates = local_explicit_predicate
.predicates.into_iter()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if I should be doing into_iter or iter() since that calculation will be cached and used by incremental?

crate_num: CrateNum,
}

impl<'tcx, 'a, 'p, 'v> ItemLikeVisitor<'v> for ExplicitVisitor<'tcx, 'a, 'p> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikomatsakis I am getting lifetime errors but not sure how to fix this.

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'tcx` due to conflicting requirements
  --> src/librustc_typeck/outlives/explicit.rs:59:49
   |
59 |         let local_explicit_predicate = self.tcx.explicit_predicates_of(def_id);
   |                                                 ^^^^^^^^^^^^^^^^^^^^^^
   |
note: first, the lifetime cannot outlive the lifetime 'tcx as defined on the impl at 54:1...
  --> src/librustc_typeck/outlives/explicit.rs:54:1
   |
54 | / impl<'tcx, 'a, 'p, 'v> ItemLikeVisitor<'v> for ExplicitVisitor<'tcx, 'a, 'p> {
55 | |     fn visit_item(&mut self, item: &hir::Item) {
56 | |
57 | |         //let def_id = LocalDefId::new(item.hir_id.owner).to_def_id();
...  |
77 | |     }
78 | | }
   | |_^
note: ...so that types are compatible (expected rustc::ty::TyCtxt<'_, '_, '_>, found rustc::ty::TyCtxt<'tcx, 'tcx, 'tcx>)
  --> src/librustc_typeck/outlives/explicit.rs:59:49
   |
59 |         let local_explicit_predicate = self.tcx.explicit_predicates_of(def_id);
   |                                                 ^^^^^^^^^^^^^^^^^^^^^^
note: but, the lifetime must be valid for the lifetime 'p as defined on the impl at 54:1...
  --> src/librustc_typeck/outlives/explicit.rs:54:1
   |
54 | / impl<'tcx, 'a, 'p, 'v> ItemLikeVisitor<'v> for ExplicitVisitor<'tcx, 'a, 'p> {
55 | |     fn visit_item(&mut self, item: &hir::Item) {
56 | |
57 | |         //let def_id = LocalDefId::new(item.hir_id.owner).to_def_id();
...  |
77 | |     }
78 | | }
   | |_^
note: ...so that expression is assignable (expected std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'p>>>, found std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)
  --> src/librustc_typeck/outlives/explicit.rs:70:49
   |
70 |         self.explicit_predicates.insert(def_id, Rc::new(filtered_predicates));
   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@nikomatsakis nikomatsakis removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 11, 2018
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 11, 2018

📌 Commit c88e59a has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2018
@bors
Copy link
Contributor

bors commented Apr 12, 2018

⌛ Testing commit c88e59abd8453401ef6679c5c3119a8de49606db with merge 7646fc426428f6915fe3b20734615580b9730b54...

@bors
Copy link
Contributor

bors commented Apr 12, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 12, 2018
@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:05:46] 31 |         inferred_outlives_of,
[00:05:46]    |         ^^^^^^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:46]    |
[00:05:46]    = note: expected type `for<'a> fn(rustc::ty::TyCtxt<'a, '_, '_>, rustc::hir::def_id::DefId) -> std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:46]               found type `for<'a, 'tcx> fn(rustc::ty::TyCtxt<'a, 'tcx, 'tcx>, rustc::hir::def_id::DefId) -> std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'tcx>>> {outlives::inferred_outlives_of}`
[00:05:46]
[00:05:46] error[E0308]: mismatched types
[00:05:46]   --> librustc_typeck/outlives/mod.rs:32:9
[00:05:46]    |
[00:05:46] 32 |         inferred_outlives_crate,
[00:05:46]    |         ^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:46]    |
[00:05:46]    = note: expected type `for<'a> fn(rustc::ty::TyCtxt<'a, '_, '_>, rustc::hir::def_id::CrateNum) -> std::sync::Arc<rustc::ty::CratePredicatesMap<'_>>`
[00:05:46]               found type `for<'r, 'tcx> fn(rustc::ty::TyCtxt<'r, 'tcx, 'tcx>, rustc::hir::def_id::CrateNum) -> std::rc::Rc<rustc::ty::CratePredicatesMap<'tcx>> {outlives::inferred_outlives_crate}`
[00:05:46]
[00:05:46] error[E0308]: mismatched types
[00:05:46]   --> librustc_typeck/outlives/mod.rs:52:17
[00:05:46]    |
[00:05:46] 52 | /                 crate_map
[00:05:46] 53 | |                     .predicates
[00:05:46] 54 | |                     .get(&item_def_id)
[00:05:46] 55 | |                     .unwrap_or(&crate_map.empty_predicate)
[00:05:46] 56 | |                     .clone()
[00:05:46]    | |____________________________^ expected struct `std::rc::Rc`, found struct `std::sync::Arc`
[00:05:46]    |
[00:05:46]    = note: expected type `std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'tcx>>>`
[00:05:46]               found type `std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:46]
[00:05:46] error[E0277]: the trait bound `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>: std::iter::FromIterator<(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)>` is not satisfied
[00:05:46]    --> librustc_typeck/outlives/mod.rs:103:10
[00:05:46]     |
[00:05:46] 103 |         .collect();
[00:05:46]     |          ^^^^^^^ a collection of type `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>` cannot be built from an iterator over elements of type `(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)`
[00:05:46]     |
[00:05:46]     = help: the trait `std::iter::FromIterator<(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)>` is not implemented for `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>`
[00:05:46]
[00:05:47] error[E0308]: mismatched types
[00:05:47]    --> librustc_typeck/outlives/mod.rs:109:9
[00:05:47]     |
[00:05:47] 109 |         empty_predicate,
[00:05:47]     |         ^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:47]     |
[00:05:47]     = note: expected type `std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:47]                found type `std::rc::Rc<std::vec::Vec<_>>`
---
[00:05:47]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_typeck librustc_typeck/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,metadata -C prefer-dynamic -C debug-assertions=off -C overflow-checks=on -C metadata=c63ba039c028c12c -C extra-filename=-c63ba039c028c12c --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/incremental -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-5726b7c8b62bc86c.rmeta --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-faf6f68107bf25e3.rmeta --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-ee064adeca477563.rmeta --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-90283f9e250487de.rmeta --extern fmt_macros=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libfmt_macros-9218d27d5a08fa21.rmeta --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-75f2b25c19b6a07d.rmeta --extern rustc_platform_intrinsics=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_platform_intrinsics-db8bb8d55fda1b18.rmeta --extern rustc_const_math=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_const_math-2bde2a5e13686daa.rmeta --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-1f1120e687485c31.rmeta --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-c43c75e6fa38c52c.rmeta -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-8b35e3c2ea935fab/out/.libs -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-63734d0048644b22/out` (exit code: 101)
[00:05:47] warning: build failed, waiting for other jobs to finish...
[00:06:10] error: build failed
[00:06:10] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:06:10] expected success, got: exit code: 101
[00:06:10] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1085:9
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0b5f85fa:start=1523502420924986083,finish=1523502420932557462,duration=7571379
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:0043582f
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:0043582f:start=1523502420942417380,finish=1523502420948995151,duration=6577771
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0701b0ec
$ dmesg | grep -i kill
[   10.461702] init: failsafe main process (1092) killed by TERM signal

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:05:46] 31 |         inferred_outlives_of,
[00:05:46]    |         ^^^^^^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:46]    |
[00:05:46]    = note: expected type `for<'a> fn(rustc::ty::TyCtxt<'a, '_, '_>, rustc::hir::def_id::DefId) -> std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:46]               found type `for<'a, 'tcx> fn(rustc::ty::TyCtxt<'a, 'tcx, 'tcx>, rustc::hir::def_id::DefId) -> std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'tcx>>> {outlives::inferred_outlives_of}`
[00:05:46]
[00:05:46] error[E0308]: mismatched types
[00:05:46]   --> librustc_typeck/outlives/mod.rs:32:9
[00:05:46]    |
[00:05:46] 32 |         inferred_outlives_crate,
[00:05:46]    |         ^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:46]    |
[00:05:46]    = note: expected type `for<'a> fn(rustc::ty::TyCtxt<'a, '_, '_>, rustc::hir::def_id::CrateNum) -> std::sync::Arc<rustc::ty::CratePredicatesMap<'_>>`
[00:05:46]               found type `for<'r, 'tcx> fn(rustc::ty::TyCtxt<'r, 'tcx, 'tcx>, rustc::hir::def_id::CrateNum) -> std::rc::Rc<rustc::ty::CratePredicatesMap<'tcx>> {outlives::inferred_outlives_crate}`
[00:05:46]
[00:05:46] error[E0308]: mismatched types
[00:05:46]   --> librustc_typeck/outlives/mod.rs:52:17
[00:05:46]    |
[00:05:46] 52 | /                 crate_map
[00:05:46] 53 | |                     .predicates
[00:05:46] 54 | |                     .get(&item_def_id)
[00:05:46] 55 | |                     .unwrap_or(&crate_map.empty_predicate)
[00:05:46] 56 | |                     .clone()
[00:05:46]    | |____________________________^ expected struct `std::rc::Rc`, found struct `std::sync::Arc`
[00:05:46]    |
[00:05:46]    = note: expected type `std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'tcx>>>`
[00:05:46]               found type `std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:46]
[00:05:46] error[E0277]: the trait bound `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>: std::iter::FromIterator<(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)>` is not satisfied
[00:05:46]    --> librustc_typeck/outlives/mod.rs:103:10
[00:05:46]     |
[00:05:46] 103 |         .collect();
[00:05:46]     |          ^^^^^^^ a collection of type `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>` cannot be built from an iterator over elements of type `(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)`
[00:05:46]     |
[00:05:46]     = help: the trait `std::iter::FromIterator<(rustc::hir::def_id::DefId, std::rc::Rc<std::vec::Vec<rustc::ty::Predicate<'_>>>)>` is not implemented for `std::collections::HashMap<rustc::hir::def_id::DefId, std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>, std::hash::BuildHasherDefault<rustc_data_structures::fx::FxHasher>>`
[00:05:46]
[00:05:47] error[E0308]: mismatched types
[00:05:47]    --> librustc_typeck/outlives/mod.rs:109:9
[00:05:47]     |
[00:05:47] 109 |         empty_predicate,
[00:05:47]     |         ^^^^^^^^^^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
[00:05:47]     |
[00:05:47]     = note: expected type `std::sync::Arc<std::vec::Vec<rustc::ty::Predicate<'_>>>`
[00:05:47]                found type `std::rc::Rc<std::vec::Vec<_>>`
---
[00:05:47]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_typeck librustc_typeck/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,metadata -C prefer-dynamic -C debug-assertions=off -C overflow-checks=on -C metadata=c63ba039c028c12c -C extra-filename=-c63ba039c028c12c --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/incremental -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-5726b7c8b62bc86c.rmeta --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-faf6f68107bf25e3.rmeta --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-ee064adeca477563.rmeta --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-90283f9e250487de.rmeta --extern fmt_macros=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libfmt_macros-9218d27d5a08fa21.rmeta --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-75f2b25c19b6a07d.rmeta --extern rustc_platform_intrinsics=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_platform_intrinsics-db8bb8d55fda1b18.rmeta --extern rustc_const_math=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_const_math-2bde2a5e13686daa.rmeta --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-1f1120e687485c31.rmeta --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-c43c75e6fa38c52c.rmeta -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-8b35e3c2ea935fab/out/.libs -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-63734d0048644b22/out` (exit code: 101)
[00:05:47] warning: build failed, waiting for other jobs to finish...
[00:06:10] error: build failed
[00:06:10] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:06:10] expected success, got: exit code: 101
[00:06:10] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1085:9
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0b5f85fa:start=1523502420924986083,finish=1523502420932557462,duration=7571379
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:0043582f
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:0043582f:start=1523502420942417380,finish=1523502420948995151,duration=6577771
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0701b0ec
$ dmesg | grep -i kill
[   10.461702] init: failsafe main process (1092) killed by TERM signal

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@@ -139,7 +140,11 @@ define_maps! { <'tcx>
[] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,

/// Maps from def-id of a type to its (inferred) outlives.
[] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Vec<ty::Predicate<'tcx>>,
[] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Lrc is causing the error if executed with parallel on. Need to update the outlives code to return an Lrc rather than a Rc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds right

@bors
Copy link
Contributor

bors commented Apr 12, 2018

☔ The latest upstream changes (presumably #48528) made this pull request unmergeable. Please resolve the merge conflicts.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2018
…um, union, and projection types. added a feature gate and tests for these scenarios.
@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 12, 2018
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 12, 2018

📌 Commit 6a229cb has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2018
@bors
Copy link
Contributor

bors commented Apr 12, 2018

⌛ Testing commit 6a229cb with merge c4a0328...

bors added a commit that referenced this pull request Apr 12, 2018
Ak 44493 infer predicate

 **WIP**  Implements #44493

Things to do:

- [x] add feature gate and appropriate tests (see [forge](https://forge.rust-lang.org/feature-guide.html) for some details)
- [x] add a unit testing system similar to `#[rustc_variance]`
  - [x] to see how, maybe `rg rustc_variance` and take some notes
- [ ] add more tests:
- [x] we need to decide how to handle `struct Foo<'a, T> { x: &'a T::Item }`
- [x] handle explicit predicates on types
- [ ] handle explicit predicates on `dyn Trait` (this could be put off to a follow-up PR)
- [ ] handle explicit predicates on projections (this could be put off to a follow-up PR)
@bors
Copy link
Contributor

bors commented Apr 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing c4a0328 to master...

@bors bors merged commit 6a229cb into rust-lang:master Apr 13, 2018
@toidiu toidiu deleted the ak-44493-infer-predicate branch April 13, 2018 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.