Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3b77203

Browse files
committedJul 22, 2018
Auto merge of #52616 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests Successful merges: - #51807 (Deprecation of str::slice_unchecked(_mut)) - #52051 (mem::swap the obvious way for types smaller than the SIMD optimization's block size) - #52465 (Add CI test harness for `thumb*` targets. [IRR-2018-embedded]) - #52507 (Reword when `_` couldn't be inferred) - #52508 (Document that Unique::empty() and NonNull::dangling() aren't sentinel values) - #52521 (Fix links in rustdoc book.) - #52581 (Avoid using `#[macro_export]` for documenting builtin macros) - #52582 (Typo) - #52587 (Add missing backtick in UniversalRegions doc comment) - #52594 (Run the error index tool against the sysroot libdir) - #52615 (Added new lines to .gitignore.)
2 parents 32772fd + b954d4d commit 3b77203

36 files changed

+165
-109
lines changed
 

‎.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,18 @@ __pycache__/
8686
target/
8787
/test/
8888
/tmp/
89+
tags
90+
tags.*
8991
TAGS
90-
TAGS.emacs
91-
TAGS.vi
92+
TAGS.*
9293
\#*
9394
\#*\#
9495
config.mk
9596
config.stamp
9697
keywords.md
9798
lexer.ml
99+
mir_dump
100+
Session.vim
98101
src/etc/dl
99102
tmp.*.rs
100103
version.md

‎src/bootstrap/test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,9 @@ impl Step for Compiletest {
966966
builder.ensure(compile::Rustc { compiler, target });
967967
}
968968

969-
builder.ensure(compile::Test { compiler, target });
969+
if builder.no_std(target) != Some(true) {
970+
builder.ensure(compile::Test { compiler, target });
971+
}
970972
builder.ensure(native::TestHelpers { target });
971973
builder.ensure(RemoteCopyLibs { compiler, target });
972974

‎src/bootstrap/tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn prepare_tool_cargo(
275275

276276
macro_rules! tool {
277277
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
278-
#[derive(Copy, Clone)]
278+
#[derive(Copy, PartialEq, Eq, Clone)]
279279
pub enum Tool {
280280
$(
281281
$name,
@@ -640,7 +640,7 @@ impl<'a> Builder<'a> {
640640
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
641641
let host = &compiler.host;
642642
let mut lib_paths: Vec<PathBuf> = vec![
643-
if compiler.stage == 0 {
643+
if compiler.stage == 0 && tool != Tool::ErrorIndex {
644644
self.build.rustc_snapshot_libdir()
645645
} else {
646646
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))

‎src/ci/docker/dist-various-1/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ RUN \
8080
echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \
8181
echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh
8282

83+
ENV RUN_MAKE_TARGETS=thumbv6m-none-eabi
84+
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7m-none-eabi
85+
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabi
86+
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabihf
87+
8388
ENV TARGETS=asmjs-unknown-emscripten
8489
ENV TARGETS=$TARGETS,wasm32-unknown-emscripten
8590
ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd
@@ -120,7 +125,9 @@ ENV RUST_CONFIGURE_ARGS \
120125
--enable-emscripten \
121126
--disable-docs
122127

123-
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
128+
ENV SCRIPT \
129+
python2.7 ../x.py test --target $RUN_MAKE_TARGETS src/test/run-make && \
130+
python2.7 ../x.py dist --target $TARGETS
124131

125132
# sccache
126133
COPY scripts/sccache.sh /scripts/

‎src/doc/rustdoc/src/passes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Rustdoc has a concept called "passes". These are transformations that
55

66
In addition to the passes below, check out the docs for these flags:
77

8-
* [`--passes`](command-line-arguments.html#--passes-add-more-rustdoc-passes)
9-
* [`--no-defaults`](command-line-arguments.html#--no-defaults-dont-run-default-passes)
8+
* [`--passes`](command-line-arguments.html#a--passes-add-more-rustdoc-passes)
9+
* [`--no-defaults`](command-line-arguments.html#a--no-defaults-dont-run-default-passes)
1010

1111
## Default passes
1212

‎src/liballoc/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ impl str {
268268
let mut result = String::new();
269269
let mut last_end = 0;
270270
for (start, part) in self.match_indices(from) {
271-
result.push_str(unsafe { self.slice_unchecked(last_end, start) });
271+
result.push_str(unsafe { self.get_unchecked(last_end..start) });
272272
result.push_str(to);
273273
last_end = start + part.len();
274274
}
275-
result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) });
275+
result.push_str(unsafe { self.get_unchecked(last_end..self.len()) });
276276
result
277277
}
278278

@@ -309,11 +309,11 @@ impl str {
309309
let mut result = String::with_capacity(32);
310310
let mut last_end = 0;
311311
for (start, part) in self.match_indices(pat).take(count) {
312-
result.push_str(unsafe { self.slice_unchecked(last_end, start) });
312+
result.push_str(unsafe { self.get_unchecked(last_end..start) });
313313
result.push_str(to);
314314
last_end = start + part.len();
315315
}
316-
result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) });
316+
result.push_str(unsafe { self.get_unchecked(last_end..self.len()) });
317317
result
318318
}
319319

‎src/liballoc/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ impl String {
12221222

12231223
while idx < len {
12241224
let ch = unsafe {
1225-
self.slice_unchecked(idx, len).chars().next().unwrap()
1225+
self.get_unchecked(idx..len).chars().next().unwrap()
12261226
};
12271227
let ch_len = ch.len_utf8();
12281228

‎src/liballoc/tests/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ fn test_join_for_different_lengths_with_long_separator() {
177177

178178
#[test]
179179
fn test_unsafe_slice() {
180-
assert_eq!("ab", unsafe {"abc".slice_unchecked(0, 2)});
181-
assert_eq!("bc", unsafe {"abc".slice_unchecked(1, 3)});
182-
assert_eq!("", unsafe {"abc".slice_unchecked(1, 1)});
180+
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
181+
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
182+
assert_eq!("", unsafe {"abc".get_unchecked(1..1)});
183183
fn a_million_letter_a() -> String {
184184
let mut i = 0;
185185
let mut rs = String::new();
@@ -200,7 +200,7 @@ fn test_unsafe_slice() {
200200
}
201201
let letters = a_million_letter_a();
202202
assert_eq!(half_a_million_letter_a(),
203-
unsafe { letters.slice_unchecked(0, 500000)});
203+
unsafe { letters.get_unchecked(0..500000)});
204204
}
205205

206206
#[test]

‎src/libcore/macros.rs

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ macro_rules! unimplemented {
543543
/// into libsyntax itself.
544544
///
545545
/// For more information, see documentation for `std`'s macros.
546+
#[cfg(dox)]
546547
mod builtin {
547548

548549
/// Unconditionally causes compilation to fail with the given error message when encountered.
@@ -551,8 +552,7 @@ mod builtin {
551552
///
552553
/// [`std::compile_error!`]: ../std/macro.compile_error.html
553554
#[stable(feature = "compile_error_macro", since = "1.20.0")]
554-
#[macro_export]
555-
#[cfg(dox)]
555+
#[rustc_doc_only_macro]
556556
macro_rules! compile_error {
557557
($msg:expr) => ({ /* compiler built-in */ });
558558
($msg:expr,) => ({ /* compiler built-in */ });
@@ -564,8 +564,7 @@ mod builtin {
564564
///
565565
/// [`std::format_args!`]: ../std/macro.format_args.html
566566
#[stable(feature = "rust1", since = "1.0.0")]
567-
#[macro_export]
568-
#[cfg(dox)]
567+
#[rustc_doc_only_macro]
569568
macro_rules! format_args {
570569
($fmt:expr) => ({ /* compiler built-in */ });
571570
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
@@ -577,8 +576,7 @@ mod builtin {
577576
///
578577
/// [`std::env!`]: ../std/macro.env.html
579578
#[stable(feature = "rust1", since = "1.0.0")]
580-
#[macro_export]
581-
#[cfg(dox)]
579+
#[rustc_doc_only_macro]
582580
macro_rules! env {
583581
($name:expr) => ({ /* compiler built-in */ });
584582
($name:expr,) => ({ /* compiler built-in */ });
@@ -590,8 +588,7 @@ mod builtin {
590588
///
591589
/// [`std::option_env!`]: ../std/macro.option_env.html
592590
#[stable(feature = "rust1", since = "1.0.0")]
593-
#[macro_export]
594-
#[cfg(dox)]
591+
#[rustc_doc_only_macro]
595592
macro_rules! option_env {
596593
($name:expr) => ({ /* compiler built-in */ });
597594
($name:expr,) => ({ /* compiler built-in */ });
@@ -603,8 +600,7 @@ mod builtin {
603600
///
604601
/// [`std::concat_idents!`]: ../std/macro.concat_idents.html
605602
#[unstable(feature = "concat_idents_macro", issue = "29599")]
606-
#[macro_export]
607-
#[cfg(dox)]
603+
#[rustc_doc_only_macro]
608604
macro_rules! concat_idents {
609605
($($e:ident),+) => ({ /* compiler built-in */ });
610606
($($e:ident,)+) => ({ /* compiler built-in */ });
@@ -616,8 +612,7 @@ mod builtin {
616612
///
617613
/// [`std::concat!`]: ../std/macro.concat.html
618614
#[stable(feature = "rust1", since = "1.0.0")]
619-
#[macro_export]
620-
#[cfg(dox)]
615+
#[rustc_doc_only_macro]
621616
macro_rules! concat {
622617
($($e:expr),*) => ({ /* compiler built-in */ });
623618
($($e:expr,)*) => ({ /* compiler built-in */ });
@@ -629,8 +624,7 @@ mod builtin {
629624
///
630625
/// [`std::line!`]: ../std/macro.line.html
631626
#[stable(feature = "rust1", since = "1.0.0")]
632-
#[macro_export]
633-
#[cfg(dox)]
627+
#[rustc_doc_only_macro]
634628
macro_rules! line { () => ({ /* compiler built-in */ }) }
635629

636630
/// A macro which expands to the column number on which it was invoked.
@@ -639,8 +633,7 @@ mod builtin {
639633
///
640634
/// [`std::column!`]: ../std/macro.column.html
641635
#[stable(feature = "rust1", since = "1.0.0")]
642-
#[macro_export]
643-
#[cfg(dox)]
636+
#[rustc_doc_only_macro]
644637
macro_rules! column { () => ({ /* compiler built-in */ }) }
645638

646639
/// A macro which expands to the file name from which it was invoked.
@@ -649,8 +642,7 @@ mod builtin {
649642
///
650643
/// [`std::file!`]: ../std/macro.file.html
651644
#[stable(feature = "rust1", since = "1.0.0")]
652-
#[macro_export]
653-
#[cfg(dox)]
645+
#[rustc_doc_only_macro]
654646
macro_rules! file { () => ({ /* compiler built-in */ }) }
655647

656648
/// A macro which stringifies its arguments.
@@ -659,8 +651,7 @@ mod builtin {
659651
///
660652
/// [`std::stringify!`]: ../std/macro.stringify.html
661653
#[stable(feature = "rust1", since = "1.0.0")]
662-
#[macro_export]
663-
#[cfg(dox)]
654+
#[rustc_doc_only_macro]
664655
macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
665656

666657
/// Includes a utf8-encoded file as a string.
@@ -669,8 +660,7 @@ mod builtin {
669660
///
670661
/// [`std::include_str!`]: ../std/macro.include_str.html
671662
#[stable(feature = "rust1", since = "1.0.0")]
672-
#[macro_export]
673-
#[cfg(dox)]
663+
#[rustc_doc_only_macro]
674664
macro_rules! include_str {
675665
($file:expr) => ({ /* compiler built-in */ });
676666
($file:expr,) => ({ /* compiler built-in */ });
@@ -682,8 +672,7 @@ mod builtin {
682672
///
683673
/// [`std::include_bytes!`]: ../std/macro.include_bytes.html
684674
#[stable(feature = "rust1", since = "1.0.0")]
685-
#[macro_export]
686-
#[cfg(dox)]
675+
#[rustc_doc_only_macro]
687676
macro_rules! include_bytes {
688677
($file:expr) => ({ /* compiler built-in */ });
689678
($file:expr,) => ({ /* compiler built-in */ });
@@ -695,8 +684,7 @@ mod builtin {
695684
///
696685
/// [`std::module_path!`]: ../std/macro.module_path.html
697686
#[stable(feature = "rust1", since = "1.0.0")]
698-
#[macro_export]
699-
#[cfg(dox)]
687+
#[rustc_doc_only_macro]
700688
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
701689

702690
/// Boolean evaluation of configuration flags, at compile-time.
@@ -705,8 +693,7 @@ mod builtin {
705693
///
706694
/// [`std::cfg!`]: ../std/macro.cfg.html
707695
#[stable(feature = "rust1", since = "1.0.0")]
708-
#[macro_export]
709-
#[cfg(dox)]
696+
#[rustc_doc_only_macro]
710697
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
711698

712699
/// Parse a file as an expression or an item according to the context.
@@ -715,8 +702,7 @@ mod builtin {
715702
///
716703
/// [`std::include!`]: ../std/macro.include.html
717704
#[stable(feature = "rust1", since = "1.0.0")]
718-
#[macro_export]
719-
#[cfg(dox)]
705+
#[rustc_doc_only_macro]
720706
macro_rules! include {
721707
($file:expr) => ({ /* compiler built-in */ });
722708
($file:expr,) => ({ /* compiler built-in */ });
@@ -727,9 +713,8 @@ mod builtin {
727713
/// For more information, see the documentation for [`std::assert!`].
728714
///
729715
/// [`std::assert!`]: ../std/macro.assert.html
730-
#[macro_export]
716+
#[rustc_doc_only_macro]
731717
#[stable(feature = "rust1", since = "1.0.0")]
732-
#[cfg(dox)]
733718
macro_rules! assert {
734719
($cond:expr) => ({ /* compiler built-in */ });
735720
($cond:expr,) => ({ /* compiler built-in */ });

‎src/libcore/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ pub unsafe fn uninitialized<T>() -> T {
638638
#[stable(feature = "rust1", since = "1.0.0")]
639639
pub fn swap<T>(x: &mut T, y: &mut T) {
640640
unsafe {
641-
ptr::swap_nonoverlapping(x, y, 1);
641+
ptr::swap_nonoverlapping_one(x, y);
642642
}
643643
}
644644

‎src/libcore/ptr.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
187187
swap_nonoverlapping_bytes(x, y, len)
188188
}
189189

190+
#[inline]
191+
pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
192+
// For types smaller than the block optimization below,
193+
// just swap directly to avoid pessimizing codegen.
194+
if mem::size_of::<T>() < 32 {
195+
let z = read(x);
196+
copy_nonoverlapping(y, x, 1);
197+
write(y, z);
198+
} else {
199+
swap_nonoverlapping(x, y, 1);
200+
}
201+
}
202+
190203
#[inline]
191204
unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
192205
// The approach here is to utilize simd to swap x & y efficiently. Testing reveals
@@ -2703,6 +2716,11 @@ impl<T: Sized> Unique<T> {
27032716
///
27042717
/// This is useful for initializing types which lazily allocate, like
27052718
/// `Vec::new` does.
2719+
///
2720+
/// Note that the pointer value may potentially represent a valid pointer to
2721+
/// a `T`, which means this must not be used as a "not yet initialized"
2722+
/// sentinel value. Types that lazily allocate must track initialization by
2723+
/// some other means.
27062724
// FIXME: rename to dangling() to match NonNull?
27072725
pub const fn empty() -> Self {
27082726
unsafe {
@@ -2834,6 +2852,11 @@ impl<T: Sized> NonNull<T> {
28342852
///
28352853
/// This is useful for initializing types which lazily allocate, like
28362854
/// `Vec::new` does.
2855+
///
2856+
/// Note that the pointer value may potentially represent a valid pointer to
2857+
/// a `T`, which means this must not be used as a "not yet initialized"
2858+
/// sentinel value. Types that lazily allocate must track initialization by
2859+
/// some other means.
28372860
#[stable(feature = "nonnull", since = "1.25.0")]
28382861
pub fn dangling() -> Self {
28392862
unsafe {

‎src/libcore/str/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10551055
if !self.finished && (self.allow_trailing_empty || self.end - self.start > 0) {
10561056
self.finished = true;
10571057
unsafe {
1058-
let string = self.matcher.haystack().slice_unchecked(self.start, self.end);
1058+
let string = self.matcher.haystack().get_unchecked(self.start..self.end);
10591059
Some(string)
10601060
}
10611061
} else {
@@ -1070,7 +1070,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10701070
let haystack = self.matcher.haystack();
10711071
match self.matcher.next_match() {
10721072
Some((a, b)) => unsafe {
1073-
let elt = haystack.slice_unchecked(self.start, a);
1073+
let elt = haystack.get_unchecked(self.start..a);
10741074
self.start = b;
10751075
Some(elt)
10761076
},
@@ -1095,13 +1095,13 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10951095
let haystack = self.matcher.haystack();
10961096
match self.matcher.next_match_back() {
10971097
Some((a, b)) => unsafe {
1098-
let elt = haystack.slice_unchecked(b, self.end);
1098+
let elt = haystack.get_unchecked(b..self.end);
10991099
self.end = a;
11001100
Some(elt)
11011101
},
11021102
None => unsafe {
11031103
self.finished = true;
1104-
Some(haystack.slice_unchecked(self.start, self.end))
1104+
Some(haystack.get_unchecked(self.start..self.end))
11051105
},
11061106
}
11071107
}
@@ -1222,7 +1222,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
12221222
#[inline]
12231223
fn next(&mut self) -> Option<(usize, &'a str)> {
12241224
self.0.next_match().map(|(start, end)| unsafe {
1225-
(start, self.0.haystack().slice_unchecked(start, end))
1225+
(start, self.0.haystack().get_unchecked(start..end))
12261226
})
12271227
}
12281228

@@ -1231,7 +1231,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
12311231
where P::Searcher: ReverseSearcher<'a>
12321232
{
12331233
self.0.next_match_back().map(|(start, end)| unsafe {
1234-
(start, self.0.haystack().slice_unchecked(start, end))
1234+
(start, self.0.haystack().get_unchecked(start..end))
12351235
})
12361236
}
12371237
}
@@ -1274,7 +1274,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
12741274
fn next(&mut self) -> Option<&'a str> {
12751275
self.0.next_match().map(|(a, b)| unsafe {
12761276
// Indices are known to be on utf8 boundaries
1277-
self.0.haystack().slice_unchecked(a, b)
1277+
self.0.haystack().get_unchecked(a..b)
12781278
})
12791279
}
12801280

@@ -1284,7 +1284,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
12841284
{
12851285
self.0.next_match_back().map(|(a, b)| unsafe {
12861286
// Indices are known to be on utf8 boundaries
1287-
self.0.haystack().slice_unchecked(a, b)
1287+
self.0.haystack().get_unchecked(a..b)
12881288
})
12891289
}
12901290
}
@@ -2453,6 +2453,7 @@ impl str {
24532453
/// }
24542454
/// ```
24552455
#[stable(feature = "rust1", since = "1.0.0")]
2456+
#[rustc_deprecated(since = "1.29.0", reason = "use `get_unchecked(begin..end)` instead")]
24562457
#[inline]
24572458
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str {
24582459
(begin..end).get_unchecked(self)
@@ -2483,6 +2484,7 @@ impl str {
24832484
/// * `begin` and `end` must be byte positions within the string slice.
24842485
/// * `begin` and `end` must lie on UTF-8 sequence boundaries.
24852486
#[stable(feature = "str_slice_mut", since = "1.5.0")]
2487+
#[rustc_deprecated(since = "1.29.0", reason = "use `get_unchecked_mut(begin..end)` instead")]
24862488
#[inline]
24872489
pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str {
24882490
(begin..end).get_unchecked_mut(self)
@@ -2524,8 +2526,8 @@ impl str {
25242526
// is_char_boundary checks that the index is in [0, .len()]
25252527
if self.is_char_boundary(mid) {
25262528
unsafe {
2527-
(self.slice_unchecked(0, mid),
2528-
self.slice_unchecked(mid, self.len()))
2529+
(self.get_unchecked(0..mid),
2530+
self.get_unchecked(mid..self.len()))
25292531
}
25302532
} else {
25312533
slice_error_fail(self, 0, mid)
@@ -3702,7 +3704,7 @@ impl str {
37023704
}
37033705
unsafe {
37043706
// Searcher is known to return valid indices
3705-
self.slice_unchecked(i, j)
3707+
self.get_unchecked(i..j)
37063708
}
37073709
}
37083710

@@ -3741,7 +3743,7 @@ impl str {
37413743
}
37423744
unsafe {
37433745
// Searcher is known to return valid indices
3744-
self.slice_unchecked(i, self.len())
3746+
self.get_unchecked(i..self.len())
37453747
}
37463748
}
37473749

@@ -3788,7 +3790,7 @@ impl str {
37883790
}
37893791
unsafe {
37903792
// Searcher is known to return valid indices
3791-
self.slice_unchecked(0, j)
3793+
self.get_unchecked(0..j)
37923794
}
37933795
}
37943796

‎src/libcore/str/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
354354
#[inline]
355355
fn next_back(&mut self) -> SearchStep {
356356
let old_finger = self.finger_back;
357-
let slice = unsafe { self.haystack.slice_unchecked(self.finger, old_finger) };
357+
let slice = unsafe { self.haystack.get_unchecked(self.finger..old_finger) };
358358
let mut iter = slice.chars();
359359
let old_len = iter.iter.len();
360360
if let Some(ch) = iter.next_back() {

‎src/librustc/hir/lowering.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3191,7 +3191,8 @@ impl<'a> LoweringContext<'a> {
31913191
let mut vis = self.lower_visibility(&i.vis, None);
31923192
let attrs = self.lower_attrs(&i.attrs);
31933193
if let ItemKind::MacroDef(ref def) = i.node {
3194-
if !def.legacy || attr::contains_name(&i.attrs, "macro_export") {
3194+
if !def.legacy || attr::contains_name(&i.attrs, "macro_export") ||
3195+
attr::contains_name(&i.attrs, "rustc_doc_only_macro") {
31953196
let body = self.lower_token_stream(def.stream());
31963197
self.exported_macros.push(hir::MacroDef {
31973198
name,

‎src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
9797
let name = self.extract_type_name(&ty);
9898

9999
let mut err_span = span;
100-
let mut labels = vec![(span, format!("cannot infer type for `{}`", name))];
100+
let mut labels = vec![(
101+
span,
102+
if &name == "_" {
103+
"cannot infer type".to_string()
104+
} else {
105+
format!("cannot infer type for `{}`", name)
106+
},
107+
)];
101108

102109
let mut local_visitor = FindLocalByTypeVisitor {
103110
infcx: &self,

‎src/librustc_mir/borrow_check/nll/universal_regions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct UniversalRegions<'tcx> {
5757
/// externals, then locals. So things from:
5858
/// - `FIRST_GLOBAL_INDEX..first_extern_index` are global;
5959
/// - `first_extern_index..first_local_index` are external; and
60-
/// - first_local_index..num_universals` are local.
60+
/// - `first_local_index..num_universals` are local.
6161
first_extern_index: usize,
6262

6363
/// See `first_extern_index`.

‎src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,15 +1273,13 @@ fn macro_resolve(cx: &DocContext, path_str: &str) -> Option<Def> {
12731273
.resolve_macro_to_def_inner(mark, &path, MacroKind::Bang, false);
12741274
if let Ok(def) = res {
12751275
if let SyntaxExtension::DeclMacro { .. } = *resolver.get_macro(def) {
1276-
Some(def)
1277-
} else {
1278-
None
1276+
return Some(def);
12791277
}
1280-
} else if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) {
1281-
Some(*def)
1282-
} else {
1283-
None
12841278
}
1279+
if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) {
1280+
return Some(*def);
1281+
}
1282+
None
12851283
}
12861284

12871285
#[derive(Debug)]

‎src/libstd/macros.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ macro_rules! assert_approx_eq {
317317
/// macro, but are documented here. Their implementations can be found hardcoded
318318
/// into libsyntax itself.
319319
#[cfg(dox)]
320-
pub mod builtin {
320+
mod builtin {
321321

322322
/// Unconditionally causes compilation to fail with the given error message when encountered.
323323
///
@@ -355,7 +355,7 @@ pub mod builtin {
355355
///
356356
/// [`panic!`]: ../std/macro.panic.html
357357
#[stable(feature = "compile_error_macro", since = "1.20.0")]
358-
#[macro_export]
358+
#[rustc_doc_only_macro]
359359
macro_rules! compile_error {
360360
($msg:expr) => ({ /* compiler built-in */ });
361361
($msg:expr,) => ({ /* compiler built-in */ });
@@ -407,7 +407,7 @@ pub mod builtin {
407407
/// assert_eq!(s, format!("hello {}", "world"));
408408
/// ```
409409
#[stable(feature = "rust1", since = "1.0.0")]
410-
#[macro_export]
410+
#[rustc_doc_only_macro]
411411
macro_rules! format_args {
412412
($fmt:expr) => ({ /* compiler built-in */ });
413413
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
@@ -445,7 +445,7 @@ pub mod builtin {
445445
/// error: what's that?!
446446
/// ```
447447
#[stable(feature = "rust1", since = "1.0.0")]
448-
#[macro_export]
448+
#[rustc_doc_only_macro]
449449
macro_rules! env {
450450
($name:expr) => ({ /* compiler built-in */ });
451451
($name:expr,) => ({ /* compiler built-in */ });
@@ -471,7 +471,7 @@ pub mod builtin {
471471
/// println!("the secret key might be: {:?}", key);
472472
/// ```
473473
#[stable(feature = "rust1", since = "1.0.0")]
474-
#[macro_export]
474+
#[rustc_doc_only_macro]
475475
macro_rules! option_env {
476476
($name:expr) => ({ /* compiler built-in */ });
477477
($name:expr,) => ({ /* compiler built-in */ });
@@ -502,7 +502,7 @@ pub mod builtin {
502502
/// # }
503503
/// ```
504504
#[unstable(feature = "concat_idents_macro", issue = "29599")]
505-
#[macro_export]
505+
#[rustc_doc_only_macro]
506506
macro_rules! concat_idents {
507507
($($e:ident),+) => ({ /* compiler built-in */ });
508508
($($e:ident,)+) => ({ /* compiler built-in */ });
@@ -524,7 +524,7 @@ pub mod builtin {
524524
/// assert_eq!(s, "test10btrue");
525525
/// ```
526526
#[stable(feature = "rust1", since = "1.0.0")]
527-
#[macro_export]
527+
#[rustc_doc_only_macro]
528528
macro_rules! concat {
529529
($($e:expr),*) => ({ /* compiler built-in */ });
530530
($($e:expr,)*) => ({ /* compiler built-in */ });
@@ -552,7 +552,7 @@ pub mod builtin {
552552
/// println!("defined on line: {}", current_line);
553553
/// ```
554554
#[stable(feature = "rust1", since = "1.0.0")]
555-
#[macro_export]
555+
#[rustc_doc_only_macro]
556556
macro_rules! line { () => ({ /* compiler built-in */ }) }
557557

558558
/// A macro which expands to the column number on which it was invoked.
@@ -577,7 +577,7 @@ pub mod builtin {
577577
/// println!("defined on column: {}", current_col);
578578
/// ```
579579
#[stable(feature = "rust1", since = "1.0.0")]
580-
#[macro_export]
580+
#[rustc_doc_only_macro]
581581
macro_rules! column { () => ({ /* compiler built-in */ }) }
582582

583583
/// A macro which expands to the file name from which it was invoked.
@@ -601,7 +601,7 @@ pub mod builtin {
601601
/// println!("defined in file: {}", this_file);
602602
/// ```
603603
#[stable(feature = "rust1", since = "1.0.0")]
604-
#[macro_export]
604+
#[rustc_doc_only_macro]
605605
macro_rules! file { () => ({ /* compiler built-in */ }) }
606606

607607
/// A macro which stringifies its arguments.
@@ -620,7 +620,7 @@ pub mod builtin {
620620
/// assert_eq!(one_plus_one, "1 + 1");
621621
/// ```
622622
#[stable(feature = "rust1", since = "1.0.0")]
623-
#[macro_export]
623+
#[rustc_doc_only_macro]
624624
macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
625625

626626
/// Includes a utf8-encoded file as a string.
@@ -654,7 +654,7 @@ pub mod builtin {
654654
///
655655
/// Compiling 'main.rs' and running the resulting binary will print "adiós".
656656
#[stable(feature = "rust1", since = "1.0.0")]
657-
#[macro_export]
657+
#[rustc_doc_only_macro]
658658
macro_rules! include_str {
659659
($file:expr) => ({ /* compiler built-in */ });
660660
($file:expr,) => ({ /* compiler built-in */ });
@@ -691,7 +691,7 @@ pub mod builtin {
691691
///
692692
/// Compiling 'main.rs' and running the resulting binary will print "adiós".
693693
#[stable(feature = "rust1", since = "1.0.0")]
694-
#[macro_export]
694+
#[rustc_doc_only_macro]
695695
macro_rules! include_bytes {
696696
($file:expr) => ({ /* compiler built-in */ });
697697
($file:expr,) => ({ /* compiler built-in */ });
@@ -715,7 +715,7 @@ pub mod builtin {
715715
/// test::foo();
716716
/// ```
717717
#[stable(feature = "rust1", since = "1.0.0")]
718-
#[macro_export]
718+
#[rustc_doc_only_macro]
719719
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
720720

721721
/// Boolean evaluation of configuration flags, at compile-time.
@@ -737,7 +737,7 @@ pub mod builtin {
737737
/// };
738738
/// ```
739739
#[stable(feature = "rust1", since = "1.0.0")]
740-
#[macro_export]
740+
#[rustc_doc_only_macro]
741741
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
742742

743743
/// Parse a file as an expression or an item according to the context.
@@ -780,7 +780,7 @@ pub mod builtin {
780780
/// Compiling 'main.rs' and running the resulting binary will print
781781
/// "🙈🙊🙉🙈🙊🙉".
782782
#[stable(feature = "rust1", since = "1.0.0")]
783-
#[macro_export]
783+
#[rustc_doc_only_macro]
784784
macro_rules! include {
785785
($file:expr) => ({ /* compiler built-in */ });
786786
($file:expr,) => ({ /* compiler built-in */ });
@@ -833,7 +833,7 @@ pub mod builtin {
833833
/// assert!(a + b == 30, "a = {}, b = {}", a, b);
834834
/// ```
835835
#[stable(feature = "rust1", since = "1.0.0")]
836-
#[macro_export]
836+
#[rustc_doc_only_macro]
837837
macro_rules! assert {
838838
($cond:expr) => ({ /* compiler built-in */ });
839839
($cond:expr,) => ({ /* compiler built-in */ });

‎src/libstd/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ impl Path {
18361836
/// * On Unix, a path has a root if it begins with `/`.
18371837
///
18381838
/// * On Windows, a path has a root if it:
1839-
/// * has no prefix and begins with a separator, e.g. `\\windows`
1839+
/// * has no prefix and begins with a separator, e.g. `\windows`
18401840
/// * has a prefix followed by a separator, e.g. `c:\windows` but not `c:windows`
18411841
/// * has any non-disk prefix, e.g. `\\server\share`
18421842
///

‎src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ pub fn deprecated_attributes() -> Vec<&'static (&'static str, AttributeType, Att
687687
}
688688

689689
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
690-
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name))
690+
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) ||
691+
attr.name().as_str().starts_with("rustc_")
691692
}
692693

693694
// Attributes that have a special meaning to rustc or rustdoc

‎src/test/codegen/swap-small-types.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -O
12+
// only-x86_64
13+
14+
#![crate_type = "lib"]
15+
16+
use std::mem::swap;
17+
18+
type RGB48 = [u16; 3];
19+
20+
// CHECK-LABEL: @swap_rgb48
21+
#[no_mangle]
22+
pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) {
23+
// CHECK-NOT: alloca
24+
// CHECK: load i48
25+
// CHECK: store i48
26+
swap(x, y)
27+
}

‎src/test/ui/error-codes/E0282.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x = "hello".chars().rev().collect(); //~ ERROR E0282
55
| ^
66
| |
7-
| cannot infer type for `_`
7+
| cannot infer type
88
| consider giving `x` a type
99

1010
error: aborting due to previous error

‎src/test/ui/issue-12187-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let &v = new();
55
| -^
66
| ||
7-
| |cannot infer type for `_`
7+
| |cannot infer type
88
| consider giving the pattern a type
99

1010
error: aborting due to previous error

‎src/test/ui/issue-12187-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let &v = new();
55
| -^
66
| ||
7-
| |cannot infer type for `_`
7+
| |cannot infer type
88
| consider giving the pattern a type
99

1010
error: aborting due to previous error

‎src/test/ui/issue-15965.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | / { return () }
55
LL | | //~^ ERROR type annotations needed [E0282]
66
LL | | ()
7-
| |______^ cannot infer type for `_`
7+
| |______^ cannot infer type
88
|
99
= note: type must be known at this point
1010

‎src/test/ui/issue-18159.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x; //~ ERROR type annotations needed
55
| ^
66
| |
7-
| cannot infer type for `_`
7+
| cannot infer type
88
| consider giving `x` a type
99

1010
error: aborting due to previous error

‎src/test/ui/issue-20261.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | for (ref i,) in [].iter() {
55
| --------- the element type for this iterator is not specified
66
LL | i.clone();
7-
| ^^^^^ cannot infer type for `_`
7+
| ^^^^^ cannot infer type
88
|
99
= note: type must be known at this point
1010

‎src/test/ui/issue-2151.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x = panic!();
55
| - consider giving `x` a type
66
LL | x.clone(); //~ ERROR type annotations needed
7-
| ^ cannot infer type for `_`
7+
| ^ cannot infer type
88
|
99
= note: type must be known at this point
1010

‎src/test/ui/issue-23041.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/issue-23041.rs:16:22
33
|
44
LL | b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
5-
| ^^^^^^^^ cannot infer type for `_`
5+
| ^^^^^^^^ cannot infer type
66

77
error: aborting due to previous error
88

‎src/test/ui/issue-24013.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/issue-24013.rs:15:20
33
|
44
LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))};
5-
| ^^^^^^ cannot infer type for `_`
5+
| ^^^^^^ cannot infer type
66

77
error: aborting due to previous error
88

‎src/test/ui/issue-51116.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
//~^ NOTE the element type for this iterator is not specified
1616
*tile = 0;
1717
//~^ ERROR type annotations needed
18-
//~| NOTE cannot infer type for `_`
18+
//~| NOTE cannot infer type
1919
//~| NOTE type must be known at this point
2020
}
2121
}

‎src/test/ui/issue-51116.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for tile in row {
55
| --- the element type for this iterator is not specified
66
LL | //~^ NOTE the element type for this iterator is not specified
77
LL | *tile = 0;
8-
| ^^^^^ cannot infer type for `_`
8+
| ^^^^^ cannot infer type
99
|
1010
= note: type must be known at this point
1111

‎src/test/ui/issue-7813.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/issue-7813.rs:12:13
33
|
44
LL | let v = &[]; //~ ERROR type annotations needed
5-
| - ^^^ cannot infer type for `_`
5+
| - ^^^ cannot infer type
66
| |
77
| consider giving `v` a type
88

‎src/test/ui/span/issue-42234-unknown-receiver-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error[E0282]: type annotations needed
1313
|
1414
LL | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed
1515
LL | | .sum::<_>()
16-
| |___________________^ cannot infer type for `_`
16+
| |___________________^ cannot infer type
1717
|
1818
= note: type must be known at this point
1919

‎src/test/ui/span/method-and-field-eager-resolution.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let mut x = Default::default();
55
| ----- consider giving `x` a type
66
LL | x.0;
7-
| ^ cannot infer type for `_`
7+
| ^ cannot infer type
88
|
99
= note: type must be known at this point
1010

@@ -14,7 +14,7 @@ error[E0282]: type annotations needed
1414
LL | let mut x = Default::default();
1515
| ----- consider giving `x` a type
1616
LL | x[0];
17-
| ^ cannot infer type for `_`
17+
| ^ cannot infer type
1818
|
1919
= note: type must be known at this point
2020

‎src/test/ui/type-check/cannot_infer_local_or_array.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/cannot_infer_local_or_array.rs:12:13
33
|
44
LL | let x = []; //~ ERROR type annotations needed
5-
| - ^^ cannot infer type for `_`
5+
| - ^^ cannot infer type
66
| |
77
| consider giving `x` a type
88

0 commit comments

Comments
 (0)
Please sign in to comment.