Auto merge of #70816 - Dylan-DPC:rollup-kzcs8px, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #67797 (Query-ify Instance::resolve) - #70777 (Don't import integer and float modules, use assoc consts) - #70795 (Keep track of position when deleting from a BTreeMap) - #70812 (Do not use "nil" to refer to `()`) - #70815 (Enable layout debugging for `impl Trait` type aliases) Failed merges: r? @ghost
This commit is contained in:
commit
b543afca9b
@ -1,7 +1,6 @@
|
||||
mod _common;
|
||||
|
||||
use _common::validate;
|
||||
use std::u64;
|
||||
|
||||
fn main() {
|
||||
for exp in 19..64 {
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use core::intrinsics::{self, min_align_of_val, size_of_val};
|
||||
use core::ptr::{NonNull, Unique};
|
||||
use core::usize;
|
||||
|
||||
#[stable(feature = "alloc_module", since = "1.28.0")]
|
||||
#[doc(inline)]
|
||||
|
@ -20,7 +20,6 @@
|
||||
//! ```
|
||||
//! use std::cmp::Ordering;
|
||||
//! use std::collections::BinaryHeap;
|
||||
//! use std::usize;
|
||||
//!
|
||||
//! #[derive(Copy, Clone, Eq, PartialEq)]
|
||||
//! struct State {
|
||||
|
@ -1780,18 +1780,12 @@ where
|
||||
where
|
||||
F: FnMut(&K, &mut V) -> bool,
|
||||
{
|
||||
while let Some(kv) = unsafe { self.next_kv() } {
|
||||
let (k, v) = unsafe { ptr::read(&kv) }.into_kv_mut();
|
||||
while let Some(mut kv) = unsafe { self.next_kv() } {
|
||||
let (k, v) = kv.kv_mut();
|
||||
if pred(k, v) {
|
||||
*self.length -= 1;
|
||||
let (k, v, leaf_edge_location) = kv.remove_kv_tracking();
|
||||
// `remove_kv_tracking` has either preserved or invalidated `self.cur_leaf_edge`
|
||||
if let Some(node) = leaf_edge_location {
|
||||
match search::search_tree(node, &k) {
|
||||
search::SearchResult::Found(_) => unreachable!(),
|
||||
search::SearchResult::GoDown(leaf) => self.cur_leaf_edge = Some(leaf),
|
||||
}
|
||||
};
|
||||
self.cur_leaf_edge = Some(leaf_edge_location);
|
||||
return Some((k, v));
|
||||
}
|
||||
self.cur_leaf_edge = Some(kv.next_leaf_edge());
|
||||
@ -2698,28 +2692,26 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
|
||||
|
||||
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 whereabouts of the leaf edge corresponding to that former pair:
|
||||
/// if None is returned, the leaf edge is still the left leaf edge of the KV handle;
|
||||
/// if a node is returned, it heads the subtree where the leaf edge may be found.
|
||||
/// the leaf edge corresponding to that former pair.
|
||||
fn remove_kv_tracking(
|
||||
self,
|
||||
) -> (K, V, Option<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>>) {
|
||||
let mut levels_down_handled: isize;
|
||||
let (small_leaf, old_key, old_val) = match self.force() {
|
||||
) -> (K, V, Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>) {
|
||||
let (mut pos, old_key, old_val, was_internal) = match self.force() {
|
||||
Leaf(leaf) => {
|
||||
levels_down_handled = 1; // handled at same level, but affects only the right side
|
||||
let (hole, old_key, old_val) = leaf.remove();
|
||||
(hole.into_node(), old_key, old_val)
|
||||
(hole, old_key, old_val, false)
|
||||
}
|
||||
Internal(mut internal) => {
|
||||
// Replace the location freed in the internal node with the next KV,
|
||||
// and remove that next KV from its leaf.
|
||||
levels_down_handled = unsafe { ptr::read(&internal).into_node().height() } as isize;
|
||||
|
||||
let key_loc = internal.kv_mut().0 as *mut K;
|
||||
let val_loc = internal.kv_mut().1 as *mut V;
|
||||
|
||||
let to_remove = internal.right_edge().descend().first_leaf_edge().right_kv().ok();
|
||||
// Deleting from the left side is typically faster since we can
|
||||
// just pop an element from the end of the KV array without
|
||||
// needing to shift the other values.
|
||||
let to_remove = internal.left_edge().descend().last_leaf_edge().left_kv().ok();
|
||||
let to_remove = unsafe { unwrap_unchecked(to_remove) };
|
||||
|
||||
let (hole, key, val) = to_remove.remove();
|
||||
@ -2727,50 +2719,69 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInter
|
||||
let old_key = unsafe { mem::replace(&mut *key_loc, key) };
|
||||
let old_val = unsafe { mem::replace(&mut *val_loc, val) };
|
||||
|
||||
(hole.into_node(), old_key, old_val)
|
||||
(hole, old_key, old_val, true)
|
||||
}
|
||||
};
|
||||
|
||||
// Handle underflow
|
||||
let mut cur_node = small_leaf.forget_type();
|
||||
let mut cur_node = unsafe { ptr::read(&pos).into_node().forget_type() };
|
||||
let mut at_leaf = true;
|
||||
while cur_node.len() < node::MIN_LEN {
|
||||
match handle_underfull_node(cur_node) {
|
||||
AtRoot(root) => {
|
||||
cur_node = root;
|
||||
break;
|
||||
}
|
||||
EmptyParent(_) => unreachable!(),
|
||||
Merged(parent) => {
|
||||
levels_down_handled -= 1;
|
||||
AtRoot => break,
|
||||
Merged(edge, merged_with_left, offset) => {
|
||||
// If we merged with our right sibling then our tracked
|
||||
// position has not changed. However if we merged with our
|
||||
// left sibling then our tracked position is now dangling.
|
||||
if at_leaf && merged_with_left {
|
||||
let idx = pos.idx() + offset;
|
||||
let node = match unsafe { ptr::read(&edge).descend().force() } {
|
||||
Leaf(leaf) => leaf,
|
||||
Internal(_) => unreachable!(),
|
||||
};
|
||||
pos = unsafe { Handle::new_edge(node, idx) };
|
||||
}
|
||||
|
||||
let parent = edge.into_node();
|
||||
if parent.len() == 0 {
|
||||
// We must be at the root
|
||||
let root = parent.into_root_mut();
|
||||
root.pop_level();
|
||||
cur_node = root.as_mut();
|
||||
parent.into_root_mut().pop_level();
|
||||
break;
|
||||
} else {
|
||||
cur_node = parent.forget_type();
|
||||
at_leaf = false;
|
||||
}
|
||||
}
|
||||
Stole(internal_node) => {
|
||||
levels_down_handled -= 1;
|
||||
cur_node = internal_node.forget_type();
|
||||
Stole(stole_from_left) => {
|
||||
// Adjust the tracked position if we stole from a left sibling
|
||||
if stole_from_left && at_leaf {
|
||||
// SAFETY: This is safe since we just added an element to our node.
|
||||
unsafe {
|
||||
pos.next_unchecked();
|
||||
}
|
||||
}
|
||||
|
||||
// This internal node might be underfull, but only if it's the root.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let leaf_edge_location = if levels_down_handled > 0 { None } else { Some(cur_node) };
|
||||
(old_key, old_val, leaf_edge_location)
|
||||
// If we deleted from an internal node then we need to compensate for
|
||||
// the earlier swap and adjust the tracked position to point to the
|
||||
// next element.
|
||||
if was_internal {
|
||||
pos = unsafe { unwrap_unchecked(pos.next_kv().ok()).next_leaf_edge() };
|
||||
}
|
||||
|
||||
(old_key, old_val, pos)
|
||||
}
|
||||
}
|
||||
|
||||
enum UnderflowResult<'a, K, V> {
|
||||
AtRoot(NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>),
|
||||
EmptyParent(NodeRef<marker::Mut<'a>, K, V, marker::Internal>),
|
||||
Merged(NodeRef<marker::Mut<'a>, K, V, marker::Internal>),
|
||||
Stole(NodeRef<marker::Mut<'a>, K, V, marker::Internal>),
|
||||
AtRoot,
|
||||
Merged(Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::Edge>, bool, usize),
|
||||
Stole(bool),
|
||||
}
|
||||
|
||||
fn handle_underfull_node<K, V>(
|
||||
@ -2778,28 +2789,27 @@ fn handle_underfull_node<K, V>(
|
||||
) -> UnderflowResult<'_, K, V> {
|
||||
let parent = match node.ascend() {
|
||||
Ok(parent) => parent,
|
||||
Err(root) => return AtRoot(root),
|
||||
Err(_) => return AtRoot,
|
||||
};
|
||||
|
||||
let (is_left, mut handle) = match parent.left_kv() {
|
||||
Ok(left) => (true, left),
|
||||
Err(parent) => match parent.right_kv() {
|
||||
Ok(right) => (false, right),
|
||||
Err(parent) => {
|
||||
return EmptyParent(parent.into_node());
|
||||
}
|
||||
},
|
||||
Err(parent) => {
|
||||
let right = unsafe { unwrap_unchecked(parent.right_kv().ok()) };
|
||||
(false, right)
|
||||
}
|
||||
};
|
||||
|
||||
if handle.can_merge() {
|
||||
Merged(handle.merge().into_node())
|
||||
let offset = if is_left { handle.reborrow().left_edge().descend().len() + 1 } else { 0 };
|
||||
Merged(handle.merge(), is_left, offset)
|
||||
} else {
|
||||
if is_left {
|
||||
handle.steal_left();
|
||||
} else {
|
||||
handle.steal_right();
|
||||
}
|
||||
Stole(handle.into_node())
|
||||
Stole(is_left)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,6 +723,11 @@ impl<Node, Type> Handle<Node, Type> {
|
||||
pub fn into_node(self) -> Node {
|
||||
self.node
|
||||
}
|
||||
|
||||
/// Returns the position of this handle in the node.
|
||||
pub fn idx(&self) -> usize {
|
||||
self.idx
|
||||
}
|
||||
}
|
||||
|
||||
impl<BorrowType, K, V, NodeType> Handle<NodeRef<BorrowType, K, V, NodeType>, marker::KV> {
|
||||
|
@ -250,7 +250,6 @@ use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
|
||||
use core::pin::Pin;
|
||||
use core::ptr::{self, NonNull};
|
||||
use core::slice::{self, from_raw_parts_mut};
|
||||
use core::usize;
|
||||
|
||||
use crate::alloc::{box_free, handle_alloc_error, AllocInit, AllocRef, Global, Layout};
|
||||
use crate::string::String;
|
||||
|
@ -90,7 +90,6 @@ use core::borrow::{Borrow, BorrowMut};
|
||||
use core::cmp::Ordering::{self, Less};
|
||||
use core::mem::{self, size_of};
|
||||
use core::ptr;
|
||||
use core::{u16, u32, u8};
|
||||
|
||||
use crate::borrow::ToOwned;
|
||||
use crate::boxed::Box;
|
||||
|
@ -23,7 +23,6 @@ use core::ptr::{self, NonNull};
|
||||
use core::slice::{self, from_raw_parts_mut};
|
||||
use core::sync::atomic;
|
||||
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
|
||||
use core::{isize, usize};
|
||||
|
||||
use crate::alloc::{box_free, handle_alloc_error, AllocInit, AllocRef, Global, Layout};
|
||||
use crate::boxed::Box;
|
||||
|
@ -3,8 +3,6 @@
|
||||
use core::any::Any;
|
||||
use core::clone::Clone;
|
||||
use core::convert::TryInto;
|
||||
use core::f64;
|
||||
use core::i64;
|
||||
use core::ops::Deref;
|
||||
use core::result::Result::{Err, Ok};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::borrow::Cow;
|
||||
use std::collections::TryReserveError::*;
|
||||
use std::mem::size_of;
|
||||
use std::{isize, usize};
|
||||
|
||||
pub trait IntoCow<'a, B: ?Sized>
|
||||
where
|
||||
|
@ -3,7 +3,6 @@ use std::collections::TryReserveError::*;
|
||||
use std::mem::size_of;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::vec::{Drain, IntoIter};
|
||||
use std::{isize, usize};
|
||||
|
||||
struct DropCounter<'a> {
|
||||
count: &'a mut u32,
|
||||
|
@ -3,7 +3,6 @@ use std::collections::{vec_deque::Drain, VecDeque};
|
||||
use std::fmt::Debug;
|
||||
use std::mem::size_of;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::{isize, usize};
|
||||
|
||||
use crate::hash;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::super::*;
|
||||
use core::num::flt2dec::strategy::dragon::*;
|
||||
use std::{f64, i16};
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::super::*;
|
||||
use core::num::flt2dec::strategy::grisu::*;
|
||||
use std::{f64, i16};
|
||||
use test::Bencher;
|
||||
|
||||
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
||||
|
@ -104,7 +104,6 @@ fn test_format_int() {
|
||||
|
||||
#[test]
|
||||
fn test_format_int_exp_limits() {
|
||||
use core::{i128, i16, i32, i64, i8, u128, u16, u32, u64, u8};
|
||||
assert_eq!(format!("{:e}", i8::MIN), "-1.28e2");
|
||||
assert_eq!(format!("{:e}", i8::MAX), "1.27e2");
|
||||
assert_eq!(format!("{:e}", i16::MIN), "-3.2768e4");
|
||||
@ -125,8 +124,6 @@ fn test_format_int_exp_limits() {
|
||||
|
||||
#[test]
|
||||
fn test_format_int_exp_precision() {
|
||||
use core::{i128, i16, i32, i64, i8};
|
||||
|
||||
//test that float and integer match
|
||||
let big_int: u32 = 314_159_265;
|
||||
assert_eq!(format!("{:.1e}", big_int), format!("{:.1e}", f64::from(big_int)));
|
||||
@ -214,7 +211,6 @@ fn test_format_int_sign_padding() {
|
||||
|
||||
#[test]
|
||||
fn test_format_int_twos_complement() {
|
||||
use core::{i16, i32, i64, i8};
|
||||
assert_eq!(format!("{}", i8::MIN), "-128");
|
||||
assert_eq!(format!("{}", i16::MIN), "-32768");
|
||||
assert_eq!(format!("{}", i32::MIN), "-2147483648");
|
||||
|
@ -3,8 +3,6 @@
|
||||
use core::cell::Cell;
|
||||
use core::convert::TryFrom;
|
||||
use core::iter::*;
|
||||
use core::usize;
|
||||
use core::{i16, i8, isize};
|
||||
|
||||
#[test]
|
||||
fn test_lt() {
|
||||
@ -2251,62 +2249,58 @@ fn test_range_inclusive_folds() {
|
||||
|
||||
#[test]
|
||||
fn test_range_size_hint() {
|
||||
use core::usize::MAX as UMAX;
|
||||
assert_eq!((0..0usize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..100usize).size_hint(), (100, Some(100)));
|
||||
assert_eq!((0..UMAX).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
|
||||
let umax = u128::try_from(UMAX).unwrap();
|
||||
let umax = u128::try_from(usize::MAX).unwrap();
|
||||
assert_eq!((0..0u128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..100u128).size_hint(), (100, Some(100)));
|
||||
assert_eq!((0..umax).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..umax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..umax).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..umax + 1).size_hint(), (usize::MAX, None));
|
||||
|
||||
use core::isize::{MAX as IMAX, MIN as IMIN};
|
||||
assert_eq!((0..0isize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((-100..100isize).size_hint(), (200, Some(200)));
|
||||
assert_eq!((IMIN..IMAX).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((isize::MIN..isize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
|
||||
let imin = i128::try_from(IMIN).unwrap();
|
||||
let imax = i128::try_from(IMAX).unwrap();
|
||||
let imin = i128::try_from(isize::MIN).unwrap();
|
||||
let imax = i128::try_from(isize::MAX).unwrap();
|
||||
assert_eq!((0..0i128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((-100..100i128).size_hint(), (200, Some(200)));
|
||||
assert_eq!((imin..imax).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((imin..imax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..imax).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((imin..imax + 1).size_hint(), (usize::MAX, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_inclusive_size_hint() {
|
||||
use core::usize::MAX as UMAX;
|
||||
assert_eq!((1..=0usize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0usize).size_hint(), (1, Some(1)));
|
||||
assert_eq!((0..=100usize).size_hint(), (101, Some(101)));
|
||||
assert_eq!((0..=UMAX - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..=UMAX).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=usize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..=usize::MAX).size_hint(), (usize::MAX, None));
|
||||
|
||||
let umax = u128::try_from(UMAX).unwrap();
|
||||
let umax = u128::try_from(usize::MAX).unwrap();
|
||||
assert_eq!((1..=0u128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0u128).size_hint(), (1, Some(1)));
|
||||
assert_eq!((0..=100u128).size_hint(), (101, Some(101)));
|
||||
assert_eq!((0..=umax - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..=umax).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=umax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=umax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..=umax).size_hint(), (usize::MAX, None));
|
||||
assert_eq!((0..=umax + 1).size_hint(), (usize::MAX, None));
|
||||
|
||||
use core::isize::{MAX as IMAX, MIN as IMIN};
|
||||
assert_eq!((0..=-1isize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0isize).size_hint(), (1, Some(1)));
|
||||
assert_eq!((-100..=100isize).size_hint(), (201, Some(201)));
|
||||
assert_eq!((IMIN..=IMAX - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((IMIN..=IMAX).size_hint(), (UMAX, None));
|
||||
assert_eq!((isize::MIN..=isize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((isize::MIN..=isize::MAX).size_hint(), (usize::MAX, None));
|
||||
|
||||
let imin = i128::try_from(IMIN).unwrap();
|
||||
let imax = i128::try_from(IMAX).unwrap();
|
||||
let imin = i128::try_from(isize::MIN).unwrap();
|
||||
let imax = i128::try_from(isize::MAX).unwrap();
|
||||
assert_eq!((0..=-1i128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0i128).size_hint(), (1, Some(1)));
|
||||
assert_eq!((-100..=100i128).size_hint(), (201, Some(201)));
|
||||
assert_eq!((imin..=imax - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((imin..=imax).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..=imax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..=imax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((imin..=imax).size_hint(), (usize::MAX, None));
|
||||
assert_eq!((imin..=imax + 1).size_hint(), (usize::MAX, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,7 +1,5 @@
|
||||
#![allow(overflowing_literals)]
|
||||
|
||||
use std::{f32, f64, i64};
|
||||
|
||||
mod parse;
|
||||
mod rawfp;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::{f32, f64, fmt, i16, str};
|
||||
use std::{fmt, str};
|
||||
|
||||
use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
|
||||
use core::num::flt2dec::{round_up, Formatted, Part, Sign, MAX_SIG_DIGITS};
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
use std::i16;
|
||||
use std::str;
|
||||
|
||||
use core::num::flt2dec::strategy::grisu::format_exact_opt;
|
||||
|
@ -2,7 +2,6 @@ macro_rules! int_module {
|
||||
($T:ident, $T_i:ident) => {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::isize;
|
||||
use core::mem;
|
||||
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
||||
use core::$T_i::*;
|
||||
|
@ -5,7 +5,6 @@ use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::{BytePos, CharPos, FileName, Pos};
|
||||
|
||||
use log::debug;
|
||||
use std::usize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -25,7 +25,7 @@ use rustc_span::Span;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::{i128, iter, u128};
|
||||
use std::iter;
|
||||
|
||||
fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Value> {
|
||||
let llvm_name = match name {
|
||||
|
@ -17,8 +17,6 @@ use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
|
||||
|
||||
use std::{i128, u128};
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn codegen_rvalue(
|
||||
&mut self,
|
||||
|
@ -23,7 +23,6 @@
|
||||
use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use std::fmt::Debug;
|
||||
use std::usize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -93,7 +93,6 @@ use std::path::Path;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::u32;
|
||||
|
||||
use measureme::{EventId, EventIdBuilder, SerializableString, StringId};
|
||||
use parking_lot::RwLock;
|
||||
|
@ -7,7 +7,6 @@ use std::iter::{self, FromIterator};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Index, IndexMut, Range, RangeBounds};
|
||||
use std::slice;
|
||||
use std::u32;
|
||||
use std::vec;
|
||||
|
||||
/// Represents some newtyped `usize` wrapper.
|
||||
|
@ -8,7 +8,6 @@ use rustc_data_structures::unify as ut;
|
||||
use std::cmp;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Range;
|
||||
use std::u32;
|
||||
|
||||
pub struct TypeVariableTable<'tcx> {
|
||||
values: sv::SnapshotVec<Delegate>,
|
||||
|
@ -58,5 +58,4 @@ pub fn setup_callbacks() {
|
||||
rustc_span::SPAN_DEBUG.swap(&(span_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
|
||||
rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
|
||||
TRACK_DIAGNOSTICS.swap(&(track_diagnostic as fn(&_)));
|
||||
rustc_middle::ty::RESOLVE_INSTANCE.swap(&(rustc_ty::instance::resolve_instance as _));
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use rustc_target::spec::abi::Abi;
|
||||
|
||||
use log::debug;
|
||||
use std::cmp;
|
||||
use std::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
|
||||
|
||||
declare_lint! {
|
||||
UNUSED_COMPARISONS,
|
||||
|
@ -42,7 +42,6 @@ use std::io;
|
||||
use std::mem;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::u32;
|
||||
|
||||
pub use cstore_impl::{provide, provide_extern};
|
||||
|
||||
|
@ -39,7 +39,6 @@ use rustc_target::abi::VariantIdx;
|
||||
use std::hash::Hash;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::u32;
|
||||
|
||||
struct EncodeContext<'tcx> {
|
||||
opaque: opaque::Encoder,
|
||||
|
@ -33,7 +33,7 @@ use std::borrow::Cow;
|
||||
use std::fmt::{self, Debug, Display, Formatter, Write};
|
||||
use std::ops::Index;
|
||||
use std::slice;
|
||||
use std::{iter, mem, option, u32};
|
||||
use std::{iter, mem, option};
|
||||
|
||||
pub use self::cache::{BodyAndCache, ReadOnlyBodyAndCache};
|
||||
pub use self::query::*;
|
||||
|
@ -1257,5 +1257,9 @@ rustc_queries! {
|
||||
eval_always
|
||||
desc { "looking up enabled feature gates" }
|
||||
}
|
||||
|
||||
query resolve_instance(key: (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>)) -> Option<ty::Instance<'tcx>> {
|
||||
desc { "resolving instance `{:?}` `{:?}` with {:?}", key.1, key.2, key.0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_data_structures::AtomicRef;
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::lang_items::DropInPlaceFnLangItem;
|
||||
@ -289,7 +288,9 @@ impl<'tcx> Instance<'tcx> {
|
||||
def_id: DefId,
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> Option<Instance<'tcx>> {
|
||||
(*RESOLVE_INSTANCE)(tcx, param_env, def_id, substs)
|
||||
// All regions in the result of this query are erased, so it's
|
||||
// fine to erase all of the input regions.
|
||||
tcx.resolve_instance((tcx.erase_regions(¶m_env), def_id, tcx.erase_regions(&substs)))
|
||||
}
|
||||
|
||||
pub fn resolve_for_fn_ptr(
|
||||
@ -440,21 +441,3 @@ fn needs_fn_once_adapter_shim(
|
||||
(ty::ClosureKind::FnMut, _) | (ty::ClosureKind::FnOnce, _) => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_instance_default(
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
_param_env: ty::ParamEnv<'tcx>,
|
||||
_def_id: DefId,
|
||||
_substs: SubstsRef<'tcx>,
|
||||
) -> Option<Instance<'tcx>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub static RESOLVE_INSTANCE: AtomicRef<
|
||||
for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
ty::ParamEnv<'tcx>,
|
||||
DefId,
|
||||
SubstsRef<'tcx>,
|
||||
) -> Option<Instance<'tcx>>,
|
||||
> = AtomicRef::new(&(resolve_instance_default as _));
|
||||
|
@ -81,7 +81,6 @@ pub use self::context::{
|
||||
CtxtInterners, GeneratorInteriorTypeCause, GlobalCtxt, Lift, TypeckTables,
|
||||
};
|
||||
|
||||
pub use self::instance::RESOLVE_INSTANCE;
|
||||
pub use self::instance::{Instance, InstanceDef};
|
||||
|
||||
pub use self::trait_def::TraitDef;
|
||||
|
@ -296,3 +296,14 @@ impl Key for (Symbol, u32, u32) {
|
||||
DUMMY_SP
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>) {
|
||||
type CacheSelector = DefaultCacheSelector;
|
||||
|
||||
fn query_crate(&self) -> CrateNum {
|
||||
self.1.krate
|
||||
}
|
||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
tcx.def_span(self.1)
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::{cmp, iter, mem, usize};
|
||||
use std::{cmp, iter, mem};
|
||||
|
||||
use crate::const_eval::{is_const_fn, is_unstable_const_fn};
|
||||
use crate::transform::check_consts::{is_lang_panic_fn, qualifs, ConstKind, Item};
|
||||
|
@ -5,7 +5,6 @@ use rustc_middle::mir::*;
|
||||
use rustc_middle::ty;
|
||||
use smallvec::SmallVec;
|
||||
use std::convert::TryInto;
|
||||
use std::u32;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
crate fn field_match_pairs<'pat>(
|
||||
|
@ -17,7 +17,6 @@ use rustc_span::symbol::kw;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
use std::u32;
|
||||
|
||||
use super::lints;
|
||||
|
||||
|
@ -256,7 +256,6 @@ use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::iter::{FromIterator, IntoIterator};
|
||||
use std::ops::RangeInclusive;
|
||||
use std::u128;
|
||||
|
||||
crate fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pat<'tcx>) -> Pat<'tcx> {
|
||||
LiteralExpander { tcx: cx.tcx, param_env: cx.param_env }.fold_pattern(&pat)
|
||||
|
@ -27,7 +27,8 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
|
||||
ItemKind::TyAlias(..)
|
||||
| ItemKind::Enum(..)
|
||||
| ItemKind::Struct(..)
|
||||
| ItemKind::Union(..) => {
|
||||
| ItemKind::Union(..)
|
||||
| ItemKind::OpaqueTy(..) => {
|
||||
for attr in self.tcx.get_attrs(item_def_id).iter() {
|
||||
if attr.check_name(sym::rustc_layout) {
|
||||
self.dump_layout_of(item_def_id, item, attr);
|
||||
@ -84,7 +85,7 @@ impl LayoutTest<'tcx> {
|
||||
sym::debug => {
|
||||
self.tcx.sess.span_err(
|
||||
item.span,
|
||||
&format!("layout debugging: {:#?}", *ty_layout),
|
||||
&format!("layout debugging for type {:?}: {:#?}", ty, *ty_layout),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -112,10 +112,10 @@ use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::rc::Rc;
|
||||
use std::{fmt, u32};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
struct Variable(u32);
|
||||
|
@ -7,7 +7,6 @@ use rustc_macros::HashStable_Generic;
|
||||
use rustc_serialize::{Decoder, Encoder};
|
||||
use std::borrow::Borrow;
|
||||
use std::fmt;
|
||||
use std::{u32, u64};
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
pub struct CrateId {
|
||||
|
@ -11,9 +11,7 @@ use log::debug;
|
||||
|
||||
pub fn resolve_instance<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
def_id: DefId,
|
||||
substs: SubstsRef<'tcx>,
|
||||
(param_env, def_id, substs): (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>),
|
||||
) -> Option<Instance<'tcx>> {
|
||||
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
||||
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
|
||||
@ -199,3 +197,7 @@ fn resolve_associated_item<'tcx>(
|
||||
traits::VtableAutoImpl(..) | traits::VtableParam(..) | traits::VtableTraitAlias(..) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
||||
*providers = ty::query::Providers { resolve_instance, ..*providers };
|
||||
}
|
||||
|
@ -25,4 +25,5 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
common_traits::provide(providers);
|
||||
needs_drop::provide(providers);
|
||||
ty::provide(providers);
|
||||
instance::provide(providers);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ use std::collections::hash_map::Entry;
|
||||
use std::default::Default;
|
||||
use std::hash::Hash;
|
||||
use std::rc::Rc;
|
||||
use std::u32;
|
||||
use std::{mem, vec};
|
||||
|
||||
use crate::core::{self, DocContext, ImplTraitParam};
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::cmp;
|
||||
use std::string::String;
|
||||
use std::usize;
|
||||
|
||||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::core::DocContext;
|
||||
|
@ -17,7 +17,6 @@ use rustc_serialize::{Decodable, Encodable};
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::prelude::*;
|
||||
use std::string;
|
||||
use std::{f32, f64, i64, u64};
|
||||
use Animal::*;
|
||||
|
||||
#[derive(RustcDecodable, Eq, PartialEq, Debug)]
|
||||
|
@ -320,7 +320,7 @@ mod prim_char {}
|
||||
|
||||
#[doc(primitive = "unit")]
|
||||
//
|
||||
/// The `()` type, sometimes called "unit" or "nil".
|
||||
/// The `()` type, also called "unit".
|
||||
///
|
||||
/// The `()` type has exactly one value `()`, and is used when there
|
||||
/// is no other meaningful value that could be returned. `()` is most
|
||||
|
@ -12,7 +12,6 @@ use self::StartResult::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::intrinsics::abort;
|
||||
use core::isize;
|
||||
|
||||
use crate::cell::UnsafeCell;
|
||||
use crate::ptr;
|
||||
|
@ -11,7 +11,6 @@ use self::Message::*;
|
||||
pub use self::UpgradeResult::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::isize;
|
||||
|
||||
use crate::cell::UnsafeCell;
|
||||
use crate::ptr;
|
||||
|
@ -26,7 +26,6 @@ use self::Blocker::*;
|
||||
pub use self::Failure::*;
|
||||
|
||||
use core::intrinsics::abort;
|
||||
use core::isize;
|
||||
use core::mem;
|
||||
use core::ptr;
|
||||
|
||||
|
@ -6,7 +6,6 @@ use crate::io;
|
||||
use crate::mem;
|
||||
use crate::sys::hermit::abi;
|
||||
use crate::time::Duration;
|
||||
use core::u32;
|
||||
|
||||
pub type Tid = abi::Tid;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN"
|
||||
#![feature(never_type, rustc_attrs)]
|
||||
#![feature(never_type, rustc_attrs, type_alias_impl_trait)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#[rustc_layout(debug)]
|
||||
@ -13,3 +13,10 @@ union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout debugging
|
||||
|
||||
#[rustc_layout(debug)]
|
||||
type Test = Result<i32, i32>; //~ ERROR: layout debugging
|
||||
|
||||
#[rustc_layout(debug)]
|
||||
type T = impl std::fmt::Debug; //~ ERROR: layout debugging
|
||||
|
||||
fn f() -> T {
|
||||
0i32
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: layout debugging: Layout {
|
||||
error: layout debugging for type E: Layout {
|
||||
fields: Arbitrary {
|
||||
offsets: [
|
||||
Size {
|
||||
@ -110,7 +110,7 @@ error: layout debugging: Layout {
|
||||
LL | enum E { Foo, Bar(!, i32, i32) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: layout debugging: Layout {
|
||||
error: layout debugging for type S: Layout {
|
||||
fields: Arbitrary {
|
||||
offsets: [
|
||||
Size {
|
||||
@ -164,7 +164,7 @@ error: layout debugging: Layout {
|
||||
LL | struct S { f1: i32, f2: (), f3: i32 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: layout debugging: Layout {
|
||||
error: layout debugging for type U: Layout {
|
||||
fields: Union(
|
||||
2,
|
||||
),
|
||||
@ -190,7 +190,7 @@ error: layout debugging: Layout {
|
||||
LL | union U { f1: (i32, i32), f3: i32 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: layout debugging: Layout {
|
||||
error: layout debugging for type std::result::Result<i32, i32>: Layout {
|
||||
fields: Arbitrary {
|
||||
offsets: [
|
||||
Size {
|
||||
@ -315,5 +315,37 @@ error: layout debugging: Layout {
|
||||
LL | type Test = Result<i32, i32>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: layout debugging for type i32: Layout {
|
||||
fields: Union(
|
||||
0,
|
||||
),
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
abi: Scalar(
|
||||
Scalar {
|
||||
value: Int(
|
||||
I32,
|
||||
true,
|
||||
),
|
||||
valid_range: 0..=4294967295,
|
||||
},
|
||||
),
|
||||
largest_niche: None,
|
||||
align: AbiAndPrefAlign {
|
||||
abi: Align {
|
||||
pow2: 2,
|
||||
},
|
||||
pref: $PREF_ALIGN,
|
||||
},
|
||||
size: Size {
|
||||
raw: 4,
|
||||
},
|
||||
}
|
||||
--> $DIR/debug.rs:18:1
|
||||
|
|
||||
LL | type T = impl std::fmt::Debug;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user