Skip to content

Commit 14d6a10

Browse files
committed
Auto merge of #33752 - mrhota:internal_docs, r=steveklabnik
Internal docs This PR is a rebase of #30621. That PR can be closed. CC @ticki @Aatch @cyplo
2 parents 476fe6e + da55fd7 commit 14d6a10

File tree

4 files changed

+54
-29
lines changed

4 files changed

+54
-29
lines changed

src/librustc/hir/map/blocks.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ struct ClosureParts<'a> {
133133

134134
impl<'a> ClosureParts<'a> {
135135
fn new(d: &'a FnDecl, b: &'a Block, id: NodeId, s: Span, attrs: &'a [Attribute]) -> Self {
136-
ClosureParts { decl: d, body: b, id: id, span: s, attrs: attrs }
136+
ClosureParts {
137+
decl: d,
138+
body: b,
139+
id: id,
140+
span: s,
141+
attrs: attrs,
142+
}
137143
}
138144
}
139145

src/librustc/hir/map/collector.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ use std::iter::repeat;
1919
use syntax::ast::{NodeId, CRATE_NODE_ID};
2020
use syntax::codemap::Span;
2121

22-
/// A Visitor that walks over the HIR and collects Node's into a HIR map.
22+
/// A Visitor that walks over the HIR and collects Nodes into a HIR map
2323
pub struct NodeCollector<'ast> {
24+
/// The crate
2425
pub krate: &'ast Crate,
26+
/// The node map
2527
pub map: Vec<MapEntry<'ast>>,
28+
/// The parent of this node
2629
pub parent_node: NodeId,
2730
}
2831

src/librustc/hir/map/definitions.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use syntax::ast;
1515
use syntax::parse::token::InternedString;
1616
use util::nodemap::NodeMap;
1717

18+
/// The definition table containing node definitions
1819
#[derive(Clone)]
1920
pub struct Definitions {
2021
data: Vec<DefData>,
@@ -139,31 +140,47 @@ pub struct InlinedRootPath {
139140
pub enum DefPathData {
140141
// Root: these should only be used for the root nodes, because
141142
// they are treated specially by the `def_path` function.
143+
/// The crate root (marker)
142144
CrateRoot,
145+
/// An inlined root
143146
InlinedRoot(Box<InlinedRootPath>),
144147

145148
// Catch-all for random DefId things like DUMMY_NODE_ID
146149
Misc,
147150

148151
// Different kinds of items and item-like things:
152+
/// An impl
149153
Impl,
150-
TypeNs(ast::Name), // something in the type NS
151-
ValueNs(ast::Name), // something in the value NS
154+
/// Something in the type NS
155+
TypeNs(ast::Name),
156+
/// Something in the value NS
157+
ValueNs(ast::Name),
158+
/// A module declaration
152159
Module(ast::Name),
160+
/// A macro rule
153161
MacroDef(ast::Name),
162+
/// A closure expression
154163
ClosureExpr,
155164

156165
// Subportions of items
166+
/// A type parameter (generic parameter)
157167
TypeParam(ast::Name),
168+
/// A lifetime definition
158169
LifetimeDef(ast::Name),
170+
/// A variant of a enum
159171
EnumVariant(ast::Name),
172+
/// A struct field
160173
Field(ast::Name),
161-
StructCtor, // implicit ctor for a tuple-like struct
162-
Initializer, // initializer for a const
163-
Binding(ast::Name), // pattern binding
174+
/// Implicit ctor for a tuple-like struct
175+
StructCtor,
176+
/// Initializer for a const
177+
Initializer,
178+
/// Pattern binding
179+
Binding(ast::Name),
164180
}
165181

166182
impl Definitions {
183+
/// Create new empty definition map.
167184
pub fn new() -> Definitions {
168185
Definitions {
169186
data: vec![],
@@ -172,6 +189,7 @@ impl Definitions {
172189
}
173190
}
174191

192+
/// Get the number of definitions.
175193
pub fn len(&self) -> usize {
176194
self.data.len()
177195
}
@@ -214,6 +232,7 @@ impl Definitions {
214232
}
215233
}
216234

235+
/// Add a definition with a parent definition.
217236
pub fn create_def_with_parent(&mut self,
218237
parent: Option<DefIndex>,
219238
node_id: ast::NodeId,

src/librustc_back/sha2.rs

+19-22
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ fn write_u32_be(dst: &mut[u8], input: u32) {
2525

2626
/// Read the value of a vector of bytes as a u32 value in big-endian format.
2727
fn read_u32_be(input: &[u8]) -> u32 {
28-
return
29-
(input[0] as u32) << 24 |
28+
(input[0] as u32) << 24 |
3029
(input[1] as u32) << 16 |
3130
(input[2] as u32) << 8 |
32-
(input[3] as u32);
31+
(input[3] as u32)
3332
}
3433

3534
/// Read a vector of bytes into a vector of u32s. The values are read in big-endian format.
@@ -50,7 +49,7 @@ trait ToBits: Sized {
5049

5150
impl ToBits for u64 {
5251
fn to_bits(self) -> (u64, u64) {
53-
return (self >> 61, self << 3);
52+
(self >> 61, self << 3)
5453
}
5554
}
5655

@@ -64,7 +63,7 @@ fn add_bytes_to_bits(bits: u64, bytes: u64) -> u64 {
6463
}
6564

6665
match bits.checked_add(new_low_bits) {
67-
Some(x) => return x,
66+
Some(x) => x,
6867
None => panic!("numeric overflow occurred.")
6968
}
7069
}
@@ -113,10 +112,10 @@ struct FixedBuffer64 {
113112
impl FixedBuffer64 {
114113
/// Create a new FixedBuffer64
115114
fn new() -> FixedBuffer64 {
116-
return FixedBuffer64 {
115+
FixedBuffer64 {
117116
buffer: [0; 64],
118117
buffer_idx: 0
119-
};
118+
}
120119
}
121120
}
122121

@@ -175,13 +174,13 @@ impl FixedBuffer for FixedBuffer64 {
175174

176175
fn next<'s>(&'s mut self, len: usize) -> &'s mut [u8] {
177176
self.buffer_idx += len;
178-
return &mut self.buffer[self.buffer_idx - len..self.buffer_idx];
177+
&mut self.buffer[self.buffer_idx - len..self.buffer_idx]
179178
}
180179

181180
fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
182181
assert!(self.buffer_idx == 64);
183182
self.buffer_idx = 0;
184-
return &self.buffer[..64];
183+
&self.buffer[..64]
185184
}
186185

187186
fn position(&self) -> usize { self.buffer_idx }
@@ -278,7 +277,7 @@ struct Engine256State {
278277

279278
impl Engine256State {
280279
fn new(h: &[u32; 8]) -> Engine256State {
281-
return Engine256State {
280+
Engine256State {
282281
h0: h[0],
283282
h1: h[1],
284283
h2: h[2],
@@ -287,7 +286,7 @@ impl Engine256State {
287286
h5: h[5],
288287
h6: h[6],
289288
h7: h[7]
290-
};
289+
}
291290
}
292291

293292
fn reset(&mut self, h: &[u32; 8]) {
@@ -433,7 +432,7 @@ struct Engine256 {
433432

434433
impl Engine256 {
435434
fn new(h: &[u32; 8]) -> Engine256 {
436-
return Engine256 {
435+
Engine256 {
437436
length_bits: 0,
438437
buffer: FixedBuffer64::new(),
439438
state: Engine256State::new(h),
@@ -457,17 +456,15 @@ impl Engine256 {
457456
}
458457

459458
fn finish(&mut self) {
460-
if self.finished {
461-
return;
459+
if !self.finished {
460+
let self_state = &mut self.state;
461+
self.buffer.standard_padding(8, |input: &[u8]| { self_state.process_block(input) });
462+
write_u32_be(self.buffer.next(4), (self.length_bits >> 32) as u32 );
463+
write_u32_be(self.buffer.next(4), self.length_bits as u32);
464+
self_state.process_block(self.buffer.full_buffer());
465+
466+
self.finished = true;
462467
}
463-
464-
let self_state = &mut self.state;
465-
self.buffer.standard_padding(8, |input: &[u8]| { self_state.process_block(input) });
466-
write_u32_be(self.buffer.next(4), (self.length_bits >> 32) as u32 );
467-
write_u32_be(self.buffer.next(4), self.length_bits as u32);
468-
self_state.process_block(self.buffer.full_buffer());
469-
470-
self.finished = true;
471468
}
472469
}
473470

0 commit comments

Comments
 (0)