mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
This commit is contained in:
parent
785aeac521
commit
441dc3640a
@ -236,26 +236,6 @@ impl<T> TypedArena<T> {
|
||||
start_ptr
|
||||
}
|
||||
|
||||
/// Allocates a slice of objects that are copied into the `TypedArena`, returning a mutable
|
||||
/// reference to it. Will panic if passed a zero-sized types.
|
||||
///
|
||||
/// Panics:
|
||||
///
|
||||
/// - Zero-sized types
|
||||
/// - Zero-length slices
|
||||
#[inline]
|
||||
pub fn alloc_slice(&self, slice: &[T]) -> &mut [T]
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
unsafe {
|
||||
let len = slice.len();
|
||||
let start_ptr = self.alloc_raw_slice(len);
|
||||
slice.as_ptr().copy_to_nonoverlapping(start_ptr, len);
|
||||
slice::from_raw_parts_mut(start_ptr, len)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn alloc_from_iter<I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T] {
|
||||
assert!(mem::size_of::<T>() != 0);
|
||||
|
@ -762,14 +762,6 @@ pub enum Mutability {
|
||||
}
|
||||
|
||||
impl Mutability {
|
||||
/// Returns `MutMutable` only if both `self` and `other` are mutable.
|
||||
pub fn and(self, other: Self) -> Self {
|
||||
match self {
|
||||
Mutability::Mut => other,
|
||||
Mutability::Not => Mutability::Not,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn invert(self) -> Self {
|
||||
match self {
|
||||
Mutability::Mut => Mutability::Not,
|
||||
@ -1722,13 +1714,6 @@ impl FloatTy {
|
||||
FloatTy::F64 => sym::f64,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bit_width(self) -> u64 {
|
||||
match self {
|
||||
FloatTy::F32 => 32,
|
||||
FloatTy::F64 => 64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
@ -1764,29 +1749,6 @@ impl IntTy {
|
||||
IntTy::I128 => sym::i128,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bit_width(&self) -> Option<u64> {
|
||||
Some(match *self {
|
||||
IntTy::Isize => return None,
|
||||
IntTy::I8 => 8,
|
||||
IntTy::I16 => 16,
|
||||
IntTy::I32 => 32,
|
||||
IntTy::I64 => 64,
|
||||
IntTy::I128 => 128,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn normalize(&self, target_width: u32) -> Self {
|
||||
match self {
|
||||
IntTy::Isize => match target_width {
|
||||
16 => IntTy::I16,
|
||||
32 => IntTy::I32,
|
||||
64 => IntTy::I64,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
_ => *self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Debug)]
|
||||
@ -1822,29 +1784,6 @@ impl UintTy {
|
||||
UintTy::U128 => sym::u128,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bit_width(&self) -> Option<u64> {
|
||||
Some(match *self {
|
||||
UintTy::Usize => return None,
|
||||
UintTy::U8 => 8,
|
||||
UintTy::U16 => 16,
|
||||
UintTy::U32 => 32,
|
||||
UintTy::U64 => 64,
|
||||
UintTy::U128 => 128,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn normalize(&self, target_width: u32) -> Self {
|
||||
match self {
|
||||
UintTy::Usize => match target_width {
|
||||
16 => UintTy::U16,
|
||||
32 => UintTy::U32,
|
||||
64 => UintTy::U64,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
_ => *self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or
|
||||
@ -2215,9 +2154,6 @@ pub struct FnDecl {
|
||||
}
|
||||
|
||||
impl FnDecl {
|
||||
pub fn get_self(&self) -> Option<ExplicitSelf> {
|
||||
self.inputs.get(0).and_then(Param::to_self)
|
||||
}
|
||||
pub fn has_self(&self) -> bool {
|
||||
self.inputs.get(0).map_or(false, Param::is_self)
|
||||
}
|
||||
|
@ -100,16 +100,7 @@ impl NestedMetaItem {
|
||||
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
|
||||
}
|
||||
|
||||
/// Returns `true` if `self` is a `MetaItem` and the meta item is a `ValueString`.
|
||||
pub fn is_value_str(&self) -> bool {
|
||||
self.value_str().is_some()
|
||||
}
|
||||
|
||||
/// Returns `true` if `self` is a `MetaItem` and the meta item is a list.
|
||||
pub fn is_meta_item_list(&self) -> bool {
|
||||
self.meta_item_list().is_some()
|
||||
}
|
||||
|
||||
/// See [`MetaItem::name_value_literal_span`].
|
||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||
self.meta_item()?.name_value_literal_span()
|
||||
}
|
||||
@ -165,31 +156,6 @@ impl Attribute {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_meta_item_list(&self) -> bool {
|
||||
self.meta_item_list().is_some()
|
||||
}
|
||||
|
||||
/// Indicates if the attribute is a `ValueString`.
|
||||
pub fn is_value_str(&self) -> bool {
|
||||
self.value_str().is_some()
|
||||
}
|
||||
|
||||
/// This is used in case you want the value span instead of the whole attribute. Example:
|
||||
///
|
||||
/// ```text
|
||||
/// #[doc(alias = "foo")]
|
||||
/// ```
|
||||
///
|
||||
/// In here, it'll return a span for `"foo"`.
|
||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||
match self.kind {
|
||||
AttrKind::Normal(ref item, _) => {
|
||||
item.meta(self.span).and_then(|meta| meta.name_value_literal_span())
|
||||
}
|
||||
AttrKind::DocComment(..) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetaItem {
|
||||
@ -236,10 +202,6 @@ impl MetaItem {
|
||||
self.path == name
|
||||
}
|
||||
|
||||
pub fn is_value_str(&self) -> bool {
|
||||
self.value_str().is_some()
|
||||
}
|
||||
|
||||
/// This is used in case you want the value span instead of the whole attribute. Example:
|
||||
///
|
||||
/// ```text
|
||||
|
@ -89,10 +89,6 @@ impl TokenTree {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn joint(self) -> TokenStream {
|
||||
TokenStream::new(vec![(self, Spacing::Joint)])
|
||||
}
|
||||
|
||||
pub fn token(kind: TokenKind, span: Span) -> TokenTree {
|
||||
TokenTree::Token(Token::new(kind, span))
|
||||
}
|
||||
@ -278,14 +274,6 @@ impl TokenStream {
|
||||
self.0.len()
|
||||
}
|
||||
|
||||
pub fn span(&self) -> Option<Span> {
|
||||
match &**self.0 {
|
||||
[] => None,
|
||||
[(tt, _)] => Some(tt.span()),
|
||||
[(tt_start, _), .., (tt_end, _)] => Some(tt_start.span().to(tt_end.span())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_streams(mut streams: SmallVec<[TokenStream; 2]>) -> TokenStream {
|
||||
match streams.len() {
|
||||
0 => TokenStream::default(),
|
||||
@ -325,10 +313,6 @@ impl TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trees_ref(&self) -> CursorRef<'_> {
|
||||
CursorRef::new(self)
|
||||
}
|
||||
|
||||
pub fn trees(&self) -> Cursor {
|
||||
self.clone().into_trees()
|
||||
}
|
||||
@ -427,10 +411,6 @@ pub struct CursorRef<'t> {
|
||||
}
|
||||
|
||||
impl<'t> CursorRef<'t> {
|
||||
fn new(stream: &TokenStream) -> CursorRef<'_> {
|
||||
CursorRef { stream, index: 0 }
|
||||
}
|
||||
|
||||
fn next_with_spacing(&mut self) -> Option<&'t TreeAndSpacing> {
|
||||
self.stream.0.get(self.index).map(|tree| {
|
||||
self.index += 1;
|
||||
|
@ -22,10 +22,6 @@ pub fn token_to_string(token: &Token) -> String {
|
||||
State::new().token_to_string(token)
|
||||
}
|
||||
|
||||
pub fn token_to_string_ext(token: &Token, convert_dollar_crate: bool) -> String {
|
||||
State::new().token_to_string_ext(token, convert_dollar_crate)
|
||||
}
|
||||
|
||||
pub fn ty_to_string(ty: &ast::Ty) -> String {
|
||||
State::new().ty_to_string(ty)
|
||||
}
|
||||
@ -50,18 +46,10 @@ pub fn tts_to_string(tokens: &TokenStream) -> String {
|
||||
State::new().tts_to_string(tokens)
|
||||
}
|
||||
|
||||
pub fn stmt_to_string(stmt: &ast::Stmt) -> String {
|
||||
State::new().stmt_to_string(stmt)
|
||||
}
|
||||
|
||||
pub fn item_to_string(i: &ast::Item) -> String {
|
||||
State::new().item_to_string(i)
|
||||
}
|
||||
|
||||
pub fn generic_params_to_string(generic_params: &[ast::GenericParam]) -> String {
|
||||
State::new().generic_params_to_string(generic_params)
|
||||
}
|
||||
|
||||
pub fn path_to_string(p: &ast::Path) -> String {
|
||||
State::new().path_to_string(p)
|
||||
}
|
||||
@ -74,26 +62,14 @@ pub fn vis_to_string(v: &ast::Visibility) -> String {
|
||||
State::new().vis_to_string(v)
|
||||
}
|
||||
|
||||
pub fn block_to_string(blk: &ast::Block) -> String {
|
||||
State::new().block_to_string(blk)
|
||||
}
|
||||
|
||||
pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
|
||||
State::new().meta_list_item_to_string(li)
|
||||
}
|
||||
|
||||
pub fn attr_item_to_string(ai: &ast::AttrItem) -> String {
|
||||
State::new().attr_item_to_string(ai)
|
||||
}
|
||||
|
||||
pub fn attribute_to_string(attr: &ast::Attribute) -> String {
|
||||
State::new().attribute_to_string(attr)
|
||||
}
|
||||
|
||||
pub fn param_to_string(arg: &ast::Param) -> String {
|
||||
State::new().param_to_string(arg)
|
||||
}
|
||||
|
||||
pub fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
|
||||
State::new().to_string(f)
|
||||
}
|
||||
|
@ -2292,10 +2292,6 @@ impl<'a> State<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_usize(&mut self, i: usize) {
|
||||
self.s.word(i.to_string())
|
||||
}
|
||||
|
||||
crate fn print_name(&mut self, name: Symbol) {
|
||||
self.s.word(name.to_string());
|
||||
self.ann.post(self, AnnNode::Name(&name))
|
||||
|
@ -190,33 +190,6 @@ pub enum RealPredicate {
|
||||
RealPredicateTrue = 15,
|
||||
}
|
||||
|
||||
impl RealPredicate {
|
||||
pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
|
||||
match realpred {
|
||||
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
|
||||
RealPredicate::RealPredicateFalse
|
||||
}
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
|
||||
RealPredicate::RealPredicateTrue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// LLVMTypeKind
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
#[repr(C)]
|
||||
@ -711,7 +684,7 @@ pub mod coverageinfo {
|
||||
}
|
||||
|
||||
impl CounterMappingRegion {
|
||||
pub fn code_region(
|
||||
crate fn code_region(
|
||||
counter: coverage_map::Counter,
|
||||
file_id: u32,
|
||||
start_line: u32,
|
||||
@ -730,65 +703,6 @@ pub mod coverageinfo {
|
||||
kind: RegionKind::CodeRegion,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expansion_region(
|
||||
file_id: u32,
|
||||
expanded_file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter: coverage_map::Counter::zero(),
|
||||
file_id,
|
||||
expanded_file_id,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col,
|
||||
kind: RegionKind::ExpansionRegion,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn skipped_region(
|
||||
file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter: coverage_map::Counter::zero(),
|
||||
file_id,
|
||||
expanded_file_id: 0,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col,
|
||||
kind: RegionKind::SkippedRegion,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gap_region(
|
||||
counter: coverage_map::Counter,
|
||||
file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter,
|
||||
file_id,
|
||||
expanded_file_id: 0,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col: ((1 as u32) << 31) | end_col,
|
||||
kind: RegionKind::GapRegion,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,46 +43,6 @@ cfg_if! {
|
||||
use std::ops::Add;
|
||||
use std::panic::{resume_unwind, catch_unwind, AssertUnwindSafe};
|
||||
|
||||
/// This is a single threaded variant of AtomicCell provided by crossbeam.
|
||||
/// Unlike `Atomic` this is intended for all `Copy` types,
|
||||
/// but it lacks the explicit ordering arguments.
|
||||
#[derive(Debug)]
|
||||
pub struct AtomicCell<T: Copy>(Cell<T>);
|
||||
|
||||
impl<T: Copy> AtomicCell<T> {
|
||||
#[inline]
|
||||
pub fn new(v: T) -> Self {
|
||||
AtomicCell(Cell::new(v))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
self.0.get_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy> AtomicCell<T> {
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> T {
|
||||
self.0.into_inner()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn load(&self) -> T {
|
||||
self.0.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn store(&self, val: T) {
|
||||
self.0.set(val)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn swap(&self, val: T) -> T {
|
||||
self.0.replace(val)
|
||||
}
|
||||
}
|
||||
|
||||
/// This is a single threaded variant of `AtomicU64`, `AtomicUsize`, etc.
|
||||
/// It differs from `AtomicCell` in that it has explicit ordering arguments
|
||||
/// and is only intended for use with the native atomic types.
|
||||
@ -99,11 +59,6 @@ cfg_if! {
|
||||
}
|
||||
|
||||
impl<T: Copy> Atomic<T> {
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> T {
|
||||
self.0.into_inner()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn load(&self, _: Ordering) -> T {
|
||||
self.0.get()
|
||||
@ -113,11 +68,6 @@ cfg_if! {
|
||||
pub fn store(&self, val: T, _: Ordering) {
|
||||
self.0.set(val)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn swap(&self, val: T, _: Ordering) -> T {
|
||||
self.0.replace(val)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + PartialEq> Atomic<T> {
|
||||
@ -159,22 +109,6 @@ cfg_if! {
|
||||
(oper_a(), oper_b())
|
||||
}
|
||||
|
||||
pub struct SerialScope;
|
||||
|
||||
impl SerialScope {
|
||||
pub fn spawn<F>(&self, f: F)
|
||||
where F: FnOnce(&SerialScope)
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scope<F, R>(f: F) -> R
|
||||
where F: FnOnce(&SerialScope) -> R
|
||||
{
|
||||
f(&SerialScope)
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! parallel {
|
||||
($($blocks:tt),*) => {
|
||||
@ -246,12 +180,6 @@ cfg_if! {
|
||||
pub fn new<F: FnMut(usize) -> T>(mut f: F) -> WorkerLocal<T> {
|
||||
WorkerLocal(OneThread::new(f(0)))
|
||||
}
|
||||
|
||||
/// Returns the worker-local value for each thread
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> Vec<T> {
|
||||
vec![OneThread::into_inner(self.0)]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for WorkerLocal<T> {
|
||||
@ -279,16 +207,6 @@ cfg_if! {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn lock(&self) -> &T {
|
||||
&self.0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn lock_mut(&mut self) -> &mut T {
|
||||
&mut self.0
|
||||
@ -521,16 +439,6 @@ impl<T> RwLock<T> {
|
||||
RwLock(InnerRwLock::new(inner))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn into_inner(self) -> T {
|
||||
self.0.into_inner()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
self.0.get_mut()
|
||||
}
|
||||
|
||||
#[cfg(not(parallel_compiler))]
|
||||
#[inline(always)]
|
||||
pub fn read(&self) -> ReadGuard<'_, T> {
|
||||
@ -547,11 +455,6 @@ impl<T> RwLock<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R {
|
||||
f(&*self.read())
|
||||
}
|
||||
|
||||
#[cfg(not(parallel_compiler))]
|
||||
#[inline(always)]
|
||||
pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
|
||||
@ -580,11 +483,6 @@ impl<T> RwLock<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
|
||||
f(&mut *self.write())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn borrow(&self) -> ReadGuard<'_, T> {
|
||||
self.read()
|
||||
@ -633,12 +531,6 @@ impl<T> OneThread<T> {
|
||||
inner,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn into_inner(value: Self) -> T {
|
||||
value.check();
|
||||
value.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for OneThread<T> {
|
||||
|
@ -42,18 +42,9 @@ where
|
||||
pub fn pointer_ref(&self) -> &P::Target {
|
||||
self.raw.pointer_ref()
|
||||
}
|
||||
pub fn pointer_mut(&mut self) -> &mut P::Target
|
||||
where
|
||||
P: std::ops::DerefMut,
|
||||
{
|
||||
self.raw.pointer_mut()
|
||||
}
|
||||
pub fn tag(&self) -> T {
|
||||
self.raw.tag()
|
||||
}
|
||||
pub fn set_tag(&mut self, tag: T) {
|
||||
self.raw.set_tag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
impl<P, T, const COMPARE_PACKED: bool> std::ops::Deref for TaggedPtr<P, T, COMPARE_PACKED>
|
||||
|
@ -41,10 +41,4 @@ impl<T: Idx> WorkQueue<T> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if nothing is enqueued.
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.deque.is_empty()
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
|
||||
pub fn new(at_args: &'a [String], callbacks: &'b mut (dyn Callbacks + Send)) -> Self {
|
||||
Self { at_args, callbacks, file_loader: None, emitter: None, make_codegen_backend: None }
|
||||
}
|
||||
/// Used by cg_clif.
|
||||
pub fn set_make_codegen_backend(
|
||||
&mut self,
|
||||
make_codegen_backend: Option<
|
||||
@ -155,10 +156,13 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
|
||||
self.make_codegen_backend = make_codegen_backend;
|
||||
self
|
||||
}
|
||||
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self {
|
||||
self.emitter = emitter;
|
||||
self
|
||||
/// Used by RLS.
|
||||
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self
|
||||
{
|
||||
self.emitter = emitter;
|
||||
self
|
||||
}
|
||||
/// Used by RLS.
|
||||
pub fn set_file_loader(
|
||||
&mut self,
|
||||
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
||||
|
@ -108,13 +108,6 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
|
||||
/// (Rust does not yet support upcasting from a trait object to
|
||||
/// an object for one of its super-traits.)
|
||||
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn;
|
||||
|
||||
/// Computes an user-readable representation of a path, if possible.
|
||||
fn node_path(&self, id: hir::HirId) -> Option<String> {
|
||||
self.hir_map().and_then(|map| map.def_path_from_hir_id(id)).map(|path| {
|
||||
path.data.into_iter().map(|elem| elem.data.to_string()).collect::<Vec<_>>().join("::")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct NoAnn<'hir> {
|
||||
@ -327,10 +320,6 @@ impl<'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'tcx> {
|
||||
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
|
||||
self
|
||||
}
|
||||
|
||||
fn node_path(&self, id: hir::HirId) -> Option<String> {
|
||||
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id(id).to_def_id()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
|
||||
|
@ -69,10 +69,6 @@ impl DiagnosticStyledString {
|
||||
pub fn highlighted<S: Into<String>>(t: S) -> DiagnosticStyledString {
|
||||
DiagnosticStyledString(vec![StringPart::Highlighted(t.into())])
|
||||
}
|
||||
|
||||
pub fn content(&self) -> String {
|
||||
self.0.iter().map(|x| x.content()).collect::<String>()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@ -81,14 +77,6 @@ pub enum StringPart {
|
||||
Highlighted(String),
|
||||
}
|
||||
|
||||
impl StringPart {
|
||||
pub fn content(&self) -> &str {
|
||||
match self {
|
||||
&StringPart::Normal(ref s) | &StringPart::Highlighted(ref s) => s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Diagnostic {
|
||||
pub fn new(level: Level, message: &str) -> Self {
|
||||
Diagnostic::new_with_code(level, None, message)
|
||||
@ -156,7 +144,7 @@ impl Diagnostic {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn note_expected_found(
|
||||
crate fn note_expected_found(
|
||||
&mut self,
|
||||
expected_label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
@ -166,7 +154,7 @@ impl Diagnostic {
|
||||
self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"")
|
||||
}
|
||||
|
||||
pub fn note_unsuccessful_coercion(
|
||||
crate fn note_unsuccessful_coercion(
|
||||
&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
@ -256,33 +244,33 @@ impl Diagnostic {
|
||||
|
||||
/// Prints the span with a note above it.
|
||||
/// This is like [`Diagnostic::note()`], but it gets its own span.
|
||||
pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
crate fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
self.sub(Level::Note, msg, sp.into(), None);
|
||||
self
|
||||
}
|
||||
|
||||
/// Add a warning attached to this diagnostic.
|
||||
pub fn warn(&mut self, msg: &str) -> &mut Self {
|
||||
crate fn warn(&mut self, msg: &str) -> &mut Self {
|
||||
self.sub(Level::Warning, msg, MultiSpan::new(), None);
|
||||
self
|
||||
}
|
||||
|
||||
/// Prints the span with a warning above it.
|
||||
/// This is like [`Diagnostic::warn()`], but it gets its own span.
|
||||
pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
crate fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
self.sub(Level::Warning, msg, sp.into(), None);
|
||||
self
|
||||
}
|
||||
|
||||
/// Add a help message attached to this diagnostic.
|
||||
pub fn help(&mut self, msg: &str) -> &mut Self {
|
||||
crate fn help(&mut self, msg: &str) -> &mut Self {
|
||||
self.sub(Level::Help, msg, MultiSpan::new(), None);
|
||||
self
|
||||
}
|
||||
|
||||
/// Prints the span with some help above it.
|
||||
/// This is like [`Diagnostic::help()`], but it gets its own span.
|
||||
pub fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
crate fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
|
||||
self.sub(Level::Help, msg, sp.into(), None);
|
||||
self
|
||||
}
|
||||
@ -311,36 +299,6 @@ impl Diagnostic {
|
||||
self
|
||||
}
|
||||
|
||||
/// Show multiple suggestions that have multiple parts.
|
||||
/// See also [`Diagnostic::multipart_suggestion()`].
|
||||
pub fn multipart_suggestions(
|
||||
&mut self,
|
||||
msg: &str,
|
||||
suggestions: Vec<Vec<(Span, String)>>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
assert!(!suggestions.is_empty());
|
||||
for s in &suggestions {
|
||||
assert!(!s.is_empty());
|
||||
}
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: suggestions
|
||||
.into_iter()
|
||||
.map(|suggestion| Substitution {
|
||||
parts: suggestion
|
||||
.into_iter()
|
||||
.map(|(span, snippet)| SubstitutionPart { snippet, span })
|
||||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::ShowCode,
|
||||
applicability,
|
||||
tool_metadata: Default::default(),
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
/// Prints out a message with for a multipart suggestion without showing the suggested code.
|
||||
///
|
||||
/// This is intended to be used for suggestions that are obvious in what the changes need to
|
||||
@ -567,7 +525,7 @@ impl Diagnostic {
|
||||
self.code.clone()
|
||||
}
|
||||
|
||||
pub fn set_primary_message<M: Into<String>>(&mut self, msg: M) -> &mut Self {
|
||||
crate fn set_primary_message<M: Into<String>>(&mut self, msg: M) -> &mut Self {
|
||||
self.message[0] = (msg.into(), Style::NoStyle);
|
||||
self
|
||||
}
|
||||
|
@ -257,20 +257,6 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// See [`Diagnostic::multipart_suggestions()`].
|
||||
pub fn multipart_suggestions(
|
||||
&mut self,
|
||||
msg: &str,
|
||||
suggestions: Vec<Vec<(Span, String)>>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
if !self.0.allow_suggestions {
|
||||
return self;
|
||||
}
|
||||
self.0.diagnostic.multipart_suggestions(msg, suggestions, applicability);
|
||||
self
|
||||
}
|
||||
|
||||
/// See [`Diagnostic::tool_only_multipart_suggestion()`].
|
||||
pub fn tool_only_multipart_suggestion(
|
||||
&mut self,
|
||||
|
@ -691,10 +691,6 @@ impl Handler {
|
||||
db
|
||||
}
|
||||
|
||||
pub fn failure(&self, msg: &str) {
|
||||
self.inner.borrow_mut().failure(msg);
|
||||
}
|
||||
|
||||
pub fn fatal(&self, msg: &str) -> FatalError {
|
||||
self.inner.borrow_mut().fatal(msg)
|
||||
}
|
||||
|
@ -13,10 +13,6 @@ impl Registry {
|
||||
Registry { long_descriptions: long_descriptions.iter().copied().collect() }
|
||||
}
|
||||
|
||||
/// This will panic if an invalid error code is passed in
|
||||
pub fn find_description(&self, code: &str) -> Option<&'static str> {
|
||||
self.long_descriptions[code]
|
||||
}
|
||||
/// Returns `InvalidErrorCode` if the code requested does not exist in the
|
||||
/// registry. Otherwise, returns an `Option` where `None` means the error
|
||||
/// code is valid but has no extended information.
|
||||
|
@ -121,16 +121,6 @@ impl Annotation {
|
||||
matches!(self.annotation_type, AnnotationType::MultilineLine(_))
|
||||
}
|
||||
|
||||
pub fn is_multiline(&self) -> bool {
|
||||
matches!(
|
||||
self.annotation_type,
|
||||
AnnotationType::Multiline(_)
|
||||
| AnnotationType::MultilineStart(_)
|
||||
| AnnotationType::MultilineLine(_)
|
||||
| AnnotationType::MultilineEnd(_)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
// Account for usize underflows
|
||||
if self.end_col > self.start_col {
|
||||
|
@ -253,17 +253,6 @@ impl<'a> ExtCtxt<'a> {
|
||||
let pathexpr = self.expr_path(self.path_global(sp, fn_path));
|
||||
self.expr_call(sp, pathexpr, args)
|
||||
}
|
||||
pub fn expr_method_call(
|
||||
&self,
|
||||
span: Span,
|
||||
expr: P<ast::Expr>,
|
||||
ident: Ident,
|
||||
mut args: Vec<P<ast::Expr>>,
|
||||
) -> P<ast::Expr> {
|
||||
args.insert(0, expr);
|
||||
let segment = ast::PathSegment::from_ident(ident.with_span_pos(span));
|
||||
self.expr(span, ast::ExprKind::MethodCall(segment, args, span))
|
||||
}
|
||||
pub fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr> {
|
||||
self.expr(b.span, ast::ExprKind::Block(b, None))
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::tests::string_to_stream;
|
||||
|
||||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::{TokenStream, TokenStreamBuilder, TokenTree};
|
||||
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenStreamBuilder, TokenTree};
|
||||
use rustc_span::with_default_session_globals;
|
||||
use rustc_span::{BytePos, Span, Symbol};
|
||||
use smallvec::smallvec;
|
||||
@ -14,6 +14,10 @@ fn sp(a: u32, b: u32) -> Span {
|
||||
Span::with_root_ctxt(BytePos(a), BytePos(b))
|
||||
}
|
||||
|
||||
fn joint(tree: TokenTree) -> TokenStream {
|
||||
TokenStream::new(vec![(tree, Spacing::Joint)])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_concat() {
|
||||
with_default_session_globals(|| {
|
||||
@ -99,8 +103,8 @@ fn test_is_empty() {
|
||||
fn test_dotdotdot() {
|
||||
with_default_session_globals(|| {
|
||||
let mut builder = TokenStreamBuilder::new();
|
||||
builder.push(TokenTree::token(token::Dot, sp(0, 1)).joint());
|
||||
builder.push(TokenTree::token(token::Dot, sp(1, 2)).joint());
|
||||
builder.push(joint(TokenTree::token(token::Dot, sp(0, 1))));
|
||||
builder.push(joint(TokenTree::token(token::Dot, sp(1, 2))));
|
||||
builder.push(TokenTree::token(token::Dot, sp(2, 3)));
|
||||
let stream = builder.build();
|
||||
assert!(stream.eq_unspanned(&string_to_ts("...")));
|
||||
|
@ -413,10 +413,6 @@ impl<'a> Id<'a> {
|
||||
pub fn as_slice(&'a self) -> &'a str {
|
||||
&*self.name
|
||||
}
|
||||
|
||||
pub fn name(self) -> Cow<'a, str> {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
|
||||
/// Each instance of a type that implements `Label<C>` maps to a
|
||||
@ -484,10 +480,6 @@ impl<'a> LabelText<'a> {
|
||||
LabelStr(s.into())
|
||||
}
|
||||
|
||||
pub fn escaped<S: Into<Cow<'a, str>>>(s: S) -> LabelText<'a> {
|
||||
EscStr(s.into())
|
||||
}
|
||||
|
||||
pub fn html<S: Into<Cow<'a, str>>>(s: S) -> LabelText<'a> {
|
||||
HtmlStr(s.into())
|
||||
}
|
||||
@ -543,11 +535,6 @@ impl<'a> LabelText<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Puts `prefix` on a line above this label, with a blank line separator.
|
||||
pub fn prefix_line(self, prefix: LabelText<'_>) -> LabelText<'static> {
|
||||
prefix.suffix_line(self)
|
||||
}
|
||||
|
||||
/// Puts `suffix` on a line below this label, with a blank line separator.
|
||||
pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
|
||||
let mut prefix = self.pre_escaped_content().into_owned();
|
||||
@ -602,11 +589,6 @@ pub enum RenderOption {
|
||||
DarkTheme,
|
||||
}
|
||||
|
||||
/// Returns vec holding all the default render options.
|
||||
pub fn default_options() -> Vec<RenderOption> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
/// Renders directed graph `g` into the writer `w` in DOT syntax.
|
||||
/// (Simple wrapper around `render_opts` that passes a default set of options.)
|
||||
pub fn render<'a, N, E, G, W>(g: &'a G, w: &mut W) -> io::Result<()>
|
||||
|
@ -111,7 +111,7 @@ impl<'a> Labeller<'a> for LabelledGraph {
|
||||
fn node_label(&'a self, n: &Node) -> LabelText<'a> {
|
||||
match self.node_labels[*n] {
|
||||
Some(l) => LabelStr(l.into()),
|
||||
None => LabelStr(id_name(n).name()),
|
||||
None => LabelStr(id_name(n).name),
|
||||
}
|
||||
}
|
||||
fn edge_label(&'a self, e: &&'a Edge) -> LabelText<'a> {
|
||||
|
@ -87,6 +87,7 @@ impl DefPathTable {
|
||||
hash
|
||||
}
|
||||
|
||||
/// Used by librustdoc for fake DefIds.
|
||||
pub fn num_def_ids(&self) -> usize {
|
||||
self.index_to_key.len()
|
||||
}
|
||||
@ -319,12 +320,6 @@ impl Definitions {
|
||||
self.table.def_path_hash(id.local_def_index)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn def_path_hash_to_def_id(&self, def_path_hash: DefPathHash) -> LocalDefId {
|
||||
let local_def_index = self.table.def_path_hash_to_index[&def_path_hash];
|
||||
LocalDefId { local_def_index }
|
||||
}
|
||||
|
||||
/// Returns the path from the crate root to `index`. The root
|
||||
/// nodes are not included in the path (i.e., this will be an
|
||||
/// empty vector for the crate root). For an inlined item, this
|
||||
|
@ -1,5 +1,5 @@
|
||||
// ignore-tidy-filelength
|
||||
use crate::def::{CtorKind, DefKind, Namespace, Res};
|
||||
use crate::def::{CtorKind, DefKind, Res};
|
||||
use crate::def_id::DefId;
|
||||
crate use crate::hir_id::HirId;
|
||||
use crate::{itemlikevisit, LangItem};
|
||||
@ -2118,15 +2118,6 @@ pub enum ImplItemKind<'hir> {
|
||||
TyAlias(&'hir Ty<'hir>),
|
||||
}
|
||||
|
||||
impl ImplItemKind<'_> {
|
||||
pub fn namespace(&self) -> Namespace {
|
||||
match self {
|
||||
ImplItemKind::TyAlias(..) => Namespace::TypeNS,
|
||||
ImplItemKind::Const(..) | ImplItemKind::Fn(..) => Namespace::ValueNS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The name of the associated type for `Fn` return types.
|
||||
pub const FN_OUTPUT_NAME: Symbol = sym::Output;
|
||||
|
||||
@ -2215,6 +2206,9 @@ impl PrimTy {
|
||||
Self::Str,
|
||||
];
|
||||
|
||||
/// [`PrimTy::name`], but returns a &str instead of a symbol.
|
||||
///
|
||||
/// Used by rustdoc.
|
||||
pub fn name_str(self) -> &'static str {
|
||||
match self {
|
||||
PrimTy::Int(i) => i.name_str(),
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::def_id::{LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use std::fmt;
|
||||
|
||||
/// Uniquely identifies a node in the HIR of the current crate. It is
|
||||
@ -62,69 +61,3 @@ pub const CRATE_HIR_ID: HirId = HirId {
|
||||
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
|
||||
local_id: ItemLocalId::from_u32(0),
|
||||
};
|
||||
|
||||
#[derive(Clone, Default, Debug, Encodable, Decodable)]
|
||||
pub struct HirIdVec<T> {
|
||||
map: IndexVec<LocalDefId, IndexVec<ItemLocalId, T>>,
|
||||
}
|
||||
|
||||
impl<T> HirIdVec<T> {
|
||||
pub fn push_owner(&mut self, id: LocalDefId) {
|
||||
self.map.ensure_contains_elem(id, IndexVec::new);
|
||||
}
|
||||
|
||||
pub fn push(&mut self, id: HirId, value: T) {
|
||||
if id.local_id == ItemLocalId::from_u32(0) {
|
||||
self.push_owner(id.owner);
|
||||
}
|
||||
let submap = &mut self.map[id.owner];
|
||||
let _ret_id = submap.push(value);
|
||||
debug_assert_eq!(_ret_id, id.local_id);
|
||||
}
|
||||
|
||||
pub fn push_sparse(&mut self, id: HirId, value: T)
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
self.map.ensure_contains_elem(id.owner, IndexVec::new);
|
||||
let submap = &mut self.map[id.owner];
|
||||
let i = id.local_id.index();
|
||||
let len = submap.len();
|
||||
if i >= len {
|
||||
submap.extend(std::iter::repeat_with(T::default).take(i - len + 1));
|
||||
}
|
||||
submap[id.local_id] = value;
|
||||
}
|
||||
|
||||
pub fn get(&self, id: HirId) -> Option<&T> {
|
||||
self.map.get(id.owner)?.get(id.local_id)
|
||||
}
|
||||
|
||||
pub fn get_owner(&self, id: LocalDefId) -> &IndexVec<ItemLocalId, T> {
|
||||
&self.map[id]
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
self.map.iter().flat_map(|la| la.iter())
|
||||
}
|
||||
|
||||
pub fn iter_enumerated(&self) -> impl Iterator<Item = (HirId, &T)> {
|
||||
self.map.iter_enumerated().flat_map(|(owner, la)| {
|
||||
la.iter_enumerated().map(move |(local_id, attr)| (HirId { owner, local_id }, attr))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::Index<HirId> for HirIdVec<T> {
|
||||
type Output = T;
|
||||
|
||||
fn index(&self, id: HirId) -> &T {
|
||||
&self.map[id.owner][id.local_id]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::IndexMut<HirId> for HirIdVec<T> {
|
||||
fn index_mut(&mut self, id: HirId) -> &mut T {
|
||||
&mut self.map[id.owner][id.local_id]
|
||||
}
|
||||
}
|
||||
|
@ -89,26 +89,6 @@ impl hir::Pat<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Checks if the pattern contains any patterns that bind something to
|
||||
/// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
|
||||
pub fn contains_bindings(&self) -> bool {
|
||||
self.satisfies(|p| matches!(p.kind, PatKind::Binding(..)))
|
||||
}
|
||||
|
||||
/// Checks if the pattern satisfies the given predicate on some sub-pattern.
|
||||
fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
|
||||
let mut satisfies = false;
|
||||
self.walk_short(|p| {
|
||||
if pred(p) {
|
||||
satisfies = true;
|
||||
false // Found one, can short circuit now.
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
satisfies
|
||||
}
|
||||
|
||||
pub fn simple_ident(&self) -> Option<Ident> {
|
||||
match self.kind {
|
||||
PatKind::Binding(
|
||||
|
@ -221,10 +221,6 @@ pub fn bounds_to_string<'b>(bounds: impl IntoIterator<Item = &'b hir::GenericBou
|
||||
to_string(NO_ANN, |s| s.print_bounds("", bounds))
|
||||
}
|
||||
|
||||
pub fn param_to_string(arg: &hir::Param<'_>) -> String {
|
||||
to_string(NO_ANN, |s| s.print_param(arg))
|
||||
}
|
||||
|
||||
pub fn ty_to_string(ty: &hir::Ty<'_>) -> String {
|
||||
to_string(NO_ANN, |s| s.print_type(ty))
|
||||
}
|
||||
@ -1701,21 +1697,10 @@ impl<'a> State<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_usize(&mut self, i: usize) {
|
||||
self.s.word(i.to_string())
|
||||
}
|
||||
|
||||
pub fn print_name(&mut self, name: Symbol) {
|
||||
self.print_ident(Ident::with_dummy_span(name))
|
||||
}
|
||||
|
||||
pub fn print_for_decl(&mut self, loc: &hir::Local<'_>, coll: &hir::Expr<'_>) {
|
||||
self.print_local_decl(loc);
|
||||
self.s.space();
|
||||
self.word_space("in");
|
||||
self.print_expr(coll)
|
||||
}
|
||||
|
||||
pub fn print_path(&mut self, path: &hir::Path<'_>, colons_before_params: bool) {
|
||||
self.maybe_print_comment(path.span.lo());
|
||||
|
||||
@ -2430,24 +2415,6 @@ impl<'a> State<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_opt_abi_and_extern_if_nondefault(&mut self, opt_abi: Option<Abi>) {
|
||||
match opt_abi {
|
||||
Some(Abi::Rust) => {}
|
||||
Some(abi) => {
|
||||
self.word_nbsp("extern");
|
||||
self.word_nbsp(abi.to_string())
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_extern_opt_abi(&mut self, opt_abi: Option<Abi>) {
|
||||
if let Some(abi) = opt_abi {
|
||||
self.word_nbsp("extern");
|
||||
self.word_nbsp(abi.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_fn_header_info(&mut self, header: hir::FnHeader, vis: &hir::Visibility<'_>) {
|
||||
self.s.word(visibility_qualified(vis, ""));
|
||||
|
||||
|
@ -74,16 +74,6 @@ const BASE_STRUCT: &[&str] =
|
||||
&[label_strs::generics_of, label_strs::predicates_of, label_strs::type_of];
|
||||
|
||||
/// Trait definition `DepNode`s.
|
||||
const BASE_TRAIT_DEF: &[&str] = &[
|
||||
label_strs::associated_item_def_ids,
|
||||
label_strs::generics_of,
|
||||
label_strs::object_safety_violations,
|
||||
label_strs::predicates_of,
|
||||
label_strs::specialization_graph_of,
|
||||
label_strs::trait_def,
|
||||
label_strs::trait_impls_of,
|
||||
];
|
||||
|
||||
/// Extra `DepNode`s for functions and methods.
|
||||
const EXTRA_ASSOCIATED: &[&str] = &[label_strs::associated_item];
|
||||
|
||||
@ -118,10 +108,6 @@ const LABELS_IMPL: &[&[&str]] = &[BASE_HIR, BASE_IMPL];
|
||||
/// Abstract data type (struct, enum, union) `DepNode`s.
|
||||
const LABELS_ADT: &[&[&str]] = &[BASE_HIR, BASE_STRUCT];
|
||||
|
||||
/// Trait definition `DepNode`s.
|
||||
#[allow(dead_code)]
|
||||
const LABELS_TRAIT: &[&[&str]] = &[BASE_HIR, BASE_TRAIT_DEF];
|
||||
|
||||
// FIXME: Struct/Enum/Unions Fields (there is currently no way to attach these)
|
||||
//
|
||||
// Fields are kind of separate from their containers, as they can change independently from
|
||||
|
@ -1266,15 +1266,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
self.resolve_vars_if_possible(t).to_string()
|
||||
}
|
||||
|
||||
pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
|
||||
let tstrs: Vec<String> = ts.iter().map(|t| self.ty_to_string(*t)).collect();
|
||||
format!("({})", tstrs.join(", "))
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_string(&self, t: ty::TraitRef<'tcx>) -> String {
|
||||
self.resolve_vars_if_possible(t).print_only_trait_path().to_string()
|
||||
}
|
||||
|
||||
/// If `TyVar(vid)` resolves to a type, return that type. Else, return the
|
||||
/// universe index of `TyVar(vid)`.
|
||||
pub fn probe_ty_var(&self, vid: TyVid) -> Result<Ty<'tcx>, ty::UniverseIndex> {
|
||||
@ -1704,14 +1695,6 @@ impl<'tcx> TypeTrace<'tcx> {
|
||||
) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: Consts(ExpectedFound::new(a_is_expected, a, b)) }
|
||||
}
|
||||
|
||||
pub fn dummy(tcx: TyCtxt<'tcx>) -> TypeTrace<'tcx> {
|
||||
let err = tcx.ty_error();
|
||||
TypeTrace {
|
||||
cause: ObligationCause::dummy(),
|
||||
values: Types(ExpectedFound { expected: err, found: err }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SubregionOrigin<'tcx> {
|
||||
|
@ -92,11 +92,6 @@ impl<'a, 'tcx> OutlivesEnvironment<'tcx> {
|
||||
&self.region_bound_pairs_map
|
||||
}
|
||||
|
||||
/// Returns ownership of the `free_region_map`.
|
||||
pub fn into_free_region_map(self) -> FreeRegionMap<'tcx> {
|
||||
self.free_region_map
|
||||
}
|
||||
|
||||
/// This is a hack to support the old-skool regionck, which
|
||||
/// processes region constraints from the main function and the
|
||||
/// closure together. In that context, when we enter a closure, we
|
||||
|
@ -186,28 +186,6 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Processes a single ad-hoc region obligation that was not
|
||||
/// registered in advance.
|
||||
pub fn type_must_outlive(
|
||||
&self,
|
||||
region_bound_pairs: &RegionBoundPairs<'tcx>,
|
||||
implicit_region_bound: Option<ty::Region<'tcx>>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
origin: infer::SubregionOrigin<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
region: ty::Region<'tcx>,
|
||||
) {
|
||||
let outlives = &mut TypeOutlives::new(
|
||||
self,
|
||||
self.tcx,
|
||||
region_bound_pairs,
|
||||
implicit_region_bound,
|
||||
param_env,
|
||||
);
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
outlives.type_must_outlive(origin, ty, region);
|
||||
}
|
||||
}
|
||||
|
||||
/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
|
||||
|
@ -309,31 +309,6 @@ pub struct RegionSnapshot {
|
||||
any_unifications: bool,
|
||||
}
|
||||
|
||||
/// When working with placeholder regions, we often wish to find all of
|
||||
/// the regions that are either reachable from a placeholder region, or
|
||||
/// which can reach a placeholder region, or both. We call such regions
|
||||
/// *tainted* regions. This struct allows you to decide what set of
|
||||
/// tainted regions you want.
|
||||
#[derive(Debug)]
|
||||
pub struct TaintDirections {
|
||||
incoming: bool,
|
||||
outgoing: bool,
|
||||
}
|
||||
|
||||
impl TaintDirections {
|
||||
pub fn incoming() -> Self {
|
||||
TaintDirections { incoming: true, outgoing: false }
|
||||
}
|
||||
|
||||
pub fn outgoing() -> Self {
|
||||
TaintDirections { incoming: false, outgoing: true }
|
||||
}
|
||||
|
||||
pub fn both() -> Self {
|
||||
TaintDirections { incoming: true, outgoing: true }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> RegionConstraintStorage<'tcx> {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
@ -472,11 +447,6 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
||||
self.var_infos[vid].universe
|
||||
}
|
||||
|
||||
/// Returns the origin for the given variable.
|
||||
pub fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin {
|
||||
self.var_infos[vid].origin
|
||||
}
|
||||
|
||||
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
|
||||
// cannot add constraints once regions are resolved
|
||||
debug!("RegionConstraintCollector: add_constraint({:?})", constraint);
|
||||
@ -795,16 +765,6 @@ impl<'tcx> VerifyBound<'tcx> {
|
||||
VerifyBound::AnyBound(vec![self, vb])
|
||||
}
|
||||
}
|
||||
|
||||
pub fn and(self, vb: VerifyBound<'tcx>) -> VerifyBound<'tcx> {
|
||||
if self.must_hold() && vb.must_hold() {
|
||||
self
|
||||
} else if self.cannot_hold() && vb.cannot_hold() {
|
||||
self
|
||||
} else {
|
||||
VerifyBound::AllBounds(vec![self, vb])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> RegionConstraintData<'tcx> {
|
||||
|
@ -146,9 +146,7 @@ impl<'tcx> TypeVariableValue<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Instantiate {
|
||||
vid: ty::TyVid,
|
||||
}
|
||||
pub(crate) struct Instantiate {}
|
||||
|
||||
pub(crate) struct Delegate;
|
||||
|
||||
@ -224,7 +222,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
|
||||
// Hack: we only need this so that `types_escaping_snapshot`
|
||||
// can see what has been unified; see the Delegate impl for
|
||||
// more details.
|
||||
self.undo_log.push(Instantiate { vid });
|
||||
self.undo_log.push(Instantiate {});
|
||||
}
|
||||
|
||||
/// Creates a new type variable.
|
||||
@ -346,56 +344,6 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Finds the set of type variables that existed *before* `s`
|
||||
/// but which have only been unified since `s` started, and
|
||||
/// return the types with which they were unified. So if we had
|
||||
/// a type variable `V0`, then we started the snapshot, then we
|
||||
/// created a type variable `V1`, unified `V0` with `T0`, and
|
||||
/// unified `V1` with `T1`, this function would return `{T0}`.
|
||||
pub fn types_escaping_snapshot(&mut self, s: &super::Snapshot<'tcx>) -> Vec<Ty<'tcx>> {
|
||||
let mut new_elem_threshold = u32::MAX;
|
||||
let mut escaping_types = Vec::new();
|
||||
let actions_since_snapshot = self.undo_log.actions_since_snapshot(s);
|
||||
debug!("actions_since_snapshot.len() = {}", actions_since_snapshot.len());
|
||||
for i in 0..actions_since_snapshot.len() {
|
||||
let actions_since_snapshot = self.undo_log.actions_since_snapshot(s);
|
||||
match actions_since_snapshot[i] {
|
||||
super::UndoLog::TypeVariables(UndoLog::Values(sv::UndoLog::NewElem(index))) => {
|
||||
// if any new variables were created during the
|
||||
// snapshot, remember the lower index (which will
|
||||
// always be the first one we see). Note that this
|
||||
// action must precede those variables being
|
||||
// specified.
|
||||
new_elem_threshold = cmp::min(new_elem_threshold, index as u32);
|
||||
debug!("NewElem({}) new_elem_threshold={}", index, new_elem_threshold);
|
||||
}
|
||||
|
||||
super::UndoLog::TypeVariables(UndoLog::Values(sv::UndoLog::Other(
|
||||
Instantiate { vid, .. },
|
||||
))) => {
|
||||
if vid.index < new_elem_threshold {
|
||||
// quick check to see if this variable was
|
||||
// created since the snapshot started or not.
|
||||
let mut eq_relations = ut::UnificationTable::with_log(
|
||||
&mut self.storage.eq_relations,
|
||||
&mut *self.undo_log,
|
||||
);
|
||||
let escaping_type = match eq_relations.probe_value(vid) {
|
||||
TypeVariableValue::Unknown { .. } => bug!(),
|
||||
TypeVariableValue::Known { value } => value,
|
||||
};
|
||||
escaping_types.push(escaping_type);
|
||||
}
|
||||
debug!("SpecifyVar({:?}) new_elem_threshold={}", vid, new_elem_threshold);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
escaping_types
|
||||
}
|
||||
|
||||
/// Returns indices of all variables that are not yet
|
||||
/// instantiated.
|
||||
pub fn unsolved_variables(&mut self) -> Vec<ty::TyVid> {
|
||||
|
@ -165,10 +165,6 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> InferCtxtUndoLogs<'tcx> {
|
||||
pub fn actions_since_snapshot(&self, snapshot: &Snapshot<'tcx>) -> &[UndoLog<'tcx>] {
|
||||
&self.logs[snapshot.undo_len..]
|
||||
}
|
||||
|
||||
pub fn start_snapshot(&mut self) -> Snapshot<'tcx> {
|
||||
self.num_open_snapshots += 1;
|
||||
Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
|
||||
|
@ -481,7 +481,7 @@ fn has_doc(sess: &Session, attr: &ast::Attribute) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
if attr.is_value_str() {
|
||||
if attr.value_str().is_some() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ impl LintStore {
|
||||
self.early_passes.push(Box::new(pass));
|
||||
}
|
||||
|
||||
/// Used by clippy.
|
||||
pub fn register_pre_expansion_pass(
|
||||
&mut self,
|
||||
pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync,
|
||||
@ -862,6 +863,8 @@ impl<'tcx> LateContext<'tcx> {
|
||||
/// // The given `def_id` is that of an `Option` type
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Used by clippy, but should be replaced by diagnostic items eventually.
|
||||
pub fn match_def_path(&self, def_id: DefId, path: &[Symbol]) -> bool {
|
||||
let names = self.get_def_path(def_id);
|
||||
|
||||
|
@ -564,10 +564,6 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||
self.id_to_set.insert(id, self.cur);
|
||||
}
|
||||
|
||||
pub fn build(self) -> LintLevelSets {
|
||||
self.sets
|
||||
}
|
||||
|
||||
pub fn build_map(self) -> LintLevelMap {
|
||||
LintLevelMap { sets: self.sets, id_to_set: self.id_to_set }
|
||||
}
|
||||
|
@ -550,24 +550,6 @@ impl<'hir> Map<'hir> {
|
||||
ParentHirIterator { current_id, map: self }
|
||||
}
|
||||
|
||||
/// Checks if the node is an argument. An argument is a local variable whose
|
||||
/// immediate parent is an item or a closure.
|
||||
pub fn is_argument(&self, id: HirId) -> bool {
|
||||
match self.find(id) {
|
||||
Some(Node::Binding(_)) => (),
|
||||
_ => return false,
|
||||
}
|
||||
matches!(
|
||||
self.find(self.get_parent_node(id)),
|
||||
Some(
|
||||
Node::Item(_)
|
||||
| Node::TraitItem(_)
|
||||
| Node::ImplItem(_)
|
||||
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/// Checks if the node is left-hand side of an assignment.
|
||||
pub fn is_lhs(&self, id: HirId) -> bool {
|
||||
match self.find(self.get_parent_node(id)) {
|
||||
@ -779,17 +761,6 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData<'hir> {
|
||||
match self.find(id) {
|
||||
Some(
|
||||
Node::Ctor(vd)
|
||||
| Node::Item(Item { kind: ItemKind::Struct(vd, _) | ItemKind::Union(vd, _), .. }),
|
||||
) => vd,
|
||||
Some(Node::Variant(variant)) => &variant.data,
|
||||
_ => bug!("expected struct or variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant(&self, id: HirId) -> &'hir Variant<'hir> {
|
||||
match self.find(id) {
|
||||
Some(Node::Variant(variant)) => variant,
|
||||
|
@ -119,11 +119,6 @@ impl<'a> StableHashingContext<'a> {
|
||||
Self::new_with_or_without_spans(sess, krate, definitions, cstore, always_ignore_spans)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn sess(&self) -> &'a Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn while_hashing_hir_bodies<F: FnOnce(&mut Self)>(&mut self, hash_bodies: bool, f: F) {
|
||||
let prev_hash_bodies = self.hash_bodies;
|
||||
|
@ -228,20 +228,12 @@ impl Certainty {
|
||||
Certainty::Ambiguous => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_ambiguous(&self) -> bool {
|
||||
!self.is_proven()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, R> QueryResponse<'tcx, R> {
|
||||
pub fn is_proven(&self) -> bool {
|
||||
self.certainty.is_proven()
|
||||
}
|
||||
|
||||
pub fn is_ambiguous(&self) -> bool {
|
||||
!self.is_proven()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> {
|
||||
|
@ -97,13 +97,6 @@ impl<'tcx> ConstVariableValue<'tcx> {
|
||||
ConstVariableValue::Known { value } => Some(value),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_unknown(&self) -> bool {
|
||||
match *self {
|
||||
ConstVariableValue::Unknown { .. } => true,
|
||||
ConstVariableValue::Known { .. } => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
@ -430,6 +430,8 @@ impl ScopeTree {
|
||||
|
||||
/// Returns `true` if `subscope` is equal to or is lexically nested inside `superscope`, and
|
||||
/// `false` otherwise.
|
||||
///
|
||||
/// Used by clippy.
|
||||
pub fn is_subscope_of(&self, subscope: Scope, superscope: Scope) -> bool {
|
||||
let mut s = subscope;
|
||||
debug!("is_subscope_of({:?}, {:?})", subscope, superscope);
|
||||
|
@ -29,12 +29,6 @@ pub enum StabilityLevel {
|
||||
Stable,
|
||||
}
|
||||
|
||||
impl StabilityLevel {
|
||||
pub fn from_attr_level(level: &attr::StabilityLevel) -> Self {
|
||||
if level.is_stable() { Stable } else { Unstable }
|
||||
}
|
||||
}
|
||||
|
||||
/// An entry in the `depr_map`.
|
||||
#[derive(Clone, HashStable, Debug)]
|
||||
pub struct DeprecationEntry {
|
||||
|
@ -117,17 +117,9 @@ impl CoverageKind {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_counter(&self) -> bool {
|
||||
matches!(self, Self::Counter { .. })
|
||||
}
|
||||
|
||||
pub fn is_expression(&self) -> bool {
|
||||
matches!(self, Self::Expression { .. })
|
||||
}
|
||||
|
||||
pub fn is_unreachable(&self) -> bool {
|
||||
*self == Self::Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for CoverageKind {
|
||||
|
@ -307,16 +307,6 @@ impl<'tcx, Tag> Scalar<Tag> {
|
||||
.unwrap_or_else(|| bug!("Signed value {:#x} does not fit in {} bits", i, size.bits()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_i8(i: i8) -> Self {
|
||||
Self::from_int(i, Size::from_bits(8))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_i16(i: i16) -> Self {
|
||||
Self::from_int(i, Size::from_bits(16))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_i32(i: i32) -> Self {
|
||||
Self::from_int(i, Size::from_bits(32))
|
||||
|
@ -379,24 +379,6 @@ impl<'tcx> Body<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterator over all temporaries.
|
||||
#[inline]
|
||||
pub fn temps_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a {
|
||||
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
|
||||
let local = Local::new(index);
|
||||
if self.local_decls[local].is_user_variable() { None } else { Some(local) }
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an iterator over all user-declared locals.
|
||||
#[inline]
|
||||
pub fn vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a {
|
||||
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
|
||||
let local = Local::new(index);
|
||||
self.local_decls[local].is_user_variable().then_some(local)
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an iterator over all user-declared mutable locals.
|
||||
#[inline]
|
||||
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a {
|
||||
|
@ -264,10 +264,6 @@ impl<'a, 'tcx> ReversePostorder<'a, 'tcx> {
|
||||
|
||||
ReversePostorder { body, blocks, idx: len }
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.idx = self.blocks.len();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reverse_postorder<'a, 'tcx>(body: &'a Body<'tcx>) -> ReversePostorder<'a, 'tcx> {
|
||||
|
@ -1247,12 +1247,6 @@ impl PlaceContext {
|
||||
matches!(self, PlaceContext::MutatingUse(..))
|
||||
}
|
||||
|
||||
/// Returns `true` if this place context represents a use that does not change the value.
|
||||
#[inline]
|
||||
pub fn is_nonmutating_use(&self) -> bool {
|
||||
matches!(self, PlaceContext::NonMutatingUse(..))
|
||||
}
|
||||
|
||||
/// Returns `true` if this place context represents a use.
|
||||
#[inline]
|
||||
pub fn is_use(&self) -> bool {
|
||||
|
@ -44,24 +44,12 @@ pub mod type_op {
|
||||
pub b: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> Eq<'tcx> {
|
||||
pub fn new(a: Ty<'tcx>, b: Ty<'tcx>) -> Self {
|
||||
Self { a, b }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)]
|
||||
pub struct Subtype<'tcx> {
|
||||
pub sub: Ty<'tcx>,
|
||||
pub sup: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> Subtype<'tcx> {
|
||||
pub fn new(sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
|
||||
Self { sub, sup }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, Lift)]
|
||||
pub struct ProvePredicate<'tcx> {
|
||||
pub predicate: Predicate<'tcx>,
|
||||
|
@ -6,7 +6,6 @@ use crate::ty;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_span::Span;
|
||||
|
||||
use super::{Ty, TyCtxt};
|
||||
@ -113,14 +112,6 @@ impl<'tcx> ClosureKind {
|
||||
// This is the initial value used when doing upvar inference.
|
||||
pub const LATTICE_BOTTOM: ClosureKind = ClosureKind::Fn;
|
||||
|
||||
pub fn trait_did(&self, tcx: TyCtxt<'tcx>) -> DefId {
|
||||
match *self {
|
||||
ClosureKind::Fn => tcx.require_lang_item(LangItem::Fn, None),
|
||||
ClosureKind::FnMut => tcx.require_lang_item(LangItem::FnMut, None),
|
||||
ClosureKind::FnOnce => tcx.require_lang_item(LangItem::FnOnce, None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if a type that impls this closure kind
|
||||
/// must also implement `other`.
|
||||
pub fn extends(self, other: ty::ClosureKind) -> bool {
|
||||
@ -377,12 +368,4 @@ impl BorrowKind {
|
||||
UniqueImmBorrow => hir::Mutability::Mut,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_user_str(&self) -> &'static str {
|
||||
match *self {
|
||||
MutBorrow => "mutable",
|
||||
ImmBorrow => "immutable",
|
||||
UniqueImmBorrow => "uniquely immutable",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ pub trait TyDecoder<'tcx>: Decoder {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decode_arena_allocable<'tcx, D, T: ArenaAllocatable<'tcx> + Decodable<D>>(
|
||||
fn decode_arena_allocable<'tcx, D, T: ArenaAllocatable<'tcx> + Decodable<D>>(
|
||||
decoder: &mut D,
|
||||
) -> Result<&'tcx T, D::Error>
|
||||
where
|
||||
@ -198,7 +198,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decode_arena_allocable_slice<'tcx, D, T: ArenaAllocatable<'tcx> + Decodable<D>>(
|
||||
fn decode_arena_allocable_slice<'tcx, D, T: ArenaAllocatable<'tcx> + Decodable<D>>(
|
||||
decoder: &mut D,
|
||||
) -> Result<&'tcx [T], D::Error>
|
||||
where
|
||||
|
@ -14,7 +14,7 @@ use crate::middle::stability;
|
||||
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
|
||||
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
|
||||
use crate::traits;
|
||||
use crate::ty::query::{self, OnDiskCache, TyCtxtAt};
|
||||
use crate::ty::query::{self, OnDiskCache};
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSubsts};
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{
|
||||
@ -2288,11 +2288,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Not })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_nil_ptr(self) -> Ty<'tcx> {
|
||||
self.mk_imm_ptr(self.mk_unit())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
|
||||
self.mk_ty(Array(ty, ty::Const::from_usize(self, n)))
|
||||
@ -2655,21 +2650,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl TyCtxtAt<'tcx> {
|
||||
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
|
||||
#[track_caller]
|
||||
pub fn ty_error(self) -> Ty<'tcx> {
|
||||
self.tcx.ty_error_with_message(self.span, "TyKind::Error constructed but no error reported")
|
||||
}
|
||||
|
||||
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
|
||||
/// ensure it gets used.
|
||||
#[track_caller]
|
||||
pub fn ty_error_with_message(self, msg: &str) -> Ty<'tcx> {
|
||||
self.tcx.ty_error_with_message(self.span, msg)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InternAs<T: ?Sized, R> {
|
||||
type Output;
|
||||
fn intern_with<F>(self, f: F) -> Self::Output
|
||||
|
@ -618,22 +618,12 @@ pub struct ProjectionPredicate<'tcx> {
|
||||
pub type PolyProjectionPredicate<'tcx> = Binder<ProjectionPredicate<'tcx>>;
|
||||
|
||||
impl<'tcx> PolyProjectionPredicate<'tcx> {
|
||||
/// Returns the `DefId` of the associated item being projected.
|
||||
pub fn item_def_id(&self) -> DefId {
|
||||
self.skip_binder().projection_ty.item_def_id
|
||||
}
|
||||
|
||||
/// Returns the `DefId` of the trait of the associated item being projected.
|
||||
#[inline]
|
||||
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId {
|
||||
self.skip_binder().projection_ty.trait_def_id(tcx)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn projection_self_ty(&self) -> Binder<Ty<'tcx>> {
|
||||
self.map_bound(|predicate| predicate.projection_ty.self_ty())
|
||||
}
|
||||
|
||||
/// Get the [PolyTraitRef] required for this projection to be well formed.
|
||||
/// Note that for generic associated types the predicates of the associated
|
||||
/// type also need to be checked.
|
||||
@ -1039,10 +1029,6 @@ impl WithOptConstParam<DefId> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn expect_local(self) -> WithOptConstParam<LocalDefId> {
|
||||
self.as_local().unwrap()
|
||||
}
|
||||
|
||||
pub fn is_local(self) -> bool {
|
||||
self.did.is_local()
|
||||
}
|
||||
@ -1222,11 +1208,6 @@ pub trait WithConstness: Sized {
|
||||
ConstnessAnd { constness, value: self }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_const(self) -> ConstnessAnd<Self> {
|
||||
self.with_constness(Constness::Const)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn without_const(self) -> ConstnessAnd<Self> {
|
||||
self.with_constness(Constness::NotConst)
|
||||
|
@ -977,22 +977,6 @@ impl<T> Binder<T> {
|
||||
Binder(value)
|
||||
}
|
||||
|
||||
/// Wraps `value` in a binder without actually binding any currently
|
||||
/// unbound variables.
|
||||
///
|
||||
/// Note that this will shift all debrujin indices of escaping bound variables
|
||||
/// by 1 to avoid accidential captures.
|
||||
pub fn wrap_nonbinding(tcx: TyCtxt<'tcx>, value: T) -> Binder<T>
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
if value.has_escaping_bound_vars() {
|
||||
Binder::bind(super::fold::shift_vars(tcx, value, 1))
|
||||
} else {
|
||||
Binder::dummy(value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Skips the binder and returns the "bound" value. This is a
|
||||
/// risky thing to do because it's easy to get confused about
|
||||
/// De Bruijn indices and the like. It is usually better to
|
||||
@ -1074,20 +1058,6 @@ impl<T> Binder<T> {
|
||||
{
|
||||
Binder(f(self.0, u.0))
|
||||
}
|
||||
|
||||
/// Splits the contents into two things that share the same binder
|
||||
/// level as the original, returning two distinct binders.
|
||||
///
|
||||
/// `f` should consider bound regions at depth 1 to be free, and
|
||||
/// anything it produces with bound regions at depth 1 will be
|
||||
/// bound in the resulting return values.
|
||||
pub fn split<U, V, F>(self, f: F) -> (Binder<U>, Binder<V>)
|
||||
where
|
||||
F: FnOnce(T) -> (U, V),
|
||||
{
|
||||
let (u, v) = f(self.0);
|
||||
(Binder(u), Binder(v))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Binder<Option<T>> {
|
||||
@ -1157,18 +1127,6 @@ pub struct GenSig<'tcx> {
|
||||
|
||||
pub type PolyGenSig<'tcx> = Binder<GenSig<'tcx>>;
|
||||
|
||||
impl<'tcx> PolyGenSig<'tcx> {
|
||||
pub fn resume_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.resume_ty)
|
||||
}
|
||||
pub fn yield_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.yield_ty)
|
||||
}
|
||||
pub fn return_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.return_ty)
|
||||
}
|
||||
}
|
||||
|
||||
/// Signature of a function type, which we have arbitrarily
|
||||
/// decided to use to refer to the input/output types.
|
||||
///
|
||||
@ -1248,10 +1206,6 @@ impl<'tcx> ParamTy {
|
||||
ParamTy { index, name }
|
||||
}
|
||||
|
||||
pub fn for_self() -> ParamTy {
|
||||
ParamTy::new(0, kw::SelfUpper)
|
||||
}
|
||||
|
||||
pub fn for_def(def: &ty::GenericParamDef) -> ParamTy {
|
||||
ParamTy::new(def.index, def.name)
|
||||
}
|
||||
@ -1269,7 +1223,7 @@ pub struct ParamConst {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
impl<'tcx> ParamConst {
|
||||
impl ParamConst {
|
||||
pub fn new(index: u32, name: Symbol) -> ParamConst {
|
||||
ParamConst { index, name }
|
||||
}
|
||||
@ -1277,10 +1231,6 @@ impl<'tcx> ParamConst {
|
||||
pub fn for_def(def: &ty::GenericParamDef) -> ParamConst {
|
||||
ParamConst::new(def.index, def.name)
|
||||
}
|
||||
|
||||
pub fn to_const(self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||
tcx.mk_const_param(self.index, self.name, ty)
|
||||
}
|
||||
}
|
||||
|
||||
pub type Region<'tcx> = &'tcx RegionKind;
|
||||
@ -1580,35 +1530,6 @@ impl RegionKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// Adjusts any De Bruijn indices so as to make `to_binder` the
|
||||
/// innermost binder. That is, if we have something bound at `to_binder`,
|
||||
/// it will now be bound at INNERMOST. This is an appropriate thing to do
|
||||
/// when moving a region out from inside binders:
|
||||
///
|
||||
/// ```
|
||||
/// for<'a> fn(for<'b> for<'c> fn(&'a u32), _)
|
||||
/// // Binder: D3 D2 D1 ^^
|
||||
/// ```
|
||||
///
|
||||
/// Here, the region `'a` would have the De Bruijn index D3,
|
||||
/// because it is the bound 3 binders out. However, if we wanted
|
||||
/// to refer to that region `'a` in the second argument (the `_`),
|
||||
/// those two binders would not be in scope. In that case, we
|
||||
/// might invoke `shift_out_to_binder(D3)`. This would adjust the
|
||||
/// De Bruijn index of `'a` to D1 (the innermost binder).
|
||||
///
|
||||
/// If we invoke `shift_out_to_binder` and the region is in fact
|
||||
/// bound by one of the binders we are shifting out of, that is an
|
||||
/// error (and should fail an assertion failure).
|
||||
pub fn shifted_out_to_binder(&self, to_binder: ty::DebruijnIndex) -> RegionKind {
|
||||
match *self {
|
||||
ty::ReLateBound(debruijn, r) => {
|
||||
ty::ReLateBound(debruijn.shifted_out_to_binder(to_binder), r)
|
||||
}
|
||||
r => r,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_flags(&self) -> TypeFlags {
|
||||
let mut flags = TypeFlags::empty();
|
||||
|
||||
|
@ -64,10 +64,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn body(&self) -> &'mir mir::Body<'tcx> {
|
||||
self.body
|
||||
}
|
||||
|
||||
/// Returns the underlying `Results`.
|
||||
pub fn results(&self) -> &Results<'tcx, A> {
|
||||
&self.results.borrow()
|
||||
|
@ -226,16 +226,6 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
|
||||
/// Get the current location within the Frame.
|
||||
///
|
||||
/// If this is `Err`, we are not currently executing any particular statement in
|
||||
/// this frame (can happen e.g. during frame initialization, and during unwinding on
|
||||
/// frames without cleanup code).
|
||||
/// We basically abuse `Result` as `Either`.
|
||||
pub fn current_loc(&self) -> Result<mir::Location, Span> {
|
||||
self.loc
|
||||
}
|
||||
|
||||
/// Return the `SourceInfo` of the current instruction.
|
||||
pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
|
||||
self.loc.ok().map(|loc| self.body.source_info(loc))
|
||||
@ -459,11 +449,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
ty.size.truncate(value)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
|
||||
ty.is_sized(self.tcx, self.param_env)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
|
||||
ty.is_freeze(self.tcx, self.param_env)
|
||||
|
@ -71,11 +71,6 @@ pub trait AllocMap<K: Hash + Eq, V> {
|
||||
fn get(&self, k: K) -> Option<&V> {
|
||||
self.get_or(k, || Err(())).ok()
|
||||
}
|
||||
|
||||
/// Mutable lookup.
|
||||
fn get_mut(&mut self, k: K) -> Option<&mut V> {
|
||||
self.get_mut_or(k, || Err(())).ok()
|
||||
}
|
||||
}
|
||||
|
||||
/// Methods of this trait signifies a point where CTFE evaluation would fail
|
||||
|
@ -77,14 +77,6 @@ impl<'tcx, Tag> Immediate<Tag> {
|
||||
pub fn to_scalar(self) -> InterpResult<'tcx, Scalar<Tag>> {
|
||||
self.to_scalar_or_uninit().check_init()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_scalar_pair(self) -> InterpResult<'tcx, (Scalar<Tag>, Scalar<Tag>)> {
|
||||
match self {
|
||||
Immediate::Scalar(..) => bug!("Got a thin pointer where a scalar pair was expected"),
|
||||
Immediate::ScalarPair(a, b) => Ok((a.check_init()?, b.check_init()?)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ScalarPair needs a type to interpret, so we often have an immediate and a type together
|
||||
|
@ -40,22 +40,6 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_subgraph(
|
||||
graph: &'a G,
|
||||
graphviz_name: &str,
|
||||
node_content_fn: NodeContentFn,
|
||||
edge_labels_fn: EdgeLabelsFn,
|
||||
) -> Self {
|
||||
Self {
|
||||
graph,
|
||||
is_subgraph: true,
|
||||
graphviz_name: graphviz_name.to_owned(),
|
||||
graph_label: None,
|
||||
node_content_fn,
|
||||
edge_labels_fn,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_graph_label(&mut self, graph_label: &str) {
|
||||
self.graph_label = Some(graph_label.to_owned());
|
||||
}
|
||||
|
@ -117,10 +117,6 @@ impl<'tcx> MirPatch<'tcx> {
|
||||
self.add_statement(loc, StatementKind::Assign(box (place, rv)));
|
||||
}
|
||||
|
||||
pub fn make_nop(&mut self, loc: Location) {
|
||||
self.make_nop.push(loc);
|
||||
}
|
||||
|
||||
pub fn apply(self, body: &mut Body<'tcx>) {
|
||||
debug!("MirPatch: make nops at: {:?}", self.make_nop);
|
||||
for loc in self.make_nop {
|
||||
|
@ -3,7 +3,6 @@
|
||||
use crate::dep_graph::{DepContext, DepNodeIndex};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::HashMapExt;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
|
||||
use std::hash::Hash;
|
||||
@ -34,13 +33,6 @@ impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> {
|
||||
pub fn insert(&self, key: Key, dep_node: DepNodeIndex, value: Value) {
|
||||
self.hashmap.borrow_mut().insert(key, WithDepNode::new(dep_node, value));
|
||||
}
|
||||
|
||||
pub fn insert_same(&self, key: Key, dep_node: DepNodeIndex, value: Value)
|
||||
where
|
||||
Value: Eq,
|
||||
{
|
||||
self.hashmap.borrow_mut().insert_same(key, WithDepNode::new(dep_node, value));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
|
@ -52,6 +52,7 @@ impl EdgeFilter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn test<K: DepKind>(&self, source: &DepNode<K>, target: &DepNode<K>) -> bool {
|
||||
self.source.test(source) && self.target.test(target)
|
||||
}
|
||||
|
@ -488,8 +488,8 @@ impl<K: DepKind> DepGraph<K> {
|
||||
self.data.is_some() && self.dep_node_index_of_opt(dep_node).is_some()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn dep_node_of(&self, dep_node_index: DepNodeIndex) -> DepNode<K> {
|
||||
#[cfg(debug_assertions)]
|
||||
fn dep_node_of(&self, dep_node_index: DepNodeIndex) -> DepNode<K> {
|
||||
let data = self.data.as_ref().unwrap();
|
||||
let previous = &data.previous;
|
||||
let data = data.current.data.lock();
|
||||
|
@ -35,11 +35,6 @@ impl<K: DepKind> PreviousDepGraph<K> {
|
||||
self.data.nodes[dep_node_index]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn node_to_index(&self, dep_node: &DepNode<K>) -> SerializedDepNodeIndex {
|
||||
self.index[dep_node]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn node_to_index_opt(&self, dep_node: &DepNode<K>) -> Option<SerializedDepNodeIndex> {
|
||||
self.index.get(dep_node).cloned()
|
||||
|
@ -31,10 +31,6 @@ impl<K: DepKind> DepGraphQuery<K> {
|
||||
DepGraphQuery { graph, indices }
|
||||
}
|
||||
|
||||
pub fn contains_node(&self, node: &DepNode<K>) -> bool {
|
||||
self.indices.contains_key(&node)
|
||||
}
|
||||
|
||||
pub fn nodes(&self) -> Vec<&DepNode<K>> {
|
||||
self.graph.all_nodes().iter().map(|n| &n.data).collect()
|
||||
}
|
||||
|
@ -516,19 +516,6 @@ impl<'tcx> SaveContext<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_trait_ref_data(&self, trait_ref: &hir::TraitRef<'_>) -> Option<Ref> {
|
||||
self.lookup_def_id(trait_ref.hir_ref_id).and_then(|def_id| {
|
||||
let span = trait_ref.path.span;
|
||||
if generated_code(span) {
|
||||
return None;
|
||||
}
|
||||
let sub_span = trait_ref.path.segments.last().unwrap().ident.span;
|
||||
filter!(self.span_utils, sub_span);
|
||||
let span = self.span_from_span(sub_span);
|
||||
Some(Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(def_id) })
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_expr_data(&self, expr: &hir::Expr<'_>) -> Option<Data> {
|
||||
let ty = self.typeck_results().expr_ty_adjusted_opt(expr)?;
|
||||
if matches!(ty.kind(), ty::Error(_)) {
|
||||
@ -784,7 +771,10 @@ impl<'tcx> SaveContext<'tcx> {
|
||||
/// For a given piece of AST defined by the supplied Span and NodeId,
|
||||
/// returns `None` if the node is not macro-generated or the span is malformed,
|
||||
/// else uses the expansion callsite and callee to return some MacroRef.
|
||||
pub fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
|
||||
///
|
||||
/// FIXME: [`dump_visitor::process_macro_use`] should actually dump this data
|
||||
#[allow(dead_code)]
|
||||
fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
|
||||
if !generated_code(span) {
|
||||
return None;
|
||||
}
|
||||
|
@ -505,6 +505,7 @@ impl<'a> From<&'a ExternDepSpec> for rustc_lint_defs::ExternDepSpec {
|
||||
}
|
||||
|
||||
impl Externs {
|
||||
/// Used for testing.
|
||||
pub fn new(data: BTreeMap<String, ExternEntry>) -> Externs {
|
||||
Externs(data)
|
||||
}
|
||||
@ -604,13 +605,6 @@ impl Input {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_input(&mut self) -> Option<&mut String> {
|
||||
match *self {
|
||||
Input::File(_) => None,
|
||||
Input::Str { ref mut input, .. } => Some(input),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn source_name(&self) -> FileName {
|
||||
match *self {
|
||||
Input::File(ref ifile) => ifile.clone().into(),
|
||||
@ -778,12 +772,6 @@ impl Options {
|
||||
|| self.debugging_opts.query_dep_graph
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn enable_dep_node_debug_strs(&self) -> bool {
|
||||
cfg!(debug_assertions)
|
||||
&& (self.debugging_opts.query_dep_graph || self.debugging_opts.incremental_info)
|
||||
}
|
||||
|
||||
pub fn file_path_mapping(&self) -> FilePathMapping {
|
||||
FilePathMapping::new(self.remap_path_prefix.clone())
|
||||
}
|
||||
@ -1060,9 +1048,6 @@ mod opt {
|
||||
pub fn flag_s(a: S, b: S, c: S) -> R {
|
||||
stable(longer(a, b), move |opts| opts.optflag(a, b, c))
|
||||
}
|
||||
pub fn flagopt_s(a: S, b: S, c: S, d: S) -> R {
|
||||
stable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
|
||||
}
|
||||
pub fn flagmulti_s(a: S, b: S, c: S) -> R {
|
||||
stable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
|
||||
}
|
||||
@ -1073,15 +1058,6 @@ mod opt {
|
||||
pub fn multi(a: S, b: S, c: S, d: S) -> R {
|
||||
unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
|
||||
}
|
||||
pub fn flag(a: S, b: S, c: S) -> R {
|
||||
unstable(longer(a, b), move |opts| opts.optflag(a, b, c))
|
||||
}
|
||||
pub fn flagopt(a: S, b: S, c: S, d: S) -> R {
|
||||
unstable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
|
||||
}
|
||||
pub fn flagmulti(a: S, b: S, c: S) -> R {
|
||||
unstable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the "short" subset of the rustc command line options,
|
||||
@ -2459,7 +2435,7 @@ crate mod dep_tracking {
|
||||
}
|
||||
|
||||
// This is a stable hash because BTreeMap is a sorted container
|
||||
pub fn stable_hash(
|
||||
crate fn stable_hash(
|
||||
sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
|
||||
hasher: &mut DefaultHasher,
|
||||
error_format: ErrorOutputType,
|
||||
|
@ -140,6 +140,7 @@ pub struct ParseSess {
|
||||
}
|
||||
|
||||
impl ParseSess {
|
||||
/// Used for testing.
|
||||
pub fn new(file_path_mapping: FilePathMapping) -> Self {
|
||||
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
||||
let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, None, Some(sm.clone()));
|
||||
|
@ -20,7 +20,7 @@ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
|
||||
use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
||||
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
||||
use rustc_lint_defs::FutureBreakage;
|
||||
pub use rustc_span::crate_disambiguator::CrateDisambiguator;
|
||||
use rustc_span::edition::Edition;
|
||||
@ -241,8 +241,7 @@ pub struct PerfStats {
|
||||
enum DiagnosticBuilderMethod {
|
||||
Note,
|
||||
SpanNote,
|
||||
SpanSuggestion(String), // suggestion
|
||||
// Add more variants as needed to support one-time diagnostics.
|
||||
// Add more variants as needed to support one-time diagnostics.
|
||||
}
|
||||
|
||||
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
||||
@ -365,14 +364,6 @@ impl Session {
|
||||
pub fn struct_span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_span_warn(sp, msg)
|
||||
}
|
||||
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_span_warn_with_code(sp, msg, code)
|
||||
}
|
||||
pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_warn(msg)
|
||||
}
|
||||
@ -411,37 +402,16 @@ impl Session {
|
||||
) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
|
||||
}
|
||||
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_fatal(msg)
|
||||
}
|
||||
|
||||
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
|
||||
self.diagnostic().span_fatal(sp, msg).raise()
|
||||
}
|
||||
pub fn span_fatal_with_code<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> ! {
|
||||
self.diagnostic().span_fatal_with_code(sp, msg, code).raise()
|
||||
}
|
||||
pub fn fatal(&self, msg: &str) -> ! {
|
||||
self.diagnostic().fatal(msg).raise()
|
||||
}
|
||||
pub fn span_err_or_warn<S: Into<MultiSpan>>(&self, is_warning: bool, sp: S, msg: &str) {
|
||||
if is_warning {
|
||||
self.span_warn(sp, msg);
|
||||
} else {
|
||||
self.span_err(sp, msg);
|
||||
}
|
||||
}
|
||||
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
self.diagnostic().span_err(sp, msg)
|
||||
}
|
||||
pub fn span_err_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: DiagnosticId) {
|
||||
self.diagnostic().span_err_with_code(sp, &msg, code)
|
||||
}
|
||||
pub fn err(&self, msg: &str) {
|
||||
self.diagnostic().err(msg)
|
||||
}
|
||||
@ -481,18 +451,9 @@ impl Session {
|
||||
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
self.diagnostic().span_warn(sp, msg)
|
||||
}
|
||||
pub fn span_warn_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: DiagnosticId) {
|
||||
self.diagnostic().span_warn_with_code(sp, msg, code)
|
||||
}
|
||||
pub fn warn(&self, msg: &str) {
|
||||
self.diagnostic().warn(msg)
|
||||
}
|
||||
pub fn opt_span_warn<S: Into<MultiSpan>>(&self, opt_sp: Option<S>, msg: &str) {
|
||||
match opt_sp {
|
||||
Some(sp) => self.span_warn(sp, msg),
|
||||
None => self.warn(msg),
|
||||
}
|
||||
}
|
||||
/// Delay a span_bug() call until abort_if_errors()
|
||||
#[track_caller]
|
||||
pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
@ -519,9 +480,6 @@ impl Session {
|
||||
pub fn note_without_error(&self, msg: &str) {
|
||||
self.diagnostic().note_without_error(msg)
|
||||
}
|
||||
pub fn span_note_without_error<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
self.diagnostic().span_note_without_error(sp, msg)
|
||||
}
|
||||
pub fn struct_note_without_error(&self, msg: &str) -> DiagnosticBuilder<'_> {
|
||||
self.diagnostic().struct_note_without_error(msg)
|
||||
}
|
||||
@ -551,15 +509,6 @@ impl Session {
|
||||
let span = span_maybe.expect("`span_note` needs a span");
|
||||
diag_builder.span_note(span, message);
|
||||
}
|
||||
DiagnosticBuilderMethod::SpanSuggestion(suggestion) => {
|
||||
let span = span_maybe.expect("`span_suggestion_*` needs a span");
|
||||
diag_builder.span_suggestion(
|
||||
span,
|
||||
message,
|
||||
suggestion,
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -589,23 +538,6 @@ impl Session {
|
||||
self.diag_once(diag_builder, DiagnosticBuilderMethod::Note, msg_id, message, None);
|
||||
}
|
||||
|
||||
pub fn diag_span_suggestion_once<'a, 'b>(
|
||||
&'a self,
|
||||
diag_builder: &'b mut DiagnosticBuilder<'a>,
|
||||
msg_id: DiagnosticMessageId,
|
||||
span: Span,
|
||||
message: &str,
|
||||
suggestion: String,
|
||||
) {
|
||||
self.diag_once(
|
||||
diag_builder,
|
||||
DiagnosticBuilderMethod::SpanSuggestion(suggestion),
|
||||
msg_id,
|
||||
message,
|
||||
Some(span),
|
||||
);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn source_map(&self) -> &SourceMap {
|
||||
self.parse_sess.source_map()
|
||||
@ -631,9 +563,6 @@ impl Session {
|
||||
pub fn verify_llvm_ir(&self) -> bool {
|
||||
self.opts.debugging_opts.verify_llvm_ir || option_env!("RUSTC_VERIFY_LLVM_IR").is_some()
|
||||
}
|
||||
pub fn borrowck_stats(&self) -> bool {
|
||||
self.opts.debugging_opts.borrowck_stats
|
||||
}
|
||||
pub fn print_llvm_passes(&self) -> bool {
|
||||
self.opts.debugging_opts.print_llvm_passes
|
||||
}
|
||||
@ -890,22 +819,6 @@ impl Session {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
|
||||
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
|
||||
|
||||
if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session {
|
||||
*load_dep_graph = load;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn incr_session_load_dep_graph(&self) -> bool {
|
||||
let incr_comp_session = self.incr_comp_session.borrow();
|
||||
match *incr_comp_session {
|
||||
IncrCompSession::Active { load_dep_graph, .. } => load_dep_graph,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_incr_comp_session(
|
||||
&self,
|
||||
session_dir: PathBuf,
|
||||
|
@ -160,6 +160,8 @@ impl DefPathHash {
|
||||
}
|
||||
|
||||
/// Returns the crate-local part of the [DefPathHash].
|
||||
///
|
||||
/// Used for tests.
|
||||
#[inline]
|
||||
pub fn local_hash(&self) -> u64 {
|
||||
self.0.as_value().1
|
||||
|
@ -1176,11 +1176,7 @@ pub fn decode_syntax_context<
|
||||
Ok(new_ctxt)
|
||||
}
|
||||
|
||||
pub fn num_syntax_ctxts() -> usize {
|
||||
HygieneData::with(|data| data.syntax_context_data.len())
|
||||
}
|
||||
|
||||
pub fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>(
|
||||
fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>(
|
||||
ctxts: impl Iterator<Item = SyntaxContext>,
|
||||
mut f: F,
|
||||
) -> Result<(), E> {
|
||||
@ -1193,7 +1189,7 @@ pub fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) ->
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>(
|
||||
fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>(
|
||||
expns: impl Iterator<Item = ExpnId>,
|
||||
mut f: F,
|
||||
) -> Result<(), E> {
|
||||
@ -1206,16 +1202,6 @@ pub fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn for_all_data<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>(
|
||||
mut f: F,
|
||||
) -> Result<(), E> {
|
||||
let all_data = HygieneData::with(|data| data.syntax_context_data.clone());
|
||||
for (i, data) in all_data.into_iter().enumerate() {
|
||||
f((i as u32, SyntaxContext(i as u32), &data))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl<E: Encoder> Encodable<E> for ExpnId {
|
||||
default fn encode(&self, _: &mut E) -> Result<(), E::Error> {
|
||||
panic!("cannot encode `ExpnId` with `{}`", std::any::type_name::<E>());
|
||||
@ -1228,14 +1214,6 @@ impl<D: Decoder> Decodable<D> for ExpnId {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_all_expn_data<E, F: FnMut(u32, &ExpnData) -> Result<(), E>>(mut f: F) -> Result<(), E> {
|
||||
let all_data = HygieneData::with(|data| data.expn_data.clone());
|
||||
for (i, data) in all_data.into_iter().enumerate() {
|
||||
f(i as u32, &data.unwrap_or_else(|| panic!("Missing ExpnData!")))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn raw_encode_syntax_context<E: Encoder>(
|
||||
ctxt: SyntaxContext,
|
||||
context: &HygieneEncodeContext,
|
||||
|
@ -1037,10 +1037,6 @@ pub enum ExternalSourceKind {
|
||||
}
|
||||
|
||||
impl ExternalSource {
|
||||
pub fn is_absent(&self) -> bool {
|
||||
!matches!(self, ExternalSource::Foreign { kind: ExternalSourceKind::Present(_), .. })
|
||||
}
|
||||
|
||||
pub fn get_source(&self) -> Option<&Lrc<String>> {
|
||||
match self {
|
||||
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
|
||||
@ -1433,9 +1429,6 @@ impl SourceFile {
|
||||
self.src.is_none()
|
||||
}
|
||||
|
||||
pub fn byte_length(&self) -> u32 {
|
||||
self.end_pos.0 - self.start_pos.0
|
||||
}
|
||||
pub fn count_lines(&self) -> usize {
|
||||
self.lines.len()
|
||||
}
|
||||
|
@ -8,12 +8,6 @@ pub struct ImpliedOutlivesBounds<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> ImpliedOutlivesBounds<'tcx> {
|
||||
pub fn new(ty: Ty<'tcx>) -> Self {
|
||||
ImpliedOutlivesBounds { ty }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
|
||||
type QueryResponse = Vec<OutlivesBound<'tcx>>;
|
||||
|
||||
|
@ -516,7 +516,7 @@ fn check_needless_must_use(
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if !attr.is_value_str() && is_must_use_ty(cx, return_ty(cx, item_id)) {
|
||||
} else if !attr.value_str().is_some() && is_must_use_ty(cx, return_ty(cx, item_id)) {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
DOUBLE_MUST_USE,
|
||||
|
@ -95,7 +95,7 @@ impl MissingDoc {
|
||||
|
||||
let has_doc = attrs
|
||||
.iter()
|
||||
.any(|a| a.is_doc_comment() || a.doc_str().is_some() || a.is_value_str() || Self::has_include(a.meta()));
|
||||
.any(|a| a.is_doc_comment() || a.doc_str().is_some() || a.value_str().is_some() || Self::has_include(a.meta()));
|
||||
if !has_doc {
|
||||
span_lint(
|
||||
cx,
|
||||
|
Loading…
Reference in New Issue
Block a user