Skip to content

Commit 8f34053

Browse files
committed
Auto merge of #32508 - Manishearth:rollup, r=Manishearth
Rollup of 6 pull requests - Successful merges: #32383, #32387, #32440, #32470, #32478, #32492 - Failed merges:
2 parents 346d0d5 + 90f2b69 commit 8f34053

File tree

6 files changed

+63
-138
lines changed

6 files changed

+63
-138
lines changed

src/doc/book/strings.md

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ let s = "foo\
4444
assert_eq!("foobar", s);
4545
```
4646

47+
Note that you normally cannot access a `str` directly, but only through a `&str`
48+
reference. This is because `str` is an unsized type which requires additional
49+
runtime information to be usable. For more information see the chapter on
50+
[unsized types][ut].
51+
4752
Rust has more than only `&str`s though. A `String` is a heap-allocated string.
4853
This string is growable, and is also guaranteed to be UTF-8. `String`s are
4954
commonly created by converting from a string slice using the `to_string`
@@ -185,5 +190,6 @@ let hello_world = hello + &world;
185190
This is because `&String` can automatically coerce to a `&str`. This is a
186191
feature called ‘[`Deref` coercions][dc]’.
187192

193+
[ut]: unsized-types.html
188194
[dc]: deref-coercions.html
189195
[connect]: ../std/net/struct.TcpStream.html#method.connect

src/doc/reference.md

+3
Original file line numberDiff line numberDiff line change
@@ -3911,6 +3911,9 @@ The _heap_ is a general term that describes boxes. The lifetime of an
39113911
allocation in the heap depends on the lifetime of the box values pointing to
39123912
it. Since box values may themselves be passed in and out of frames, or stored
39133913
in the heap, heap allocations may outlive the frame they are allocated within.
3914+
An allocation in the heap is guaranteed to reside at a single location in the
3915+
heap for the whole lifetime of the allocation - it will never be relocated as
3916+
a result of moving a box value.
39143917

39153918
### Memory ownership
39163919

src/etc/CONFIGS.md

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ These are some links to repos with configs which ease the use of rust.
1010
* [kate-config](https://github.com/rust-lang/kate-config)
1111
* [nano-config](https://github.com/rust-lang/nano-config)
1212
* [zsh-config](https://github.com/rust-lang/zsh-config)
13-
14-
## Community-maintained Configs
15-
16-
* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/))

src/librustc_unicode/char.rs

+48-132
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,9 @@ impl char {
153153
/// Basic usage:
154154
///
155155
/// ```
156-
/// let d = '1';
157-
///
158-
/// assert!(d.is_digit(10));
159-
///
160-
/// let d = 'f';
161-
///
162-
/// assert!(d.is_digit(16));
163-
/// assert!(!d.is_digit(10));
156+
/// assert!('1'.is_digit(10));
157+
/// assert!('f'.is_digit(16));
158+
/// assert!(!'f'.is_digit(10));
164159
/// ```
165160
///
166161
/// Passing a large radix, causing a panic:
@@ -169,10 +164,8 @@ impl char {
169164
/// use std::thread;
170165
///
171166
/// let result = thread::spawn(|| {
172-
/// let d = '1';
173-
///
174167
/// // this panics
175-
/// d.is_digit(37);
168+
/// '1'.is_digit(37);
176169
/// }).join();
177170
///
178171
/// assert!(result.is_err());
@@ -209,25 +202,15 @@ impl char {
209202
/// Basic usage:
210203
///
211204
/// ```
212-
/// let d = '1';
213-
///
214-
/// assert_eq!(d.to_digit(10), Some(1));
215-
///
216-
/// let d = 'f';
217-
///
218-
/// assert_eq!(d.to_digit(16), Some(15));
205+
/// assert_eq!('1'.to_digit(10), Some(1));
206+
/// assert_eq!('f'.to_digit(16), Some(15));
219207
/// ```
220208
///
221209
/// Passing a non-digit results in failure:
222210
///
223211
/// ```
224-
/// let d = 'f';
225-
///
226-
/// assert_eq!(d.to_digit(10), None);
227-
///
228-
/// let d = 'z';
229-
///
230-
/// assert_eq!(d.to_digit(16), None);
212+
/// assert_eq!('f'.to_digit(10), None);
213+
/// assert_eq!('z'.to_digit(16), None);
231214
/// ```
232215
///
233216
/// Passing a large radix, causing a panic:
@@ -236,9 +219,7 @@ impl char {
236219
/// use std::thread;
237220
///
238221
/// let result = thread::spawn(|| {
239-
/// let d = '1';
240-
///
241-
/// d.to_digit(37);
222+
/// '1'.to_digit(37);
242223
/// }).join();
243224
///
244225
/// assert!(result.is_err());
@@ -463,12 +444,8 @@ impl char {
463444
/// Basic usage:
464445
///
465446
/// ```
466-
/// let c = 'a';
467-
///
468-
/// assert!(c.is_alphabetic());
469-
///
470-
/// let c = '京';
471-
/// assert!(c.is_alphabetic());
447+
/// assert!('a'.is_alphabetic());
448+
/// assert!('京'.is_alphabetic());
472449
///
473450
/// let c = '💝';
474451
/// // love is many things, but it is not alphabetic
@@ -522,21 +499,13 @@ impl char {
522499
/// Basic usage:
523500
///
524501
/// ```
525-
/// let c = 'a';
526-
/// assert!(c.is_lowercase());
527-
///
528-
/// let c = 'δ';
529-
/// assert!(c.is_lowercase());
530-
///
531-
/// let c = 'A';
532-
/// assert!(!c.is_lowercase());
533-
///
534-
/// let c = 'Δ';
535-
/// assert!(!c.is_lowercase());
502+
/// assert!('a'.is_lowercase());
503+
/// assert!('δ'.is_lowercase());
504+
/// assert!(!'A'.is_lowercase());
505+
/// assert!(!'Δ'.is_lowercase());
536506
///
537507
/// // The various Chinese scripts do not have case, and so:
538-
/// let c = '中';
539-
/// assert!(!c.is_lowercase());
508+
/// assert!(!'中'.is_lowercase());
540509
/// ```
541510
#[stable(feature = "rust1", since = "1.0.0")]
542511
#[inline]
@@ -558,21 +527,13 @@ impl char {
558527
/// Basic usage:
559528
///
560529
/// ```
561-
/// let c = 'a';
562-
/// assert!(!c.is_uppercase());
563-
///
564-
/// let c = 'δ';
565-
/// assert!(!c.is_uppercase());
566-
///
567-
/// let c = 'A';
568-
/// assert!(c.is_uppercase());
569-
///
570-
/// let c = 'Δ';
571-
/// assert!(c.is_uppercase());
530+
/// assert!(!'a'.is_uppercase());
531+
/// assert!(!'δ'.is_uppercase());
532+
/// assert!('A'.is_uppercase());
533+
/// assert!('Δ'.is_uppercase());
572534
///
573535
/// // The various Chinese scripts do not have case, and so:
574-
/// let c = '中';
575-
/// assert!(!c.is_uppercase());
536+
/// assert!(!'中'.is_uppercase());
576537
/// ```
577538
#[stable(feature = "rust1", since = "1.0.0")]
578539
#[inline]
@@ -594,15 +555,12 @@ impl char {
594555
/// Basic usage:
595556
///
596557
/// ```
597-
/// let c = ' ';
598-
/// assert!(c.is_whitespace());
558+
/// assert!(' '.is_whitespace());
599559
///
600560
/// // a non-breaking space
601-
/// let c = '\u{A0}';
602-
/// assert!(c.is_whitespace());
561+
/// assert!('\u{A0}'.is_whitespace());
603562
///
604-
/// let c = '越';
605-
/// assert!(!c.is_whitespace());
563+
/// assert!(!'越'.is_whitespace());
606564
/// ```
607565
#[stable(feature = "rust1", since = "1.0.0")]
608566
#[inline]
@@ -624,29 +582,14 @@ impl char {
624582
/// Basic usage:
625583
///
626584
/// ```
627-
/// let c = '٣';
628-
/// assert!(c.is_alphanumeric());
629-
///
630-
/// let c = '7';
631-
/// assert!(c.is_alphanumeric());
632-
///
633-
/// let c = '৬';
634-
/// assert!(c.is_alphanumeric());
635-
///
636-
/// let c = 'K';
637-
/// assert!(c.is_alphanumeric());
638-
///
639-
/// let c = 'و';
640-
/// assert!(c.is_alphanumeric());
641-
///
642-
/// let c = '藏';
643-
/// assert!(c.is_alphanumeric());
644-
///
645-
/// let c = '¾';
646-
/// assert!(!c.is_alphanumeric());
647-
///
648-
/// let c = '①';
649-
/// assert!(!c.is_alphanumeric());
585+
/// assert!('٣'.is_alphanumeric());
586+
/// assert!('7'.is_alphanumeric());
587+
/// assert!('৬'.is_alphanumeric());
588+
/// assert!('K'.is_alphanumeric());
589+
/// assert!('و'.is_alphanumeric());
590+
/// assert!('藏'.is_alphanumeric());
591+
/// assert!(!'¾'.is_alphanumeric());
592+
/// assert!(!'①'.is_alphanumeric());
650593
/// ```
651594
#[stable(feature = "rust1", since = "1.0.0")]
652595
#[inline]
@@ -665,11 +608,8 @@ impl char {
665608
///
666609
/// ```
667610
/// // U+009C, STRING TERMINATOR
668-
/// let c = 'œ';
669-
/// assert!(c.is_control());
670-
///
671-
/// let c = 'q';
672-
/// assert!(!c.is_control());
611+
/// assert!('œ'.is_control());
612+
/// assert!(!'q'.is_control());
673613
/// ```
674614
#[stable(feature = "rust1", since = "1.0.0")]
675615
#[inline]
@@ -687,29 +627,14 @@ impl char {
687627
/// Basic usage:
688628
///
689629
/// ```
690-
/// let c = '٣';
691-
/// assert!(c.is_numeric());
692-
///
693-
/// let c = '7';
694-
/// assert!(c.is_numeric());
695-
///
696-
/// let c = '৬';
697-
/// assert!(c.is_numeric());
698-
///
699-
/// let c = 'K';
700-
/// assert!(!c.is_numeric());
701-
///
702-
/// let c = 'و';
703-
/// assert!(!c.is_numeric());
704-
///
705-
/// let c = '藏';
706-
/// assert!(!c.is_numeric());
707-
///
708-
/// let c = '¾';
709-
/// assert!(!c.is_numeric());
710-
///
711-
/// let c = '①';
712-
/// assert!(!c.is_numeric());
630+
/// assert!('٣'.is_numeric());
631+
/// assert!('7'.is_numeric());
632+
/// assert!('৬'.is_numeric());
633+
/// assert!(!'K'.is_numeric());
634+
/// assert!(!'و'.is_numeric());
635+
/// assert!(!'藏'.is_numeric());
636+
/// assert!(!'¾'.is_numeric());
637+
/// assert!(!'①'.is_numeric());
713638
/// ```
714639
#[stable(feature = "rust1", since = "1.0.0")]
715640
#[inline]
@@ -744,13 +669,10 @@ impl char {
744669
/// Basic usage:
745670
///
746671
/// ```
747-
/// let c = 'C';
748-
///
749-
/// assert_eq!(c.to_lowercase().next(), Some('c'));
672+
/// assert_eq!('C'.to_lowercase().next(), Some('c'));
750673
///
751674
/// // Japanese scripts do not have case, and so:
752-
/// let c = '山';
753-
/// assert_eq!(c.to_lowercase().next(), Some('山'));
675+
/// assert_eq!('山'.to_lowercase().next(), Some('山'));
754676
/// ```
755677
#[stable(feature = "rust1", since = "1.0.0")]
756678
#[inline]
@@ -781,12 +703,10 @@ impl char {
781703
/// Basic usage:
782704
///
783705
/// ```
784-
/// let c = 'c';
785-
/// assert_eq!(c.to_uppercase().next(), Some('C'));
706+
/// assert_eq!('c'.to_uppercase().next(), Some('C'));
786707
///
787708
/// // Japanese does not have case, and so:
788-
/// let c = '山';
789-
/// assert_eq!(c.to_uppercase().next(), Some('山'));
709+
/// assert_eq!('山'.to_uppercase().next(), Some('山'));
790710
/// ```
791711
///
792712
/// In Turkish, the equivalent of 'i' in Latin has five forms instead of two:
@@ -797,19 +717,15 @@ impl char {
797717
/// Note that the lowercase dotted 'i' is the same as the Latin. Therefore:
798718
///
799719
/// ```
800-
/// let i = 'i';
801-
///
802-
/// let upper_i = i.to_uppercase().next();
720+
/// let upper_i = 'i'.to_uppercase().next();
803721
/// ```
804722
///
805723
/// The value of `upper_i` here relies on the language of the text: if we're
806724
/// in `en-US`, it should be `Some('I')`, but if we're in `tr_TR`, it should
807725
/// be `Some('İ')`. `to_uppercase()` does not take this into account, and so:
808726
///
809727
/// ```
810-
/// let i = 'i';
811-
///
812-
/// let upper_i = i.to_uppercase().next();
728+
/// let upper_i = 'i'.to_uppercase().next();
813729
///
814730
/// assert_eq!(Some('I'), upper_i);
815731
/// ```

src/librustdoc/html/static/main.js

-2
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,6 @@
742742
if ($(this).val().length === 0) {
743743
if (browserSupportsHistoryApi()) {
744744
history.replaceState("", "std - Rust", "?search=");
745-
} else {
746-
location.replace("?search=");
747745
}
748746
$('#main.content').removeClass('hidden');
749747
$('#search.content').addClass('hidden');

src/libstd/ascii.rs

+6
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,10 @@ mod tests {
567567
&from_u32(lower).unwrap().to_string()));
568568
}
569569
}
570+
571+
#[test]
572+
fn inference_works() {
573+
let x = "a".to_string();
574+
x.eq_ignore_ascii_case("A");
575+
}
570576
}

0 commit comments

Comments
 (0)