Skip to content

Commit d8d88f6

Browse files
committed
---
yaml --- r: 235857 b: refs/heads/stable c: c46f913 h: refs/heads/master i: 235855: 3249f6f v: v3
1 parent bc7dcde commit d8d88f6

File tree

5 files changed

+61
-81
lines changed

5 files changed

+61
-81
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: 6d36798c89806fc4eaabb83831be1a4c90919a02
32+
refs/heads/stable: c46f91324434d46472bd4aa15286240b7ba537d6
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libcollections/str.rs

Lines changed: 47 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ impl str {
500500
///
501501
/// # Unsafety
502502
///
503-
/// Caller must check both UTF-8 sequence boundaries and the boundaries
503+
/// Caller must check both UTF-8 character boundaries and the boundaries
504504
/// of the entire slice as
505505
/// well.
506506
///
@@ -526,16 +526,15 @@ impl str {
526526
core_str::StrExt::slice_mut_unchecked(self, begin, end)
527527
}
528528

529-
/// Returns a slice of the string from the range [`begin`..`end`) where indices
530-
/// are counted in code points.
529+
/// Returns a slice of the string from the character range [`begin`..`end`).
531530
///
532531
/// That is, start at the `begin`-th code point of the string and continue
533532
/// to the `end`-th code point. This does not detect or handle edge cases
534-
/// such as leaving a combining character as the first `char` of the
533+
/// such as leaving a combining character as the first code point of the
535534
/// string.
536535
///
537536
/// Due to the design of UTF-8, this operation is `O(end)`. Use slicing
538-
/// syntax if you want to use `O(1)` byte indices instead.
537+
/// syntax if you want to use byte indices rather than codepoint indices.
539538
///
540539
/// # Panics
541540
///
@@ -557,26 +556,26 @@ impl str {
557556
core_str::StrExt::slice_chars(self, begin, end)
558557
}
559558

560-
/// Given a byte position, return the next code point and its index.
559+
/// Given a byte position, return the next char and its index.
561560
///
562-
/// This can be used to iterate over the Unicode code points of a string.
561+
/// This can be used to iterate over the Unicode characters of a string.
563562
///
564563
/// # Panics
565564
///
566565
/// If `i` is greater than or equal to the length of the string.
567-
/// If `i` is not the index of the beginning of a valid UTF-8 sequence.
566+
/// If `i` is not the index of the beginning of a valid UTF-8 character.
568567
///
569568
/// # Examples
570569
///
571-
/// This example manually iterates through the code points of a string;
570+
/// This example manually iterates through the characters of a string;
572571
/// this should normally be
573572
/// done by `.chars()` or `.char_indices()`.
574573
///
575574
/// ```
576575
/// # #![feature(str_char, core)]
577576
/// use std::str::CharRange;
578577
///
579-
/// let s = "中华Việt Nam";
578+
/// let s = "中华Việt Nam";
580579
/// let mut i = 0;
581580
/// while i < s.len() {
582581
/// let CharRange {ch, next} = s.char_range_at(i);
@@ -592,14 +591,12 @@ impl str {
592591
/// 3: 华
593592
/// 6: V
594593
/// 7: i
595-
/// 8: e
596-
/// 9: ̣
597-
/// 11: ̂
598-
/// 13: t
599-
/// 14:
600-
/// 15: N
601-
/// 16: a
602-
/// 17: m
594+
/// 8: ệ
595+
/// 11: t
596+
/// 12:
597+
/// 13: N
598+
/// 14: a
599+
/// 15: m
603600
/// ```
604601
#[unstable(feature = "str_char",
605602
reason = "often replaced by char_indices, this method may \
@@ -611,29 +608,26 @@ impl str {
611608

612609
/// Given a byte position, return the previous `char` and its position.
613610
///
614-
/// This function can be used to iterate over a Unicode code points in reverse.
615-
///
616-
/// Note that Unicode has many features, such as combining marks, ligatures,
617-
/// and direction marks, that need to be taken into account to correctly reverse a string.
611+
/// This function can be used to iterate over a Unicode string in reverse.
618612
///
619613
/// Returns 0 for next index if called on start index 0.
620614
///
621615
/// # Panics
622616
///
623617
/// If `i` is greater than the length of the string.
624-
/// If `i` is not an index following a valid UTF-8 sequence.
618+
/// If `i` is not an index following a valid UTF-8 character.
625619
///
626620
/// # Examples
627621
///
628-
/// This example manually iterates through the code points of a string;
622+
/// This example manually iterates through the characters of a string;
629623
/// this should normally be
630624
/// done by `.chars().rev()` or `.char_indices()`.
631625
///
632626
/// ```
633627
/// # #![feature(str_char, core)]
634628
/// use std::str::CharRange;
635629
///
636-
/// let s = "中华Việt Nam";
630+
/// let s = "中华Việt Nam";
637631
/// let mut i = s.len();
638632
/// while i > 0 {
639633
/// let CharRange {ch, next} = s.char_range_at_reverse(i);
@@ -645,14 +639,12 @@ impl str {
645639
/// This outputs:
646640
///
647641
/// ```text
648-
/// 18: m
649-
/// 17: a
650-
/// 16: N
651-
/// 15:
652-
/// 14: t
653-
/// 13: ̂
654-
/// 11: ̣
655-
/// 9: e
642+
/// 16: m
643+
/// 15: a
644+
/// 14: N
645+
/// 13:
646+
/// 12: t
647+
/// 11: ệ
656648
/// 8: i
657649
/// 7: V
658650
/// 6: 华
@@ -671,7 +663,7 @@ impl str {
671663
/// # Panics
672664
///
673665
/// If `i` is greater than or equal to the length of the string.
674-
/// If `i` is not the index of the beginning of a valid UTF-8 sequence.
666+
/// If `i` is not the index of the beginning of a valid UTF-8 character.
675667
///
676668
/// # Examples
677669
///
@@ -680,7 +672,6 @@ impl str {
680672
/// let s = "abπc";
681673
/// assert_eq!(s.char_at(1), 'b');
682674
/// assert_eq!(s.char_at(2), 'π');
683-
/// assert_eq!(s.char_at(4), 'c');
684675
/// ```
685676
#[unstable(feature = "str_char",
686677
reason = "frequently replaced by the chars() iterator, this \
@@ -698,7 +689,7 @@ impl str {
698689
/// # Panics
699690
///
700691
/// If `i` is greater than the length of the string.
701-
/// If `i` is not an index following a valid UTF-8 sequence.
692+
/// If `i` is not an index following a valid UTF-8 character.
702693
///
703694
/// # Examples
704695
///
@@ -707,7 +698,6 @@ impl str {
707698
/// let s = "abπc";
708699
/// assert_eq!(s.char_at_reverse(1), 'a');
709700
/// assert_eq!(s.char_at_reverse(2), 'b');
710-
/// assert_eq!(s.char_at_reverse(3), 'π');
711701
/// ```
712702
#[unstable(feature = "str_char",
713703
reason = "see char_at for more details, but reverse semantics \
@@ -717,30 +707,28 @@ impl str {
717707
core_str::StrExt::char_at_reverse(self, i)
718708
}
719709

720-
/// Retrieves the first code point from a `&str` and returns it.
721-
///
722-
/// Note that a single Unicode character (grapheme cluster)
723-
/// can be composed of multiple `char`s.
710+
/// Retrieves the first character from a `&str` and returns it.
724711
///
725712
/// This does not allocate a new string; instead, it returns a slice that
726-
/// points one code point beyond the code point that was shifted.
713+
/// points one character
714+
/// beyond the character that was shifted.
727715
///
728-
/// `None` is returned if the slice is empty.
716+
/// If the slice does not contain any characters, None is returned instead.
729717
///
730718
/// # Examples
731719
///
732720
/// ```
733721
/// # #![feature(str_char)]
734-
/// let s = "Łódź"; // \u{141}o\u{301}dz\u{301}
722+
/// let s = "Löwe 老虎 Léopard";
735723
/// let (c, s1) = s.slice_shift_char().unwrap();
736724
///
737-
/// assert_eq!(c, 'Ł');
738-
/// assert_eq!(s1, "ódź");
725+
/// assert_eq!(c, 'L');
726+
/// assert_eq!(s1, "öwe 老虎 Léopard");
739727
///
740728
/// let (c, s2) = s1.slice_shift_char().unwrap();
741729
///
742-
/// assert_eq!(c, 'o');
743-
/// assert_eq!(s2, "\u{301}dz\u{301}");
730+
/// assert_eq!(c, 'ö');
731+
/// assert_eq!(s2, "we 老虎 Léopard");
744732
/// ```
745733
#[unstable(feature = "str_char",
746734
reason = "awaiting conventions about shifting and slices and \
@@ -753,14 +741,14 @@ impl str {
753741
/// Divide one string slice into two at an index.
754742
///
755743
/// The index `mid` is a byte offset from the start of the string
756-
/// that must be on a `char` boundary.
744+
/// that must be on a character boundary.
757745
///
758746
/// Return slices `&self[..mid]` and `&self[mid..]`.
759747
///
760748
/// # Panics
761749
///
762-
/// Panics if `mid` is beyond the last code point of the string,
763-
/// or if it is not on a `char` boundary.
750+
/// Panics if `mid` is beyond the last character of the string,
751+
/// or if it is not on a character boundary.
764752
///
765753
/// # Examples
766754
/// ```
@@ -785,39 +773,27 @@ impl str {
785773
core_str::StrExt::split_at_mut(self, mid)
786774
}
787775

788-
/// An iterator over the code points of `self`.
789-
///
790-
/// In Unicode relationship between code points and characters is complex.
791-
/// A single character may be composed of multiple code points
792-
/// (e.g. diacritical marks added to a letter), and a single code point
793-
/// (e.g. Hangul syllable) may contain multiple characters.
794-
///
795-
/// For iteration over human-readable characters a grapheme cluster iterator
796-
/// may be more appropriate. See the [unicode-segmentation crate][1].
797-
///
798-
/// [1]: https://crates.io/crates/unicode-segmentation
776+
/// An iterator over the codepoints of `self`.
799777
///
800778
/// # Examples
801779
///
802780
/// ```
803-
/// let v: Vec<char> = "ASCII żółć 🇨🇭 한".chars().collect();
781+
/// let v: Vec<char> = "abc åäö".chars().collect();
804782
///
805-
/// assert_eq!(v, ['A', 'S', 'C', 'I', 'I', ' ',
806-
/// 'z', '\u{307}', 'o', '\u{301}', 'ł', 'c', '\u{301}', ' ',
807-
/// '\u{1f1e8}', '\u{1f1ed}', ' ', '한']);
783+
/// assert_eq!(v, ['a', 'b', 'c', ' ', 'å', 'ä', 'ö']);
808784
/// ```
809785
#[stable(feature = "rust1", since = "1.0.0")]
810786
pub fn chars(&self) -> Chars {
811787
core_str::StrExt::chars(self)
812788
}
813789

814-
/// An iterator over the `char`s of `self` and their byte offsets.
790+
/// An iterator over the characters of `self` and their byte offsets.
815791
///
816792
/// # Examples
817793
///
818794
/// ```
819-
/// let v: Vec<(usize, char)> = "A🇨🇭".char_indices().collect();
820-
/// let b = vec![(0, 'A'), (1, '\u{1f1e8}'), (5, '\u{1f1ed}')];
795+
/// let v: Vec<(usize, char)> = "abc".char_indices().collect();
796+
/// let b = vec![(0, 'a'), (1, 'b'), (2, 'c')];
821797
///
822798
/// assert_eq!(v, b);
823799
/// ```
@@ -846,7 +822,7 @@ impl str {
846822
/// # Examples
847823
///
848824
/// ```
849-
/// let some_words = " Mary had\ta\u{2009}little \n\t lamb";
825+
/// let some_words = " Mary had\ta little \n\t lamb";
850826
/// let v: Vec<&str> = some_words.split_whitespace().collect();
851827
///
852828
/// assert_eq!(v, ["Mary", "had", "a", "little", "lamb"]);
@@ -864,7 +840,7 @@ impl str {
864840
/// ```
865841
/// # #![feature(str_words)]
866842
/// # #![allow(deprecated)]
867-
/// let some_words = " Mary had\ta\u{2009}little \n\t lamb";
843+
/// let some_words = " Mary had\ta little \n\t lamb";
868844
/// let v: Vec<&str> = some_words.words().collect();
869845
///
870846
/// assert_eq!(v, ["Mary", "had", "a", "little", "lamb"]);

branches/stable/src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
24902490
// The special-cased logic below has three functions:
24912491
// 1. Provide as good of an expected type as possible.
24922492
let expected = expected_arg_tys.get(i).map(|&ty| {
2493-
Expectation::rvalue_hint(ty)
2493+
Expectation::rvalue_hint(fcx.tcx(), ty)
24942494
});
24952495

24962496
check_expr_with_unifier(fcx, &**arg,
@@ -3268,7 +3268,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
32683268
match unop {
32693269
ast::UnUniq => match ty.sty {
32703270
ty::TyBox(ty) => {
3271-
Expectation::rvalue_hint(ty)
3271+
Expectation::rvalue_hint(tcx, ty)
32723272
}
32733273
_ => {
32743274
NoExpectation
@@ -3345,7 +3345,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
33453345
// the last field of a struct can be unsized.
33463346
ExpectHasType(mt.ty)
33473347
} else {
3348-
Expectation::rvalue_hint(mt.ty)
3348+
Expectation::rvalue_hint(tcx, mt.ty)
33493349
}
33503350
}
33513351
_ => NoExpectation
@@ -3982,8 +3982,8 @@ impl<'tcx> Expectation<'tcx> {
39823982
/// which still is useful, because it informs integer literals and the like.
39833983
/// See the test case `test/run-pass/coerce-expect-unsized.rs` and #20169
39843984
/// for examples of where this comes up,.
3985-
fn rvalue_hint(ty: Ty<'tcx>) -> Expectation<'tcx> {
3986-
match ty.sty {
3985+
fn rvalue_hint(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
3986+
match tcx.struct_tail(ty).sty {
39873987
ty::TySlice(_) | ty::TyTrait(..) => {
39883988
ExpectRvalueLikeUnsized(ty)
39893989
}

branches/stable/src/libstd/rand/os.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mod imp {
185185
use io;
186186
use mem;
187187
use rand::Rng;
188-
use libc::{c_int, c_void, size_t};
188+
use libc::{c_int, size_t};
189189

190190
/// A random number generator that retrieves randomness straight from
191191
/// the operating system. Platform sources:
@@ -203,9 +203,8 @@ mod imp {
203203
_dummy: (),
204204
}
205205

206-
// Fake definition; this is actually a struct, but we don't use the
207-
// contents here.
208-
type SecRandom = c_void;
206+
#[repr(C)]
207+
struct SecRandom;
209208

210209
#[allow(non_upper_case_globals)]
211210
const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom;

branches/stable/src/test/run-pass/coerce-expect-unsized.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#![allow(unknown_features)]
1414
#![feature(box_syntax)]
1515

16+
use std::cell::RefCell;
1617
use std::fmt::Debug;
18+
use std::rc::Rc;
1719

1820
// Check that coercions apply at the pointer level and don't cause
1921
// rvalue expressions to be unsized. See #20169 for more information.
@@ -45,6 +47,9 @@ pub fn main() {
4547
let _: Box<[isize]> = Box::new([1, 2, 3]);
4648
let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));
4749

50+
let _: Rc<RefCell<[isize]>> = Rc::new(RefCell::new([1, 2, 3]));
51+
let _: Rc<RefCell<FnMut(isize) -> _>> = Rc::new(RefCell::new(|x| (x as u8)));
52+
4853
let _: Vec<Box<Fn(isize) -> _>> = vec![
4954
Box::new(|x| (x as u8)),
5055
Box::new(|x| (x as i16 as u8)),

0 commit comments

Comments
 (0)