Skip to content

Commit ae9f097

Browse files
committed
---
yaml --- r: 111007 b: refs/heads/snap-stage3 c: 246ebd2 h: refs/heads/master i: 111005: 24d5ebb 111003: d7cda17 110999: 9f35011 110991: 99aab35 110975: 1b7bc4a v: v3
1 parent 4290efa commit ae9f097

File tree

9 files changed

+266
-89
lines changed

9 files changed

+266
-89
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 296e60be6b027a52de58251848037a92f23a0878
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 713e87526eac42aa9879e7cfb556ea64d63e7a91
4+
refs/heads/snap-stage3: 246ebd2d5aebc68a581c33c33cbce5f2bc7dc7d6
55
refs/heads/try: 38201d7c6bf0c32b0e5bdc8ecd63976ebc1b3a4c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/typeck/check/vtable.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,17 @@ fn lookup_vtable(vcx: &VtableContext,
242242
// bounds to see if they include the trait we are looking for.
243243
let vtable_opt = match ty::get(ty).sty {
244244
ty::ty_param(param_ty {idx: n, ..}) => {
245-
let type_param_bounds: &[@ty::TraitRef] =
246-
vcx.param_env
247-
.type_param_bounds
248-
.get(n)
249-
.trait_bounds
250-
.as_slice();
251-
lookup_vtable_from_bounds(vcx, span,
252-
type_param_bounds,
253-
param_numbered(n),
254-
trait_ref)
245+
let env_bounds = &vcx.param_env.type_param_bounds;
246+
if env_bounds.len() > n {
247+
let type_param_bounds: &[@ty::TraitRef] =
248+
env_bounds.get(n).trait_bounds.as_slice();
249+
lookup_vtable_from_bounds(vcx, span,
250+
type_param_bounds,
251+
param_numbered(n),
252+
trait_ref)
253+
} else {
254+
None
255+
}
255256
}
256257

257258
ty::ty_self(_) => {

branches/snap-stage3/src/librustc/util/ppaux.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
365365
ty_param(param_ty {idx: id, def_id: did}) => {
366366
let ident = match cx.ty_param_defs.borrow().find(&did.node) {
367367
Some(def) => token::get_ident(def.ident).get().to_str(),
368-
// This should not happen...
369-
None => format!("BUG[{:?}]", id)
368+
// This can only happen when a type mismatch error happens and
369+
// the actual type has more type parameters than the expected one.
370+
None => format!("<generic \\#{}>", id)
370371
};
371372
if !cx.sess.verbose() {
372373
ident

branches/snap-stage3/src/librustdoc/html/format.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -24,6 +24,8 @@ use syntax::ast;
2424
use syntax::ast_util;
2525

2626
use clean;
27+
use html::item_type;
28+
use html::item_type::ItemType;
2729
use html::render;
2830
use html::render::{cache_key, current_location_key};
2931

@@ -172,17 +174,17 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
172174
},
173175
|_cache| {
174176
Some((Vec::from_slice(fqn), match kind {
175-
clean::TypeStruct => "struct",
176-
clean::TypeEnum => "enum",
177-
clean::TypeFunction => "fn",
178-
clean::TypeTrait => "trait",
177+
clean::TypeStruct => item_type::Struct,
178+
clean::TypeEnum => item_type::Enum,
179+
clean::TypeFunction => item_type::Function,
180+
clean::TypeTrait => item_type::Trait,
179181
}))
180182
})
181183
}
182184

183185
fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
184186
root: |&render::Cache, &[~str]| -> Option<~str>,
185-
info: |&render::Cache| -> Option<(Vec<~str> , &'static str)>)
187+
info: |&render::Cache| -> Option<(Vec<~str> , ItemType)>)
186188
-> fmt::Result
187189
{
188190
// The generics will get written to both the title and link
@@ -252,12 +254,12 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
252254
url.push_str("/");
253255
}
254256
match shortty {
255-
"mod" => {
257+
item_type::Module => {
256258
url.push_str(*fqp.last().unwrap());
257259
url.push_str("/index.html");
258260
}
259261
_ => {
260-
url.push_str(shortty);
262+
url.push_str(shortty.to_static_str());
261263
url.push_str(".");
262264
url.push_str(*fqp.last().unwrap());
263265
url.push_str(".html");
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Item types.
12+
13+
use std::fmt;
14+
use clean;
15+
16+
/// Item type. Corresponds to `clean::ItemEnum` variants.
17+
///
18+
/// The search index uses item types encoded as smaller numbers which equal to
19+
/// discriminants. JavaScript then is used to decode them into the original value.
20+
/// Consequently, every change to this type should be synchronized to
21+
/// the `itemTypes` mapping table in `static/main.js`.
22+
#[deriving(Eq, Clone)]
23+
pub enum ItemType {
24+
Module = 0,
25+
Struct = 1,
26+
Enum = 2,
27+
Function = 3,
28+
Typedef = 4,
29+
Static = 5,
30+
Trait = 6,
31+
Impl = 7,
32+
ViewItem = 8,
33+
TyMethod = 9,
34+
Method = 10,
35+
StructField = 11,
36+
Variant = 12,
37+
ForeignFunction = 13,
38+
ForeignStatic = 14,
39+
Macro = 15,
40+
}
41+
42+
impl ItemType {
43+
pub fn to_static_str(&self) -> &'static str {
44+
match *self {
45+
Module => "mod",
46+
Struct => "struct",
47+
Enum => "enum",
48+
Function => "fn",
49+
Typedef => "typedef",
50+
Static => "static",
51+
Trait => "trait",
52+
Impl => "impl",
53+
ViewItem => "viewitem",
54+
TyMethod => "tymethod",
55+
Method => "method",
56+
StructField => "structfield",
57+
Variant => "variant",
58+
ForeignFunction => "ffi",
59+
ForeignStatic => "ffs",
60+
Macro => "macro",
61+
}
62+
}
63+
}
64+
65+
impl fmt::Show for ItemType {
66+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
67+
self.to_static_str().fmt(f)
68+
}
69+
}
70+
71+
impl fmt::Unsigned for ItemType {
72+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
73+
(*self as uint).fmt(f)
74+
}
75+
}
76+
77+
pub fn shortty(item: &clean::Item) -> ItemType {
78+
match item.inner {
79+
clean::ModuleItem(..) => Module,
80+
clean::StructItem(..) => Struct,
81+
clean::EnumItem(..) => Enum,
82+
clean::FunctionItem(..) => Function,
83+
clean::TypedefItem(..) => Typedef,
84+
clean::StaticItem(..) => Static,
85+
clean::TraitItem(..) => Trait,
86+
clean::ImplItem(..) => Impl,
87+
clean::ViewItemItem(..) => ViewItem,
88+
clean::TyMethodItem(..) => TyMethod,
89+
clean::MethodItem(..) => Method,
90+
clean::StructFieldItem(..) => StructField,
91+
clean::VariantItem(..) => Variant,
92+
clean::ForeignFunctionItem(..) => ForeignFunction,
93+
clean::ForeignStaticItem(..) => ForeignStatic,
94+
clean::MacroItem(..) => Macro,
95+
}
96+
}
97+

0 commit comments

Comments
 (0)