Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #47195

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2535804
Allow underscores in camel-case between non-alphabetic characters
varkor Dec 21, 2017
e4c02e5
Adjust the rules for underscores
varkor Dec 21, 2017
c1aa017
Add tests
varkor Dec 21, 2017
a8d107b
Correct a few stability attributes
ollie27 Dec 27, 2017
838fb4a
Disable printing of error message on file descriptor 2 on CloudABI.
EdSchouten Dec 27, 2017
c661e38
Build the right platform module on CloudABI.
EdSchouten Dec 31, 2017
4fe167a
Use the right TLS model for CloudABI.
EdSchouten Jan 1, 2018
3dff918
Remove dependency on regex
varkor Jan 2, 2018
2b9add2
Return None from Span::join if in different files
dtolnay Jan 3, 2018
000e907
Span::resolved_at and Span::located_at to combine behavior of two spans
dtolnay Jan 3, 2018
48f2f71
Implement TrustedRandomAccess for slice::{Chunks, ChunksMut, Windows}
sdroege Jan 2, 2018
a56a3fc
Add unit test for zipping slice::{Chunks, ChunksMut, Windows} iterators
sdroege Jan 3, 2018
3f29e2b
Fix compilation of TrustedRandomAccess impl for slice::Chunks
sdroege Jan 3, 2018
47e18e0
This isn't in Rust 1.23
steveklabnik Jan 3, 2018
50989cd
This is an unstable feature
steveklabnik Jan 3, 2018
05949b0
Explain why local-exec is used by CloudABI.
EdSchouten Jan 3, 2018
d7bbd30
Remove outdated LLVMRustBuildLandingPad() wrapper
dotdash Dec 8, 2017
493c29d
Remove unused function LLVMRustGetValueContext()
dotdash Dec 8, 2017
7e522b2
Simplify LLVMRustModuleCost()
dotdash Dec 8, 2017
b69c124
Fix potential overflow in TrustedRandomAccess impl for slice::{Chunks…
sdroege Jan 4, 2018
922f061
Make examples equivalent
aheart Jan 4, 2018
ba11790
Rollup merge of #46907 - varkor:contrib-8, r=nagisa
kennytm Jan 4, 2018
f2d9035
Rollup merge of #47030 - ollie27:stab, r=alexcrichton
kennytm Jan 4, 2018
b583e17
Rollup merge of #47033 - EdSchouten:cloudabi-oom, r=kennytm
kennytm Jan 4, 2018
9e5787d
Rollup merge of #47110 - EdSchouten:cloudabi-tls, r=kennytm
kennytm Jan 4, 2018
dc8254e
Rollup merge of #47142 - sdroege:trusted-random-access-chunks, r=kennytm
kennytm Jan 4, 2018
8eca1b3
Rollup merge of #47149 - dtolnay:spans, r=jseyfried
kennytm Jan 4, 2018
e3e54d9
Rollup merge of #47150 - dtolnay:join, r=jseyfried
kennytm Jan 4, 2018
891a901
Rollup merge of #47160 - rust-lang:steveklabnik-patch-1, r=alexcrichton
kennytm Jan 4, 2018
a4e4899
Rollup merge of #47173 - dotdash:cleanup, r=michaelwoerister
kennytm Jan 4, 2018
1791414
Rollup merge of #47182 - aheart:master, r=steveklabnik
kennytm Jan 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Stabilized APIs

Cargo
-----
- [Cargo now supports alternative registries][cargo/4506]
- [Cargo now supports uninstallation of multiple packages][cargo/4561]
eg. `cargo uninstall foo bar` uninstalls `foo` and `bar`.
- [Added unit test checking to `cargo check`][cargo/4592]
Expand All @@ -49,7 +48,6 @@ Misc
----
- [Releases now ship with the Cargo book documentation.][45692]
- [rustdoc now prints rendering warnings on every run.][45324]
- [Release tarballs now come with rustfmt][45903]

Compatibility Notes
-------------------
Expand Down Expand Up @@ -83,9 +81,7 @@ Compatibility Notes
[45852]: https://github.com/rust-lang/rust/issues/45852
[45853]: https://github.com/rust-lang/rust/pull/45853
[45887]: https://github.com/rust-lang/rust/pull/45887
[45903]: https://github.com/rust-lang/rust/pull/45903
[45920]: https://github.com/rust-lang/rust/pull/45920
[cargo/4506]: https://github.com/rust-lang/cargo/pull/4506
[cargo/4561]: https://github.com/rust-lang/cargo/pull/4561
[cargo/4592]: https://github.com/rust-lang/cargo/pull/4592
[cargo/4637]: https://github.com/rust-lang/cargo/pull/4637
Expand Down
14 changes: 12 additions & 2 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![feature(core_intrinsics)]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![cfg_attr(any(unix, target_os = "redox"), feature(libc))]
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]
#![rustc_alloc_kind = "lib"]

// The minimum alignment guaranteed by the architecture. This value is used to
Expand Down Expand Up @@ -116,7 +116,7 @@ unsafe impl Alloc for System {
}
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(any(unix, target_os = "cloudabi", target_os = "redox"))]
mod platform {
extern crate libc;

Expand Down Expand Up @@ -213,6 +213,16 @@ mod platform {
struct Stderr;

impl Write for Stderr {
#[cfg(target_os = "cloudabi")]
fn write_str(&mut self, _: &str) -> fmt::Result {
// CloudABI does not have any reserved file descriptor
// numbers. We should not attempt to write to file
// descriptor #2, as it may be associated with any kind of
// resource.
Ok(())
}

#[cfg(not(target_os = "cloudabi"))]
fn write_str(&mut self, s: &str) -> fmt::Result {
unsafe {
libc::write(libc::STDERR_FILENO,
Expand Down
1 change: 1 addition & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ macro_rules! debug_assert_ne {
/// // The prefered method of quick returning Errors
/// fn write_to_file_question() -> Result<(), MyError> {
/// let mut file = File::create("my_best_friends.txt")?;
/// file.write_all(b"This is a list of my best friends.")?;
/// Ok(())
/// }
///
Expand Down
14 changes: 7 additions & 7 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ impl<T: ::fmt::Debug> ::fmt::Debug for ManuallyDrop<T> {
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: Clone> Clone for ManuallyDrop<T> {
fn clone(&self) -> Self {
ManuallyDrop::new(self.deref().clone())
Expand All @@ -1035,14 +1035,14 @@ impl<T: Clone> Clone for ManuallyDrop<T> {
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: Default> Default for ManuallyDrop<T> {
fn default() -> Self {
ManuallyDrop::new(Default::default())
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: PartialEq> PartialEq for ManuallyDrop<T> {
fn eq(&self, other: &Self) -> bool {
self.deref().eq(other)
Expand All @@ -1053,10 +1053,10 @@ impl<T: PartialEq> PartialEq for ManuallyDrop<T> {
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: Eq> Eq for ManuallyDrop<T> {}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: PartialOrd> PartialOrd for ManuallyDrop<T> {
fn partial_cmp(&self, other: &Self) -> Option<::cmp::Ordering> {
self.deref().partial_cmp(other)
Expand All @@ -1079,14 +1079,14 @@ impl<T: PartialOrd> PartialOrd for ManuallyDrop<T> {
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: Ord> Ord for ManuallyDrop<T> {
fn cmp(&self, other: &Self) -> ::cmp::Ordering {
self.deref().cmp(other)
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
#[stable(feature = "manually_drop_impls", since = "1.22.0")]
impl<T: ::hash::Hash> ::hash::Hash for ManuallyDrop<T> {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.deref().hash(state);
Expand Down
34 changes: 34 additions & 0 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,14 @@ impl<'a, T> ExactSizeIterator for Windows<'a, T> {}
#[unstable(feature = "fused", issue = "35602")]
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)
}
fn may_have_side_effect() -> bool { false }
}

/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
/// time).
///
Expand Down Expand Up @@ -2228,6 +2236,19 @@ impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
#[unstable(feature = "fused", issue = "35602")]
impl<'a, T> FusedIterator for Chunks<'a, T> {}

#[doc(hidden)]
unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> {
unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] {
let start = i * self.chunk_size;
let end = match start.checked_add(self.chunk_size) {
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)
}
fn may_have_side_effect() -> bool { false }
}

/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size`
/// elements at a time). When the slice len is not evenly divided by the chunk
/// size, the last slice of the iteration will be the remainder.
Expand Down Expand Up @@ -2331,6 +2352,19 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
#[unstable(feature = "fused", issue = "35602")]
impl<'a, T> FusedIterator for ChunksMut<'a, T> {}

#[doc(hidden)]
unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> {
unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] {
let start = i * self.chunk_size;
let end = match start.checked_add(self.chunk_size) {
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)
}
fn may_have_side_effect() -> bool { false }
}

//
// Free functions
//
Expand Down
8 changes: 6 additions & 2 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,9 @@ mod traits {
}
}

#[stable(feature = "str_checked_slicing", since = "1.20.0")]
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
impl SliceIndex<str> for ops::RangeInclusive<usize> {
type Output = str;
#[inline]
Expand Down Expand Up @@ -2040,7 +2042,9 @@ mod traits {



#[stable(feature = "str_checked_slicing", since = "1.20.0")]
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
impl SliceIndex<str> for ops::RangeToInclusive<usize> {
type Output = str;
#[inline]
Expand Down
13 changes: 12 additions & 1 deletion src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ macro_rules! atomic_int {
$stable_cxchg:meta,
$stable_debug:meta,
$stable_access:meta,
$stable_from:meta,
$s_int_type:expr, $int_ref:expr,
$int_type:ident $atomic_type:ident $atomic_init:ident) => {
/// An integer type which can be safely shared between threads.
Expand Down Expand Up @@ -978,7 +979,7 @@ macro_rules! atomic_int {
}
}

#[stable(feature = "atomic_from", since = "1.23.0")]
#[$stable_from]
impl From<$int_type> for $atomic_type {
#[inline]
fn from(v: $int_type) -> Self { Self::new(v) }
Expand Down Expand Up @@ -1375,6 +1376,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"i8", "../../../std/primitive.i8.html",
i8 AtomicI8 ATOMIC_I8_INIT
}
Expand All @@ -1384,6 +1386,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"u8", "../../../std/primitive.u8.html",
u8 AtomicU8 ATOMIC_U8_INIT
}
Expand All @@ -1393,6 +1396,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"i16", "../../../std/primitive.i16.html",
i16 AtomicI16 ATOMIC_I16_INIT
}
Expand All @@ -1402,6 +1406,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"u16", "../../../std/primitive.u16.html",
u16 AtomicU16 ATOMIC_U16_INIT
}
Expand All @@ -1411,6 +1416,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"i32", "../../../std/primitive.i32.html",
i32 AtomicI32 ATOMIC_I32_INIT
}
Expand All @@ -1420,6 +1426,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"u32", "../../../std/primitive.u32.html",
u32 AtomicU32 ATOMIC_U32_INIT
}
Expand All @@ -1429,6 +1436,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"i64", "../../../std/primitive.i64.html",
i64 AtomicI64 ATOMIC_I64_INIT
}
Expand All @@ -1438,6 +1446,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
"u64", "../../../std/primitive.u64.html",
u64 AtomicU64 ATOMIC_U64_INIT
}
Expand All @@ -1447,6 +1456,7 @@ atomic_int!{
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
stable(feature = "atomic_access", since = "1.15.0"),
stable(feature = "atomic_from", since = "1.23.0"),
"isize", "../../../std/primitive.isize.html",
isize AtomicIsize ATOMIC_ISIZE_INIT
}
Expand All @@ -1456,6 +1466,7 @@ atomic_int!{
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
stable(feature = "atomic_access", since = "1.15.0"),
stable(feature = "atomic_from", since = "1.23.0"),
"usize", "../../../std/primitive.usize.html",
usize AtomicUsize ATOMIC_USIZE_INIT
}
Expand Down
39 changes: 39 additions & 0 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ fn test_chunks_last() {
assert_eq!(c2.last().unwrap()[0], 4);
}

#[test]
fn test_chunks_zip() {
let v1: &[i32] = &[0, 1, 2, 3, 4];
let v2: &[i32] = &[6, 7, 8, 9, 10];

let res = v1.chunks(2)
.zip(v2.chunks(2))
.map(|(a, b)| a.iter().sum::<i32>() + b.iter().sum::<i32>())
.collect::<Vec<_>>();
assert_eq!(res, vec![14, 22, 14]);
}

#[test]
fn test_chunks_mut_count() {
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
Expand Down Expand Up @@ -176,6 +188,20 @@ fn test_chunks_mut_last() {
assert_eq!(c2.last().unwrap()[0], 4);
}

#[test]
fn test_chunks_mut_zip() {
let v1: &mut [i32] = &mut [0, 1, 2, 3, 4];
let v2: &[i32] = &[6, 7, 8, 9, 10];

for (a, b) in v1.chunks_mut(2).zip(v2.chunks(2)) {
let sum = b.iter().sum::<i32>();
for v in a {
*v += sum;
}
}
assert_eq!(v1, [13, 14, 19, 20, 14]);
}

#[test]
fn test_windows_count() {
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
Expand Down Expand Up @@ -215,6 +241,19 @@ fn test_windows_last() {
assert_eq!(c2.last().unwrap()[0], 3);
}

#[test]
fn test_windows_zip() {
let v1: &[i32] = &[0, 1, 2, 3, 4];
let v2: &[i32] = &[6, 7, 8, 9, 10];

let res = v1.windows(2)
.zip(v2.windows(2))
.map(|(a, b)| a.iter().sum::<i32>() + b.iter().sum::<i32>())
.collect::<Vec<_>>();

assert_eq!(res, [14, 18, 22, 26]);
}

#[test]
fn get_range() {
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
Expand Down
16 changes: 15 additions & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,27 @@ impl Span {
#[unstable(feature = "proc_macro", issue = "38356")]
pub fn join(&self, other: Span) -> Option<Span> {
let self_loc = __internal::lookup_char_pos(self.0.lo());
let other_loc = __internal::lookup_char_pos(self.0.lo());
let other_loc = __internal::lookup_char_pos(other.0.lo());

if self_loc.file.name != other_loc.file.name { return None }

Some(Span(self.0.to(other.0)))
}

/// Creates a new span with the same line/column information as `self` but
/// that resolves symbols as though it were at `other`.
#[unstable(feature = "proc_macro", issue = "38356")]
pub fn resolved_at(&self, other: Span) -> Span {
Span(self.0.with_ctxt(other.0.ctxt()))
}

/// Creates a new span with the same name resolution behavior as `self` but
/// with the line/column information of `other`.
#[unstable(feature = "proc_macro", issue = "38356")]
pub fn located_at(&self, other: Span) -> Span {
other.resolved_at(*self)
}

diagnostic_method!(error, Level::Error);
diagnostic_method!(warning, Level::Warning);
diagnostic_method!(note, Level::Note);
Expand Down
Loading