Rollup merge of #59216 - stepnivlk:type_dependent_defs-wrappers, r=oli-obk

Type dependent defs wrappers

First of all, forgive me if something would seem lame to you or I offend some rule (although I tried to read through docs), this is my first PR.

Issue: https://github.com/rust-lang/rust/issues/59094

This PR adds 3 helper methods to `TypeckTables`:
* `opt_type_dependent_def`
* `opt_type_dependent_def_id`
* `type_dependent_def_id`

I didn't add `type_dependent_def` as was proposed in the issue simply because it wasn't used anywhere in the code. Only non-option wrapped`type_dependent_defs()[]` accesses were found in clippy which always called `def_id()` on result.
Speaking of clippy, should I open separate PR in its own repo, given it's used as submodule here?

Sry it took me so long, as I said I'm new here and I had tough week :).
This commit is contained in:
Mazdak Farrokhzad 2019-03-28 13:35:33 +01:00 committed by GitHub
commit 4720fcac4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 24 additions and 19 deletions

View file

@ -405,8 +405,7 @@ fn check_expr_kind<'a, 'tcx>(
for index in hirvec.iter() {
method_call_result &= v.check_expr(index);
}
if let Some(def) = v.tables.type_dependent_defs().get(e.hir_id) {
let def_id = def.def_id();
if let Some(def_id) = v.tables.type_dependent_def_id(e.hir_id) {
match v.tcx.associated_item(def_id).container {
ty::ImplContainer(_) => method_call_result & v.handle_const_fn_call(def_id),
ty::TraitContainer(_) => NotPromotable,