Skip to content

Commit 404d2e8

Browse files
committed
---
yaml --- r: 136447 b: refs/heads/dist-snap c: 8b88811 h: refs/heads/master i: 136445: b85be0e 136443: 1236525 136439: 2b5d324 136431: f79193e 136415: 3305533 136383: 4f03bca 136319: cdb91a3 136191: bba4f63 v: v3
1 parent 6d34691 commit 404d2e8

File tree

18 files changed

+58
-38
lines changed

18 files changed

+58
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 189b7332968972f34cdbbbd9b62d97ababf53059
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: ef4b92159997093e1fd53a6f8dde377d78d7da4a
9+
refs/heads/dist-snap: 8b88811419f3745a182e9453921101919c609739
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
325325
};
326326
DlDef(def::DefStaticMethod(did, provenance, fn_style))
327327
}
328-
Type | ForeignType => DlDef(def::DefTy(did)),
328+
Type | ForeignType => DlDef(def::DefTy(did, false)),
329329
Mod => DlDef(def::DefMod(did)),
330330
ForeignMod => DlDef(def::DefForeignMod(did)),
331331
StructVariant => {
@@ -337,7 +337,7 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
337337
DlDef(def::DefVariant(enum_did, did, false))
338338
}
339339
Trait => DlDef(def::DefTrait(did)),
340-
Enum => DlDef(def::DefTy(did)),
340+
Enum => DlDef(def::DefTy(did, true)),
341341
Impl => DlImpl(did),
342342
PublicField | InheritedField => DlField,
343343
}

branches/dist-snap/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl tr for def::Def {
454454
def::DefVariant(e_did.tr(dcx), v_did.tr(dcx), is_s)
455455
},
456456
def::DefTrait(did) => def::DefTrait(did.tr(dcx)),
457-
def::DefTy(did) => def::DefTy(did.tr(dcx)),
457+
def::DefTy(did, is_enum) => def::DefTy(did.tr(dcx), is_enum),
458458
def::DefPrimTy(p) => def::DefPrimTy(p),
459459
def::DefTyParam(s, did, v) => def::DefTyParam(s, did.tr(dcx), v),
460460
def::DefBinding(nid, bm) => def::DefBinding(dcx.tr_id(nid), bm),

branches/dist-snap/src/librustc/middle/def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum Def {
2525
DefArg(ast::NodeId, ast::BindingMode),
2626
DefLocal(ast::NodeId, ast::BindingMode),
2727
DefVariant(ast::DefId /* enum */, ast::DefId /* variant */, bool /* is_structure */),
28-
DefTy(ast::DefId),
28+
DefTy(ast::DefId, bool /* is_enum */),
2929
DefTrait(ast::DefId),
3030
DefPrimTy(ast::PrimTy),
3131
DefTyParam(ParamSpace, ast::DefId, uint),
@@ -62,7 +62,7 @@ impl Def {
6262
match *self {
6363
DefFn(id, _) | DefStaticMethod(id, _, _) | DefMod(id) |
6464
DefForeignMod(id) | DefStatic(id, _) |
65-
DefVariant(_, id, _) | DefTy(id) | DefTyParam(_, id, _) |
65+
DefVariant(_, id, _) | DefTy(id, _) | DefTyParam(_, id, _) |
6666
DefUse(id) | DefStruct(id) | DefTrait(id) | DefMethod(id, _) => {
6767
id
6868
}

branches/dist-snap/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
531531
Ok(self.cat_rvalue_node(id, span, expr_ty))
532532
}
533533
def::DefMod(_) | def::DefForeignMod(_) | def::DefUse(_) |
534-
def::DefTrait(_) | def::DefTy(_) | def::DefPrimTy(_) |
534+
def::DefTrait(_) | def::DefTy(..) | def::DefPrimTy(_) |
535535
def::DefTyParam(..) | def::DefTyParamBinder(..) | def::DefRegion(_) |
536536
def::DefLabel(_) | def::DefSelfTy(..) | def::DefMethod(..) => {
537537
Ok(Rc::new(cmt_ {

branches/dist-snap/src/librustc/middle/privacy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
771771
def::DefFn(..) => ck("function"),
772772
def::DefStatic(..) => ck("static"),
773773
def::DefVariant(..) => ck("variant"),
774-
def::DefTy(..) => ck("type"),
774+
def::DefTy(_, false) => ck("type"),
775+
def::DefTy(_, true) => ck("enum"),
775776
def::DefTrait(..) => ck("trait"),
776777
def::DefStruct(..) => ck("struct"),
777778
def::DefMethod(_, Some(..)) => ck("trait method"),

branches/dist-snap/src/librustc/middle/resolve.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ impl<'a> Resolver<'a> {
12521252
sp);
12531253

12541254
name_bindings.define_type
1255-
(DefTy(local_def(item.id)), sp, is_public);
1255+
(DefTy(local_def(item.id), false), sp, is_public);
12561256
parent
12571257
}
12581258

@@ -1264,7 +1264,7 @@ impl<'a> Resolver<'a> {
12641264
sp);
12651265

12661266
name_bindings.define_type
1267-
(DefTy(local_def(item.id)), sp, is_public);
1267+
(DefTy(local_def(item.id), true), sp, is_public);
12681268

12691269
for variant in (*enum_definition).variants.iter() {
12701270
self.build_reduced_graph_for_variant(
@@ -1287,7 +1287,7 @@ impl<'a> Resolver<'a> {
12871287
let name_bindings = self.add_child(ident, parent.clone(), forbid, sp);
12881288

12891289
// Define a name in the type namespace.
1290-
name_bindings.define_type(DefTy(local_def(item.id)), sp, is_public);
1290+
name_bindings.define_type(DefTy(local_def(item.id), false), sp, is_public);
12911291

12921292
// If this is a newtype or unit-like struct, define a name
12931293
// in the value namespace as well
@@ -1732,7 +1732,7 @@ impl<'a> Resolver<'a> {
17321732

17331733
match def {
17341734
DefMod(def_id) | DefForeignMod(def_id) | DefStruct(def_id) |
1735-
DefTy(def_id) => {
1735+
DefTy(def_id, _) => {
17361736
let type_def = child_name_bindings.type_def.borrow().clone();
17371737
match type_def {
17381738
Some(TypeNsDef { module_def: Some(module_def), .. }) => {
@@ -1823,7 +1823,7 @@ impl<'a> Resolver<'a> {
18231823
is_public,
18241824
DUMMY_SP)
18251825
}
1826-
DefTy(_) => {
1826+
DefTy(..) => {
18271827
debug!("(building reduced graph for external \
18281828
crate) building type {}", final_ident);
18291829

@@ -4320,7 +4320,7 @@ impl<'a> Resolver<'a> {
43204320

43214321
// If it's a typedef, give a note
43224322
match def {
4323-
DefTy(_) => {
4323+
DefTy(..) => {
43244324
self.session.span_note(
43254325
trait_reference.path.span,
43264326
format!("`type` aliases cannot \
@@ -4381,7 +4381,7 @@ impl<'a> Resolver<'a> {
43814381
Some(ref t) => match t.node {
43824382
TyPath(ref path, None, path_id) => {
43834383
match this.resolve_path(id, path, TypeNS, true) {
4384-
Some((DefTy(def_id), lp)) if this.structs.contains_key(&def_id) => {
4384+
Some((DefTy(def_id, _), lp)) if this.structs.contains_key(&def_id) => {
43854385
let def = DefStruct(def_id);
43864386
debug!("(resolving struct) resolved `{}` to type {:?}",
43874387
token::get_ident(path.segments
@@ -5440,7 +5440,7 @@ impl<'a> Resolver<'a> {
54405440
if allowed == Everything {
54415441
// Look for a field with the same name in the current self_type.
54425442
match self.def_map.borrow().find(&node_id) {
5443-
Some(&DefTy(did))
5443+
Some(&DefTy(did, _))
54445444
| Some(&DefStruct(did))
54455445
| Some(&DefVariant(_, did, _)) => match self.structs.find(&did) {
54465446
None => {}
@@ -5582,7 +5582,7 @@ impl<'a> Resolver<'a> {
55825582
// structs, which wouldn't result in this error.)
55835583
match self.with_no_errors(|this|
55845584
this.resolve_path(expr.id, path, TypeNS, false)) {
5585-
Some((DefTy(struct_id), _))
5585+
Some((DefTy(struct_id, _), _))
55865586
if self.structs.contains_key(&struct_id) => {
55875587
self.resolve_error(expr.span,
55885588
format!("`{}` is a structure name, but \

branches/dist-snap/src/librustc/middle/save/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
226226
def::DefMod(_) |
227227
def::DefForeignMod(_) => Some(recorder::ModRef),
228228
def::DefStruct(_) => Some(recorder::StructRef),
229-
def::DefTy(_) |
229+
def::DefTy(..) |
230230
def::DefTrait(_) => Some(recorder::TypeRef),
231231
def::DefStatic(_, _) |
232232
def::DefBinding(_, _) |

branches/dist-snap/src/librustc/middle/typeck/astconv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
438438
// FIXME(#12938): This is a hack until we have full support for
439439
// DST.
440440
match a_def {
441-
def::DefTy(did) | def::DefStruct(did)
441+
def::DefTy(did, _) | def::DefStruct(did)
442442
if Some(did) == this.tcx().lang_items.owned_box() => {
443443
if path.segments
444444
.iter()
@@ -462,7 +462,7 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
462462
"not enough type parameters supplied to `Box<T>`");
463463
Some(ty::mk_err())
464464
}
465-
def::DefTy(did) | def::DefStruct(did)
465+
def::DefTy(did, _) | def::DefStruct(did)
466466
if Some(did) == this.tcx().lang_items.gc() => {
467467
if path.segments
468468
.iter()
@@ -833,7 +833,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
833833
result.substs.clone(),
834834
bounds)
835835
}
836-
def::DefTy(did) | def::DefStruct(did) => {
836+
def::DefTy(did, _) | def::DefStruct(did) => {
837837
ast_path_to_ty(this, rscope, did, path).ty
838838
}
839839
def::DefTyParam(space, id, n) => {

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4937,7 +4937,7 @@ pub fn polytype_for_def(fcx: &FnCtxt,
49374937
return polytype_for_def(fcx, sp, *inner);
49384938
}
49394939
def::DefTrait(_) |
4940-
def::DefTy(_) |
4940+
def::DefTy(..) |
49414941
def::DefPrimTy(_) |
49424942
def::DefTyParam(..)=> {
49434943
fcx.ccx.tcx.sess.span_bug(sp, "expected value, found type");

branches/dist-snap/src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12351235
Some(&d) => d
12361236
};
12371237
match a_def {
1238-
def::DefTy(did) | def::DefStruct(did) => {
1238+
def::DefTy(did, _) | def::DefStruct(did) => {
12391239
let generics = ty::lookup_item_type(self.tcx, did).generics;
12401240

12411241
let expected =

branches/dist-snap/src/librustdoc/clean/inline.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
8787
ret.extend(build_impls(cx, tcx, did).into_iter());
8888
clean::StructItem(build_struct(cx, tcx, did))
8989
}
90-
def::DefTy(did) => {
90+
def::DefTy(did, false) => {
91+
record_extern_fqn(cx, did, clean::TypeTypedef);
92+
ret.extend(build_impls(cx, tcx, did).into_iter());
93+
build_type(cx, tcx, did)
94+
}
95+
def::DefTy(did, true) => {
9196
record_extern_fqn(cx, did, clean::TypeEnum);
9297
ret.extend(build_impls(cx, tcx, did).into_iter());
9398
build_type(cx, tcx, did)

branches/dist-snap/src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ pub enum TypeKind {
10941094
TypeStruct,
10951095
TypeTrait,
10961096
TypeVariant,
1097+
TypeTypedef,
10971098
}
10981099

10991100
impl Primitive {
@@ -2049,7 +2050,8 @@ fn resolve_type(cx: &DocContext, path: Path,
20492050
fn register_def(cx: &DocContext, def: def::Def) -> ast::DefId {
20502051
let (did, kind) = match def {
20512052
def::DefFn(i, _) => (i, TypeFunction),
2052-
def::DefTy(i) => (i, TypeEnum),
2053+
def::DefTy(i, false) => (i, TypeTypedef),
2054+
def::DefTy(i, true) => (i, TypeEnum),
20532055
def::DefTrait(i) => (i, TypeTrait),
20542056
def::DefStruct(i) => (i, TypeStruct),
20552057
def::DefMod(i) => (i, TypeModule),

branches/dist-snap/src/librustdoc/html/item_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ItemType {
4545
match *self {
4646
Module => "mod",
4747
Struct => "struct",
48-
Enum => "type",
48+
Enum => "enum",
4949
Function => "fn",
5050
Typedef => "type",
5151
Static => "static",

branches/dist-snap/src/librustdoc/html/render.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) ->
308308
clean::TypeModule => item_type::Module,
309309
clean::TypeStatic => item_type::Static,
310310
clean::TypeVariant => item_type::Variant,
311+
clean::TypeTypedef => item_type::Typedef,
311312
}))
312313
}).collect()
313314
}).unwrap_or(HashMap::new());

branches/dist-snap/src/librustdoc/html/static/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@
555555
// `rustdoc::html::item_type::ItemType` type in Rust.
556556
var itemTypes = ["mod",
557557
"struct",
558-
"type",
558+
"enum",
559559
"fn",
560560
"type",
561561
"static",

branches/dist-snap/src/test/auxiliary/static_priv_by_default.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod foo {
2424
pub fn b() {}
2525
pub struct c;
2626
pub enum d {}
27+
pub type e = int;
2728

2829
pub struct A(());
2930

@@ -36,21 +37,25 @@ mod foo {
3637
pub fn reexported_b() {}
3738
pub struct reexported_c;
3839
pub enum reexported_d {}
40+
pub type reexported_e = int;
3941
}
4042

4143
pub mod bar {
4244
pub use foo::reexported_a as e;
4345
pub use foo::reexported_b as f;
4446
pub use foo::reexported_c as g;
4547
pub use foo::reexported_d as h;
48+
pub use foo::reexported_e as i;
4649
}
4750

4851
pub static a: int = 0;
4952
pub fn b() {}
5053
pub struct c;
5154
pub enum d {}
55+
pub type e = int;
5256

53-
static i: int = 0;
54-
fn j() {}
55-
struct k;
56-
enum l {}
57+
static j: int = 0;
58+
fn k() {}
59+
struct l;
60+
enum m {}
61+
type n = int;

branches/dist-snap/src/test/compile-fail/xcrate-private-by-default.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,26 @@ fn main() {
2020
static_priv_by_default::b;
2121
static_priv_by_default::c;
2222
foo::<static_priv_by_default::d>();
23+
foo::<static_priv_by_default::e>();
2324

2425
// publicly re-exported items should be available
2526
static_priv_by_default::bar::e;
2627
static_priv_by_default::bar::f;
2728
static_priv_by_default::bar::g;
2829
foo::<static_priv_by_default::bar::h>();
30+
foo::<static_priv_by_default::bar::i>();
2931

3032
// private items at the top should be inaccessible
31-
static_priv_by_default::i;
32-
//~^ ERROR: static `i` is private
3333
static_priv_by_default::j;
34-
//~^ ERROR: function `j` is private
34+
//~^ ERROR: static `j` is private
3535
static_priv_by_default::k;
36-
//~^ ERROR: struct `k` is private
37-
foo::<static_priv_by_default::l>();
38-
//~^ ERROR: type `l` is private
36+
//~^ ERROR: function `k` is private
37+
static_priv_by_default::l;
38+
//~^ ERROR: struct `l` is private
39+
foo::<static_priv_by_default::m>();
40+
//~^ ERROR: enum `m` is private
41+
foo::<static_priv_by_default::n>();
42+
//~^ ERROR: type `n` is private
3943

4044
// public items in a private mod should be inaccessible
4145
static_priv_by_default::foo::a;
@@ -45,5 +49,7 @@ fn main() {
4549
static_priv_by_default::foo::c;
4650
//~^ ERROR: struct `c` is private
4751
foo::<static_priv_by_default::foo::d>();
48-
//~^ ERROR: type `d` is private
52+
//~^ ERROR: enum `d` is private
53+
foo::<static_priv_by_default::foo::e>();
54+
//~^ ERROR: type `e` is private
4955
}

0 commit comments

Comments
 (0)