Skip to content

Commit 7555e70

Browse files
committed
comments
1 parent 7ca560d commit 7555e70

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ pub struct CrateData {
4242
pub number: u32,
4343
}
4444

45-
// Data for any entity in the Rust language. The actual data contained varied
46-
// with the kind of entity being queried. See the nested structs for details.
45+
/// Data for any entity in the Rust language. The actual data contained varied
46+
/// with the kind of entity being queried. See the nested structs for details.
4747
pub enum Data {
48+
/// Data for all kinds of functions and methods.
4849
FunctionData(FunctionData),
50+
/// Data for local and global variables (consts and statics).
4951
VariableData(VariableData),
5052
}
5153

54+
/// Data for all kinds of functions and methods.
5255
pub struct FunctionData {
5356
pub id: NodeId,
5457
pub name: String,
@@ -58,6 +61,7 @@ pub struct FunctionData {
5861
pub scope: NodeId,
5962
}
6063

64+
/// Data for local and global variables (consts and statics).
6165
pub struct VariableData {
6266
pub id: NodeId,
6367
pub name: String,

src/librustc_trans/save/span_utils.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ impl<'a> SpanUtils<'a> {
230230
// Reparse span and return an owned vector of sub spans of the first limit
231231
// identifier tokens in the given nesting level.
232232
// example with Foo<Bar<T,V>, Bar<T,V>>
233-
// Nesting = 0: all idents outside of brackets: Vec<Foo>
234-
// Nesting = 1: idents within one level of brackets: Vec<Bar, Bar>
233+
// Nesting = 0: all idents outside of brackets: [Foo]
234+
// Nesting = 1: idents within one level of brackets: [Bar, Bar]
235235
pub fn spans_with_brackets(&self, span: Span, nesting: isize, limit: isize) -> Vec<Span> {
236236
let mut result: Vec<Span> = vec!();
237237

@@ -260,10 +260,20 @@ impl<'a> SpanUtils<'a> {
260260
token::BinOp(token::Shr) => -2,
261261
_ => 0
262262
};
263+
263264
// Ignore the `>::` in `<Type as Trait>::AssocTy`.
265+
266+
// The root cause of this hack is that the AST representation of
267+
// qpaths is horrible. It treats <A as B>::C as a path with two
268+
// segments, B and C and notes that there is also a self type A at
269+
// position 0. Because we don't have spans for individual idents,
270+
// only the whole path, we have to iterate over the tokens in the
271+
// path, trying to pull out the non-nested idents (e.g., avoiding 'a
272+
// in `<A as B<'a>>::C`). So we end up with a span for `B>::C` from
273+
// the start of the first ident to the end of the path.
264274
if !found_ufcs_sep && bracket_count == -1 {
265275
found_ufcs_sep = true;
266-
bracket_count += 1
276+
bracket_count += 1;
267277
}
268278
if ts.tok.is_ident() && bracket_count == nesting {
269279
result.push(self.make_sub_span(span, Some(ts.sp)).unwrap());
@@ -332,7 +342,7 @@ impl<'a> SpanUtils<'a> {
332342
}
333343

334344

335-
// Returns a list of the spans of idents in a patch.
345+
// Returns a list of the spans of idents in a path.
336346
// E.g., For foo::bar<x,t>::baz, we return [foo, bar, baz] (well, their spans)
337347
pub fn spans_for_path_segments(&self, path: &ast::Path) -> Vec<Span> {
338348
if generated_code(path.span) {

0 commit comments

Comments
 (0)