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

Rollup of 29 pull requests #38499

Merged
merged 106 commits into from
Dec 21, 2016
Merged
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
c470d4a
Add borrow support for slice binary search methods.
christophebiocca Nov 14, 2016
9976f5f
Add missing doc examples for SocketAddr struct
GuillaumeGomez Dec 8, 2016
7fe17f9
Add doc examples for UnixStream
GuillaumeGomez Dec 8, 2016
c35b9f6
Add UnixListener doc examples
GuillaumeGomez Dec 8, 2016
a78a33c
Add Incoming doc examples
GuillaumeGomez Dec 8, 2016
ef09db0
Point out the known type when field doesn't satisfy bound
estebank Dec 4, 2016
90c5b71
compiletest: A more verbose matching failure for mir tests
bluss Dec 10, 2016
f09e2cc
Expand E0309 explanation with motivating example
jonhoo Dec 12, 2016
8323185
minor fix about visibility in reference
liigo Dec 7, 2016
e095c71
Associated items and variants inherit visibility from their traits an…
liigo Dec 13, 2016
16d4b7b
doc: Explain meaning of Result iters and link to factory functions.
sourcefrog Dec 3, 2016
60fbe7a
Add missing Duration examples
GuillaumeGomez Dec 13, 2016
cf56c1f
Indicate `BTreeSet` in docs is code-like.
frewsxcv Dec 7, 2016
5c13041
review comments
estebank Dec 12, 2016
868fb03
When cast needs a dereference point at full cast
estebank Dec 8, 2016
ae36934
Document how `BTreeSet` iterator structures are created.
frewsxcv Dec 7, 2016
4c4e8c4
Simplify `BTreeSet::iter` doc example.
frewsxcv Dec 7, 2016
8cd3081
rustdoc: a formatting nit
tshepang Dec 15, 2016
c49e317
rustbuild: Stop building docs for libtest by default
ollie27 Dec 15, 2016
897cf9b
Add prefix to config.toml
jackpot51 Dec 15, 2016
58b94bd
Update config.toml.example
jackpot51 Dec 15, 2016
2938e6a
Add missing doc examples for UnixDatagram
GuillaumeGomez Dec 8, 2016
87b4071
Definitions: Split out NodeId <-> DefIndex mapping
michaelwoerister Dec 13, 2016
8e34a8e
Definitions: Extract DefPath interning into its own data structure.
michaelwoerister Dec 14, 2016
aed0cdb
definitions: Don't allocate DefIds for inlined HIR
michaelwoerister Dec 16, 2016
ed5a88e
definitions: Store DefPath data in separate table in metadata
michaelwoerister Dec 16, 2016
e0d2629
definitions: Add some timing stats for DefPathTable decoding.
michaelwoerister Dec 16, 2016
ea733b5
No need to store Definitions in RefCell within HIR map
michaelwoerister Dec 16, 2016
72f95aa
Move retrace_path() implementation to DefPathTable
michaelwoerister Dec 16, 2016
70944c2
No need to have tcx::opt_def_path() now that we store all DefPaths
michaelwoerister Dec 16, 2016
45571f3
definitions: Add some documentation.
michaelwoerister Dec 17, 2016
77e659a
Remove some more things that were only needed for inlined-HIR DefIds
michaelwoerister Dec 17, 2016
dd0fc0a
Disconnect ar from cc on OpenBSD
semarie Dec 17, 2016
18ff641
Minor fix in the merge_sort comments
Dec 17, 2016
9f8c1e2
disable run-pass/backtrace for openbsd
semarie Dec 17, 2016
a7d9025
let BSD to use gmake for GNU-make
semarie Dec 17, 2016
2c39ee1
OpenBSD has two stdc++ libraries: use the newer
semarie Dec 18, 2016
86fc63e
Implement `fmt::Debug` for all structures in libstd.
frewsxcv Nov 25, 2016
b35c306
Fix the path resolutions of glob imports.
jseyfried Dec 2, 2016
83ab9f7
Remove some unused functions and fix formatting.
jseyfried Nov 29, 2016
59de7f8
Add `ident.unhygienize()` and use `Ident` more instead of `Name` in `…
jseyfried Nov 29, 2016
aa19274
De-genericize `try_define`.
jseyfried Nov 29, 2016
532b013
Rename `ModuleS` -> `ModuleData`.
jseyfried Nov 26, 2016
4d638fd
Canonicalize lifetime names.
jseyfried Nov 26, 2016
e80d1a8
Remove `MacroDef`'s fields `imported_from` and `allow_internal_unstab…
jseyfried Nov 29, 2016
421c5d1
Remove scope placeholders, remove method `add_macro` of `ext::base::R…
jseyfried Dec 1, 2016
6f040b4
Avoid including attributes in bang macro invocations.
jseyfried Dec 1, 2016
745ddf2
Refactor out `mark.as_placeholder_id()`.
jseyfried Dec 1, 2016
dcae8bf
Give extern crates' root modules a better name.
jseyfried Dec 6, 2016
bd85a6d
target spec: add an asm-args field to pass arguments to the external ..
Dec 19, 2016
5049ad2
From<[u16; 8]> for Ipv6Addr.
clarfonthey Dec 2, 2016
3a82b0d
Don't try get local DefId of imported macro in rustdoc.
michaelwoerister Dec 19, 2016
488359e
travis: Fix the cargotest bot
alexcrichton Dec 19, 2016
cae98ca
travis: Support local sccache if not on bots
alexcrichton Dec 19, 2016
8e61ff2
Optimize `ast::PathSegment`.
jseyfried Dec 10, 2016
51f25b3
resolve: clean up diagnostics for name conflicts.
jseyfried Dec 12, 2016
8d9ba29
Minor bugfix for macro invocation path resolution.
jseyfried Dec 12, 2016
39e6ae2
Clean up `get_traits_containing_item`.
jseyfried Dec 14, 2016
f705c69
Simplify `TyCtxt::create_and_enter`.
jseyfried Dec 15, 2016
2dc2f5f
Bump version to 1.16
brson Dec 19, 2016
0a014c6
Move prefix to [install] section
jackpot51 Dec 19, 2016
228e495
Remove trailing whitespace
jackpot51 Dec 20, 2016
f5e7d92
rustbuild: Update Cargo download location
alexcrichton Dec 19, 2016
e1d8806
Fix closure debuginfo.
ahicks92 Dec 20, 2016
54f75c9
Add regression test for #38458
est31 Dec 20, 2016
73877a0
Find FileCheck using llvm-config
sanxiyn Dec 20, 2016
46d74ea
rustbuild: only plan from build triple for dist
xen0n Dec 19, 2016
8e38b2d
rustbuild: package src only once for build triple
xen0n Dec 19, 2016
57cf2ab
rustbuild: Deny and fix warnings
alexcrichton Dec 20, 2016
49546cc
rustbuild: Actually test musl on the musl bot
alexcrichton Dec 20, 2016
70ef94d
rustbuild: Run debuginfo tests by default
alexcrichton Dec 19, 2016
fe0d092
Indicate that `BTreeSet::iter` returns values in ascending order.
frewsxcv Dec 7, 2016
7fe44f7
Rollup merge of #37761 - christophebiocca:borrow-stdlib-fn-refactor, …
alexcrichton Dec 20, 2016
68dd6fd
Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichton
alexcrichton Dec 20, 2016
65e9691
Rollup merge of #38131 - clarcharr:from_segments, r=alexcrichton
alexcrichton Dec 20, 2016
2fb2d30
Rollup merge of #38150 - estebank:fix-23286, r=nikomatsakis
alexcrichton Dec 20, 2016
58d58c2
Rollup merge of #38158 - sourcefrog:doc-iter, r=GuillaumeGomez
alexcrichton Dec 20, 2016
551cb06
Rollup merge of #38171 - jseyfried:cleanup, r=nrc
alexcrichton Dec 20, 2016
b070feb
Rollup merge of #38208 - frewsxcv:btreesetdocs, r=alexcrichton
alexcrichton Dec 20, 2016
70e1275
Rollup merge of #38215 - liigo:patch-12, r=petrochenkov
alexcrichton Dec 20, 2016
4cfb2b4
Rollup merge of #38236 - GuillaumeGomez:unix_socket_doc, r=frewsxcv
alexcrichton Dec 20, 2016
2f4ca4e
Rollup merge of #38245 - estebank:cast-deref-hint-2, r=nikomatsakis
alexcrichton Dec 20, 2016
dfa9948
Rollup merge of #38289 - bluss:mir-verbose-test-fail, r=michaelwoerister
alexcrichton Dec 20, 2016
a7710ef
Rollup merge of #38315 - jonhoo:better-E0309, r=pnkfelix
alexcrichton Dec 20, 2016
adfafff
Rollup merge of #38346 - GuillaumeGomez:duration_doc, r=frewsxcv
alexcrichton Dec 20, 2016
0874149
Rollup merge of #38388 - redox-os:config_toml_prefix, r=alexcrichton
alexcrichton Dec 20, 2016
55b8660
Rollup merge of #38395 - tshepang:nit, r=steveklabnik
alexcrichton Dec 20, 2016
2104111
Rollup merge of #38398 - ollie27:patch-1, r=alexcrichton
alexcrichton Dec 20, 2016
21f33db
Rollup merge of #38418 - michaelwoerister:def_path_cleanup, r=eddyb
alexcrichton Dec 20, 2016
a8e7f95
Rollup merge of #38432 - stjepang:fix-sort-comment, r=bluss
alexcrichton Dec 20, 2016
60842c1
Rollup merge of #38451 - semarie:openbsd-rustbuild, r=alexcrichton
alexcrichton Dec 20, 2016
cade120
Rollup merge of #38463 - japaric:asm-args, r=alexcrichton
alexcrichton Dec 20, 2016
6e2a901
Rollup merge of #38468 - xen0n:tarball-wrangling, r=alexcrichton
alexcrichton Dec 20, 2016
1509155
Rollup merge of #38470 - alexcrichton:really-fix-osx, r=brson
alexcrichton Dec 20, 2016
da73b4e
Rollup merge of #38471 - alexcrichton:run-debuginfo-tests, r=brson
alexcrichton Dec 20, 2016
6737f1a
Rollup merge of #38472 - alexcrichton:fix-cargotest, r=brson
alexcrichton Dec 20, 2016
802784d
Rollup merge of #38478 - brson:bump, r=alexcrichton
alexcrichton Dec 20, 2016
10bb4a4
Rollup merge of #38486 - est31:master, r=petrochenkov
alexcrichton Dec 20, 2016
c188635
Rollup merge of #38493 - sanxiyn:filecheck, r=alexcrichton
alexcrichton Dec 20, 2016
00fdc0c
Rollup merge of #38498 - alexcrichton:actually-test-musl, r=brson
alexcrichton Dec 20, 2016
7b8cbbe
Merge branch 'rustbuild-warnings' of https://github.com/alexcrichton/…
alexcrichton Dec 20, 2016
6b8dda5
Merge branch 'local-sccache' of https://github.com/alexcrichton/rust …
alexcrichton Dec 20, 2016
5f1ecb0
Merge branch 'fix_closure_debuginfo' of https://github.com/camlorn/ru…
alexcrichton Dec 20, 2016
0cf7d5d
Merge branch 'rfc_1560_warning_cycle' of https://github.com/jseyfried…
alexcrichton Dec 20, 2016
214a6c6
Fix compile errors and such
alexcrichton Dec 20, 2016
d5f1c6e
Merge remote-tracking branch 'origin/master' into rollup
alexcrichton Dec 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up get_traits_containing_item.
  • Loading branch information
jseyfried committed Dec 19, 2016
commit 39e6ae2dccdea270ef70aa7eecdd87252a5c36f2
92 changes: 42 additions & 50 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2863,72 +2863,64 @@ impl<'a> Resolver<'a> {
fn get_traits_containing_item(&mut self, name: Name) -> Vec<TraitCandidate> {
debug!("(getting traits containing item) looking for '{}'", name);

fn add_trait_info(found_traits: &mut Vec<TraitCandidate>,
trait_def_id: DefId,
import_id: Option<NodeId>,
name: Name) {
debug!("(adding trait info) found trait {:?} for method '{}'",
trait_def_id,
name);
found_traits.push(TraitCandidate {
def_id: trait_def_id,
import_id: import_id,
});
}

let mut found_traits = Vec::new();
// Look for the current trait.
if let Some((trait_def_id, _)) = self.current_trait_ref {
if self.trait_item_map.contains_key(&(name, trait_def_id)) {
add_trait_info(&mut found_traits, trait_def_id, None, name);
found_traits.push(TraitCandidate { def_id: trait_def_id, import_id: None });
}
}

let mut search_module = self.current_module;
loop {
// Look for trait children.
let mut search_in_module = |this: &mut Self, module: Module<'a>| {
let mut traits = module.traits.borrow_mut();
if traits.is_none() {
let mut collected_traits = Vec::new();
module.for_each_child(|name, ns, binding| {
if ns != TypeNS { return }
if let Def::Trait(_) = binding.def() {
collected_traits.push((name, binding));
}
});
*traits = Some(collected_traits.into_boxed_slice());
}

for &(trait_name, binding) in traits.as_ref().unwrap().iter() {
let trait_def_id = binding.def().def_id();
if this.trait_item_map.contains_key(&(name, trait_def_id)) {
let mut import_id = None;
if let NameBindingKind::Import { directive, .. } = binding.kind {
let id = directive.id;
this.maybe_unused_trait_imports.insert(id);
this.add_to_glob_map(id, trait_name);
import_id = Some(id);
}
add_trait_info(&mut found_traits, trait_def_id, import_id, name);
}
}
};
search_in_module(self, search_module);
self.get_traits_in_module_containing_item(name, search_module, &mut found_traits);
match search_module.kind {
ModuleKind::Block(..) => search_module = search_module.parent.unwrap(),
_ => break,
}
}

if let ModuleKind::Block(..) = search_module.kind {
search_module = search_module.parent.unwrap();
} else {
if !search_module.no_implicit_prelude {
self.prelude.map(|prelude| search_in_module(self, prelude));
}
break;
if let Some(prelude) = self.prelude {
if !search_module.no_implicit_prelude {
self.get_traits_in_module_containing_item(name, prelude, &mut found_traits);
}
}

found_traits
}

fn get_traits_in_module_containing_item(&mut self,
name: Name,
module: Module,
found_traits: &mut Vec<TraitCandidate>) {
let mut traits = module.traits.borrow_mut();
if traits.is_none() {
let mut collected_traits = Vec::new();
module.for_each_child(|name, ns, binding| {
if ns != TypeNS { return }
if let Def::Trait(_) = binding.def() {
collected_traits.push((name, binding));
}
});
*traits = Some(collected_traits.into_boxed_slice());
}

for &(trait_name, binding) in traits.as_ref().unwrap().iter() {
let trait_def_id = binding.def().def_id();
if self.trait_item_map.contains_key(&(name, trait_def_id)) {
let import_id = match binding.kind {
NameBindingKind::Import { directive, .. } => {
self.maybe_unused_trait_imports.insert(directive.id);
self.add_to_glob_map(directive.id, trait_name);
Some(directive.id)
}
_ => None,
};
found_traits.push(TraitCandidate { def_id: trait_def_id, import_id: import_id });
}
}
}

/// When name resolution fails, this method can be used to look up candidate
/// entities with the expected name. It allows filtering them using the
/// supplied predicate (which should be used to only accept the types of
Expand Down