Skip to content

Commit 3803043

Browse files
committed
---
yaml --- r: 160268 b: refs/heads/master c: b64c7b8 h: refs/heads/master v: v3
1 parent 1bbaf87 commit 3803043

26 files changed

+151
-337
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: fee71bd476720abc01422a4184badcb734fd4f35
2+
refs/heads/master: b64c7b83dd08c7c3afc643564d65975d57785172
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 96c8f2b0c1846756e617f1f1fc1372c506e24248
55
refs/heads/try: 225de0d60f8ca8dcc62ab2fd8818ebbda4b58cfe

trunk/src/doc/reference.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,14 +3557,17 @@ The machine types are the following:
35573557

35583558
#### Machine-dependent integer types
35593559

3560-
The `uint` type is an unsigned integer type with the same number of bits as the
3561-
platform's pointer type. It can represent every memory address in the process.
3562-
3563-
The `int` type is a signed integer type with the same number of bits as the
3564-
platform's pointer type. The theoretical upper bound on object and array size
3565-
is the maximum `int` value. This ensures that `int` can be used to calculate
3566-
differences between pointers into an object or array and can address every byte
3567-
within an object along with one byte past the end.
3560+
The Rust type `uint` [^rustuint] is an
3561+
unsigned integer type with target-machine-dependent size. Its size, in
3562+
bits, is equal to the number of bits required to hold any memory address on
3563+
the target machine.
3564+
3565+
The Rust type `int` [^rustint] is a two's complement signed integer type with
3566+
target-machine-dependent size. Its size, in bits, is equal to the size of the
3567+
rust type `uint` on the same target machine.
3568+
3569+
[^rustuint]: A Rust `uint` is analogous to a C99 `uintptr_t`.
3570+
[^rustint]: A Rust `int` is analogous to a C99 `intptr_t`.
35683571

35693572
### Textual types
35703573

trunk/src/librustc/middle/resolve.rs

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ enum TraitReferenceType {
633633
TraitDerivation, // trait T : SomeTrait { ... }
634634
TraitBoundingTypeParameter, // fn f<T:SomeTrait>() { ... }
635635
TraitObject, // Box<for<'a> SomeTrait>
636+
TraitQPath, // <T as SomeTrait>::
636637
}
637638

638639
impl NameBindings {
@@ -4532,6 +4533,7 @@ impl<'a> Resolver<'a> {
45324533
TraitImplementation => "implement",
45334534
TraitDerivation => "derive",
45344535
TraitObject => "reference",
4536+
TraitQPath => "extract an associated type from",
45354537
};
45364538

45374539
let msg = format!("attempt to {} a nonexistent trait `{}`", usage_str, path_str);
@@ -4969,65 +4971,8 @@ impl<'a> Resolver<'a> {
49694971
}
49704972

49714973
TyQPath(ref qpath) => {
4972-
self.resolve_type(&*qpath.for_type);
4973-
4974-
let current_module = self.current_module.clone();
4975-
let module_path: Vec<_> =
4976-
qpath.trait_name
4977-
.segments
4978-
.iter()
4979-
.map(|ps| ps.identifier.name)
4980-
.collect();
4981-
match self.resolve_module_path(
4982-
current_module,
4983-
module_path.as_slice(),
4984-
UseLexicalScope,
4985-
qpath.trait_name.span,
4986-
PathSearch) {
4987-
Success((ref module, _)) if module.kind.get() ==
4988-
TraitModuleKind => {
4989-
match self.resolve_definition_of_name_in_module(
4990-
(*module).clone(),
4991-
qpath.item_name.name,
4992-
TypeNS) {
4993-
ChildNameDefinition(def, lp) |
4994-
ImportNameDefinition(def, lp) => {
4995-
match def {
4996-
DefAssociatedTy(trait_type_id) => {
4997-
let def = DefAssociatedTy(
4998-
trait_type_id);
4999-
self.record_def(ty.id, (def, lp));
5000-
}
5001-
_ => {
5002-
self.resolve_error(
5003-
ty.span,
5004-
"not an associated type");
5005-
}
5006-
}
5007-
}
5008-
NoNameDefinition => {
5009-
self.resolve_error(ty.span,
5010-
"unresolved associated \
5011-
type");
5012-
}
5013-
}
5014-
}
5015-
Success(..) => self.resolve_error(ty.span, "not a trait"),
5016-
Indeterminate => {
5017-
self.session.span_bug(ty.span,
5018-
"indeterminate result when \
5019-
resolving associated type")
5020-
}
5021-
Failed(error) => {
5022-
let (span, help) = match error {
5023-
Some((span, msg)) => (span, format!("; {}", msg)),
5024-
None => (ty.span, String::new()),
5025-
};
5026-
self.resolve_error(span,
5027-
format!("unresolved trait: {}",
5028-
help).as_slice())
5029-
}
5030-
}
4974+
self.resolve_type(&*qpath.self_type);
4975+
self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath);
50314976
}
50324977

50334978
TyClosure(ref c) | TyProc(ref c) => {

trunk/src/librustc/middle/subst.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ impl<'tcx> Substs<'tcx> {
100100
regions_is_noop && self.types.is_empty()
101101
}
102102

103+
pub fn type_for_def(&self, ty_param_def: &ty::TypeParameterDef) -> Ty<'tcx> {
104+
*self.types.get(ty_param_def.space, ty_param_def.index)
105+
}
106+
103107
pub fn has_regions_escaping_depth(&self, depth: uint) -> bool {
104108
self.types.iter().any(|&t| ty::type_escapes_depth(t, depth)) || {
105109
match self.regions {

trunk/src/librustc/middle/traits/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::rc::Rc;
2525
use std::slice::Items;
2626
use syntax::ast;
2727
use syntax::codemap::{Span, DUMMY_SP};
28+
use util::common::ErrorReported;
2829

2930
pub use self::fulfill::FulfillmentContext;
3031
pub use self::select::SelectionContext;
@@ -95,10 +96,6 @@ pub enum ObligationCauseCode<'tcx> {
9596
FieldSized,
9697
}
9798

98-
// An error has already been reported to the user, so no need to continue checking.
99-
#[deriving(Clone,Show)]
100-
pub struct ErrorReported;
101-
10299
pub type Obligations<'tcx> = subst::VecPerParamSpace<Obligation<'tcx>>;
103100

104101
pub type Selection<'tcx> = Vtable<'tcx, Obligation<'tcx>>;

trunk/src/librustc/middle/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use self::Candidate::*;
1717
use self::BuiltinBoundConditions::*;
1818
use self::EvaluationResult::*;
1919

20-
use super::{ErrorReported};
2120
use super::{Obligation, ObligationCause};
2221
use super::{SelectionError, Unimplemented, Overflow,
2322
OutputTypeParameterMismatch};
@@ -38,6 +37,7 @@ use std::cell::RefCell;
3837
use std::collections::hash_map::HashMap;
3938
use std::rc::Rc;
4039
use syntax::ast;
40+
use util::common::ErrorReported;
4141
use util::ppaux::Repr;
4242

4343
pub struct SelectionContext<'cx, 'tcx:'cx> {

trunk/src/librustc/middle/traits/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ use std::fmt;
1818
use std::rc::Rc;
1919
use syntax::ast;
2020
use syntax::codemap::Span;
21+
use util::common::ErrorReported;
2122
use util::ppaux::Repr;
2223

23-
use super::{ErrorReported, Obligation, ObligationCause, VtableImpl,
24+
use super::{Obligation, ObligationCause, VtableImpl,
2425
VtableParam, VtableParamData, VtableImplData};
2526

2627
///////////////////////////////////////////////////////////////////////////

trunk/src/librustc/middle/ty.rs

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,6 +3396,14 @@ pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
33963396
}
33973397
}
33983398

3399+
pub fn deref_or_dont<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
3400+
match ty.sty {
3401+
ty_uniq(ty) => ty,
3402+
ty_rptr(_, mt) | ty_ptr(mt) => mt.ty,
3403+
_ => ty
3404+
}
3405+
}
3406+
33993407
pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
34003408
match ty.sty {
34013409
ty_open(ty) => mk_rptr(cx, ReStatic, mt {ty: ty, mutbl:ast::MutImmutable}),
@@ -5981,59 +5989,3 @@ impl DebruijnIndex {
59815989
DebruijnIndex { depth: self.depth + amount }
59825990
}
59835991
}
5984-
5985-
impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> {
5986-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
5987-
match *self {
5988-
AdjustAddEnv(ref trait_store) => {
5989-
format!("AdjustAddEnv({})", trait_store)
5990-
}
5991-
AdjustDerefRef(ref data) => {
5992-
data.repr(tcx)
5993-
}
5994-
}
5995-
}
5996-
}
5997-
5998-
impl<'tcx> Repr<'tcx> for UnsizeKind<'tcx> {
5999-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
6000-
match *self {
6001-
UnsizeLength(n) => format!("UnsizeLength({})", n),
6002-
UnsizeStruct(ref k, n) => format!("UnsizeStruct({},{})", k.repr(tcx), n),
6003-
UnsizeVtable(ref a, ref b) => format!("UnsizeVtable({},{})", a.repr(tcx), b.repr(tcx)),
6004-
}
6005-
}
6006-
}
6007-
6008-
impl<'tcx> Repr<'tcx> for AutoDerefRef<'tcx> {
6009-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
6010-
format!("AutoDerefRef({}, {})", self.autoderefs, self.autoref.repr(tcx))
6011-
}
6012-
}
6013-
6014-
impl<'tcx> Repr<'tcx> for AutoRef<'tcx> {
6015-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
6016-
match *self {
6017-
AutoPtr(a, b, ref c) => {
6018-
format!("AutoPtr({},{},{})", a.repr(tcx), b, c.repr(tcx))
6019-
}
6020-
AutoUnsize(ref a) => {
6021-
format!("AutoUnsize({})", a.repr(tcx))
6022-
}
6023-
AutoUnsizeUniq(ref a) => {
6024-
format!("AutoUnsizeUniq({})", a.repr(tcx))
6025-
}
6026-
AutoUnsafe(ref a, ref b) => {
6027-
format!("AutoUnsafe({},{})", a, b.repr(tcx))
6028-
}
6029-
}
6030-
}
6031-
}
6032-
6033-
impl<'tcx> Repr<'tcx> for TyTrait<'tcx> {
6034-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
6035-
format!("TyTrait({},{})",
6036-
self.principal.repr(tcx),
6037-
self.bounds.repr(tcx))
6038-
}
6039-
}

0 commit comments

Comments
 (0)