Auto merge of #56549 - pietroalbini:rollup, r=pietroalbini
Rollup of 15 pull requests Successful merges: - #51753 (Document `From` implementations) - #55563 (Improve no result found sentence in doc search) - #55987 (Add Weak.ptr_eq) - #56119 (Utilize `?` instead of `return None`.) - #56372 (Refer to the second borrow as the "second borrow" in E0501.rs) - #56388 (More MIR borrow check cleanup) - #56424 (Mention raw-ident syntax) - #56452 (Remove redundant clones) - #56456 (Handle existential types in dead code analysis) - #56466 (data_structures: remove tuple_slice) - #56476 (Fix invalid line number match) - #56497 (cleanup: remove static lifetimes from consts in libstd) - #56498 (Fix line numbers display) - #56523 (Added a bare-bones eslint config (removing jslint)) - #56538 (Use inner iterator may_have_side_effect for Cloned) Failed merges: r? @ghost
This commit is contained in:
commit
4988b096e6
59 changed files with 518 additions and 418 deletions
|
@ -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")]
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ||
|
||||
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,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::slice;
|
||||
|
||||
/// Allows to view uniform tuples as slices
|
||||
pub trait TupleSlice<T> {
|
||||
fn as_slice(&self) -> &[T];
|
||||
fn as_mut_slice(&mut self) -> &mut [T];
|
||||
}
|
||||
|
||||
macro_rules! impl_tuple_slice {
|
||||
($tuple_type:ty, $size:expr) => {
|
||||
impl<T> TupleSlice<T> for $tuple_type {
|
||||
fn as_slice(&self) -> &[T] {
|
||||
unsafe {
|
||||
let ptr = &self.0 as *const T;
|
||||
slice::from_raw_parts(ptr, $size)
|
||||
}
|
||||
}
|
||||
|
||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
unsafe {
|
||||
let ptr = &mut self.0 as *mut T;
|
||||
slice::from_raw_parts_mut(ptr, $size)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl_tuple_slice!((T, T), 2);
|
||||
impl_tuple_slice!((T, T, T), 3);
|
||||
impl_tuple_slice!((T, T, T, T), 4);
|
||||
impl_tuple_slice!((T, T, T, T, T), 5);
|
||||
impl_tuple_slice!((T, T, T, T, T, T), 6);
|
||||
impl_tuple_slice!((T, T, T, T, T, T, T), 7);
|
||||
impl_tuple_slice!((T, T, T, T, T, T, T, T), 8);
|
||||
|
||||
#[test]
|
||||
fn test_sliced_tuples() {
|
||||
let t2 = (100, 101);
|
||||
assert_eq!(t2.as_slice(), &[100, 101]);
|
||||
|
||||
let t3 = (102, 103, 104);
|
||||
assert_eq!(t3.as_slice(), &[102, 103, 104]);
|
||||
|
||||
let t4 = (105, 106, 107, 108);
|
||||
assert_eq!(t4.as_slice(), &[105, 106, 107, 108]);
|
||||
|
||||
let t5 = (109, 110, 111, 112, 113);
|
||||
assert_eq!(t5.as_slice(), &[109, 110, 111, 112, 113]);
|
||||
|
||||
let t6 = (114, 115, 116, 117, 118, 119);
|
||||
assert_eq!(t6.as_slice(), &[114, 115, 116, 117, 118, 119]);
|
||||
|
||||
let t7 = (120, 121, 122, 123, 124, 125, 126);
|
||||
assert_eq!(t7.as_slice(), &[120, 121, 122, 123, 124, 125, 126]);
|
||||
|
||||
let t8 = (127, 128, 129, 130, 131, 132, 133, 134);
|
||||
assert_eq!(t8.as_slice(), &[127, 128, 129, 130, 131, 132, 133, 134]);
|
||||
|
||||
}
|
|
@ -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(),
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc::mir::traversal;
|
|||
use rustc::mir::visit::{
|
||||
PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext
|
||||
};
|
||||
use rustc::mir::{self, Location, Mir, Place, Local};
|
||||
use rustc::mir::{self, Location, Mir, Local};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
|
@ -41,10 +41,6 @@ crate struct BorrowSet<'tcx> {
|
|||
/// only need to store one borrow index
|
||||
crate activation_map: FxHashMap<Location, Vec<BorrowIndex>>,
|
||||
|
||||
/// Every borrow has a region; this maps each such regions back to
|
||||
/// its borrow-indexes.
|
||||
crate region_map: FxHashMap<RegionVid, FxHashSet<BorrowIndex>>,
|
||||
|
||||
/// Map from local to all the borrows on that local
|
||||
crate local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
|
||||
|
||||
|
@ -149,7 +145,6 @@ impl<'tcx> BorrowSet<'tcx> {
|
|||
idx_vec: IndexVec::new(),
|
||||
location_map: Default::default(),
|
||||
activation_map: Default::default(),
|
||||
region_map: Default::default(),
|
||||
local_map: Default::default(),
|
||||
pending_activations: Default::default(),
|
||||
locals_state_at_exit:
|
||||
|
@ -164,7 +159,6 @@ impl<'tcx> BorrowSet<'tcx> {
|
|||
borrows: visitor.idx_vec,
|
||||
location_map: visitor.location_map,
|
||||
activation_map: visitor.activation_map,
|
||||
region_map: visitor.region_map,
|
||||
local_map: visitor.local_map,
|
||||
locals_state_at_exit: visitor.locals_state_at_exit,
|
||||
}
|
||||
|
@ -184,7 +178,6 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
|||
idx_vec: IndexVec<BorrowIndex, BorrowData<'tcx>>,
|
||||
location_map: FxHashMap<Location, BorrowIndex>,
|
||||
activation_map: FxHashMap<Location, Vec<BorrowIndex>>,
|
||||
region_map: FxHashMap<RegionVid, FxHashSet<BorrowIndex>>,
|
||||
local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
|
||||
|
||||
/// When we encounter a 2-phase borrow statement, it will always
|
||||
|
@ -229,7 +222,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
|||
|
||||
self.insert_as_pending_if_two_phase(location, &assigned_place, kind, idx);
|
||||
|
||||
self.region_map.entry(region).or_default().insert(idx);
|
||||
if let Some(local) = borrowed_place.root_local() {
|
||||
self.local_map.entry(local).or_default().insert(idx);
|
||||
}
|
||||
|
@ -238,17 +230,18 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
|||
self.super_assign(block, assigned_place, rvalue, location)
|
||||
}
|
||||
|
||||
fn visit_place(
|
||||
fn visit_local(
|
||||
&mut self,
|
||||
place: &mir::Place<'tcx>,
|
||||
temp: &Local,
|
||||
context: PlaceContext<'tcx>,
|
||||
location: Location,
|
||||
) {
|
||||
self.super_place(place, context, location);
|
||||
if !context.is_use() {
|
||||
return;
|
||||
}
|
||||
|
||||
// We found a use of some temporary TEMP...
|
||||
if let Place::Local(temp) = place {
|
||||
// ... check whether we (earlier) saw a 2-phase borrow like
|
||||
// We found a use of some temporary TMP
|
||||
// check whether we (earlier) saw a 2-phase borrow like
|
||||
//
|
||||
// TMP = &mut place
|
||||
if let Some(&borrow_index) = self.pending_activations.get(temp) {
|
||||
|
@ -301,7 +294,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: mir::Location) {
|
||||
if let mir::Rvalue::Ref(region, kind, ref place) = *rvalue {
|
||||
|
|
|
@ -344,6 +344,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let first_borrow_desc;
|
||||
|
||||
let explanation = self.explain_why_borrow_contains_point(context, issued_borrow, None);
|
||||
let second_borrow_desc = if explanation.is_explained() {
|
||||
"second "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
||||
// FIXME: supply non-"" `opt_via` when appropriate
|
||||
let mut err = match (
|
||||
gen_borrow_kind,
|
||||
|
@ -454,6 +461,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
issued_span,
|
||||
"",
|
||||
None,
|
||||
second_borrow_desc,
|
||||
Origin::Mir,
|
||||
)
|
||||
}
|
||||
|
@ -469,6 +477,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
issued_span,
|
||||
"",
|
||||
None,
|
||||
second_borrow_desc,
|
||||
Origin::Mir,
|
||||
)
|
||||
}
|
||||
|
@ -513,7 +522,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
self.explain_why_borrow_contains_point(context, issued_borrow, None)
|
||||
explanation
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, first_borrow_desc);
|
||||
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
|
|
|
@ -52,6 +52,12 @@ pub(in borrow_check) enum LaterUseKind {
|
|||
}
|
||||
|
||||
impl BorrowExplanation {
|
||||
pub(in borrow_check) fn is_explained(&self) -> bool {
|
||||
match self {
|
||||
BorrowExplanation::Unexplained => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
pub(in borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
|
|
|
@ -87,10 +87,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
|
||||
type Item = &'cx Place<'tcx>;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let mut cursor = match self.next {
|
||||
None => return None,
|
||||
Some(place) => place,
|
||||
};
|
||||
let mut cursor = self.next?;
|
||||
|
||||
// Post-processing `place`: Enqueue any remaining
|
||||
// work. Also, `place` may not be a prefix itself, but
|
||||
|
|
|
@ -246,7 +246,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
|
|||
// re-consider the current implementations of the
|
||||
// propagate_call_return method.
|
||||
|
||||
if let mir::Rvalue::Ref(region, _, ref place) = **rhs {
|
||||
if let mir::Rvalue::Ref(_, _, ref place) = **rhs {
|
||||
if place.ignore_borrow(
|
||||
self.tcx,
|
||||
self.mir,
|
||||
|
@ -258,13 +258,6 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
|
|||
panic!("could not find BorrowIndex for location {:?}", location);
|
||||
});
|
||||
|
||||
assert!(self.borrow_set.region_map
|
||||
.get(®ion.to_region_vid())
|
||||
.unwrap_or_else(|| {
|
||||
panic!("could not find BorrowIndexs for RegionVid {:?}", region);
|
||||
})
|
||||
.contains(&index)
|
||||
);
|
||||
sets.gen(*index);
|
||||
|
||||
// Issue #46746: Two-phase borrows handles
|
||||
|
|
|
@ -585,7 +585,7 @@ fn merge_codegen_units<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
|||
// smallest into each other) we're sure to start off with a deterministic
|
||||
// order (sorted by name). This'll mean that if two cgus have the same size
|
||||
// the stable sort below will keep everything nice and deterministic.
|
||||
codegen_units.sort_by_key(|cgu| cgu.name().clone());
|
||||
codegen_units.sort_by_key(|cgu| *cgu.name());
|
||||
|
||||
// Merge the two smallest codegen units until the target size is reached.
|
||||
while codegen_units.len() > target_cgu_count {
|
||||
|
@ -985,7 +985,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
|
|||
output.push_str(" @@");
|
||||
let mut empty = Vec::new();
|
||||
let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
|
||||
cgus.as_mut_slice().sort_by_cached_key(|&(ref name, _)| name.clone());
|
||||
cgus.sort_by_key(|(name, _)| *name);
|
||||
cgus.dedup();
|
||||
for &(ref cgu_name, (linkage, _)) in cgus.iter() {
|
||||
output.push_str(" ");
|
||||
|
|
|
@ -10,17 +10,25 @@
|
|||
|
||||
//! This module provides two passes:
|
||||
//!
|
||||
//! - [CleanAscribeUserType], that replaces all
|
||||
//! [StatementKind::AscribeUserType] statements with [StatementKind::Nop].
|
||||
//! - [CleanFakeReadsAndBorrows], that replaces all [FakeRead] statements and
|
||||
//! borrows that are read by [FakeReadCause::ForMatchGuard] fake reads with
|
||||
//! [StatementKind::Nop].
|
||||
//! - [`CleanAscribeUserType`], that replaces all [`AscribeUserType`]
|
||||
//! statements with [`Nop`].
|
||||
//! - [`CleanFakeReadsAndBorrows`], that replaces all [`FakeRead`] statements
|
||||
//! and borrows that are read by [`ForMatchGuard`] fake reads with [`Nop`].
|
||||
//!
|
||||
//! The [CleanFakeReadsAndBorrows] "pass" is actually implemented as two
|
||||
//! The `CleanFakeReadsAndBorrows` "pass" is actually implemented as two
|
||||
//! traversals (aka visits) of the input MIR. The first traversal,
|
||||
//! [DeleteAndRecordFakeReads], deletes the fake reads and finds the temporaries
|
||||
//! read by [ForMatchGuard] reads, and [DeleteFakeBorrows] deletes the
|
||||
//! initialization of those temporaries.
|
||||
//! [`DeleteAndRecordFakeReads`], deletes the fake reads and finds the
|
||||
//! temporaries read by [`ForMatchGuard`] reads, and [`DeleteFakeBorrows`]
|
||||
//! deletes the initialization of those temporaries.
|
||||
//!
|
||||
//! [`CleanAscribeUserType`]: cleanup_post_borrowck::CleanAscribeUserType
|
||||
//! [`CleanFakeReadsAndBorrows`]: cleanup_post_borrowck::CleanFakeReadsAndBorrows
|
||||
//! [`DeleteAndRecordFakeReads`]: cleanup_post_borrowck::DeleteAndRecordFakeReads
|
||||
//! [`DeleteFakeBorrows`]: cleanup_post_borrowck::DeleteFakeBorrows
|
||||
//! [`AscribeUserType`]: rustc::mir::StatementKind::AscribeUserType
|
||||
//! [`Nop`]: rustc::mir::StatementKind::Nop
|
||||
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
|
||||
//! [`ForMatchGuard`]: rustc::mir::FakeReadCause::ForMatchGuard
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
||||
|
|
|
@ -261,6 +261,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
|
|||
old_loan_span: Span,
|
||||
old_opt_via: &str,
|
||||
previous_end_span: Option<Span>,
|
||||
second_borrow_desc: &str,
|
||||
o: Origin,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let mut err = struct_span_err!(
|
||||
|
@ -274,7 +275,10 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
|
|||
kind_new,
|
||||
OGN = o
|
||||
);
|
||||
err.span_label(new_loan_span, format!("borrow occurs here{}", opt_via));
|
||||
err.span_label(
|
||||
new_loan_span,
|
||||
format!("{}borrow occurs here{}", second_borrow_desc, opt_via),
|
||||
);
|
||||
err.span_label(
|
||||
old_loan_span,
|
||||
format!("{} construction occurs here{}", container_name, old_opt_via),
|
||||
|
|
|
@ -318,7 +318,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
// This particular use tree
|
||||
&tree, id, &prefix, true,
|
||||
// The whole `use` item
|
||||
parent_scope.clone(), item, ty::Visibility::Invisible, root_span,
|
||||
parent_scope, item, ty::Visibility::Invisible, root_span,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3948,10 +3948,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
|||
let mut path_it = path.iter().peekable();
|
||||
|
||||
loop {
|
||||
let segment = match path_it.next() {
|
||||
Some(segment) => segment,
|
||||
None => return None,
|
||||
};
|
||||
let segment = path_it.next()?;
|
||||
|
||||
for item_id in mem::replace(&mut items, HirVec::new()).iter() {
|
||||
let item = tcx.hir.expect_item(item_id.id);
|
||||
|
@ -3986,10 +3983,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
|||
let mut path_it = path.iter().skip(1).peekable();
|
||||
|
||||
loop {
|
||||
let segment = match path_it.next() {
|
||||
Some(segment) => segment,
|
||||
None => return None,
|
||||
};
|
||||
let segment = path_it.next()?;
|
||||
|
||||
for item in mem::replace(&mut items, Lrc::new(vec![])).iter() {
|
||||
if item.ident.name == *segment {
|
||||
|
|
|
@ -2220,13 +2220,13 @@ impl<'a> Item<'a> {
|
|||
return None;
|
||||
}
|
||||
} else {
|
||||
let (krate, src_root) = match cache.extern_locations.get(&self.item.def_id.krate) {
|
||||
Some(&(ref name, ref src, Local)) => (name, src),
|
||||
Some(&(ref name, ref src, Remote(ref s))) => {
|
||||
let (krate, src_root) = match *cache.extern_locations.get(&self.item.def_id.krate)? {
|
||||
(ref name, ref src, Local) => (name, src),
|
||||
(ref name, ref src, Remote(ref s)) => {
|
||||
root = s.to_string();
|
||||
(name, src)
|
||||
}
|
||||
Some(&(_, _, Unknown)) | None => return None,
|
||||
(_, _, Unknown) => return None,
|
||||
};
|
||||
|
||||
clean_srcpath(&src_root, file, false, |component| {
|
||||
|
|
21
src/librustdoc/html/static/.eslintrc.js
Normal file
21
src/librustdoc/html/static/.eslintrc.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2015,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
};
|
|
@ -10,8 +10,12 @@
|
|||
* except according to those terms.
|
||||
*/
|
||||
|
||||
/*jslint browser: true, es5: true */
|
||||
/*globals $: true, rootPath: true */
|
||||
// From rust:
|
||||
/* global ALIASES, currentCrate, rootPath */
|
||||
|
||||
// Local js definitions:
|
||||
/* global addClass, getCurrentValue, hasClass */
|
||||
/* global isHidden onEach, removeClass, updateLocalStorage */
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
|
@ -1300,7 +1304,16 @@ if (!String.prototype.endsWith) {
|
|||
output = '<div class="search-failed"' + extraStyle + '>No results :(<br/>' +
|
||||
'Try on <a href="https://duckduckgo.com/?q=' +
|
||||
encodeURIComponent('rust ' + query.query) +
|
||||
'">DuckDuckGo</a>?</div>';
|
||||
'">DuckDuckGo</a>?<br/><br/>' +
|
||||
'Or try looking in one of these:<ul><li>The <a ' +
|
||||
'href="https://doc.rust-lang.org/reference/index.html">Rust Reference</a> for' +
|
||||
' technical details about the language.</li><li><a ' +
|
||||
'href="https://doc.rust-lang.org/rust-by-example/index.html">Rust By Example' +
|
||||
'</a> for expository code examples.</a></li><li>The <a ' +
|
||||
'href="https://doc.rust-lang.org/book/index.html">Rust Book</a> for ' +
|
||||
'introductions to language features and the language itself.</li><li><a ' +
|
||||
'href="https://docs.rs">Docs.rs</a> for documentation of crates released on ' +
|
||||
'<a href="https://crates.io/">crates.io</a>.</li></ul></div>';
|
||||
}
|
||||
return [output, length];
|
||||
}
|
||||
|
|
|
@ -135,7 +135,6 @@ summary {
|
|||
|
||||
code, pre {
|
||||
font-family: "Source Code Pro", monospace;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.docblock code, .docblock-short code {
|
||||
border-radius: 3px;
|
||||
|
@ -283,7 +282,7 @@ nav.sub {
|
|||
padding-left: 0;
|
||||
}
|
||||
|
||||
:not(.source) .example-wrap {
|
||||
.rustdoc:not(.source) .example-wrap {
|
||||
display: inline-flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
@ -301,8 +300,9 @@ nav.sub {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
:not(.source) .example-wrap > pre.rust {
|
||||
.rustdoc:not(.source) .example-wrap > pre.rust {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
body:not(.source) .example-wrap > pre {
|
||||
|
@ -1132,6 +1132,13 @@ pre.rust {
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.search-failed > ul {
|
||||
text-align: left;
|
||||
max-width: 570px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#titles {
|
||||
height: 35px;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
* except according to those terms.
|
||||
*/
|
||||
|
||||
// From rust:
|
||||
/* global sourcesIndex */
|
||||
|
||||
// Local js definitions:
|
||||
/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */
|
||||
|
||||
function getCurrentFilePath() {
|
||||
var parts = window.location.pathname.split("/");
|
||||
var rootPathParts = window.rootPath.split("/");
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
* except according to those terms.
|
||||
*/
|
||||
|
||||
// From rust:
|
||||
/* global resourcesSuffix */
|
||||
|
||||
var currentTheme = document.getElementById("themeStyle");
|
||||
var mainTheme = document.getElementById("mainThemeStyle");
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
|||
color: rgba(255,142,0,1);
|
||||
}
|
||||
|
||||
.search-failed > a {
|
||||
.search-failed a {
|
||||
color: #0089ff;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
|||
color: rgba(255,142,0,1);
|
||||
}
|
||||
|
||||
.search-failed > a {
|
||||
.search-failed a {
|
||||
color: #0089ff;
|
||||
}
|
||||
|
||||
|
|
|
@ -828,7 +828,7 @@ pub mod consts {
|
|||
/// - s390x
|
||||
/// - sparc64
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const ARCH: &'static str = super::arch::ARCH;
|
||||
pub const ARCH: &str = super::arch::ARCH;
|
||||
|
||||
/// The family of the operating system. Example value is `unix`.
|
||||
///
|
||||
|
@ -837,7 +837,7 @@ pub mod consts {
|
|||
/// - unix
|
||||
/// - windows
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const FAMILY: &'static str = os::FAMILY;
|
||||
pub const FAMILY: &str = os::FAMILY;
|
||||
|
||||
/// A string describing the specific operating system in use.
|
||||
/// Example value is `linux`.
|
||||
|
@ -856,7 +856,7 @@ pub mod consts {
|
|||
/// - android
|
||||
/// - windows
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const OS: &'static str = os::OS;
|
||||
pub const OS: &str = os::OS;
|
||||
|
||||
/// Specifies the filename prefix used for shared libraries on this
|
||||
/// platform. Example value is `lib`.
|
||||
|
@ -866,7 +866,7 @@ pub mod consts {
|
|||
/// - lib
|
||||
/// - `""` (an empty string)
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const DLL_PREFIX: &'static str = os::DLL_PREFIX;
|
||||
pub const DLL_PREFIX: &str = os::DLL_PREFIX;
|
||||
|
||||
/// Specifies the filename suffix used for shared libraries on this
|
||||
/// platform. Example value is `.so`.
|
||||
|
@ -877,7 +877,7 @@ pub mod consts {
|
|||
/// - .dylib
|
||||
/// - .dll
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const DLL_SUFFIX: &'static str = os::DLL_SUFFIX;
|
||||
pub const DLL_SUFFIX: &str = os::DLL_SUFFIX;
|
||||
|
||||
/// Specifies the file extension used for shared libraries on this
|
||||
/// platform that goes after the dot. Example value is `so`.
|
||||
|
@ -888,7 +888,7 @@ pub mod consts {
|
|||
/// - dylib
|
||||
/// - dll
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const DLL_EXTENSION: &'static str = os::DLL_EXTENSION;
|
||||
pub const DLL_EXTENSION: &str = os::DLL_EXTENSION;
|
||||
|
||||
/// Specifies the filename suffix used for executable binaries on this
|
||||
/// platform. Example value is `.exe`.
|
||||
|
@ -900,7 +900,7 @@ pub mod consts {
|
|||
/// - .pexe
|
||||
/// - `""` (an empty string)
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const EXE_SUFFIX: &'static str = os::EXE_SUFFIX;
|
||||
pub const EXE_SUFFIX: &str = os::EXE_SUFFIX;
|
||||
|
||||
/// Specifies the file extension, if any, used for executable binaries
|
||||
/// on this platform. Example value is `exe`.
|
||||
|
@ -910,72 +910,72 @@ pub mod consts {
|
|||
/// - exe
|
||||
/// - `""` (an empty string)
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub const EXE_EXTENSION: &'static str = os::EXE_EXTENSION;
|
||||
pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "x86";
|
||||
pub const ARCH: &str = "x86";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "x86_64";
|
||||
pub const ARCH: &str = "x86_64";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "arm";
|
||||
pub const ARCH: &str = "arm";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "aarch64";
|
||||
pub const ARCH: &str = "aarch64";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "mips")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "mips";
|
||||
pub const ARCH: &str = "mips";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "mips64")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "mips64";
|
||||
pub const ARCH: &str = "mips64";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "powerpc")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "powerpc";
|
||||
pub const ARCH: &str = "powerpc";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "powerpc64")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "powerpc64";
|
||||
pub const ARCH: &str = "powerpc64";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "s390x")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "s390x";
|
||||
pub const ARCH: &str = "s390x";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "sparc64")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "sparc64";
|
||||
pub const ARCH: &str = "sparc64";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "le32")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "le32";
|
||||
pub const ARCH: &str = "le32";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "asmjs")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "asmjs";
|
||||
pub const ARCH: &str = "asmjs";
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod arch {
|
||||
pub const ARCH: &'static str = "wasm32";
|
||||
pub const ARCH: &str = "wasm32";
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -671,7 +671,7 @@ impl fmt::Debug for CStr {
|
|||
#[stable(feature = "cstr_default", since = "1.10.0")]
|
||||
impl<'a> Default for &'a CStr {
|
||||
fn default() -> &'a CStr {
|
||||
const SLICE: &'static [c_char] = &[0];
|
||||
const SLICE: &[c_char] = &[0];
|
||||
unsafe { CStr::from_ptr(SLICE.as_ptr()) }
|
||||
}
|
||||
}
|
||||
|
@ -1475,7 +1475,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn cstr_const_constructor() {
|
||||
const CSTR: &'static CStr = unsafe {
|
||||
const CSTR: &CStr = unsafe {
|
||||
CStr::from_bytes_with_nul_unchecked(b"Hello, world!\0")
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ mod as_keyword { }
|
|||
/// look like this:
|
||||
///
|
||||
/// ```rust
|
||||
/// const WORDS: &'static str = "hello rust!";
|
||||
/// const WORDS: &str = "hello rust!";
|
||||
/// ```
|
||||
///
|
||||
/// Thanks to static lifetime elision, you usually don't have to explicitly use 'static:
|
||||
|
|
|
@ -1397,6 +1397,9 @@ impl<'a> From<&'a Path> for Box<Path> {
|
|||
|
||||
#[stable(feature = "path_buf_from_box", since = "1.18.0")]
|
||||
impl From<Box<Path>> for PathBuf {
|
||||
/// Converts a `Box<Path>` into a `PathBuf`
|
||||
///
|
||||
/// This conversion does not allocate or copy memory.
|
||||
fn from(boxed: Box<Path>) -> PathBuf {
|
||||
boxed.into_path_buf()
|
||||
}
|
||||
|
@ -1404,6 +1407,10 @@ impl From<Box<Path>> for PathBuf {
|
|||
|
||||
#[stable(feature = "box_from_path_buf", since = "1.20.0")]
|
||||
impl From<PathBuf> for Box<Path> {
|
||||
/// Converts a `PathBuf` into a `Box<Path>`
|
||||
///
|
||||
/// This conversion currently should not allocate memory,
|
||||
/// but this behavior is not guaranteed on all platforms or in all future versions.
|
||||
fn from(p: PathBuf) -> Box<Path> {
|
||||
p.into_boxed_path()
|
||||
}
|
||||
|
@ -1426,6 +1433,9 @@ impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl From<OsString> for PathBuf {
|
||||
/// Converts a `OsString` into a `PathBuf`
|
||||
///
|
||||
/// This conversion does not allocate or copy memory.
|
||||
fn from(s: OsString) -> PathBuf {
|
||||
PathBuf { inner: s }
|
||||
}
|
||||
|
@ -1433,6 +1443,9 @@ impl From<OsString> for PathBuf {
|
|||
|
||||
#[stable(feature = "from_path_buf_for_os_string", since = "1.14.0")]
|
||||
impl From<PathBuf> for OsString {
|
||||
/// Converts a `PathBuf` into a `OsString`
|
||||
///
|
||||
/// This conversion does not allocate or copy memory.
|
||||
fn from(path_buf : PathBuf) -> OsString {
|
||||
path_buf.inner
|
||||
}
|
||||
|
@ -1440,6 +1453,9 @@ impl From<PathBuf> for OsString {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl From<String> for PathBuf {
|
||||
/// Converts a `String` into a `PathBuf`
|
||||
///
|
||||
/// This conversion does not allocate or copy memory.
|
||||
fn from(s: String) -> PathBuf {
|
||||
PathBuf::from(OsString::from(s))
|
||||
}
|
||||
|
@ -1536,6 +1552,7 @@ impl<'a> From<Cow<'a, Path>> for PathBuf {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl From<PathBuf> for Arc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: PathBuf) -> Arc<Path> {
|
||||
let arc: Arc<OsStr> = Arc::from(s.into_os_string());
|
||||
|
@ -1545,6 +1562,7 @@ impl From<PathBuf> for Arc<Path> {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a Path> for Arc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: &Path) -> Arc<Path> {
|
||||
let arc: Arc<OsStr> = Arc::from(s.as_os_str());
|
||||
|
@ -1554,6 +1572,7 @@ impl<'a> From<&'a Path> for Arc<Path> {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl From<PathBuf> for Rc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: PathBuf) -> Rc<Path> {
|
||||
let rc: Rc<OsStr> = Rc::from(s.into_os_string());
|
||||
|
@ -1563,6 +1582,7 @@ impl From<PathBuf> for Rc<Path> {
|
|||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a Path> for Rc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: &Path) -> Rc<Path> {
|
||||
let rc: Rc<OsStr> = Rc::from(s.as_os_str());
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "cloudabi";
|
||||
pub const OS: &'static str = "cloudabi";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "cloudabi";
|
||||
pub const OS: &str = "cloudabi";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "redox";
|
||||
pub const OS: &'static str = "redox";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "redox";
|
||||
pub const OS: &str = "redox";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix> {
|
|||
}
|
||||
}
|
||||
|
||||
pub const MAIN_SEP_STR: &'static str = "/";
|
||||
pub const MAIN_SEP_STR: &str = "/";
|
||||
pub const MAIN_SEP: char = '/';
|
||||
|
|
|
@ -143,7 +143,7 @@ impl Command {
|
|||
|
||||
pub fn spawn(&mut self, default: Stdio, needs_stdin: bool)
|
||||
-> io::Result<(Process, StdioPipes)> {
|
||||
const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX";
|
||||
const CLOEXEC_MSG_FOOTER: &[u8] = b"NOEX";
|
||||
|
||||
if self.saw_nul {
|
||||
return Err(io::Error::new(ErrorKind::InvalidInput,
|
||||
|
|
|
@ -10,176 +10,176 @@
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "linux";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "linux";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "macos";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".dylib";
|
||||
pub const DLL_EXTENSION: &'static str = "dylib";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "macos";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".dylib";
|
||||
pub const DLL_EXTENSION: &str = "dylib";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "ios";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".dylib";
|
||||
pub const DLL_EXTENSION: &'static str = "dylib";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "ios";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".dylib";
|
||||
pub const DLL_EXTENSION: &str = "dylib";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "freebsd";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "freebsd";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "dragonfly";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "dragonfly";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "bitrig")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "bitrig";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "bitrig";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "netbsd";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "netbsd";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "openbsd")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "openbsd";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "openbsd";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "android";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "android";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "solaris")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "solaris";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "solaris";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "haiku")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "haiku";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "haiku";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "emscripten", target_arch = "asmjs"))]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "emscripten";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = ".js";
|
||||
pub const EXE_EXTENSION: &'static str = "js";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "emscripten";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = ".js";
|
||||
pub const EXE_EXTENSION: &str = "js";
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "emscripten", target_arch = "wasm32"))]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "emscripten";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = ".js";
|
||||
pub const EXE_EXTENSION: &'static str = "js";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "emscripten";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = ".js";
|
||||
pub const EXE_EXTENSION: &str = "js";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "fuchsia";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "fuchsia";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "l4re")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "l4re";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "l4re";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "hermit")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "unix";
|
||||
pub const OS: &'static str = "hermit";
|
||||
pub const DLL_PREFIX: &'static str = "lib";
|
||||
pub const DLL_SUFFIX: &'static str = ".so";
|
||||
pub const DLL_EXTENSION: &'static str = "so";
|
||||
pub const EXE_SUFFIX: &'static str = "";
|
||||
pub const EXE_EXTENSION: &'static str = "";
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "hermit";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".so";
|
||||
pub const DLL_EXTENSION: &str = "so";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ pub fn parse_prefix(_: &OsStr) -> Option<Prefix> {
|
|||
None
|
||||
}
|
||||
|
||||
pub const MAIN_SEP_STR: &'static str = "/";
|
||||
pub const MAIN_SEP_STR: &str = "/";
|
||||
pub const MAIN_SEP: char = '/';
|
||||
|
|
|
@ -22,7 +22,7 @@ use sys;
|
|||
impl Command {
|
||||
pub fn spawn(&mut self, default: Stdio, needs_stdin: bool)
|
||||
-> io::Result<(Process, StdioPipes)> {
|
||||
const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX";
|
||||
const CLOEXEC_MSG_FOOTER: &[u8] = b"NOEX";
|
||||
|
||||
let envp = self.capture_env();
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "";
|
||||
pub const OS: &'static str = "";
|
||||
pub const DLL_PREFIX: &'static str = "";
|
||||
pub const DLL_SUFFIX: &'static str = ".wasm";
|
||||
pub const DLL_EXTENSION: &'static str = "wasm";
|
||||
pub const EXE_SUFFIX: &'static str = ".wasm";
|
||||
pub const EXE_EXTENSION: &'static str = "wasm";
|
||||
pub const FAMILY: &str = "";
|
||||
pub const OS: &str = "";
|
||||
pub const DLL_PREFIX: &str = "";
|
||||
pub const DLL_SUFFIX: &str = ".wasm";
|
||||
pub const DLL_EXTENSION: &str = "wasm";
|
||||
pub const EXE_SUFFIX: &str = ".wasm";
|
||||
pub const EXE_EXTENSION: &str = "wasm";
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ pub fn parse_prefix(_: &OsStr) -> Option<Prefix> {
|
|||
None
|
||||
}
|
||||
|
||||
pub const MAIN_SEP_STR: &'static str = "/";
|
||||
pub const MAIN_SEP_STR: &str = "/";
|
||||
pub const MAIN_SEP: char = '/';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub mod os {
|
||||
pub const FAMILY: &'static str = "windows";
|
||||
pub const OS: &'static str = "windows";
|
||||
pub const DLL_PREFIX: &'static str = "";
|
||||
pub const DLL_SUFFIX: &'static str = ".dll";
|
||||
pub const DLL_EXTENSION: &'static str = "dll";
|
||||
pub const EXE_SUFFIX: &'static str = ".exe";
|
||||
pub const EXE_EXTENSION: &'static str = "exe";
|
||||
pub const FAMILY: &str = "windows";
|
||||
pub const OS: &str = "windows";
|
||||
pub const DLL_PREFIX: &str = "";
|
||||
pub const DLL_SUFFIX: &str = ".dll";
|
||||
pub const DLL_EXTENSION: &str = "dll";
|
||||
pub const EXE_SUFFIX: &str = ".exe";
|
||||
pub const EXE_EXTENSION: &str = "exe";
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn error_string(mut errnum: i32) -> String {
|
|||
// `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx
|
||||
if (errnum & c::FACILITY_NT_BIT as i32) != 0 {
|
||||
// format according to https://support.microsoft.com/en-us/help/259693
|
||||
const NTDLL_DLL: &'static [u16] = &['N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _,
|
||||
const NTDLL_DLL: &[u16] = &['N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _,
|
||||
'.' as _, 'D' as _, 'L' as _, 'L' as _, 0];
|
||||
module = c::GetModuleHandleW(NTDLL_DLL.as_ptr());
|
||||
|
||||
|
|
|
@ -91,10 +91,7 @@ pub fn parse_prefix<'a>(path: &'a OsStr) -> Option<Prefix> {
|
|||
}
|
||||
|
||||
fn parse_two_comps(mut path: &[u8], f: fn(u8) -> bool) -> Option<(&[u8], &[u8])> {
|
||||
let first = match path.iter().position(|x| f(*x)) {
|
||||
None => return None,
|
||||
Some(x) => &path[..x],
|
||||
};
|
||||
let first = &path[..path.iter().position(|x| f(*x))?];
|
||||
path = &path[(first.len() + 1)..];
|
||||
let idx = path.iter().position(|x| f(*x));
|
||||
let second = &path[..idx.unwrap_or(path.len())];
|
||||
|
@ -102,5 +99,5 @@ pub fn parse_prefix<'a>(path: &'a OsStr) -> Option<Prefix> {
|
|||
}
|
||||
}
|
||||
|
||||
pub const MAIN_SEP_STR: &'static str = "\\";
|
||||
pub const MAIN_SEP_STR: &str = "\\";
|
||||
pub const MAIN_SEP: char = '\\';
|
||||
|
|
|
@ -40,7 +40,7 @@ use str;
|
|||
use sync::Arc;
|
||||
use sys_common::AsInner;
|
||||
|
||||
const UTF8_REPLACEMENT_CHARACTER: &'static str = "\u{FFFD}";
|
||||
const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}";
|
||||
|
||||
/// A Unicode code point: from U+0000 to U+10FFFF.
|
||||
///
|
||||
|
|
|
@ -309,7 +309,7 @@ fn create_matches(len: usize) -> Box<[Rc<NamedMatchVec>]> {
|
|||
vec![]
|
||||
} else {
|
||||
let empty_matches = Rc::new(SmallVec::new());
|
||||
vec![empty_matches.clone(); len]
|
||||
vec![empty_matches; len]
|
||||
}.into_boxed_slice()
|
||||
}
|
||||
|
||||
|
|
|
@ -753,10 +753,7 @@ where It: Iterator {
|
|||
type Item = Vec<It::Item>;
|
||||
|
||||
fn next(&mut self) -> Option<Vec<It::Item>> {
|
||||
let first = match self.it.next() {
|
||||
Some(e) => e,
|
||||
None => return None
|
||||
};
|
||||
let first = self.it.next()?;
|
||||
|
||||
let mut result = Vec::with_capacity(self.n);
|
||||
result.push(first);
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | inside_closure(a)
|
|||
| - first borrow occurs due to use of `a` in closure
|
||||
LL | };
|
||||
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
| ^ second borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- first borrow later used here
|
||||
|
@ -21,7 +21,7 @@ LL | inside_closure(a)
|
|||
| - first borrow occurs due to use of `a` in closure
|
||||
...
|
||||
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
| ^ second borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- first borrow later used here
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | inside_closure(a)
|
|||
| - first borrow occurs due to use of `a` in closure
|
||||
LL | };
|
||||
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
| ^ second borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- first borrow later used here
|
||||
|
@ -21,7 +21,7 @@ LL | inside_closure(a)
|
|||
| - first borrow occurs due to use of `a` in closure
|
||||
...
|
||||
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
| ^ second borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- first borrow later used here
|
||||
|
|
|
@ -10,7 +10,7 @@ LL | | |a| { //~ ERROR closure requires unique access to `f`
|
|||
LL | | f.n.insert(*a);
|
||||
| | - first borrow occurs due to use of `f` in closure
|
||||
LL | | })
|
||||
| |__________^ borrow occurs here
|
||||
| |__________^ second borrow occurs here
|
||||
|
||||
error[E0500]: closure requires unique access to `f` but it is already borrowed
|
||||
--> $DIR/borrowck-insert-during-each.rs:27:9
|
||||
|
|
13
src/test/ui/existential_types/private_unused.rs
Normal file
13
src/test/ui/existential_types/private_unused.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// compile-pass
|
||||
|
||||
#[deny(warnings)]
|
||||
|
||||
enum Empty { }
|
||||
trait Bar<T> {}
|
||||
impl Bar<Empty> for () {}
|
||||
|
||||
fn boo() -> impl Bar<Empty> {}
|
||||
|
||||
fn main() {
|
||||
boo();
|
||||
}
|
|
@ -7,7 +7,7 @@ LL | let a = &mut *x;
|
|||
| - first borrow occurs due to use of `x` in generator
|
||||
...
|
||||
LL | println!("{}", x); //~ ERROR
|
||||
| ^ borrow occurs here
|
||||
| ^ second borrow occurs here
|
||||
LL | b.resume();
|
||||
| - first borrow later used here
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ LL | let f = || *x = 0;
|
|||
| |
|
||||
| closure construction occurs here
|
||||
LL | let y = &x; //~ ERROR
|
||||
| ^^ borrow occurs here
|
||||
| ^^ second borrow occurs here
|
||||
LL | f.use_ref();
|
||||
| - first borrow later used here
|
||||
|
||||
|
@ -138,7 +138,7 @@ LL | let f = || *x = 0;
|
|||
| |
|
||||
| closure construction occurs here
|
||||
LL | let y = &mut x; //~ ERROR
|
||||
| ^^^^^^ borrow occurs here
|
||||
| ^^^^^^ second borrow occurs here
|
||||
LL | f.use_ref();
|
||||
| - first borrow later used here
|
||||
|
||||
|
|
|
@ -119,10 +119,7 @@ fn parse_expected(
|
|||
line: &str,
|
||||
tag: &str,
|
||||
) -> Option<(WhichLine, Error)> {
|
||||
let start = match line.find(tag) {
|
||||
Some(i) => i,
|
||||
None => return None,
|
||||
};
|
||||
let start = line.find(tag)?;
|
||||
let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
|
||||
(true, 0)
|
||||
} else {
|
||||
|
|
|
@ -707,14 +707,8 @@ impl Config {
|
|||
|
||||
fn parse_custom_normalization(&self, mut line: &str, prefix: &str) -> Option<(String, String)> {
|
||||
if self.parse_cfg_name_directive(line, prefix) == ParsedNameDirective::Match {
|
||||
let from = match parse_normalization_string(&mut line) {
|
||||
Some(s) => s,
|
||||
None => return None,
|
||||
};
|
||||
let to = match parse_normalization_string(&mut line) {
|
||||
Some(s) => s,
|
||||
None => return None,
|
||||
};
|
||||
let from = parse_normalization_string(&mut line)?;
|
||||
let to = parse_normalization_string(&mut line)?;
|
||||
Some((from, to))
|
||||
} else {
|
||||
None
|
||||
|
@ -873,14 +867,8 @@ fn expand_variables(mut value: String, config: &Config) -> String {
|
|||
/// ```
|
||||
fn parse_normalization_string(line: &mut &str) -> Option<String> {
|
||||
// FIXME support escapes in strings.
|
||||
let begin = match line.find('"') {
|
||||
Some(i) => i + 1,
|
||||
None => return None,
|
||||
};
|
||||
let end = match line[begin..].find('"') {
|
||||
Some(i) => i + begin,
|
||||
None => return None,
|
||||
};
|
||||
let begin = line.find('"')? + 1;
|
||||
let end = line[begin..].find('"')? + begin;
|
||||
let result = line[begin..end].to_owned();
|
||||
*line = &line[end + 1..];
|
||||
Some(result)
|
||||
|
|
|
@ -332,10 +332,7 @@ fn maybe_redirect(source: &str) -> Option<String> {
|
|||
const REDIRECT: &'static str = "<p>Redirecting to <a href=";
|
||||
|
||||
let mut lines = source.lines();
|
||||
let redirect_line = match lines.nth(6) {
|
||||
Some(l) => l,
|
||||
None => return None,
|
||||
};
|
||||
let redirect_line = lines.nth(6)?;
|
||||
|
||||
redirect_line.find(REDIRECT).map(|i| {
|
||||
let rest = &redirect_line[(i + REDIRECT.len() + 1)..];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue