Skip to content

Rollup of 15 pull requests #56549

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

Merged
merged 44 commits into from
Dec 6, 2018
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
700c83b
Document `From` implementations
Jun 24, 2018
072bca3
Remove 'unsafe' comments
Jun 25, 2018
88a708d
Update comments
Jun 25, 2018
5c747eb
Update style of comments
Jul 26, 2018
e8dafba
Adjust doc comments
Nov 21, 2018
7933628
Remove trailing whitespace
Nov 21, 2018
c209ed8
Improve no result found sentence in doc search
GuillaumeGomez Nov 1, 2018
1560a75
Refer to the second borrow as the "second borrow".
wildarch Nov 30, 2018
d92287a
Fix some rustc doc links
matthewjasper Nov 30, 2018
4f5b8ea
Remove the `region_map` field from `BorrowSet`
matthewjasper Nov 30, 2018
6000c2e
Use visit_local to find 2PB activations
matthewjasper Nov 30, 2018
23abd18
Fix invalid line number match
GuillaumeGomez Dec 2, 2018
380dd7d
Add rc::Weak.ptr_eq
Thomasdezeeuw Nov 15, 2018
d4b41fa
Add sync::Weak::ptr_eq
Thomasdezeeuw Nov 15, 2018
38e21f9
Fix link in Weak::new
Thomasdezeeuw Nov 23, 2018
1fb82b5
Handle existential types in dead code analysis
oli-obk Dec 3, 2018
651373c
data_structures: remove tuple_slice
ljedrz Dec 3, 2018
9c8802d
Explain raw identifer syntax
mark-i-m Dec 2, 2018
0b40be6
link to raw identifiers
mark-i-m Dec 2, 2018
65aa0a6
Remove redundant clone
sinkuu Nov 28, 2018
bc7c3dc
sort_by_cached_key -> sort_by
sinkuu Nov 30, 2018
450a8a6
Add extra comment slash
Dec 4, 2018
8c4129c
cleanup: remove static lifetimes from consts in libstd
ljedrz Dec 4, 2018
e41e85c
Fix line numbers display
GuillaumeGomez Dec 4, 2018
9012af6
Utilize `?` instead of `return None`.
frewsxcv Nov 21, 2018
56ace3e
Added a bare-bones eslint config (removing jslint)
JohnHeitmann Dec 4, 2018
5d7cf59
Added trailing newline
JohnHeitmann Dec 5, 2018
3eddc74
Use inner iterator may_have_side_effect for Cloned
KamilaBorowska Dec 5, 2018
a964307
Add a test for cloned side effects
KamilaBorowska Dec 5, 2018
1598868
Rollup merge of #51753 - gruberb:document-from-conversions-libstdpath…
pietroalbini Dec 5, 2018
66ba6b3
Rollup merge of #55563 - GuillaumeGomez:doc-search-sentence, r=QuietM…
pietroalbini Dec 5, 2018
1594a42
Rollup merge of #55987 - Thomasdezeeuw:weak-ptr_eq, r=sfackler
pietroalbini Dec 5, 2018
64371f1
Rollup merge of #56119 - frewsxcv:frewsxcv-option-carrier, r=TimNN
pietroalbini Dec 5, 2018
b2a002d
Rollup merge of #56372 - wildarch:issue-55314-second-borrow-ref, r=da…
pietroalbini Dec 5, 2018
b6e2fc9
Rollup merge of #56388 - matthewjasper:more-lexical-mir-cleanup, r=ni…
pietroalbini Dec 5, 2018
21ba28f
Rollup merge of #56424 - mark-i-m:explain-raw, r=Centril
pietroalbini Dec 5, 2018
4ff4fc1
Rollup merge of #56452 - sinkuu:redundant_clone, r=nikic
pietroalbini Dec 5, 2018
1276ffe
Rollup merge of #56456 - oli-obk:private_impl_trait, r=cramertj
pietroalbini Dec 5, 2018
650b4ed
Rollup merge of #56466 - ljedrz:delete_tuple_slice, r=nikomatsakis
pietroalbini Dec 5, 2018
d07d299
Rollup merge of #56476 - GuillaumeGomez:invalid-line-number-match, r=…
pietroalbini Dec 5, 2018
bcf2fa1
Rollup merge of #56497 - ljedrz:cleanup_libstd_const_lifetimes, r=ken…
pietroalbini Dec 5, 2018
39d4c0c
Rollup merge of #56498 - GuillaumeGomez:line-numbers, r=QuietMisdreavus
pietroalbini Dec 5, 2018
0fb90f3
Rollup merge of #56523 - JohnHeitmann:es6, r=GuillaumeGomez
pietroalbini Dec 5, 2018
f8ee5ab
Rollup merge of #56538 - xfix:patch-13, r=bluss
pietroalbini Dec 5, 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
49 changes: 48 additions & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
@@ -1187,8 +1187,9 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Weak<U>> for Weak<T> {}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>`, without allocating any memory.
/// Calling [`upgrade`][Weak::upgrade] on the return value always gives [`None`].
/// Calling [`upgrade`] on the return value always gives [`None`].
///
/// [`upgrade`]: #method.upgrade
/// [`None`]: ../../std/option/enum.Option.html
///
/// # Examples
@@ -1260,6 +1261,52 @@ impl<T: ?Sized> Weak<T> {
Some(unsafe { self.ptr.as_ref() })
}
}

/// Returns true if the two `Weak`s point to the same value (not just values
/// that compare as equal).
///
/// # Notes
///
/// Since this compares pointers it means that `Weak::new()` will equal each
/// other, even though they don't point to any value.
///
/// # Examples
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::rc::{Rc, Weak};
///
/// let first_rc = Rc::new(5);
/// let first = Rc::downgrade(&first_rc);
/// let second = Rc::downgrade(&first_rc);
///
/// assert!(Weak::ptr_eq(&first, &second));
///
/// let third_rc = Rc::new(5);
/// let third = Rc::downgrade(&third_rc);
///
/// assert!(!Weak::ptr_eq(&first, &third));
/// ```
///
/// Comparing `Weak::new`.
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::rc::{Rc, Weak};
///
/// let first = Weak::new();
/// let second = Weak::new();
/// assert!(Weak::ptr_eq(&first, &second));
///
/// let third_rc = Rc::new(());
/// let third = Rc::downgrade(&third_rc);
/// assert!(!Weak::ptr_eq(&first, &third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
this.ptr.as_ptr() == other.ptr.as_ptr()
}
}

#[stable(feature = "rc_weak", since = "1.4.0")]
47 changes: 47 additions & 0 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
@@ -1130,6 +1130,53 @@ impl<T: ?Sized> Weak<T> {
Some(unsafe { self.ptr.as_ref() })
}
}

/// Returns true if the two `Weak`s point to the same value (not just values
/// that compare as equal).
///
/// # Notes
///
/// Since this compares pointers it means that `Weak::new()` will equal each
/// other, even though they don't point to any value.
///
///
/// # Examples
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::sync::{Arc, Weak};
///
/// let first_rc = Arc::new(5);
/// let first = Arc::downgrade(&first_rc);
/// let second = Arc::downgrade(&first_rc);
///
/// assert!(Weak::ptr_eq(&first, &second));
///
/// let third_rc = Arc::new(5);
/// let third = Arc::downgrade(&third_rc);
///
/// assert!(!Weak::ptr_eq(&first, &third));
/// ```
///
/// Comparing `Weak::new`.
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::sync::{Arc, Weak};
///
/// let first = Weak::new();
/// let second = Weak::new();
/// assert!(Weak::ptr_eq(&first, &second));
///
/// let third_rc = Arc::new(());
/// let third = Arc::downgrade(&third_rc);
/// assert!(!Weak::ptr_eq(&first, &third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
this.ptr.as_ptr() == other.ptr.as_ptr()
}
}

#[stable(feature = "arc_weak", since = "1.4.0")]
4 changes: 3 additions & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
@@ -602,7 +602,9 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned<I>
}

#[inline]
fn may_have_side_effect() -> bool { false }
fn may_have_side_effect() -> bool {
I::may_have_side_effect()
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
4 changes: 4 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
@@ -238,6 +238,10 @@ macro_rules! debug_assert_ne {
/// with converting downstream errors.
///
/// The `?` operator was added to replace `try!` and should be used instead.
/// Furthermore, `try` is a reserved word in Rust 2018, so if you must use
/// it, you will need to use the [raw-identifier syntax][ris]: `r#try`.
///
/// [ris]: https://doc.rust-lang.org/nightly/rust-by-example/compatibility/raw_identifiers.html
///
/// `try!` matches the given [`Result`]. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
7 changes: 3 additions & 4 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
@@ -536,10 +536,9 @@ fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option<u32>
where I: DoubleEndedIterator<Item = &'a u8>,
{
// Decode UTF-8
let w = match bytes.next_back() {
None => return None,
Some(&next_byte) if next_byte < 128 => return Some(next_byte as u32),
Some(&back_byte) => back_byte,
let w = match *bytes.next_back()? {
next_byte if next_byte < 128 => return Some(next_byte as u32),
back_byte => back_byte,
};

// Multibyte case follows
17 changes: 17 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
@@ -1249,6 +1249,23 @@ fn test_cloned() {
assert_eq!(it.next_back(), None);
}

#[test]
fn test_cloned_side_effects() {
let mut count = 0;
{
let iter = [1, 2, 3]
.iter()
.map(|x| {
count += 1;
x
})
.cloned()
.zip(&[1]);
for _ in iter {}
}
assert_eq!(count, 2);
}

#[test]
fn test_double_ended_map() {
let xs = [1, 2, 3, 4, 5, 6];
1 change: 1 addition & 0 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
@@ -166,6 +166,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
hir::ItemKind::Fn(..)
| hir::ItemKind::Ty(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Existential(..)
| hir::ItemKind::Const(..) => {
intravisit::walk_item(self, &item);
}
5 changes: 1 addition & 4 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
@@ -592,10 +592,7 @@ impl<'tcx> ScopeTree {
return Some(scope.item_local_id());
}

match self.opt_encl_scope(scope) {
None => return None,
Some(parent) => scope = parent,
}
scope = self.opt_encl_scope(scope)?;
}
}

11 changes: 5 additions & 6 deletions src/librustc/session/search_paths.rs
Original file line number Diff line number Diff line change
@@ -67,14 +67,13 @@ impl<'a> Iterator for Iter<'a> {

fn next(&mut self) -> Option<(&'a Path, PathKind)> {
loop {
match self.iter.next() {
Some(&(kind, ref p)) if self.kind == PathKind::All ||
kind == PathKind::All ||
kind == self.kind => {
match *self.iter.next()? {
(kind, ref p) if self.kind == PathKind::All ||
kind == PathKind::All ||
kind == self.kind => {
return Some((p, kind))
}
Some(..) => {}
None => return None,
_ => {}
}
}
}
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
@@ -615,7 +615,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
let new_loan_str = &new_loan.kind.to_user_str();
self.bccx.cannot_reborrow_already_uniquely_borrowed(
new_loan.span, "closure", &nl, &new_loan_msg, new_loan_str,
old_loan.span, &old_loan_msg, previous_end_span, Origin::Ast)
old_loan.span, &old_loan_msg, previous_end_span, "", Origin::Ast)
}
(..) =>
self.bccx.cannot_reborrow_already_borrowed(
1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
@@ -81,7 +81,6 @@ pub mod sync;
pub mod tiny_list;
pub mod thin_vec;
pub mod transitive_relation;
pub mod tuple_slice;
pub use ena::unify;
pub mod vec_linked_list;
pub mod work_queue;
70 changes: 0 additions & 70 deletions src/librustc_data_structures/tuple_slice.rs

This file was deleted.

8 changes: 2 additions & 6 deletions src/librustc_incremental/persist/work_product.rs
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
return None
}

let saved_files: Option<Vec<_>> =
let saved_files =
files.iter()
.map(|&(kind, ref path)| {
let extension = match kind {
@@ -51,11 +51,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
}
}
})
.collect();
let saved_files = match saved_files {
None => return None,
Some(v) => v,
};
.collect::<Option<Vec<_>>>()?;

let work_product = WorkProduct {
cgu_name: cgu_name.to_string(),
Loading