mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Auto merge of #78060 - JohnTitor:rollup-uou8vyu, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #75802 (resolve: Do not put nonexistent crate `meta` into prelude) - #76607 (Modify executable checking to be more universal) - #77851 (BTreeMap: refactor Entry out of map.rs into its own file) - #78043 (Fix grammar in note for orphan-rule error [E0210]) - #78048 (Suggest correct place to add `self` parameter when inside closure) - #78050 (Small CSS cleanup) - #78059 (Set `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker) Failed merges: r? `@ghost`
This commit is contained in:
commit
043eca7f0b
@ -369,7 +369,7 @@ struct DiagnosticMetadata<'ast> {
|
||||
/// param.
|
||||
currently_processing_generics: bool,
|
||||
|
||||
/// The current enclosing function (used for better errors).
|
||||
/// The current enclosing (non-closure) function (used for better errors).
|
||||
current_function: Option<(FnKind<'ast>, Span)>,
|
||||
|
||||
/// A list of labels as of yet unused. Labels will be removed from this map when
|
||||
@ -515,8 +515,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||
FnKind::Fn(FnCtxt::Assoc(_), ..) => NormalRibKind,
|
||||
FnKind::Closure(..) => ClosureOrAsyncRibKind,
|
||||
};
|
||||
let previous_value =
|
||||
replace(&mut self.diagnostic_metadata.current_function, Some((fn_kind, sp)));
|
||||
let previous_value = self.diagnostic_metadata.current_function;
|
||||
if matches!(fn_kind, FnKind::Fn(..)) {
|
||||
self.diagnostic_metadata.current_function = Some((fn_kind, sp));
|
||||
}
|
||||
debug!("(resolving function) entering function");
|
||||
let declaration = fn_kind.decl();
|
||||
|
||||
|
@ -1240,9 +1240,6 @@ impl<'a> Resolver<'a> {
|
||||
extern_prelude.insert(Ident::with_dummy_span(sym::core), Default::default());
|
||||
if !session.contains_name(&krate.attrs, sym::no_std) {
|
||||
extern_prelude.insert(Ident::with_dummy_span(sym::std), Default::default());
|
||||
if session.rust_2018() {
|
||||
extern_prelude.insert(Ident::with_dummy_span(sym::meta), Default::default());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
||||
)
|
||||
.note(
|
||||
"implementing a foreign trait is only possible if at \
|
||||
least one of the types for which is it implemented is local, \
|
||||
least one of the types for which it is implemented is local, \
|
||||
and no uncovered type parameters appear before that first \
|
||||
local type",
|
||||
)
|
||||
@ -135,7 +135,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
||||
local type",
|
||||
param_ty,
|
||||
)).note("implementing a foreign trait is only possible if at \
|
||||
least one of the types for which is it implemented is local"
|
||||
least one of the types for which it is implemented is local"
|
||||
).note("only traits defined in the current crate can be \
|
||||
implemented for a type parameter"
|
||||
).emit();
|
||||
|
@ -9,13 +9,16 @@ use core::ops::{Index, RangeBounds};
|
||||
use core::ptr;
|
||||
|
||||
use super::borrow::DormantMutRef;
|
||||
use super::node::{self, marker, ForceResult::*, Handle, InsertResult::*, NodeRef};
|
||||
use super::node::{self, marker, ForceResult::*, Handle, NodeRef};
|
||||
use super::search::{self, SearchResult::*};
|
||||
use super::unwrap_unchecked;
|
||||
|
||||
use Entry::*;
|
||||
use UnderflowResult::*;
|
||||
|
||||
mod entry;
|
||||
pub use entry::{Entry, OccupiedEntry, VacantEntry};
|
||||
use Entry::*;
|
||||
|
||||
/// A map based on a B-Tree.
|
||||
///
|
||||
/// B-Trees represent a fundamental compromise between cache-efficiency and actually minimizing
|
||||
@ -452,69 +455,6 @@ impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for RangeMut<'_, K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A view into a single entry in a map, which may either be vacant or occupied.
|
||||
///
|
||||
/// This `enum` is constructed from the [`entry`] method on [`BTreeMap`].
|
||||
///
|
||||
/// [`entry`]: BTreeMap::entry
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Entry<'a, K: 'a, V: 'a> {
|
||||
/// A vacant entry.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
|
||||
|
||||
/// An occupied entry.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V: Debug> Debug for Entry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(),
|
||||
Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A view into a vacant entry in a `BTreeMap`.
|
||||
/// It is part of the [`Entry`] enum.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct VacantEntry<'a, K: 'a, V: 'a> {
|
||||
key: K,
|
||||
handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
|
||||
dormant_map: DormantMutRef<'a, BTreeMap<K, V>>,
|
||||
|
||||
// Be invariant in `K` and `V`
|
||||
_marker: PhantomData<&'a mut (K, V)>,
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V> Debug for VacantEntry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_tuple("VacantEntry").field(self.key()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// A view into an occupied entry in a `BTreeMap`.
|
||||
/// It is part of the [`Entry`] enum.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
|
||||
handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV>,
|
||||
dormant_map: DormantMutRef<'a, BTreeMap<K, V>>,
|
||||
|
||||
// Be invariant in `K` and `V`
|
||||
_marker: PhantomData<&'a mut (K, V)>,
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V: Debug> Debug for OccupiedEntry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
// An iterator for merging two sorted sequences into one
|
||||
struct MergeIter<K, V, I: Iterator<Item = (K, V)>> {
|
||||
left: Peekable<I>,
|
||||
@ -2310,409 +2250,6 @@ impl<K, V> BTreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> Entry<'a, K, V> {
|
||||
/// Ensures a value is in the entry by inserting the default if empty, and returns
|
||||
/// a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn or_insert(self, default: V) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(default),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensures a value is in the entry by inserting the result of the default function if empty,
|
||||
/// and returns a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, String> = BTreeMap::new();
|
||||
/// let s = "hoho".to_string();
|
||||
///
|
||||
/// map.entry("poneyland").or_insert_with(|| s);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], "hoho".to_string());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(default()),
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "or_insert_with_key", issue = "71024")]
|
||||
/// Ensures a value is in the entry by inserting, if empty, the result of the default function,
|
||||
/// which takes the key as its argument, and returns a mutable reference to the value in the
|
||||
/// entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(or_insert_with_key)]
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// map.entry("poneyland").or_insert_with_key(|key| key.chars().count());
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 9);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => {
|
||||
let value = default(entry.key());
|
||||
entry.insert(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to this entry's key.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
match *self {
|
||||
Occupied(ref entry) => entry.key(),
|
||||
Vacant(ref entry) => entry.key(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides in-place mutable access to an occupied entry before any
|
||||
/// potential inserts into the map.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// map.entry("poneyland")
|
||||
/// .and_modify(|e| { *e += 1 })
|
||||
/// .or_insert(42);
|
||||
/// assert_eq!(map["poneyland"], 42);
|
||||
///
|
||||
/// map.entry("poneyland")
|
||||
/// .and_modify(|e| { *e += 1 })
|
||||
/// .or_insert(42);
|
||||
/// assert_eq!(map["poneyland"], 43);
|
||||
/// ```
|
||||
#[stable(feature = "entry_and_modify", since = "1.26.0")]
|
||||
pub fn and_modify<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&mut V),
|
||||
{
|
||||
match self {
|
||||
Occupied(mut entry) => {
|
||||
f(entry.get_mut());
|
||||
Occupied(entry)
|
||||
}
|
||||
Vacant(entry) => Vacant(entry),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V: Default> Entry<'a, K, V> {
|
||||
#[stable(feature = "entry_or_default", since = "1.28.0")]
|
||||
/// Ensures a value is in the entry by inserting the default value if empty,
|
||||
/// and returns a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, Option<usize>> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_default();
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], None);
|
||||
/// ```
|
||||
pub fn or_default(self) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(Default::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
|
||||
/// Gets a reference to the key that would be used when inserting a value
|
||||
/// through the VacantEntry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
&self.key
|
||||
}
|
||||
|
||||
/// Take ownership of the key.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// if let Entry::Vacant(v) = map.entry("poneyland") {
|
||||
/// v.into_key();
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
|
||||
pub fn into_key(self) -> K {
|
||||
self.key
|
||||
}
|
||||
|
||||
/// Sets the value of the entry with the `VacantEntry`'s key,
|
||||
/// and returns a mutable reference to it.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
|
||||
///
|
||||
/// if let Entry::Vacant(o) = map.entry("poneyland") {
|
||||
/// o.insert(37);
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 37);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn insert(self, value: V) -> &'a mut V {
|
||||
let out_ptr = match self.handle.insert_recursing(self.key, value) {
|
||||
(Fit(_), val_ptr) => {
|
||||
// Safety: We have consumed self.handle and the handle returned.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
map.length += 1;
|
||||
val_ptr
|
||||
}
|
||||
(Split(ins), val_ptr) => {
|
||||
drop(ins.left);
|
||||
// Safety: We have consumed self.handle and the reference returned.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
let root = map.root.as_mut().unwrap();
|
||||
root.push_internal_level().push(ins.k, ins.v, ins.right);
|
||||
map.length += 1;
|
||||
val_ptr
|
||||
}
|
||||
};
|
||||
// Now that we have finished growing the tree using borrowed references,
|
||||
// dereference the pointer to a part of it, that we picked up along the way.
|
||||
unsafe { &mut *out_ptr }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
|
||||
/// Gets a reference to the key in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
self.handle.reborrow().into_kv().0
|
||||
}
|
||||
|
||||
/// Take ownership of the key and value from the map.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// // We delete the entry from the map.
|
||||
/// o.remove_entry();
|
||||
/// }
|
||||
///
|
||||
/// // If now try to get the value, it will panic:
|
||||
/// // println!("{}", map["poneyland"]);
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
|
||||
pub fn remove_entry(self) -> (K, V) {
|
||||
self.remove_kv()
|
||||
}
|
||||
|
||||
/// Gets a reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.get(), &12);
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn get(&self) -> &V {
|
||||
self.handle.reborrow().into_kv().1
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the value in the entry.
|
||||
///
|
||||
/// If you need a reference to the `OccupiedEntry` that may outlive the
|
||||
/// destruction of the `Entry` value, see [`into_mut`].
|
||||
///
|
||||
/// [`into_mut`]: OccupiedEntry::into_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
|
||||
/// *o.get_mut() += 10;
|
||||
/// assert_eq!(*o.get(), 22);
|
||||
///
|
||||
/// // We can use the same Entry multiple times.
|
||||
/// *o.get_mut() += 2;
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 24);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn get_mut(&mut self) -> &mut V {
|
||||
self.handle.kv_mut().1
|
||||
}
|
||||
|
||||
/// Converts the entry into a mutable reference to its value.
|
||||
///
|
||||
/// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
|
||||
///
|
||||
/// [`get_mut`]: OccupiedEntry::get_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// *o.into_mut() += 10;
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 22);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn into_mut(self) -> &'a mut V {
|
||||
self.handle.into_val_mut()
|
||||
}
|
||||
|
||||
/// Sets the value of the entry with the `OccupiedEntry`'s key,
|
||||
/// and returns the entry's old value.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.insert(15), 12);
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 15);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn insert(&mut self, value: V) -> V {
|
||||
mem::replace(self.get_mut(), value)
|
||||
}
|
||||
|
||||
/// Takes the value of the entry out of the map, and returns it.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.remove(), 12);
|
||||
/// }
|
||||
/// // If we try to get "poneyland"'s value, it'll panic:
|
||||
/// // println!("{}", map["poneyland"]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn remove(self) -> V {
|
||||
self.remove_kv().1
|
||||
}
|
||||
|
||||
// Body of `remove_entry`, separate to keep the above implementations short.
|
||||
fn remove_kv(self) -> (K, V) {
|
||||
let mut emptied_internal_root = false;
|
||||
let (old_kv, _) = self.handle.remove_kv_tracking(|| emptied_internal_root = true);
|
||||
// SAFETY: we consumed the intermediate root borrow, `self.handle`.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
map.length -= 1;
|
||||
if emptied_internal_root {
|
||||
let root = map.root.as_mut().unwrap();
|
||||
root.pop_internal_level();
|
||||
}
|
||||
old_kv
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV> {
|
||||
/// Removes a key/value-pair from the map, and returns that pair, as well as
|
||||
/// the leaf edge corresponding to that former pair.
|
||||
|
475
library/alloc/src/collections/btree/map/entry.rs
Normal file
475
library/alloc/src/collections/btree/map/entry.rs
Normal file
@ -0,0 +1,475 @@
|
||||
use core::fmt::{self, Debug};
|
||||
use core::marker::PhantomData;
|
||||
use core::mem;
|
||||
|
||||
use super::super::borrow::DormantMutRef;
|
||||
use super::super::node::{marker, Handle, InsertResult::*, NodeRef};
|
||||
use super::BTreeMap;
|
||||
|
||||
use Entry::*;
|
||||
|
||||
/// A view into a single entry in a map, which may either be vacant or occupied.
|
||||
///
|
||||
/// This `enum` is constructed from the [`entry`] method on [`BTreeMap`].
|
||||
///
|
||||
/// [`entry`]: BTreeMap::entry
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Entry<'a, K: 'a, V: 'a> {
|
||||
/// A vacant entry.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
|
||||
|
||||
/// An occupied entry.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V: Debug> Debug for Entry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(),
|
||||
Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A view into a vacant entry in a `BTreeMap`.
|
||||
/// It is part of the [`Entry`] enum.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct VacantEntry<'a, K: 'a, V: 'a> {
|
||||
pub(super) key: K,
|
||||
pub(super) handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
|
||||
pub(super) dormant_map: DormantMutRef<'a, BTreeMap<K, V>>,
|
||||
|
||||
// Be invariant in `K` and `V`
|
||||
pub(super) _marker: PhantomData<&'a mut (K, V)>,
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V> Debug for VacantEntry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_tuple("VacantEntry").field(self.key()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// A view into an occupied entry in a `BTreeMap`.
|
||||
/// It is part of the [`Entry`] enum.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
|
||||
pub(super) handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV>,
|
||||
pub(super) dormant_map: DormantMutRef<'a, BTreeMap<K, V>>,
|
||||
|
||||
// Be invariant in `K` and `V`
|
||||
pub(super) _marker: PhantomData<&'a mut (K, V)>,
|
||||
}
|
||||
|
||||
#[stable(feature = "debug_btree_map", since = "1.12.0")]
|
||||
impl<K: Debug + Ord, V: Debug> Debug for OccupiedEntry<'_, K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> Entry<'a, K, V> {
|
||||
/// Ensures a value is in the entry by inserting the default if empty, and returns
|
||||
/// a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn or_insert(self, default: V) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(default),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensures a value is in the entry by inserting the result of the default function if empty,
|
||||
/// and returns a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, String> = BTreeMap::new();
|
||||
/// let s = "hoho".to_string();
|
||||
///
|
||||
/// map.entry("poneyland").or_insert_with(|| s);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], "hoho".to_string());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(default()),
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "or_insert_with_key", issue = "71024")]
|
||||
/// Ensures a value is in the entry by inserting, if empty, the result of the default function,
|
||||
/// which takes the key as its argument, and returns a mutable reference to the value in the
|
||||
/// entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(or_insert_with_key)]
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// map.entry("poneyland").or_insert_with_key(|key| key.chars().count());
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 9);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => {
|
||||
let value = default(entry.key());
|
||||
entry.insert(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to this entry's key.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
match *self {
|
||||
Occupied(ref entry) => entry.key(),
|
||||
Vacant(ref entry) => entry.key(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides in-place mutable access to an occupied entry before any
|
||||
/// potential inserts into the map.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// map.entry("poneyland")
|
||||
/// .and_modify(|e| { *e += 1 })
|
||||
/// .or_insert(42);
|
||||
/// assert_eq!(map["poneyland"], 42);
|
||||
///
|
||||
/// map.entry("poneyland")
|
||||
/// .and_modify(|e| { *e += 1 })
|
||||
/// .or_insert(42);
|
||||
/// assert_eq!(map["poneyland"], 43);
|
||||
/// ```
|
||||
#[stable(feature = "entry_and_modify", since = "1.26.0")]
|
||||
pub fn and_modify<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&mut V),
|
||||
{
|
||||
match self {
|
||||
Occupied(mut entry) => {
|
||||
f(entry.get_mut());
|
||||
Occupied(entry)
|
||||
}
|
||||
Vacant(entry) => Vacant(entry),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V: Default> Entry<'a, K, V> {
|
||||
#[stable(feature = "entry_or_default", since = "1.28.0")]
|
||||
/// Ensures a value is in the entry by inserting the default value if empty,
|
||||
/// and returns a mutable reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, Option<usize>> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_default();
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], None);
|
||||
/// ```
|
||||
pub fn or_default(self) -> &'a mut V {
|
||||
match self {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(Default::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
|
||||
/// Gets a reference to the key that would be used when inserting a value
|
||||
/// through the VacantEntry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
&self.key
|
||||
}
|
||||
|
||||
/// Take ownership of the key.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
///
|
||||
/// if let Entry::Vacant(v) = map.entry("poneyland") {
|
||||
/// v.into_key();
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
|
||||
pub fn into_key(self) -> K {
|
||||
self.key
|
||||
}
|
||||
|
||||
/// Sets the value of the entry with the `VacantEntry`'s key,
|
||||
/// and returns a mutable reference to it.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
|
||||
///
|
||||
/// if let Entry::Vacant(o) = map.entry("poneyland") {
|
||||
/// o.insert(37);
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 37);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn insert(self, value: V) -> &'a mut V {
|
||||
let out_ptr = match self.handle.insert_recursing(self.key, value) {
|
||||
(Fit(_), val_ptr) => {
|
||||
// Safety: We have consumed self.handle and the handle returned.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
map.length += 1;
|
||||
val_ptr
|
||||
}
|
||||
(Split(ins), val_ptr) => {
|
||||
drop(ins.left);
|
||||
// Safety: We have consumed self.handle and the reference returned.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
let root = map.root.as_mut().unwrap();
|
||||
root.push_internal_level().push(ins.k, ins.v, ins.right);
|
||||
map.length += 1;
|
||||
val_ptr
|
||||
}
|
||||
};
|
||||
// Now that we have finished growing the tree using borrowed references,
|
||||
// dereference the pointer to a part of it, that we picked up along the way.
|
||||
unsafe { &mut *out_ptr }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
|
||||
/// Gets a reference to the key in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_keys", since = "1.10.0")]
|
||||
pub fn key(&self) -> &K {
|
||||
self.handle.reborrow().into_kv().0
|
||||
}
|
||||
|
||||
/// Take ownership of the key and value from the map.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// // We delete the entry from the map.
|
||||
/// o.remove_entry();
|
||||
/// }
|
||||
///
|
||||
/// // If now try to get the value, it will panic:
|
||||
/// // println!("{}", map["poneyland"]);
|
||||
/// ```
|
||||
#[stable(feature = "map_entry_recover_keys2", since = "1.12.0")]
|
||||
pub fn remove_entry(self) -> (K, V) {
|
||||
self.remove_kv()
|
||||
}
|
||||
|
||||
/// Gets a reference to the value in the entry.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.get(), &12);
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn get(&self) -> &V {
|
||||
self.handle.reborrow().into_kv().1
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the value in the entry.
|
||||
///
|
||||
/// If you need a reference to the `OccupiedEntry` that may outlive the
|
||||
/// destruction of the `Entry` value, see [`into_mut`].
|
||||
///
|
||||
/// [`into_mut`]: OccupiedEntry::into_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
|
||||
/// *o.get_mut() += 10;
|
||||
/// assert_eq!(*o.get(), 22);
|
||||
///
|
||||
/// // We can use the same Entry multiple times.
|
||||
/// *o.get_mut() += 2;
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 24);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn get_mut(&mut self) -> &mut V {
|
||||
self.handle.kv_mut().1
|
||||
}
|
||||
|
||||
/// Converts the entry into a mutable reference to its value.
|
||||
///
|
||||
/// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
|
||||
///
|
||||
/// [`get_mut`]: OccupiedEntry::get_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], 12);
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// *o.into_mut() += 10;
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 22);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn into_mut(self) -> &'a mut V {
|
||||
self.handle.into_val_mut()
|
||||
}
|
||||
|
||||
/// Sets the value of the entry with the `OccupiedEntry`'s key,
|
||||
/// and returns the entry's old value.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.insert(15), 12);
|
||||
/// }
|
||||
/// assert_eq!(map["poneyland"], 15);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn insert(&mut self, value: V) -> V {
|
||||
mem::replace(self.get_mut(), value)
|
||||
}
|
||||
|
||||
/// Takes the value of the entry out of the map, and returns it.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::btree_map::Entry;
|
||||
///
|
||||
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
/// map.entry("poneyland").or_insert(12);
|
||||
///
|
||||
/// if let Entry::Occupied(o) = map.entry("poneyland") {
|
||||
/// assert_eq!(o.remove(), 12);
|
||||
/// }
|
||||
/// // If we try to get "poneyland"'s value, it'll panic:
|
||||
/// // println!("{}", map["poneyland"]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn remove(self) -> V {
|
||||
self.remove_kv().1
|
||||
}
|
||||
|
||||
// Body of `remove_entry`, separate to keep the above implementations short.
|
||||
pub(super) fn remove_kv(self) -> (K, V) {
|
||||
let mut emptied_internal_root = false;
|
||||
let (old_kv, _) = self.handle.remove_kv_tracking(|| emptied_internal_root = true);
|
||||
// SAFETY: we consumed the intermediate root borrow, `self.handle`.
|
||||
let map = unsafe { self.dormant_map.awaken() };
|
||||
map.length -= 1;
|
||||
if emptied_internal_root {
|
||||
let root = map.root.as_mut().unwrap();
|
||||
root.pop_internal_level();
|
||||
}
|
||||
old_kv
|
||||
}
|
||||
}
|
@ -737,6 +737,7 @@ impl Step for Tidy {
|
||||
let mut cmd = builder.tool_cmd(Tool::Tidy);
|
||||
cmd.arg(&builder.src);
|
||||
cmd.arg(&builder.initial_cargo);
|
||||
cmd.arg(&builder.out);
|
||||
if builder.is_verbose() {
|
||||
cmd.arg("--verbose");
|
||||
}
|
||||
|
@ -1557,11 +1557,7 @@ h4 > .notable-traits {
|
||||
}
|
||||
|
||||
@media (max-width: 416px) {
|
||||
#titles {
|
||||
height: 73px;
|
||||
}
|
||||
|
||||
#titles > div {
|
||||
#titles, #titles > div {
|
||||
height: 73px;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<T> for isize { }
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<T> Remote1<BigInt> for T { }
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`BigInt`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -13,7 +13,7 @@ error[E0210]: type parameter `A` must be used as the type parameter for some loc
|
||||
LL | impl<A> Foo for A {
|
||||
| ^ type parameter `A` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote for T { }
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote for Box<T> {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<u32> for Box<T> {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<'a, T> Remote1<u32> for &'a T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<u32> for T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<Box<T>> for u32 {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<'a, T> Remote1<&'a T> for u32 {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<'a, T> Remote1<Box<T>> for &'a T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<'a, T> Remote1<&'a T> for Box<T> {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<Box<T>> for T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<'a, T> Remote1<&'a T> for T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<T> Remote2<Box<T>, Local> for u32 {
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<'a, T> Remote2<&'a T, Local> for u32 {
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<T> Remote1<Local> for Box<T> {
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<T> Remote1<Local> for &T {
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
|
||||
LL | impl<T> Remote1<Local> for T {
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<T> for u32 {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<T> for Box<T> {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error[E0210]: type parameter `B` must be used as the type parameter for some local type (e.g., `MyStruct<B>`)
|
||||
@ -13,7 +13,7 @@ error[E0210]: type parameter `B` must be used as the type parameter for some loc
|
||||
LL | impl<'a, A, B> Remote1<A> for &'a B {
|
||||
| ^ type parameter `B` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Remote1<T> for T {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -10,6 +10,10 @@ impl Foo {
|
||||
fn baz(_: i32) {
|
||||
self.bar(); //~ ERROR E0424
|
||||
}
|
||||
|
||||
fn qux() {
|
||||
let _ = || self.bar(); //~ ERROR E0424
|
||||
}
|
||||
}
|
||||
|
||||
fn main () {
|
||||
|
@ -24,14 +24,27 @@ help: add a `self` receiver parameter to make the associated `fn` a method
|
||||
LL | fn baz(&self, _: i32) {
|
||||
| ^^^^^^
|
||||
|
||||
error[E0424]: expected value, found module `self`
|
||||
--> $DIR/E0424.rs:15:20
|
||||
|
|
||||
LL | fn qux() {
|
||||
| --- this function doesn't have a `self` parameter
|
||||
LL | let _ = || self.bar();
|
||||
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
||||
|
|
||||
help: add a `self` receiver parameter to make the associated `fn` a method
|
||||
|
|
||||
LL | fn qux(&self) {
|
||||
| ^^^^^
|
||||
|
||||
error[E0424]: expected unit struct, unit variant or constant, found module `self`
|
||||
--> $DIR/E0424.rs:16:9
|
||||
--> $DIR/E0424.rs:20:9
|
||||
|
|
||||
LL | fn main () {
|
||||
| ---- this function can't have a `self` parameter
|
||||
LL | let self = "self";
|
||||
| ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0424`.
|
||||
|
@ -14,7 +14,7 @@ error[E0210]: type parameter `Foo` must be used as the type parameter for some l
|
||||
LL | impl<Foo> Deref for Foo { }
|
||||
| ^^^ type parameter `Foo` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -21,7 +21,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> Drop for T where T: A {
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -5,6 +5,9 @@ trait B <A> {
|
||||
fn b(x: i32) {
|
||||
this.b(x); //~ ERROR cannot find value `this` in this scope
|
||||
}
|
||||
fn c() {
|
||||
let _ = || this.a; //~ ERROR cannot find value `this` in this scope
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -28,6 +28,21 @@ help: if you meant to use `self`, you are also missing a `self` receiver argumen
|
||||
LL | fn b(&self, x: i32) {
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0425]: cannot find value `this` in this scope
|
||||
--> $DIR/issue-5099.rs:9:20
|
||||
|
|
||||
LL | let _ = || this.a;
|
||||
| ^^^^ not found in this scope
|
||||
|
|
||||
help: you might have meant to use `self` here instead
|
||||
|
|
||||
LL | let _ = || self.a;
|
||||
| ^^^^
|
||||
help: if you meant to use `self`, you are also missing a `self` receiver argument
|
||||
|
|
||||
LL | fn c(&self) {
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0425`.
|
||||
|
@ -4,7 +4,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some loc
|
||||
LL | impl<T> RemoteTrait for T where T: LocalTrait {}
|
||||
| ^ type parameter `T` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,7 +0,0 @@
|
||||
// edition:2018
|
||||
|
||||
// Tests that `meta` is allowed, even if the crate doesn't exist
|
||||
// yet (i.e., it causes a different error than `not-allowed.rs`).
|
||||
use meta; //~ ERROR can't find crate for `meta`
|
||||
|
||||
fn main() {}
|
@ -1,9 +0,0 @@
|
||||
error[E0463]: can't find crate for `meta`
|
||||
--> $DIR/meta.rs:5:5
|
||||
|
|
||||
LL | use meta;
|
||||
| ^^^^ can't find crate
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0463`.
|
@ -14,7 +14,7 @@ error[E0210]: type parameter `F` must be used as the type parameter for some loc
|
||||
LL | impl<F> FnOnce<()> for &F {
|
||||
| ^ type parameter `F` must be used as the type parameter for some local type
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
|
||||
= note: only traits defined in the current crate can be implemented for a type parameter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -14,7 +14,7 @@ pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "Bina
|
||||
pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"];
|
||||
pub const BOX: [&str; 3] = ["alloc", "boxed", "Box"];
|
||||
pub const BTREEMAP: [&str; 5] = ["alloc", "collections", "btree", "map", "BTreeMap"];
|
||||
pub const BTREEMAP_ENTRY: [&str; 5] = ["alloc", "collections", "btree", "map", "Entry"];
|
||||
pub const BTREEMAP_ENTRY: [&str; 6] = ["alloc", "collections", "btree", "map", "entry", "Entry"];
|
||||
pub const BTREESET: [&str; 5] = ["alloc", "collections", "btree", "set", "BTreeSet"];
|
||||
pub const CLONE_TRAIT: [&str; 3] = ["core", "clone", "Clone"];
|
||||
pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
|
||||
|
@ -34,6 +34,9 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Avoid failure caused by newer mdbook.
|
||||
export MDBOOK_OUTPUT__HTML__INPUT_404=""
|
||||
|
||||
book_name=""
|
||||
# Iterative will avoid cleaning up, so you can quickly run it repeatedly.
|
||||
iterative=0
|
||||
|
@ -9,19 +9,56 @@ use std::path::Path;
|
||||
|
||||
// All files are executable on Windows, so just check on Unix.
|
||||
#[cfg(windows)]
|
||||
pub fn check(_path: &Path, _bad: &mut bool) {}
|
||||
pub fn check(_path: &Path, _output: &Path, _bad: &mut bool) {}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
pub fn check(path: &Path, output: &Path, bad: &mut bool) {
|
||||
use std::fs;
|
||||
use std::os::unix::prelude::*;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
if let Ok(contents) = fs::read_to_string("/proc/version") {
|
||||
// Probably on Windows Linux Subsystem or Docker via VirtualBox,
|
||||
// all files will be marked as executable, so skip checking.
|
||||
if contents.contains("Microsoft") || contents.contains("boot2docker") {
|
||||
return;
|
||||
fn is_executable(path: &Path) -> std::io::Result<bool> {
|
||||
Ok(path.metadata()?.mode() & 0o111 != 0)
|
||||
}
|
||||
|
||||
// We want to avoid false positives on filesystems that do not support the
|
||||
// executable bit. This occurs on some versions of Window's linux subsystem,
|
||||
// for example.
|
||||
//
|
||||
// We try to create the temporary file first in the src directory, which is
|
||||
// the preferred location as it's most likely to be on the same filesystem,
|
||||
// and then in the output (`build`) directory if that fails. Sometimes we
|
||||
// see the source directory mounted as read-only which means we can't
|
||||
// readily create a file there to test.
|
||||
//
|
||||
// See #36706 and #74753 for context.
|
||||
let mut temp_path = path.join("tidy-test-file");
|
||||
match fs::File::create(&temp_path).or_else(|_| {
|
||||
temp_path = output.join("tidy-test-file");
|
||||
fs::File::create(&temp_path)
|
||||
}) {
|
||||
Ok(file) => {
|
||||
let exec = is_executable(&temp_path).unwrap_or(false);
|
||||
std::mem::drop(file);
|
||||
std::fs::remove_file(&temp_path).expect("Deleted temp file");
|
||||
if exec {
|
||||
// If the file is executable, then we assume that this
|
||||
// filesystem does not track executability, so skip this check.
|
||||
return;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
// If the directory is read-only or we otherwise don't have rights,
|
||||
// just don't run this check.
|
||||
//
|
||||
// 30 is the "Read-only filesystem" code at least in one CI
|
||||
// environment.
|
||||
if e.raw_os_error() == Some(30) {
|
||||
eprintln!("tidy: Skipping binary file check, read-only filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
panic!("unable to create temporary file `{:?}`: {:?}", temp_path, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,8 +73,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
return;
|
||||
}
|
||||
|
||||
let metadata = t!(entry.metadata(), file);
|
||||
if metadata.mode() & 0o111 != 0 {
|
||||
if t!(is_executable(&file), file) {
|
||||
let rel_path = file.strip_prefix(path).unwrap();
|
||||
let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");
|
||||
let output = Command::new("git")
|
||||
|
@ -13,6 +13,8 @@ use std::process;
|
||||
fn main() {
|
||||
let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into();
|
||||
let cargo: PathBuf = env::args_os().nth(2).expect("need path to cargo").into();
|
||||
let output_directory: PathBuf =
|
||||
env::args_os().nth(3).expect("need path to output directory").into();
|
||||
|
||||
let src_path = root_path.join("src");
|
||||
let library_path = root_path.join("library");
|
||||
@ -36,9 +38,9 @@ fn main() {
|
||||
unit_tests::check(&library_path, &mut bad);
|
||||
|
||||
// Checks that need to be done for both the compiler and std libraries.
|
||||
bins::check(&src_path, &mut bad);
|
||||
bins::check(&compiler_path, &mut bad);
|
||||
bins::check(&library_path, &mut bad);
|
||||
bins::check(&src_path, &output_directory, &mut bad);
|
||||
bins::check(&compiler_path, &output_directory, &mut bad);
|
||||
bins::check(&library_path, &output_directory, &mut bad);
|
||||
|
||||
style::check(&src_path, &mut bad);
|
||||
style::check(&compiler_path, &mut bad);
|
||||
|
Loading…
Reference in New Issue
Block a user