diff --git a/RELEASES.md b/RELEASES.md index 1f7ffb53d3cad..088d361b7ea6a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,78 @@ +Version 1.29.0 (2018-09-13) +========================== + +Compiler +-------- +- [Bumped minimum LLVM version to 5.0.][51899] +- [Added `powerpc64le-unknown-linux-musl` target.][51619] +- [Added `aarch64-unknown-hermit` and `x86_64-unknown-hermit` targets.][52861] + +Libraries +--------- +- [`Once::call_once` now no longer requires `Once` to be `'static`.][52239] +- [`BuildHasherDefault` now implements `PartialEq` and `Eq`.][52402] +- [`Box`, `Box`, and `Box` now implement `Clone`.][51912] +- [Implemented `PartialEq<&str>` for `OsString` and `PartialEq` + for `&str`.][51178] +- [`Cell` now allows `T` to be unsized.][50494] +- [`SocketAddr` is now stable on Redox.][52656] + +Stabilized APIs +--------------- +- [`Arc::downcast`] +- [`Iterator::flatten`] +- [`Rc::downcast`] + +Cargo +----- +- [Cargo can silently fix some bad lockfiles ][cargo/5831] You can use + `--locked` to disable this behaviour. +- [`cargo-install` will now allow you to cross compile an install + using `--target`][cargo/5614] +- [Added the `cargo-fix` subcommand to automatically move project code from + 2015 edition to 2018.][cargo/5723] + +Misc +---- +- [`rustdoc` now has the `--cap-lints` option which demotes all lints above + the specified level to that level.][52354] For example `--cap-lints warn` + will demote `deny` and `forbid` lints to `warn`. +- [`rustc` and `rustdoc` will now have the exit code of `1` if compilation + fails, and `101` if there is a panic.][52197] + +Compatibility Notes +------------------- +- [`str::{slice_unchecked, slice_unchecked_mut}` are now deprecated.][51807] + Use `str::get_unchecked(begin..end)` instead. +- [`std::env::home_dir` is now deprecated for its unintuitive behaviour.][51656] + Consider using the `home_dir` function from + https://crates.io/crates/dirs instead. +- [`rustc` will no longer silently ignore invalid data in target spec.][52330] + +[52861]: https://github.com/rust-lang/rust/pull/52861/ +[52656]: https://github.com/rust-lang/rust/pull/52656/ +[52239]: https://github.com/rust-lang/rust/pull/52239/ +[52330]: https://github.com/rust-lang/rust/pull/52330/ +[52354]: https://github.com/rust-lang/rust/pull/52354/ +[52402]: https://github.com/rust-lang/rust/pull/52402/ +[52103]: https://github.com/rust-lang/rust/pull/52103/ +[52197]: https://github.com/rust-lang/rust/pull/52197/ +[51807]: https://github.com/rust-lang/rust/pull/51807/ +[51899]: https://github.com/rust-lang/rust/pull/51899/ +[51912]: https://github.com/rust-lang/rust/pull/51912/ +[51511]: https://github.com/rust-lang/rust/pull/51511/ +[51619]: https://github.com/rust-lang/rust/pull/51619/ +[51656]: https://github.com/rust-lang/rust/pull/51656/ +[51178]: https://github.com/rust-lang/rust/pull/51178/ +[50494]: https://github.com/rust-lang/rust/pull/50494/ +[cargo/5614]: https://github.com/rust-lang/cargo/pull/5614/ +[cargo/5723]: https://github.com/rust-lang/cargo/pull/5723/ +[cargo/5831]: https://github.com/rust-lang/cargo/pull/5831/ +[`Arc::downcast`]: https://doc.rust-lang.org/std/sync/struct.Arc.html#method.downcast +[`Iterator::flatten`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.flatten +[`Rc::downcast`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.downcast + + Version 1.28.0 (2018-08-02) =========================== diff --git a/src/ci/docker/scripts/musl.sh b/src/ci/docker/scripts/musl.sh index 4ca7389d6d1a5..e6a48a96da464 100644 --- a/src/ci/docker/scripts/musl.sh +++ b/src/ci/docker/scripts/musl.sh @@ -32,7 +32,7 @@ shift export CFLAGS="-fPIC $CFLAGS" -# FIXME: remove the patch when upate to 1.1.20 +# FIXME: remove the patch when updating to 1.1.20 MUSL=musl-1.1.19 # may have been downloaded in a previous run diff --git a/src/doc/index.md b/src/doc/index.md index 3a4f51069fc3b..11313ba99e1a6 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -34,7 +34,7 @@ minimum. It also includes exercises! # Use Rust -Once you've gotten familliar with the language, these resources can help you +Once you've gotten familiar with the language, these resources can help you when you're actually using it day-to-day. ## The Standard Library diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index eff09428902e8..4fc5f42dd5527 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -153,7 +153,7 @@ This option allows you to put extra data in each output filename. This flag lets you control how many threads are used when doing code generation. -Increasing paralellism may speed up compile times, but may also +Increasing parallelism may speed up compile times, but may also produce slower code. ## remark diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 3a85a40fd1fdb..ff9e0235a0435 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -56,7 +56,7 @@ mod m { pub struct S(u8); fn f() { - // this is trying to use S from the 'use' line, but becuase the `u8` is + // this is trying to use S from the 'use' line, but because the `u8` is // not pub, it is private ::S; } @@ -103,7 +103,7 @@ This warning can always be fixed by removing the unused pattern in the ## mutable-transmutes -This lint catches transmuting from `&T` to `&mut T` becuase it is undefined +This lint catches transmuting from `&T` to `&mut T` because it is undefined behavior. Some example code that triggers this lint: ```rust,ignore diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 7f110d6a3d22c..a91c2cd71cde3 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -1,6 +1,6 @@ # Unstable features -Rustdoc is under active developement, and like the Rust compiler, some features are only available +Rustdoc is under active development, and like the Rust compiler, some features are only available on the nightly releases. Some of these are new and need some more testing before they're able to get released to the world at large, and some of them are tied to features in the Rust compiler that are themselves unstable. Several features here require a matching `#![feature(...)]` attribute to diff --git a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md index 73c7eafdb98d5..fe82f8555da32 100644 --- a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md +++ b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md @@ -6,12 +6,12 @@ The tracking issue for this feature is: [#44493] ------------------------ The `infer_outlives_requirements` feature indicates that certain -outlives requirements can be infered by the compiler rather than +outlives requirements can be inferred by the compiler rather than stating them explicitly. For example, currently generic struct definitions that contain references, require where-clauses of the form T: 'a. By using -this feature the outlives predicates will be infered, although +this feature the outlives predicates will be inferred, although they may still be written explicitly. ```rust,ignore (pseudo-Rust) diff --git a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md index f50472fb41e31..6187f395b0498 100644 --- a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md +++ b/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md @@ -6,7 +6,7 @@ The tracking issue for this feature is: [#44493] ------------------------ The `infer_static_outlives_requirements` feature indicates that certain -`'static` outlives requirements can be infered by the compiler rather than +`'static` outlives requirements can be inferred by the compiler rather than stating them explicitly. Note: It is an accompanying feature to `infer_outlives_requirements`, @@ -14,7 +14,7 @@ which must be enabled to infer outlives requirements. For example, currently generic struct definitions that contain references, require where-clauses of the form T: 'static. By using -this feature the outlives predicates will be infered, although +this feature the outlives predicates will be inferred, although they may still be written explicitly. ```rust,ignore (pseudo-Rust) diff --git a/src/doc/unstable-book/src/language-features/macro-vis-matcher.md b/src/doc/unstable-book/src/language-features/macro-vis-matcher.md deleted file mode 100644 index 7918a35684329..0000000000000 --- a/src/doc/unstable-book/src/language-features/macro-vis-matcher.md +++ /dev/null @@ -1,14 +0,0 @@ -# `macro_vis_matcher` - -The tracking issue for this feature is: [#41022] - -With this feature gate enabled, the [list of fragment specifiers][frags] gains one more entry: - -* `vis`: a visibility qualifier. Examples: nothing (default visibility); `pub`; `pub(crate)`. - -A `vis` variable may be followed by a comma, ident, type, or path. - -[#41022]: https://github.com/rust-lang/rust/issues/41022 -[frags]: ../book/first-edition/macros.html#syntactic-requirements - ------------------------- diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 19ece09509078..b408d5d080515 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -183,7 +183,6 @@ that warns about any item named `lintme`. ```rust,ignore #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] #![feature(macro_at_most_once_rep)] extern crate syntax; diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index c69b2fb5e1c2a..3bd0c243b39ac 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -245,7 +245,7 @@ mod tests { .unwrap_or_else(|_| handle_alloc_error(layout)); let mut i = ptr.cast::().as_ptr(); - let end = i.offset(layout.size() as isize); + let end = i.add(layout.size()); while i < end { assert_eq!(*i, 0); i = i.offset(1); diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 08db5136d0404..32292e61f94d2 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -126,7 +126,9 @@ impl Box { Box(Unique::new_unchecked(raw)) } - /// Consumes the `Box`, returning the wrapped raw pointer. + /// Consumes the `Box`, returning a wrapped raw pointer. + /// + /// The pointer will be properly aligned and non-null. /// /// After calling this function, the caller is responsible for the /// memory previously managed by the `Box`. In particular, the @@ -704,7 +706,7 @@ impl Clone for Box<[T]> { impl Drop for BoxBuilder { fn drop(&mut self) { let mut data = self.data.ptr(); - let max = unsafe { data.offset(self.len as isize) }; + let max = unsafe { data.add(self.len) }; while data != max { unsafe { diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 0ae45b3123259..0315545262b6b 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -1151,12 +1151,12 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::KV> let new_len = self.node.len() - self.idx - 1; ptr::copy_nonoverlapping( - self.node.keys().as_ptr().offset(self.idx as isize + 1), + self.node.keys().as_ptr().add(self.idx + 1), new_node.keys.as_mut_ptr(), new_len ); ptr::copy_nonoverlapping( - self.node.vals().as_ptr().offset(self.idx as isize + 1), + self.node.vals().as_ptr().add(self.idx + 1), new_node.vals.as_mut_ptr(), new_len ); @@ -1209,17 +1209,17 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: let new_len = self.node.len() - self.idx - 1; ptr::copy_nonoverlapping( - self.node.keys().as_ptr().offset(self.idx as isize + 1), + self.node.keys().as_ptr().add(self.idx + 1), new_node.data.keys.as_mut_ptr(), new_len ); ptr::copy_nonoverlapping( - self.node.vals().as_ptr().offset(self.idx as isize + 1), + self.node.vals().as_ptr().add(self.idx + 1), new_node.data.vals.as_mut_ptr(), new_len ); ptr::copy_nonoverlapping( - self.node.as_internal().edges.as_ptr().offset(self.idx as isize + 1), + self.node.as_internal().edges.as_ptr().add(self.idx + 1), new_node.edges.as_mut_ptr(), new_len + 1 ); @@ -1283,14 +1283,14 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: slice_remove(self.node.keys_mut(), self.idx)); ptr::copy_nonoverlapping( right_node.keys().as_ptr(), - left_node.keys_mut().as_mut_ptr().offset(left_len as isize + 1), + left_node.keys_mut().as_mut_ptr().add(left_len + 1), right_len ); ptr::write(left_node.vals_mut().get_unchecked_mut(left_len), slice_remove(self.node.vals_mut(), self.idx)); ptr::copy_nonoverlapping( right_node.vals().as_ptr(), - left_node.vals_mut().as_mut_ptr().offset(left_len as isize + 1), + left_node.vals_mut().as_mut_ptr().add(left_len + 1), right_len ); @@ -1309,7 +1309,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: .as_internal_mut() .edges .as_mut_ptr() - .offset(left_len as isize + 1), + .add(left_len + 1), right_len + 1 ); @@ -1394,10 +1394,10 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: // Make room for stolen elements in the right child. ptr::copy(right_kv.0, - right_kv.0.offset(count as isize), + right_kv.0.add(count), right_len); ptr::copy(right_kv.1, - right_kv.1.offset(count as isize), + right_kv.1.add(count), right_len); // Move elements from the left child to the right one. @@ -1418,7 +1418,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: // Make room for stolen edges. let right_edges = right.reborrow_mut().as_internal_mut().edges.as_mut_ptr(); ptr::copy(right_edges, - right_edges.offset(count as isize), + right_edges.add(count), right_len + 1); right.correct_childrens_parent_links(count, count + right_len + 1); @@ -1463,10 +1463,10 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: move_kv(right_kv, count - 1, parent_kv, 0, 1); // Fix right indexing - ptr::copy(right_kv.0.offset(count as isize), + ptr::copy(right_kv.0.add(count), right_kv.0, new_right_len); - ptr::copy(right_kv.1.offset(count as isize), + ptr::copy(right_kv.1.add(count), right_kv.1, new_right_len); } @@ -1480,7 +1480,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: // Fix right indexing. let right_edges = right.reborrow_mut().as_internal_mut().edges.as_mut_ptr(); - ptr::copy(right_edges.offset(count as isize), + ptr::copy(right_edges.add(count), right_edges, new_right_len + 1); right.correct_childrens_parent_links(0, new_right_len + 1); @@ -1497,11 +1497,11 @@ unsafe fn move_kv( dest: (*mut K, *mut V), dest_offset: usize, count: usize) { - ptr::copy_nonoverlapping(source.0.offset(source_offset as isize), - dest.0.offset(dest_offset as isize), + ptr::copy_nonoverlapping(source.0.add(source_offset), + dest.0.add(dest_offset), count); - ptr::copy_nonoverlapping(source.1.offset(source_offset as isize), - dest.1.offset(dest_offset as isize), + ptr::copy_nonoverlapping(source.1.add(source_offset), + dest.1.add(dest_offset), count); } @@ -1513,8 +1513,8 @@ unsafe fn move_edges( { let source_ptr = source.as_internal_mut().edges.as_mut_ptr(); let dest_ptr = dest.as_internal_mut().edges.as_mut_ptr(); - ptr::copy_nonoverlapping(source_ptr.offset(source_offset as isize), - dest_ptr.offset(dest_offset as isize), + ptr::copy_nonoverlapping(source_ptr.add(source_offset), + dest_ptr.add(dest_offset), count); dest.correct_childrens_parent_links(dest_offset, dest_offset + count); } @@ -1604,8 +1604,8 @@ pub mod marker { unsafe fn slice_insert(slice: &mut [T], idx: usize, val: T) { ptr::copy( - slice.as_ptr().offset(idx as isize), - slice.as_mut_ptr().offset(idx as isize + 1), + slice.as_ptr().add(idx), + slice.as_mut_ptr().add(idx + 1), slice.len() - idx ); ptr::write(slice.get_unchecked_mut(idx), val); @@ -1614,8 +1614,8 @@ unsafe fn slice_insert(slice: &mut [T], idx: usize, val: T) { unsafe fn slice_remove(slice: &mut [T], idx: usize) -> T { let ret = ptr::read(slice.get_unchecked(idx)); ptr::copy( - slice.as_ptr().offset(idx as isize + 1), - slice.as_mut_ptr().offset(idx as isize), + slice.as_ptr().add(idx + 1), + slice.as_mut_ptr().add(idx), slice.len() - idx - 1 ); ret diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 0f759bb8f0b4f..55c8a78f8d046 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -126,13 +126,13 @@ impl VecDeque { /// Moves an element out of the buffer #[inline] unsafe fn buffer_read(&mut self, off: usize) -> T { - ptr::read(self.ptr().offset(off as isize)) + ptr::read(self.ptr().add(off)) } /// Writes an element into the buffer, moving it. #[inline] unsafe fn buffer_write(&mut self, off: usize, value: T) { - ptr::write(self.ptr().offset(off as isize), value); + ptr::write(self.ptr().add(off), value); } /// Returns `true` if and only if the buffer is at full capacity. @@ -177,8 +177,8 @@ impl VecDeque { src, len, self.cap()); - ptr::copy(self.ptr().offset(src as isize), - self.ptr().offset(dst as isize), + ptr::copy(self.ptr().add(src), + self.ptr().add(dst), len); } @@ -197,8 +197,8 @@ impl VecDeque { src, len, self.cap()); - ptr::copy_nonoverlapping(self.ptr().offset(src as isize), - self.ptr().offset(dst as isize), + ptr::copy_nonoverlapping(self.ptr().add(src), + self.ptr().add(dst), len); } @@ -436,7 +436,7 @@ impl VecDeque { pub fn get(&self, index: usize) -> Option<&T> { if index < self.len() { let idx = self.wrap_add(self.tail, index); - unsafe { Some(&*self.ptr().offset(idx as isize)) } + unsafe { Some(&*self.ptr().add(idx)) } } else { None } @@ -465,7 +465,7 @@ impl VecDeque { pub fn get_mut(&mut self, index: usize) -> Option<&mut T> { if index < self.len() { let idx = self.wrap_add(self.tail, index); - unsafe { Some(&mut *self.ptr().offset(idx as isize)) } + unsafe { Some(&mut *self.ptr().add(idx)) } } else { None } @@ -501,8 +501,8 @@ impl VecDeque { let ri = self.wrap_add(self.tail, i); let rj = self.wrap_add(self.tail, j); unsafe { - ptr::swap(self.ptr().offset(ri as isize), - self.ptr().offset(rj as isize)) + ptr::swap(self.ptr().add(ri), + self.ptr().add(rj)) } } @@ -1805,20 +1805,20 @@ impl VecDeque { // `at` lies in the first half. let amount_in_first = first_len - at; - ptr::copy_nonoverlapping(first_half.as_ptr().offset(at as isize), + ptr::copy_nonoverlapping(first_half.as_ptr().add(at), other.ptr(), amount_in_first); // just take all of the second half. ptr::copy_nonoverlapping(second_half.as_ptr(), - other.ptr().offset(amount_in_first as isize), + other.ptr().add(amount_in_first), second_len); } else { // `at` lies in the second half, need to factor in the elements we skipped // in the first half. let offset = at - first_len; let amount_in_second = second_len - offset; - ptr::copy_nonoverlapping(second_half.as_ptr().offset(offset as isize), + ptr::copy_nonoverlapping(second_half.as_ptr().add(offset), other.ptr(), amount_in_second); } @@ -2709,24 +2709,24 @@ impl From> for Vec { // Need to move the ring to the front of the buffer, as vec will expect this. if other.is_contiguous() { - ptr::copy(buf.offset(tail as isize), buf, len); + ptr::copy(buf.add(tail), buf, len); } else { if (tail - head) >= cmp::min(cap - tail, head) { // There is enough free space in the centre for the shortest block so we can // do this in at most three copy moves. if (cap - tail) > head { // right hand block is the long one; move that enough for the left - ptr::copy(buf.offset(tail as isize), - buf.offset((tail - head) as isize), + ptr::copy(buf.add(tail), + buf.add(tail - head), cap - tail); // copy left in the end - ptr::copy(buf, buf.offset((cap - head) as isize), head); + ptr::copy(buf, buf.add(cap - head), head); // shift the new thing to the start - ptr::copy(buf.offset((tail - head) as isize), buf, len); + ptr::copy(buf.add(tail - head), buf, len); } else { // left hand block is the long one, we can do it in two! - ptr::copy(buf, buf.offset((cap - tail) as isize), head); - ptr::copy(buf.offset(tail as isize), buf, cap - tail); + ptr::copy(buf, buf.add(cap - tail), head); + ptr::copy(buf.add(tail), buf, cap - tail); } } else { // Need to use N swaps to move the ring @@ -2751,7 +2751,7 @@ impl From> for Vec { for i in left_edge..right_edge { right_offset = (i - left_edge) % (cap - right_edge); let src: isize = (right_edge + right_offset) as isize; - ptr::swap(buf.offset(i as isize), buf.offset(src)); + ptr::swap(buf.add(i), buf.offset(src)); } let n_ops = right_edge - left_edge; left_edge += n_ops; diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 4f2686abf4515..837770feecef5 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "raw_vec_internals", reason = "implemention detail", issue = "0")] +#![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "0")] #![doc(hidden)] use core::cmp; @@ -282,7 +282,7 @@ impl RawVec { /// // double would have aborted or panicked if the len exceeded /// // `isize::MAX` so this is safe to do unchecked now. /// unsafe { - /// ptr::write(self.buf.ptr().offset(self.len as isize), elem); + /// ptr::write(self.buf.ptr().add(self.len), elem); /// } /// self.len += 1; /// } @@ -487,7 +487,7 @@ impl RawVec { /// // `isize::MAX` so this is safe to do unchecked now. /// for x in elems { /// unsafe { - /// ptr::write(self.buf.ptr().offset(self.len as isize), x.clone()); + /// ptr::write(self.buf.ptr().add(self.len), x.clone()); /// } /// self.len += 1; /// } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index be049eb6e5ef3..b8f1d51db464f 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -771,7 +771,7 @@ impl RcFromSlice for Rc<[T]> { }; for (i, item) in v.iter().enumerate() { - ptr::write(elems.offset(i as isize), item.clone()); + ptr::write(elems.add(i), item.clone()); guard.n_elems += 1; } diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index c27c596e7975a..9d442b3e00ca0 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -715,8 +715,8 @@ unsafe fn merge(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F) { let len = v.len(); let v = v.as_mut_ptr(); - let v_mid = v.offset(mid as isize); - let v_end = v.offset(len as isize); + let v_mid = v.add(mid); + let v_end = v.add(len); // The merge process first copies the shorter run into `buf`. Then it traces the newly copied // run and the longer run forwards (or backwards), comparing their next unconsumed elements and @@ -742,7 +742,7 @@ unsafe fn merge(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F) ptr::copy_nonoverlapping(v, buf, mid); hole = MergeHole { start: buf, - end: buf.offset(mid as isize), + end: buf.add(mid), dest: v, }; @@ -766,7 +766,7 @@ unsafe fn merge(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F) ptr::copy_nonoverlapping(v_mid, buf, len - mid); hole = MergeHole { start: buf, - end: buf.offset((len - mid) as isize), + end: buf.add(len - mid), dest: v_mid, }; diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index dd559df08cce6..eabda7123dec0 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1190,8 +1190,8 @@ impl String { let next = idx + ch.len_utf8(); let len = self.len(); unsafe { - ptr::copy(self.vec.as_ptr().offset(next as isize), - self.vec.as_mut_ptr().offset(idx as isize), + ptr::copy(self.vec.as_ptr().add(next), + self.vec.as_mut_ptr().add(idx), len - next); self.vec.set_len(len - (next - idx)); } @@ -1232,8 +1232,8 @@ impl String { del_bytes += ch_len; } else if del_bytes > 0 { unsafe { - ptr::copy(self.vec.as_ptr().offset(idx as isize), - self.vec.as_mut_ptr().offset((idx - del_bytes) as isize), + ptr::copy(self.vec.as_ptr().add(idx), + self.vec.as_mut_ptr().add(idx - del_bytes), ch_len); } } @@ -1289,11 +1289,11 @@ impl String { let amt = bytes.len(); self.vec.reserve(amt); - ptr::copy(self.vec.as_ptr().offset(idx as isize), - self.vec.as_mut_ptr().offset((idx + amt) as isize), + ptr::copy(self.vec.as_ptr().add(idx), + self.vec.as_mut_ptr().add(idx + amt), len - idx); ptr::copy(bytes.as_ptr(), - self.vec.as_mut_ptr().offset(idx as isize), + self.vec.as_mut_ptr().add(idx), amt); self.vec.set_len(len + amt); } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index a00b6b4e435f0..2cd7898f4c781 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -672,7 +672,7 @@ impl ArcFromSlice for Arc<[T]> { }; for (i, item) in v.iter().enumerate() { - ptr::write(elems.offset(i as isize), item.clone()); + ptr::write(elems.add(i), item.clone()); guard.n_elems += 1; } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index cc913dfbb4b01..e9c1a3df51891 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -692,7 +692,7 @@ impl Vec { pub fn truncate(&mut self, len: usize) { let current_len = self.len; unsafe { - let mut ptr = self.as_mut_ptr().offset(self.len as isize); + let mut ptr = self.as_mut_ptr().add(self.len); // Set the final length at the end, keeping in mind that // dropping an element might panic. Works around a missed // optimization, as seen in the following issue: @@ -856,7 +856,7 @@ impl Vec { // infallible // The spot to put the new value { - let p = self.as_mut_ptr().offset(index as isize); + let p = self.as_mut_ptr().add(index); // Shift everything over to make space. (Duplicating the // `index`th element into two consecutive places.) ptr::copy(p, p.offset(1), len - index); @@ -891,7 +891,7 @@ impl Vec { let ret; { // the place we are taking from. - let ptr = self.as_mut_ptr().offset(index as isize); + let ptr = self.as_mut_ptr().add(index); // copy it out, unsafely having a copy of the value on // the stack and in the vector at the same time. ret = ptr::read(ptr); @@ -1034,8 +1034,8 @@ impl Vec { let mut w: usize = 1; while r < ln { - let p_r = p.offset(r as isize); - let p_wm1 = p.offset((w - 1) as isize); + let p_r = p.add(r); + let p_wm1 = p.add(w - 1); if !same_bucket(&mut *p_r, &mut *p_wm1) { if r != w { let p_w = p_wm1.offset(1); @@ -1072,7 +1072,7 @@ impl Vec { self.reserve(1); } unsafe { - let end = self.as_mut_ptr().offset(self.len as isize); + let end = self.as_mut_ptr().add(self.len); ptr::write(end, value); self.len += 1; } @@ -1196,7 +1196,7 @@ impl Vec { self.set_len(start); // Use the borrow in the IterMut to indicate borrowing behavior of the // whole Drain iterator (like &mut T). - let range_slice = slice::from_raw_parts_mut(self.as_mut_ptr().offset(start as isize), + let range_slice = slice::from_raw_parts_mut(self.as_mut_ptr().add(start), end - start); Drain { tail_start: end, @@ -1290,7 +1290,7 @@ impl Vec { self.set_len(at); other.set_len(other_len); - ptr::copy_nonoverlapping(self.as_ptr().offset(at as isize), + ptr::copy_nonoverlapping(self.as_ptr().add(at), other.as_mut_ptr(), other.len()); } @@ -1473,7 +1473,7 @@ impl Vec { self.reserve(n); unsafe { - let mut ptr = self.as_mut_ptr().offset(self.len() as isize); + let mut ptr = self.as_mut_ptr().add(self.len()); // Use SetLenOnDrop to work around bug where compiler // may not realize the store through `ptr` through self.set_len() // don't alias. @@ -1799,7 +1799,7 @@ impl IntoIterator for Vec { let end = if mem::size_of::() == 0 { arith_offset(begin as *const i8, self.len() as isize) as *const T } else { - begin.offset(self.len() as isize) as *const T + begin.add(self.len()) as *const T }; let cap = self.buf.cap(); mem::forget(self); @@ -1898,7 +1898,7 @@ impl SpecExtend for Vec if let Some(additional) = high { self.reserve(additional); unsafe { - let mut ptr = self.as_mut_ptr().offset(self.len() as isize); + let mut ptr = self.as_mut_ptr().add(self.len()); let mut local_len = SetLenOnDrop::new(&mut self.len); for element in iterator { ptr::write(ptr, element); @@ -2561,8 +2561,8 @@ impl<'a, T> Drop for Drain<'a, T> { let start = source_vec.len(); let tail = self.tail_start; if tail != start { - let src = source_vec.as_ptr().offset(tail as isize); - let dst = source_vec.as_mut_ptr().offset(start as isize); + let src = source_vec.as_ptr().add(tail); + let dst = source_vec.as_mut_ptr().add(start); ptr::copy(src, dst, self.tail_len); } source_vec.set_len(start + self.tail_len); @@ -2672,7 +2672,7 @@ impl<'a, T> Drain<'a, T> { let range_start = vec.len; let range_end = self.tail_start; let range_slice = slice::from_raw_parts_mut( - vec.as_mut_ptr().offset(range_start as isize), + vec.as_mut_ptr().add(range_start), range_end - range_start); for place in range_slice { @@ -2693,8 +2693,8 @@ impl<'a, T> Drain<'a, T> { vec.buf.reserve(used_capacity, extra_capacity); let new_tail_start = self.tail_start + extra_capacity; - let src = vec.as_ptr().offset(self.tail_start as isize); - let dst = vec.as_mut_ptr().offset(new_tail_start as isize); + let src = vec.as_ptr().add(self.tail_start); + let dst = vec.as_mut_ptr().add(new_tail_start); ptr::copy(src, dst, self.tail_len); self.tail_start = new_tail_start; } diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index c5e056f6b12be..753b6a5e29248 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -249,7 +249,7 @@ mod platform { } unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 { - let aligned = ptr.offset((align - (ptr as usize & (align - 1))) as isize); + let aligned = ptr.add(align - (ptr as usize & (align - 1))); *get_header(aligned) = Header(ptr); aligned } diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 265721c749755..6ad703180c224 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -106,7 +106,7 @@ impl TypedArenaChunk { // A pointer as large as possible for zero-sized elements. !0 as *mut T } else { - self.start().offset(self.storage.cap() as isize) + self.start().add(self.storage.cap()) } } } @@ -179,7 +179,7 @@ impl TypedArena { unsafe { let start_ptr = self.ptr.get(); let arena_slice = slice::from_raw_parts_mut(start_ptr, slice.len()); - self.ptr.set(start_ptr.offset(arena_slice.len() as isize)); + self.ptr.set(start_ptr.add(arena_slice.len())); arena_slice.copy_from_slice(slice); arena_slice } diff --git a/src/libcore/future/future_obj.rs b/src/libcore/future/future_obj.rs index 6045fac2b4b3d..2df870a011dcb 100644 --- a/src/libcore/future/future_obj.rs +++ b/src/libcore/future/future_obj.rs @@ -27,7 +27,7 @@ use task::{Context, Poll}; /// - The `Future` trait is currently not object safe: The `Future::poll` /// method makes uses the arbitrary self types feature and traits in which /// this feature is used are currently not object safe due to current compiler -/// limitations. (See tracking issue for arbitray self types for more +/// limitations. (See tracking issue for arbitrary self types for more /// information #44874) pub struct LocalFutureObj<'a, T> { ptr: *mut (), @@ -102,7 +102,7 @@ impl<'a, T> Drop for LocalFutureObj<'a, T> { /// - The `Future` trait is currently not object safe: The `Future::poll` /// method makes uses the arbitrary self types feature and traits in which /// this feature is used are currently not object safe due to current compiler -/// limitations. (See tracking issue for arbitray self types for more +/// limitations. (See tracking issue for arbitrary self types for more /// information #44874) pub struct FutureObj<'a, T>(LocalFutureObj<'a, T>); diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 9ddf902349dd2..7756a6f71dbd6 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -918,7 +918,7 @@ extern "rust-intrinsic" { /// // treat it as "dead", and therefore, you only have two real /// // mutable slices. /// (slice::from_raw_parts_mut(ptr, mid), - /// slice::from_raw_parts_mut(ptr.offset(mid as isize), len - mid)) + /// slice::from_raw_parts_mut(ptr.add(mid), len - mid)) /// } /// } /// ``` diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index d18e167fc3fa4..b1dc84bb84cb8 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -511,7 +511,7 @@ macro_rules! impls{ /// let ptr = vec.as_ptr(); /// Slice { /// start: ptr, -/// end: unsafe { ptr.offset(vec.len() as isize) }, +/// end: unsafe { ptr.add(vec.len()) }, /// phantom: PhantomData, /// } /// } @@ -603,15 +603,35 @@ unsafe impl Freeze for *mut T {} unsafe impl<'a, T: ?Sized> Freeze for &'a T {} unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} -/// Types which can be moved out of a `PinMut`. +/// Types which can be safely moved after being pinned. /// -/// The `Unpin` trait is used to control the behavior of the [`PinMut`] type. If a -/// type implements `Unpin`, it is safe to move a value of that type out of the -/// `PinMut` pointer. +/// Since Rust itself has no notion of immovable types, and will consider moves to always be safe, +/// this trait cannot prevent types from moving by itself. +/// +/// Instead it can be used to prevent moves through the type system, +/// by controlling the behavior of special pointer types like [`PinMut`], +/// which "pin" the type in place by not allowing it to be moved out of them. +/// +/// Implementing this trait lifts the restrictions of pinning off a type, +/// which then allows it to move out with functions such as [`replace`]. +/// +/// So this, for example, can only be done on types implementing `Unpin`: +/// +/// ```rust +/// #![feature(pin)] +/// use std::mem::{PinMut, replace}; +/// +/// let mut string = "this".to_string(); +/// let mut pinned_string = PinMut::new(&mut string); +/// +/// // dereferencing the pointer mutably is only possible because String implements Unpin +/// replace(&mut *pinned_string, "other".to_string()); +/// ``` /// /// This trait is automatically implemented for almost every type. /// /// [`PinMut`]: ../mem/struct.PinMut.html +/// [`replace`]: ../mem/fn.replace.html #[unstable(feature = "pin", issue = "49150")] pub auto trait Unpin {} diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 37856dc546935..b93428c6321f6 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -34,22 +34,32 @@ macro_rules! impl_nonzero_fmt { } } +macro_rules! doc_comment { + ($x:expr, $($tt:tt)*) => { + #[doc = $x] + $($tt)* + }; +} + macro_rules! nonzero_integers { ( $( $Ty: ident($Int: ty); )+ ) => { $( - /// An integer that is known not to equal zero. - /// - /// This enables some memory layout optimization. - /// For example, `Option` is the same size as `u32`: - /// - /// ```rust - /// use std::mem::size_of; - /// assert_eq!(size_of::>(), size_of::()); - /// ``` - #[stable(feature = "nonzero", since = "1.28.0")] - #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] - #[repr(transparent)] - pub struct $Ty(NonZero<$Int>); + doc_comment! { + concat!("An integer that is known not to equal zero. + +This enables some memory layout optimization. +For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`: + +```rust +use std::mem::size_of; +assert_eq!(size_of::>(), size_of::<", stringify!($Int), +">()); +```"), + #[stable(feature = "nonzero", since = "1.28.0")] + #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] + #[repr(transparent)] + pub struct $Ty(NonZero<$Int>); + } impl $Ty { /// Create a non-zero without checking the value. @@ -176,13 +186,6 @@ pub mod dec2flt; pub mod bignum; pub mod diy_float; -macro_rules! doc_comment { - ($x:expr, $($tt:tt)*) => { - #[doc = $x] - $($tt)* - }; -} - mod wrapping; // `Int` + `SignedInt` implemented for signed integers diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index d10fcb86b2411..3ebd10a920919 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -66,6 +66,11 @@ #[lang = "fn"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{Fn}<{Args}>` closure, found `{Self}`", + label="expected an `Fn<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait Fn : FnMut { /// Performs the call operation. @@ -139,6 +144,11 @@ pub trait Fn : FnMut { #[lang = "fn_mut"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{FnMut}<{Args}>` closure, found `{Self}`", + label="expected an `FnMut<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnMut : FnOnce { /// Performs the call operation. @@ -212,6 +222,11 @@ pub trait FnMut : FnOnce { #[lang = "fn_once"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{FnOnce}<{Args}>` closure, found `{Self}`", + label="expected an `FnOnce<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnOnce { /// The returned type after the call operator is used. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 61033e7511253..ebdddde7de371 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -226,8 +226,8 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { // Declaring `t` here avoids aligning the stack when this loop is unused let mut t: Block = mem::uninitialized(); let t = &mut t as *mut _ as *mut u8; - let x = x.offset(i as isize); - let y = y.offset(i as isize); + let x = x.add(i); + let y = y.add(i); // Swap a block of bytes of x & y, using t as a temporary buffer // This should be optimized into efficient SIMD operations where available @@ -243,8 +243,8 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { let rem = len - i; let t = &mut t as *mut _ as *mut u8; - let x = x.offset(i as isize); - let y = y.offset(i as isize); + let x = x.add(i); + let y = y.add(i); copy_nonoverlapping(x, t, rem); copy_nonoverlapping(y, x, rem); @@ -613,7 +613,7 @@ impl *const T { /// The compiler and standard library generally tries to ensure allocations /// never reach a size where an offset is a concern. For instance, `Vec` /// and `Box` ensure they never allocate more than `isize::MAX` bytes, so - /// `vec.as_ptr().offset(vec.len() as isize)` is always safe. + /// `vec.as_ptr().add(vec.len())` is always safe. /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request @@ -1231,7 +1231,7 @@ impl *const T { /// let ptr = &x[n] as *const u8; /// let offset = ptr.align_offset(align_of::()); /// if offset < x.len() - n - 1 { - /// let u16_ptr = ptr.offset(offset as isize) as *const u16; + /// let u16_ptr = ptr.add(offset) as *const u16; /// assert_ne!(*u16_ptr, 500); /// } else { /// // while the pointer can be aligned via `offset`, it would point @@ -1334,7 +1334,7 @@ impl *mut T { /// The compiler and standard library generally tries to ensure allocations /// never reach a size where an offset is a concern. For instance, `Vec` /// and `Box` ensure they never allocate more than `isize::MAX` bytes, so - /// `vec.as_ptr().offset(vec.len() as isize)` is always safe. + /// `vec.as_ptr().add(vec.len())` is always safe. /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request @@ -2261,7 +2261,7 @@ impl *mut T { /// let ptr = &x[n] as *const u8; /// let offset = ptr.align_offset(align_of::()); /// if offset < x.len() - n - 1 { - /// let u16_ptr = ptr.offset(offset as isize) as *const u16; + /// let u16_ptr = ptr.add(offset) as *const u16; /// assert_ne!(*u16_ptr, 500); /// } else { /// // while the pointer can be aligned via `offset`, it would point @@ -2291,7 +2291,7 @@ impl *mut T { /// /// If we ever decide to make it possible to call the intrinsic with `a` that is not a /// power-of-two, it will probably be more prudent to just change to a naive implementation rather -/// than trying to adapt this to accomodate that change. +/// than trying to adapt this to accommodate that change. /// /// Any questions go to @nagisa. #[lang="align_offset"] diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs index c9d3c7fea9839..cf95333af9cbb 100644 --- a/src/libcore/slice/memchr.rs +++ b/src/libcore/slice/memchr.rs @@ -72,8 +72,8 @@ pub fn memchr(x: u8, text: &[u8]) -> Option { if len >= 2 * usize_bytes { while offset <= len - 2 * usize_bytes { unsafe { - let u = *(ptr.offset(offset as isize) as *const usize); - let v = *(ptr.offset((offset + usize_bytes) as isize) as *const usize); + let u = *(ptr.add(offset) as *const usize); + let v = *(ptr.add(offset + usize_bytes) as *const usize); // break if there is a matching byte let zu = contains_zero_byte(u ^ repeated_x); diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index a3960556d3412..3366c4a3e661c 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -383,7 +383,7 @@ impl [T] { /// /// unsafe { /// for i in 0..x.len() { - /// assert_eq!(x.get_unchecked(i), &*x_ptr.offset(i as isize)); + /// assert_eq!(x.get_unchecked(i), &*x_ptr.add(i)); /// } /// } /// ``` @@ -410,7 +410,7 @@ impl [T] { /// /// unsafe { /// for i in 0..x.len() { - /// *x_ptr.offset(i as isize) += 2; + /// *x_ptr.add(i) += 2; /// } /// } /// assert_eq!(x, &[3, 4, 6]); @@ -546,9 +546,9 @@ impl [T] { assume(!ptr.is_null()); let end = if mem::size_of::() == 0 { - (ptr as *const u8).wrapping_offset(self.len() as isize) as *const T + (ptr as *const u8).wrapping_add(self.len()) as *const T } else { - ptr.offset(self.len() as isize) + ptr.add(self.len()) }; Iter { @@ -578,9 +578,9 @@ impl [T] { assume(!ptr.is_null()); let end = if mem::size_of::() == 0 { - (ptr as *mut u8).wrapping_offset(self.len() as isize) as *mut T + (ptr as *mut u8).wrapping_add(self.len()) as *mut T } else { - ptr.offset(self.len() as isize) + ptr.add(self.len()) }; IterMut { @@ -842,7 +842,7 @@ impl [T] { assert!(mid <= len); (from_raw_parts_mut(ptr, mid), - from_raw_parts_mut(ptr.offset(mid as isize), len - mid)) + from_raw_parts_mut(ptr.add(mid), len - mid)) } } @@ -1444,7 +1444,7 @@ impl [T] { unsafe { let p = self.as_mut_ptr(); - rotate::ptr_rotate(mid, p.offset(mid as isize), k); + rotate::ptr_rotate(mid, p.add(mid), k); } } @@ -1485,7 +1485,7 @@ impl [T] { unsafe { let p = self.as_mut_ptr(); - rotate::ptr_rotate(mid, p.offset(mid as isize), k); + rotate::ptr_rotate(mid, p.add(mid), k); } } @@ -1680,7 +1680,7 @@ impl [T] { } } - /// Function to calculate lenghts of the middle and trailing slice for `align_to{,_mut}`. + /// Function to calculate lengths of the middle and trailing slice for `align_to{,_mut}`. fn align_to_offsets(&self) -> (usize, usize) { // What we gonna do about `rest` is figure out what multiple of `U`s we can put in a // lowest number of `T`s. And how many `T`s we need for each such "multiple". @@ -1740,7 +1740,7 @@ impl [T] { (us_len, ts_len) } - /// Transmute the slice to a slice of another type, ensuring aligment of the types is + /// Transmute the slice to a slice of another type, ensuring alignment of the types is /// maintained. /// /// This method splits the slice into three distinct slices: prefix, correctly aligned middle @@ -1789,11 +1789,11 @@ impl [T] { let (us_len, ts_len) = rest.align_to_offsets::(); (left, from_raw_parts(rest.as_ptr() as *const U, us_len), - from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len)) + from_raw_parts(rest.as_ptr().add(rest.len() - ts_len), ts_len)) } } - /// Transmute the slice to a slice of another type, ensuring aligment of the types is + /// Transmute the slice to a slice of another type, ensuring alignment of the types is /// maintained. /// /// This method splits the slice into three distinct slices: prefix, correctly aligned middle @@ -1843,7 +1843,7 @@ impl [T] { let mut_ptr = rest.as_mut_ptr(); (left, from_raw_parts_mut(mut_ptr as *mut U, us_len), - from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len)) + from_raw_parts_mut(mut_ptr.add(rest.len() - ts_len), ts_len)) } } } @@ -2037,12 +2037,12 @@ impl SliceIndex<[T]> for usize { #[inline] unsafe fn get_unchecked(self, slice: &[T]) -> &T { - &*slice.as_ptr().offset(self as isize) + &*slice.as_ptr().add(self) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut T { - &mut *slice.as_mut_ptr().offset(self as isize) + &mut *slice.as_mut_ptr().add(self) } #[inline] @@ -2086,12 +2086,12 @@ impl SliceIndex<[T]> for ops::Range { #[inline] unsafe fn get_unchecked(self, slice: &[T]) -> &[T] { - from_raw_parts(slice.as_ptr().offset(self.start as isize), self.end - self.start) + from_raw_parts(slice.as_ptr().add(self.start), self.end - self.start) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] { - from_raw_parts_mut(slice.as_mut_ptr().offset(self.start as isize), self.end - self.start) + from_raw_parts_mut(slice.as_mut_ptr().add(self.start), self.end - self.start) } #[inline] @@ -2467,7 +2467,7 @@ macro_rules! iterator { } // We are in bounds. `offset` does the right thing even for ZSTs. unsafe { - let elem = Some(& $( $mut_ )* *self.ptr.offset(n as isize)); + let elem = Some(& $( $mut_ )* *self.ptr.add(n)); self.post_inc_start((n as isize).wrapping_add(1)); elem } @@ -3347,7 +3347,7 @@ impl<'a, T> FusedIterator for Windows<'a, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] { - from_raw_parts(self.v.as_ptr().offset(i as isize), self.size) + from_raw_parts(self.v.as_ptr().add(i), self.size) } fn may_have_side_effect() -> bool { false } } @@ -3474,7 +3474,7 @@ unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> { None => self.v.len(), Some(end) => cmp::min(end, self.v.len()), }; - from_raw_parts(self.v.as_ptr().offset(start as isize), end - start) + from_raw_parts(self.v.as_ptr().add(start), end - start) } fn may_have_side_effect() -> bool { false } } @@ -3593,7 +3593,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> { None => self.v.len(), Some(end) => cmp::min(end, self.v.len()), }; - from_raw_parts_mut(self.v.as_mut_ptr().offset(start as isize), end - start) + from_raw_parts_mut(self.v.as_mut_ptr().add(start), end - start) } fn may_have_side_effect() -> bool { false } } @@ -3716,7 +3716,7 @@ impl<'a, T> FusedIterator for ExactChunks<'a, T> {} unsafe impl<'a, T> TrustedRandomAccess for ExactChunks<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] { let start = i * self.chunk_size; - from_raw_parts(self.v.as_ptr().offset(start as isize), self.chunk_size) + from_raw_parts(self.v.as_ptr().add(start), self.chunk_size) } fn may_have_side_effect() -> bool { false } } @@ -3831,7 +3831,7 @@ impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {} unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] { let start = i * self.chunk_size; - from_raw_parts_mut(self.v.as_mut_ptr().offset(start as isize), self.chunk_size) + from_raw_parts_mut(self.v.as_mut_ptr().add(start), self.chunk_size) } fn may_have_side_effect() -> bool { false } } @@ -4116,7 +4116,7 @@ impl_marker_for!(BytewiseEquality, #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a T { - &*self.ptr.offset(i as isize) + &*self.ptr.add(i) } fn may_have_side_effect() -> bool { false } } @@ -4124,7 +4124,7 @@ unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> { #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for IterMut<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut T { - &mut *self.ptr.offset(i as isize) + &mut *self.ptr.add(i) } fn may_have_side_effect() -> bool { false } } diff --git a/src/libcore/slice/rotate.rs b/src/libcore/slice/rotate.rs index 28ef53ccb5cb6..0d182b8497452 100644 --- a/src/libcore/slice/rotate.rs +++ b/src/libcore/slice/rotate.rs @@ -77,8 +77,8 @@ pub unsafe fn ptr_rotate(mut left: usize, mid: *mut T, mut right: usize) { } ptr::swap_nonoverlapping( - mid.offset(-(left as isize)), - mid.offset((right-delta) as isize), + mid.sub(left), + mid.add(right - delta), delta); if left <= right { @@ -91,15 +91,15 @@ pub unsafe fn ptr_rotate(mut left: usize, mid: *mut T, mut right: usize) { let rawarray = RawArray::new(); let buf = rawarray.ptr(); - let dim = mid.offset(-(left as isize)).offset(right as isize); + let dim = mid.sub(left).add(right); if left <= right { - ptr::copy_nonoverlapping(mid.offset(-(left as isize)), buf, left); - ptr::copy(mid, mid.offset(-(left as isize)), right); + ptr::copy_nonoverlapping(mid.sub(left), buf, left); + ptr::copy(mid, mid.sub(left), right); ptr::copy_nonoverlapping(buf, dim, left); } else { ptr::copy_nonoverlapping(mid, buf, right); - ptr::copy(mid.offset(-(left as isize)), dim, left); - ptr::copy_nonoverlapping(buf, mid.offset(-(left as isize)), right); + ptr::copy(mid.sub(left), dim, left); + ptr::copy_nonoverlapping(buf, mid.sub(left), right); } } diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index 518d56095d601..e4c1fd03f9eb3 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -221,15 +221,15 @@ fn partition_in_blocks(v: &mut [T], pivot: &T, is_less: &mut F) -> usize // 3. `end` - End pointer into the `offsets` array. // 4. `offsets - Indices of out-of-order elements within the block. - // The current block on the left side (from `l` to `l.offset(block_l)`). + // The current block on the left side (from `l` to `l.add(block_l)`). let mut l = v.as_mut_ptr(); let mut block_l = BLOCK; let mut start_l = ptr::null_mut(); let mut end_l = ptr::null_mut(); let mut offsets_l: [u8; BLOCK] = unsafe { mem::uninitialized() }; - // The current block on the right side (from `r.offset(-block_r)` to `r`). - let mut r = unsafe { l.offset(v.len() as isize) }; + // The current block on the right side (from `r.sub(block_r)` to `r`). + let mut r = unsafe { l.add(v.len()) }; let mut block_r = BLOCK; let mut start_r = ptr::null_mut(); let mut end_r = ptr::null_mut(); diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 810d19df0c5ba..64bdf4d9f486a 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1518,12 +1518,12 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { let ptr = v.as_ptr(); let align = unsafe { // the offset is safe, because `index` is guaranteed inbounds - ptr.offset(index as isize).align_offset(usize_bytes) + ptr.add(index).align_offset(usize_bytes) }; if align == 0 { while index < blocks_end { unsafe { - let block = ptr.offset(index as isize) as *const usize; + let block = ptr.add(index) as *const usize; // break if there is a nonascii byte let zu = contains_nonascii(*block); let zv = contains_nonascii(*block.offset(1)); @@ -1878,13 +1878,13 @@ mod traits { } #[inline] unsafe fn get_unchecked(self, slice: &str) -> &Self::Output { - let ptr = slice.as_ptr().offset(self.start as isize); + let ptr = slice.as_ptr().add(self.start); let len = self.end - self.start; super::from_utf8_unchecked(slice::from_raw_parts(ptr, len)) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut str) -> &mut Self::Output { - let ptr = slice.as_ptr().offset(self.start as isize); + let ptr = slice.as_ptr().add(self.start); let len = self.end - self.start; super::from_utf8_unchecked_mut(slice::from_raw_parts_mut(ptr as *mut u8, len)) } @@ -1973,13 +1973,13 @@ mod traits { } #[inline] unsafe fn get_unchecked(self, slice: &str) -> &Self::Output { - let ptr = slice.as_ptr().offset(self.start as isize); + let ptr = slice.as_ptr().add(self.start); let len = slice.len() - self.start; super::from_utf8_unchecked(slice::from_raw_parts(ptr, len)) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut str) -> &mut Self::Output { - let ptr = slice.as_ptr().offset(self.start as isize); + let ptr = slice.as_ptr().add(self.start); let len = slice.len() - self.start; super::from_utf8_unchecked_mut(slice::from_raw_parts_mut(ptr as *mut u8, len)) } @@ -2573,7 +2573,7 @@ impl str { unsafe { (from_utf8_unchecked_mut(slice::from_raw_parts_mut(ptr, mid)), from_utf8_unchecked_mut(slice::from_raw_parts_mut( - ptr.offset(mid as isize), + ptr.add(mid), len - mid ))) } diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index e2380f0fe2ff3..1bac6d22d3744 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -154,7 +154,7 @@ pub struct Parser<'a> { style: Option, /// How many newlines have been seen in the string so far, to adjust the error spans seen_newlines: usize, - /// Start and end byte offset of every successfuly parsed argument + /// Start and end byte offset of every successfully parsed argument pub arg_places: Vec<(usize, usize)>, } diff --git a/src/libpanic_unwind/dwarf/mod.rs b/src/libpanic_unwind/dwarf/mod.rs index 5c05ac11d307d..7e0c32fe03d8a 100644 --- a/src/libpanic_unwind/dwarf/mod.rs +++ b/src/libpanic_unwind/dwarf/mod.rs @@ -38,7 +38,7 @@ impl DwarfReader { // telling the backend to generate "misalignment-safe" code. pub unsafe fn read(&mut self) -> T { let Unaligned(result) = *(self.ptr as *const Unaligned); - self.ptr = self.ptr.offset(mem::size_of::() as isize); + self.ptr = self.ptr.add(mem::size_of::()); result } diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index 8cbc4a623fa05..015be2dea2157 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -142,7 +142,7 @@ mod imp { #[repr(C)] pub struct _ThrowInfo { - pub attribues: c_uint, + pub attributes: c_uint, pub pnfnUnwind: imp::ptr_t, pub pForwardCompat: imp::ptr_t, pub pCatchableTypeArray: imp::ptr_t, @@ -178,7 +178,7 @@ pub struct _TypeDescriptor { } static mut THROW_INFO: _ThrowInfo = _ThrowInfo { - attribues: 0, + attributes: 0, pnfnUnwind: ptr!(0), pForwardCompat: ptr!(0), pCatchableTypeArray: ptr!(0), diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 0a32963a861de..656819880b135 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -12,7 +12,7 @@ //! //! This library, provided by the standard distribution, provides the types //! consumed in the interfaces of procedurally defined macro definitions such as -//! function-like macros `#[proc_macro]`, macro attribures `#[proc_macro_attribute]` and +//! function-like macros `#[proc_macro]`, macro attributes `#[proc_macro_attribute]` and //! custom derive attributes`#[proc_macro_derive]`. //! //! Note that this crate is intentionally bare-bones currently. diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 9b25727112cdf..b56da8f630424 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -49,7 +49,7 @@ pub mod query_result; mod substitute; /// A "canonicalized" type `V` is one where all free inference -/// variables have been rewriten to "canonical vars". These are +/// variables have been rewritten to "canonical vars". These are /// numbered starting from 0 in order of first appearance. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)] pub struct Canonical<'gcx, V> { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index d2987119e2996..d458d62e738c3 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -561,7 +561,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { value.push_highlighted("<"); } - // Output the lifetimes fot the first type + // Output the lifetimes for the first type let lifetimes = sub.regions() .map(|lifetime| { let s = lifetime.to_string(); diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index cb4e1ab65e759..bb1c9448132c1 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -527,7 +527,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { * we're not careful, it will succeed. * * The reason is that when we walk through the subtyping - * algorith, we begin by replacing `'a` with a skolemized + * algorithm, we begin by replacing `'a` with a skolemized * variable `'1`. We then have `fn(_#0t) <: fn(&'1 int)`. This * can be made true by unifying `_#0t` with `&'1 int`. In the * process, we create a fresh variable for the skolemized diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b6f4bd6dc408c..c92f7eb595496 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -47,7 +47,7 @@ #![feature(drain_filter)] #![feature(iterator_find_map)] #![cfg_attr(windows, feature(libc))] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(never_type)] #![feature(exhaustive_patterns)] #![feature(extern_types)] diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index b91a9644b211a..f4b4404338961 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -42,11 +42,6 @@ pub use self::NativeLibraryKind::*; // lonely orphan structs and enums looking for a better home -#[derive(Clone, Debug, Copy)] -pub struct LinkMeta { - pub crate_hash: Svh, -} - /// Where a crate came from on the local filesystem. One of these three options /// must be non-None. #[derive(PartialEq, Clone, Debug)] @@ -233,8 +228,7 @@ pub trait CrateStore { // utility functions fn encode_metadata<'a, 'tcx>(&self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - link_meta: &LinkMeta) + tcx: TyCtxt<'a, 'tcx, 'tcx>) -> EncodedMetadata; fn metadata_encoding_version(&self) -> &[u8]; } diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index f569f4def143f..3e8b44b87fe74 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -68,7 +68,7 @@ impl<'tcx> ConstValue<'tcx> { /// A `Value` represents a single self-contained Rust value. /// -/// A `Value` can either refer to a block of memory inside an allocation (`ByRef`) or to a primitve +/// A `Value` can either refer to a block of memory inside an allocation (`ByRef`) or to a primitive /// value held directly, outside of any allocation (`Scalar`). For `ByRef`-values, we remember /// whether the pointer is supposed to be aligned or not (also see Place). /// diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 8ceff303774b5..54fe30e609d38 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -927,11 +927,11 @@ pub enum TerminatorKind<'tcx> { /// Drop(P, goto BB1, unwind BB2) /// } /// BB1 { - /// // P is now unitialized + /// // P is now uninitialized /// P <- V /// } /// BB2 { - /// // P is now unitialized -- its dtor panicked + /// // P is now uninitialized -- its dtor panicked /// P <- V /// } /// ``` diff --git a/src/librustc/mir/traversal.rs b/src/librustc/mir/traversal.rs index c178a9063c9ac..c919793fe3e03 100644 --- a/src/librustc/mir/traversal.rs +++ b/src/librustc/mir/traversal.rs @@ -171,7 +171,7 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> { // (A, [C])] // // Now that the top of the stack has no successors we can traverse, each item will - // be popped off during iteration until we get back to `A`. This yeilds [E, D, B]. + // be popped off during iteration until we get back to `A`. This yields [E, D, B]. // // When we yield `B` and call `traverse_successor`, we push `C` to the stack, but // since we've already visited `E`, that child isn't added to the stack. The last diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index fd8c2d45e644a..a0882f8f92b46 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -264,12 +264,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // The core logic responsible for computing the bounds for our synthesized impl. // // To calculate the bounds, we call SelectionContext.select in a loop. Like FulfillmentContext, - // we recursively select the nested obligations of predicates we encounter. However, whenver we + // we recursively select the nested obligations of predicates we encounter. However, whenever we // encounter an UnimplementedError involving a type parameter, we add it to our ParamEnv. Since // our goal is to determine when a particular type implements an auto trait, Unimplemented // errors tell us what conditions need to be met. // - // This method ends up working somewhat similary to FulfillmentContext, but with a few key + // This method ends up working somewhat similarly to FulfillmentContext, but with a few key // differences. FulfillmentContext works under the assumption that it's dealing with concrete // user code. According, it considers all possible ways that a Predicate could be met - which // isn't always what we want for a synthesized impl. For example, given the predicate 'T: @@ -289,11 +289,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // we'll pick up any nested bounds, without ever inferring that 'T: IntoIterator' needs to // hold. // - // One additonal consideration is supertrait bounds. Normally, a ParamEnv is only ever + // One additional consideration is supertrait bounds. Normally, a ParamEnv is only ever // consutrcted once for a given type. As part of the construction process, the ParamEnv will // have any supertrait bounds normalized - e.g. if we have a type 'struct Foo', the // ParamEnv will contain 'T: Copy' and 'T: Clone', since 'Copy: Clone'. When we construct our - // own ParamEnv, we need to do this outselves, through traits::elaborate_predicates, or else + // own ParamEnv, we need to do this ourselves, through traits::elaborate_predicates, or else // SelectionContext will choke on the missing predicates. However, this should never show up in // the final synthesized generics: we don't want our generated docs page to contain something // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 5d45badf49f8d..fb09551704018 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -652,7 +652,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } // If this error is due to `!: Trait` not implemented but `(): Trait` is - // implemented, and fallback has occured, then it could be due to a + // implemented, and fallback has occurred, then it could be due to a // variable that used to fallback to `()` now falling back to `!`. Issue a // note informing about the change in behaviour. if trait_predicate.skip_binder().self_ty().is_never() diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 56484e17777fe..3a1d50a6584ef 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -82,7 +82,7 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { // Errors and ambiuity in dropck occur in two cases: // - unresolved inference variables at the end of typeck // - non well-formed types where projections cannot be resolved - // Either of these should hvae created an error before. + // Either of these should have created an error before. tcx.sess .delay_span_bug(span, "dtorck encountered internal error"); return InferOk { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ef363459108c9..ee0543f53ba69 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -26,7 +26,7 @@ use lint::{self, Lint}; use ich::{StableHashingContext, NodeIdHashingMode}; use infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; use infer::outlives::free_region_map::FreeRegionMap; -use middle::cstore::{CrateStoreDyn, LinkMeta}; +use middle::cstore::CrateStoreDyn; use middle::cstore::EncodedMetadata; use middle::lang_items; use middle::resolve_lifetime::{self, ObjectLifetimeDefault}; @@ -892,7 +892,7 @@ pub struct GlobalCtxt<'tcx> { pub(crate) queries: query::Queries<'tcx>, - // Records the free variables refrenced by every closure + // Records the free variables referenced by every closure // expression. Do not track deps for this, just recompute it from // scratch every time. freevars: FxHashMap>>, @@ -1490,10 +1490,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { - pub fn encode_metadata(self, link_meta: &LinkMeta) + pub fn encode_metadata(self) -> EncodedMetadata { - self.cstore.encode_metadata(self, link_meta) + self.cstore.encode_metadata(self) } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6c27d527ae891..4902356321c36 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1503,7 +1503,7 @@ impl UniverseIndex { /// Creates a universe index from the given integer. Not to be /// used lightly lest you pick a bad value. But sometimes we - /// convert universe indicies into integers and back for various + /// convert universe indices into integers and back for various /// reasons. pub fn from_u32(index: u32) -> Self { UniverseIndex(index) diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 56a8c13a8d3b8..e3b0f8c4570df 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -262,7 +262,7 @@ where } } - // Visit the explict waiters which use condvars and are resumable + // Visit the explicit waiters which use condvars and are resumable for (i, waiter) in query.latch.info.lock().waiters.iter().enumerate() { if let Some(ref waiter_query) = waiter.query { if visit(waiter.span, waiter_query.clone()).is_some() { diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 34ddfa9455229..d50a56ad84ab2 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -47,8 +47,7 @@ use std::str; use syntax::attr; pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target, - invalid_output_for_target, build_link_meta, out_filename, - check_file_is_writeable}; + invalid_output_for_target, out_filename, check_file_is_writeable}; // The third parameter is for env vars, used on windows to set up the // path for MSVC to find its DLLs, and gcc to find its bundled diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 462a2c9f02863..80e9965e39cd8 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -19,7 +19,7 @@ use base; use consts; use rustc_incremental::{copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir}; use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; -use rustc::middle::cstore::{LinkMeta, EncodedMetadata}; +use rustc::middle::cstore::EncodedMetadata; use rustc::session::config::{self, OutputFilenames, OutputType, Passes, Sanitizer, Lto}; use rustc::session::Session; use rustc::util::nodemap::FxHashMap; @@ -32,6 +32,7 @@ use rustc::ty::TyCtxt; use rustc::util::common::{time_ext, time_depth, set_time_depth, print_time_passes_entry}; use rustc_fs_util::{path2cstr, link_or_copy}; use rustc_data_structures::small_c_str::SmallCStr; +use rustc_data_structures::svh::Svh; use errors::{self, Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId}; use errors::emitter::{Emitter}; use syntax::attr; @@ -327,7 +328,7 @@ struct AssemblerCommand { /// Additional resources used by optimize_and_codegen (not module specific) #[derive(Clone)] pub struct CodegenContext { - // Resouces needed when running LTO + // Resources needed when running LTO pub time_passes: bool, pub lto: Lto, pub no_landing_pads: bool, @@ -595,7 +596,7 @@ unsafe fn optimize(cgcx: &CodegenContext, -C passes=name-anon-globals to the compiler command line."); } else { bug!("We are using thin LTO buffers without running the NameAnonGlobals pass. \ - This will likely cause errors in LLVM and shoud never happen."); + This will likely cause errors in LLVM and should never happen."); } } } @@ -912,13 +913,13 @@ fn need_crate_bitcode_for_rlib(sess: &Session) -> bool { pub fn start_async_codegen(tcx: TyCtxt, time_graph: Option, - link: LinkMeta, metadata: EncodedMetadata, coordinator_receive: Receiver>, total_cgus: usize) -> OngoingCodegen { let sess = tcx.sess; let crate_name = tcx.crate_name(LOCAL_CRATE); + let crate_hash = tcx.crate_hash(LOCAL_CRATE); let no_builtins = attr::contains_name(&tcx.hir.krate().attrs, "no_builtins"); let subsystem = attr::first_attr_value_str_by_name(&tcx.hir.krate().attrs, "windows_subsystem"); @@ -1037,7 +1038,7 @@ pub fn start_async_codegen(tcx: TyCtxt, OngoingCodegen { crate_name, - link, + crate_hash, metadata, windows_subsystem, linker_info, @@ -2270,7 +2271,7 @@ impl SharedEmitterMain { pub struct OngoingCodegen { crate_name: Symbol, - link: LinkMeta, + crate_hash: Svh, metadata: EncodedMetadata, windows_subsystem: Option, linker_info: LinkerInfo, @@ -2321,7 +2322,7 @@ impl OngoingCodegen { (CodegenResults { crate_name: self.crate_name, - link: self.link, + crate_hash: self.crate_hash, metadata: self.metadata, windows_subsystem: self.windows_subsystem, linker_info: self.linker_info, diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 0330a0598268c..3834672633c05 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -29,7 +29,6 @@ use super::ModuleCodegen; use super::ModuleKind; use abi; -use back::link; use back::write::{self, OngoingCodegen}; use llvm::{self, TypeKind, get_param}; use metadata; @@ -42,7 +41,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::layout::{self, Align, TyLayout, LayoutOf}; use rustc::ty::query::Providers; use rustc::dep_graph::{DepNode, DepConstructor}; -use rustc::middle::cstore::{self, LinkMeta, LinkagePreference}; +use rustc::middle::cstore::{self, LinkagePreference}; use rustc::middle::exported_symbols; use rustc::util::common::{time, print_time_passes_entry}; use rustc::util::profiling::ProfileCategory; @@ -608,8 +607,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) { } fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, - llvm_module: &ModuleLlvm, - link_meta: &LinkMeta) + llvm_module: &ModuleLlvm) -> EncodedMetadata { use std::io::Write; use flate2::Compression; @@ -641,7 +639,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, return EncodedMetadata::new(); } - let metadata = tcx.encode_metadata(link_meta); + let metadata = tcx.encode_metadata(); if kind == MetadataKind::Uncompressed { return metadata; } @@ -719,8 +717,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.sess.fatal("this compiler's LLVM does not support PGO"); } - let crate_hash = tcx.crate_hash(LOCAL_CRATE); - let link_meta = link::build_link_meta(crate_hash); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); // Codegen the metadata. @@ -732,7 +728,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .to_string(); let metadata_llvm_module = ModuleLlvm::new(tcx.sess, &metadata_cgu_name); let metadata = time(tcx.sess, "write metadata", || { - write_metadata(tcx, &metadata_llvm_module, &link_meta) + write_metadata(tcx, &metadata_llvm_module) }); tcx.sess.profiler(|p| p.end_activity(ProfileCategory::Codegen)); @@ -754,7 +750,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let ongoing_codegen = write::start_async_codegen( tcx, time_graph.clone(), - link_meta, metadata, rx, 1); @@ -789,7 +784,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let ongoing_codegen = write::start_async_codegen( tcx, time_graph.clone(), - link_meta, metadata, rx, codegen_units.len()); diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index a65511a24af72..03a2e0a82cf10 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -88,6 +88,7 @@ use rustc::util::nodemap::{FxHashSet, FxHashMap}; use rustc::util::profiling::ProfileCategory; use rustc_mir::monomorphize; use rustc_codegen_utils::codegen_backend::CodegenBackend; +use rustc_data_structures::svh::Svh; mod diagnostics; @@ -251,7 +252,7 @@ impl CodegenBackend for LlvmCodegenBackend { // Now that we won't touch anything in the incremental compilation directory // any more, we can finalize it (which involves renaming it) - rustc_incremental::finalize_session_directory(sess, ongoing_codegen.link.crate_hash); + rustc_incremental::finalize_session_directory(sess, ongoing_codegen.crate_hash); Ok(()) } @@ -389,7 +390,7 @@ struct CodegenResults { modules: Vec, allocator_module: Option, metadata_module: CompiledModule, - link: rustc::middle::cstore::LinkMeta, + crate_hash: Svh, metadata: rustc::middle::cstore::EncodedMetadata, windows_subsystem: Option, linker_info: back::linker::LinkerInfo, diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index 1104408c1c8d7..02de587467277 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -656,7 +656,7 @@ impl FunctionCx<'a, 'll, 'tcx> { llargs.push(b); return; } - _ => bug!("codegen_argument: {:?} invalid for pair arugment", op) + _ => bug!("codegen_argument: {:?} invalid for pair argument", op) } } else if arg.is_unsized_indirect() { match op.val { diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index ae8f65303a7fe..d693e088360d4 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -44,7 +44,7 @@ use rustc::dep_graph::DepGraph; use rustc_target::spec::Target; use rustc_data_structures::fx::FxHashMap; use rustc_mir::monomorphize::collector; -use link::{build_link_meta, out_filename}; +use link::out_filename; pub use rustc_data_structures::sync::MetadataRef; @@ -180,8 +180,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { } tcx.sess.abort_if_errors(); - let link_meta = build_link_meta(tcx.crate_hash(LOCAL_CRATE)); - let metadata = tcx.encode_metadata(&link_meta); + let metadata = tcx.encode_metadata(); box OngoingCodegen { metadata: metadata, diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index a0d88ccae0f13..75f1d614ae72f 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -10,8 +10,6 @@ use rustc::session::config::{self, OutputFilenames, Input, OutputType}; use rustc::session::Session; -use rustc::middle::cstore::LinkMeta; -use rustc_data_structures::svh::Svh; use std::path::{Path, PathBuf}; use syntax::{ast, attr}; use syntax_pos::Span; @@ -50,14 +48,6 @@ fn is_writeable(p: &Path) -> bool { } } -pub fn build_link_meta(crate_hash: Svh) -> LinkMeta { - let r = LinkMeta { - crate_hash, - }; - info!("{:?}", r); - return r; -} - pub fn find_crate_name(sess: Option<&Session>, attrs: &[ast::Attribute], input: &Input) -> String { diff --git a/src/librustc_data_structures/array_vec.rs b/src/librustc_data_structures/array_vec.rs index 56bb961324210..45fb565706180 100644 --- a/src/librustc_data_structures/array_vec.rs +++ b/src/librustc_data_structures/array_vec.rs @@ -139,7 +139,7 @@ impl ArrayVec { // whole Drain iterator (like &mut T). let range_slice = { let arr = &mut self.values as &mut [ManuallyDrop<::Element>]; - slice::from_raw_parts_mut(arr.as_mut_ptr().offset(start as isize), + slice::from_raw_parts_mut(arr.as_mut_ptr().add(start), end - start) }; Drain { @@ -262,8 +262,8 @@ impl<'a, A: Array> Drop for Drain<'a, A> { { let arr = &mut source_array_vec.values as &mut [ManuallyDrop<::Element>]; - let src = arr.as_ptr().offset(tail as isize); - let dst = arr.as_mut_ptr().offset(start as isize); + let src = arr.as_ptr().add(tail); + let dst = arr.as_mut_ptr().add(start); ptr::copy(src, dst, self.tail_len); }; source_array_vec.set_len(start + self.tail_len); diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 5699512326a37..c3ee48d20f6f5 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -25,7 +25,7 @@ #![feature(unsize)] #![feature(specialization)] #![feature(optin_builtin_traits)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(not(stage0), feature(nll))] #![feature(allow_internal_unstable)] #![feature(vec_resize_with)] diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index 6f101b20d8806..689aad25b431d 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -125,7 +125,7 @@ impl SmallVec { // infallible // The spot to put the new value { - let p = self.as_mut_ptr().offset(index as isize); + let p = self.as_mut_ptr().add(index); // Shift everything over to make space. (Duplicating the // `index`th element into two consecutive places.) ptr::copy(p, p.offset(1), len - index); diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index d4c6b1c2ced81..6989cdc0a9a15 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -26,7 +26,7 @@ //! //! `MTLock` is a mutex which disappears if cfg!(parallel_queries) is false. //! -//! `MTRef` is a immutable refernce if cfg!(parallel_queries), and an mutable reference otherwise. +//! `MTRef` is a immutable reference if cfg!(parallel_queries), and an mutable reference otherwise. //! //! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync //! depending on the value of cfg!(parallel_queries). @@ -432,7 +432,7 @@ impl Once { /// closures may concurrently be computing a value which the inner value should take. /// Only one of these closures are used to actually initialize the value. /// If some other closure already set the value, we assert that it our closure computed - /// a value equal to the value aready set and then + /// a value equal to the value already set and then /// we return the value our closure computed wrapped in a `Option`. /// If our closure set the value, `None` is returned. /// If the value is already initialized, the closure is not called and `None` is returned. diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 0936f28a8fb1e..c3cdeda686079 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -889,7 +889,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // NB. this has an edge case with non-returning statements, // like `loop {}` or `panic!()`: control flow never reaches // the exit node through these, so one can have a function - // that never actually calls itselfs but is still picked up by + // that never actually calls itself but is still picked up by // this lint: // // fn f(cond: bool) { diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 801604d1379e3..15eb4730c1d20 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -26,7 +26,7 @@ #![cfg_attr(test, feature(test))] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(not(stage0), feature(nll))] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 46b33255b45a2..eb2b3479401eb 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -486,7 +486,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Protect against infinite recursion, for example // `struct S(*mut S);`. // FIXME: A recursion limit is necessary as well, for irregular - // recusive types. + // recursive types. if !cache.insert(ty) { return FfiSafe; } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index c51bebd2e3b63..083f95656665d 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -17,7 +17,6 @@ use schema; use rustc::ty::query::QueryConfig; use rustc::middle::cstore::{CrateStore, DepKind, - LinkMeta, EncodedMetadata, NativeLibraryKind}; use rustc::middle::exported_symbols::ExportedSymbol; use rustc::middle::stability::DeprecationEntry; @@ -567,11 +566,10 @@ impl CrateStore for cstore::CStore { } fn encode_metadata<'a, 'tcx>(&self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - link_meta: &LinkMeta) + tcx: TyCtxt<'a, 'tcx, 'tcx>) -> EncodedMetadata { - encoder::encode_metadata(tcx, link_meta) + encoder::encode_metadata(tcx) } fn metadata_encoding_version(&self) -> &[u8] diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 4b5c9d68fd7f2..b5a1f4b3b1b27 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -13,7 +13,7 @@ use index_builder::{FromId, IndexBuilder, Untracked}; use isolated_encoder::IsolatedEncoder; use schema::*; -use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary, +use rustc::middle::cstore::{LinkagePreference, NativeLibrary, EncodedMetadata, ForeignModule}; use rustc::hir::def::CtorKind; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; @@ -52,7 +52,6 @@ use rustc::hir::intravisit; pub struct EncodeContext<'a, 'tcx: 'a> { opaque: opaque::Encoder, pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - link_meta: &'a LinkMeta, lazy_state: LazyState, type_shorthands: FxHashMap, usize>, @@ -482,7 +481,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let index_bytes = self.position() - i; let attrs = tcx.hir.krate_attrs(); - let link_meta = self.link_meta; let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro); let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator"); let has_global_allocator = *tcx.sess.has_global_allocator.get(); @@ -491,7 +489,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { name: tcx.crate_name(LOCAL_CRATE), extra_filename: tcx.sess.opts.cg.extra_filename.clone(), triple: tcx.sess.opts.target_triple.clone(), - hash: link_meta.crate_hash, + hash: tcx.crate_hash(LOCAL_CRATE), disambiguator: tcx.sess.local_crate_disambiguator(), panic_strategy: tcx.sess.panic_strategy(), edition: hygiene::default_edition(), @@ -1824,8 +1822,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> { // will allow us to slice the metadata to the precise length that we just // generated regardless of trailing bytes that end up in it. -pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - link_meta: &LinkMeta) +pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> EncodedMetadata { let mut encoder = opaque::Encoder::new(vec![]); @@ -1838,7 +1835,6 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut ecx = EncodeContext { opaque: encoder, tcx, - link_meta, lazy_state: LazyState::NoNode, type_shorthands: Default::default(), predicate_shorthands: Default::default(), diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 70eda895bd0a2..446ea6c324441 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -207,7 +207,7 @@ impl<'a, 'tcx> Collector<'a, 'tcx> { } } - // Update kind and, optionally, the name of all native libaries + // Update kind and, optionally, the name of all native libraries // (there may be more than one) with the specified name. for &(ref name, ref new_name, kind) in &self.tcx.sess.opts.libs { let mut found = false; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 82d3d31a52eb3..4390ca371823a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1080,7 +1080,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - if self + // Check is_empty() first because it's the common case, and doing that + // way we avoid the clone() call. + if !self.access_place_error_reported.is_empty() && + self .access_place_error_reported .contains(&(place_span.0.clone(), place_span.1)) { diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 301999cc4a51e..dc37c21fdabeb 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -541,7 +541,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cg, 'cx, 'tcx, 'gcx> { // unique or mutable borrows are invalidated by writes. // Reservations count as writes since we need to check // that activating the borrow will be OK - // TOOD(bob_twinkles) is this actually the right thing to do? + // FIXME(bob_twinkles) is this actually the right thing to do? this.generate_invalidates(borrow_index, context.loc); } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index ab83cfe25b590..2a78feed84915 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -783,7 +783,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { /// predicates, or otherwise uses the inference context, executes /// `op` and then executes all the further obligations that `op` /// returns. This will yield a set of outlives constraints amongst - /// regions which are extracted and stored as having occured at + /// regions which are extracted and stored as having occurred at /// `locations`. /// /// **Any `rustc::infer` operations that might generate region diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 640ae31d45b34..85abec7e7acc4 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -83,7 +83,7 @@ fn place_components_conflict<'gcx, 'tcx>( // Our invariant is, that at each step of the iteration: // - If we didn't run out of access to match, our borrow and access are comparable // and either equal or disjoint. - // - If we did run out of accesss, the borrow can access a part of it. + // - If we did run out of access, the borrow can access a part of it. loop { // loop invariant: borrow_c is always either equal to access_c or disjoint from it. if let Some(borrow_c) = borrow_components.next() { diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 56c4dac19e504..116cefea17544 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -605,7 +605,7 @@ pub trait BitDenotation: BitwiseOperator { /// `sets.on_entry` to that local clone into `statement_effect` and /// `terminator_effect`). /// - /// When its false, no local clone is constucted; instead a + /// When it's false, no local clone is constructed; instead a /// reference directly into `on_entry` is passed along via /// `sets.on_entry` instead, which represents the flow state at /// the block's start, not necessarily the state immediately prior diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 3329a47759bea..5517ed145546d 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -462,7 +462,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), substituted) } - /// Return the size and aligment of the value at the given type. + /// Return the size and alignment of the value at the given type. /// Note that the value does not matter if the type is sized. For unsized types, /// the value has to be a fat pointer, and we only care about the "extra" data in it. pub fn size_and_align_of_dst( diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index b62add8a559b4..636b04a8d16da 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -599,7 +599,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Some(MemoryKind::Stack) => {}, } if let Some(mut alloc) = alloc { - // ensure llvm knows not to put this into immutable memroy + // ensure llvm knows not to put this into immutable memory alloc.runtime_mutability = mutability; let alloc = self.tcx.intern_const_alloc(alloc); self.tcx.alloc_map.lock().set_id_memory(alloc_id, alloc); diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index bda80ff562c75..19fc087f12803 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -26,7 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(const_fn)] #![feature(core_intrinsics)] #![feature(decl_macro)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(exhaustive_patterns)] #![feature(range_contains)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 85115427edae9..5062775fec168 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -704,7 +704,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *unwind = Some(self.update_target(tgt)); } else if !self.in_cleanup_block { // Unless this drop is in a cleanup block, add an unwind edge to - // the orignal call's cleanup block + // the original call's cleanup block *unwind = self.cleanup_block; } } @@ -716,7 +716,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *cleanup = Some(self.update_target(tgt)); } else if !self.in_cleanup_block { // Unless this call is in a cleanup block, add an unwind edge to - // the orignal call's cleanup block + // the original call's cleanup block *cleanup = self.cleanup_block; } } @@ -726,7 +726,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *cleanup = Some(self.update_target(tgt)); } else if !self.in_cleanup_block { // Unless this assert is in a cleanup block, add an unwind edge to - // the orignal call's cleanup block + // the original call's cleanup block *cleanup = self.cleanup_block; } } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index b3ae65f532592..bb66b9ed6ece8 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -302,7 +302,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { let ref mut statement = blocks[loc.block].statements[loc.statement_index]; match statement.kind { StatementKind::Assign(_, Rvalue::Ref(_, _, ref mut place)) => { - // Find the underlying local for this (necessarilly interior) borrow. + // Find the underlying local for this (necessarily interior) borrow. // HACK(eddyb) using a recursive function because of mutable borrows. fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>) -> &'a mut Place<'tcx> { diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 7a8c35e7b96f5..4e9e085ca08a3 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -190,7 +190,7 @@ impl MirPass for RestoreSubsliceArrayMoveOut { let local_use = &visitor.locals_use[*local]; let opt_index_and_place = Self::try_get_item_source(local_use, mir); // each local should be used twice: - // in assign and in aggregate statments + // in assign and in aggregate statements if local_use.use_count == 2 && opt_index_and_place.is_some() { let (index, src_place) = opt_index_and_place.unwrap(); return Some((local_use, index, src_place)); @@ -231,15 +231,15 @@ impl RestoreSubsliceArrayMoveOut { if opt_size.is_some() && items.iter().all( |l| l.is_some() && l.unwrap().2 == opt_src_place.unwrap()) { - let indicies: Vec<_> = items.iter().map(|x| x.unwrap().1).collect(); - for i in 1..indicies.len() { - if indicies[i - 1] + 1 != indicies[i] { + let indices: Vec<_> = items.iter().map(|x| x.unwrap().1).collect(); + for i in 1..indices.len() { + if indices[i - 1] + 1 != indices[i] { return; } } - let min = *indicies.first().unwrap(); - let max = *indicies.last().unwrap(); + let min = *indices.first().unwrap(); + let max = *indices.last().unwrap(); for item in items { let locals_use = item.unwrap().0; diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index df975998edcf8..bf835f5f0d9ad 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -459,7 +459,7 @@ fn write_scope_tree( let indent = depth * INDENT.len(); let children = match scope_tree.get(&parent) { - Some(childs) => childs, + Some(children) => children, None => return Ok(()), }; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 282589c4e68cf..b56cc5fad069d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -201,7 +201,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, if let Some(impl_span) = maybe_impl_defid.map_or(None, |def_id| resolver.definitions.opt_span(def_id)) { err.span_label(reduce_impl_span_to_impl_keyword(cm, impl_span), - "`Self` type implicitely declared here, on the `impl`"); + "`Self` type implicitly declared here, on the `impl`"); } }, Def::TyParam(typaram_defid) => { diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 8bffecfc7c901..973580bcbe904 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -81,7 +81,7 @@ fn dropck_outlives<'tcx>( // into the types of its fields `(B, Vec)`. These will get // pushed onto the stack. Eventually, expanding `Vec` will // lead to us trying to push `A` a second time -- to prevent - // infinite recusion, we notice that `A` was already pushed + // infinite recursion, we notice that `A` was already pushed // once and stop. let mut ty_stack = vec![(for_ty, 0)]; diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 6e0c0bac186f4..f0afc58b3cec5 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -121,7 +121,7 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, // Replace all regions inside the generator interior with late bound regions // Note that each region slot in the types gets a new fresh late bound region, // which means that none of the regions inside relate to any other, even if - // typeck had previously found contraints that would cause them to be related. + // typeck had previously found constraints that would cause them to be related. let mut counter = 0; let type_list = fcx.tcx.fold_regions(&type_list, &mut false, |_, current_depth| { counter += 1; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b57967a7aab21..c8a8ca4fc3038 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -876,7 +876,7 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // backwards compatibility. This makes fallback a stronger type hint than a cast coercion. fcx.check_casts(); - // Closure and generater analysis may run after fallback + // Closure and generator analysis may run after fallback // because they don't constrain other type variables. fcx.closure_analyze(body); assert!(fcx.deferred_call_resolutions.borrow().is_empty()); @@ -2329,7 +2329,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // unconstrained floats with f64. // Fallback becomes very dubious if we have encountered type-checking errors. // In that case, fallback to TyError. - // The return value indicates whether fallback has occured. + // The return value indicates whether fallback has occurred. fn fallback_if_possible(&self, ty: Ty<'tcx>) -> bool { use rustc::ty::error::UnconstrainedNumeric::Neither; use rustc::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 8aa5658d291db..6af939fcf99b7 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1284,7 +1284,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { // how all the types get adjusted.) match ref_kind { ty::ImmBorrow => { - // The reference being reborrowed is a sharable ref of + // The reference being reborrowed is a shareable ref of // type `&'a T`. In this case, it doesn't matter where we // *found* the `&T` pointer, the memory it references will // be valid and immutable for `'a`. So we can stop here. diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index b37f489b2c721..e87183f847321 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -516,7 +516,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } fn visit_node_id(&mut self, span: Span, hir_id: hir::HirId) { - // Export associated path extensions and method resultions. + // Export associated path extensions and method resolutions. if let Some(def) = self.fcx .tables .borrow_mut() diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index b7921301957ce..11260b8f11e12 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -152,7 +152,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // } // ``` // - // In a concession to backwards compatbility, we continue to + // In a concession to backwards compatibility, we continue to // permit those, so long as the lifetimes aren't used in // associated types. I believe this is sound, because lifetimes // used elsewhere are not projected back out. diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 1331bd5186f19..de5a680ccf9d1 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -824,7 +824,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { // In fact, the iteration of an FxHashMap can even vary between platforms, // since FxHasher has different behavior for 32-bit and 64-bit platforms. // - // Obviously, it's extremely undesireable for documentation rendering + // Obviously, it's extremely undesirable for documentation rendering // to be depndent on the platform it's run on. Apart from being confusing // to end users, it makes writing tests much more difficult, as predicates // can appear in any order in the final result. @@ -836,7 +836,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { // predicates and bounds, however, we ensure that for a given codebase, all // auto-trait impls always render in exactly the same way. // - // Using the Debug impementation for sorting prevents us from needing to + // Using the Debug implementation for sorting prevents us from needing to // write quite a bit of almost entirely useless code (e.g. how should two // Types be sorted relative to each other). It also allows us to solve the // problem for both WherePredicates and GenericBounds at the same time. This diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index d5aab1fb098e1..f90f1e54da22c 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -31,7 +31,7 @@ pub enum Cfg { True, /// Denies all configurations. False, - /// A generic configration option, e.g. `test` or `target_os = "linux"`. + /// A generic configuration option, e.g. `test` or `target_os = "linux"`. Cfg(Symbol, Option), /// Negate a configuration requirement, i.e. `not(x)`. Not(Box), diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 44a9710e30f7d..4caea56faad34 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -315,7 +315,7 @@ pub struct Cache { // the access levels from crateanalysis. pub access_levels: Arc>, - /// The version of the crate being documented, if given fron the `--crate-version` flag. + /// The version of the crate being documented, if given from the `--crate-version` flag. pub crate_version: Option, // Private fields only used when initially crawling a crate to build a cache diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index b63abec1f0e8b..70782973e426d 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -52,6 +52,8 @@ var themesWidth = null; + var titleBeforeSearch = document.title; + if (!String.prototype.startsWith) { String.prototype.startsWith = function(searchString, position) { position = position || 0; @@ -267,6 +269,7 @@ ev.preventDefault(); addClass(search, "hidden"); removeClass(document.getElementById("main"), "hidden"); + document.title = titleBeforeSearch; } defocusSearchBar(); } diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs index da705081ff34d..9748a5063925b 100644 --- a/src/libserialize/collection_impls.rs +++ b/src/libserialize/collection_impls.rs @@ -17,9 +17,7 @@ use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSe use std::rc::Rc; use std::sync::Arc; -impl< - T: Encodable -> Encodable for LinkedList { +impl Encodable for LinkedList { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { for (i, e) in self.iter().enumerate() { @@ -65,10 +63,10 @@ impl Decodable for VecDeque { } } -impl< - K: Encodable + PartialEq + Ord, - V: Encodable -> Encodable for BTreeMap { +impl Encodable for BTreeMap + where K: Encodable + PartialEq + Ord, + V: Encodable +{ fn encode(&self, e: &mut S) -> Result<(), S::Error> { e.emit_map(self.len(), |e| { let mut i = 0; @@ -82,10 +80,10 @@ impl< } } -impl< - K: Decodable + PartialEq + Ord, - V: Decodable -> Decodable for BTreeMap { +impl Decodable for BTreeMap + where K: Decodable + PartialEq + Ord, + V: Decodable +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_map(|d, len| { let mut map = BTreeMap::new(); @@ -99,9 +97,9 @@ impl< } } -impl< - T: Encodable + PartialEq + Ord -> Encodable for BTreeSet { +impl Encodable for BTreeSet + where T: Encodable + PartialEq + Ord +{ fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { let mut i = 0; @@ -114,9 +112,9 @@ impl< } } -impl< - T: Decodable + PartialEq + Ord -> Decodable for BTreeSet { +impl Decodable for BTreeSet + where T: Decodable + PartialEq + Ord +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut set = BTreeSet::new(); diff --git a/src/libserialize/leb128.rs b/src/libserialize/leb128.rs index eee95d9fa6777..e02bc5e1025fd 100644 --- a/src/libserialize/leb128.rs +++ b/src/libserialize/leb128.rs @@ -118,6 +118,7 @@ pub fn write_signed_leb128_to(mut value: i128, mut write: W) } } +#[inline] pub fn write_signed_leb128(out: &mut Vec, value: i128) { write_signed_leb128_to(value, |v| write_to_vec(out, v)) } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index a77d1d9b88b89..c71f474891131 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -31,6 +31,7 @@ impl Encoder { self.data } + #[inline] pub fn emit_raw_bytes(&mut self, s: &[u8]) { self.data.extend_from_slice(s); } @@ -193,6 +194,7 @@ impl<'a> Decoder<'a> { self.position += bytes; } + #[inline] pub fn read_raw_bytes(&mut self, s: &mut [u8]) -> Result<(), String> { let start = self.position; let end = start + s.len(); @@ -326,6 +328,7 @@ impl<'a> serialize::Decoder for Decoder<'a> { Ok(Cow::Borrowed(s)) } + #[inline] fn error(&mut self, err: &str) -> Self::Error { err.to_string() } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index ed94194ffcc05..60bb5a0fec2cd 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -119,6 +119,7 @@ pub trait Encoder { self.emit_enum("Option", f) } + #[inline] fn emit_option_none(&mut self) -> Result<(), Self::Error> { self.emit_enum_variant("None", 0, 0, |_| Ok(())) } @@ -560,14 +561,12 @@ impl< T: Decodable> Decodable for Box<[T]> { } impl Encodable for Rc { - #[inline] fn encode(&self, s: &mut S) -> Result<(), S::Error> { (**self).encode(s) } } impl Decodable for Rc { - #[inline] fn decode(d: &mut D) -> Result, D::Error> { Ok(Rc::new(Decodable::decode(d)?)) } @@ -618,7 +617,9 @@ impl<'a, T:Encodable> Encodable for Cow<'a, [T]> where [T]: ToOwned Decodable for Cow<'static, [T]> where [T]: ToOwned> { +impl Decodable for Cow<'static, [T]> + where [T]: ToOwned> +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut v = Vec::with_capacity(len); diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 2b319186a8db2..768357ec8dc41 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -234,10 +234,10 @@ fn can_alias_safehash_as_hash() { // make a RawBucket point to invalid memory using safe code. impl RawBucket { unsafe fn hash(&self) -> *mut HashUint { - self.hash_start.offset(self.idx as isize) + self.hash_start.add(self.idx) } unsafe fn pair(&self) -> *mut (K, V) { - self.pair_start.offset(self.idx as isize) as *mut (K, V) + self.pair_start.add(self.idx) as *mut (K, V) } unsafe fn hash_pair(&self) -> (*mut HashUint, *mut (K, V)) { (self.hash(), self.pair()) diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 12ea1ea9f9d49..cadb5c0ba5d0e 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -88,7 +88,7 @@ where /// This function acquires exclusive access to the task context. /// /// Panics if no task has been set or if the task context has already been -/// retrived by a surrounding call to get_task_cx. +/// retrieved by a surrounding call to get_task_cx. pub fn get_task_cx(f: F) -> R where F: FnOnce(&mut task::Context) -> R diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 03c97de6ec1e9..77bc7e946eb41 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -889,7 +889,7 @@ impl Write for LineWriter { // Find the last newline character in the buffer provided. If found then // we're going to write all the data up to that point and then flush, - // otherewise we just write the whole block to the underlying writer. + // otherwise we just write the whole block to the underlying writer. let i = match memchr::memrchr(b'\n', buf) { Some(i) => i, None => return self.inner.write(buf), diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index b0069f826eefa..ade297219d221 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -270,7 +270,7 @@ #![feature(libc)] #![feature(link_args)] #![feature(linkage)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(needs_panic_runtime)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] diff --git a/src/libstd/memchr.rs b/src/libstd/memchr.rs index 240e82069ff4d..c28f3da98cea9 100644 --- a/src/libstd/memchr.rs +++ b/src/libstd/memchr.rs @@ -57,7 +57,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { #[cfg(test)] mod tests { - // test the implementations for the current plattform + // test the implementations for the current platform use super::{memchr, memrchr}; #[test] diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 9a610cd7d6ba3..d45a66ef66532 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -357,15 +357,12 @@ impl Ipv4Addr { /// # Examples /// /// ``` - /// #![feature(ip_constructors)] /// use std::net::Ipv4Addr; /// /// let addr = Ipv4Addr::LOCALHOST; /// assert_eq!(addr, Ipv4Addr::new(127, 0, 0, 1)); /// ``` - #[unstable(feature = "ip_constructors", - reason = "requires greater scrutiny before stabilization", - issue = "44582")] + #[stable(feature = "ip_constructors", since = "1.30.0")] pub const LOCALHOST: Self = Ipv4Addr::new(127, 0, 0, 1); /// An IPv4 address representing an unspecified address: 0.0.0.0 @@ -373,15 +370,12 @@ impl Ipv4Addr { /// # Examples /// /// ``` - /// #![feature(ip_constructors)] /// use std::net::Ipv4Addr; /// /// let addr = Ipv4Addr::UNSPECIFIED; /// assert_eq!(addr, Ipv4Addr::new(0, 0, 0, 0)); /// ``` - #[unstable(feature = "ip_constructors", - reason = "requires greater scrutiny before stabilization", - issue = "44582")] + #[stable(feature = "ip_constructors", since = "1.30.0")] pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0); /// An IPv4 address representing the broadcast address: 255.255.255.255 @@ -389,15 +383,12 @@ impl Ipv4Addr { /// # Examples /// /// ``` - /// #![feature(ip_constructors)] /// use std::net::Ipv4Addr; /// /// let addr = Ipv4Addr::BROADCAST; /// assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255)); /// ``` - #[unstable(feature = "ip_constructors", - reason = "requires greater scrutiny before stabilization", - issue = "44582")] + #[stable(feature = "ip_constructors", since = "1.30.0")] pub const BROADCAST: Self = Ipv4Addr::new(255, 255, 255, 255); /// Returns the four eight-bit integers that make up this address. @@ -896,15 +887,12 @@ impl Ipv6Addr { /// # Examples /// /// ``` - /// #![feature(ip_constructors)] /// use std::net::Ipv6Addr; /// /// let addr = Ipv6Addr::LOCALHOST; /// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); /// ``` - #[unstable(feature = "ip_constructors", - reason = "requires greater scrutiny before stabilization", - issue = "44582")] + #[stable(feature = "ip_constructors", since = "1.30.0")] pub const LOCALHOST: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1); /// An IPv6 address representing the unspecified address: `::` @@ -912,15 +900,12 @@ impl Ipv6Addr { /// # Examples /// /// ``` - /// #![feature(ip_constructors)] /// use std::net::Ipv6Addr; /// /// let addr = Ipv6Addr::UNSPECIFIED; /// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)); /// ``` - #[unstable(feature = "ip_constructors", - reason = "requires greater scrutiny before stabilization", - issue = "44582")] + #[stable(feature = "ip_constructors", since = "1.30.0")] pub const UNSPECIFIED: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0); /// Returns the eight 16-bit segments that make up this address. diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index f6cb8beae8415..f258ff073e2a7 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -176,7 +176,7 @@ impl Once { /// happens-before relation between the closure and code executing after the /// return). /// - /// If the given closure recusively invokes `call_once` on the same `Once` + /// If the given closure recursively invokes `call_once` on the same `Once` /// instance the exact behavior is not specified, allowed outcomes are /// a panic or a deadlock. /// diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 7a89d9857bbcf..1d5b0cfa94ad5 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -857,7 +857,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { use sync::atomic::{AtomicBool, Ordering}; // Kernel prior to 4.5 don't have copy_file_range - // We store the availability in a global to avoid unneccessary syscalls + // We store the availability in a global to avoid unnecessary syscalls static HAS_COPY_FILE_RANGE: AtomicBool = AtomicBool::new(true); unsafe fn copy_file_range( diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index 04d9f0b06d344..8c73fe8c6129f 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -35,7 +35,7 @@ use libc::SOCK_CLOEXEC; #[cfg(not(target_os = "linux"))] const SOCK_CLOEXEC: c_int = 0; -// Another conditional contant for name resolution: Macos et iOS use +// Another conditional constant for name resolution: Macos et iOS use // SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket. // Other platforms do otherwise. #[cfg(target_vendor = "apple")] diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index df1dd7401af61..4b19519a57a87 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -359,6 +359,6 @@ unsafe fn slice_to_end(v: &mut Vec) -> &mut [u8] { if v.capacity() == v.len() { v.reserve(1); } - slice::from_raw_parts_mut(v.as_mut_ptr().offset(v.len() as isize), + slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len()) } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 45204b56ead36..8725abe741679 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -772,7 +772,7 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool { pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { // memory layout of an &[u8] and &Wtf8 are the same Wtf8::from_bytes_unchecked(slice::from_raw_parts( - s.bytes.as_ptr().offset(begin as isize), + s.bytes.as_ptr().add(begin), end - begin )) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b12b2c49caa58..06e4087171a83 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -321,7 +321,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // we'll be able to immediately resolve most of imported macros. self.resolve_imports(); - // Resolve paths in all invocations and produce ouput expanded fragments for them, but + // Resolve paths in all invocations and produce output expanded fragments for them, but // do not insert them into our input AST fragment yet, only store in `expanded_fragments`. // The output fragments also go through expansion recursively until no invocations are left. // Unresolved macros produce dummy outputs as a recovery measure. diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 82f88d1d8643e..7d98fa661c039 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -637,7 +637,7 @@ pub fn parse( // A queue of possible matcher positions. We initialize it with the matcher position in which // the "dot" is before the first token of the first token tree in `ms`. `inner_parse_loop` then - // processes all of these possible matcher positions and produces posible next positions into + // processes all of these possible matcher positions and produces possible next positions into // `next_items`. After some post-processing, the contents of `next_items` replenish `cur_items` // and we start over again. // @@ -726,7 +726,7 @@ pub fn parse( ), ); } - // If there are no posible next positions AND we aren't waiting for the black-box parser, + // If there are no possible next positions AND we aren't waiting for the black-box parser, // then their is a syntax error. else if bb_items.is_empty() && next_items.is_empty() { return Failure(parser.span, parser.token); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 770561fe3269a..2c738ac2a04cd 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -964,7 +964,7 @@ fn is_legal_fragment_specifier(sess: &ParseSess, frag_span: Span) -> bool { match frag_name { "item" | "block" | "stmt" | "expr" | "pat" | "lifetime" | - "path" | "ty" | "ident" | "meta" | "tt" | "" => true, + "path" | "ty" | "ident" | "meta" | "tt" | "vis" | "" => true, "literal" => { if !features.macro_literal_matcher && !attr::contains_name(attrs, "allow_internal_unstable") { @@ -977,18 +977,6 @@ fn is_legal_fragment_specifier(sess: &ParseSess, } true }, - "vis" => { - if !features.macro_vis_matcher && - !attr::contains_name(attrs, "allow_internal_unstable") { - let explain = feature_gate::EXPLAIN_VIS_MATCHER; - emit_feature_err(sess, - "macro_vis_matcher", - frag_span, - GateIssue::Language, - explain); - } - true - }, _ => false, } } diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 357fc77a3a79d..cc635a29275fa 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -323,7 +323,7 @@ where } // `tree` is followed by an `ident`. This could be `$meta_var` or the `$crate` special - // metavariable that names the crate of the invokation. + // metavariable that names the crate of the invocation. Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { let (ident, is_raw) = token.ident().unwrap(); let span = ident_span.with_lo(span.lo()); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 74f573fceba81..2d74b4508a244 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -342,9 +342,6 @@ declare_features! ( // Allows overlapping impls of marker traits (active, overlapping_marker_traits, "1.18.0", Some(29864), None), - // Allows use of the :vis macro fragment specifier - (active, macro_vis_matcher, "1.18.0", Some(41022), None), - // rustc internal (active, abi_thiscall, "1.19.0", None, None), @@ -648,6 +645,8 @@ declare_features! ( (accepted, repr_transparent, "1.28.0", Some(43036), None), // Defining procedural macros in `proc-macro` crates (accepted, proc_macro, "1.29.0", Some(38356), None), + // Allows use of the :vis macro fragment specifier + (accepted, macro_vis_matcher, "1.29.0", Some(41022), None), // Allows importing and reexporting macros with `use`, // enables macro modularization in general. (accepted, use_extern_macros, "1.30.0", Some(35896), None), @@ -1363,9 +1362,6 @@ pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &'static str = pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str = "attributes of the form `#[derive_*]` are reserved for the compiler"; -pub const EXPLAIN_VIS_MATCHER: &'static str = - ":vis fragment specifier is experimental and subject to change"; - pub const EXPLAIN_LITERAL_MATCHER: &'static str = ":literal fragment specifier is experimental and subject to change"; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index adf01197c6d9f..1136cda5ee359 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -533,7 +533,7 @@ fn byte_lit(lit: &str) -> (u8, usize) { fn byte_str_lit(lit: &str) -> Lrc> { let mut res = Vec::with_capacity(lit.len()); - let error = |i| format!("lexer should have rejected {} at {}", lit, i); + let error = |i| panic!("lexer should have rejected {} at {}", lit, i); /// Eat everything up to a non-whitespace fn eat>(it: &mut iter::Peekable) { @@ -552,12 +552,11 @@ fn byte_str_lit(lit: &str) -> Lrc> { loop { match chars.next() { Some((i, b'\\')) => { - let em = error(i); - match chars.peek().expect(&em).1 { + match chars.peek().unwrap_or_else(|| error(i)).1 { b'\n' => eat(&mut chars), b'\r' => { chars.next(); - if chars.peek().expect(&em).1 != b'\n' { + if chars.peek().unwrap_or_else(|| error(i)).1 != b'\n' { panic!("lexer accepted bare CR"); } eat(&mut chars); @@ -574,8 +573,7 @@ fn byte_str_lit(lit: &str) -> Lrc> { } }, Some((i, b'\r')) => { - let em = error(i); - if chars.peek().expect(&em).1 != b'\n' { + if chars.peek().unwrap_or_else(|| error(i)).1 != b'\n' { panic!("lexer accepted bare CR"); } chars.next(); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b1e2e69863d97..5467bab33f90d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3535,8 +3535,8 @@ impl<'a> Parser<'a> { if arm_start_lines.lines[0].end_col == expr_lines.lines[0].end_col && expr_lines.lines.len() == 2 && self.token == token::FatArrow => { - // We check wether there's any trailing code in the parse span, if there - // isn't, we very likely have the following: + // We check whether there's any trailing code in the parse span, + // if there isn't, we very likely have the following: // // X | &Y => "y" // | -- - missing comma @@ -3934,7 +3934,7 @@ impl<'a> Parser<'a> { } /// A wrapper around `parse_pat` with some special error handling for the - /// "top-level" patterns in a match arm, `for` loop, `let`, &c. (in contast + /// "top-level" patterns in a match arm, `for` loop, `let`, &c. (in contrast /// to subpatterns within such). fn parse_top_level_pat(&mut self) -> PResult<'a, P> { let pat = self.parse_pat()?; @@ -4322,7 +4322,7 @@ impl<'a> Parser<'a> { // If `break_on_semi` is `Break`, then we will stop consuming tokens after // finding (and consuming) a `;` outside of `{}` or `[]` (note that this is // approximate - it can mean we break too early due to macros, but that - // shoud only lead to sub-optimal recovery, not inaccurate parsing). + // should only lead to sub-optimal recovery, not inaccurate parsing). // // If `break_on_block` is `Break`, then we will stop consuming tokens // after finding (and consuming) a brace-delimited block. @@ -4887,7 +4887,7 @@ impl<'a> Parser<'a> { fn parse_generic_bounds_common(&mut self, allow_plus: bool) -> PResult<'a, GenericBounds> { let mut bounds = Vec::new(); loop { - // This needs to be syncronized with `Token::can_begin_bound`. + // This needs to be synchronized with `Token::can_begin_bound`. let is_bound_start = self.check_path() || self.check_lifetime() || self.check(&token::Question) || self.check_keyword(keywords::For) || diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index d97c0b14f797a..bebf20b1a3855 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -117,7 +117,7 @@ struct Context<'a, 'b: 'a> { invalid_refs: Vec<(usize, usize)>, /// Spans of all the formatting arguments, in order. arg_spans: Vec, - /// Wether this formatting string is a literal or it comes from a macro. + /// Whether this formatting string is a literal or it comes from a macro. is_literal: bool, } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 62f22475e7de7..6b4684e14fcfe 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -586,7 +586,7 @@ impl InternedString { }); // This is safe because the interner keeps string alive until it is dropped. // We can access it because we know the interner is still alive since we use a - // scoped thread local to access it, and it was alive at the begining of this scope + // scoped thread local to access it, and it was alive at the beginning of this scope unsafe { f(&*str) } } diff --git a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs index 7a16b22a023c4..2951ee4f6c94b 100644 --- a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs @@ -28,7 +28,7 @@ fn start(_: isize, _: *const *const u8) -> isize { let _: (char, u32) = Trait::without_default_impl(0); // Currently, no object code is generated for trait methods with default - // implemenations, unless they are actually called from somewhere. Therefore + // implementations, unless they are actually called from somewhere. Therefore // we cannot import the implementations and have to create our own inline. //~ MONO_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl[0] let _ = Trait::with_default_impl(0u32); diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs index 7303af73cac9e..c965a3ed86c82 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #[macro_use] extern crate rustc; diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs index 3f3997726c939..8ccb5878c4045 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] // Load rustc as a plugin to get macros diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs index ab39709c529dc..315dad7eea515 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff --git a/src/test/compile-fail-fulldeps/auxiliary/pub_and_stability.rs b/src/test/compile-fail-fulldeps/auxiliary/pub_and_stability.rs index eedc1e745e270..f46d906d865a8 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/pub_and_stability.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/pub_and_stability.rs @@ -9,7 +9,7 @@ // except according to those terms. // This crate attempts to enumerate the various scenarios for how a -// type can define fields and methods with various visiblities and +// type can define fields and methods with various visibilities and // stabilities. // // The basic stability pattern in this file has four cases: @@ -23,7 +23,7 @@ // // However, since stability attributes can only be observed in // cross-crate linkage scenarios, there is little reason to take the -// cross-product (4 stability cases * 4 visiblity cases), because the +// cross-product (4 stability cases * 4 visibility cases), because the // first three visibility cases cannot be accessed outside this crate, // and therefore stability is only relevant when the visibility is pub // to the whole universe. diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index 3f75229948df0..c7d5574f909f2 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:runned an unexported test +// error-pattern:ran an unexported test // compile-flags:--test // check-stdout @@ -17,6 +17,6 @@ mod m { #[test] fn unexported() { - panic!("runned an unexported test"); + panic!("ran an unexported test"); } } diff --git a/src/test/run-make-fulldeps/hir-tree/Makefile b/src/test/run-make-fulldeps/hir-tree/Makefile index 2e100b269e14b..3412c8ce1f582 100644 --- a/src/test/run-make-fulldeps/hir-tree/Makefile +++ b/src/test/run-make-fulldeps/hir-tree/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# Test that hir-tree output doens't crash and includes +# Test that hir-tree output doesn't crash and includes # the string constant we would expect to see. all: diff --git a/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile index 0019e5ee7943b..b669f9cedc1e9 100644 --- a/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile +++ b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# Test that hir-tree output doens't crash and includes +# Test that hir-tree output doesn't crash and includes # the string constant we would expect to see. all: diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile index bea5519ec5f70..4b7fece36d92a 100644 --- a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile @@ -3,7 +3,7 @@ LOG := $(TMPDIR)/log.txt # This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both +# rust library (contrast to an rlib). The shared library and executable both # are compiled with address sanitizer, and we assert that a fault in the cdylib # is correctly detected. diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile index 0cc8f73da8b56..97f6172142224 100644 --- a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile @@ -3,7 +3,7 @@ LOG := $(TMPDIR)/log.txt # This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both +# rust library (contrast to an rlib). The shared library and executable both # are compiled with address sanitizer, and we assert that a fault in the dylib # is correctly detected. diff --git a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs index fa208e14b7d1c..601003827c6a2 100644 --- a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs +++ b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #[macro_use] extern crate rustc; diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs index 7edb3e0f8a083..adcd2d605e3ce 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs @@ -9,7 +9,7 @@ // except according to those terms. #![feature(box_syntax, plugin, plugin_registrar, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #![crate_type = "dylib"] diff --git a/src/test/run-pass/dropck_legal_cycles.rs b/src/test/run-pass/dropck_legal_cycles.rs index b6e640ab5b5b6..5f915a762d149 100644 --- a/src/test/run-pass/dropck_legal_cycles.rs +++ b/src/test/run-pass/dropck_legal_cycles.rs @@ -385,7 +385,7 @@ pub fn main() { // RwLock (since we can grab the child pointers in read-only // mode), but we cannot lock a std::sync::Mutex to guard reading // from each node via the same pattern, since once you hit the - // cycle, you'll be trying to acquring the same lock twice. + // cycle, you'll be trying to acquiring the same lock twice. // (We deal with this by exiting the traversal early if try_lock fails.) // Cycle 12: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, refcells diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index d09376acc84ae..37436d7ae0042 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -310,7 +310,7 @@ fn test_order() { } fn test_once() { - // Make sure each argument are evaluted only once even though it may be + // Make sure each argument are evaluated only once even though it may be // formatted multiple times fn foo() -> isize { static mut FOO: isize = 0; diff --git a/src/test/run-pass/issue-15881-model-lexer-dotdotdot.rs b/src/test/run-pass/issue-15881-model-lexer-dotdotdot.rs index 2ec97e373b29b..04ffad501b042 100644 --- a/src/test/run-pass/issue-15881-model-lexer-dotdotdot.rs +++ b/src/test/run-pass/issue-15881-model-lexer-dotdotdot.rs @@ -27,7 +27,7 @@ pub fn main() { } match 'c' { 'a'...'z' => {} - _ => panic!("should suppport char ranges") + _ => panic!("should support char ranges") } match -3_isize { -7...5 => {} diff --git a/src/test/run-pass/issue-20616.rs b/src/test/run-pass/issue-20616.rs index d5b799710941b..5727f54cd7046 100644 --- a/src/test/run-pass/issue-20616.rs +++ b/src/test/run-pass/issue-20616.rs @@ -26,7 +26,7 @@ type TypeD = TypeA<'static>; // trailing comma on lifetime bounds type TypeE = TypeA<'static,>; -// normal type arugment +// normal type argument type TypeF = Box; // type argument with trailing comma diff --git a/src/test/run-pass/issue-33903.rs b/src/test/run-pass/issue-33903.rs index ab368537e21c0..3bc0f7a0fdee8 100644 --- a/src/test/run-pass/issue-33903.rs +++ b/src/test/run-pass/issue-33903.rs @@ -11,7 +11,7 @@ // Issue 33903: // Built-in indexing should be used even when the index is not // trivially an integer -// Only built-in indexing can be used in constant expresssions +// Only built-in indexing can be used in constant expressions const FOO: i32 = [12, 34][0 + 1]; diff --git a/src/test/run-pass/issue-48962.rs b/src/test/run-pass/issue-48962.rs index a603dfbfe5fa5..46aeb329c896b 100644 --- a/src/test/run-pass/issue-48962.rs +++ b/src/test/run-pass/issue-48962.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that we are able to reinitilize box with moved referent +// Test that we are able to reinitialize box with moved referent #![feature(nll)] static mut ORDER: [usize; 3] = [0, 0, 0]; static mut INDEX: usize = 0; diff --git a/src/test/run-pass/macro-first-set.rs b/src/test/run-pass/macro-first-set.rs index c371a33257f4e..9216040ab6ec8 100644 --- a/src/test/run-pass/macro-first-set.rs +++ b/src/test/run-pass/macro-first-set.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] //{{{ issue 40569 ============================================================== diff --git a/src/test/run-pass/macro-pub-matcher.rs b/src/test/run-pass/macro-pub-matcher.rs index 32145277252cb..db8331358b96e 100644 --- a/src/test/run-pass/macro-pub-matcher.rs +++ b/src/test/run-pass/macro-pub-matcher.rs @@ -9,7 +9,8 @@ // except according to those terms. #![allow(dead_code, unused_imports)] -#![feature(macro_vis_matcher, crate_visibility_modifier)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] +#![feature(crate_visibility_modifier)] /** Ensure that `:vis` matches can be captured in existing positions, and passed diff --git a/src/test/run-pass/match-range.rs b/src/test/run-pass/match-range.rs index 859edb80a0743..efa725321967d 100644 --- a/src/test/run-pass/match-range.rs +++ b/src/test/run-pass/match-range.rs @@ -34,7 +34,7 @@ pub fn main() { } match 'c' { 'a'..='z' => {} - _ => panic!("should suppport char ranges") + _ => panic!("should support char ranges") } match -3 { -7..=5 => {} diff --git a/src/test/run-pass/match-reassign.rs b/src/test/run-pass/match-reassign.rs index 759296ad46b87..bedcee43db5ba 100644 --- a/src/test/run-pass/match-reassign.rs +++ b/src/test/run-pass/match-reassign.rs @@ -9,7 +9,7 @@ // except according to those terms. // Regression test for #23698: The reassignment checker only cared -// about the last assigment in a match arm body +// about the last assignment in a match arm body // Use an extra function to make sure no extra assignments // are introduced by macros in the match statement diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 4de8f6a719415..220482f57eb01 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -27,7 +27,7 @@ impl<'a> MyWriter for &'a mut [u8] { let write_len = buf.len(); unsafe { *self = slice::from_raw_parts_mut( - self.as_mut_ptr().offset(write_len as isize), + self.as_mut_ptr().add(write_len), self.len() - write_len ); } diff --git a/src/test/run-pass/packed-struct-optimized-enum.rs b/src/test/run-pass/packed-struct-optimized-enum.rs index 7968ae2278ae9..9d23a0c71489a 100644 --- a/src/test/run-pass/packed-struct-optimized-enum.rs +++ b/src/test/run-pass/packed-struct-optimized-enum.rs @@ -26,7 +26,7 @@ fn sanity_check_size(one: T) { fn main() { // This can fail if rustc and LLVM disagree on the size of a type. - // In this case, `Option>` was erronously not + // In this case, `Option>` was erroneously not // marked as packed despite needing alignment `1` and containing // its `&()` discriminant, which has alignment larger than `1`. sanity_check_size((Some(Packed((&(), 0))), true)); diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index 61ef386442bb9..c4cae1e1d611d 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -37,8 +37,8 @@ unsafe fn test_triangle() -> bool { for i in 0..COUNT / 2 { let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); for j in 0..size { - assert_eq!(*p0.offset(j as isize), i as u8); - assert_eq!(*p1.offset(j as isize), i as u8); + assert_eq!(*p0.add(j), i as u8); + assert_eq!(*p1.add(j), i as u8); } } } @@ -100,8 +100,8 @@ unsafe fn test_triangle() -> bool { for i in 0..COUNT / 2 { let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); for j in 0..size { - *p0.offset(j as isize) = i as u8; - *p1.offset(j as isize) = i as u8; + *p0.add(j) = i as u8; + *p1.add(j) = i as u8; } } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index a0b83ba4c24a5..d349519478ae4 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -36,7 +36,7 @@ fn start(argc: isize, argv: *const *const u8) -> isize { let args = unsafe { (0..argc as usize).map(|i| { - let ptr = *argv.offset(i as isize) as *const _; + let ptr = *argv.add(i) as *const _; CStr::from_ptr(ptr).to_bytes().to_vec() }).collect::>() }; diff --git a/src/test/run-pass/signal-alternate-stack-cleanup.rs b/src/test/run-pass/signal-alternate-stack-cleanup.rs index eae431aa4044d..ad099f82d13b9 100644 --- a/src/test/run-pass/signal-alternate-stack-cleanup.rs +++ b/src/test/run-pass/signal-alternate-stack-cleanup.rs @@ -33,7 +33,7 @@ extern fn send_signal() { fn main() { unsafe { - // Install signal hander that runs on alternate signal stack. + // Install signal handler that runs on alternate signal stack. let mut action: sigaction = std::mem::zeroed(); action.sa_flags = (SA_ONSTACK | SA_SIGINFO) as _; action.sa_sigaction = signal_handler as sighandler_t; diff --git a/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs b/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs index d4a9a9f379b92..3fce62529c78f 100644 --- a/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs +++ b/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs @@ -10,7 +10,7 @@ #![crate_name = "qwop"] -/// (writen on a spider's web) Some Macro +/// (written on a spider's web) Some Macro #[macro_export] macro_rules! some_macro { () => { diff --git a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs index 3f3997726c939..8ccb5878c4045 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] // Load rustc as a plugin to get macros diff --git a/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs index ab39709c529dc..315dad7eea515 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs @@ -12,7 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff --git a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs index 01fa2f3459ea7..d7895bd8781ba 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs @@ -10,7 +10,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.rs b/src/test/ui/associated-types/associated-types-incomplete-object.rs index c1feb8ac45900..9f1df14605b69 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.rs +++ b/src/test/ui/associated-types/associated-types-incomplete-object.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that the user gets an errror if they omit a binding from an +// Check that the user gets an error if they omit a binding from an // object type. pub trait Foo { diff --git a/src/test/ui/borrowck/issue-45983.rs b/src/test/ui/borrowck/issue-45983.rs index bcbe0d1ffc000..5ed425e958a58 100644 --- a/src/test/ui/borrowck/issue-45983.rs +++ b/src/test/ui/borrowck/issue-45983.rs @@ -19,7 +19,7 @@ // revisions: ast migrate nll // Since we are testing nll (and migration) explicitly as a separate -// revisions, dont worry about the --compare-mode=nll on this test. +// revisions, don't worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll diff --git a/src/test/ui/feature-gates/feature-gate-macro-vis-matcher.rs b/src/test/ui/closure-expected.rs similarity index 58% rename from src/test/ui/feature-gates/feature-gate-macro-vis-matcher.rs rename to src/test/ui/closure-expected.rs index 5d6f2acea83ce..ff52948ca8559 100644 --- a/src/test/ui/feature-gates/feature-gate-macro-vis-matcher.rs +++ b/src/test/ui/closure-expected.rs @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,12 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that the MSP430 interrupt ABI cannot be used when msp430_interrupt -// feature gate is not used. - -macro_rules! m { ($v:vis) => {} } -//~^ ERROR :vis fragment specifier is experimental and subject to change - fn main() { - m!(pub); + let x = Some(1); + let y = x.or_else(4); + //~^ ERROR expected a `std::ops::FnOnce<()>` closure, found `{integer}` } diff --git a/src/test/ui/closure-expected.stderr b/src/test/ui/closure-expected.stderr new file mode 100644 index 0000000000000..0da506b5b8139 --- /dev/null +++ b/src/test/ui/closure-expected.stderr @@ -0,0 +1,12 @@ +error[E0277]: expected a `std::ops::FnOnce<()>` closure, found `{integer}` + --> $DIR/closure-expected.rs:13:15 + | +LL | let y = x.or_else(4); + | ^^^^^^^ expected an `FnOnce<()>` closure, found `{integer}` + | + = help: the trait `std::ops::FnOnce<()>` is not implemented for `{integer}` + = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ } + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-eval/issue-53157.rs b/src/test/ui/consts/const-eval/issue-53157.rs similarity index 100% rename from src/test/ui/const-eval/issue-53157.rs rename to src/test/ui/consts/const-eval/issue-53157.rs diff --git a/src/test/ui/defaulted-never-note.rs b/src/test/ui/defaulted-never-note.rs index ac8ac85824edc..b53ef0f5ba823 100644 --- a/src/test/ui/defaulted-never-note.rs +++ b/src/test/ui/defaulted-never-note.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// We need to opt inot the `!` feature in order to trigger the +// We need to opt into the `!` feature in order to trigger the // requirement that this is testing. #![feature(never_type)] diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index 5b66d1093408e..b088e8330e998 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -24,7 +24,7 @@ error[E0401]: can't use type parameters from outer function --> $DIR/E0401.rs:32:25 | LL | impl Iterator for A { - | ---- `Self` type implicitely declared here, on the `impl` + | ---- `Self` type implicitly declared here, on the `impl` ... LL | fn helper(sel: &Self) -> u8 { //~ ERROR E0401 | ------ ^^^^ use of type variable from outer function diff --git a/src/test/ui/extern/extern-wrong-value-type.rs b/src/test/ui/extern/extern-wrong-value-type.rs index 66b06c505e476..ea313385c1018 100644 --- a/src/test/ui/extern/extern-wrong-value-type.rs +++ b/src/test/ui/extern/extern-wrong-value-type.rs @@ -17,5 +17,5 @@ fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK is_fn(f); - //~^ ERROR `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied + //~^ ERROR expected a `std::ops::Fn<()>` closure, found `extern "C" fn() {f}` } diff --git a/src/test/ui/extern/extern-wrong-value-type.stderr b/src/test/ui/extern/extern-wrong-value-type.stderr index 35e0d68e46aa8..0d8185839ccb4 100644 --- a/src/test/ui/extern/extern-wrong-value-type.stderr +++ b/src/test/ui/extern/extern-wrong-value-type.stderr @@ -1,9 +1,11 @@ -error[E0277]: the trait bound `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied +error[E0277]: expected a `std::ops::Fn<()>` closure, found `extern "C" fn() {f}` --> $DIR/extern-wrong-value-type.rs:19:5 | LL | is_fn(f); - | ^^^^^ the trait `std::ops::Fn<()>` is not implemented for `extern "C" fn() {f}` + | ^^^^^ expected an `Fn<()>` closure, found `extern "C" fn() {f}` | + = help: the trait `std::ops::Fn<()>` is not implemented for `extern "C" fn() {f}` + = note: wrap the `extern "C" fn() {f}` in a closure with no arguments: `|| { /* code */ } note: required by `is_fn` --> $DIR/extern-wrong-value-type.rs:14:1 | diff --git a/src/test/ui/feature-gates/feature-gate-macro-vis-matcher.stderr b/src/test/ui/feature-gates/feature-gate-macro-vis-matcher.stderr deleted file mode 100644 index 9d98091674e76..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-macro-vis-matcher.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: :vis fragment specifier is experimental and subject to change (see issue #41022) - --> $DIR/feature-gate-macro-vis-matcher.rs:14:19 - | -LL | macro_rules! m { ($v:vis) => {} } - | ^^^^^^ - | - = help: add #![feature(macro_vis_matcher)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/fn/fn-trait-formatting.rs b/src/test/ui/fn/fn-trait-formatting.rs index 56d64d77ee258..ac7b0a6098462 100644 --- a/src/test/ui/fn/fn-trait-formatting.rs +++ b/src/test/ui/fn/fn-trait-formatting.rs @@ -27,5 +27,5 @@ fn main() { //~| found type `std::boxed::Box isize>` needs_fn(1); - //~^ ERROR : std::ops::Fn<(isize,)>` + //~^ ERROR expected a `std::ops::Fn<(isize,)>` closure, found `{integer}` } diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index 5bf1ed76d5f46..198b343cdd3e7 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -25,15 +25,13 @@ LL | let _: () = (box || -> isize { unimplemented!() }) as Box is = note: expected type `()` found type `std::boxed::Box isize>` -error[E0277]: the trait bound `{integer}: std::ops::Fn<(isize,)>` is not satisfied +error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `{integer}` --> $DIR/fn-trait-formatting.rs:29:5 | LL | needs_fn(1); - | ^^^^^^^^ the trait `std::ops::Fn<(isize,)>` is not implemented for `{integer}` + | ^^^^^^^^ expected an `Fn<(isize,)>` closure, found `{integer}` | - = help: the following implementations were found: - <&'a F as std::ops::Fn> - > + = help: the trait `std::ops::Fn<(isize,)>` is not implemented for `{integer}` note: required by `needs_fn` --> $DIR/fn-trait-formatting.rs:13:1 | diff --git a/src/test/ui/imports/local-modularized-tricky-fail-2.rs b/src/test/ui/imports/local-modularized-tricky-fail-2.rs index afdebc4533ff6..1ae7ed268ebf8 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-2.rs +++ b/src/test/ui/imports/local-modularized-tricky-fail-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// `#[macro_export] macro_rules` that doen't originate from macro expansions can be placed +// `#[macro_export] macro_rules` that doesn't originate from macro expansions can be placed // into the root module soon enough to act as usual items and shadow globs and preludes. #![feature(decl_macro)] diff --git a/src/test/ui/issues/issue-22034.rs b/src/test/ui/issues/issue-22034.rs index 5271ea7991784..2708de2c13a8f 100644 --- a/src/test/ui/issues/issue-22034.rs +++ b/src/test/ui/issues/issue-22034.rs @@ -16,6 +16,6 @@ fn main() { let ptr: *mut () = 0 as *mut _; let _: &mut Fn() = unsafe { &mut *(ptr as *mut Fn()) - //~^ ERROR `(): std::ops::Fn<()>` is not satisfied + //~^ ERROR expected a `std::ops::Fn<()>` closure, found `()` }; } diff --git a/src/test/ui/issues/issue-22034.stderr b/src/test/ui/issues/issue-22034.stderr index bac62a1301aad..da376fedbb98a 100644 --- a/src/test/ui/issues/issue-22034.stderr +++ b/src/test/ui/issues/issue-22034.stderr @@ -1,9 +1,11 @@ -error[E0277]: the trait bound `(): std::ops::Fn<()>` is not satisfied +error[E0277]: expected a `std::ops::Fn<()>` closure, found `()` --> $DIR/issue-22034.rs:18:16 | LL | &mut *(ptr as *mut Fn()) - | ^^^ the trait `std::ops::Fn<()>` is not implemented for `()` + | ^^^ expected an `Fn<()>` closure, found `()` | + = help: the trait `std::ops::Fn<()>` is not implemented for `()` + = note: wrap the `()` in a closure with no arguments: `|| { /* code */ } = note: required for the cast to the object type `dyn std::ops::Fn()` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23966.stderr b/src/test/ui/issues/issue-23966.stderr index 07d2cfbf55f10..0418933180c00 100644 --- a/src/test/ui/issues/issue-23966.stderr +++ b/src/test/ui/issues/issue-23966.stderr @@ -1,8 +1,10 @@ -error[E0277]: the trait bound `(): std::ops::FnMut<(_, char)>` is not satisfied +error[E0277]: expected a `std::ops::FnMut<(_, char)>` closure, found `()` --> $DIR/issue-23966.rs:12:16 | LL | "".chars().fold(|_, _| (), ()); - | ^^^^ the trait `std::ops::FnMut<(_, char)>` is not implemented for `()` + | ^^^^ expected an `FnMut<(_, char)>` closure, found `()` + | + = help: the trait `std::ops::FnMut<(_, char)>` is not implemented for `()` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-31845.rs b/src/test/ui/issues/issue-31845.rs index 514255e46769e..418754b9a2446 100644 --- a/src/test/ui/issues/issue-31845.rs +++ b/src/test/ui/issues/issue-31845.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Checks lexical scopes cannot see through normal module boundries +// Checks lexical scopes cannot see through normal module boundaries fn f() { fn g() {} diff --git a/src/test/ui/issues/issue-42755.rs b/src/test/ui/issues/issue-42755.rs index 7547c4a17beba..dd53a1c71a5bc 100644 --- a/src/test/ui/issues/issue-42755.rs +++ b/src/test/ui/issues/issue-42755.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] macro_rules! foo { ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree diff --git a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs index da42e171fcc50..8624dbd28dceb 100644 --- a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs +++ b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs @@ -24,7 +24,7 @@ // run-pass -// This test has structs and functions that are by definiton unusable +// This test has structs and functions that are by definition unusable // all over the place, so just go ahead and allow dead_code #![allow(dead_code)] diff --git a/src/test/ui/issues/issue-50761.rs b/src/test/ui/issues/issue-50761.rs index b8a7a089c2313..6c87d52093473 100644 --- a/src/test/ui/issues/issue-50761.rs +++ b/src/test/ui/issues/issue-50761.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Confirm that we don't accidently divide or mod by zero in llvm_type +// Confirm that we don't accidentally divide or mod by zero in llvm_type // compile-pass diff --git a/src/test/ui/label/label_break_value_illegal_uses.rs b/src/test/ui/label/label_break_value_illegal_uses.rs index 18644033e4ff8..8315104d37ff4 100644 --- a/src/test/ui/label/label_break_value_illegal_uses.rs +++ b/src/test/ui/label/label_break_value_illegal_uses.rs @@ -10,7 +10,7 @@ #![feature(label_break_value)] -// These are forbidden occurences of label-break-value +// These are forbidden occurrences of label-break-value fn labeled_unsafe() { unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{` diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs index 20a2cbfd3aa78..6b0ca2ce9e004 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs @@ -9,8 +9,8 @@ // except according to those terms. // FIXME: Change to UI Test -// Check notes are placed on an assignment that can actually precede the current assigmnent -// Don't emmit a first assignment for assignment in a loop. +// Check notes are placed on an assignment that can actually precede the current assignment +// Don't emit a first assignment for assignment in a loop. // compile-flags: -Zborrowck=compare diff --git a/src/test/ui/lint/lint-unused-extern-crate.rs b/src/test/ui/lint/lint-unused-extern-crate.rs index 8f0b53fd59971..4ef185ee71c5a 100644 --- a/src/test/ui/lint/lint-unused-extern-crate.rs +++ b/src/test/ui/lint/lint-unused-extern-crate.rs @@ -35,7 +35,7 @@ use lint_unused_extern_crate2::foo as bar; use other::*; mod foo { - // Test that this is unused even though an earler `extern crate` is used. + // Test that this is unused even though an earlier `extern crate` is used. extern crate lint_unused_extern_crate2; //~ ERROR unused extern crate } diff --git a/src/test/ui/lint/unreachable_pub-pub_crate.rs b/src/test/ui/lint/unreachable_pub-pub_crate.rs index 0a1926f8ae56a..0089617b11c0b 100644 --- a/src/test/ui/lint/unreachable_pub-pub_crate.rs +++ b/src/test/ui/lint/unreachable_pub-pub_crate.rs @@ -16,7 +16,7 @@ // compile-pass -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![allow(unused)] #![warn(unreachable_pub)] diff --git a/src/test/ui/lint/unreachable_pub.rs b/src/test/ui/lint/unreachable_pub.rs index 5bb67670d85c2..7fd4a90109071 100644 --- a/src/test/ui/lint/unreachable_pub.rs +++ b/src/test/ui/lint/unreachable_pub.rs @@ -11,7 +11,7 @@ // compile-pass #![feature(crate_visibility_modifier)] -#![feature(macro_vis_matcher)] +#![cfg_attr(stage0, feature(macro_vis_matcher))] #![allow(unused)] #![warn(unreachable_pub)] diff --git a/src/test/ui/rfc1598-generic-associated-types/shadowing.rs b/src/test/ui/rfc1598-generic-associated-types/shadowing.rs index 6cdcaf2568394..ddc6a29a8f0bd 100644 --- a/src/test/ui/rfc1598-generic-associated-types/shadowing.rs +++ b/src/test/ui/rfc1598-generic-associated-types/shadowing.rs @@ -11,7 +11,7 @@ #![feature(generic_associated_types)] //FIXME(#44265): The lifetime shadowing and type parameter shadowing -// should cause an error. Now it compiles (errorneously) and this will be addressed +// should cause an error. Now it compiles (erroneously) and this will be addressed // by a future PR. Then remove the following: // compile-pass diff --git a/src/test/ui/rust-2018/async-ident-allowed.rs b/src/test/ui/rust-2018/async-ident-allowed.rs index 3bc468483bda2..9a046bc6952b3 100644 --- a/src/test/ui/rust-2018/async-ident-allowed.rs +++ b/src/test/ui/rust-2018/async-ident-allowed.rs @@ -12,7 +12,7 @@ #![deny(rust_2018_compatibility)] -// Don't make a suggestion for a raw identifer replacement unless raw +// Don't make a suggestion for a raw identifier replacement unless raw // identifiers are enabled. fn main() { diff --git a/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs b/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs index 4706b9cbb092c..81adf89fd4330 100644 --- a/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs +++ b/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs @@ -9,7 +9,7 @@ // except according to those terms. // Test that we DO NOT warn when lifetime name is used multiple -// argments, or more than once in a single argument. +// arguments, or more than once in a single argument. // // compile-pass diff --git a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr index 95aa3f15b7648..e5e66efcaa2ce 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr @@ -1,9 +1,10 @@ -error[E0277]: the trait bound `S: std::ops::Fn<(isize,)>` is not satisfied +error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `S` --> $DIR/unboxed-closures-fnmut-as-fn.rs:38:13 | LL | let x = call_it(&S, 22); - | ^^^^^^^ the trait `std::ops::Fn<(isize,)>` is not implemented for `S` + | ^^^^^^^ expected an `Fn<(isize,)>` closure, found `S` | + = help: the trait `std::ops::Fn<(isize,)>` is not implemented for `S` note: required by `call_it` --> $DIR/unboxed-closures-fnmut-as-fn.rs:33:1 | diff --git a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr index 16b2b11ad7b42..7c76c10443af9 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr @@ -1,33 +1,36 @@ -error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:22:13 | LL | let x = call_it(&square, 22); - | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` note: required by `call_it` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:17:1 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:27:13 | LL | let y = call_it_mut(&mut square, 22); - | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` note: required by `call_it_mut` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:1 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:32:13 | LL | let z = call_it_once(square, 22); - | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | ^^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` note: required by `call_it_once` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:19:1 | diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr index 6e5e1b928a2c0..18ade48de6640 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr @@ -1,33 +1,36 @@ -error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:22:13 | LL | let x = call_it(&square, 22); - | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` note: required by `call_it` --> $DIR/unboxed-closures-wrong-abi.rs:17:1 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:27:13 | LL | let y = call_it_mut(&mut square, 22); - | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` note: required by `call_it_mut` --> $DIR/unboxed-closures-wrong-abi.rs:18:1 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:32:13 | LL | let z = call_it_once(square, 22); - | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | ^^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` note: required by `call_it_once` --> $DIR/unboxed-closures-wrong-abi.rs:19:1 | diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr index 5c2e73f57160d..f27b73017a28f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr @@ -1,33 +1,36 @@ -error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:23:13 | LL | let x = call_it(&square, 22); - | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` note: required by `call_it` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:18:1 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:28:13 | LL | let y = call_it_mut(&mut square, 22); - | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` note: required by `call_it_mut` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:1 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied +error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:33:13 | LL | let z = call_it_once(square, 22); - | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | ^^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` | + = help: the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` note: required by `call_it_once` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:20:1 | diff --git a/src/test/ui/variadic/variadic-ffi-2.rs b/src/test/ui/variadic/variadic-ffi-2.rs index ec5669f639277..a5011c3abe7a7 100644 --- a/src/test/ui/variadic/variadic-ffi-2.rs +++ b/src/test/ui/variadic/variadic-ffi-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-arm stdcall isn't suppported +// ignore-arm stdcall isn't supported fn baz(f: extern "stdcall" fn(usize, ...)) { //~^ ERROR: variadic function must have C or cdecl calling convention diff --git a/src/test/ui/variadic/variadic-ffi.rs b/src/test/ui/variadic/variadic-ffi.rs index f245306f4d8f6..d81e61cac566d 100644 --- a/src/test/ui/variadic/variadic-ffi.rs +++ b/src/test/ui/variadic/variadic-ffi.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-arm stdcall isn't suppported -// ignore-aarch64 stdcall isn't suppported +// ignore-arm stdcall isn't supported +// ignore-aarch64 stdcall isn't supported extern "stdcall" { fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling diff --git a/src/test/ui/where-clauses/where-for-self-2.rs b/src/test/ui/where-clauses/where-for-self-2.rs index bf8fc29217338..6179bdb34a381 100644 --- a/src/test/ui/where-clauses/where-for-self-2.rs +++ b/src/test/ui/where-clauses/where-for-self-2.rs @@ -10,7 +10,7 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including // the self type) in a where clause. Specifically, test that implementing for a -// specific lifetime is not enough to satisify the `for<'a> ...` constraint, which +// specific lifetime is not enough to satisfy the `for<'a> ...` constraint, which // should require *all* lifetimes. static X: &'static u32 = &42; diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index ee1345c7f9411..76c15f6601a4a 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -273,7 +273,8 @@ impl Builder { self.clippy_version = self.version("clippy", "x86_64-unknown-linux-gnu"); self.rustfmt_version = self.version("rustfmt", "x86_64-unknown-linux-gnu"); self.llvm_tools_version = self.version("llvm-tools", "x86_64-unknown-linux-gnu"); - self.lldb_version = self.version("lldb", "x86_64-unknown-linux-gnu"); + // lldb is only built for macOS. + self.lldb_version = self.version("lldb", "x86_64-apple-darwin"); self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu"); self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu"); diff --git a/src/tools/lld b/src/tools/lld index f76ea3ca16ed2..813b3b952c07b 160000 --- a/src/tools/lld +++ b/src/tools/lld @@ -1 +1 @@ -Subproject commit f76ea3ca16ed22dde8ef929db74a4b4df6f2f899 +Subproject commit 813b3b952c07b6b85732c3fbdf3eb74f61a9fa96