Skip to content

Commit 8de4837

Browse files
committed
---
yaml --- r: 235135 b: refs/heads/stable c: fe354e5 h: refs/heads/master i: 235133: 0295b64 235131: edcebec 235127: 442da86 235119: efbe1e6 235103: 9154f88 235071: 277c856 235007: 3466c59 v: v3
1 parent fa68fe2 commit 8de4837

File tree

22 files changed

+165
-220
lines changed

22 files changed

+165
-220
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: b381449dfffef27e8b28a6f0867a8c238eef7188
32+
refs/heads/stable: fe354e58bdd17ad63f2d9278820eb7ee1ee091d5
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Read ["Installing Rust"] from [The Book].
7373
```
7474
7575
3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
76-
MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
76+
MYSY2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
7777
7878
4. Navigate to Rust's source code, configure and build it:
7979

branches/stable/src/libcollections/str.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ impl str {
483483
/// considered to be
484484
/// boundaries.
485485
///
486-
/// Returns `false` if `index` is greater than `self.len()`.
486+
/// # Panics
487+
///
488+
/// Panics if `index` is greater than `self.len()`.
487489
///
488490
/// # Examples
489491
///
@@ -1857,6 +1859,8 @@ impl str {
18571859
/// # Examples
18581860
///
18591861
/// ```
1862+
/// #![feature(str_casing)]
1863+
///
18601864
/// let s = "HELLO";
18611865
/// assert_eq!(s.to_lowercase(), "hello");
18621866
/// ```
@@ -1901,6 +1905,8 @@ impl str {
19011905
/// # Examples
19021906
///
19031907
/// ```
1908+
/// #![feature(str_casing)]
1909+
///
19041910
/// let s = "hello";
19051911
/// assert_eq!(s.to_uppercase(), "HELLO");
19061912
/// ```

branches/stable/src/libcore/str/pattern.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,17 @@ impl<'a, 'b> Pattern<'a> for &'b str {
513513
/// Checks whether the pattern matches at the front of the haystack
514514
#[inline]
515515
fn is_prefix_of(self, haystack: &'a str) -> bool {
516-
haystack.is_char_boundary(self.len()) &&
517-
self == &haystack[..self.len()]
516+
// Use `as_bytes` so that we can slice through a character in the haystack.
517+
// Since self is always valid UTF-8, this can't result in a false positive.
518+
self.len() <= haystack.len() &&
519+
self.as_bytes() == &haystack.as_bytes()[..self.len()]
518520
}
519521

520522
/// Checks whether the pattern matches at the back of the haystack
521523
#[inline]
522524
fn is_suffix_of(self, haystack: &'a str) -> bool {
523525
self.len() <= haystack.len() &&
524-
haystack.is_char_boundary(haystack.len() - self.len()) &&
525-
self == &haystack[haystack.len() - self.len()..]
526+
self.as_bytes() == &haystack.as_bytes()[haystack.len() - self.len()..]
526527
}
527528
}
528529

branches/stable/src/librustc/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ register_diagnostics! {
12051205
E0017,
12061206
E0022,
12071207
E0038,
1208-
// E0134,
1209-
// E0135,
1208+
E0134,
1209+
E0135,
12101210
E0136,
12111211
E0138,
12121212
E0139,

branches/stable/src/librustc/middle/astencode.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,8 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
755755
})
756756
}
757757

758-
ty::MethodStaticClosure(def_id) => {
759-
this.emit_enum_variant("MethodStaticClosure", 1, 1, |this| {
760-
Ok(this.emit_def_id(def_id))
761-
})
762-
}
763-
764758
ty::MethodTypeParam(ref p) => {
765-
this.emit_enum_variant("MethodTypeParam", 2, 1, |this| {
759+
this.emit_enum_variant("MethodTypeParam", 1, 1, |this| {
766760
this.emit_struct("MethodParam", 2, |this| {
767761
try!(this.emit_struct_field("trait_ref", 0, |this| {
768762
Ok(this.emit_trait_ref(ecx, &p.trait_ref))
@@ -786,7 +780,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
786780
}
787781

788782
ty::MethodTraitObject(ref o) => {
789-
this.emit_enum_variant("MethodTraitObject", 3, 1, |this| {
783+
this.emit_enum_variant("MethodTraitObject", 2, 1, |this| {
790784
this.emit_struct("MethodObject", 2, |this| {
791785
try!(this.emit_struct_field("trait_ref", 0, |this| {
792786
Ok(this.emit_trait_ref(ecx, &o.trait_ref))
@@ -1239,8 +1233,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12391233
-> ty::MethodOrigin<'tcx>
12401234
{
12411235
self.read_enum("MethodOrigin", |this| {
1242-
let variants = &["MethodStatic", "MethodStaticClosure",
1243-
"MethodTypeParam", "MethodTraitObject"];
1236+
let variants = &["MethodStatic", "MethodTypeParam", "MethodTraitObject"];
12441237
this.read_enum_variant(variants, |this, i| {
12451238
Ok(match i {
12461239
0 => {
@@ -1249,11 +1242,6 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12491242
}
12501243

12511244
1 => {
1252-
let def_id = this.read_def_id(dcx);
1253-
ty::MethodStaticClosure(def_id)
1254-
}
1255-
1256-
2 => {
12571245
this.read_struct("MethodTypeParam", 2, |this| {
12581246
Ok(ty::MethodTypeParam(
12591247
ty::MethodParam {
@@ -1282,7 +1270,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12821270
}).unwrap()
12831271
}
12841272

1285-
3 => {
1273+
2 => {
12861274
this.read_struct("MethodTraitObject", 2, |this| {
12871275
Ok(ty::MethodTraitObject(
12881276
ty::MethodObject {

branches/stable/src/librustc/middle/dead.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
105105
None => self.check_def_id(def_id)
106106
}
107107
}
108-
ty::MethodStaticClosure(_) => {}
109108
ty::MethodTypeParam(ty::MethodParam {
110109
ref trait_ref,
111110
method_num: index,

branches/stable/src/librustc/middle/effect.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
5959
UnsafeFn => {}
6060
}
6161
}
62+
63+
fn check_str_index(&mut self, e: &ast::Expr) {
64+
let base_type = match e.node {
65+
ast::ExprIndex(ref base, _) => self.tcx.node_id_to_type(base.id),
66+
_ => return
67+
};
68+
debug!("effect: checking index with base type {:?}",
69+
base_type);
70+
match base_type.sty {
71+
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
72+
span_err!(self.tcx.sess, e.span, E0134,
73+
"modification of string types is not allowed");
74+
},
75+
ty::TyStr => {
76+
span_err!(self.tcx.sess, e.span, E0135,
77+
"modification of string types is not allowed");
78+
}
79+
_ => {}
80+
}
81+
}
6282
}
6383

6484
impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
@@ -144,6 +164,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
144164
self.require_unsafe(expr.span, "dereference of raw pointer")
145165
}
146166
}
167+
ast::ExprAssign(ref base, _) | ast::ExprAssignOp(_, ref base, _) => {
168+
self.check_str_index(&**base);
169+
}
170+
ast::ExprAddrOf(ast::MutMutable, ref base) => {
171+
self.check_str_index(&**base);
172+
}
147173
ast::ExprInlineAsm(..) => {
148174
self.require_unsafe(expr.span, "use of inline assembly");
149175
}

branches/stable/src/librustc/middle/expr_use_visitor.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,27 +254,12 @@ impl OverloadedCallType {
254254
OverloadedCallType::from_trait_id(tcx, trait_ref.def_id)
255255
}
256256

257-
fn from_closure(tcx: &ty::ctxt, closure_did: ast::DefId)
258-
-> OverloadedCallType {
259-
let trait_did =
260-
tcx.tables
261-
.borrow()
262-
.closure_kinds
263-
.get(&closure_did)
264-
.expect("OverloadedCallType::from_closure: didn't find closure id")
265-
.trait_did(tcx);
266-
OverloadedCallType::from_trait_id(tcx, trait_did)
267-
}
268-
269257
fn from_method_origin(tcx: &ty::ctxt, origin: &MethodOrigin)
270258
-> OverloadedCallType {
271259
match *origin {
272260
MethodStatic(def_id) => {
273261
OverloadedCallType::from_method_id(tcx, def_id)
274262
}
275-
MethodStaticClosure(def_id) => {
276-
OverloadedCallType::from_closure(tcx, def_id)
277-
}
278263
MethodTypeParam(MethodParam { ref trait_ref, .. }) |
279264
MethodTraitObject(MethodObject { ref trait_ref, .. }) => {
280265
OverloadedCallType::from_trait_id(tcx, trait_ref.def_id)

branches/stable/src/librustc/middle/stability.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,6 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
412412
ty::MethodStatic(def_id) => {
413413
def_id
414414
}
415-
ty::MethodStaticClosure(def_id) => {
416-
def_id
417-
}
418415
ty::MethodTypeParam(ty::MethodParam {
419416
ref trait_ref,
420417
method_num: index,

branches/stable/src/librustc/middle/ty.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,6 @@ pub enum MethodOrigin<'tcx> {
631631
// fully statically resolved method
632632
MethodStatic(ast::DefId),
633633

634-
// fully statically resolved closure invocation
635-
MethodStaticClosure(ast::DefId),
636-
637634
// method invoked on a type parameter with a bounded trait
638635
MethodTypeParam(MethodParam<'tcx>),
639636

branches/stable/src/librustc/middle/ty_fold.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::MethodOrigin<'tcx> {
316316
ty::MethodStatic(def_id) => {
317317
ty::MethodStatic(def_id)
318318
}
319-
ty::MethodStaticClosure(def_id) => {
320-
ty::MethodStaticClosure(def_id)
321-
}
322319
ty::MethodTypeParam(ref param) => {
323320
ty::MethodTypeParam(ty::MethodParam {
324321
trait_ref: param.trait_ref.fold_with(folder),

branches/stable/src/librustc/util/ppaux.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,6 @@ impl<'tcx> fmt::Debug for ty::MethodOrigin<'tcx> {
500500
ty::MethodStatic(def_id) => {
501501
write!(f, "MethodStatic({:?})", def_id)
502502
}
503-
ty::MethodStaticClosure(def_id) => {
504-
write!(f, "MethodStaticClosure({:?})", def_id)
505-
}
506503
ty::MethodTypeParam(ref p) => write!(f, "{:?}", p),
507504
ty::MethodTraitObject(ref p) => write!(f, "{:?}", p)
508505
}

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ impl LintPass for UnconditionalRecursion {
20032003
ty::MethodTraitObject(_) => return false,
20042004

20052005
// This `did` refers directly to the method definition.
2006-
ty::MethodStatic(did) | ty::MethodStaticClosure(did) => did,
2006+
ty::MethodStatic(did) => did,
20072007

20082008
// MethodTypeParam are methods from traits:
20092009

branches/stable/src/librustc_privacy/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
854854
MethodStatic(method_id) => {
855855
self.check_static_method(span, method_id, name)
856856
}
857-
MethodStaticClosure(_) => {}
858857
// Trait methods are always all public. The only controlling factor
859858
// is whether the trait itself is accessible or not.
860859
MethodTypeParam(MethodParam { ref trait_ref, .. }) |

branches/stable/src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
889889
let method_map = &self.tcx.tables.borrow().method_map;
890890
let method_callee = method_map.get(&ty::MethodCall::expr(ex.id)).unwrap();
891891
let (def_id, decl_id) = match method_callee.origin {
892-
ty::MethodStatic(def_id) |
893-
ty::MethodStaticClosure(def_id) => {
892+
ty::MethodStatic(def_id) => {
894893
// method invoked on an object with a concrete type (not a static method)
895894
let decl_id =
896895
match self.tcx.trait_item_of_item(def_id) {
@@ -907,7 +906,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
907906
_ => self.sess
908907
.span_bug(ex.span,
909908
"save::process_method_call: non-method \
910-
DefId in MethodStatic or MethodStaticClosure"),
909+
DefId in MethodStatic"),
911910
};
912911
(Some(def_id), decl_id)
913912
}

branches/stable/src/librustc_trans/trans/meth.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
117117
.unwrap();
118118

119119
match origin {
120-
ty::MethodStatic(did) |
121-
ty::MethodStaticClosure(did) => {
120+
ty::MethodStatic(did) => {
122121
debug!("trans_method_callee: static, {:?}", did);
123122
Callee {
124123
bcx: bcx,

0 commit comments

Comments
 (0)