Skip to content

Commit 880808f

Browse files
committed
---
yaml --- r: 123667 b: refs/heads/try c: a0cfda5 h: refs/heads/master i: 123665: a8c7170 123663: 7c9ab9a v: v3
1 parent 289feb3 commit 880808f

File tree

36 files changed

+222
-234
lines changed

36 files changed

+222
-234
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: da4e4e4e0a7778a85748aa4a303b13f603e96b4b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8ddd286ea4ba4384a0dc9eae393ed515460a986e
5-
refs/heads/try: bfe4ddfdea45533c98657701509bb7185fd96cba
5+
refs/heads/try: a0cfda53c4b7367f6494e3d746b35cea644ee50d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ endif
171171
# Main test targets
172172
######################################################################
173173

174-
check: cleantmptestlogs cleantestlibs check-notidy tidy
174+
check: cleantmptestlogs cleantestlibs tidy check-notidy
175175

176176
check-notidy: cleantmptestlogs cleantestlibs all check-stage2
177177
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

branches/try/src/librustc/driver/driver.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -903,21 +903,10 @@ pub fn build_output_filenames(input: &Input,
903903
};
904904

905905
// If a crate name is present, we use it as the link name
906-
let stem = sess.opts.crate_name.clone().or_else(|| {
907-
attr::find_crate_name(attrs).map(|n| n.get().to_string())
908-
}).or_else(|| {
909-
// NB: this clause can be removed once #[crate_id] is no longer
910-
// deprecated.
911-
//
912-
// Also note that this will be warned about later so we don't
913-
// warn about it here.
914-
use syntax::crateid::CrateId;
915-
attrs.iter().find(|at| at.check_name("crate_id"))
916-
.and_then(|at| at.value_str())
917-
.and_then(|s| from_str::<CrateId>(s.get()))
918-
.map(|id| id.name)
919-
}).unwrap_or(input.filestem());
920-
906+
let stem = match attr::find_crate_name(attrs) {
907+
None => input.filestem(),
908+
Some(name) => name.get().to_string(),
909+
};
921910
OutputFilenames {
922911
out_directory: dirpath,
923912
out_filestem: stem,

branches/try/src/librustc/front/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
109109
.map(|x| *x).collect();
110110
ast::ItemImpl((*a).clone(), (*b).clone(), c, methods)
111111
}
112-
ast::ItemTrait(ref a, b, ref c, ref methods) => {
112+
ast::ItemTrait(ref a, ref b, ref c, ref methods) => {
113113
let methods = methods.iter()
114114
.filter(|m| trait_method_in_cfg(cx, *m) )
115115
.map(|x| (*x).clone())
116116
.collect();
117-
ast::ItemTrait((*a).clone(), b, (*c).clone(), methods)
117+
ast::ItemTrait((*a).clone(), (*b).clone(), (*c).clone(), methods)
118118
}
119119
ast::ItemStruct(ref def, ref generics) => {
120120
ast::ItemStruct(fold_struct(cx, &**def), generics.clone())

branches/try/src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,12 @@ impl LintPass for UnusedAttribute {
575575
];
576576

577577
static CRATE_ATTRS: &'static [&'static str] = &[
578-
"crate_name",
579578
"crate_type",
580579
"feature",
581580
"no_start",
582581
"no_main",
583582
"no_std",
583+
"crate_id",
584584
"desc",
585585
"comment",
586586
"license",

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,6 @@ fn item_visibility(item: ebml::Doc) -> ast::Visibility {
164164
}
165165
}
166166

167-
fn item_sized(item: ebml::Doc) -> ast::Sized {
168-
match reader::maybe_get_doc(item, tag_items_data_item_sized) {
169-
None => ast::StaticSize,
170-
Some(sized_doc) => {
171-
match reader::doc_as_u8(sized_doc) as char {
172-
'd' => ast::DynSize,
173-
's' => ast::StaticSize,
174-
_ => fail!("unknown sized-ness character")
175-
}
176-
}
177-
}
178-
}
179-
180167
fn item_method_sort(item: ebml::Doc) -> char {
181168
let mut ret = 'r';
182169
reader::tagged_docs(item, tag_item_trait_method_sort, |doc| {
@@ -393,7 +380,6 @@ pub fn get_trait_def(cdata: Cmd,
393380
let tp_defs = item_ty_param_defs(item_doc, tcx, cdata,
394381
tag_items_data_item_ty_param_bounds);
395382
let rp_defs = item_region_param_defs(item_doc, cdata);
396-
let sized = item_sized(item_doc);
397383
let mut bounds = ty::empty_builtin_bounds();
398384
// Collect the builtin bounds from the encoded supertraits.
399385
// FIXME(#8559): They should be encoded directly.
@@ -405,12 +391,6 @@ pub fn get_trait_def(cdata: Cmd,
405391
});
406392
true
407393
});
408-
// Turn sized into a bound, FIXME(#8559).
409-
if sized == ast::StaticSize {
410-
tcx.lang_items.to_builtin_kind(tcx.lang_items.sized_trait().unwrap()).map(|bound| {
411-
bounds.add(bound);
412-
});
413-
}
414394

415395
ty::TraitDef {
416396
generics: ty::Generics {types: tp_defs,

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -881,16 +881,6 @@ fn encode_extension_implementations(ecx: &EncodeContext,
881881
}
882882
}
883883

884-
fn encode_sized(ebml_w: &mut Encoder, sized: Sized) {
885-
ebml_w.start_tag(tag_items_data_item_sized);
886-
let ch = match sized {
887-
DynSize => 'd',
888-
StaticSize => 's',
889-
};
890-
ebml_w.wr_str(str::from_char(ch).as_slice());
891-
ebml_w.end_tag();
892-
}
893-
894884
fn encode_stability(ebml_w: &mut Encoder, stab_opt: Option<attr::Stability>) {
895885
stab_opt.map(|stab| {
896886
ebml_w.start_tag(tag_items_data_item_stability);
@@ -1149,7 +1139,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
11491139
ast_method)
11501140
}
11511141
}
1152-
ItemTrait(_, sized, ref super_traits, ref ms) => {
1142+
ItemTrait(_, _, ref super_traits, ref ms) => {
11531143
add_to_index(item, ebml_w, index);
11541144
ebml_w.start_tag(tag_items_data_item);
11551145
encode_def_id(ebml_w, def_id);
@@ -1163,9 +1153,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
11631153
encode_trait_ref(ebml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
11641154
encode_name(ebml_w, item.ident.name);
11651155
encode_attributes(ebml_w, item.attrs.as_slice());
1166-
// When we fix the rest of the supertrait nastiness (FIXME(#8559)), we
1167-
// should no longer need this ugly little hack either.
1168-
encode_sized(ebml_w, sized);
11691156
encode_visibility(ebml_w, vis);
11701157
encode_stability(ebml_w, stab);
11711158
for &method_def_id in ty::trait_method_def_ids(tcx, def_id).iter() {

branches/try/src/librustc/middle/resolve.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,7 @@ impl<'a> Resolver<'a> {
35983598
item.id,
35993599
ItemRibKind),
36003600
|this| {
3601+
this.resolve_type_parameters(&generics.ty_params);
36013602
visit::walk_item(this, item, ());
36023603
});
36033604
}
@@ -3623,7 +3624,7 @@ impl<'a> Resolver<'a> {
36233624
methods.as_slice());
36243625
}
36253626

3626-
ItemTrait(ref generics, _, ref traits, ref methods) => {
3627+
ItemTrait(ref generics, ref unbound, ref traits, ref methods) => {
36273628
// Create a new rib for the self type.
36283629
let self_type_rib = Rib::new(ItemRibKind);
36293630

@@ -3645,6 +3646,12 @@ impl<'a> Resolver<'a> {
36453646
for trt in traits.iter() {
36463647
this.resolve_trait_reference(item.id, trt, TraitDerivation);
36473648
}
3649+
match unbound {
3650+
&Some(ast::TraitTyParamBound(ref tpb)) => {
3651+
this.resolve_trait_reference(item.id, tpb, TraitDerivation);
3652+
}
3653+
_ => {}
3654+
}
36483655

36493656
for method in (*methods).iter() {
36503657
// Create a new rib for the method-specific type
@@ -3856,11 +3863,15 @@ impl<'a> Resolver<'a> {
38563863
}
38573864

38583865
fn resolve_type_parameters(&mut self,
3859-
type_parameters: &OwnedSlice<TyParam>) {
3866+
type_parameters: &OwnedSlice<TyParam>) {
38603867
for type_parameter in type_parameters.iter() {
38613868
for bound in type_parameter.bounds.iter() {
38623869
self.resolve_type_parameter_bound(type_parameter.id, bound);
38633870
}
3871+
match &type_parameter.unbound {
3872+
&Some(ref unbound) => self.resolve_type_parameter_bound(type_parameter.id, unbound),
3873+
&None => {}
3874+
}
38643875
match type_parameter.default {
38653876
Some(ref ty) => self.resolve_type(&**ty),
38663877
None => {}
@@ -3887,9 +3898,9 @@ impl<'a> Resolver<'a> {
38873898
}
38883899

38893900
fn resolve_trait_reference(&mut self,
3890-
id: NodeId,
3891-
trait_reference: &TraitRef,
3892-
reference_type: TraitReferenceType) {
3901+
id: NodeId,
3902+
trait_reference: &TraitRef,
3903+
reference_type: TraitReferenceType) {
38933904
match self.resolve_path(id, &trait_reference.path, TypeNS, true) {
38943905
None => {
38953906
let path_str = self.path_idents_to_str(&trait_reference.path);

branches/try/src/librustc/middle/typeck/collect.rs

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
692692
_ => {}
693693
}
694694

695-
let (generics, sized, supertraits) = match it.node {
696-
ast::ItemTrait(ref generics, sized, ref supertraits, _) => {
697-
(generics, sized, supertraits)
695+
let (generics, unbound, supertraits) = match it.node {
696+
ast::ItemTrait(ref generics, ref unbound, ref supertraits, _) => {
697+
(generics, unbound, supertraits)
698698
}
699699
ref s => {
700700
tcx.sess.span_bug(
@@ -711,7 +711,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
711711
generics);
712712

713713
let builtin_bounds =
714-
ensure_supertraits(ccx, it.id, it.span, supertraits, sized);
714+
ensure_supertraits(ccx, it.id, it.span, supertraits, unbound);
715715

716716
let substs = mk_item_substs(ccx, &ty_generics);
717717
let trait_def = Rc::new(ty::TraitDef {
@@ -759,7 +759,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
759759
id: ast::NodeId,
760760
sp: codemap::Span,
761761
ast_trait_refs: &Vec<ast::TraitRef>,
762-
sized: ast::Sized)
762+
unbound: &Option<ast::TyParamBound>)
763763
-> ty::BuiltinBounds
764764
{
765765
let tcx = ccx.tcx;
@@ -798,15 +798,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
798798
}
799799
}
800800

801-
if sized == ast::StaticSize {
802-
match tcx.lang_items.require(SizedTraitLangItem) {
803-
Ok(def_id) => {
804-
ty::try_add_builtin_trait(tcx, def_id, &mut bounds);
805-
}
806-
Err(s) => tcx.sess.err(s.as_slice()),
807-
};
808-
}
809-
801+
add_unsized_bound(ccx, unbound, &mut bounds, "trait", sp);
810802
tcx.supertraits.borrow_mut().insert(local_def(id),
811803
Rc::new(ty_trait_refs));
812804
bounds
@@ -974,6 +966,43 @@ fn ty_generics_for_fn_or_method(ccx: &CrateCtxt,
974966
&generics.ty_params, base_generics)
975967
}
976968

969+
// Add the Sized bound, unless the type parameter is marked as `Sized?`.
970+
fn add_unsized_bound(ccx: &CrateCtxt,
971+
unbound: &Option<ast::TyParamBound>,
972+
bounds: &mut ty::BuiltinBounds,
973+
desc: &str,
974+
span: Span) {
975+
let kind_id = ccx.tcx.lang_items.require(SizedTraitLangItem);
976+
match unbound {
977+
&Some(TraitTyParamBound(ref tpb)) => {
978+
// #FIXME(8559) currently requires the unbound to be built-in.
979+
let trait_def_id = ty::trait_ref_to_def_id(ccx.tcx, tpb);
980+
match kind_id {
981+
Ok(kind_id) if trait_def_id != kind_id => {
982+
ccx.tcx.sess.span_warn(span,
983+
format!("default bound relaxed \
984+
for a {}, but this does \
985+
nothing because the given \
986+
bound is not a default. \
987+
Only `Sized?` is supported.",
988+
desc).as_slice());
989+
ty::try_add_builtin_trait(ccx.tcx,
990+
kind_id,
991+
bounds);
992+
}
993+
_ => {}
994+
}
995+
}
996+
_ if kind_id.is_ok() => {
997+
ty::try_add_builtin_trait(ccx.tcx,
998+
kind_id.unwrap(),
999+
bounds);
1000+
}
1001+
// No lang item for Sized, so we can't add it as a bound.
1002+
_ => {}
1003+
}
1004+
}
1005+
9771006
fn ty_generics(ccx: &CrateCtxt,
9781007
space: subst::ParamSpace,
9791008
lifetimes: &Vec<ast::Lifetime>,
@@ -1016,7 +1045,7 @@ fn ty_generics(ccx: &CrateCtxt,
10161045
let bounds = Rc::new(compute_bounds(ccx,
10171046
param_ty,
10181047
&param.bounds,
1019-
param.sized,
1048+
&param.unbound,
10201049
param.ident,
10211050
param.span));
10221051
let default = param.default.map(|path| {
@@ -1056,7 +1085,7 @@ fn ty_generics(ccx: &CrateCtxt,
10561085
ccx: &CrateCtxt,
10571086
param_ty: ty::ParamTy,
10581087
ast_bounds: &OwnedSlice<ast::TyParamBound>,
1059-
sized: ast::Sized,
1088+
unbound: &Option<ast::TyParamBound>,
10601089
ident: ast::Ident,
10611090
span: Span) -> ty::ParamBounds
10621091
{
@@ -1113,15 +1142,11 @@ fn ty_generics(ccx: &CrateCtxt,
11131142
}
11141143
}
11151144

1116-
if sized == ast::StaticSize {
1117-
match ccx.tcx.lang_items.require(SizedTraitLangItem) {
1118-
Ok(def_id) => { ty::try_add_builtin_trait(ccx.tcx,
1119-
def_id,
1120-
&mut param_bounds.builtin_bounds); },
1121-
// Fixme(13367) after `type` makes it into the snapshot, we can check this properly
1122-
Err(_s) => {}, //ccx.tcx.sess.err(s),
1123-
}
1124-
}
1145+
add_unsized_bound(ccx,
1146+
unbound,
1147+
&mut param_bounds.builtin_bounds,
1148+
"type parameter",
1149+
span);
11251150

11261151
check_bounds_compatible(ccx.tcx, &param_bounds, ident, span);
11271152

branches/try/src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,9 @@ impl<'a> Rebuilder<'a> {
895895
ident: ty_param.ident,
896896
id: ty_param.id,
897897
bounds: bounds,
898+
unbound: ty_param.unbound.clone(),
898899
default: ty_param.default,
899900
span: ty_param.span,
900-
sized: ty_param.sized,
901901
}
902902
})
903903
}

branches/try/src/librustdoc/html/highlight.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
110110
// miscellaneous, no highlighting
111111
t::DOT | t::DOTDOT | t::DOTDOTDOT | t::COMMA | t::SEMI |
112112
t::COLON | t::MOD_SEP | t::LARROW | t::LPAREN |
113-
t::RPAREN | t::LBRACKET | t::LBRACE | t::RBRACE => "",
113+
t::RPAREN | t::LBRACKET | t::LBRACE | t::RBRACE | t::QUESTION => "",
114114
t::DOLLAR => {
115115
if t::is_ident(&lexer.peek().tok) {
116116
is_macro_nonterminal = true;

branches/try/src/libsyntax/ast.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ pub enum TyParamBound {
184184
pub struct TyParam {
185185
pub ident: Ident,
186186
pub id: NodeId,
187-
pub sized: Sized,
188187
pub bounds: OwnedSlice<TyParamBound>,
188+
pub unbound: Option<TyParamBound>,
189189
pub default: Option<P<Ty>>,
190190
pub span: Span
191191
}
@@ -1041,12 +1041,6 @@ impl Visibility {
10411041
}
10421042
}
10431043

1044-
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
1045-
pub enum Sized {
1046-
DynSize,
1047-
StaticSize,
1048-
}
1049-
10501044
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
10511045
pub struct StructField_ {
10521046
pub kind: StructFieldKind,
@@ -1115,7 +1109,11 @@ pub enum Item_ {
11151109
ItemEnum(EnumDef, Generics),
11161110
ItemStruct(Gc<StructDef>, Generics),
11171111
/// Represents a Trait Declaration
1118-
ItemTrait(Generics, Sized, Vec<TraitRef> , Vec<TraitMethod> ),
1112+
ItemTrait(Generics,
1113+
Option<TyParamBound>, // (optional) default bound not required for Self.
1114+
// Currently, only Sized makes sense here.
1115+
Vec<TraitRef> ,
1116+
Vec<TraitMethod>),
11191117
ItemImpl(Generics,
11201118
Option<TraitRef>, // (optional) trait this impl implements
11211119
P<Ty>, // self

0 commit comments

Comments
 (0)