Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b7845f9

Browse files
committedNov 15, 2015
Auto merge of #29387 - little-dude:rustfmt_librustc_resolve, r=nrc
Another rustfmt PR. I ran rustfmt, then split the changes in multiple commits. First commit are the non-problematic changed. The others are all the little weirdness that caught my attention and could be discussed.
2 parents 19abaf8 + 889b0e9 commit b7845f9

File tree

6 files changed

+1220
-1190
lines changed

6 files changed

+1220
-1190
lines changed
 

‎src/librustc_resolve/build_reduced_graph.rs

Lines changed: 267 additions & 256 deletions
Large diffs are not rendered by default.

‎src/librustc_resolve/check_unused.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use rustc_front::hir;
3131
use rustc_front::hir::{ViewPathGlob, ViewPathList, ViewPathSimple};
3232
use rustc_front::visit::{self, Visitor};
3333

34-
struct UnusedImportCheckVisitor<'a, 'b:'a, 'tcx:'b> {
35-
resolver: &'a mut Resolver<'b, 'tcx>
34+
struct UnusedImportCheckVisitor<'a, 'b: 'a, 'tcx: 'b> {
35+
resolver: &'a mut Resolver<'b, 'tcx>,
3636
}
3737

3838
// Deref and DerefMut impls allow treating UnusedImportCheckVisitor as Resolver.
@@ -51,16 +51,16 @@ impl<'a, 'b, 'tcx:'b> DerefMut for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
5151
}
5252

5353
impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
54-
// We have information about whether `use` (import) directives are actually used now.
55-
// If an import is not used at all, we signal a lint error. If an import is only used
56-
// for a single namespace, we remove the other namespace from the recorded privacy
57-
// information. That means in privacy.rs, we will only check imports and namespaces
58-
// which are used. In particular, this means that if an import could name either a
59-
// public or private item, we will check the correct thing, dependent on how the import
60-
// is used.
54+
// We have information about whether `use` (import) directives are actually
55+
// used now. If an import is not used at all, we signal a lint error. If an
56+
// import is only used for a single namespace, we remove the other namespace
57+
// from the recorded privacy information. That means in privacy.rs, we will
58+
// only check imports and namespaces which are used. In particular, this
59+
// means that if an import could name either a public or private item, we
60+
// will check the correct thing, dependent on how the import is used.
6161
fn finalize_import(&mut self, id: ast::NodeId, span: Span) {
6262
debug!("finalizing import uses for {:?}",
63-
self.session.codemap().span_to_snippet(span));
63+
self.session.codemap().span_to_snippet(span));
6464

6565
if !self.used_imports.contains(&(id, TypeNS)) &&
6666
!self.used_imports.contains(&(id, ValueNS)) {
@@ -99,14 +99,14 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
9999
// we might have two LastPrivates pointing at the same thing. There is no point
100100
// checking both, so lets not check the value one.
101101
(Some(DependsOn(def_v)), Some(DependsOn(def_t))) if def_v == def_t => v_used = Unused,
102-
_ => {},
102+
_ => {}
103103
}
104104

105105
path_res.last_private = LastImport {
106106
value_priv: v_priv,
107107
value_used: v_used,
108108
type_priv: t_priv,
109-
type_used: t_used
109+
type_used: t_used,
110110
};
111111
}
112112
}
@@ -132,7 +132,7 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
132132
"unused extern crate".to_string());
133133
}
134134
}
135-
},
135+
}
136136
hir::ItemUse(ref p) => {
137137
match p.node {
138138
ViewPathSimple(_, _) => {

‎src/librustc_resolve/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
#![allow(non_snake_case)]
1212

13-
// Error messages for EXXXX errors.
14-
// Each message should start and end with a new line, and be wrapped to 80 characters.
15-
// In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
13+
// Error messages for EXXXX errors. Each message should start and end with a
14+
// new line, and be wrapped to 80 characters. In vim you can `:set tw=80` and
15+
// use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
1616
register_long_diagnostics! {
1717

1818
E0154: r##"

‎src/librustc_resolve/lib.rs

Lines changed: 748 additions & 716 deletions
Large diffs are not rendered by default.

‎src/librustc_resolve/record_exports.rs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use syntax::ast;
3030
use std::ops::{Deref, DerefMut};
3131
use std::rc::Rc;
3232

33-
struct ExportRecorder<'a, 'b:'a, 'tcx:'b> {
34-
resolver: &'a mut Resolver<'b, 'tcx>
33+
struct ExportRecorder<'a, 'b: 'a, 'tcx: 'b> {
34+
resolver: &'a mut Resolver<'b, 'tcx>,
3535
}
3636

3737
// Deref and DerefMut impls allow treating ExportRecorder as Resolver.
@@ -50,28 +50,26 @@ impl<'a, 'b, 'tcx:'b> DerefMut for ExportRecorder<'a, 'b, 'tcx> {
5050
}
5151

5252
impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
53-
fn record_exports_for_module_subtree(&mut self,
54-
module_: Rc<Module>) {
53+
fn record_exports_for_module_subtree(&mut self, module_: Rc<Module>) {
5554
// If this isn't a local krate, then bail out. We don't need to record
5655
// exports for nonlocal crates.
5756

5857
match module_.def_id.get() {
5958
Some(def_id) if def_id.is_local() => {
6059
// OK. Continue.
61-
debug!("(recording exports for module subtree) recording \
62-
exports for local module `{}`",
60+
debug!("(recording exports for module subtree) recording exports for local \
61+
module `{}`",
6362
module_to_string(&*module_));
6463
}
6564
None => {
6665
// Record exports for the root module.
67-
debug!("(recording exports for module subtree) recording \
68-
exports for root module `{}`",
66+
debug!("(recording exports for module subtree) recording exports for root module \
67+
`{}`",
6968
module_to_string(&*module_));
7069
}
7170
Some(_) => {
7271
// Bail out.
73-
debug!("(recording exports for module subtree) not recording \
74-
exports for `{}`",
72+
debug!("(recording exports for module subtree) not recording exports for `{}`",
7573
module_to_string(&*module_));
7674
return;
7775
}
@@ -118,10 +116,11 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
118116
match namebindings.def_for_namespace(ns) {
119117
Some(d) => {
120118
debug!("(computing exports) YES: export '{}' => {:?}",
121-
name, d.def_id());
119+
name,
120+
d.def_id());
122121
exports.push(Export {
123122
name: name,
124-
def_id: d.def_id()
123+
def_id: d.def_id(),
125124
});
126125
}
127126
d_opt => {
@@ -130,25 +129,19 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
130129
}
131130
}
132131

133-
fn add_exports_for_module(&mut self,
134-
exports: &mut Vec<Export>,
135-
module_: &Module) {
132+
fn add_exports_for_module(&mut self, exports: &mut Vec<Export>, module_: &Module) {
136133
for (name, import_resolution) in module_.import_resolutions.borrow().iter() {
137134
if !import_resolution.is_public {
138-
continue
135+
continue;
139136
}
140137
let xs = [TypeNS, ValueNS];
141138
for &ns in &xs {
142139
match import_resolution.target_for_namespace(ns) {
143140
Some(target) => {
144-
debug!("(computing exports) maybe export '{}'",
145-
name);
146-
self.add_exports_of_namebindings(exports,
147-
*name,
148-
&*target.bindings,
149-
ns)
141+
debug!("(computing exports) maybe export '{}'", name);
142+
self.add_exports_of_namebindings(exports, *name, &*target.bindings, ns)
150143
}
151-
_ => ()
144+
_ => (),
152145
}
153146
}
154147
}

‎src/librustc_resolve/resolve_imports.rs

Lines changed: 173 additions & 179 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.