Skip to content

Commit 94c8b93

Browse files
committed
---
yaml --- r: 113630 b: refs/heads/snap-stage3 c: bcabcf5 h: refs/heads/master v: v3
1 parent 4d4790d commit 94c8b93

File tree

14 files changed

+118
-232
lines changed

14 files changed

+118
-232
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: abdacecdf86b4b5a4f432560445a24e1c5f4751b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 63287eef27b1a23a1fc24a7b4453eb7bd8ec1f11
4+
refs/heads/snap-stage3: bcabcf53cfe2a86ebf02aa762b8ab7278060ce10
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/fmt/mod.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,16 @@ pub mod rt;
4343

4444
pub type Result = result::Result<(), FormatError>;
4545

46-
/// The error type which is returned from formatting a message into a stream.
47-
///
48-
/// This type does not support transmission of an error other than that an error
49-
/// occurred. Any extra information must be arranged to be transmitted through
50-
/// some other means.
46+
/// dox
5147
pub enum FormatError {
52-
/// A generic write error occurred during formatting, no other information
53-
/// is transmitted via this variant.
48+
/// dox
5449
WriteError,
5550
}
5651

57-
/// A collection of methods that are required to format a message into a stream.
58-
///
59-
/// This trait is the type which this modules requires when formatting
60-
/// information. This is similar to the standard library's `io::Writer` trait,
61-
/// but it is only intended for use in libcore.
62-
///
63-
/// This trait should generally not be implemented by consumers of the standard
64-
/// library. The `write!` macro accepts an instance of `io::Writer`, and the
65-
/// `io::Writer` trait is favored over implementing this trait.
52+
/// dox
6653
pub trait FormatWriter {
67-
/// Writes a slice of bytes into this writer, returning whether the write
68-
/// succeeded.
69-
///
70-
/// This method can only succeed if the entire byte slice was successfully
71-
/// written, and this method will not return until all data has been
72-
/// written or an error occurs.
73-
///
74-
/// # Errors
75-
///
76-
/// This function will return an instance of `FormatError` on error.
54+
/// dox
7755
fn write(&mut self, bytes: &[u8]) -> Result;
78-
79-
/// Glue for usage of the `write!` macro with implementors of this trait.
80-
///
81-
/// This method should generally not be invoked manually, but rather through
82-
/// the `write!` macro itself.
83-
fn write_fmt(&mut self, args: &Arguments) -> Result { write(self, args) }
8456
}
8557

8658
/// A struct to represent both where to emit formatting strings to and how they

branches/snap-stage3/src/libcore/prelude.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,7 @@
1010

1111
//! The core prelude
1212
//!
13-
//! This module is intended for users of libcore which do not link to libstd as
14-
//! well. This module is not imported by default, but using the entire contents
15-
//! of this module will provide all of the useful traits and types in libcore
16-
//! that one would expect from the standard library as well.
17-
//!
18-
//! There is no method to automatically inject this prelude, and this prelude is
19-
//! a subset of the standard library's prelude.
20-
//!
21-
//! # Example
22-
//!
23-
//! ```ignore
24-
//! # fn main() {
25-
//! #![feature(globs)]
26-
//!
27-
//! use core::prelude::*;
28-
//! # }
29-
//! ```
13+
//! For more information, see std::prelude.
3014
3115
// Reexported core operators
3216
pub use kinds::{Copy, Send, Sized, Share};

branches/snap-stage3/src/librustc/middle/trans/adt.rs

Lines changed: 44 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,6 @@ pub enum Repr {
8585
* all start with a field for the discriminant.
8686
*/
8787
General(IntType, Vec<Struct>),
88-
/**
89-
* Two cases distinguished by a nullable pointer: the case with discriminant
90-
* `nndiscr` must have single field which is known to be nonnull due to its type.
91-
* The other case is known to be zero sized. Hence we represent the enum
92-
* as simply a nullable pointer: if not null it indicates the `nndiscr` variant,
93-
* otherwise it indicates the other case.
94-
*/
95-
RawNullablePointer {
96-
pub nndiscr: Disr,
97-
pub nnty: ty::t,
98-
pub nullfields: Vec<ty::t>
99-
},
10088
/**
10189
* Two cases distinguished by a nullable pointer: the case with discriminant
10290
* `nndiscr` is represented by the struct `nonnull`, where the `ptrfield`th
@@ -108,7 +96,7 @@ pub enum Repr {
10896
* is represented such that `None` is a null pointer and `Some` is the
10997
* identity function.
11098
*/
111-
StructWrappedNullablePointer {
99+
NullablePointer {
112100
pub nonnull: Struct,
113101
pub nndiscr: Disr,
114102
pub ptrfield: uint,
@@ -212,23 +200,17 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {
212200
if cases.get(1 - discr).is_zerolen(cx) {
213201
match cases.get(discr).find_ptr() {
214202
Some(ptrfield) => {
215-
let st = mk_struct(cx, cases.get(discr).tys.as_slice(),
216-
false);
217-
218-
return if st.fields.len() == 1 {
219-
RawNullablePointer {
220-
nndiscr: discr as Disr,
221-
nnty: *st.fields.get(0),
222-
nullfields: cases.get(1 - discr).tys.clone()
223-
}
224-
} else {
225-
StructWrappedNullablePointer {
226-
nndiscr: discr as Disr,
227-
nonnull: st,
228-
ptrfield: ptrfield,
229-
nullfields: cases.get(1 - discr).tys.clone()
230-
}
231-
};
203+
return NullablePointer {
204+
nndiscr: discr as u64,
205+
nonnull: mk_struct(cx,
206+
cases.get(discr)
207+
.tys
208+
.as_slice(),
209+
false),
210+
ptrfield: ptrfield,
211+
nullfields: cases.get(1 - discr).tys
212+
.clone()
213+
}
232214
}
233215
None => { }
234216
}
@@ -431,8 +413,8 @@ pub fn incomplete_type_of(cx: &CrateContext, r: &Repr, name: &str) -> Type {
431413
}
432414
pub fn finish_type_of(cx: &CrateContext, r: &Repr, llty: &mut Type) {
433415
match *r {
434-
CEnum(..) | General(..) | RawNullablePointer { .. } => { }
435-
Univariant(ref st, _) | StructWrappedNullablePointer { nonnull: ref st, .. } =>
416+
CEnum(..) | General(..) => { }
417+
Univariant(ref st, _) | NullablePointer{ nonnull: ref st, .. } =>
436418
llty.set_struct_body(struct_llfields(cx, st, false).as_slice(),
437419
st.packed)
438420
}
@@ -441,8 +423,7 @@ pub fn finish_type_of(cx: &CrateContext, r: &Repr, llty: &mut Type) {
441423
fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool) -> Type {
442424
match *r {
443425
CEnum(ity, _, _) => ll_inttype(cx, ity),
444-
RawNullablePointer { nnty, .. } => type_of::sizing_type_of(cx, nnty),
445-
Univariant(ref st, _) | StructWrappedNullablePointer { nonnull: ref st, .. } => {
426+
Univariant(ref st, _) | NullablePointer{ nonnull: ref st, .. } => {
446427
match name {
447428
None => {
448429
Type::struct_(cx, struct_llfields(cx, st, sizing).as_slice(),
@@ -514,10 +495,12 @@ fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool) -> Vec<Type> {
514495
pub fn trans_switch(bcx: &Block, r: &Repr, scrutinee: ValueRef)
515496
-> (_match::branch_kind, Option<ValueRef>) {
516497
match *r {
517-
CEnum(..) | General(..) |
518-
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
498+
CEnum(..) | General(..) => {
519499
(_match::switch, Some(trans_get_discr(bcx, r, scrutinee, None)))
520500
}
501+
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
502+
(_match::switch, Some(nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee)))
503+
}
521504
Univariant(..) => {
522505
(_match::single, None)
523506
}
@@ -545,14 +528,8 @@ pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Opti
545528
val = C_u8(bcx.ccx(), 0);
546529
signed = false;
547530
}
548-
RawNullablePointer { nndiscr, nnty, .. } => {
549-
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
550-
let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
551-
val = ICmp(bcx, cmp, Load(bcx, scrutinee), C_null(llptrty));
552-
signed = false;
553-
}
554-
StructWrappedNullablePointer { nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
555-
val = struct_wrapped_nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee);
531+
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
532+
val = nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee);
556533
signed = false;
557534
}
558535
}
@@ -562,10 +539,10 @@ pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Opti
562539
}
563540
}
564541

565-
fn struct_wrapped_nullable_bitdiscr(bcx: &Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
566-
scrutinee: ValueRef) -> ValueRef {
567-
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
542+
fn nullable_bitdiscr(bcx: &Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
543+
scrutinee: ValueRef) -> ValueRef {
568544
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
545+
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
569546
let llptrty = type_of::type_of(bcx.ccx(), *nonnull.fields.get(ptrfield));
570547
ICmp(bcx, cmp, llptr, C_null(llptrty))
571548
}
@@ -613,8 +590,7 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr)
613590
Univariant(..) => {
614591
bcx.ccx().sess().bug("no cases for univariants or structs")
615592
}
616-
RawNullablePointer { .. } |
617-
StructWrappedNullablePointer { .. } => {
593+
NullablePointer{ .. } => {
618594
assert!(discr == 0 || discr == 1);
619595
_match::single_result(Result::new(bcx, C_i1(bcx.ccx(), discr != 0)))
620596
}
@@ -645,13 +621,7 @@ pub fn trans_start_init(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr) {
645621
Univariant(..) => {
646622
assert_eq!(discr, 0);
647623
}
648-
RawNullablePointer { nndiscr, nnty, ..} => {
649-
if discr != nndiscr {
650-
let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
651-
Store(bcx, C_null(llptrty), val)
652-
}
653-
}
654-
StructWrappedNullablePointer { nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
624+
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
655625
if discr != nndiscr {
656626
let llptrptr = GEPi(bcx, val, [0, ptrfield]);
657627
let llptrty = type_of::type_of(bcx.ccx(),
@@ -681,11 +651,8 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
681651
st.fields.len() - (if dtor { 1 } else { 0 })
682652
}
683653
General(_, ref cases) => cases.get(discr as uint).fields.len() - 1,
684-
RawNullablePointer { nndiscr, ref nullfields, .. } => {
685-
if discr == nndiscr { 1 } else { nullfields.len() }
686-
}
687-
StructWrappedNullablePointer { nonnull: ref nonnull, nndiscr,
688-
nullfields: ref nullfields, .. } => {
654+
NullablePointer{ nonnull: ref nonnull, nndiscr,
655+
nullfields: ref nullfields, .. } => {
689656
if discr == nndiscr { nonnull.fields.len() } else { nullfields.len() }
690657
}
691658
}
@@ -708,25 +675,19 @@ pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr,
708675
General(_, ref cases) => {
709676
struct_field_ptr(bcx, cases.get(discr as uint), val, ix + 1, true)
710677
}
711-
RawNullablePointer { nndiscr, ref nullfields, .. } |
712-
StructWrappedNullablePointer { nndiscr, ref nullfields, .. } if discr != nndiscr => {
713-
// The unit-like case might have a nonzero number of unit-like fields.
714-
// (e.d., Result of Either with (), as one side.)
715-
let ty = type_of::type_of(bcx.ccx(), *nullfields.get(ix));
716-
assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0);
717-
// The contents of memory at this pointer can't matter, but use
718-
// the value that's "reasonable" in case of pointer comparision.
719-
PointerCast(bcx, val, ty.ptr_to())
720-
}
721-
RawNullablePointer { nndiscr, nnty, .. } => {
722-
assert_eq!(ix, 0);
723-
assert_eq!(discr, nndiscr);
724-
let ty = type_of::type_of(bcx.ccx(), nnty);
725-
PointerCast(bcx, val, ty.ptr_to())
726-
}
727-
StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
728-
assert_eq!(discr, nndiscr);
729-
struct_field_ptr(bcx, nonnull, val, ix, false)
678+
NullablePointer{ nonnull: ref nonnull, nullfields: ref nullfields,
679+
nndiscr, .. } => {
680+
if discr == nndiscr {
681+
struct_field_ptr(bcx, nonnull, val, ix, false)
682+
} else {
683+
// The unit-like case might have a nonzero number of unit-like fields.
684+
// (e.g., Result or Either with () as one side.)
685+
let ty = type_of::type_of(bcx.ccx(), *nullfields.get(ix));
686+
assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0);
687+
// The contents of memory at this pointer can't matter, but use
688+
// the value that's "reasonable" in case of pointer comparison.
689+
PointerCast(bcx, val, ty.ptr_to())
690+
}
730691
}
731692
}
732693
}
@@ -798,15 +759,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
798759
let contents = build_const_struct(ccx, st, vals);
799760
C_struct(ccx, contents.as_slice(), st.packed)
800761
}
801-
RawNullablePointer { nndiscr, nnty, .. } => {
802-
if discr == nndiscr {
803-
assert_eq!(vals.len(), 1);
804-
vals[0]
805-
} else {
806-
C_null(type_of::sizing_type_of(ccx, nnty))
807-
}
808-
}
809-
StructWrappedNullablePointer { nonnull: ref nonnull, nndiscr, .. } => {
762+
NullablePointer{ nonnull: ref nonnull, nndiscr, .. } => {
810763
if discr == nndiscr {
811764
C_struct(ccx, build_const_struct(ccx,
812765
nonnull,
@@ -914,15 +867,7 @@ pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef)
914867
}
915868
}
916869
Univariant(..) => 0,
917-
RawNullablePointer { nndiscr, .. } => {
918-
if is_null(val) {
919-
/* subtraction as uint is ok because nndiscr is either 0 or 1 */
920-
(1 - nndiscr) as Disr
921-
} else {
922-
nndiscr
923-
}
924-
}
925-
StructWrappedNullablePointer { nndiscr, ptrfield, .. } => {
870+
NullablePointer{ nndiscr, ptrfield, .. } => {
926871
if is_null(const_struct_field(ccx, val, ptrfield)) {
927872
/* subtraction as uint is ok because nndiscr is either 0 or 1 */
928873
(1 - nndiscr) as Disr
@@ -946,11 +891,7 @@ pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
946891
CEnum(..) => ccx.sess().bug("element access in C-like enum const"),
947892
Univariant(..) => const_struct_field(ccx, val, ix),
948893
General(..) => const_struct_field(ccx, val, ix + 1),
949-
RawNullablePointer { .. } => {
950-
assert_eq!(ix, 0);
951-
val
952-
}
953-
StructWrappedNullablePointer{ .. } => const_struct_field(ccx, val, ix)
894+
NullablePointer{ .. } => const_struct_field(ccx, val, ix)
954895
}
955896
}
956897

branches/snap-stage3/src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,10 +1675,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
16751675
}),
16761676
}
16771677
}
1678-
adt::RawNullablePointer { nnty, .. } => {
1679-
FinalMetadata(type_metadata(cx, nnty, span))
1680-
}
1681-
adt::StructWrappedNullablePointer { nonnull: ref struct_def, nndiscr, .. } => {
1678+
adt::NullablePointer { nonnull: ref struct_def, nndiscr, .. } => {
16821679
let (metadata_stub,
16831680
variant_llvm_type,
16841681
member_description_factory) =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
653653
tcx.sess.span_err(
654654
ast_ty.span,
655655
format!("reference to trait `{name}` where a type is expected; \
656-
try `Box<{name}>` or `&{name}`", name=path_str));
656+
try `~{name}` or `&{name}`", name=path_str));
657657
ty::mk_err()
658658
}
659659
ast::DefTy(did) | ast::DefStruct(did) => {

0 commit comments

Comments
 (0)